2021-04-17 13:56:07 -05: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 14:04:15 -05:00
|
2022-11-18 15:56:22 -06:00
LL | / async {
2019-11-24 15:29:40 -06:00
LL | | let x: Option<u32> = None;
LL | | x?;
2021-04-17 13:56:07 -05:00
| | ^ cannot use the `?` operator in an async block that returns `{integer}`
2019-11-24 15:29:40 -06:00
LL | | 22
2020-05-14 10:07:46 -05:00
LL | | }
2019-11-24 15:29:40 -06:00
| |_____- this function should return `Result` or `Option` to accept `?`
2019-10-28 14:04:15 -05:00
|
2021-04-17 13:56:07 -05:00
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `{integer}`
2019-10-28 14:04:15 -05:00
2021-04-17 13:56:07 -05: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 14:04:15 -05:00
|
2019-11-24 15:29:40 -06:00
LL | let async_closure = async || {
| __________________________________-
LL | | let x: Option<u32> = None;
LL | | x?;
2021-04-17 13:56:07 -05:00
| | ^ cannot use the `?` operator in an async closure that returns `u32`
2019-11-24 15:29:40 -06:00
LL | | 22_u32
LL | | };
| |_____- this function should return `Result` or `Option` to accept `?`
2019-10-28 14:04:15 -05:00
|
2021-04-17 13:56:07 -05:00
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `u32`
2019-10-28 14:04:15 -05:00
2021-04-17 13:56:07 -05: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 14:04:15 -05:00
|
2019-11-24 15:29:40 -06:00
LL | async fn an_async_function() -> u32 {
| _____________________________________-
LL | | let x: Option<u32> = None;
LL | | x?;
2021-04-17 13:56:07 -05:00
| | ^ cannot use the `?` operator in an async function that returns `u32`
2019-11-24 15:29:40 -06:00
LL | | 22
LL | | }
| |_- this function should return `Result` or `Option` to accept `?`
2019-10-28 14:04:15 -05:00
|
2021-04-17 13:56:07 -05:00
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `u32`
2019-10-28 14:04:15 -05:00
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0277`.