From 227d91248988f24c14f9d440ec0171c844bd89e0 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 19 Feb 2022 15:36:11 +0100 Subject: Stop interning stability. --- compiler/rustc_middle/src/middle/stability.rs | 14 +++++++------- compiler/rustc_middle/src/query/mod.rs | 6 +++--- compiler/rustc_middle/src/ty/context.rs | 19 +------------------ 3 files changed, 11 insertions(+), 28 deletions(-) (limited to 'compiler/rustc_middle/src') diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs index fedf456ccc8..54d53a810b1 100644 --- a/compiler/rustc_middle/src/middle/stability.rs +++ b/compiler/rustc_middle/src/middle/stability.rs @@ -57,11 +57,11 @@ impl DeprecationEntry { /// A stability index, giving the stability level for items and methods. #[derive(HashStable, Debug)] -pub struct Index<'tcx> { +pub struct Index { /// This is mostly a cache, except the stabilities of local items /// are filled by the annotator. - pub stab_map: FxHashMap, - pub const_stab_map: FxHashMap, + pub stab_map: FxHashMap, + pub const_stab_map: FxHashMap, pub depr_map: FxHashMap, /// Maps for each crate whether it is part of the staged API. @@ -71,12 +71,12 @@ pub struct Index<'tcx> { pub active_features: FxHashSet, } -impl<'tcx> Index<'tcx> { - pub fn local_stability(&self, def_id: LocalDefId) -> Option<&'tcx Stability> { +impl Index { + pub fn local_stability(&self, def_id: LocalDefId) -> Option { self.stab_map.get(&def_id).copied() } - pub fn local_const_stability(&self, def_id: LocalDefId) -> Option<&'tcx ConstStability> { + pub fn local_const_stability(&self, def_id: LocalDefId) -> Option { self.const_stab_map.get(&def_id).copied() } @@ -416,7 +416,7 @@ impl<'tcx> TyCtxt<'tcx> { } match stability { - Some(&Stability { + Some(Stability { level: attr::Unstable { reason, issue, is_soft }, feature, .. }) => { if span.allows_unstable(feature) { diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 43cfe6f3b8a..46103b77ade 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -1010,12 +1010,12 @@ rustc_queries! { separate_provide_extern } - query lookup_stability(def_id: DefId) -> Option<&'tcx attr::Stability> { + query lookup_stability(def_id: DefId) -> Option { desc { |tcx| "looking up stability of `{}`", tcx.def_path_str(def_id) } separate_provide_extern } - query lookup_const_stability(def_id: DefId) -> Option<&'tcx attr::ConstStability> { + query lookup_const_stability(def_id: DefId) -> Option { desc { |tcx| "looking up const stability of `{}`", tcx.def_path_str(def_id) } separate_provide_extern } @@ -1626,7 +1626,7 @@ rustc_queries! { desc { |tcx| "names_imported_by_glob_use for `{}`", tcx.def_path_str(def_id.to_def_id()) } } - query stability_index(_: ()) -> stability::Index<'tcx> { + query stability_index(_: ()) -> stability::Index { storage(ArenaCacheSelector<'tcx>) eval_always desc { "calculating the stability index for the local crate" } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 41145d25017..33db83f0524 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -24,7 +24,6 @@ use crate::ty::{ RegionKind, ReprOptions, TraitObjectVisitor, Ty, TyKind, TyS, TyVar, TyVid, TypeAndMut, UintTy, }; use rustc_ast as ast; -use rustc_attr as attr; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::intern::Interned; use rustc_data_structures::memmap::Mmap; @@ -116,12 +115,6 @@ pub struct CtxtInterners<'tcx> { bound_variable_kinds: InternedSet<'tcx, List>, layout: InternedSet<'tcx, Layout>, adt_def: InternedSet<'tcx, AdtDef>, - - /// `#[stable]` and `#[unstable]` attributes - stability: InternedSet<'tcx, attr::Stability>, - - /// `#[rustc_const_stable]` and `#[rustc_const_unstable]` attributes - const_stability: InternedSet<'tcx, attr::ConstStability>, } impl<'tcx> CtxtInterners<'tcx> { @@ -143,8 +136,6 @@ impl<'tcx> CtxtInterners<'tcx> { bound_variable_kinds: Default::default(), layout: Default::default(), adt_def: Default::default(), - stability: Default::default(), - const_stability: Default::default(), } } @@ -1271,7 +1262,7 @@ impl<'tcx> TyCtxt<'tcx> { self.diagnostic_items(did.krate).name_to_id.get(&name) == Some(&did) } - pub fn stability(self) -> &'tcx stability::Index<'tcx> { + pub fn stability(self) -> &'tcx stability::Index { self.stability_index(()) } @@ -1981,12 +1972,6 @@ impl<'tcx> TyCtxt<'tcx> { writeln!(fmt, "InternalSubsts interner: #{}", self.0.interners.substs.len())?; writeln!(fmt, "Region interner: #{}", self.0.interners.region.len())?; - writeln!(fmt, "Stability interner: #{}", self.0.interners.stability.len())?; - writeln!( - fmt, - "Const Stability interner: #{}", - self.0.interners.const_stability.len() - )?; writeln!( fmt, "Const Allocation interner: #{}", @@ -2174,8 +2159,6 @@ direct_interners_old! { const_allocation: intern_const_alloc(Allocation), layout: intern_layout(Layout), adt_def: intern_adt_def(AdtDef), - stability: intern_stability(attr::Stability), - const_stability: intern_const_stability(attr::ConstStability), } macro_rules! slice_interners { -- cgit 1.4.1-3-g733a5