-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
typeck: add tests for suggesting -> 2018 on wrong <expr>.await
- Loading branch information
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
src/test/ui/async-await/suggest-switching-edition-on-await.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use std::pin::Pin; | ||
use std::future::Future; | ||
|
||
fn main() {} | ||
|
||
fn await_on_struct_missing() { | ||
struct S; | ||
let x = S; | ||
x.await; | ||
//~^ ERROR no field `await` on type | ||
//~| NOTE unknown field | ||
//~| NOTE to `.await` a `Future`, switch to Rust 2018 | ||
//~| HELP set `edition = "2018"` in `Cargo.toml` | ||
//~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide | ||
} | ||
|
||
fn await_on_struct_similar() { | ||
struct S { | ||
awai: u8, | ||
} | ||
let x = S { awai: 42 }; | ||
x.await; | ||
//~^ ERROR no field `await` on type | ||
//~| HELP a field with a similar name exists | ||
//~| NOTE to `.await` a `Future`, switch to Rust 2018 | ||
//~| HELP set `edition = "2018"` in `Cargo.toml` | ||
//~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide | ||
} | ||
|
||
fn await_on_63533(x: Pin<&mut dyn Future<Output = ()>>) { | ||
x.await; | ||
//~^ ERROR no field `await` on type | ||
//~| NOTE unknown field | ||
//~| NOTE to `.await` a `Future`, switch to Rust 2018 | ||
//~| HELP set `edition = "2018"` in `Cargo.toml` | ||
//~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide | ||
} | ||
|
||
fn await_on_apit(x: impl Future<Output = ()>) { | ||
x.await; | ||
//~^ ERROR no field `await` on type | ||
//~| NOTE to `.await` a `Future`, switch to Rust 2018 | ||
//~| HELP set `edition = "2018"` in `Cargo.toml` | ||
//~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide | ||
} |
43 changes: 43 additions & 0 deletions
43
src/test/ui/async-await/suggest-switching-edition-on-await.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
error[E0609]: no field `await` on type `await_on_struct_missing::S` | ||
--> $DIR/suggest-switching-edition-on-await.rs:9:7 | ||
| | ||
LL | x.await; | ||
| ^^^^^ unknown field | ||
| | ||
= note: to `.await` a `Future`, 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[E0609]: no field `await` on type `await_on_struct_similar::S` | ||
--> $DIR/suggest-switching-edition-on-await.rs:22:7 | ||
| | ||
LL | x.await; | ||
| ^^^^^ help: a field with a similar name exists: `awai` | ||
| | ||
= note: to `.await` a `Future`, 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[E0609]: no field `await` on type `std::pin::Pin<&mut dyn std::future::Future<Output = ()>>` | ||
--> $DIR/suggest-switching-edition-on-await.rs:31:7 | ||
| | ||
LL | x.await; | ||
| ^^^^^ unknown field | ||
| | ||
= note: to `.await` a `Future`, 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[E0609]: no field `await` on type `impl Future<Output = ()>` | ||
--> $DIR/suggest-switching-edition-on-await.rs:40:7 | ||
| | ||
LL | x.await; | ||
| ^^^^^ | ||
| | ||
= note: to `.await` a `Future`, 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: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0609`. |