diff options
| author | Ken Matsui <26405363+ken-matsui@users.noreply.github.com> | 2022-05-02 08:19:57 +0900 |
|---|---|---|
| committer | Ken Matsui <26405363+ken-matsui@users.noreply.github.com> | 2022-05-08 09:34:02 +0900 |
| commit | 8b89a1280c929f7aaf11386f8f1a9ecdbef2f539 (patch) | |
| tree | 8ba30baef2760c8f2f7f0385f325e6fae6fa09ad /src | |
| parent | bf611439e3239ad3f74bd76cc46a4e89b87d8219 (diff) | |
| download | rust-8b89a1280c929f7aaf11386f8f1a9ecdbef2f539.tar.gz rust-8b89a1280c929f7aaf11386f8f1a9ecdbef2f539.zip | |
Fix incorrect syntax suggestion with `pub async fn`
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/suggestions/issue-96555.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/suggestions/issue-96555.stderr | 66 |
2 files changed, 85 insertions, 0 deletions
diff --git a/src/test/ui/suggestions/issue-96555.rs b/src/test/ui/suggestions/issue-96555.rs new file mode 100644 index 00000000000..9f0a047c6e9 --- /dev/null +++ b/src/test/ui/suggestions/issue-96555.rs @@ -0,0 +1,19 @@ +// edition:2018 + +async fn f() { + m::f1().await; //~ ERROR `()` is not a future + m::f2().await; //~ ERROR `()` is not a future + m::f3().await; //~ ERROR `()` is not a future +} + +mod m { + pub fn f1() {} + + pub(crate) fn f2() {} + + pub + fn + f3() {} +} + +fn main() {} diff --git a/src/test/ui/suggestions/issue-96555.stderr b/src/test/ui/suggestions/issue-96555.stderr new file mode 100644 index 00000000000..6d3b8844d95 --- /dev/null +++ b/src/test/ui/suggestions/issue-96555.stderr @@ -0,0 +1,66 @@ +error[E0277]: `()` is not a future + --> $DIR/issue-96555.rs:4:12 + | +LL | m::f1().await; + | -------^^^^^^ `()` is not a future + | | + | this call returns `()` + | + = help: the trait `Future` is not implemented for `()` + = note: () must be a future or must implement `IntoFuture` to be awaited + = note: required because of the requirements on the impl of `IntoFuture` for `()` +help: remove the `.await` + | +LL - m::f1().await; +LL + m::f1(); + | +help: alternatively, consider making `fn f1` asynchronous + | +LL | pub async fn f1() {} + | +++++ + +error[E0277]: `()` is not a future + --> $DIR/issue-96555.rs:5:12 + | +LL | m::f2().await; + | -------^^^^^^ `()` is not a future + | | + | this call returns `()` + | + = help: the trait `Future` is not implemented for `()` + = note: () must be a future or must implement `IntoFuture` to be awaited + = note: required because of the requirements on the impl of `IntoFuture` for `()` +help: remove the `.await` + | +LL - m::f2().await; +LL + m::f2(); + | +help: alternatively, consider making `fn f2` asynchronous + | +LL | pub(crate) async fn f2() {} + | +++++ + +error[E0277]: `()` is not a future + --> $DIR/issue-96555.rs:6:12 + | +LL | m::f3().await; + | -------^^^^^^ `()` is not a future + | | + | this call returns `()` + | + = help: the trait `Future` is not implemented for `()` + = note: () must be a future or must implement `IntoFuture` to be awaited + = note: required because of the requirements on the impl of `IntoFuture` for `()` +help: remove the `.await` + | +LL - m::f3().await; +LL + m::f3(); + | +help: alternatively, consider making `fn f3` asynchronous + | +LL | pub async + | +++++ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. |
