@@ -440,6 +440,8 @@ pub(crate) enum PathSource<'a, 'ast, 'ra> {
440
440
ReturnTypeNotation ,
441
441
/// Paths from `#[define_opaque]` attributes
442
442
DefineOpaques ,
443
+ /// Resolving a macro
444
+ Macro ,
443
445
}
444
446
445
447
impl PathSource < ' _ , ' _ , ' _ > {
@@ -456,6 +458,7 @@ impl PathSource<'_, '_, '_> {
456
458
| PathSource :: ReturnTypeNotation => ValueNS ,
457
459
PathSource :: TraitItem ( ns, _) => ns,
458
460
PathSource :: PreciseCapturingArg ( ns) => ns,
461
+ PathSource :: Macro => MacroNS ,
459
462
}
460
463
}
461
464
@@ -471,7 +474,8 @@ impl PathSource<'_, '_, '_> {
471
474
| PathSource :: TraitItem ( ..)
472
475
| PathSource :: DefineOpaques
473
476
| PathSource :: Delegation
474
- | PathSource :: PreciseCapturingArg ( ..) => false ,
477
+ | PathSource :: PreciseCapturingArg ( ..)
478
+ | PathSource :: Macro => false ,
475
479
}
476
480
}
477
481
@@ -513,6 +517,7 @@ impl PathSource<'_, '_, '_> {
513
517
} ,
514
518
PathSource :: ReturnTypeNotation | PathSource :: Delegation => "function" ,
515
519
PathSource :: PreciseCapturingArg ( ..) => "type or const parameter" ,
520
+ PathSource :: Macro => "macro" ,
516
521
}
517
522
}
518
523
@@ -607,6 +612,7 @@ impl PathSource<'_, '_, '_> {
607
612
Res :: Def ( DefKind :: TyParam , _) | Res :: SelfTyParam { .. } | Res :: SelfTyAlias { .. }
608
613
) ,
609
614
PathSource :: PreciseCapturingArg ( MacroNS ) => false ,
615
+ PathSource :: Macro => matches ! ( res, Res :: Def ( DefKind :: Macro ( _) , _) ) ,
610
616
}
611
617
}
612
618
@@ -626,6 +632,7 @@ impl PathSource<'_, '_, '_> {
626
632
( PathSource :: TraitItem ( ..) | PathSource :: ReturnTypeNotation , false ) => E0576 ,
627
633
( PathSource :: PreciseCapturingArg ( ..) , true ) => E0799 ,
628
634
( PathSource :: PreciseCapturingArg ( ..) , false ) => E0800 ,
635
+ ( PathSource :: Macro , _) => E0425 ,
629
636
}
630
637
}
631
638
}
@@ -1051,6 +1058,12 @@ impl<'ast, 'ra, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'ra, 'tc
1051
1058
} ;
1052
1059
debug ! ( "(resolving function) entering function" ) ;
1053
1060
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
+
1054
1067
// Create a value rib for the function.
1055
1068
self . with_rib ( ValueNS , RibKind :: FnOrCoroutine , |this| {
1056
1069
// Create a label rib for the function.
@@ -2005,7 +2018,8 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
2005
2018
| PathSource :: TraitItem ( ..)
2006
2019
| PathSource :: Type
2007
2020
| PathSource :: PreciseCapturingArg ( ..)
2008
- | PathSource :: ReturnTypeNotation => false ,
2021
+ | PathSource :: ReturnTypeNotation
2022
+ | PathSource :: Macro => false ,
2009
2023
PathSource :: Expr ( ..)
2010
2024
| PathSource :: Pat
2011
2025
| PathSource :: Struct ( _)
@@ -2759,6 +2773,17 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
2759
2773
let def_id = self . r . local_def_id ( item. id ) ;
2760
2774
self . parent_scope . macro_rules = self . r . macro_rules_scopes [ & def_id] ;
2761
2775
}
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
+ }
2762
2787
}
2763
2788
2764
2789
ItemKind :: ForeignMod ( _) | ItemKind :: GlobalAsm ( _) => {
0 commit comments