Skip to content

Commit 6167bc5

Browse files
committed
Remove eval_always for stability_index.
1 parent e6d2de9 commit 6167bc5

File tree

4 files changed

+16
-17
lines changed

4 files changed

+16
-17
lines changed

compiler/rustc_middle/src/middle/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ impl<'tcx> TyCtxt<'tcx> {
424424
debug!("stability: skipping span={:?} since it is internal", span);
425425
return EvalResult::Allow;
426426
}
427-
if self.stability().active_features.contains(&feature) {
427+
if self.stability_index(()).active_features.contains(&feature) {
428428
return EvalResult::Allow;
429429
}
430430

compiler/rustc_middle/src/query/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,6 @@ rustc_queries! {
15751575

15761576
query stability_index(_: ()) -> stability::Index<'tcx> {
15771577
storage(ArenaCacheSelector<'tcx>)
1578-
eval_always
15791578
desc { "calculating the stability index for the local crate" }
15801579
}
15811580
query crates(_: ()) -> &'tcx [CrateNum] {

compiler/rustc_middle/src/ty/context.rs

-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos};
77
use crate::lint::{struct_lint_level, LintDiagnosticBuilder, LintLevelSource};
88
use crate::middle;
99
use crate::middle::resolve_lifetime::{self, LifetimeScopeForPath, ObjectLifetimeDefault};
10-
use crate::middle::stability;
1110
use crate::mir::interpret::{self, Allocation, ConstValue, Scalar};
1211
use crate::mir::{Body, Field, Local, Place, PlaceElem, ProjectionKind, Promoted};
1312
use crate::thir::Thir;
@@ -1242,10 +1241,6 @@ impl<'tcx> TyCtxt<'tcx> {
12421241
self.diagnostic_items(did.krate).name_to_id.get(&name) == Some(&did)
12431242
}
12441243

1245-
pub fn stability(self) -> &'tcx stability::Index<'tcx> {
1246-
self.stability_index(())
1247-
}
1248-
12491244
pub fn features(self) -> &'tcx rustc_feature::Features {
12501245
self.features_query(())
12511246
}
@@ -2856,12 +2851,6 @@ pub fn provide(providers: &mut ty::query::Providers) {
28562851
providers.names_imported_by_glob_use = |tcx, id| {
28572852
tcx.arena.alloc(tcx.resolutions(()).glob_map.get(&id).cloned().unwrap_or_default())
28582853
};
2859-
2860-
providers.lookup_stability = |tcx, id| tcx.stability().local_stability(id.expect_local());
2861-
providers.lookup_const_stability =
2862-
|tcx, id| tcx.stability().local_const_stability(id.expect_local());
2863-
providers.lookup_deprecation_entry =
2864-
|tcx, id| tcx.stability().local_deprecation_entry(id.expect_local());
28652854
providers.extern_mod_stmt_cnum =
28662855
|tcx, id| tcx.resolutions(()).extern_crate_map.get(&id).cloned();
28672856
providers.output_filenames = |tcx, ()| tcx.output_filenames.clone();

compiler/rustc_passes/src/stability.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -569,15 +569,15 @@ struct MissingStabilityAnnotations<'tcx> {
569569

570570
impl<'tcx> MissingStabilityAnnotations<'tcx> {
571571
fn check_missing_stability(&self, def_id: LocalDefId, span: Span) {
572-
let stab = self.tcx.stability().local_stability(def_id);
572+
let stab = self.tcx.stability_index(()).local_stability(def_id);
573573
if !self.tcx.sess.opts.test && stab.is_none() && self.access_levels.is_reachable(def_id) {
574574
let descr = self.tcx.def_kind(def_id).descr(def_id.to_def_id());
575575
self.tcx.sess.span_err(span, &format!("{} has missing stability attribute", descr));
576576
}
577577
}
578578

579579
fn check_missing_const_stability(&self, def_id: LocalDefId, span: Span) {
580-
let stab_map = self.tcx.stability();
580+
let stab_map = self.tcx.stability_index(());
581581
let stab = stab_map.local_stability(def_id);
582582
if stab.map_or(false, |stab| stab.level.is_stable()) {
583583
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) {
730730
}
731731

732732
pub(crate) fn provide(providers: &mut Providers) {
733-
*providers = Providers { check_mod_unstable_api_usage, stability_index, ..*providers };
733+
*providers = Providers {
734+
check_mod_unstable_api_usage,
735+
stability_index,
736+
lookup_stability: |tcx, id| tcx.stability_index(()).local_stability(id.expect_local()),
737+
lookup_const_stability: |tcx, id| {
738+
tcx.stability_index(()).local_const_stability(id.expect_local())
739+
},
740+
lookup_deprecation_entry: |tcx, id| {
741+
tcx.stability_index(()).local_deprecation_entry(id.expect_local())
742+
},
743+
..*providers
744+
};
734745
}
735746

736747
struct Checker<'tcx> {
@@ -905,7 +916,7 @@ impl Visitor<'tcx> for CheckTraitImplStable<'tcx> {
905916
pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
906917
let access_levels = &tcx.privacy_access_levels(());
907918

908-
if tcx.stability().staged_api[&LOCAL_CRATE] {
919+
if tcx.stability_index(()).staged_api[&LOCAL_CRATE] {
909920
let mut missing = MissingStabilityAnnotations { tcx, access_levels };
910921
missing.check_missing_stability(CRATE_DEF_ID, tcx.hir().span(CRATE_HIR_ID));
911922
tcx.hir().walk_toplevel_module(&mut missing);

0 commit comments

Comments
 (0)