@@ -31,7 +31,7 @@ use rustc_middle::bug;
3131use rustc_middle:: hir:: exports:: Export ;
3232use rustc_middle:: middle:: cstore:: CrateStore ;
3333use rustc_middle:: ty;
34- use rustc_span:: hygiene:: { ExpnId , MacroKind } ;
34+ use rustc_span:: hygiene:: { ExpnId , LocalExpnId , MacroKind } ;
3535use rustc_span:: source_map:: { respan, Spanned } ;
3636use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
3737use rustc_span:: Span ;
@@ -42,7 +42,7 @@ use tracing::debug;
4242
4343type Res = def:: Res < NodeId > ;
4444
45- impl < ' a > ToNameBinding < ' a > for ( Module < ' a > , ty:: Visibility , Span , ExpnId ) {
45+ impl < ' a > ToNameBinding < ' a > for ( Module < ' a > , ty:: Visibility , Span , LocalExpnId ) {
4646 fn to_name_binding ( self , arenas : & ' a ResolverArenas < ' a > ) -> & ' a NameBinding < ' a > {
4747 arenas. alloc_name_binding ( NameBinding {
4848 kind : NameBindingKind :: Module ( self . 0 ) ,
@@ -54,7 +54,7 @@ impl<'a> ToNameBinding<'a> for (Module<'a>, ty::Visibility, Span, ExpnId) {
5454 }
5555}
5656
57- impl < ' a > ToNameBinding < ' a > for ( Res , ty:: Visibility , Span , ExpnId ) {
57+ impl < ' a > ToNameBinding < ' a > for ( Res , ty:: Visibility , Span , LocalExpnId ) {
5858 fn to_name_binding ( self , arenas : & ' a ResolverArenas < ' a > ) -> & ' a NameBinding < ' a > {
5959 arenas. alloc_name_binding ( NameBinding {
6060 kind : NameBindingKind :: Res ( self . 0 , false ) ,
@@ -68,7 +68,7 @@ impl<'a> ToNameBinding<'a> for (Res, ty::Visibility, Span, ExpnId) {
6868
6969struct IsMacroExport ;
7070
71- impl < ' a > ToNameBinding < ' a > for ( Res , ty:: Visibility , Span , ExpnId , IsMacroExport ) {
71+ impl < ' a > ToNameBinding < ' a > for ( Res , ty:: Visibility , Span , LocalExpnId , IsMacroExport ) {
7272 fn to_name_binding ( self , arenas : & ' a ResolverArenas < ' a > ) -> & ' a NameBinding < ' a > {
7373 arenas. alloc_name_binding ( NameBinding {
7474 kind : NameBindingKind :: Res ( self . 0 , true ) ,
@@ -157,7 +157,12 @@ impl<'a> Resolver<'a> {
157157 crate fn macro_def_scope ( & mut self , expn_id : ExpnId ) -> Module < ' a > {
158158 let def_id = match expn_id. expn_data ( ) . macro_def_id {
159159 Some ( def_id) => def_id,
160- None => return self . ast_transform_scopes . get ( & expn_id) . unwrap_or ( & self . graph_root ) ,
160+ None => {
161+ return expn_id
162+ . as_local ( )
163+ . and_then ( |expn_id| self . ast_transform_scopes . get ( & expn_id) )
164+ . unwrap_or ( & self . graph_root ) ;
165+ }
161166 } ;
162167 self . macro_def_scope_from_def_id ( def_id)
163168 }
@@ -739,7 +744,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
739744 if ptr:: eq ( parent, self . r . graph_root ) {
740745 if let Some ( entry) = self . r . extern_prelude . get ( & ident. normalize_to_macros_2_0 ( ) )
741746 {
742- if expansion != ExpnId :: root ( )
747+ if expansion != LocalExpnId :: ROOT
743748 && orig_name. is_some ( )
744749 && entry. extern_crate_item . is_none ( )
745750 {
@@ -769,7 +774,13 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
769774 no_implicit_prelude : parent. no_implicit_prelude || {
770775 self . r . session . contains_name ( & item. attrs , sym:: no_implicit_prelude)
771776 } ,
772- ..ModuleData :: new ( Some ( parent) , module_kind, def_id, expansion, item. span )
777+ ..ModuleData :: new (
778+ Some ( parent) ,
779+ module_kind,
780+ def_id,
781+ expansion. to_expn_id ( ) ,
782+ item. span ,
783+ )
773784 } ) ;
774785 self . r . define ( parent, ident, TypeNS , ( module, vis, sp, expansion) ) ;
775786 self . r . module_map . insert ( local_def_id, module) ;
@@ -808,7 +819,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
808819 parent,
809820 module_kind,
810821 parent. nearest_parent_mod ,
811- expansion,
822+ expansion. to_expn_id ( ) ,
812823 item. span ,
813824 ) ;
814825 self . r . define ( parent, ident, TypeNS , ( module, vis, sp, expansion) ) ;
@@ -883,7 +894,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
883894 parent,
884895 module_kind,
885896 parent. nearest_parent_mod ,
886- expansion,
897+ expansion. to_expn_id ( ) ,
887898 item. span ,
888899 ) ;
889900 self . r . define ( parent, ident, TypeNS , ( module, vis, sp, expansion) ) ;
@@ -926,7 +937,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
926937 parent,
927938 ModuleKind :: Block ( block. id ) ,
928939 parent. nearest_parent_mod ,
929- expansion,
940+ expansion. to_expn_id ( ) ,
930941 block. span ,
931942 ) ;
932943 self . r . block_map . insert ( block. id , module) ;
@@ -946,7 +957,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
946957 parent,
947958 ModuleKind :: Def ( kind, def_id, ident. name ) ,
948959 def_id,
949- expansion,
960+ expansion. to_expn_id ( ) ,
950961 span,
951962 ) ;
952963 self . r . define ( parent, ident, TypeNS , ( module, vis, span, expansion) ) ;
@@ -1112,7 +1123,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
11121123 } )
11131124 } ;
11141125
1115- let allow_shadowing = self . parent_scope . expansion == ExpnId :: root ( ) ;
1126+ let allow_shadowing = self . parent_scope . expansion == LocalExpnId :: ROOT ;
11161127 if let Some ( span) = import_all {
11171128 let import = macro_use_import ( self , span) ;
11181129 self . r . potentially_unused_imports . push ( import) ;
@@ -1175,7 +1186,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
11751186 false
11761187 }
11771188
1178- fn visit_invoc ( & mut self , id : NodeId ) -> ExpnId {
1189+ fn visit_invoc ( & mut self , id : NodeId ) -> LocalExpnId {
11791190 let invoc_id = id. placeholder_to_expn_id ( ) ;
11801191 let old_parent_scope = self . r . invocation_parent_scopes . insert ( invoc_id, self . parent_scope ) ;
11811192 assert ! ( old_parent_scope. is_none( ) , "invocation data is reset for an invocation" ) ;
0 commit comments