Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir_def/src/path.rs')
| -rw-r--r-- | crates/hir_def/src/path.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/hir_def/src/path.rs b/crates/hir_def/src/path.rs index a54352439c..5bb8afa5cc 100644 --- a/crates/hir_def/src/path.rs +++ b/crates/hir_def/src/path.rs @@ -22,7 +22,7 @@ pub struct ModPath { segments: Vec<Name>, } -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum PathKind { Plain, /// `self::` is `Super(0)` @@ -119,7 +119,7 @@ pub struct Path { type_anchor: Option<Interned<TypeRef>>, mod_path: Interned<ModPath>, /// Invariant: the same len as `self.mod_path.segments` - generic_args: Vec<Option<Interned<GenericArgs>>>, + generic_args: Box<[Option<Interned<GenericArgs>>]>, } /// Generic arguments to a path segment (e.g. the `i32` in `Option<i32>`). This @@ -171,9 +171,9 @@ impl Path { /// Converts a known mod path to `Path`. pub fn from_known_path( path: ModPath, - generic_args: Vec<Option<Interned<GenericArgs>>>, + generic_args: impl Into<Box<[Option<Interned<GenericArgs>>]>>, ) -> Path { - Path { type_anchor: None, mod_path: Interned::new(path), generic_args } + Path { type_anchor: None, mod_path: Interned::new(path), generic_args: generic_args.into() } } pub fn kind(&self) -> &PathKind { @@ -187,7 +187,7 @@ impl Path { pub fn segments(&self) -> PathSegments<'_> { PathSegments { segments: self.mod_path.segments.as_slice(), - generic_args: self.generic_args.as_slice(), + generic_args: &self.generic_args, } } @@ -205,14 +205,14 @@ impl Path { self.mod_path.kind.clone(), self.mod_path.segments[..self.mod_path.segments.len() - 1].iter().cloned(), )), - generic_args: self.generic_args[..self.generic_args.len() - 1].to_vec(), + generic_args: self.generic_args[..self.generic_args.len() - 1].to_vec().into(), }; Some(res) } pub fn is_self_type(&self) -> bool { self.type_anchor.is_none() - && self.generic_args == [None] + && *self.generic_args == [None] && self.mod_path.as_ident() == Some(&name!(Self)) } } @@ -286,7 +286,7 @@ impl From<Name> for Path { Path { type_anchor: None, mod_path: Interned::new(ModPath::from_segments(PathKind::Plain, iter::once(name))), - generic_args: vec![None], + generic_args: Box::new([None]), } } } |