@@ -1265,18 +1265,6 @@ struct DeriveData {
12651265 has_derive_copy : bool ,
12661266}
12671267
1268- struct MacroData {
1269- ext : Arc < SyntaxExtension > ,
1270- nrules : usize ,
1271- macro_rules : bool ,
1272- }
1273-
1274- impl MacroData {
1275- fn new ( ext : Arc < SyntaxExtension > ) -> MacroData {
1276- MacroData { ext, nrules : 0 , macro_rules : false }
1277- }
1278- }
1279-
12801268pub struct ResolverOutputs < ' tcx > {
12811269 pub global_ctxt : ResolverGlobalCtxt ,
12821270 pub ast_lowering : ResolverAstLowering < ' tcx > ,
@@ -1396,12 +1384,12 @@ pub struct Resolver<'ra, 'tcx> {
13961384 registered_tools : & ' tcx RegisteredTools ,
13971385 macro_use_prelude : FxIndexMap < Symbol , Decl < ' ra > > ,
13981386 /// Eagerly populated map of all local macro definitions.
1399- local_macro_map : FxHashMap < LocalDefId , & ' ra MacroData > = default:: fx_hash_map ( ) ,
1387+ local_macro_map : FxHashMap < LocalDefId , & ' ra Arc < SyntaxExtension > > = default:: fx_hash_map ( ) ,
14001388 /// Lazily populated cache of macro definitions loaded from external crates.
1401- extern_macro_map : CacheRefCell < FxHashMap < DefId , & ' ra MacroData > > ,
1389+ extern_macro_map : CacheRefCell < FxHashMap < DefId , & ' ra Arc < SyntaxExtension > > > ,
14021390 dummy_ext_bang : Arc < SyntaxExtension > ,
14031391 dummy_ext_derive : Arc < SyntaxExtension > ,
1404- non_macro_attr : & ' ra MacroData ,
1392+ non_macro_attr : & ' ra Arc < SyntaxExtension > ,
14051393 local_macro_def_scopes : FxHashMap < LocalDefId , LocalModule < ' ra > > = default:: fx_hash_map ( ) ,
14061394 ast_transform_scopes : FxHashMap < LocalExpnId , LocalModule < ' ra > > = default:: fx_hash_map ( ) ,
14071395 unused_macros : FxIndexMap < LocalDefId , ( NodeId , Ident ) > ,
@@ -1520,7 +1508,7 @@ pub struct ResolverArenas<'ra> {
15201508 imports : TypedArena < ImportData < ' ra > > ,
15211509 name_resolutions : TypedArena < CmRefCell < NameResolution < ' ra > > > ,
15221510 ast_paths : TypedArena < ast:: Path > ,
1523- macros : TypedArena < MacroData > ,
1511+ macros : TypedArena < Arc < SyntaxExtension > > ,
15241512 dropless : DroplessArena ,
15251513}
15261514
@@ -1599,8 +1587,8 @@ impl<'ra> ResolverArenas<'ra> {
15991587 fn alloc_ast_paths ( & ' ra self , paths : & [ ast:: Path ] ) -> & ' ra [ ast:: Path ] {
16001588 self . ast_paths . alloc_from_iter ( paths. iter ( ) . cloned ( ) )
16011589 }
1602- fn alloc_macro ( & ' ra self , macro_data : MacroData ) -> & ' ra MacroData {
1603- self . macros . alloc ( macro_data )
1590+ fn alloc_macro ( & ' ra self , ext : Arc < SyntaxExtension > ) -> & ' ra Arc < SyntaxExtension > {
1591+ self . macros . alloc ( ext )
16041592 }
16051593 fn alloc_pattern_spans ( & ' ra self , spans : impl Iterator < Item = Span > ) -> & ' ra [ Span ] {
16061594 self . dropless . alloc_from_iter ( spans)
@@ -1821,8 +1809,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
18211809 extern_macro_map : Default :: default ( ) ,
18221810 dummy_ext_bang : Arc :: new ( SyntaxExtension :: dummy_bang ( edition) ) ,
18231811 dummy_ext_derive : Arc :: new ( SyntaxExtension :: dummy_derive ( edition) ) ,
1824- non_macro_attr : arenas
1825- . alloc_macro ( MacroData :: new ( Arc :: new ( SyntaxExtension :: non_macro_attr ( edition) ) ) ) ,
1812+ non_macro_attr : arenas. alloc_macro ( Arc :: new ( SyntaxExtension :: non_macro_attr ( edition) ) ) ,
18261813 unused_macros : Default :: default ( ) ,
18271814 unused_macro_rules : Default :: default ( ) ,
18281815 single_segment_macro_resolutions : Default :: default ( ) ,
@@ -1889,8 +1876,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
18891876 module
18901877 }
18911878
1892- fn new_local_macro ( & mut self , def_id : LocalDefId , macro_data : MacroData ) -> & ' ra MacroData {
1893- let mac = self . arenas . alloc_macro ( macro_data) ;
1879+ fn new_local_macro (
1880+ & mut self ,
1881+ def_id : LocalDefId ,
1882+ ext : Arc < SyntaxExtension > ,
1883+ ) -> & ' ra Arc < SyntaxExtension > {
1884+ let mac = self . arenas . alloc_macro ( ext) ;
18941885 self . local_macro_map . insert ( def_id, mac) ;
18951886 mac
18961887 }
@@ -1993,7 +1984,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
19931984 match macro_kind {
19941985 MacroKind :: Bang => Arc :: clone ( & self . dummy_ext_bang ) ,
19951986 MacroKind :: Derive => Arc :: clone ( & self . dummy_ext_derive ) ,
1996- MacroKind :: Attr => Arc :: clone ( & self . non_macro_attr . ext ) ,
1987+ MacroKind :: Attr => Arc :: clone ( self . non_macro_attr ) ,
19971988 }
19981989 }
19991990
@@ -2022,11 +2013,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
20222013 }
20232014
20242015 fn is_builtin_macro ( & self , res : Res ) -> bool {
2025- self . get_macro ( res) . is_some_and ( |macro_data| macro_data . ext . builtin_name . is_some ( ) )
2016+ self . get_macro ( res) . is_some_and ( |ext| ext. builtin_name . is_some ( ) )
20262017 }
20272018
20282019 fn is_specific_builtin_macro ( & self , res : Res , symbol : Symbol ) -> bool {
2029- self . get_macro ( res) . is_some_and ( |macro_data| macro_data . ext . builtin_name == Some ( symbol) )
2020+ self . get_macro ( res) . is_some_and ( |ext| ext. builtin_name == Some ( symbol) )
20302021 }
20312022
20322023 fn macro_def ( & self , mut ctxt : SyntaxContext ) -> DefId {
0 commit comments