@@ -60,6 +60,19 @@ pub enum LegacyScope<'a> {
60
60
Binding ( & ' a LegacyBinding < ' a > ) ,
61
61
}
62
62
63
+ impl < ' a > LegacyScope < ' a > {
64
+ fn simplify_expansion ( mut invoc : & ' a InvocationData < ' a > ) -> Self {
65
+ while let LegacyScope :: Invocation ( _) = invoc. expansion . get ( ) {
66
+ match invoc. legacy_scope . get ( ) {
67
+ LegacyScope :: Expansion ( new_invoc) => invoc = new_invoc,
68
+ LegacyScope :: Binding ( _) => break ,
69
+ scope @ _ => return scope,
70
+ }
71
+ }
72
+ LegacyScope :: Expansion ( invoc)
73
+ }
74
+ }
75
+
63
76
pub struct LegacyBinding < ' a > {
64
77
parent : LegacyScope < ' a > ,
65
78
kind : LegacyBindingKind ,
@@ -175,8 +188,11 @@ impl<'a> base::Resolver for Resolver<'a> {
175
188
InvocationKind :: Attr { ref attr, .. } => ( intern ( & * attr. name ( ) ) , attr. span ) ,
176
189
} ;
177
190
178
- let scope = self . invocations [ & scope] . legacy_scope . get ( ) ;
179
- self . resolve_macro_name ( scope, name, true ) . or_else ( || {
191
+ let invocation = self . invocations [ & scope] ;
192
+ if let LegacyScope :: Expansion ( parent) = invocation. legacy_scope . get ( ) {
193
+ invocation. legacy_scope . set ( LegacyScope :: simplify_expansion ( parent) ) ;
194
+ }
195
+ self . resolve_macro_name ( invocation. legacy_scope . get ( ) , name, true ) . or_else ( || {
180
196
let mut err =
181
197
self . session . struct_span_err ( span, & format ! ( "macro undefined: '{}!'" , name) ) ;
182
198
self . suggest_macro_name ( & name. as_str ( ) , & mut err) ;
0 commit comments