Detect errors caused by async block in 2015 edition
This commit is contained in:
parent
6318d24ad8
commit
3cf556939e
7 changed files with 121 additions and 41 deletions
|
|
@ -2,9 +2,8 @@ error[E0670]: `async fn` is not permitted in the 2015 edition
|
|||
--> $DIR/edition-deny-async-fns-2015.rs:3:1
|
||||
|
|
||||
LL | async fn foo() {}
|
||||
| ^^^^^
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018
|
||||
|
|
||||
= note: to use `async fn`, switch to Rust 2018
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
|
|
@ -12,9 +11,8 @@ error[E0670]: `async fn` is not permitted in the 2015 edition
|
|||
--> $DIR/edition-deny-async-fns-2015.rs:5:12
|
||||
|
|
||||
LL | fn baz() { async fn foo() {} }
|
||||
| ^^^^^
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018
|
||||
|
|
||||
= note: to use `async fn`, switch to Rust 2018
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
|
|
@ -22,9 +20,8 @@ error[E0670]: `async fn` is not permitted in the 2015 edition
|
|||
--> $DIR/edition-deny-async-fns-2015.rs:7:1
|
||||
|
|
||||
LL | async fn async_baz() {
|
||||
| ^^^^^
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018
|
||||
|
|
||||
= note: to use `async fn`, switch to Rust 2018
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
|
|
@ -32,9 +29,8 @@ error[E0670]: `async fn` is not permitted in the 2015 edition
|
|||
--> $DIR/edition-deny-async-fns-2015.rs:8:5
|
||||
|
|
||||
LL | async fn bar() {}
|
||||
| ^^^^^
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018
|
||||
|
|
||||
= note: to use `async fn`, switch to Rust 2018
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
|
|
@ -42,9 +38,8 @@ error[E0670]: `async fn` is not permitted in the 2015 edition
|
|||
--> $DIR/edition-deny-async-fns-2015.rs:14:5
|
||||
|
|
||||
LL | async fn foo() {}
|
||||
| ^^^^^
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018
|
||||
|
|
||||
= note: to use `async fn`, switch to Rust 2018
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
|
|
@ -52,9 +47,8 @@ error[E0670]: `async fn` is not permitted in the 2015 edition
|
|||
--> $DIR/edition-deny-async-fns-2015.rs:18:5
|
||||
|
|
||||
LL | async fn foo() {}
|
||||
| ^^^^^
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018
|
||||
|
|
||||
= note: to use `async fn`, switch to Rust 2018
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
|
|
@ -62,9 +56,8 @@ error[E0670]: `async fn` is not permitted in the 2015 edition
|
|||
--> $DIR/edition-deny-async-fns-2015.rs:36:9
|
||||
|
|
||||
LL | async fn bar() {}
|
||||
| ^^^^^
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018
|
||||
|
|
||||
= note: to use `async fn`, switch to Rust 2018
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
|
|
@ -72,9 +65,8 @@ error[E0670]: `async fn` is not permitted in the 2015 edition
|
|||
--> $DIR/edition-deny-async-fns-2015.rs:26:9
|
||||
|
|
||||
LL | async fn foo() {}
|
||||
| ^^^^^
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018
|
||||
|
|
||||
= note: to use `async fn`, switch to Rust 2018
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
|
|
@ -82,9 +74,8 @@ error[E0670]: `async fn` is not permitted in the 2015 edition
|
|||
--> $DIR/edition-deny-async-fns-2015.rs:31:13
|
||||
|
|
||||
LL | async fn bar() {}
|
||||
| ^^^^^
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018
|
||||
|
|
||||
= note: to use `async fn`, switch to Rust 2018
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
|
|
|
|||
30
src/test/ui/editions/async-block-2015.rs
Normal file
30
src/test/ui/editions/async-block-2015.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
async fn foo() {
|
||||
//~^ ERROR `async fn` is not permitted in the 2015 edition
|
||||
//~| NOTE to use `async fn`, switch to Rust 2018
|
||||
//~| 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
|
||||
let x = 42;
|
||||
//~^ ERROR expected identifier, found keyword `let`
|
||||
//~| NOTE expected identifier, found keyword
|
||||
//~| HELP set `edition = "2018"` in `Cargo.toml`
|
||||
//~| 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
|
||||
42
|
||||
//~^ ERROR expected identifier, found `42`
|
||||
//~| NOTE expected identifier
|
||||
//~| HELP set `edition = "2018"` in `Cargo.toml`
|
||||
//~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
};
|
||||
y.await;
|
||||
z.await;
|
||||
x
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
41
src/test/ui/editions/async-block-2015.stderr
Normal file
41
src/test/ui/editions/async-block-2015.stderr
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
error[E0670]: `async fn` is not permitted in the 2015 edition
|
||||
--> $DIR/async-block-2015.rs:1:1
|
||||
|
|
||||
LL | async fn foo() {
|
||||
| ^^^^^ to use `async fn`, switch to Rust 2018
|
||||
|
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
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
|
||||
LL | let x = 42;
|
||||
| ^^^ expected identifier, found keyword
|
||||
|
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
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
|
||||
LL | 42
|
||||
| ^^ expected identifier
|
||||
|
|
||||
= help: set `edition = "2018"` in `Cargo.toml`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
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
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0422, E0670.
|
||||
For more information about an error, try `rustc --explain E0422`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue