]> git.proxmox.com Git - rustc.git/blame - src/test/ui/try-trait/try-on-option.stderr
New upstream version 1.55.0+dfsg1
[rustc.git] / src / test / ui / try-trait / try-on-option.stderr
CommitLineData
17df50a5
XL
1error[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:7:6
3 |
4LL | / fn foo() -> Result<u32, ()> {
5LL | | let x: Option<u32> = None;
6LL | | x?;
7 | | ^ use `.ok_or(...)?` to provide an error compatible with `Result<u32, ()>`
8LL | | Ok(22)
9LL | | }
10 | |_- this function returns a `Result`
11 |
12 = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<u32, ()>`
136023e0
XL
13note: required by `from_residual`
14 --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
15 |
16LL | fn from_residual(residual: R) -> Self;
17 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17df50a5
XL
18
19error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
20 --> $DIR/try-on-option.rs:13:6
21 |
22LL | / fn bar() -> u32 {
23LL | | let x: Option<u32> = None;
24LL | | x?;
25 | | ^ cannot use the `?` operator in a function that returns `u32`
26LL | | 22
27LL | | }
28 | |_- this function should return `Result` or `Option` to accept `?`
29 |
30 = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `u32`
136023e0
XL
31note: required by `from_residual`
32 --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
33 |
34LL | fn from_residual(residual: R) -> Self;
35 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17df50a5
XL
36
37error: aborting due to 2 previous errors
38
39For more information about this error, try `rustc --explain E0277`.