Skip to content

Commit 9287eb6

Browse files
committed
typeck: add tests for suggesting -> 2018 on wrong <expr>.await
1 parent 88398a4 commit 9287eb6

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
use std::pin::Pin;
2+
use std::future::Future;
3+
4+
fn main() {}
5+
6+
fn await_on_struct_missing() {
7+
struct S;
8+
let x = S;
9+
x.await;
10+
//~^ ERROR no field `await` on type
11+
//~| NOTE unknown field
12+
//~| NOTE to `.await` a `Future`, switch to Rust 2018
13+
//~| HELP set `edition = "2018"` in `Cargo.toml`
14+
//~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide
15+
}
16+
17+
fn await_on_struct_similar() {
18+
struct S {
19+
awai: u8,
20+
}
21+
let x = S { awai: 42 };
22+
x.await;
23+
//~^ ERROR no field `await` on type
24+
//~| HELP a field with a similar name exists
25+
//~| NOTE to `.await` a `Future`, switch to Rust 2018
26+
//~| HELP set `edition = "2018"` in `Cargo.toml`
27+
//~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide
28+
}
29+
30+
fn await_on_63533(x: Pin<&mut dyn Future<Output = ()>>) {
31+
x.await;
32+
//~^ ERROR no field `await` on type
33+
//~| NOTE unknown field
34+
//~| NOTE to `.await` a `Future`, switch to Rust 2018
35+
//~| HELP set `edition = "2018"` in `Cargo.toml`
36+
//~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide
37+
}
38+
39+
fn await_on_apit(x: impl Future<Output = ()>) {
40+
x.await;
41+
//~^ ERROR no field `await` on type
42+
//~| NOTE to `.await` a `Future`, switch to Rust 2018
43+
//~| HELP set `edition = "2018"` in `Cargo.toml`
44+
//~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
error[E0609]: no field `await` on type `await_on_struct_missing::S`
2+
--> $DIR/suggest-switching-edition-on-await.rs:9:7
3+
|
4+
LL | x.await;
5+
| ^^^^^ unknown field
6+
|
7+
= note: to `.await` a `Future`, switch to Rust 2018
8+
= help: set `edition = "2018"` in `Cargo.toml`
9+
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
10+
11+
error[E0609]: no field `await` on type `await_on_struct_similar::S`
12+
--> $DIR/suggest-switching-edition-on-await.rs:22:7
13+
|
14+
LL | x.await;
15+
| ^^^^^ help: a field with a similar name exists: `awai`
16+
|
17+
= note: to `.await` a `Future`, switch to Rust 2018
18+
= help: set `edition = "2018"` in `Cargo.toml`
19+
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
20+
21+
error[E0609]: no field `await` on type `std::pin::Pin<&mut dyn std::future::Future<Output = ()>>`
22+
--> $DIR/suggest-switching-edition-on-await.rs:31:7
23+
|
24+
LL | x.await;
25+
| ^^^^^ unknown field
26+
|
27+
= note: to `.await` a `Future`, switch to Rust 2018
28+
= help: set `edition = "2018"` in `Cargo.toml`
29+
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
30+
31+
error[E0609]: no field `await` on type `impl Future<Output = ()>`
32+
--> $DIR/suggest-switching-edition-on-await.rs:40:7
33+
|
34+
LL | x.await;
35+
| ^^^^^
36+
|
37+
= note: to `.await` a `Future`, switch to Rust 2018
38+
= help: set `edition = "2018"` in `Cargo.toml`
39+
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
40+
41+
error: aborting due to 4 previous errors
42+
43+
For more information about this error, try `rustc --explain E0609`.

0 commit comments

Comments
 (0)