diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs index 8a5fc5feeb71b..1185356cdb680 100644 --- a/compiler/rustc_middle/src/middle/stability.rs +++ b/compiler/rustc_middle/src/middle/stability.rs @@ -424,7 +424,7 @@ impl<'tcx> TyCtxt<'tcx> { debug!("stability: skipping span={:?} since it is internal", span); return EvalResult::Allow; } - if self.stability().active_features.contains(&feature) { + if self.stability_index(()).active_features.contains(&feature) { return EvalResult::Allow; } diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index ca93efbf19b7b..86b998fb01c51 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -1575,7 +1575,6 @@ rustc_queries! { query stability_index(_: ()) -> stability::Index<'tcx> { storage(ArenaCacheSelector<'tcx>) - eval_always desc { "calculating the stability index for the local crate" } } query crates(_: ()) -> &'tcx [CrateNum] { diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 8240273acad4c..249c37ed680dd 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -7,7 +7,6 @@ use crate::infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos}; use crate::lint::{struct_lint_level, LintDiagnosticBuilder, LintLevelSource}; use crate::middle; use crate::middle::resolve_lifetime::{self, LifetimeScopeForPath, ObjectLifetimeDefault}; -use crate::middle::stability; use crate::mir::interpret::{self, Allocation, ConstValue, Scalar}; use crate::mir::{Body, Field, Local, Place, PlaceElem, ProjectionKind, Promoted}; use crate::thir::Thir; @@ -1242,10 +1241,6 @@ impl<'tcx> TyCtxt<'tcx> { self.diagnostic_items(did.krate).name_to_id.get(&name) == Some(&did) } - pub fn stability(self) -> &'tcx stability::Index<'tcx> { - self.stability_index(()) - } - pub fn features(self) -> &'tcx rustc_feature::Features { self.features_query(()) } @@ -2856,12 +2851,6 @@ pub fn provide(providers: &mut ty::query::Providers) { providers.names_imported_by_glob_use = |tcx, id| { tcx.arena.alloc(tcx.resolutions(()).glob_map.get(&id).cloned().unwrap_or_default()) }; - - providers.lookup_stability = |tcx, id| tcx.stability().local_stability(id.expect_local()); - providers.lookup_const_stability = - |tcx, id| tcx.stability().local_const_stability(id.expect_local()); - providers.lookup_deprecation_entry = - |tcx, id| tcx.stability().local_deprecation_entry(id.expect_local()); providers.extern_mod_stmt_cnum = |tcx, id| tcx.resolutions(()).extern_crate_map.get(&id).cloned(); providers.output_filenames = |tcx, ()| tcx.output_filenames.clone(); diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index 8c9f04bef1376..e158426a4d11a 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -569,7 +569,7 @@ struct MissingStabilityAnnotations<'tcx> { impl<'tcx> MissingStabilityAnnotations<'tcx> { fn check_missing_stability(&self, def_id: LocalDefId, span: Span) { - let stab = self.tcx.stability().local_stability(def_id); + let stab = self.tcx.stability_index(()).local_stability(def_id); if !self.tcx.sess.opts.test && stab.is_none() && self.access_levels.is_reachable(def_id) { let descr = self.tcx.def_kind(def_id).descr(def_id.to_def_id()); self.tcx.sess.span_err(span, &format!("{} has missing stability attribute", descr)); @@ -577,7 +577,7 @@ impl<'tcx> MissingStabilityAnnotations<'tcx> { } fn check_missing_const_stability(&self, def_id: LocalDefId, span: Span) { - let stab_map = self.tcx.stability(); + let stab_map = self.tcx.stability_index(()); let stab = stab_map.local_stability(def_id); if stab.map_or(false, |stab| stab.level.is_stable()) { let const_stab = stab_map.local_const_stability(def_id); @@ -730,7 +730,18 @@ fn check_mod_unstable_api_usage(tcx: TyCtxt<'_>, module_def_id: LocalDefId) { } pub(crate) fn provide(providers: &mut Providers) { - *providers = Providers { check_mod_unstable_api_usage, stability_index, ..*providers }; + *providers = Providers { + check_mod_unstable_api_usage, + stability_index, + lookup_stability: |tcx, id| tcx.stability_index(()).local_stability(id.expect_local()), + lookup_const_stability: |tcx, id| { + tcx.stability_index(()).local_const_stability(id.expect_local()) + }, + lookup_deprecation_entry: |tcx, id| { + tcx.stability_index(()).local_deprecation_entry(id.expect_local()) + }, + ..*providers + }; } struct Checker<'tcx> { @@ -905,7 +916,7 @@ impl Visitor<'tcx> for CheckTraitImplStable<'tcx> { pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) { let access_levels = &tcx.privacy_access_levels(()); - if tcx.stability().staged_api[&LOCAL_CRATE] { + if tcx.stability_index(()).staged_api[&LOCAL_CRATE] { let mut missing = MissingStabilityAnnotations { tcx, access_levels }; missing.check_missing_stability(CRATE_DEF_ID, tcx.hir().span(CRATE_HIR_ID)); tcx.hir().walk_toplevel_module(&mut missing);