Skip to content

Commit a9c828e

Browse files
committed
Querify lookup_default_body_stability.
1 parent c8f69ec commit a9c828e

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

compiler/rustc_middle/src/middle/stability.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ pub struct Index {
7272
/// are filled by the annotator.
7373
pub stab_map: LocalDefIdMap<Stability>,
7474
pub const_stab_map: LocalDefIdMap<ConstStability>,
75-
pub default_body_stab_map: LocalDefIdMap<DefaultBodyStability>,
7675
/// Mapping from feature name to feature name based on the `implied_by` field of `#[unstable]`
7776
/// attributes. If a `#[unstable(feature = "implier", implied_by = "impliee")]` attribute
7877
/// exists, then this map will have a `impliee -> implier` entry.
@@ -96,10 +95,6 @@ impl Index {
9695
pub fn local_const_stability(&self, def_id: LocalDefId) -> Option<ConstStability> {
9796
self.const_stab_map.get(&def_id).copied()
9897
}
99-
100-
pub fn local_default_body_stability(&self, def_id: LocalDefId) -> Option<DefaultBodyStability> {
101-
self.default_body_stab_map.get(&def_id).copied()
102-
}
10398
}
10499

105100
pub fn report_unstable(

compiler/rustc_passes/src/stability.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use std::num::NonZero;
66

77
use rustc_ast_lowering::stability::extern_abi_stability;
88
use 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
};
1212
use rustc_data_structures::fx::FxIndexMap;
1313
use 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`.
154168
struct 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);
@@ -702,7 +707,6 @@ fn stability_index(tcx: TyCtxt<'_>, (): ()) -> Index {
702707
let mut index = Index {
703708
stab_map: Default::default(),
704709
const_stab_map: Default::default(),
705-
default_body_stab_map: Default::default(),
706710
implications: Default::default(),
707711
};
708712

@@ -755,7 +759,7 @@ pub(crate) fn provide(providers: &mut Providers) {
755759
stability_implications: |tcx, _| tcx.stability().implications.clone(),
756760
lookup_stability: |tcx, id| tcx.stability().local_stability(id),
757761
lookup_const_stability: |tcx, id| tcx.stability().local_const_stability(id),
758-
lookup_default_body_stability: |tcx, id| tcx.stability().local_default_body_stability(id),
762+
lookup_default_body_stability,
759763
lookup_deprecation_entry,
760764
..*providers
761765
};

0 commit comments

Comments
 (0)