]> git.lizzy.rs Git - rust.git/blob - src/test/ui/try-trait/try-on-option-diagnostics.stderr
Dedup logic and improve output for other types that impl trait
[rust.git] / src / test / ui / try-trait / try-on-option-diagnostics.stderr
1 error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
2   --> $DIR/try-on-option-diagnostics.rs:7:6
3    |
4 LL | / fn a_function() -> u32 {
5 LL | |     let x: Option<u32> = None;
6 LL | |     x?;
7    | |      ^ cannot use the `?` operator in a function that returns `u32`
8 LL | |     22
9 LL | | }
10    | |_- this function should return `Result` or `Option` to accept `?`
11    |
12    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `u32`
13
14 error[E0277]: the `?` operator can only be used in a closure that returns `Result` or `Option` (or another type that implements `FromResidual`)
15   --> $DIR/try-on-option-diagnostics.rs:14:10
16    |
17 LL |       let a_closure = || {
18    |  _____________________-
19 LL | |         let x: Option<u32> = None;
20 LL | |         x?;
21    | |          ^ cannot use the `?` operator in a closure that returns `{integer}`
22 LL | |         22
23 LL | |     };
24    | |_____- this function should return `Result` or `Option` to accept `?`
25    |
26    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `{integer}`
27
28 error[E0277]: the `?` operator can only be used in a method that returns `Result` or `Option` (or another type that implements `FromResidual`)
29   --> $DIR/try-on-option-diagnostics.rs:26:14
30    |
31 LL | /         fn a_method() {
32 LL | |             let x: Option<u32> = None;
33 LL | |             x?;
34    | |              ^ cannot use the `?` operator in a method that returns `()`
35 LL | |         }
36    | |_________- this function should return `Result` or `Option` to accept `?`
37    |
38    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `()`
39
40 error[E0277]: the `?` operator can only be used in a trait method that returns `Result` or `Option` (or another type that implements `FromResidual`)
41   --> $DIR/try-on-option-diagnostics.rs:39:14
42    |
43 LL | /         fn a_trait_method() {
44 LL | |             let x: Option<u32> = None;
45 LL | |             x?;
46    | |              ^ cannot use the `?` operator in a trait method that returns `()`
47 LL | |         }
48    | |_________- this function should return `Result` or `Option` to accept `?`
49    |
50    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `()`
51
52 error: aborting due to 4 previous errors
53
54 For more information about this error, try `rustc --explain E0277`.