Skip to content

Commit 3e6fa0c

Browse files
committed
Revert "passes: improved partial stabilization diagnostic"
This reverts commit 6246d66.
1 parent cd1a08a commit 3e6fa0c

File tree

11 files changed

+14
-115
lines changed

11 files changed

+14
-115
lines changed

compiler/rustc_metadata/src/rmeta/decoder.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -951,13 +951,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
951951
tcx.arena.alloc_from_iter(self.root.lib_features.decode(self))
952952
}
953953

954-
/// Iterates over the stability implications in the given crate (when a `#[unstable]` attribute
955-
/// has an `implied_by` meta item, then the mapping from the implied feature to the actual
956-
/// feature is a stability implication).
957-
fn get_stability_implications(self, tcx: TyCtxt<'tcx>) -> &'tcx [(Symbol, Symbol)] {
958-
tcx.arena.alloc_from_iter(self.root.stability_implications.decode(self))
959-
}
960-
961954
/// Iterates over the language items in the given crate.
962955
fn get_lang_items(self, tcx: TyCtxt<'tcx>) -> &'tcx [(DefId, usize)] {
963956
tcx.arena.alloc_from_iter(

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,6 @@ provide! { <'tcx> tcx, def_id, other, cdata,
291291
tcx.arena.alloc_slice(&result)
292292
}
293293
defined_lib_features => { cdata.get_lib_features(tcx) }
294-
stability_implications => {
295-
cdata.get_stability_implications(tcx).iter().copied().collect()
296-
}
297294
is_intrinsic => { cdata.get_is_intrinsic(def_id.index) }
298295
defined_lang_items => { cdata.get_lang_items(tcx) }
299296
diagnostic_items => { cdata.get_diagnostic_items() }

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -538,11 +538,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
538538
let lib_features = self.encode_lib_features();
539539
let lib_feature_bytes = self.position() - i;
540540

541-
// Encode the stability implications.
542-
i = self.position();
543-
let stability_implications = self.encode_stability_implications();
544-
let stability_implications_bytes = self.position() - i;
545-
546541
// Encode the language items.
547542
i = self.position();
548543
let lang_items = self.encode_lang_items();
@@ -691,7 +686,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
691686
crate_deps,
692687
dylib_dependency_formats,
693688
lib_features,
694-
stability_implications,
695689
lang_items,
696690
diagnostic_items,
697691
lang_items_missing,
@@ -716,7 +710,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
716710
let computed_total_bytes = preamble_bytes
717711
+ dep_bytes
718712
+ lib_feature_bytes
719-
+ stability_implications_bytes
720713
+ lang_item_bytes
721714
+ diagnostic_item_bytes
722715
+ native_lib_bytes
@@ -768,7 +761,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
768761
p("preamble", preamble_bytes);
769762
p("dep", dep_bytes);
770763
p("lib feature", lib_feature_bytes);
771-
p("stability_implications", stability_implications_bytes);
772764
p("lang item", lang_item_bytes);
773765
p("diagnostic item", diagnostic_item_bytes);
774766
p("native lib", native_lib_bytes);
@@ -1785,13 +1777,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
17851777
self.lazy_array(lib_features.to_vec())
17861778
}
17871779

1788-
fn encode_stability_implications(&mut self) -> LazyArray<(Symbol, Symbol)> {
1789-
empty_proc_macro!(self);
1790-
let tcx = self.tcx;
1791-
let implications = tcx.stability_implications(LOCAL_CRATE);
1792-
self.lazy_array(implications.iter().map(|(k, v)| (*k, *v)))
1793-
}
1794-
17951780
fn encode_diagnostic_items(&mut self) -> LazyArray<(Symbol, DefIndex)> {
17961781
empty_proc_macro!(self);
17971782
let tcx = self.tcx;

compiler/rustc_metadata/src/rmeta/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ pub(crate) struct CrateRoot {
226226
crate_deps: LazyArray<CrateDep>,
227227
dylib_dependency_formats: LazyArray<Option<LinkagePreference>>,
228228
lib_features: LazyArray<(Symbol, Option<Symbol>)>,
229-
stability_implications: LazyArray<(Symbol, Symbol)>,
230229
lang_items: LazyArray<(DefIndex, usize)>,
231230
lang_items_missing: LazyArray<lang_items::LangItem>,
232231
diagnostic_items: LazyArray<(Symbol, DefIndex)>,

compiler/rustc_middle/src/middle/stability.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,6 @@ pub struct Index {
6262
pub stab_map: FxHashMap<LocalDefId, Stability>,
6363
pub const_stab_map: FxHashMap<LocalDefId, ConstStability>,
6464
pub depr_map: FxHashMap<LocalDefId, DeprecationEntry>,
65-
/// Mapping from feature name to feature name based on the `implied_by` field of `#[unstable]`
66-
/// attributes. If a `#[unstable(feature = "implier", implied_by = "impliee")]` attribute
67-
/// exists, then this map will have a `impliee -> implier` entry.
68-
///
69-
/// This mapping is necessary unless both the `#[stable]` and `#[unstable]` attributes should
70-
/// specify their implications (both `implies` and `implied_by`). If only one of the two
71-
/// attributes do (as in the current implementation, `implied_by` in `#[unstable]`), then this
72-
/// mapping is necessary for diagnostics. When a "unnecessary feature attribute" error is
73-
/// reported, only the `#[stable]` attribute information is available, so the map is necessary
74-
/// to know that the feature implies another feature. If it were reversed, and the `#[stable]`
75-
/// attribute had an `implies` meta item, then a map would be necessary when avoiding a "use of
76-
/// unstable feature" error for a feature that was implied.
77-
pub implications: FxHashMap<Symbol, Symbol>,
7865
}
7966

8067
impl Index {

compiler/rustc_middle/src/query/mod.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,15 +1634,11 @@ rustc_queries! {
16341634
storage(ArenaCacheSelector<'tcx>)
16351635
desc { "calculating the lib features map" }
16361636
}
1637-
query defined_lib_features(_: CrateNum) -> &'tcx [(Symbol, Option<Symbol>)] {
1637+
query defined_lib_features(_: CrateNum)
1638+
-> &'tcx [(Symbol, Option<Symbol>)] {
16381639
desc { "calculating the lib features defined in a crate" }
16391640
separate_provide_extern
16401641
}
1641-
query stability_implications(_: CrateNum) -> FxHashMap<Symbol, Symbol> {
1642-
storage(ArenaCacheSelector<'tcx>)
1643-
desc { "calculating the implications between `#[unstable]` features defined in a crate" }
1644-
separate_provide_extern
1645-
}
16461642
/// Whether the function is an intrinsic
16471643
query is_intrinsic(def_id: DefId) -> bool {
16481644
desc { |tcx| "is_intrinsic({})", tcx.def_path_str(def_id) }

compiler/rustc_passes/src/stability.rs

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
//! propagating default levels lexically from parent to children ast nodes.
33
44
use attr::StabilityLevel;
5-
use rustc_attr::{self as attr, ConstStability, Stability, Unstable, UnstableReason};
5+
use rustc_attr::{self as attr, ConstStability, Stability, UnstableReason};
66
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
7-
use rustc_errors::{struct_span_err, Applicability};
7+
use rustc_errors::struct_span_err;
88
use rustc_hir as hir;
99
use rustc_hir::def::{DefKind, Res};
1010
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
@@ -265,10 +265,6 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
265265
}
266266
}
267267

268-
if let Stability { level: Unstable { implied_by: Some(implied_by), .. }, feature } = stab {
269-
self.index.implications.insert(implied_by, feature);
270-
}
271-
272268
self.index.stab_map.insert(def_id, stab);
273269
stab
274270
});
@@ -614,7 +610,6 @@ fn stability_index(tcx: TyCtxt<'_>, (): ()) -> Index {
614610
stab_map: Default::default(),
615611
const_stab_map: Default::default(),
616612
depr_map: Default::default(),
617-
implications: Default::default(),
618613
};
619614

620615
{
@@ -670,7 +665,6 @@ pub(crate) fn provide(providers: &mut Providers) {
670665
*providers = Providers {
671666
check_mod_unstable_api_usage,
672667
stability_index,
673-
stability_implications: |tcx, _| tcx.stability().implications.clone(),
674668
lookup_stability: |tcx, id| tcx.stability().local_stability(id.expect_local()),
675669
lookup_const_stability: |tcx, id| tcx.stability().local_const_stability(id.expect_local()),
676670
lookup_deprecation_entry: |tcx, id| {
@@ -949,18 +943,11 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
949943
remaining_lib_features.remove(&sym::libc);
950944
remaining_lib_features.remove(&sym::test);
951945

952-
let mut implications = tcx.stability_implications(rustc_hir::def_id::LOCAL_CRATE).clone();
953-
for &cnum in tcx.crates(()) {
954-
implications.extend(tcx.stability_implications(cnum));
955-
}
956-
957946
let check_features = |remaining_lib_features: &mut FxIndexMap<_, _>, defined_features: &[_]| {
958947
for &(feature, since) in defined_features {
959-
if let Some(since) = since && let Some(span) = remaining_lib_features.get(&feature) {
960-
// Warn if the user has enabled an already-stable lib feature.
961-
if let Some(implies) = implications.get(&feature) {
962-
unnecessary_partially_stable_feature_lint(tcx, *span, feature, *implies, since);
963-
} else {
948+
if let Some(since) = since {
949+
if let Some(span) = remaining_lib_features.get(&feature) {
950+
// Warn if the user has enabled an already-stable lib feature.
964951
unnecessary_stable_feature_lint(tcx, *span, feature, since);
965952
}
966953
}
@@ -993,41 +980,12 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
993980
// don't lint about unused features. We should re-enable this one day!
994981
}
995982

996-
fn unnecessary_partially_stable_feature_lint(
997-
tcx: TyCtxt<'_>,
998-
span: Span,
999-
feature: Symbol,
1000-
implies: Symbol,
1001-
since: Symbol,
1002-
) {
1003-
tcx.struct_span_lint_hir(lint::builtin::STABLE_FEATURES, hir::CRATE_HIR_ID, span, |lint| {
1004-
lint.build(&format!(
1005-
"the feature `{feature}` has been partially stabilized since {since} and is succeeded \
1006-
by the feature `{implies}`"
1007-
))
1008-
.span_suggestion(
1009-
span,
1010-
&format!(
1011-
"if you are using features which are still unstable, change to using `{implies}`"
1012-
),
1013-
implies,
1014-
Applicability::MaybeIncorrect,
1015-
)
1016-
.span_suggestion(
1017-
tcx.sess.source_map().span_extend_to_line(span),
1018-
"if you are using features which are now stable, remove this line",
1019-
"",
1020-
Applicability::MaybeIncorrect,
1021-
)
1022-
.emit();
1023-
});
1024-
}
1025-
1026983
fn unnecessary_stable_feature_lint(tcx: TyCtxt<'_>, span: Span, feature: Symbol, since: Symbol) {
1027984
tcx.struct_span_lint_hir(lint::builtin::STABLE_FEATURES, hir::CRATE_HIR_ID, span, |lint| {
1028985
lint.build(&format!(
1029-
"the feature `{feature}` has been stable since {since} and no longer requires an \
1030-
attribute to enable",
986+
"the feature `{}` has been stable since {} and no longer requires \
987+
an attribute to enable",
988+
feature, since
1031989
))
1032990
.emit();
1033991
});

src/test/ui/stability-attribute/stability-attribute-implies-using-stable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// aux-build:stability-attribute-implies.rs
22
#![deny(stable_features)]
33
#![feature(foo)]
4-
//~^ ERROR the feature `foo` has been partially stabilized since 1.62.0 and is succeeded by the feature `foobar`
4+
//~^ ERROR the feature `foo` has been stable since 1.62.0 and no longer requires an attribute to enable
55

66
// Tests that the use of `implied_by` in the `#[unstable]` attribute results in a diagnostic
77
// mentioning partial stabilization, and that given the implied unstable feature is unused (there
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: the feature `foo` has been partially stabilized since 1.62.0 and is succeeded by the feature `foobar`
1+
error: the feature `foo` has been stable since 1.62.0 and no longer requires an attribute to enable
22
--> $DIR/stability-attribute-implies-using-stable.rs:3:12
33
|
44
LL | #![feature(foo)]
@@ -9,14 +9,6 @@ note: the lint level is defined here
99
|
1010
LL | #![deny(stable_features)]
1111
| ^^^^^^^^^^^^^^^
12-
help: if you are using features which are still unstable, change to using `foobar`
13-
|
14-
LL | #![feature(foobar)]
15-
| ~~~~~~
16-
help: if you are using features which are now stable, remove this line
17-
|
18-
LL - #![feature(foo)]
19-
|
2012

2113
error: aborting due to previous error
2214

src/test/ui/stability-attribute/stability-attribute-implies-using-unstable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// aux-build:stability-attribute-implies.rs
22
#![deny(stable_features)]
33
#![feature(foo)]
4-
//~^ ERROR the feature `foo` has been partially stabilized since 1.62.0 and is succeeded by the feature `foobar`
4+
//~^ ERROR the feature `foo` has been stable since 1.62.0 and no longer requires an attribute to enable
55

66
// Tests that the use of `implied_by` in the `#[unstable]` attribute results in a diagnostic
77
// mentioning partial stabilization and that given the implied unstable feature is used (there is a
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: the feature `foo` has been partially stabilized since 1.62.0 and is succeeded by the feature `foobar`
1+
error: the feature `foo` has been stable since 1.62.0 and no longer requires an attribute to enable
22
--> $DIR/stability-attribute-implies-using-unstable.rs:3:12
33
|
44
LL | #![feature(foo)]
@@ -9,14 +9,6 @@ note: the lint level is defined here
99
|
1010
LL | #![deny(stable_features)]
1111
| ^^^^^^^^^^^^^^^
12-
help: if you are using features which are still unstable, change to using `foobar`
13-
|
14-
LL | #![feature(foobar)]
15-
| ~~~~~~
16-
help: if you are using features which are now stable, remove this line
17-
|
18-
LL - #![feature(foo)]
19-
|
2012

2113
error: aborting due to previous error
2214

0 commit comments

Comments
 (0)