2021-04-17 18:56:07 +00:00
error[E0277]: the `?` operator can only be used in an async block that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> $DIR/try-on-option-in-async.rs:8:10
2019-10-28 19:04:15 +00:00
|
2022-11-18 21:56:22 +00:00
LL | / async {
2019-11-24 21:29:40 +00:00
LL | | let x: Option<u32> = None;
LL | | x?;
2021-04-17 18:56:07 +00:00
| | ^ cannot use the `?` operator in an async block that returns `{integer}`
2019-11-24 21:29:40 +00:00
LL | | 22
2020-05-14 15:07:46 +00:00
LL | | }
2019-11-24 21:29:40 +00:00
| |_____- this function should return `Result` or `Option` to accept `?`
2019-10-28 19:04:15 +00:00
|
2021-04-17 18:56:07 +00:00
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `{integer}`
2019-10-28 19:04:15 +00:00
2021-04-17 18:56:07 +00:00
error[E0277]: the `?` operator can only be used in an async closure that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> $DIR/try-on-option-in-async.rs:17:10
2019-10-28 19:04:15 +00:00
|
2019-11-24 21:29:40 +00:00
LL | let async_closure = async || {
| __________________________________-
LL | | let x: Option<u32> = None;
LL | | x?;
2021-04-17 18:56:07 +00:00
| | ^ cannot use the `?` operator in an async closure that returns `u32`
2019-11-24 21:29:40 +00:00
LL | | 22_u32
LL | | };
| |_____- this function should return `Result` or `Option` to accept `?`
2019-10-28 19:04:15 +00:00
|
2021-04-17 18:56:07 +00:00
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `u32`
2019-10-28 19:04:15 +00:00
2021-04-17 18:56:07 +00:00
error[E0277]: the `?` operator can only be used in an async function that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> $DIR/try-on-option-in-async.rs:26:6
2019-10-28 19:04:15 +00:00
|
2019-11-24 21:29:40 +00:00
LL | async fn an_async_function() -> u32 {
| _____________________________________-
LL | | let x: Option<u32> = None;
LL | | x?;
2021-04-17 18:56:07 +00:00
| | ^ cannot use the `?` operator in an async function that returns `u32`
2019-11-24 21:29:40 +00:00
LL | | 22
LL | | }
| |_- this function should return `Result` or `Option` to accept `?`
2019-10-28 19:04:15 +00:00
|
2021-04-17 18:56:07 +00:00
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `u32`
2019-10-28 19:04:15 +00:00
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0277`.