@@ -22,7 +22,7 @@ pub struct ModPath {
22
22
segments : Vec < Name > ,
23
23
}
24
24
25
- #[ derive( Debug , Clone , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
25
+ #[ derive( Debug , Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
26
26
pub enum PathKind {
27
27
Plain ,
28
28
/// `self::` is `Super(0)`
@@ -119,7 +119,7 @@ pub struct Path {
119
119
type_anchor : Option < Interned < TypeRef > > ,
120
120
mod_path : Interned < ModPath > ,
121
121
/// Invariant: the same len as `self.mod_path.segments`
122
- generic_args : Vec < Option < Interned < GenericArgs > > > ,
122
+ generic_args : Box < [ Option < Interned < GenericArgs > > ] > ,
123
123
}
124
124
125
125
/// Generic arguments to a path segment (e.g. the `i32` in `Option<i32>`). This
@@ -171,9 +171,9 @@ impl Path {
171
171
/// Converts a known mod path to `Path`.
172
172
pub fn from_known_path (
173
173
path : ModPath ,
174
- generic_args : Vec < Option < Interned < GenericArgs > > > ,
174
+ generic_args : impl Into < Box < [ Option < Interned < GenericArgs > > ] > > ,
175
175
) -> Path {
176
- Path { type_anchor : None , mod_path : Interned :: new ( path) , generic_args }
176
+ Path { type_anchor : None , mod_path : Interned :: new ( path) , generic_args : generic_args . into ( ) }
177
177
}
178
178
179
179
pub fn kind ( & self ) -> & PathKind {
@@ -187,7 +187,7 @@ impl Path {
187
187
pub fn segments ( & self ) -> PathSegments < ' _ > {
188
188
PathSegments {
189
189
segments : self . mod_path . segments . as_slice ( ) ,
190
- generic_args : self . generic_args . as_slice ( ) ,
190
+ generic_args : & self . generic_args ,
191
191
}
192
192
}
193
193
@@ -205,14 +205,14 @@ impl Path {
205
205
self . mod_path . kind . clone ( ) ,
206
206
self . mod_path . segments [ ..self . mod_path . segments . len ( ) - 1 ] . iter ( ) . cloned ( ) ,
207
207
) ) ,
208
- generic_args : self . generic_args [ ..self . generic_args . len ( ) - 1 ] . to_vec ( ) ,
208
+ generic_args : self . generic_args [ ..self . generic_args . len ( ) - 1 ] . to_vec ( ) . into ( ) ,
209
209
} ;
210
210
Some ( res)
211
211
}
212
212
213
213
pub fn is_self_type ( & self ) -> bool {
214
214
self . type_anchor . is_none ( )
215
- && self . generic_args == [ None ]
215
+ && * self . generic_args == [ None ]
216
216
&& self . mod_path . as_ident ( ) == Some ( & name ! ( Self ) )
217
217
}
218
218
}
@@ -286,7 +286,7 @@ impl From<Name> for Path {
286
286
Path {
287
287
type_anchor : None ,
288
288
mod_path : Interned :: new ( ModPath :: from_segments ( PathKind :: Plain , iter:: once ( name) ) ) ,
289
- generic_args : vec ! [ None ] ,
289
+ generic_args : Box :: new ( [ None ] ) ,
290
290
}
291
291
}
292
292
}
0 commit comments