Skip to content

Commit

Permalink
Don't track parent body stability (it wasn't used anyway)
Browse files Browse the repository at this point in the history
  • Loading branch information
WaffleLapkin committed Jul 31, 2022
1 parent e11b4b8 commit 963e402
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions compiler/rustc_passes/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
//! propagating default levels lexically from parent to children ast nodes.
use rustc_attr::{
self as attr, ConstStability, DefaultBodyStability, Stability, StabilityLevel, Unstable,
UnstableReason,
self as attr, ConstStability, Stability, StabilityLevel, Unstable, UnstableReason,
};
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
use rustc_errors::{struct_span_err, Applicability};
Expand Down Expand Up @@ -91,7 +90,6 @@ struct Annotator<'a, 'tcx> {
index: &'a mut Index,
parent_stab: Option<Stability>,
parent_const_stab: Option<ConstStability>,
parent_body_stab: Option<DefaultBodyStability>,
parent_depr: Option<DeprecationEntry>,
in_trait_impl: bool,
}
Expand Down Expand Up @@ -159,7 +157,6 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
depr.map(|(d, _)| DeprecationEntry::local(d, def_id)),
None,
None,
None,
visit_children,
);
return;
Expand Down Expand Up @@ -213,14 +210,12 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
}
}

let body_stab = body_stab.map(|(body_stab, _span)| {
if let Some((body_stab, _span)) = body_stab {
// FIXME: check that this item can have body stability

self.index.default_body_stab_map.insert(def_id, body_stab);
debug!(?self.index.default_body_stab_map);

body_stab
});
}

let stab = stab.map(|(stab, span)| {
// Error if prohibited, or can't inherit anything from a container.
Expand Down Expand Up @@ -299,7 +294,6 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
depr.map(|(d, _)| DeprecationEntry::local(d, def_id)),
stab,
if inherit_const_stability.yes() { const_stab } else { None },
body_stab,
visit_children,
);
}
Expand All @@ -309,14 +303,12 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
depr: Option<DeprecationEntry>,
stab: Option<Stability>,
const_stab: Option<ConstStability>,
body_stab: Option<DefaultBodyStability>,
f: impl FnOnce(&mut Self),
) {
// These will be `Some` if this item changes the corresponding stability attribute.
let mut replaced_parent_depr = None;
let mut replaced_parent_stab = None;
let mut replaced_parent_const_stab = None;
let mut replaced_parent_body_stab = None;

if let Some(depr) = depr {
replaced_parent_depr = Some(replace(&mut self.parent_depr, Some(depr)));
Expand All @@ -328,9 +320,6 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
replaced_parent_const_stab =
Some(replace(&mut self.parent_const_stab, Some(const_stab)));
}
if let Some(body_stab) = body_stab {
replaced_parent_body_stab = Some(self.parent_body_stab.replace(body_stab));
}

f(self);

Expand All @@ -343,9 +332,6 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
if let Some(orig_parent_const_stab) = replaced_parent_const_stab {
self.parent_const_stab = orig_parent_const_stab;
}
if let Some(orig_parent_body_stab) = replaced_parent_body_stab {
self.parent_body_stab = orig_parent_body_stab;
}
}
}

Expand Down Expand Up @@ -646,7 +632,6 @@ fn stability_index(tcx: TyCtxt<'_>, (): ()) -> Index {
index: &mut index,
parent_stab: None,
parent_const_stab: None,
parent_body_stab: None,
parent_depr: None,
in_trait_impl: false,
};
Expand Down

0 comments on commit 963e402

Please sign in to comment.