@@ -440,6 +440,8 @@ pub(crate) enum PathSource<'a, 'ast, 'ra> {
440440 ReturnTypeNotation ,
441441 /// Paths from `#[define_opaque]` attributes
442442 DefineOpaques ,
443+ /// Resolving a macro
444+ Macro ,
443445}
444446
445447impl PathSource < ' _ , ' _ , ' _ > {
@@ -456,6 +458,7 @@ impl PathSource<'_, '_, '_> {
456458 | PathSource :: ReturnTypeNotation => ValueNS ,
457459 PathSource :: TraitItem ( ns, _) => ns,
458460 PathSource :: PreciseCapturingArg ( ns) => ns,
461+ PathSource :: Macro => MacroNS ,
459462 }
460463 }
461464
@@ -471,7 +474,8 @@ impl PathSource<'_, '_, '_> {
471474 | PathSource :: TraitItem ( ..)
472475 | PathSource :: DefineOpaques
473476 | PathSource :: Delegation
474- | PathSource :: PreciseCapturingArg ( ..) => false ,
477+ | PathSource :: PreciseCapturingArg ( ..)
478+ | PathSource :: Macro => false ,
475479 }
476480 }
477481
@@ -513,6 +517,7 @@ impl PathSource<'_, '_, '_> {
513517 } ,
514518 PathSource :: ReturnTypeNotation | PathSource :: Delegation => "function" ,
515519 PathSource :: PreciseCapturingArg ( ..) => "type or const parameter" ,
520+ PathSource :: Macro => "macro" ,
516521 }
517522 }
518523
@@ -607,6 +612,7 @@ impl PathSource<'_, '_, '_> {
607612 Res :: Def ( DefKind :: TyParam , _) | Res :: SelfTyParam { .. } | Res :: SelfTyAlias { .. }
608613 ) ,
609614 PathSource :: PreciseCapturingArg ( MacroNS ) => false ,
615+ PathSource :: Macro => matches ! ( res, Res :: Def ( DefKind :: Macro ( _) , _) ) ,
610616 }
611617 }
612618
@@ -626,6 +632,7 @@ impl PathSource<'_, '_, '_> {
626632 ( PathSource :: TraitItem ( ..) | PathSource :: ReturnTypeNotation , false ) => E0576 ,
627633 ( PathSource :: PreciseCapturingArg ( ..) , true ) => E0799 ,
628634 ( PathSource :: PreciseCapturingArg ( ..) , false ) => E0800 ,
635+ ( PathSource :: Macro , _) => E0425 ,
629636 }
630637 }
631638}
@@ -1051,6 +1058,12 @@ impl<'ast, 'ra, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'ra, 'tc
10511058 } ;
10521059 debug ! ( "(resolving function) entering function" ) ;
10531060
1061+ if let FnKind :: Fn ( _, _, f) = fn_kind {
1062+ for EiiImpl { node_id, eii_macro_path, .. } in & f. eii_impls {
1063+ self . smart_resolve_path ( * node_id, & None , & eii_macro_path, PathSource :: Macro ) ;
1064+ }
1065+ }
1066+
10541067 // Create a value rib for the function.
10551068 self . with_rib ( ValueNS , RibKind :: FnOrCoroutine , |this| {
10561069 // Create a label rib for the function.
@@ -2005,7 +2018,8 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
20052018 | PathSource :: TraitItem ( ..)
20062019 | PathSource :: Type
20072020 | PathSource :: PreciseCapturingArg ( ..)
2008- | PathSource :: ReturnTypeNotation => false ,
2021+ | PathSource :: ReturnTypeNotation
2022+ | PathSource :: Macro => false ,
20092023 PathSource :: Expr ( ..)
20102024 | PathSource :: Pat
20112025 | PathSource :: Struct ( _)
@@ -2759,6 +2773,17 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
27592773 let def_id = self . r . local_def_id ( item. id ) ;
27602774 self . parent_scope . macro_rules = self . r . macro_rules_scopes [ & def_id] ;
27612775 }
2776+
2777+ if let Some ( EiiExternTarget { extern_item_path, impl_unsafe : _, span : _ } ) =
2778+ & macro_def. eii_extern_target
2779+ {
2780+ self . smart_resolve_path (
2781+ item. id ,
2782+ & None ,
2783+ extern_item_path,
2784+ PathSource :: Expr ( None ) ,
2785+ ) ;
2786+ }
27622787 }
27632788
27642789 ItemKind :: ForeignMod ( _) | ItemKind :: GlobalAsm ( _) => {
0 commit comments