@@ -118,11 +118,9 @@ impl<'a> base::Resolver for Resolver<'a> {
118
118
& mut self , expansion : ExpnId , fragment : & AstFragment , derives : & [ ExpnId ]
119
119
) {
120
120
// Fill in some data for derives if the fragment is from a derive container.
121
- let parent_scope = self . invocation_parent_scopes [ & expansion] . clone ( ) ;
121
+ let parent_scope = self . invocation_parent_scopes [ & expansion] ;
122
122
let parent_def = self . definitions . invocation_parent ( expansion) ;
123
- self . invocation_parent_scopes . extend (
124
- derives. iter ( ) . map ( |& derive| ( derive, parent_scope. clone ( ) ) )
125
- ) ;
123
+ self . invocation_parent_scopes . extend ( derives. iter ( ) . map ( |& derive| ( derive, parent_scope) ) ) ;
126
124
for & derive_invoc_id in derives {
127
125
self . definitions . set_invocation_parent ( derive_invoc_id, parent_def) ;
128
126
}
@@ -152,14 +150,14 @@ impl<'a> base::Resolver for Resolver<'a> {
152
150
153
151
fn resolve_macro_invocation ( & mut self , invoc : & Invocation , invoc_id : ExpnId , force : bool )
154
152
-> Result < Option < Lrc < SyntaxExtension > > , Indeterminate > {
155
- let parent_scope = & self . invocation_parent_scopes [ & invoc_id] . clone ( ) ;
153
+ let parent_scope = self . invocation_parent_scopes [ & invoc_id] ;
156
154
let ( path, kind, derives, after_derive) = match invoc. kind {
157
155
InvocationKind :: Attr { ref attr, ref derives, after_derive, .. } =>
158
- ( & attr. path , MacroKind :: Attr , derives . clone ( ) , after_derive) ,
156
+ ( & attr. path , MacroKind :: Attr , self . arenas . alloc_ast_paths ( derives ) , after_derive) ,
159
157
InvocationKind :: Bang { ref mac, .. } =>
160
- ( & mac. path , MacroKind :: Bang , Vec :: new ( ) , false ) ,
158
+ ( & mac. path , MacroKind :: Bang , & [ ] [ .. ] , false ) ,
161
159
InvocationKind :: Derive { ref path, .. } =>
162
- ( path, MacroKind :: Derive , Vec :: new ( ) , false ) ,
160
+ ( path, MacroKind :: Derive , & [ ] [ .. ] , false ) ,
163
161
InvocationKind :: DeriveContainer { ref derives, .. } => {
164
162
// Block expansion of derives in the container until we know whether one of them
165
163
// is a built-in `Copy`. Skip the resolution if there's only one derive - either
@@ -169,7 +167,7 @@ impl<'a> base::Resolver for Resolver<'a> {
169
167
if derives. len ( ) > 1 {
170
168
for path in derives {
171
169
match self . resolve_macro_path ( path, Some ( MacroKind :: Derive ) ,
172
- parent_scope, true , force) {
170
+ & parent_scope, true , force) {
173
171
Ok ( ( Some ( ref ext) , _) ) if ext. is_derive_copy => {
174
172
self . add_derives ( invoc. expansion_data . id , SpecialDerives :: COPY ) ;
175
173
return Ok ( None ) ;
@@ -184,7 +182,7 @@ impl<'a> base::Resolver for Resolver<'a> {
184
182
} ;
185
183
186
184
// Derives are not included when `invocations` are collected, so we have to add them here.
187
- let parent_scope = & ParentScope { derives, ..parent_scope. clone ( ) } ;
185
+ let parent_scope = & ParentScope { derives, ..parent_scope } ;
188
186
let ( ext, res) = self . smart_resolve_macro_path ( path, kind, parent_scope, force) ?;
189
187
190
188
let span = invoc. span ( ) ;
@@ -324,7 +322,7 @@ impl<'a> Resolver<'a> {
324
322
if trace {
325
323
let kind = kind. expect ( "macro kind must be specified if tracing is enabled" ) ;
326
324
self . multi_segment_macro_resolutions
327
- . push ( ( path, path_span, kind, parent_scope. clone ( ) , res. ok ( ) ) ) ;
325
+ . push ( ( path, path_span, kind, * parent_scope, res. ok ( ) ) ) ;
328
326
}
329
327
330
328
self . prohibit_imported_non_macro_attrs ( None , res. ok ( ) , path_span) ;
@@ -341,7 +339,7 @@ impl<'a> Resolver<'a> {
341
339
if trace {
342
340
let kind = kind. expect ( "macro kind must be specified if tracing is enabled" ) ;
343
341
self . single_segment_macro_resolutions
344
- . push ( ( path[ 0 ] . ident , kind, parent_scope. clone ( ) , binding. ok ( ) ) ) ;
342
+ . push ( ( path[ 0 ] . ident , kind, * parent_scope, binding. ok ( ) ) ) ;
345
343
}
346
344
347
345
let res = binding. map ( |binding| binding. res ( ) ) ;
@@ -410,8 +408,8 @@ impl<'a> Resolver<'a> {
410
408
let result = match scope {
411
409
Scope :: DeriveHelpers => {
412
410
let mut result = Err ( Determinacy :: Determined ) ;
413
- for derive in & parent_scope. derives {
414
- let parent_scope = & ParentScope { derives : Vec :: new ( ) , ..* parent_scope } ;
411
+ for derive in parent_scope. derives {
412
+ let parent_scope = & ParentScope { derives : & [ ] , ..* parent_scope } ;
415
413
match this. resolve_macro_path ( derive, Some ( MacroKind :: Derive ) ,
416
414
parent_scope, true , force) {
417
415
Ok ( ( Some ( ext) , _) ) => if ext. helper_attrs . contains ( & ident. name ) {
@@ -457,7 +455,7 @@ impl<'a> Resolver<'a> {
457
455
}
458
456
}
459
457
Scope :: Module ( module) => {
460
- let adjusted_parent_scope = & ParentScope { module, ..parent_scope. clone ( ) } ;
458
+ let adjusted_parent_scope = & ParentScope { module, ..* parent_scope } ;
461
459
let binding = this. resolve_ident_in_module_unadjusted_ext (
462
460
ModuleOrUniformRoot :: Module ( module) ,
463
461
ident,
0 commit comments