@@ -1013,7 +1013,7 @@ struct DeriveData {
10131013 has_derive_copy : bool ,
10141014}
10151015
1016- pub struct MacroData {
1016+ struct MacroData {
10171017 ext : Arc < SyntaxExtension > ,
10181018 nrules : usize ,
10191019 macro_rules : bool ,
@@ -1025,20 +1025,7 @@ impl MacroData {
10251025 }
10261026}
10271027
1028- pub ( crate ) type Macro < ' ra > = Interned < ' ra , MacroData > ;
1029-
1030- // Allows us to use Interned without actually enforcing (via Hash/PartialEq/...) uniqueness of the
1031- // contained data.
1032- // FIXME: We may wish to actually have at least debug-level assertions that Interned's guarantees
1033- // are upheld.
1034- impl std:: hash:: Hash for MacroData {
1035- fn hash < H > ( & self , _: & mut H )
1036- where
1037- H : std:: hash:: Hasher ,
1038- {
1039- unreachable ! ( )
1040- }
1041- }
1028+ type Macro < ' ra > = & ' ra MacroData ;
10421029
10431030/// The main resolver class.
10441031///
@@ -1144,7 +1131,8 @@ pub struct Resolver<'ra, 'tcx> {
11441131 registered_tools : & ' tcx RegisteredTools ,
11451132 macro_use_prelude : FxIndexMap < Symbol , NameBinding < ' ra > > ,
11461133 local_macro_map : FxHashMap < LocalDefId , Macro < ' ra > > ,
1147- external_macro_map : RefCell < FxHashMap < DefId , Macro < ' ra > > > ,
1134+ /// Lazily populated cache of macros loaded from external crates.
1135+ extern_macro_map : RefCell < FxHashMap < DefId , Macro < ' ra > > > ,
11481136 dummy_ext_bang : Arc < SyntaxExtension > ,
11491137 dummy_ext_derive : Arc < SyntaxExtension > ,
11501138 non_macro_attr : Macro < ' ra > ,
@@ -1316,7 +1304,7 @@ impl<'ra> ResolverArenas<'ra> {
13161304 self . ast_paths . alloc_from_iter ( paths. iter ( ) . cloned ( ) )
13171305 }
13181306 fn alloc_macro ( & ' ra self , macro_data : MacroData ) -> Macro < ' ra > {
1319- Interned :: new_unchecked ( self . macros . alloc ( macro_data) )
1307+ self . macros . alloc ( macro_data)
13201308 }
13211309 fn alloc_pattern_spans ( & ' ra self , spans : impl Iterator < Item = Span > ) -> & ' ra [ Span ] {
13221310 self . dropless . alloc_from_iter ( spans)
@@ -1560,8 +1548,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15601548 builtin_macros : Default :: default ( ) ,
15611549 registered_tools,
15621550 macro_use_prelude : Default :: default ( ) ,
1563- local_macro_map : FxHashMap :: default ( ) ,
1564- external_macro_map : RefCell :: default ( ) ,
1551+ local_macro_map : Default :: default ( ) ,
1552+ extern_macro_map : Default :: default ( ) ,
15651553 dummy_ext_bang : Arc :: new ( SyntaxExtension :: dummy_bang ( edition) ) ,
15661554 dummy_ext_derive : Arc :: new ( SyntaxExtension :: dummy_derive ( edition) ) ,
15671555 non_macro_attr : arenas
@@ -1638,13 +1626,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16381626 )
16391627 }
16401628
1641- pub fn new_local_macro (
1642- & mut self ,
1643- local_def_id : LocalDefId ,
1644- macro_data : MacroData ,
1645- ) -> Macro < ' ra > {
1629+ fn new_local_macro ( & mut self , def_id : LocalDefId , macro_data : MacroData ) -> Macro < ' ra > {
16461630 let mac = self . arenas . alloc_macro ( macro_data) ;
1647- self . local_macro_map . insert ( local_def_id , mac) ;
1631+ self . local_macro_map . insert ( def_id , mac) ;
16481632 mac
16491633 }
16501634
@@ -1766,7 +1750,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
17661750 f ( self , MacroNS ) ;
17671751 }
17681752
1769- fn is_builtin_macro ( & mut self , res : Res ) -> bool {
1753+ fn is_builtin_macro ( & self , res : Res ) -> bool {
17701754 self . get_macro ( res) . is_some_and ( |macro_data| macro_data. ext . builtin_name . is_some ( ) )
17711755 }
17721756
0 commit comments