Skip to content

Remove eval_always for stability_index. #91331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_middle/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Expand Down
11 changes: 0 additions & 11 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(())
}
Expand Down Expand Up @@ -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();
Expand Down
19 changes: 15 additions & 4 deletions compiler/rustc_passes/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,15 +569,15 @@ 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));
}
}

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);
Expand Down Expand Up @@ -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> {
Expand Down Expand Up @@ -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);
Expand Down