@@ -6,8 +6,8 @@ use std::num::NonZero;
66
77use rustc_ast_lowering:: stability:: extern_abi_stability;
88use rustc_attr_data_structures:: {
9- self as attrs, AttributeKind , ConstStability , DeprecatedSince , Stability , StabilityLevel ,
10- StableSince , UnstableReason , VERSION_PLACEHOLDER , find_attr,
9+ self as attrs, AttributeKind , ConstStability , DefaultBodyStability , DeprecatedSince , Stability ,
10+ StabilityLevel , StableSince , UnstableReason , VERSION_PLACEHOLDER , find_attr,
1111} ;
1212use rustc_data_structures:: fx:: FxIndexMap ;
1313use rustc_data_structures:: unord:: { ExtendUnord , UnordMap , UnordSet } ;
@@ -150,6 +150,20 @@ fn lookup_deprecation_entry(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<Depre
150150 Some ( DeprecationEntry :: local ( depr, def_id) )
151151}
152152
153+ #[ instrument( level = "debug" , skip( tcx) ) ]
154+ fn lookup_default_body_stability (
155+ tcx : TyCtxt < ' _ > ,
156+ def_id : LocalDefId ,
157+ ) -> Option < DefaultBodyStability > {
158+ if !tcx. features ( ) . staged_api ( ) {
159+ return None ;
160+ }
161+
162+ let attrs = tcx. hir_attrs ( tcx. local_def_id_to_hir_id ( def_id) ) ;
163+ // FIXME: check that this item can have body stability
164+ attrs:: find_attr!( attrs, AttributeKind :: BodyStability { stability, .. } => * stability)
165+ }
166+
153167/// A private tree-walker for producing an `Index`.
154168struct Annotator < ' a , ' tcx > {
155169 tcx : TyCtxt < ' tcx > ,
@@ -197,18 +211,9 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
197211 return ;
198212 }
199213
200- // # Regular and body stability
214+ // # Regular stability
201215 let stab =
202216 attrs:: find_attr!( attrs, AttributeKind :: Stability { stability, span: _ } => * stability) ;
203- let body_stab =
204- attrs:: find_attr!( attrs, AttributeKind :: BodyStability { stability, .. } => * stability) ;
205-
206- if let Some ( body_stab) = body_stab {
207- // FIXME: check that this item can have body stability
208-
209- self . index . default_body_stab_map . insert ( def_id, body_stab) ;
210- debug ! ( ?self . index. default_body_stab_map) ;
211- }
212217
213218 if let Some ( stab) = stab {
214219 debug ! ( "annotate: found {:?}" , stab) ;
@@ -679,7 +684,6 @@ fn stability_index(tcx: TyCtxt<'_>, (): ()) -> Index {
679684 let mut index = Index {
680685 stab_map : Default :: default ( ) ,
681686 const_stab_map : Default :: default ( ) ,
682- default_body_stab_map : Default :: default ( ) ,
683687 implications : Default :: default ( ) ,
684688 } ;
685689
@@ -732,7 +736,7 @@ pub(crate) fn provide(providers: &mut Providers) {
732736 stability_implications : |tcx, _| tcx. stability ( ) . implications . clone ( ) ,
733737 lookup_stability : |tcx, id| tcx. stability ( ) . local_stability ( id) ,
734738 lookup_const_stability : |tcx, id| tcx. stability ( ) . local_const_stability ( id) ,
735- lookup_default_body_stability : |tcx , id| tcx . stability ( ) . local_default_body_stability ( id ) ,
739+ lookup_default_body_stability,
736740 lookup_deprecation_entry,
737741 ..* providers
738742 } ;
0 commit comments