Skip to content

Commit 9fb80b1

Browse files
committed
Retire stability_index query.
1 parent 6dad5e8 commit 9fb80b1

File tree

5 files changed

+26
-47
lines changed

5 files changed

+26
-47
lines changed

compiler/rustc_interface/src/passes.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,6 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
10651065
// This marks the corresponding crate-level attributes
10661066
// as used, and ensures that their values are valid.
10671067
tcx.ensure_ok().limits(());
1068-
tcx.ensure_ok().stability_index(());
10691068
}
10701069
);
10711070
});

compiler/rustc_middle/src/middle/stability.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use rustc_ast::NodeId;
77
use rustc_attr_data_structures::{
88
self as attrs, ConstStability, DefaultBodyStability, DeprecatedSince, Deprecation, Stability,
99
};
10-
use rustc_data_structures::unord::UnordMap;
1110
use rustc_errors::{Applicability, Diag, EmissionGuarantee};
1211
use rustc_feature::GateIssue;
1312
use rustc_hir::def_id::{DefId, LocalDefId};
@@ -65,24 +64,6 @@ impl DeprecationEntry {
6564
}
6665
}
6766

68-
/// A stability index, giving the stability level for items and methods.
69-
#[derive(HashStable, Debug)]
70-
pub struct Index {
71-
/// Mapping from feature name to feature name based on the `implied_by` field of `#[unstable]`
72-
/// attributes. If a `#[unstable(feature = "implier", implied_by = "impliee")]` attribute
73-
/// exists, then this map will have a `impliee -> implier` entry.
74-
///
75-
/// This mapping is necessary unless both the `#[stable]` and `#[unstable]` attributes should
76-
/// specify their implications (both `implies` and `implied_by`). If only one of the two
77-
/// attributes do (as in the current implementation, `implied_by` in `#[unstable]`), then this
78-
/// mapping is necessary for diagnostics. When a "unnecessary feature attribute" error is
79-
/// reported, only the `#[stable]` attribute information is available, so the map is necessary
80-
/// to know that the feature implies another feature. If it were reversed, and the `#[stable]`
81-
/// attribute had an `implies` meta item, then a map would be necessary when avoiding a "use of
82-
/// unstable feature" error for a feature that was implied.
83-
pub implications: UnordMap<Symbol, Symbol>,
84-
}
85-
8667
pub fn report_unstable(
8768
sess: &Session,
8869
feature: Symbol,

compiler/rustc_middle/src/query/mod.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ use crate::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo};
112112
use crate::middle::lib_features::LibFeatures;
113113
use crate::middle::privacy::EffectiveVisibilities;
114114
use crate::middle::resolve_bound_vars::{ObjectLifetimeDefault, ResolveBoundVars, ResolvedArg};
115-
use crate::middle::stability::{self, DeprecationEntry};
115+
use crate::middle::stability::DeprecationEntry;
116116
use crate::mir::interpret::{
117117
EvalStaticInitializerRawResult, EvalToAllocationRawResult, EvalToConstValueResult,
118118
EvalToValTreeResult, GlobalId, LitToConstInput,
@@ -2162,6 +2162,18 @@ rustc_queries! {
21622162
separate_provide_extern
21632163
arena_cache
21642164
}
2165+
/// Mapping from feature name to feature name based on the `implied_by` field of `#[unstable]`
2166+
/// attributes. If a `#[unstable(feature = "implier", implied_by = "impliee")]` attribute
2167+
/// exists, then this map will have a `impliee -> implier` entry.
2168+
///
2169+
/// This mapping is necessary unless both the `#[stable]` and `#[unstable]` attributes should
2170+
/// specify their implications (both `implies` and `implied_by`). If only one of the two
2171+
/// attributes do (as in the current implementation, `implied_by` in `#[unstable]`), then this
2172+
/// mapping is necessary for diagnostics. When a "unnecessary feature attribute" error is
2173+
/// reported, only the `#[stable]` attribute information is available, so the map is necessary
2174+
/// to know that the feature implies another feature. If it were reversed, and the `#[stable]`
2175+
/// attribute had an `implies` meta item, then a map would be necessary when avoiding a "use of
2176+
/// unstable feature" error for a feature that was implied.
21652177
query stability_implications(_: CrateNum) -> &'tcx UnordMap<Symbol, Symbol> {
21662178
arena_cache
21672179
desc { "calculating the implications between `#[unstable]` features defined in a crate" }
@@ -2268,11 +2280,6 @@ rustc_queries! {
22682280
desc { "fetching potentially unused trait imports" }
22692281
}
22702282

2271-
query stability_index(_: ()) -> &'tcx stability::Index {
2272-
arena_cache
2273-
eval_always
2274-
desc { "calculating the stability index for the local crate" }
2275-
}
22762283
/// All available crates in the graph, including those that should not be user-facing
22772284
/// (such as private crates).
22782285
query crates(_: ()) -> &'tcx [CrateNum] {

