Skip to content

Commit 2b41547

Browse files
committed
Auto merge of #134273 - RalfJung:de-stabilize-bench, r=<try>
de-stabilize bench attribute This has been soft-unstable since forever (#64066), and shown in future-compat reports since Rust 1.77 (#116274). The feature covering `bench` itself is tracked in #50297, which has been closed despite still having active feature gates referencing it. Cc `@rust-lang/libs-api`
2 parents 5dfe648 + f5c63b9 commit 2b41547

File tree

7 files changed

+16
-100
lines changed

7 files changed

+16
-100
lines changed

compiler/rustc_lint_defs/src/builtin.rs

+3-29
Original file line numberDiff line numberDiff line change
@@ -2389,37 +2389,11 @@ declare_lint! {
23892389
}
23902390

23912391
declare_lint! {
2392-
/// The `soft_unstable` lint detects unstable features that were
2393-
/// unintentionally allowed on stable.
2394-
///
2395-
/// ### Example
2396-
///
2397-
/// ```rust,compile_fail
2398-
/// #[cfg(test)]
2399-
/// extern crate test;
2400-
///
2401-
/// #[bench]
2402-
/// fn name(b: &mut test::Bencher) {
2403-
/// b.iter(|| 123)
2404-
/// }
2405-
/// ```
2406-
///
2407-
/// {{produces}}
2408-
///
2409-
/// ### Explanation
2410-
///
2411-
/// The [`bench` attribute] was accidentally allowed to be specified on
2412-
/// the [stable release channel]. Turning this to a hard error would have
2413-
/// broken some projects. This lint allows those projects to continue to
2414-
/// build correctly when [`--cap-lints`] is used, but otherwise signal an
2415-
/// error that `#[bench]` should not be used on the stable channel. This
2416-
/// is a [future-incompatible] lint to transition this to a hard error in
2417-
/// the future. See [issue #64266] for more details.
2392+
/// The `soft_unstable` lint detects unstable features that were unintentionally allowed on
2393+
/// stable. This is a [future-incompatible] lint to transition this to a hard error in the
2394+
/// future. See [issue #64266] for more details.
24182395
///
24192396
/// [issue #64266]: https://github.com/rust-lang/rust/issues/64266
2420-
/// [`bench` attribute]: https://doc.rust-lang.org/nightly/unstable-book/library-features/test.html
2421-
/// [stable release channel]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html
2422-
/// [`--cap-lints`]: https://doc.rust-lang.org/rustc/lints/levels.html#capping-lints
24232397
/// [future-incompatible]: ../index.md#future-incompatible-lints
24242398
pub SOFT_UNSTABLE,
24252399
Deny,

library/core/src/macros/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,6 @@ pub(crate) mod builtin {
16841684
#[unstable(
16851685
feature = "test",
16861686
issue = "50297",
1687-
soft,
16881687
reason = "`bench` is a part of custom test frameworks which are unstable"
16891688
)]
16901689
#[allow_internal_unstable(test, rustc_attrs)]

src/tools/lint-docs/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ impl<'a> LintExtractor<'a> {
306306
if matches!(
307307
lint.name.as_str(),
308308
"unused_features" // broken lint
309+
| "soft_unstable" // cannot have a stable example
309310
) {
310311
return Ok(());
311312
}

tests/ui/feature-gates/bench.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
//@ edition:2018
22

33
#[bench] //~ ERROR use of unstable library feature `test`
4-
//~| WARN this was previously accepted
54
fn bench() {}
65

76
use bench as _; //~ ERROR use of unstable library feature `test`
8-
//~| WARN this was previously accepted
97
fn main() {}

tests/ui/feature-gates/bench.stderr

+10-30
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,23 @@
1-
error: use of unstable library feature `test`: `bench` is a part of custom test frameworks which are unstable
1+
error[E0658]: use of unstable library feature `test`: `bench` is a part of custom test frameworks which are unstable
22
--> $DIR/bench.rs:3:3
33
|
44
LL | #[bench]
55
| ^^^^^
66
|
7-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8-
= note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
9-
= note: `#[deny(soft_unstable)]` on by default
7+
= note: see issue #50297 <https://github.com/rust-lang/rust/issues/50297> for more information
8+
= help: add `#![feature(test)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1010

11-
error: use of unstable library feature `test`: `bench` is a part of custom test frameworks which are unstable
12-
--> $DIR/bench.rs:7:5
11+
error[E0658]: use of unstable library feature `test`: `bench` is a part of custom test frameworks which are unstable
12+
--> $DIR/bench.rs:6:5
1313
|
1414
LL | use bench as _;
1515
| ^^^^^
1616
|
17-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
18-
= note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
17+
= note: see issue #50297 <https://github.com/rust-lang/rust/issues/50297> for more information
18+
= help: add `#![feature(test)]` to the crate attributes to enable
19+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1920

2021
error: aborting due to 2 previous errors
2122

22-
Future incompatibility report: Future breakage diagnostic:
23-
error: use of unstable library feature `test`: `bench` is a part of custom test frameworks which are unstable
24-
--> $DIR/bench.rs:3:3
25-
|
26-
LL | #[bench]
27-
| ^^^^^
28-
|
29-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
30-
= note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
31-
= note: `#[deny(soft_unstable)]` on by default
32-
33-
Future breakage diagnostic:
34-
error: use of unstable library feature `test`: `bench` is a part of custom test frameworks which are unstable
35-
--> $DIR/bench.rs:7:5
36-
|
37-
LL | use bench as _;
38-
| ^^^^^
39-
|
40-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
41-
= note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
42-
= note: `#[deny(soft_unstable)]` on by default
43-
23+
For more information about this error, try `rustc --explain E0658`.

tests/ui/lint/expansion-time.rs

-7
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ macro_rules! foo {
99
macro_rules! m { ($i) => {} } //~ WARN missing fragment specifier
1010
//~| WARN this was previously accepted
1111

12-
#[warn(soft_unstable)]
13-
mod benches {
14-
#[bench] //~ WARN use of unstable library feature `test`
15-
//~| WARN this was previously accepted
16-
fn foo() {}
17-
}
18-
1912
#[deprecated = "reason"]
2013
macro_rules! deprecated {
2114
() => {}

tests/ui/lint/expansion-time.stderr

+2-31
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,19 @@ note: the lint level is defined here
2626
LL | #[warn(missing_fragment_specifier)]
2727
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
2828

29-
warning: use of unstable library feature `test`: `bench` is a part of custom test frameworks which are unstable
30-
--> $DIR/expansion-time.rs:14:7
31-
|
32-
LL | #[bench]
33-
| ^^^^^
34-
|
35-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
36-
= note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
37-
note: the lint level is defined here
38-
--> $DIR/expansion-time.rs:12:8
39-
|
40-
LL | #[warn(soft_unstable)]
41-
| ^^^^^^^^^^^^^
42-
4329
warning: include macro expected single expression in source
4430
--> $DIR/expansion-time-include.rs:4:1
4531
|
4632
LL | 2
4733
| ^
4834
|
4935
note: the lint level is defined here
50-
--> $DIR/expansion-time.rs:29:8
36+
--> $DIR/expansion-time.rs:22:8
5137
|
5238
LL | #[warn(incomplete_include)]
5339
| ^^^^^^^^^^^^^^^^^^
5440

55-
warning: 4 warnings emitted
41+
warning: 3 warnings emitted
5642

5743
Future incompatibility report: Future breakage diagnostic:
5844
warning: missing fragment specifier
@@ -69,18 +55,3 @@ note: the lint level is defined here
6955
LL | #[warn(missing_fragment_specifier)]
7056
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
7157

72-
Future breakage diagnostic:
73-
warning: use of unstable library feature `test`: `bench` is a part of custom test frameworks which are unstable
74-
--> $DIR/expansion-time.rs:14:7
75-
|
76-
LL | #[bench]
77-
| ^^^^^
78-
|
79-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
80-
= note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
81-
note: the lint level is defined here
82-
--> $DIR/expansion-time.rs:12:8
83-
|
84-
LL | #[warn(soft_unstable)]
85-
| ^^^^^^^^^^^^^
86-

0 commit comments

Comments
 (0)