Skip to content

Commit 2aea4b2

Browse files
authored
Rollup merge of #141642 - xizheyin:issue-141619, r=BoxyUwU
Note the version and PR of removed features when using it Fixes #141619 I added the diagnostic information. Since all the current version information is present, it prints the version information anyway, as shown in tests/ui. And PR will not print if it is None, we can gradually add the PR links. Split into two commits for easier review. r? compiler cc ``@jyn514`` Since you're on vocation in the review list, I can't r? you.
2 parents d11756f + 4b89804 commit 2aea4b2

18 files changed

+174
-100
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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,20 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute], crate_name: Symbol) -
8080

8181
// If the enabled feature has been removed, issue an error.
8282
if let Some(f) = REMOVED_LANG_FEATURES.iter().find(|f| name == f.feature.name) {
83+
let pull_note = if let Some(pull) = f.pull {
84+
format!(
85+
"; see <https://github.com/rust-lang/rust/pull/{}> for more information",
86+
pull
87+
)
88+
} else {
89+
"".to_owned()
90+
};
8391
sess.dcx().emit_err(FeatureRemoved {
8492
span: mi.span(),
8593
reason: f.reason.map(|reason| FeatureRemovedReason { reason }),
94+
removed_rustc_version: f.feature.since,
95+
current_rustc_version: sess.cfg_version,
96+
pull_note,
8697
});
8798
continue;
8899
}

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: 98 additions & 84 deletions
Large diffs are not rendered by default.

tests/ui/deprecation/deprecated_no_stack_check.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
2+
13
#![deny(warnings)]
24
#![feature(no_stack_check)]
35
//~^ ERROR: feature has been removed [E0557]

tests/ui/deprecation/deprecated_no_stack_check.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
error[E0557]: feature has been removed
2-
--> $DIR/deprecated_no_stack_check.rs:2:12
2+
--> $DIR/deprecated_no_stack_check.rs:4:12
33
|
44
LL | #![feature(no_stack_check)]
55
| ^^^^^^^^^^^^^^ feature has been removed
6+
|
7+
= note: removed in 1.0.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/40110> for more information
68

79
error: aborting due to 1 previous error
810

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
2+
13
#![crate_type = "lib"]
24
#![feature(no_coverage)] //~ ERROR feature has been removed [E0557]
35

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
error[E0557]: feature has been removed
2-
--> $DIR/feature-gate-coverage-attribute.rs:2:12
2+
--> $DIR/feature-gate-coverage-attribute.rs:4:12
33
|
44
LL | #![feature(no_coverage)]
55
| ^^^^^^^^^^^ feature has been removed
66
|
7+
= note: removed in 1.74.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/114656> for more information
78
= note: renamed to `coverage_attribute`
89

910
error[E0658]: the `#[coverage]` attribute is an experimental feature
10-
--> $DIR/feature-gate-coverage-attribute.rs:10:1
11+
--> $DIR/feature-gate-coverage-attribute.rs:12:1
1112
|
1213
LL | #[coverage(off)]
1314
| ^^^^^^^^^^^^^^^^

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
12
#![feature(foo_bar_baz, foo(bar), foo = "baz", foo)]
23
//~^ ERROR malformed `feature`
34
//~| ERROR malformed `feature`

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
11
error[E0556]: malformed `feature` attribute input
2-
--> $DIR/gated-bad-feature.rs:1:25
2+
--> $DIR/gated-bad-feature.rs:2:25
33
|
44
LL | #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)]
55
| ^^^^^^^^ help: expected just one word: `foo`
66

77
error[E0556]: malformed `feature` attribute input
8-
--> $DIR/gated-bad-feature.rs:1:35
8+
--> $DIR/gated-bad-feature.rs:2:35
99
|
1010
LL | #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)]
1111
| ^^^^^^^^^^^ help: expected just one word: `foo`
1212

1313
error[E0557]: feature has been removed
14-
--> $DIR/gated-bad-feature.rs:8:12
14+
--> $DIR/gated-bad-feature.rs:9:12
1515
|
1616
LL | #![feature(test_removed_feature)]
1717
| ^^^^^^^^^^^^^^^^^^^^ feature has been removed
18+
|
19+
= note: removed in 1.0.0 (you are using $RUSTC_VERSION)
1820

1921
error: malformed `feature` attribute input
20-
--> $DIR/gated-bad-feature.rs:6:1
22+
--> $DIR/gated-bad-feature.rs:7:1
2123
|
2224
LL | #![feature]
2325
| ^^^^^^^^^^^ help: must be of the form: `#![feature(name1, name2, ...)]`
2426

