]> git.lizzy.rs Git - rust.git/blob - src/test/ui/async-await/try-on-option-in-async.stderr
Rollup merge of #82259 - osa1:issue82156, r=petrochenkov
[rust.git] / src / test / ui / async-await / try-on-option-in-async.stderr
1 error[E0277]: the `?` operator can only be used in an async block that returns `Result` or `Option` (or another type that implements `Try`)
2   --> $DIR/try-on-option-in-async.rs:8:9
3    |
4 LL |       async {
5    |  ___________-
6 LL | |         let x: Option<u32> = None;
7 LL | |         x?;
8    | |         ^^ cannot use the `?` operator in an async block that returns `{integer}`
9 LL | |         22
10 LL | |     }
11    | |_____- this function should return `Result` or `Option` to accept `?`
12    |
13    = help: the trait `Try` is not implemented for `{integer}`
14    = note: required by `from_error`
15
16 error[E0277]: the `?` operator can only be used in an async closure that returns `Result` or `Option` (or another type that implements `Try`)
17   --> $DIR/try-on-option-in-async.rs:17:9
18    |
19 LL |       let async_closure = async || {
20    |  __________________________________-
21 LL | |         let x: Option<u32> = None;
22 LL | |         x?;
23    | |         ^^ cannot use the `?` operator in an async closure that returns `u32`
24 LL | |         22_u32
25 LL | |     };
26    | |_____- this function should return `Result` or `Option` to accept `?`
27    |
28    = help: the trait `Try` is not implemented for `u32`
29    = note: required by `from_error`
30
31 error[E0277]: the `?` operator can only be used in an async function that returns `Result` or `Option` (or another type that implements `Try`)
32   --> $DIR/try-on-option-in-async.rs:26:5
33    |
34 LL |   async fn an_async_function() -> u32 {
35    |  _____________________________________-
36 LL | |     let x: Option<u32> = None;
37 LL | |     x?;
38    | |     ^^ cannot use the `?` operator in an async function that returns `u32`
39 LL | |     22
40 LL | | }
41    | |_- this function should return `Result` or `Option` to accept `?`
42    |
43    = help: the trait `Try` is not implemented for `u32`
44    = note: required by `from_error`
45
46 error: aborting due to 3 previous errors
47
48 For more information about this error, try `rustc --explain E0277`.