-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Infer async block return type from future expectation
- Loading branch information
1 parent
ab9bb3e
commit 7456253
Showing
6 changed files
with
47 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// check-pass | ||
// edition: 2021 | ||
|
||
use std::fmt::Debug; | ||
use std::future::Future; | ||
|
||
fn needs_future(_: impl Future<Output = Box<dyn Debug>>) {} | ||
|
||
fn main() { | ||
needs_future(async { Box::new(()) }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,9 @@ | ||
error[E0271]: expected `[async block@$DIR/async.rs:12:17: 12:25]` to be a future that resolves to `i32`, but it resolves to `()` | ||
--> $DIR/async.rs:12:17 | ||
error[E0308]: mismatched types | ||
--> $DIR/async.rs:12:23 | ||
| | ||
LL | needs_async(async {}); | ||
| ----------- ^^^^^^^^ expected `i32`, found `()` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
note: required by a bound in `needs_async` | ||
--> $DIR/async.rs:8:31 | ||
| | ||
LL | fn needs_async(_: impl Future<Output = i32>) {} | ||
| ^^^^^^^^^^^^ required by this bound in `needs_async` | ||
| ^^ expected `i32`, found `()` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0271`. | ||
For more information about this error, try `rustc --explain E0308`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters