]> git.lizzy.rs Git - rust.git/blob - src/test/ui/try-trait/option-to-result.stderr
Dedup logic and improve output for other types that impl trait
[rust.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    = help: the trait `FromResidual<Result<Infallible, E>>` is implemented for `Result<T, F>`
14
15 error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option`
16   --> $DIR/option-to-result.rs:11:6
17    |
18 LL | / fn test_option() -> Option<i32>{
19 LL | |     let a:Result<i32, i32> = Ok(5);
20 LL | |     a?;
21    | |      ^ use `.ok()?` if you want to discard the `Result<Infallible, i32>` error information
22 LL | |     Some(5)
23 LL | | }
24    | |_- this function returns an `Option`
25    |
26    = help: the trait `FromResidual<Result<Infallible, i32>>` is not implemented for `Option<i32>`
27    = help: the trait `FromResidual` is implemented for `Option<T>`
28
29 error: aborting due to 2 previous errors
30
31 For more information about this error, try `rustc --explain E0277`.