@@ -8,14 +8,12 @@ pub mod place;
88
99use crate :: ty:: query:: Providers ;
1010use crate :: ty:: TyCtxt ;
11- use rustc_ast:: Attribute ;
1211use rustc_data_structures:: fingerprint:: Fingerprint ;
1312use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
1413use rustc_hir:: def_id:: LocalDefId ;
1514use rustc_hir:: * ;
1615use rustc_query_system:: ich:: StableHashingContext ;
1716use rustc_span:: DUMMY_SP ;
18- use std:: collections:: BTreeMap ;
1917
2018/// Top-level HIR node for current owner. This only contains the node for which
2119/// `HirId::local_id == 0`, and excludes bodies.
@@ -36,24 +34,6 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Owner<'tcx> {
3634 }
3735}
3836
39- /// Attributes owner by a HIR owner.
40- #[ derive( Copy , Clone , Debug , HashStable ) ]
41- pub struct AttributeMap < ' tcx > {
42- map : & ' tcx BTreeMap < ItemLocalId , & ' tcx [ Attribute ] > ,
43- }
44-
45- impl < ' tcx > AttributeMap < ' tcx > {
46- fn new ( owner_info : & ' tcx Option < OwnerInfo < ' tcx > > ) -> AttributeMap < ' tcx > {
47- const FALLBACK : & ' static BTreeMap < ItemLocalId , & ' static [ Attribute ] > = & BTreeMap :: new ( ) ;
48- let map = owner_info. as_ref ( ) . map_or ( FALLBACK , |info| & info. attrs ) ;
49- AttributeMap { map }
50- }
51-
52- fn get ( & self , id : ItemLocalId ) -> & ' tcx [ Attribute ] {
53- self . map . get ( & id) . copied ( ) . unwrap_or ( & [ ] )
54- }
55- }
56-
5737/// Gather the LocalDefId for each item-like within a module, including items contained within
5838/// bodies. The Ids are in visitor order. This is used to partition a pass between modules.
5939#[ derive( Debug , HashStable ) ]
@@ -105,7 +85,8 @@ pub fn provide(providers: &mut Providers) {
10585 } ) ;
10686 parent
10787 } ;
108- providers. hir_attrs = |tcx, id| AttributeMap :: new ( & tcx. hir_crate ( ( ) ) . owners [ id] ) ;
88+ providers. hir_attrs =
89+ |tcx, id| tcx. hir_crate ( ( ) ) . owners [ id] . as_ref ( ) . map_or ( AttributeMap :: EMPTY , |o| & o. attrs ) ;
10990 providers. source_span = |tcx, def_id| tcx. resolutions ( ( ) ) . definitions . def_span ( def_id) ;
11091 providers. def_span = |tcx, def_id| tcx. hir ( ) . span_if_local ( def_id) . unwrap_or ( DUMMY_SP ) ;
11192 providers. fn_arg_names = |tcx, id| {
0 commit comments