@@ -60,6 +60,19 @@ pub enum LegacyScope<'a> {
6060 Binding ( & ' a LegacyBinding < ' a > ) ,
6161}
6262
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+
6376pub struct LegacyBinding < ' a > {
6477 parent : LegacyScope < ' a > ,
6578 kind : LegacyBindingKind ,
@@ -175,8 +188,11 @@ impl<'a> base::Resolver for Resolver<'a> {
175188 InvocationKind :: Attr { ref attr, .. } => ( intern ( & * attr. name ( ) ) , attr. span ) ,
176189 } ;
177190
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 ( || {
180196 let mut err =
181197 self . session . struct_span_err ( span, & format ! ( "macro undefined: '{}!'" , name) ) ;
182198 self . suggest_macro_name ( & name. as_str ( ) , & mut err) ;
0 commit comments