@@ -35,8 +35,8 @@ use crate::{
3535 db:: DefDatabase ,
3636 item_scope:: { GlobId , ImportId , ImportOrExternCrate , PerNsGlobImports } ,
3737 item_tree:: {
38- self , FieldsShape , ImportAlias , ImportKind , ItemTree , ItemTreeAstId , ItemTreeNode , Macro2 ,
39- MacroCall , MacroRules , Mod , ModItem , ModKind , TreeId , UseTreeKind ,
38+ self , AttrOwner , FieldsShape , ImportAlias , ImportKind , ItemTree , ItemTreeAstId ,
39+ ItemTreeNode , Macro2 , MacroCall , MacroRules , Mod , ModItem , ModKind , TreeId , UseTreeKind ,
4040 } ,
4141 macro_call_as_call_id,
4242 nameres:: {
@@ -246,7 +246,7 @@ struct DefCollector<'a> {
246246 /// This also stores the attributes to skip when we resolve derive helpers and non-macro
247247 /// non-builtin attributes in general.
248248 // FIXME: There has to be a better way to do this
249- skip_attrs : FxHashMap < InFile < ModItem > , AttrId > ,
249+ skip_attrs : FxHashMap < InFile < FileAstId < ast :: Item > > , AttrId > ,
250250}
251251
252252impl DefCollector < ' _ > {
@@ -472,7 +472,7 @@ impl DefCollector<'_> {
472472 attr. path ( ) . clone ( ) ,
473473 ) ) ;
474474
475- self . skip_attrs . insert ( ast_id. ast_id . with_value ( * mod_item) , attr. id ) ;
475+ self . skip_attrs . insert ( ast_id. ast_id . with_value ( mod_item. ast_id ( ) ) , attr. id ) ;
476476
477477 Some ( ( idx, directive, * mod_item, * tree) )
478478 }
@@ -1371,7 +1371,9 @@ impl DefCollector<'_> {
13711371 let mut recollect_without = |collector : & mut Self | {
13721372 // Remove the original directive since we resolved it.
13731373 let mod_dir = collector. mod_dirs [ & directive. module_id ] . clone ( ) ;
1374- collector. skip_attrs . insert ( InFile :: new ( file_id, * mod_item) , attr. id ) ;
1374+ collector
1375+ . skip_attrs
1376+ . insert ( InFile :: new ( file_id, mod_item. ast_id ( ) ) , attr. id ) ;
13751377
13761378 let item_tree = tree. item_tree ( self . db ) ;
13771379 ModCollector {
@@ -1728,25 +1730,7 @@ impl ModCollector<'_, '_> {
17281730 let attrs = self . item_tree . attrs ( db, krate, item. into ( ) ) ;
17291731 if let Some ( cfg) = attrs. cfg ( ) {
17301732 if !self . is_cfg_enabled ( & cfg) {
1731- let ast_id = match item {
1732- ModItem :: Use ( it) => self . item_tree [ it] . ast_id . erase ( ) ,
1733- ModItem :: ExternCrate ( it) => self . item_tree [ it] . ast_id . erase ( ) ,
1734- ModItem :: ExternBlock ( it) => self . item_tree [ it] . ast_id . erase ( ) ,
1735- ModItem :: Function ( it) => self . item_tree [ it] . ast_id . erase ( ) ,
1736- ModItem :: Struct ( it) => self . item_tree [ it] . ast_id . erase ( ) ,
1737- ModItem :: Union ( it) => self . item_tree [ it] . ast_id . erase ( ) ,
1738- ModItem :: Enum ( it) => self . item_tree [ it] . ast_id . erase ( ) ,
1739- ModItem :: Const ( it) => self . item_tree [ it] . ast_id . erase ( ) ,
1740- ModItem :: Static ( it) => self . item_tree [ it] . ast_id . erase ( ) ,
1741- ModItem :: Trait ( it) => self . item_tree [ it] . ast_id . erase ( ) ,
1742- ModItem :: TraitAlias ( it) => self . item_tree [ it] . ast_id . erase ( ) ,
1743- ModItem :: Impl ( it) => self . item_tree [ it] . ast_id . erase ( ) ,
1744- ModItem :: TypeAlias ( it) => self . item_tree [ it] . ast_id . erase ( ) ,
1745- ModItem :: Mod ( it) => self . item_tree [ it] . ast_id . erase ( ) ,
1746- ModItem :: MacroCall ( it) => self . item_tree [ it] . ast_id . erase ( ) ,
1747- ModItem :: MacroRules ( it) => self . item_tree [ it] . ast_id . erase ( ) ,
1748- ModItem :: Macro2 ( it) => self . item_tree [ it] . ast_id . erase ( ) ,
1749- } ;
1733+ let ast_id = item. ast_id ( ) . erase ( ) ;
17501734 self . emit_unconfigured_diagnostic ( InFile :: new ( self . file_id ( ) , ast_id) , & cfg) ;
17511735 return ;
17521736 }
@@ -2256,8 +2240,11 @@ impl ModCollector<'_, '_> {
22562240 mod_item : ModItem ,
22572241 container : ItemContainerId ,
22582242 ) -> Result < ( ) , ( ) > {
2259- let mut ignore_up_to =
2260- self . def_collector . skip_attrs . get ( & InFile :: new ( self . file_id ( ) , mod_item) ) . copied ( ) ;
2243+ let mut ignore_up_to = self
2244+ . def_collector
2245+ . skip_attrs
2246+ . get ( & InFile :: new ( self . file_id ( ) , mod_item. ast_id ( ) ) )
2247+ . copied ( ) ;
22612248 let iter = attrs
22622249 . iter ( )
22632250 . dedup_by ( |a, b| {
@@ -2309,7 +2296,7 @@ impl ModCollector<'_, '_> {
23092296 fn collect_macro_rules ( & mut self , id : ItemTreeAstId < MacroRules > , module : ModuleId ) {
23102297 let krate = self . def_collector . def_map . krate ;
23112298 let mac = & self . item_tree [ id] ;
2312- let attrs = self . item_tree . attrs ( self . def_collector . db , krate, ModItem :: from ( id) . into ( ) ) ;
2299+ let attrs = self . item_tree . attrs ( self . def_collector . db , krate, AttrOwner :: Item ( id. erase ( ) ) ) ;
23132300 let ast_id = InFile :: new ( self . file_id ( ) , mac. ast_id . upcast ( ) ) ;
23142301
23152302 let export_attr = || attrs. by_key ( sym:: macro_export) ;
@@ -2398,7 +2385,7 @@ impl ModCollector<'_, '_> {
23982385
23992386 // Case 1: builtin macros
24002387 let mut helpers_opt = None ;
2401- let attrs = self . item_tree . attrs ( self . def_collector . db , krate, ModItem :: from ( id) . into ( ) ) ;
2388+ let attrs = self . item_tree . attrs ( self . def_collector . db , krate, AttrOwner :: Item ( id. erase ( ) ) ) ;
24022389 let expander = if attrs. by_key ( sym:: rustc_builtin_macro) . exists ( ) {
24032390 if let Some ( expander) = find_builtin_macro ( & mac. name ) {
24042391 match expander {
0 commit comments