-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a note for ? on future in sync function
- Loading branch information
1 parent
fb20e4d
commit 5e8820c
Showing
3 changed files
with
82 additions
and
43 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,9 @@ | ||
//@ edition: 2021 | ||
|
||
async fn foo() -> Result<(), ()> { todo!() } | ||
|
||
fn main() -> Result<(), ()> { | ||
foo()?; | ||
//~^ ERROR the `?` operator can only be applied to values that implement `Try` | ||
Ok(()) | ||
} |
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,18 @@ | ||
error[E0277]: the `?` operator can only be applied to values that implement `Try` | ||
--> $DIR/try-in-sync.rs:6:5 | ||
| | ||
LL | foo()?; | ||
| ^^^^^^ the `?` operator cannot be applied to type `impl Future<Output = Result<(), ()>>` | ||
| | ||
= help: the trait `Try` is not implemented for `impl Future<Output = Result<(), ()>>` | ||
note: this implements `Future` and its output type supports `?`, but the future cannot be awaited in a synchronous function | ||
--> $DIR/try-in-sync.rs:6:10 | ||
| | ||
LL | fn main() -> Result<(), ()> { | ||
| --------------------------- this is not `async` | ||
LL | foo()?; | ||
| ^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |