]> git.lizzy.rs Git - rust.git/blob - tests/ui/try-trait/try-on-option-diagnostics.stderr
Rollup merge of #103702 - WaffleLapkin:lift-sized-bounds-from-pointer-methods-where...
[rust.git] / tests / 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    | ---------------------- this function should return `Result` or `Option` to accept `?`
6 LL |     let x: Option<u32> = None;
7 LL |     x?;
8    |      ^ cannot use the `?` operator in a function that returns `u32`
9    |
10    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `u32`
11
12 error[E0277]: the `?` operator can only be used in a closure that returns `Result` or `Option` (or another type that implements `FromResidual`)
13   --> $DIR/try-on-option-diagnostics.rs:14:10
14    |
15 LL |     let a_closure = || {
16    |                     -- this function should return `Result` or `Option` to accept `?`
17 LL |         let x: Option<u32> = None;
18 LL |         x?;
19    |          ^ cannot use the `?` operator in a closure that returns `{integer}`
20    |
21    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `{integer}`
22
23 error[E0277]: the `?` operator can only be used in a method that returns `Result` or `Option` (or another type that implements `FromResidual`)
24   --> $DIR/try-on-option-diagnostics.rs:26:14
25    |
26 LL |         fn a_method() {
27    |         ------------- this function should return `Result` or `Option` to accept `?`
28 LL |             let x: Option<u32> = None;
29 LL |             x?;
30    |              ^ cannot use the `?` operator in a method that returns `()`
31    |
32    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `()`
33
34 error[E0277]: the `?` operator can only be used in a trait method that returns `Result` or `Option` (or another type that implements `FromResidual`)
35   --> $DIR/try-on-option-diagnostics.rs:39:14
36    |
37 LL |         fn a_trait_method() {
38    |         ------------------- this function should return `Result` or `Option` to accept `?`
39 LL |             let x: Option<u32> = None;
40 LL |             x?;
41    |              ^ cannot use the `?` operator in a trait method that returns `()`
42    |
43    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `()`
44
45 error: aborting due to 4 previous errors
46
47 For more information about this error, try `rustc --explain E0277`.