Skip to content

Commit

Permalink
Code review feedback
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
eholk committed Dec 2, 2021
1 parent db80c07 commit 0cb7693
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
6 changes: 5 additions & 1 deletion library/core/src/future/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/async-await/async-error-span.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions src/test/ui/async-await/await-into-future.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -25,4 +25,6 @@ async fn run() {
assert_eq!(AwaitMe.await, 41);
}

fn main() {}
fn main() {
issue_72470_lib::run(run());
}
1 change: 1 addition & 0 deletions src/test/ui/async-await/issue-70594.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/async-await/issues/issue-62009-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0cb7693

Please sign in to comment.