Rollup merge of #118802 - ehuss:remove-edition-preview, r=TaKO8Ki

Remove edition umbrella features.

In the 2018 edition, there was an "umbrella" feature `#[feature(rust_2018_preview)]` which was used to enable several other features at once. This umbrella mechanism was not used in the 2021 edition and likely will not be used in 2024 either. During 2018 users reported that setting the feature was awkward, especially since they already needed to opt-in via the edition mechanism.

This PR removes this mechanism because I believe it will not be used (and will clean up and simplify the code). I believe that there are better ways to handle features and editions. In short:

- For highly experimental features, that may or may not be involved in an edition, they can implement regular feature gates like `tcx.features().my_feature`.
- For experimental features that *might* be involved in an edition, they should implement gates with `tcx.features().my_feature && span.at_least_rust_20xx()`. This requires the user to still specify `#![feature(my_feature)]`, to avoid disrupting testing of other edition features which are ready and have been accepted within the edition.
- For experimental features that have graduated to definitely be part of an edition, they should implement gates with `tcx.features().my_feature || span.at_least_rust_20xx()`, or just remove the feature check altogether and just check `span.at_least_rust_20xx()`.
- For relatively simple changes, they can skip the whole feature gating thing and just check `span.at_least_rust_20xx()`, and rely on the instability of the edition itself (which requires `-Zunstable-options`) to gate it.

I am working on documenting all of this in the rustc-dev-guide.
This commit is contained in:
Guillaume Gomez 2023-12-11 11:40:36 +01:00 committed by GitHub
commit 54d6bded30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
49 changed files with 471 additions and 652 deletions

View file

@ -1,5 +0,0 @@
// check-pass
#![feature(rust_2018_preview)]
fn main() {}

View file

@ -1,7 +0,0 @@
// edition:2018
// check-pass
#![feature(rust_2018_preview)]
//~^ WARN the feature `rust_2018_preview` is included in the Rust 2018 edition
fn main() {}

View file

@ -1,9 +0,0 @@
warning[E0705]: the feature `rust_2018_preview` is included in the Rust 2018 edition
--> $DIR/edition-feature-redundant.rs:4:12
|
LL | #![feature(rust_2018_preview)]
| ^^^^^^^^^^^^^^^^^
warning: 1 warning emitted
For more information about this error, try `rustc --explain E0705`.

View file

@ -1,15 +0,0 @@
// run-pass
#![allow(dead_code)]
#![allow(unused_variables)]
// Checks if the correct registers are being used to pass arguments
// when the sysv64 ABI is specified.
#![feature(rust_2018_preview)]
pub trait Foo {}
// should compile without the dyn trait feature flag
fn foo(x: &dyn Foo) {}
pub fn main() {}

View file

@ -1,10 +0,0 @@
// check-pass
// This is a stub feature that doesn't control anything, so to make tidy happy,
// gate-test-test_2018_feature
#![feature(test_2018_feature)]
//~^ WARN the feature `test_2018_feature` is included in the Rust 2018 edition
#![feature(rust_2018_preview)]
fn main() {}

View file

@ -1,9 +0,0 @@
warning[E0705]: the feature `test_2018_feature` is included in the Rust 2018 edition
--> $DIR/E0705.rs:6:12
|
LL | #![feature(test_2018_feature)]
| ^^^^^^^^^^^^^^^^^
warning: 1 warning emitted
For more information about this error, try `rustc --explain E0705`.

View file

@ -1,8 +1,6 @@
// run-pass
// aux-build:custom-attr-only-one-derive.rs
#![feature(rust_2018_preview)]
#[macro_use]
extern crate custom_attr_only_one_derive;

View file

