Skip to content

Commit 0a542e3

Browse files
committed
Note the version and PR of removed features when using it
Signed-off-by: xizheyin <[email protected]>
1 parent 8ddc69e commit 0a542e3

11 files changed

+126
-91
lines changed

compiler/rustc_expand/messages.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ expand_feature_not_allowed =
6262
expand_feature_removed =
6363
feature has been removed
6464
.label = feature has been removed
65+
.note = removed in {$removed_rustc_version} (you are using {$current_rustc_version}){$pull_note}
6566
.reason = {$reason}
6667
6768
expand_glob_delegation_outside_impls =

compiler/rustc_expand/src/config.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,24 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute], crate_name: Symbol) -
8181

8282
// If the enabled feature has been removed, issue an error.
8383
if let Some(f) = REMOVED_LANG_FEATURES.iter().find(|f| name == f.feature.name) {
84+
let span = mi.span();
85+
let reason = f.reason.map(|reason| FeatureRemovedReason { reason });
86+
let removed_rustc_version = f.feature.since;
87+
let current_rustc_version = sess.cfg_version;
88+
let pull_note = if let Some(pull) = f.pull {
89+
format!(
90+
"; see <https://github.com/rust-lang/rust/pull/{}> for more information",
91+
pull
92+
)
93+
} else {
94+
"".to_owned()
95+
};
8496
sess.dcx().emit_err(FeatureRemoved {
85-
span: mi.span(),
86-
reason: f.reason.map(|reason| FeatureRemovedReason { reason }),
97+
span,
98+
reason,
99+
removed_rustc_version,
100+
current_rustc_version,
101+
pull_note,
87102
});
88103
continue;
89104
}

compiler/rustc_expand/src/errors.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,16 @@ pub(crate) struct HelperAttributeNameInvalid {
154154

155155
#[derive(Diagnostic)]
156156
#[diag(expand_feature_removed, code = E0557)]
157+
#[note]
157158
pub(crate) struct FeatureRemoved<'a> {
158159
#[primary_span]
159160
#[label]
160161
pub span: Span,
161162
#[subdiagnostic]
162163
pub reason: Option<FeatureRemovedReason<'a>>,
164+
pub removed_rustc_version: &'a str,
165+
pub current_rustc_version: &'a str,
166+
pub pull_note: String,
163167
}
164168

165169
#[derive(Subdiagnostic)]

compiler/rustc_feature/src/removed.rs

Lines changed: 94 additions & 89 deletions
Large diffs are not rendered by default.

tests/ui/deprecation/deprecated_no_stack_check.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ error[E0557]: feature has been removed
33
|
44
LL | #![feature(no_stack_check)]
55
| ^^^^^^^^^^^^^^ feature has been removed
6+
|
7+
= note: removed in 1.0.0 (you are using 1.89.0-dev)
68

79
error: aborting due to 1 previous error
810

tests/ui/feature-gates/feature-gate-coverage-attribute.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ error[E0557]: feature has been removed
44
LL | #![feature(no_coverage)]
55
| ^^^^^^^^^^^ feature has been removed
66
|
7+
= note: removed in 1.74.0 (you are using 1.89.0-dev)
78
= note: renamed to `coverage_attribute`
89

910
error[E0658]: the `#[coverage]` attribute is an experimental feature

tests/ui/feature-gates/gated-bad-feature.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ error[E0557]: feature has been removed
1515
|
1616
LL | #![feature(test_removed_feature)]
1717
| ^^^^^^^^^^^^^^^^^^^^ feature has been removed
18+
|
19+
= note: removed in 1.0.0 (you are using 1.89.0-dev)
1820

1921
error: malformed `feature` attribute input
2022
--> $DIR/gated-bad-feature.rs:6:1

tests/ui/feature-gates/removed-features-note-version-and-pr-issue-141619.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ error[E0557]: feature has been removed
44
LL | #![feature(external_doc)]
55
| ^^^^^^^^^^^^ feature has been removed
66
|
7+
= note: removed in 1.54.0 (you are using 1.89.0-dev); see <https://github.com/rust-lang/rust/pull/85457> for more information
78
= note: use #[doc = include_str!("filename")] instead, which handles macro invocations
89

910
error: unknown `doc` attribute `include`

tests/ui/macros/macro-reexport-removed.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ error[E0557]: feature has been removed
44
LL | #![feature(macro_reexport)]
55
| ^^^^^^^^^^^^^^ feature has been removed
66
|
7+
= note: removed in 1.0.0 (you are using 1.89.0-dev)
78
= note: subsumed by `pub use`
89

910
error: cannot find attribute `macro_reexport` in this scope

tests/ui/rustdoc/renamed-features-rustdoc_internals.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ error[E0557]: feature has been removed
44
LL | #![feature(doc_keyword)]
55
| ^^^^^^^^^^^ feature has been removed
66
|
7+
= note: removed in 1.28.0 (you are using 1.89.0-dev)
78
= note: merged into `#![feature(rustdoc_internals)]`
89

910
error[E0557]: feature has been removed
@@ -12,6 +13,7 @@ error[E0557]: feature has been removed
1213
LL | #![feature(doc_primitive)]
1314
| ^^^^^^^^^^^^^ feature has been removed
1415
|
16+
= note: removed in 1.56.0 (you are using 1.89.0-dev)
1517
= note: merged into `#![feature(rustdoc_internals)]`
1618

1719
error: aborting due to 2 previous errors

tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ error[E0557]: feature has been removed
44
LL | #![feature(const_trait_impl, effects)]
55
| ^^^^^^^ feature has been removed
66
|
7+
= note: removed in 1.84.0 (you are using 1.89.0-dev)
78
= note: removed, redundant with `#![feature(const_trait_impl)]`
89

910
error[E0049]: associated function `compute` has 0 type parameters but its trait declaration has 1 type parameter

0 commit comments

Comments
 (0)