-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add suggestion for missing
.await
keyword
- Loading branch information
Showing
9 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
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
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,21 @@ | ||
// edition:2018 | ||
|
||
// This test ensures we don't make the suggestion in bodies that aren't `async`. | ||
|
||
#![feature(async_await)] | ||
|
||
fn take_u32(x: u32) {} | ||
|
||
async fn make_u32() -> u32 { | ||
22 | ||
} | ||
|
||
async fn dont_suggest_await_in_closure() { | ||
|| { | ||
let x = make_u32(); | ||
take_u32(x) | ||
//~^ ERROR mismatched types [E0308] | ||
}; | ||
} | ||
|
||
fn main() {} |
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,12 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/dont-suggest-missing-await.rs:16:18 | ||
| | ||
LL | take_u32(x) | ||
| ^ expected u32, found opaque type | ||
| | ||
= note: expected type `u32` | ||
found type `impl std::future::Future` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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,32 @@ | ||
// edition:2018 | ||
// run-rustfix | ||
|
||
#![feature(async_await)] | ||
|
||
fn take_u32(_x: u32) {} | ||
|
||
async fn make_u32() -> u32 { | ||
22 | ||
} | ||
|
||
#[allow(unused)] | ||
async fn suggest_await_in_async_fn() { | ||
let x = make_u32(); | ||
take_u32(x.await) | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider using `.await` here | ||
//~| SUGGESTION x.await | ||
} | ||
|
||
#[allow(unused)] | ||
async fn suggest_await_in_async_closure() { | ||
async || { | ||
let x = make_u32(); | ||
take_u32(x.await) | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider using `.await` here | ||
//~| SUGGESTION x.await | ||
}; | ||
} | ||
|
||
fn main() {} |
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,32 @@ | ||
// edition:2018 | ||
// run-rustfix | ||
|
||
#![feature(async_await)] | ||
|
||
fn take_u32(_x: u32) {} | ||
|
||
async fn make_u32() -> u32 { | ||
22 | ||
} | ||
|
||
#[allow(unused)] | ||
async fn suggest_await_in_async_fn() { | ||
let x = make_u32(); | ||
take_u32(x) | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider using `.await` here | ||
//~| SUGGESTION x.await | ||
} | ||
|
||
#[allow(unused)] | ||
async fn suggest_await_in_async_closure() { | ||
async || { | ||
let x = make_u32(); | ||
take_u32(x) | ||
//~^ ERROR mismatched types [E0308] | ||
//~| HELP consider using `.await` here | ||
//~| SUGGESTION x.await | ||
}; | ||
} | ||
|
||
fn main() {} |
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,27 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/suggest-missing-await.rs:15:14 | ||
| | ||
LL | take_u32(x) | ||
| ^ | ||
| | | ||
| expected u32, found opaque type | ||
| help: consider using `.await` here: `x.await` | ||
| | ||
= note: expected type `u32` | ||
found type `impl std::future::Future` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/suggest-missing-await.rs:25:18 | ||
| | ||
LL | take_u32(x) | ||
| ^ | ||
| | | ||
| expected u32, found opaque type | ||
| help: consider using `.await` here: `x.await` | ||
| | ||
= note: expected type `u32` | ||
found type `impl std::future::Future` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |