diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/async-await/suggest-missing-await.rs | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/async-await/suggest-missing-await.rs | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/test/ui/async-await/suggest-missing-await.rs b/src/test/ui/async-await/suggest-missing-await.rs new file mode 100644 index 000000000..796f82e77 --- /dev/null +++ b/src/test/ui/async-await/suggest-missing-await.rs @@ -0,0 +1,74 @@ +// edition:2018 + +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 `await`ing on the `Future` + //~| SUGGESTION .await +} + +async fn dummy() {} + +#[allow(unused)] +async fn suggest_await_in_async_fn_return() { + dummy() + //~^ ERROR mismatched types [E0308] + //~| HELP consider `await`ing on the `Future` + //~| HELP consider using a semicolon here + //~| SUGGESTION .await +} + +#[allow(unused)] +async fn suggest_await_on_if() { + let _x = if true { + dummy() + //~^ HELP consider `await`ing on the `Future` + } else { + dummy().await + //~^ ERROR `if` and `else` have incompatible types [E0308] + }; +} + +#[allow(unused)] +async fn suggest_await_on_previous_match_arms() { + let _x = match 0usize { + 0 => dummy(), //~ HELP consider `await`ing on the `Future` + 1 => dummy(), + 2 => dummy().await, + //~^ `match` arms have incompatible types [E0308] + }; +} + +#[allow(unused)] +async fn suggest_await_on_match_expr() { + let _x = match dummy() { //~ HELP consider `await`ing on the `Future` + () => {} //~ ERROR mismatched types [E0308] + }; +} + +async fn dummy_result() -> Result<(), ()> { + Ok(()) +} + +#[allow(unused)] +async fn suggest_await_in_generic_pattern() { + match dummy_result() { + //~^ HELP consider `await`ing on the `Future` + //~| HELP consider `await`ing on the `Future` + //~| SUGGESTION .await + Ok(_) => {} + //~^ ERROR mismatched types [E0308] + Err(_) => {} + //~^ ERROR mismatched types [E0308] + } +} + +fn main() {} |