@@ -443,6 +443,8 @@ pub(crate) enum PathSource<'a, 'ast, 'ra> {
443443 ReturnTypeNotation ,
444444 /// Paths from `#[define_opaque]` attributes
445445 DefineOpaques ,
446+ /// Resolving a macro
447+ Macro ,
446448}
447449
448450impl PathSource < ' _ , ' _ , ' _ > {
@@ -459,6 +461,7 @@ impl PathSource<'_, '_, '_> {
459461 | PathSource :: ReturnTypeNotation => ValueNS ,
460462 PathSource :: TraitItem ( ns, _) => ns,
461463 PathSource :: PreciseCapturingArg ( ns) => ns,
464+ PathSource :: Macro => MacroNS ,
462465 }
463466 }
464467
@@ -474,7 +477,8 @@ impl PathSource<'_, '_, '_> {
474477 | PathSource :: TraitItem ( ..)
475478 | PathSource :: DefineOpaques
476479 | PathSource :: Delegation
477- | PathSource :: PreciseCapturingArg ( ..) => false ,
480+ | PathSource :: PreciseCapturingArg ( ..)
481+ | PathSource :: Macro => false ,
478482 }
479483 }
480484
@@ -516,6 +520,7 @@ impl PathSource<'_, '_, '_> {
516520 } ,
517521 PathSource :: ReturnTypeNotation | PathSource :: Delegation => "function" ,
518522 PathSource :: PreciseCapturingArg ( ..) => "type or const parameter" ,
523+ PathSource :: Macro => "macro" ,
519524 }
520525 }
521526
@@ -610,6 +615,7 @@ impl PathSource<'_, '_, '_> {
610615 Res :: Def ( DefKind :: TyParam , _) | Res :: SelfTyParam { .. } | Res :: SelfTyAlias { .. }
611616 ) ,
612617 PathSource :: PreciseCapturingArg ( MacroNS ) => false ,
618+ PathSource :: Macro => matches ! ( res, Res :: Def ( DefKind :: Macro ( _) , _) ) ,
613619 }
614620 }
615621
@@ -629,6 +635,7 @@ impl PathSource<'_, '_, '_> {
629635 ( PathSource :: TraitItem ( ..) | PathSource :: ReturnTypeNotation , false ) => E0576 ,
630636 ( PathSource :: PreciseCapturingArg ( ..) , true ) => E0799 ,
631637 ( PathSource :: PreciseCapturingArg ( ..) , false ) => E0800 ,
638+ ( PathSource :: Macro , _) => E0425 ,
632639 }
633640 }
634641}
@@ -1054,6 +1061,12 @@ impl<'ast, 'ra, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'ra, 'tc
10541061 } ;
10551062 debug ! ( "(resolving function) entering function" ) ;
10561063
1064+ if let FnKind :: Fn ( _, _, f) = fn_kind {
1065+ for EiiImpl { node_id, eii_macro_path, .. } in & f. eii_impls {
1066+ self . smart_resolve_path ( * node_id, & None , & eii_macro_path, PathSource :: Macro ) ;
1067+ }
1068+ }
1069+
10571070 // Create a value rib for the function.
10581071 self . with_rib ( ValueNS , RibKind :: FnOrCoroutine , |this| {
10591072 // Create a label rib for the function.
@@ -2056,7 +2069,8 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
20562069 | PathSource :: TraitItem ( ..)
20572070 | PathSource :: Type
20582071 | PathSource :: PreciseCapturingArg ( ..)
2059- | PathSource :: ReturnTypeNotation => false ,
2072+ | PathSource :: ReturnTypeNotation
2073+ | PathSource :: Macro => false ,
20602074 PathSource :: Expr ( ..)
20612075 | PathSource :: Pat
20622076 | PathSource :: Struct ( _)
@@ -2810,6 +2824,17 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
28102824 let def_id = self . r . local_def_id ( item. id ) ;
28112825 self . parent_scope . macro_rules = self . r . macro_rules_scopes [ & def_id] ;
28122826 }
2827+
2828+ if let Some ( EiiExternTarget { extern_item_path, impl_unsafe : _, span : _ } ) =
2829+ & macro_def. eii_extern_target
2830+ {
2831+ self . smart_resolve_path (
2832+ item. id ,
2833+ & None ,
2834+ extern_item_path,
2835+ PathSource :: Expr ( None ) ,
2836+ ) ;
2837+ }
28132838 }
28142839
28152840 ItemKind :: ForeignMod ( _) | ItemKind :: GlobalAsm ( _) => {
0 commit comments