fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #71868 - Mark-Simulacrum:stable-1.43.1, r=pietroalbini8d69840ab92

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