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