about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2020-05-01 18:24:14 -0700
committerEsteban Küber <esteban@kuber.com.ar>2020-05-05 19:35:20 -0700
commit3cf556939e4f5fcce686ad9c157ac331bd05aabc (patch)
treecd83bd426c7021aaef20743110ea1d6457cf595b /src/test/ui
parent6318d24ad8440fa30428b405be1174478e9536e3 (diff)
Detect errors caused by `async` block in 2015 edition
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/async-await/edition-deny-async-fns-2015.stderr27
-rw-r--r--src/test/ui/editions/async-block-2015.rs30
-rw-r--r--src/test/ui/editions/async-block-2015.stderr41
3 files changed, 80 insertions, 18 deletions
diff --git a/src/test/ui/async-await/edition-deny-async-fns-2015.stderr b/src/test/ui/async-await/edition-deny-async-fns-2015.stderr
index f3d982801bb..8bffeb2131d 100644
--- a/src/test/ui/async-await/edition-deny-async-fns-2015.stderr
+++ b/src/test/ui/async-await/edition-deny-async-fns-2015.stderr
@@ -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
 
diff --git a/src/test/ui/editions/async-block-2015.rs b/src/test/ui/editions/async-block-2015.rs
new file mode 100644
index 00000000000..985606a6f25
--- /dev/null
+++ b/src/test/ui/editions/async-block-2015.rs
@@ -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() {}
diff --git a/src/test/ui/editions/async-block-2015.stderr b/src/test/ui/editions/async-block-2015.stderr
new file mode 100644
index 00000000000..8e5e5d8bfab
--- /dev/null
+++ b/src/test/ui/editions/async-block-2015.stderr
@@ -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`.