Don't include current rustc version string in feature removed help

The version string is difficult to properly normalize out, and removing
it isn't a huge deal (the user can query version info easily through
`rustc --version` or `cargo --version`).

The normalization options were all non-ideal:

- Per-test version string normalization is nasty to maintain, and we
  need to maintain `n` copies of it.
- Centralized compiletest normalization (with a directive opt-out) is
  also not ideal, because `cfg(version(..))` tests can't have those
  accidentally normalized out (and you'd have to remember to opt-out).
This commit is contained in:
Jieyou Xu
2025-06-24 10:09:58 +08:00
parent 36b21637e9
commit db11e74723
19 changed files with 29 additions and 44 deletions

View File

@@ -62,7 +62,7 @@ expand_feature_not_allowed =
expand_feature_removed =
feature has been removed
.label = feature has been removed
.note = removed in {$removed_rustc_version} (you are using {$current_rustc_version}){$pull_note}
.note = removed in {$removed_rustc_version}{$pull_note}
.reason = {$reason}
expand_glob_delegation_outside_impls =

View File

@@ -92,7 +92,6 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute], crate_name: Symbol) -
span: mi.span(),
reason: f.reason.map(|reason| FeatureRemovedReason { reason }),
removed_rustc_version: f.feature.since,
current_rustc_version: sess.cfg_version,
pull_note,
});
continue;

View File

@@ -162,7 +162,6 @@ pub(crate) struct FeatureRemoved<'a> {
#[subdiagnostic]
pub reason: Option<FeatureRemovedReason<'a>>,
pub removed_rustc_version: &'a str,
pub current_rustc_version: &'a str,
pub pull_note: String,
}

View File

@@ -1,5 +1,3 @@
//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
#![deny(warnings)]
#![feature(no_stack_check)]
//~^ ERROR: feature has been removed [E0557]

View File

@@ -1,10 +1,10 @@
error[E0557]: feature has been removed
--> $DIR/deprecated_no_stack_check.rs:4:12
--> $DIR/deprecated_no_stack_check.rs:2:12
|
LL | #![feature(no_stack_check)]
| ^^^^^^^^^^^^^^ feature has been removed
|
= note: removed in 1.0.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/40110> for more information
= note: removed in 1.0.0; see <https://github.com/rust-lang/rust/pull/40110> for more information
error: aborting due to 1 previous error

View File

@@ -1,5 +1,3 @@
//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
#![crate_type = "lib"]
#![feature(no_coverage)] //~ ERROR feature has been removed [E0557]

View File

@@ -1,14 +1,14 @@
error[E0557]: feature has been removed
--> $DIR/feature-gate-coverage-attribute.rs:4:12
--> $DIR/feature-gate-coverage-attribute.rs:2:12
|
LL | #![feature(no_coverage)]
| ^^^^^^^^^^^ feature has been removed
|
= note: removed in 1.74.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/114656> for more information
= note: removed in 1.74.0; see <https://github.com/rust-lang/rust/pull/114656> for more information
= note: renamed to `coverage_attribute`
error[E0658]: the `#[coverage]` attribute is an experimental feature
--> $DIR/feature-gate-coverage-attribute.rs:12:1
--> $DIR/feature-gate-coverage-attribute.rs:10:1
|
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^

View File

@@ -1,4 +1,3 @@
//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
#![feature(foo_bar_baz, foo(bar), foo = "baz", foo)]
//~^ ERROR malformed `feature`
//~| ERROR malformed `feature`

View File

@@ -1,43 +1,43 @@
error[E0556]: malformed `feature` attribute input
--> $DIR/gated-bad-feature.rs:2:25
--> $DIR/gated-bad-feature.rs:1:25
|
LL | #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)]
| ^^^^^^^^ help: expected just one word: `foo`
error[E0556]: malformed `feature` attribute input
--> $DIR/gated-bad-feature.rs:2:35
--> $DIR/gated-bad-feature.rs:1:35
|
LL | #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)]
| ^^^^^^^^^^^ help: expected just one word: `foo`
error[E0557]: feature has been removed
--> $DIR/gated-bad-feature.rs:9:12
--> $DIR/gated-bad-feature.rs:8:12
|
LL | #![feature(test_removed_feature)]
| ^^^^^^^^^^^^^^^^^^^^ feature has been removed
|
= note: removed in 1.0.0 (you are using $RUSTC_VERSION)
= note: removed in 1.0.0
error: malformed `feature` attribute input
--> $DIR/gated-bad-feature.rs:7:1
--> $DIR/gated-bad-feature.rs:6:1
|
LL | #![feature]
| ^^^^^^^^^^^ help: must be of the form: `#![feature(name1, name2, ...)]`
error: malformed `feature` attribute input
--> $DIR/gated-bad-feature.rs:8:1
--> $DIR/gated-bad-feature.rs:7:1
|
LL | #![feature = "foo"]
| ^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![feature(name1, name2, ...)]`
error[E0635]: unknown feature `foo_bar_baz`
--> $DIR/gated-bad-feature.rs:2:12
--> $DIR/gated-bad-feature.rs:1:12
|
LL | #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)]
| ^^^^^^^^^^^
error[E0635]: unknown feature `foo`
--> $DIR/gated-bad-feature.rs:2:48
--> $DIR/gated-bad-feature.rs:1:48
|
LL | #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)]
| ^^^

View File

@@ -1,5 +1,3 @@
//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
#![feature(external_doc)] //~ ERROR feature has been removed
#![doc(include("README.md"))] //~ ERROR unknown `doc` attribute `include`

View File

@@ -1,14 +1,14 @@
error[E0557]: feature has been removed
--> $DIR/removed-features-note-version-and-pr-issue-141619.rs:3:12
--> $DIR/removed-features-note-version-and-pr-issue-141619.rs:1:12
|
LL | #![feature(external_doc)]
| ^^^^^^^^^^^^ feature has been removed
|
= note: removed in 1.54.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/85457> for more information
= note: removed in 1.54.0; see <https://github.com/rust-lang/rust/pull/85457> for more information
= note: use #[doc = include_str!("filename")] instead, which handles macro invocations
error: unknown `doc` attribute `include`
--> $DIR/removed-features-note-version-and-pr-issue-141619.rs:4:8
--> $DIR/removed-features-note-version-and-pr-issue-141619.rs:2:8
|
LL | #![doc(include("README.md"))]
| ^^^^^^^^^^^^^^^^^^^^

View File

@@ -1,5 +1,4 @@
//@ aux-build:two_macros.rs
//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
#![feature(macro_reexport)] //~ ERROR feature has been removed

View File

@@ -1,14 +1,14 @@
error[E0557]: feature has been removed
--> $DIR/macro-reexport-removed.rs:4:12
--> $DIR/macro-reexport-removed.rs:3:12
|
LL | #![feature(macro_reexport)]
| ^^^^^^^^^^^^^^ feature has been removed
|
= note: removed in 1.0.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/49982> for more information
= note: removed in 1.0.0; see <https://github.com/rust-lang/rust/pull/49982> for more information
= note: subsumed by `pub use`
error: cannot find attribute `macro_reexport` in this scope
--> $DIR/macro-reexport-removed.rs:6:3
--> $DIR/macro-reexport-removed.rs:5:3
|
LL | #[macro_reexport(macro_one)]
| ^^^^^^^^^^^^^^ help: a built-in attribute with a similar name exists: `macro_export`

View File

@@ -1,5 +1,3 @@
//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
#![feature(doc_keyword)] //~ ERROR
#![feature(doc_primitive)] //~ ERROR
#![crate_type = "lib"]

View File

@@ -1,19 +1,19 @@
error[E0557]: feature has been removed
--> $DIR/renamed-features-rustdoc_internals.rs:3:12
--> $DIR/renamed-features-rustdoc_internals.rs:1:12
|
LL | #![feature(doc_keyword)]
| ^^^^^^^^^^^ feature has been removed
|
= note: removed in 1.58.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/90420> for more information
= note: removed in 1.58.0; see <https://github.com/rust-lang/rust/pull/90420> for more information
= note: merged into `#![feature(rustdoc_internals)]`
error[E0557]: feature has been removed
--> $DIR/renamed-features-rustdoc_internals.rs:4:12
--> $DIR/renamed-features-rustdoc_internals.rs:2:12
|
LL | #![feature(doc_primitive)]
| ^^^^^^^^^^^^^ feature has been removed
|
= note: removed in 1.58.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/90420> for more information
= note: removed in 1.58.0; see <https://github.com/rust-lang/rust/pull/90420> for more information
= note: merged into `#![feature(rustdoc_internals)]`
error: aborting due to 2 previous errors

View File

@@ -6,7 +6,6 @@
// Regression test for issue #125877.
//@ compile-flags: -Znext-solver
//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
#![feature(const_trait_impl, effects)]
//~^ ERROR feature has been removed

View File

@@ -1,14 +1,14 @@
error[E0557]: feature has been removed
--> $DIR/const-trait-impl-parameter-mismatch.rs:11:30
--> $DIR/const-trait-impl-parameter-mismatch.rs:10:30
|
LL | #![feature(const_trait_impl, effects)]
| ^^^^^^^ feature has been removed
|
= note: removed in 1.84.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/132479> for more information
= note: removed in 1.84.0; see <https://github.com/rust-lang/rust/pull/132479> for more information
= note: removed, redundant with `#![feature(const_trait_impl)]`
error[E0049]: associated function `compute` has 0 type parameters but its trait declaration has 1 type parameter
--> $DIR/const-trait-impl-parameter-mismatch.rs:20:16
--> $DIR/const-trait-impl-parameter-mismatch.rs:19:16
|
LL | fn compute<T: ~const Aux>() -> u32;
| - expected 1 type parameter

View File

@@ -1,4 +1,2 @@
//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
#![feature(unsized_locals)] //~ERROR feature has been removed
#![crate_type = "lib"]

View File

@@ -1,10 +1,10 @@
error[E0557]: feature has been removed
--> $DIR/yote.rs:3:12
--> $DIR/yote.rs:1:12
|
LL | #![feature(unsized_locals)]
| ^^^^^^^^^^^^^^ feature has been removed
|
= note: removed in CURRENT_RUSTC_VERSION (you are using $RUSTC_VERSION)
= note: removed in CURRENT_RUSTC_VERSION
= note: removed due to implementation concerns; see https://github.com/rust-lang/rust/issues/111942
error: aborting due to 1 previous error