@ -1,6 +1,5 @@
// run-rustfix
#![feature(rust_2018_preview)]
#![deny(absolute_paths_not_starting_with_crate)]
mod foo {

View file

@ -1,6 +1,5 @@
// run-rustfix
#![feature(rust_2018_preview)]
#![deny(absolute_paths_not_starting_with_crate)]
mod foo {

View file

@ -1,5 +1,5 @@
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-fully-qualified-paths.rs:19:25
--> $DIR/edition-lint-fully-qualified-paths.rs:18:25
|
LL | let _: <foo::Baz as ::foo::Foo>::Bar = ();
| ^^^^^^^^^^ help: use `crate`: `crate::foo::Foo`
@ -7,13 +7,13 @@ LL | let _: <foo::Baz as ::foo::Foo>::Bar = ();
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
note: the lint level is defined here
--> $DIR/edition-lint-fully-qualified-paths.rs:4:9
--> $DIR/edition-lint-fully-qualified-paths.rs:3:9
|
LL | #![deny(absolute_paths_not_starting_with_crate)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-fully-qualified-paths.rs:19:25
--> $DIR/edition-lint-fully-qualified-paths.rs:18:25
|
LL | let _: <foo::Baz as ::foo::Foo>::Bar = ();
| ^^^^^^^^^^ help: use `crate`: `crate::foo::Foo`
@ -23,7 +23,7 @@ LL | let _: <foo::Baz as ::foo::Foo>::Bar = ();
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-fully-qualified-paths.rs:25:13
--> $DIR/edition-lint-fully-qualified-paths.rs:24:13
|
LL | let _: <::foo::Baz as foo::Foo>::Bar = ();
| ^^^^^^^^^^ help: use `crate`: `crate::foo::Baz`

View file

@ -1,6 +1,5 @@
// run-rustfix
#![feature(rust_2018_preview)]
#![deny(absolute_paths_not_starting_with_crate)]
#![allow(unused_imports)]
#![allow(dead_code)]

View file

@ -1,6 +1,5 @@
// run-rustfix
#![feature(rust_2018_preview)]
#![deny(absolute_paths_not_starting_with_crate)]
#![allow(unused_imports)]
#![allow(dead_code)]

View file

@ -1,5 +1,5 @@
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-empty-paths.rs:17:5
--> $DIR/edition-lint-nested-empty-paths.rs:16:5
|
LL | use foo::{bar::{baz::{}}};
| ^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}}}`
@ -7,13 +7,13 @@ LL | use foo::{bar::{baz::{}}};
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
note: the lint level is defined here
--> $DIR/edition-lint-nested-empty-paths.rs:4:9
--> $DIR/edition-lint-nested-empty-paths.rs:3:9
|
LL | #![deny(absolute_paths_not_starting_with_crate)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-empty-paths.rs:21:5
--> $DIR/edition-lint-nested-empty-paths.rs:20:5
|
LL | use foo::{bar::{XX, baz::{}}};
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}`
@ -22,7 +22,7 @@ LL | use foo::{bar::{XX, baz::{}}};
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-empty-paths.rs:21:5
--> $DIR/edition-lint-nested-empty-paths.rs:20:5
|
LL | use foo::{bar::{XX, baz::{}}};
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}`
@ -32,7 +32,7 @@ LL | use foo::{bar::{XX, baz::{}}};
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-empty-paths.rs:27:5
--> $DIR/edition-lint-nested-empty-paths.rs:26:5
|
LL | use foo::{bar::{baz::{}, baz1::{}}};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}`
@ -41,7 +41,7 @@ LL | use foo::{bar::{baz::{}, baz1::{}}};
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-empty-paths.rs:27:5
--> $DIR/edition-lint-nested-empty-paths.rs:26:5
|
LL | use foo::{bar::{baz::{}, baz1::{}}};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}`

View file

@ -1,6 +1,5 @@
// run-rustfix
#![feature(rust_2018_preview)]
#![deny(absolute_paths_not_starting_with_crate)]
use crate::foo::{a, b};

View file

@ -1,6 +1,5 @@
// run-rustfix
#![feature(rust_2018_preview)]
#![deny(absolute_paths_not_starting_with_crate)]
use foo::{a, b};

View file

@ -1,5 +1,5 @@
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-paths.rs:6:5
--> $DIR/edition-lint-nested-paths.rs:5:5
|
LL | use foo::{a, b};
| ^^^^^^^^^^^ help: use `crate`: `crate::foo::{a, b}`
@ -7,13 +7,13 @@ LL | use foo::{a, b};
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
note: the lint level is defined here
--> $DIR/edition-lint-nested-paths.rs:4:9
--> $DIR/edition-lint-nested-paths.rs:3:9
|
LL | #![deny(absolute_paths_not_starting_with_crate)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-paths.rs:6:5
--> $DIR/edition-lint-nested-paths.rs:5:5
|
LL | use foo::{a, b};
| ^^^^^^^^^^^ help: use `crate`: `crate::foo::{a, b}`
@ -23,7 +23,7 @@ LL | use foo::{a, b};
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-paths.rs:23:13
--> $DIR/edition-lint-nested-paths.rs:22:13
|
LL | use foo::{self as x, c};
| ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}`
@ -32,7 +32,7 @@ LL | use foo::{self as x, c};
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-paths.rs:23:13
--> $DIR/edition-lint-nested-paths.rs:22:13
|
LL | use foo::{self as x, c};
| ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}`

View file

@ -1,7 +1,6 @@
// aux-build:edition-lint-paths.rs
// run-rustfix
#![feature(rust_2018_preview)]
#![deny(absolute_paths_not_starting_with_crate)]
#![allow(unused)]

View file

@ -1,7 +1,6 @@
// aux-build:edition-lint-paths.rs
// run-rustfix
#![feature(rust_2018_preview)]
#![deny(absolute_paths_not_starting_with_crate)]
#![allow(unused)]

View file

@ -1,5 +1,5 @@
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:12:9
--> $DIR/edition-lint-paths.rs:11:9
|
LL | use bar::Bar;
| ^^^^^^^^ help: use `crate`: `crate::bar::Bar`
@ -7,13 +7,13 @@ LL | use bar::Bar;
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
note: the lint level is defined here
--> $DIR/edition-lint-paths.rs:5:9
--> $DIR/edition-lint-paths.rs:4:9
|
LL | #![deny(absolute_paths_not_starting_with_crate)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:19:9
--> $DIR/edition-lint-paths.rs:18:9
|
LL | use bar;
| ^^^ help: use `crate`: `crate::bar`
@ -22,7 +22,7 @@ LL | use bar;
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:25:9
--> $DIR/edition-lint-paths.rs:24:9
|
LL | use {main, Bar as SomethingElse};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}`
@ -31,7 +31,7 @@ LL | use {main, Bar as SomethingElse};
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:25:9
--> $DIR/edition-lint-paths.rs:24:9
|
LL | use {main, Bar as SomethingElse};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}`
@ -41,7 +41,7 @@ LL | use {main, Bar as SomethingElse};
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:25:9
--> $DIR/edition-lint-paths.rs:24:9
|
LL | use {main, Bar as SomethingElse};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}`
@ -51,7 +51,7 @@ LL | use {main, Bar as SomethingElse};
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:40:5
--> $DIR/edition-lint-paths.rs:39:5
|
LL | use bar::Bar;
| ^^^^^^^^ help: use `crate`: `crate::bar::Bar`
@ -60,7 +60,7 @@ LL | use bar::Bar;
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:52:9
--> $DIR/edition-lint-paths.rs:51:9
|
LL | use *;
| ^ help: use `crate`: `crate::*`
@ -69,7 +69,7 @@ LL | use *;
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:57:6
--> $DIR/edition-lint-paths.rs:56:6
|
LL | impl ::foo::SomeTrait for u32 {}
| ^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::SomeTrait`
@ -78,7 +78,7 @@ LL | impl ::foo::SomeTrait for u32 {}
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:62:13
--> $DIR/edition-lint-paths.rs:61:13
|
LL | let x = ::bar::Bar;
| ^^^^^^^^^^ help: use `crate`: `crate::bar::Bar`

View file

@ -6,7 +6,6 @@
// The "normal case". Ideally we would remove the `extern crate` here,
// but we don't.
#![feature(rust_2018_preview)]
#![deny(absolute_paths_not_starting_with_crate)]
extern crate edition_lint_paths;

View file

@ -6,7 +6,6 @@
// The "normal case". Ideally we would remove the `extern crate` here,
// but we don't.
#![feature(rust_2018_preview)]
#![deny(absolute_paths_not_starting_with_crate)]
extern crate edition_lint_paths;

View file

@ -6,7 +6,6 @@
// rather than being accessed directly. Unless we rewrite that path,
// we can't drop the extern crate.
#![feature(rust_2018_preview)]
#![deny(absolute_paths_not_starting_with_crate)]
extern crate edition_lint_paths;

View file

@ -6,7 +6,6 @@
// rather than being accessed directly. Unless we rewrite that path,
// we can't drop the extern crate.
#![feature(rust_2018_preview)]
#![deny(absolute_paths_not_starting_with_crate)]
extern crate edition_lint_paths;

View file

@ -4,7 +4,6 @@
// Oddball: crate is renamed, making it harder for us to rewrite
// paths. We don't (and we leave the `extern crate` in place).
#![feature(rust_2018_preview)]
#![deny(absolute_paths_not_starting_with_crate)]
extern crate edition_lint_paths as my_crate;

View file

@ -4,7 +4,6 @@
// Oddball: crate is renamed, making it harder for us to rewrite
// paths. We don't (and we leave the `extern crate` in place).
#![feature(rust_2018_preview)]
#![deny(absolute_paths_not_starting_with_crate)]
extern crate edition_lint_paths as my_crate;

View file

@ -1,5 +1,5 @@
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/extern-crate-rename.rs:12:5
--> $DIR/extern-crate-rename.rs:11:5
|
LL | use my_crate::foo;
| ^^^^^^^^^^^^^ help: use `crate`: `crate::my_crate::foo`
@ -7,7 +7,7 @@ LL | use my_crate::foo;
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
note: the lint level is defined here
--> $DIR/extern-crate-rename.rs:8:9
--> $DIR/extern-crate-rename.rs:7:9
|
LL | #![deny(absolute_paths_not_starting_with_crate)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -5,7 +5,6 @@
// us to rewrite paths. We don't (and we leave the `extern crate` in
// place).
#![feature(rust_2018_preview)]
#![deny(absolute_paths_not_starting_with_crate)]
mod m {

View file

@ -5,7 +5,6 @@
// us to rewrite paths. We don't (and we leave the `extern crate` in
// place).
#![feature(rust_2018_preview)]
#![deny(absolute_paths_not_starting_with_crate)]
mod m {

View file

@ -1,5 +1,5 @@
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/extern-crate-submod.rs:19:5
--> $DIR/extern-crate-submod.rs:18:5
|
LL | use m::edition_lint_paths::foo;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::m::edition_lint_paths::foo`
@ -7,7 +7,7 @@ LL | use m::edition_lint_paths::foo;
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
note: the lint level is defined here
--> $DIR/extern-crate-submod.rs:9:9
--> $DIR/extern-crate-submod.rs:8:9
|
LL | #![deny(absolute_paths_not_starting_with_crate)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -4,8 +4,6 @@
//
// run-pass
#![feature(rust_2018_preview)]
trait A {
}

View file

@ -4,8 +4,6 @@
//
// run-pass
#![feature(rust_2018_preview)]
trait A {
}

View file

@ -4,7 +4,6 @@
#![crate_type = "proc-macro"]
#![deny(rust_2018_compatibility)]
#![feature(rust_2018_preview)]
extern crate proc_macro;

View file

@ -4,7 +4,6 @@
// rustfix-only-machine-applicable
// check-pass
#![feature(rust_2018_preview)]
#![warn(rust_2018_compatibility)]
extern crate suggestions_not_always_applicable as foo;

View file

@ -4,7 +4,6 @@
// rustfix-only-machine-applicable
// check-pass
#![feature(rust_2018_preview)]
#![warn(rust_2018_compatibility)]
extern crate suggestions_not_always_applicable as foo;

View file

@ -1,6 +1,5 @@
// run-pass
#![feature(rust_2018_preview)]
#![deny(unknown_lints)]
#[allow(clippy::almost_swapped)]