@@ -1013,7 +1013,7 @@ struct DeriveData {
1013
1013
has_derive_copy : bool ,
1014
1014
}
1015
1015
1016
- pub struct MacroData {
1016
+ struct MacroData {
1017
1017
ext : Arc < SyntaxExtension > ,
1018
1018
nrules : usize ,
1019
1019
macro_rules : bool ,
@@ -1025,20 +1025,7 @@ impl MacroData {
1025
1025
}
1026
1026
}
1027
1027
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 ;
1042
1029
1043
1030
/// The main resolver class.
1044
1031
///
@@ -1144,7 +1131,8 @@ pub struct Resolver<'ra, 'tcx> {
1144
1131
registered_tools : & ' tcx RegisteredTools ,
1145
1132
macro_use_prelude : FxIndexMap < Symbol , NameBinding < ' ra > > ,
1146
1133
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 > > > ,
1148
1136
dummy_ext_bang : Arc < SyntaxExtension > ,
1149
1137
dummy_ext_derive : Arc < SyntaxExtension > ,
1150
1138
non_macro_attr : Macro < ' ra > ,
@@ -1316,7 +1304,7 @@ impl<'ra> ResolverArenas<'ra> {
1316
1304
self . ast_paths . alloc_from_iter ( paths. iter ( ) . cloned ( ) )
1317
1305
}
1318
1306
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)
1320
1308
}
1321
1309
fn alloc_pattern_spans ( & ' ra self , spans : impl Iterator < Item = Span > ) -> & ' ra [ Span ] {
1322
1310
self . dropless . alloc_from_iter ( spans)
@@ -1560,8 +1548,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1560
1548
builtin_macros : Default :: default ( ) ,
1561
1549
registered_tools,
1562
1550
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 ( ) ,
1565
1553
dummy_ext_bang : Arc :: new ( SyntaxExtension :: dummy_bang ( edition) ) ,
1566
1554
dummy_ext_derive : Arc :: new ( SyntaxExtension :: dummy_derive ( edition) ) ,
1567
1555
non_macro_attr : arenas
@@ -1638,13 +1626,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1638
1626
)
1639
1627
}
1640
1628
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 > {
1646
1630
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) ;
1648
1632
mac
1649
1633
}
1650
1634
@@ -1766,7 +1750,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1766
1750
f ( self , MacroNS ) ;
1767
1751
}
1768
1752
1769
- fn is_builtin_macro ( & mut self , res : Res ) -> bool {
1753
+ fn is_builtin_macro ( & self , res : Res ) -> bool {
1770
1754
self . get_macro ( res) . is_some_and ( |macro_data| macro_data. ext . builtin_name . is_some ( ) )
1771
1755
}
1772
1756
0 commit comments