compiler/rustc_middle/src/ty/context.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ use crate::infer::canonical::{CanonicalParamEnvCache, CanonicalVarKind, Canonica
6565
use crate::lint::lint_level;
6666
use crate::metadata::ModChild;
6767
use crate::middle::codegen_fn_attrs::{CodegenFnAttrs, TargetFeature};
68-
use crate::middle::{resolve_bound_vars, stability};
68+
use crate::middle::resolve_bound_vars;
6969
use crate::mir::interpret::{self, Allocation, ConstAllocation};
7070
use crate::mir::{Body, Local, Place, PlaceElem, ProjectionKind, Promoted};
7171
use crate::query::plumbing::QuerySystem;
@@ -1799,10 +1799,6 @@ impl<'tcx> TyCtxt<'tcx> {
17991799
)
18001800
}
18011801

1802-
pub fn stability(self) -> &'tcx stability::Index {
1803-
self.stability_index(())
1804-
}
1805-
18061802
pub fn features(self) -> &'tcx rustc_feature::Features {
18071803
self.features_query(())
18081804
}

compiler/rustc_passes/src/stability.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ use rustc_hir::{self as hir, AmbigArg, FieldDef, Item, ItemKind, TraitRef, Ty, T
1919
use rustc_middle::hir::nested_filter;
2020
use rustc_middle::middle::lib_features::{FeatureStability, LibFeatures};
2121
use rustc_middle::middle::privacy::EffectiveVisibilities;
22-
use rustc_middle::middle::stability::{
23-
AllowUnstable, Deprecated, DeprecationEntry, EvalResult, Index,
24-
};
25-
use rustc_middle::query::Providers;
22+
use rustc_middle::middle::stability::{AllowUnstable, Deprecated, DeprecationEntry, EvalResult};
23+
use rustc_middle::query::{LocalCrate, Providers};
2624
use rustc_middle::ty::TyCtxt;
2725
use rustc_middle::ty::print::with_no_trimmed_paths;
2826
use rustc_session::lint;
@@ -317,12 +315,12 @@ fn lookup_const_stability(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<ConstSt
317315
}
318316

319317
/// A private tree-walker for producing an `Index`.
320-
struct Annotator<'a, 'tcx> {
318+
struct Annotator<'tcx> {
321319
tcx: TyCtxt<'tcx>,
322-
index: &'a mut Index,
320+
implications: UnordMap<Symbol, Symbol>,
323321
}
324322

325-
impl<'a, 'tcx> Annotator<'a, 'tcx> {
323+
impl<'tcx> Annotator<'tcx> {
326324
/// Determine the stability for a node based on its attributes and inherited stability. The
327325
/// stability is recorded in the index and used as the parent. If the node is a function,
328326
/// `fn_sig` is its signature.
@@ -335,18 +333,18 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
335333
if let Some(stability) = self.tcx.lookup_stability(def_id)
336334
&& let StabilityLevel::Unstable { implied_by: Some(implied_by), .. } = stability.level
337335
{
338-
self.index.implications.insert(implied_by, stability.feature);
336+
self.implications.insert(implied_by, stability.feature);
339337
}
340338

341339
if let Some(stability) = self.tcx.lookup_const_stability(def_id)
342340
&& let StabilityLevel::Unstable { implied_by: Some(implied_by), .. } = stability.level
343341
{
344-
self.index.implications.insert(implied_by, stability.feature);
342+
self.implications.insert(implied_by, stability.feature);
345343
}
346344
}
347345
}
348346

349-
impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
347+
impl<'tcx> Visitor<'tcx> for Annotator<'tcx> {
350348
/// Because stability levels are scoped lexically, we want to walk
351349
/// nested items in the context of the outer item, so enable
352350
/// deep-walking.
@@ -610,12 +608,11 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> {
610608
}
611609
}
612610

613-
fn stability_index(tcx: TyCtxt<'_>, (): ()) -> Index {
614-
let mut index = Index { implications: Default::default() };
615-
let mut annotator = Annotator { tcx, index: &mut index };
611+
fn stability_implications(tcx: TyCtxt<'_>, LocalCrate: LocalCrate) -> UnordMap<Symbol, Symbol> {
612+
let mut annotator = Annotator { tcx, implications: Default::default() };
616613
annotator.annotate(CRATE_DEF_ID);
617614
tcx.hir_walk_toplevel_module(&mut annotator);
618-
index
615+
annotator.implications
619616
}
620617

621618
/// Cross-references the feature names of unstable APIs with enabled
@@ -627,8 +624,7 @@ fn check_mod_unstable_api_usage(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) {
627624
pub(crate) fn provide(providers: &mut Providers) {
628625
*providers = Providers {
629626
check_mod_unstable_api_usage,
630-
stability_index,
631-
stability_implications: |tcx, _| tcx.stability().implications.clone(),
627+
stability_implications,
632628
lookup_stability,
633629
lookup_const_stability,
634630
lookup_default_body_stability,

0 commit comments

Comments
 (0)