Auto merge of #79576 - m-ou-se:2021, r=Mark-Simulacrum
Add edition 2021. 🎆 Happy new ~~year~~ Rust. 🍾 This adds --edition=2021, and updates suggestions about 2018 to say "2018 *or later*". Related Cargo PR: https://github.com/rust-lang/cargo/pull/8922 --- Edit: This adds the new edition as *unstable*. Without `-Z unstable-options`, `--edition=2021` results in: ``` $ rustc --edition=2021 error: edition 2021 is unstable and only available with -Z unstable-options. ```
This commit is contained in:
commit
f8ab56bf32
17 changed files with 87 additions and 59 deletions
|
|
@ -1,21 +1,21 @@
|
|||
// edition:2015
|
||||
|
||||
async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
|
||||
async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015
|
||||
|
||||
fn baz() { async fn foo() {} } //~ ERROR `async fn` is not permitted in the 2015 edition
|
||||
fn baz() { async fn foo() {} } //~ ERROR `async fn` is not permitted in Rust 2015
|
||||
|
||||
async fn async_baz() { //~ ERROR `async fn` is not permitted in the 2015 edition
|
||||
async fn bar() {} //~ ERROR `async fn` is not permitted in the 2015 edition
|
||||
async fn async_baz() { //~ ERROR `async fn` is not permitted in Rust 2015
|
||||
async fn bar() {} //~ ERROR `async fn` is not permitted in Rust 2015
|
||||
}
|
||||
|
||||
struct Foo {}
|
||||
|
||||
impl Foo {
|
||||
async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
|
||||
async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015
|
||||
}
|
||||
|
||||
trait Bar {
|
||||
async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
|
||||
async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015
|
||||
//~^ ERROR functions in traits cannot be declared `async`
|
||||
}
|
||||
|
||||
|
|
@ -23,16 +23,16 @@ fn main() {
|
|||
macro_rules! accept_item { ($x:item) => {} }
|
||||
|
||||
accept_item! {
|
||||
async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
|
||||
async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015
|
||||
}
|
||||
|
||||
accept_item! {
|
||||
impl Foo {
|
||||
async fn bar() {} //~ ERROR `async fn` is not permitted in the 2015 edition
|
||||
async fn bar() {} //~ ERROR `async fn` is not permitted in Rust 2015
|
||||
}
|
||||
}
|
||||
|
||||
let inside_closure = || {
|
||||
async fn bar() {} //~ ERROR `async fn` is not permitted in the 2015 edition
|
||||
async fn bar() {} //~ ERROR `async fn` is not permitted in Rust 2015
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,80 +1,80 @@
|
|||
error[E0670]: `async fn` is not permitted in the 2015 edition
|
||||
error[E0670]: `async fn` is not permitted in Rust 2015
|
||||
--> $DIR/edition-deny-async-fns-2015.rs:3:1
|
||||
|
|
||||
LL | async fn foo() {}
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
||||
|
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
error[E0670]: `async fn` is not permitted in the 2015 edition
|
||||
error[E0670]: `async fn` is not permitted in Rust 2015
|
||||
--> $DIR/edition-deny-async-fns-2015.rs:5:12
|
||||
|
|
||||
LL | fn baz() { async fn foo() {} }
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
||||
|
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
error[E0670]: `async fn` is not permitted in the 2015 edition
|
||||
error[E0670]: `async fn` is not permitted in Rust 2015
|
||||
--> $DIR/edition-deny-async-fns-2015.rs:7:1
|
||||
|
|
||||
LL | async fn async_baz() {
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
||||
|
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
error[E0670]: `async fn` is not permitted in the 2015 edition
|
||||
error[E0670]: `async fn` is not permitted in Rust 2015
|
||||
--> $DIR/edition-deny-async-fns-2015.rs:8:5
|
||||
|
|
||||
LL | async fn bar() {}
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
||||
|
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
error[E0670]: `async fn` is not permitted in the 2015 edition
|
||||
error[E0670]: `async fn` is not permitted in Rust 2015
|
||||
--> $DIR/edition-deny-async-fns-2015.rs:14:5
|
||||
|
|
||||
LL | async fn foo() {}
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
||||
|
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
error[E0670]: `async fn` is not permitted in the 2015 edition
|
||||
error[E0670]: `async fn` is not permitted in Rust 2015
|
||||
--> $DIR/edition-deny-async-fns-2015.rs:18:5
|
||||
|
|
||||
LL | async fn foo() {}
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
||||
|
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
error[E0670]: `async fn` is not permitted in the 2015 edition
|
||||
error[E0670]: `async fn` is not permitted in Rust 2015
|
||||
--> $DIR/edition-deny-async-fns-2015.rs:36:9
|
||||
|
|
||||
LL | async fn bar() {}
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
||||
|
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
error[E0670]: `async fn` is not permitted in the 2015 edition
|
||||
error[E0670]: `async fn` is not permitted in Rust 2015
|
||||
--> $DIR/edition-deny-async-fns-2015.rs:26:9
|
||||
|
|
||||
LL | async fn foo() {}
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
||||
|
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
error[E0670]: `async fn` is not permitted in the 2015 edition
|
||||
error[E0670]: `async fn` is not permitted in Rust 2015
|
||||
--> $DIR/edition-deny-async-fns-2015.rs:31:13
|
||||
|
|
||||
LL | async fn bar() {}
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
||||
|
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error[E0609]: no field `await` on type `await_on_struct_missing::S`
|
|||
LL | x.await;
|
||||
| ^^^^^ unknown field
|
||||
|
|
||||
= note: to `.await` a `Future`, switch to Rust 2018
|
||||
= note: to `.await` a `Future`, switch to Rust 2018 or later
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ error[E0609]: no field `await` on type `await_on_struct_similar::S`
|
|||
LL | x.await;
|
||||
| ^^^^^ help: a field with a similar name exists: `awai`
|
||||
|
|
||||
= note: to `.await` a `Future`, switch to Rust 2018
|
||||
= note: to `.await` a `Future`, switch to Rust 2018 or later
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ error[E0609]: no field `await` on type `Pin<&mut dyn Future<Output = ()>>`
|
|||
LL | x.await;
|
||||
| ^^^^^ unknown field
|
||||
|
|
||||
= note: to `.await` a `Future`, switch to Rust 2018
|
||||
= note: to `.await` a `Future`, switch to Rust 2018 or later
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ error[E0609]: no field `await` on type `impl Future<Output = ()>`
|
|||
LL | x.await;
|
||||
| ^^^^^
|
||||
|
|
||||
= note: to `.await` a `Future`, switch to Rust 2018
|
||||
= note: to `.await` a `Future`, switch to Rust 2018 or later
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
async fn foo() {
|
||||
//~^ ERROR `async fn` is not permitted in the 2015 edition
|
||||
//~| NOTE to use `async fn`, switch to Rust 2018
|
||||
//~^ ERROR `async fn` is not permitted in Rust 2015
|
||||
//~| NOTE to use `async fn`, switch to Rust 2018 or later
|
||||
//~| HELP set `edition = "2018"` in `Cargo.toml`
|
||||
//~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
let x = async {};
|
||||
//~^ ERROR cannot find struct, variant or union type `async` in this scope
|
||||
//~| NOTE `async` blocks are only allowed in the 2018 edition
|
||||
let y = async { //~ NOTE `async` blocks are only allowed in the 2018 edition
|
||||
//~| NOTE `async` blocks are only allowed in Rust 2018 or later
|
||||
let y = async { //~ NOTE `async` blocks are only allowed in Rust 2018 or later
|
||||
let x = 42;
|
||||
//~^ ERROR expected identifier, found keyword `let`
|
||||
//~| NOTE expected identifier, found keyword
|
||||
|
|
@ -15,7 +15,7 @@ async fn foo() {
|
|||
//~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
42
|
||||
};
|
||||
let z = async { //~ NOTE `async` blocks are only allowed in the 2018 edition
|
||||
let z = async { //~ NOTE `async` blocks are only allowed in Rust 2018 or later
|
||||
42
|
||||
//~^ ERROR expected identifier, found `42`
|
||||
//~| NOTE expected identifier
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error[E0670]: `async fn` is not permitted in the 2015 edition
|
||||
error[E0670]: `async fn` is not permitted in Rust 2015
|
||||
--> $DIR/async-block-2015.rs:1:1
|
||||
|
|
||||
LL | async fn foo() {
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
||||
|
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
|
@ -11,7 +11,7 @@ error: expected identifier, found keyword `let`
|
|||
--> $DIR/async-block-2015.rs:11:9
|
||||
|
|
||||
LL | let y = async {
|
||||
| ----- `async` blocks are only allowed in the 2018 edition
|
||||
| ----- `async` blocks are only allowed in Rust 2018 or later
|
||||
LL | let x = 42;
|
||||
| ^^^ expected identifier, found keyword
|
||||
|
|
||||
|
|
@ -22,7 +22,7 @@ error: expected identifier, found `42`
|
|||
--> $DIR/async-block-2015.rs:19:9
|
||||
|
|
||||
LL | let z = async {
|
||||
| ----- `async` blocks are only allowed in the 2018 edition
|
||||
| ----- `async` blocks are only allowed in Rust 2018 or later
|
||||
LL | 42
|
||||
| ^^ expected identifier
|
||||
|
|
||||
|
|
@ -33,7 +33,7 @@ error[E0422]: cannot find struct, variant or union type `async` in this scope
|
|||
--> $DIR/async-block-2015.rs:7:13
|
||||
|
|
||||
LL | let x = async {};
|
||||
| ^^^^^ `async` blocks are only allowed in the 2018 edition
|
||||
| ^^^^^ `async` blocks are only allowed in Rust 2018 or later
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
7
src/test/ui/hello2021.rs
Normal file
7
src/test/ui/hello2021.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
// run-pass
|
||||
// edition:2021
|
||||
// compile-flags: -Zunstable-options
|
||||
|
||||
fn main() {
|
||||
println!("hello, 2021");
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ error[E0574]: expected struct, variant or union type, found macro `try`
|
|||
LL | let try_result: Option<_> = try {
|
||||
| ^^^ not a struct, variant or union type
|
||||
|
|
||||
= note: if you want the `try` keyword, you need to be in the 2018 edition
|
||||
= note: if you want the `try` keyword, you need Rust 2018 or later
|
||||
help: use `!` to invoke the macro
|
||||
|
|
||||
LL | let try_result: Option<_> = try! {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue