Skip to content

Commit 0cb7693

Browse files
committed
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.
1 parent db80c07 commit 0cb7693

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

library/core/src/future/future.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ use crate::task::{Context, Poll};
2828
#[must_use = "futures do nothing unless you `.await` or poll them"]
2929
#[stable(feature = "futures_api", since = "1.36.0")]
3030
#[lang = "future_trait"]
31-
#[rustc_on_unimplemented(label = "`{Self}` is not a future", message = "`{Self}` is not a future")]
31+
#[rustc_on_unimplemented(
32+
label = "`{Self}` is not a future",
33+
message = "`{Self}` is not a future",
34+
note = "{Self} must be a future or must implement `IntoFuture` to be awaited"
35+
)]
3236
pub trait Future {
3337
/// The type of value produced on completion.
3438
#[stable(feature = "futures_api", since = "1.36.0")]

src/test/ui/async-await/async-error-span.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | fn get_future() -> impl Future<Output = ()> {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not a future
66
|
77
= help: the trait `Future` is not implemented for `()`
8+
= note: () must be a future or must implement `IntoFuture` to be awaited
89

910
error[E0698]: type inside `async fn` body must be known in this context
1011
--> $DIR/async-error-span.rs:13:9

src/test/ui/async-await/await-into-future.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// check-pass
2-
1+
// run-pass
2+
// aux-build: issue-72470-lib.rs
33
// edition:2021
4-
54
#![feature(into_future)]
65

6+
extern crate issue_72470_lib;
77
use std::{future::{Future, IntoFuture}, pin::Pin};
88

99
struct AwaitMe;
@@ -25,4 +25,6 @@ async fn run() {
2525
assert_eq!(AwaitMe.await, 41);
2626
}
2727

28-
fn main() {}
28+
fn main() {
29+
issue_72470_lib::run(run());
30+
}

src/test/ui/async-await/issue-70594.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ LL | [1; ().await];
2525
| ^^^^^^^^ `()` is not a future
2626
|
2727
= help: the trait `Future` is not implemented for `()`
28+
= note: () must be a future or must implement `IntoFuture` to be awaited
2829
= note: required because of the requirements on the impl of `IntoFuture` for `()`
2930

3031
error: aborting due to 4 previous errors

src/test/ui/async-await/issues/issue-62009-1.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ LL | (|_| 2333).await;
3434
| ^^^^^^^^^^^^^^^^ `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]` is not a future
3535
|
3636
= help: the trait `Future` is not implemented for `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]`
37+
= note: [closure@$DIR/issue-62009-1.rs:12:5: 12:15] must be a future or must implement `IntoFuture` to be awaited
3738
= note: required because of the requirements on the impl of `IntoFuture` for `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]`
3839

3940
error: aborting due to 4 previous errors

0 commit comments

Comments
 (0)