about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEric Holk <ericholk@microsoft.com>2021-12-02 11:36:48 -0800
committerEric Holk <ericholk@microsoft.com>2021-12-02 11:36:56 -0800
commit0cb769347d64b52187a593aca941879d990f61b2 (patch)
tree73413decb7fe4604b537f3eb146173a5b1ca85c7
parentdb80c0759067028edc71939b24c35d8234835096 (diff)
downloadrust-0cb769347d64b52187a593aca941879d990f61b2.tar.gz
rust-0cb769347d64b52187a593aca941879d990f61b2.zip
Code review feedback
Add a note about `IntoFuture` in error messages where T is not a future.

Change await-into-future.rs to be a run-pass test.
-rw-r--r--library/core/src/future/future.rs6
-rw-r--r--src/test/ui/async-await/async-error-span.stderr1
-rw-r--r--src/test/ui/async-await/await-into-future.rs10
-rw-r--r--src/test/ui/async-await/issue-70594.stderr1
-rw-r--r--src/test/ui/async-await/issues/issue-62009-1.stderr1
5 files changed, 14 insertions, 5 deletions
diff --git a/library/core/src/future/future.rs b/library/core/src/future/future.rs
index 09d8a2aac26..6b62236b32f 100644
--- a/library/core/src/future/future.rs
+++ b/library/core/src/future/future.rs
@@ -28,7 +28,11 @@ use crate::task::{Context, Poll};
 #[must_use = "futures do nothing unless you `.await` or poll them"]
 #[stable(feature = "futures_api", since = "1.36.0")]
 #[lang = "future_trait"]
-#[rustc_on_unimplemented(label = "`{Self}` is not a future", message = "`{Self}` is not a future")]
+#[rustc_on_unimplemented(
+    label = "`{Self}` is not a future",
+    message = "`{Self}` is not a future",
+    note = "{Self} must be a future or must implement `IntoFuture` to be awaited"
+)]
 pub trait Future {
     /// The type of value produced on completion.
     #[stable(feature = "futures_api", since = "1.36.0")]
diff --git a/src/test/ui/async-await/async-error-span.stderr b/src/test/ui/async-await/async-error-span.stderr
index 994bfd33ba4..2e3f8bb5256 100644
--- a/src/test/ui/async-await/async-error-span.stderr
+++ b/src/test/ui/async-await/async-error-span.stderr
@@ -5,6 +5,7 @@ LL | fn get_future() -> impl Future<Output = ()> {
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not a future
    |
    = help: the trait `Future` is not implemented for `()`
+   = note: () must be a future or must implement `IntoFuture` to be awaited
 
 error[E0698]: type inside `async fn` body must be known in this context
   --> $DIR/async-error-span.rs:13:9
diff --git a/src/test/ui/async-await/await-into-future.rs b/src/test/ui/async-await/await-into-future.rs
index 49712684b04..b74b1684440 100644
--- a/src/test/ui/async-await/await-into-future.rs
+++ b/src/test/ui/async-await/await-into-future.rs
@@ -1,9 +1,9 @@
-// check-pass
-
+// run-pass
+// aux-build: issue-72470-lib.rs
 // edition:2021
-
 #![feature(into_future)]
 
+extern crate issue_72470_lib;
 use std::{future::{Future, IntoFuture}, pin::Pin};
 
 struct AwaitMe;
@@ -25,4 +25,6 @@ async fn run() {
     assert_eq!(AwaitMe.await, 41);
 }
 
-fn main() {}
+fn main() {
+    issue_72470_lib::run(run());
+}
diff --git a/src/test/ui/async-await/issue-70594.stderr b/src/test/ui/async-await/issue-70594.stderr
index b010ff75828..ab05251526b 100644
--- a/src/test/ui/async-await/issue-70594.stderr
+++ b/src/test/ui/async-await/issue-70594.stderr
@@ -25,6 +25,7 @@ LL |     [1; ().await];
    |         ^^^^^^^^ `()` is not a future
    |
    = 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 `()`
 
 error: aborting due to 4 previous errors
diff --git a/src/test/ui/async-await/issues/issue-62009-1.stderr b/src/test/ui/async-await/issues/issue-62009-1.stderr
index 33aae59bbd7..19d6f9bc438 100644
--- a/src/test/ui/async-await/issues/issue-62009-1.stderr
+++ b/src/test/ui/async-await/issues/issue-62009-1.stderr
@@ -34,6 +34,7 @@ LL |     (|_| 2333).await;
    |     ^^^^^^^^^^^^^^^^ `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]` is not a future
    |
    = help: the trait `Future` is not implemented for `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]`
+   = note: [closure@$DIR/issue-62009-1.rs:12:5: 12:15] must be a future or must implement `IntoFuture` to be awaited
    = note: required because of the requirements on the impl of `IntoFuture` for `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]`
 
 error: aborting due to 4 previous errors