2527
error: malformed `feature` attribute input
26-
--> $DIR/gated-bad-feature.rs:7:1
28+
--> $DIR/gated-bad-feature.rs:8:1
2729
|
2830
LL | #![feature = "foo"]
2931
| ^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![feature(name1, name2, ...)]`
3032

3133
error[E0635]: unknown feature `foo_bar_baz`
32-
--> $DIR/gated-bad-feature.rs:1:12
34+
--> $DIR/gated-bad-feature.rs:2:12
3335
|
3436
LL | #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)]
3537
| ^^^^^^^^^^^
3638

3739
error[E0635]: unknown feature `foo`
38-
--> $DIR/gated-bad-feature.rs:1:48
40+
--> $DIR/gated-bad-feature.rs:2:48
3941
|
4042
LL | #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)]
4143
| ^^^
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
2+
3+
#![feature(external_doc)] //~ ERROR feature has been removed
4+
#![doc(include("README.md"))] //~ ERROR unknown `doc` attribute `include`
5+
6+
fn main(){}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error[E0557]: feature has been removed
2+
--> $DIR/removed-features-note-version-and-pr-issue-141619.rs:3:12
3+
|
4+
LL | #![feature(external_doc)]
5+
| ^^^^^^^^^^^^ feature has been removed
6+
|
7+
= note: removed in 1.54.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/85457> for more information
8+
= note: use #[doc = include_str!("filename")] instead, which handles macro invocations
9+
10+
error: unknown `doc` attribute `include`
11+
--> $DIR/removed-features-note-version-and-pr-issue-141619.rs:4:8
12+
|
13+
LL | #![doc(include("README.md"))]
14+
| ^^^^^^^^^^^^^^^^^^^^
15+
|
16+
= note: `#[deny(invalid_doc_attributes)]` on by default
17+
18+
error: aborting due to 2 previous errors
19+
20+
For more information about this error, try `rustc --explain E0557`.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ aux-build:two_macros.rs
2+
//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
23

34
#![feature(macro_reexport)] //~ ERROR feature has been removed
45

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
error[E0557]: feature has been removed
2-
--> $DIR/macro-reexport-removed.rs:3:12
2+
--> $DIR/macro-reexport-removed.rs:4:12
33
|
44
LL | #![feature(macro_reexport)]
55
| ^^^^^^^^^^^^^^ feature has been removed
66
|
7+
= note: removed in 1.0.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/49982> for more information
78
= note: subsumed by `pub use`
89

910
error: cannot find attribute `macro_reexport` in this scope
10-
--> $DIR/macro-reexport-removed.rs:5:3
11+
--> $DIR/macro-reexport-removed.rs:6:3
1112
|
1213
LL | #[macro_reexport(macro_one)]
1314
| ^^^^^^^^^^^^^^ help: a built-in attribute with a similar name exists: `macro_export`

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
2+
13
#![feature(doc_keyword)] //~ ERROR
24
#![feature(doc_primitive)] //~ ERROR
35
#![crate_type = "lib"]

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
error[E0557]: feature has been removed
2-
--> $DIR/renamed-features-rustdoc_internals.rs:1:12
2+
--> $DIR/renamed-features-rustdoc_internals.rs:3:12
33
|
44
LL | #![feature(doc_keyword)]
55
| ^^^^^^^^^^^ feature has been removed
66
|
7+
= note: removed in 1.58.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/90420> for more information
78
= note: merged into `#![feature(rustdoc_internals)]`
89

910
error[E0557]: feature has been removed
10-
--> $DIR/renamed-features-rustdoc_internals.rs:2:12
11+
--> $DIR/renamed-features-rustdoc_internals.rs:4:12
1112
|
1213
LL | #![feature(doc_primitive)]
1314
| ^^^^^^^^^^^^^ feature has been removed
1415
|
16+
= note: removed in 1.58.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/90420> for more information
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.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Regression test for issue #125877.
77

88
//@ compile-flags: -Znext-solver
9+
//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
910

1011
#![feature(const_trait_impl, effects)]
1112
//~^ ERROR feature has been removed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
error[E0557]: feature has been removed
2-
--> $DIR/const-trait-impl-parameter-mismatch.rs:10:30
2+
--> $DIR/const-trait-impl-parameter-mismatch.rs:11:30
33
|
44
LL | #![feature(const_trait_impl, effects)]
55
| ^^^^^^^ feature has been removed
66
|
7+
= note: removed in 1.84.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/132479> for more information
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
10-
--> $DIR/const-trait-impl-parameter-mismatch.rs:19:16
11+
--> $DIR/const-trait-impl-parameter-mismatch.rs:20:16
1112
|
1213
LL | fn compute<T: ~const Aux>() -> u32;
1314
| - expected 1 type parameter

0 commit comments

Comments
 (0)