]> git.proxmox.com Git - rustc.git/blob - src/test/ui/try-trait/try-on-option.stderr
ba85a7cada2329668ec3bebd3a3f3bb3a4fb05ba
[rustc.git] / src / test / ui / try-trait / try-on-option.stderr
1 error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result`
2 --> $DIR/try-on-option.rs:5:6
3 |
4 LL | / fn foo() -> Result<u32, ()> {
5 LL | | let x: Option<u32> = None;
6 LL | | x?;
7 | | ^ use `.ok_or(...)?` to provide an error compatible with `Result<u32, ()>`
8 LL | | Ok(22)
9 LL | | }
10 | |_- this function returns a `Result`
11 |
12 = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<u32, ()>`
13 = help: the following other types implement trait `FromResidual<R>`:
14 <Result<T, F> as FromResidual<Result<Infallible, E>>>
15 <Result<T, F> as FromResidual<Yeet<E>>>
16
17 error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
18 --> $DIR/try-on-option.rs:11:6
19 |
20 LL | / fn bar() -> u32 {
21 LL | | let x: Option<u32> = None;
22 LL | | x?;
23 | | ^ cannot use the `?` operator in a function that returns `u32`
24 LL | | 22
25 LL | | }
26 | |_- this function should return `Result` or `Option` to accept `?`
27 |
28 = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `u32`
29
30 error: aborting due to 2 previous errors
31
32 For more information about this error, try `rustc --explain E0277`.