@@ -75,12 +75,9 @@ impl<'a> LegacyScope<'a> {
75
75
76
76
pub struct LegacyBinding < ' a > {
77
77
parent : LegacyScope < ' a > ,
78
- kind : LegacyBindingKind ,
79
- }
80
-
81
- pub enum LegacyBindingKind {
82
- MacroRules ( ast:: Name , Rc < SyntaxExtension > , Span ) ,
83
- MacroUse ( LegacyImports ) ,
78
+ name : ast:: Name ,
79
+ ext : Rc < SyntaxExtension > ,
80
+ span : Span ,
84
81
}
85
82
86
83
pub type LegacyImports = FnvHashMap < ast:: Name , ( Rc < SyntaxExtension > , Span ) > ;
@@ -123,10 +120,11 @@ impl<'a> base::Resolver for Resolver<'a> {
123
120
}
124
121
if def. use_locally {
125
122
let invocation = self . invocations [ & scope] ;
126
- let ext = Rc :: new ( macro_rules:: compile ( & self . session . parse_sess , & def) ) ;
127
123
let binding = self . arenas . alloc_legacy_binding ( LegacyBinding {
128
124
parent : invocation. legacy_scope . get ( ) ,
129
- kind : LegacyBindingKind :: MacroRules ( def. ident . name , ext, def. span ) ,
125
+ name : def. ident . name ,
126
+ ext : Rc :: new ( macro_rules:: compile ( & self . session . parse_sess , & def) ) ,
127
+ span : def. span ,
130
128
} ) ;
131
129
invocation. legacy_scope . set ( LegacyScope :: Binding ( binding) ) ;
132
130
self . macro_names . insert ( def. ident . name ) ;
@@ -208,12 +206,6 @@ impl<'a> Resolver<'a> {
208
206
name : ast:: Name ,
209
207
record_used : bool )
210
208
-> Option < Rc < SyntaxExtension > > {
211
- let check_shadowing = |this : & mut Self , relative_depth, scope, span| {
212
- if record_used && relative_depth > 0 {
213
- this. disallowed_shadowing . push ( ( name, span, scope) ) ;
214
- }
215
- } ;
216
-
217
209
let mut relative_depth: u32 = 0 ;
218
210
loop {
219
211
scope = match scope {
@@ -227,29 +219,18 @@ impl<'a> Resolver<'a> {
227
219
}
228
220
}
229
221
LegacyScope :: Invocation ( invocation) => {
230
- let new_relative_depth = relative_depth. saturating_sub ( 1 ) ;
231
- let mut scope = invocation. legacy_scope . get ( ) ;
232
- if let LegacyScope :: Binding ( binding) = scope {
233
- match binding. kind {
234
- LegacyBindingKind :: MacroUse ( ref imports) => {
235
- if let Some ( & ( ref ext, span) ) = imports. get ( & name) {
236
- check_shadowing ( self , relative_depth, binding. parent , span) ;
237
- return Some ( ext. clone ( ) ) ;
238
- }
239
- } ,
240
- LegacyBindingKind :: MacroRules ( name_, ref ext, span) => {
241
- if name_ == name {
242
- check_shadowing ( self , new_relative_depth, binding. parent , span) ;
243
- return Some ( ext. clone ( ) ) ;
244
- }
245
- }
222
+ relative_depth = relative_depth. saturating_sub ( 1 ) ;
223
+ invocation. legacy_scope . get ( )
224
+ }
225
+ LegacyScope :: Binding ( binding) => {
226
+ if binding. name == name {
227
+ if record_used && relative_depth > 0 {
228
+ self . disallowed_shadowing . push ( ( name, binding. span , binding. parent ) ) ;
246
229
}
247
- scope = binding. parent
230
+ return Some ( binding. ext . clone ( ) ) ;
248
231
}
249
- relative_depth = new_relative_depth;
250
- scope
232
+ binding. parent
251
233
}
252
- _ => unreachable ! ( ) ,
253
234
} ;
254
235
}
255
236
0 commit comments