]> git.lizzy.rs Git - rust.git/blob - src/test/ui/try-trait/option-to-result.stderr
Auto merge of #106349 - LeSeulArtichaut:dyn-star-tracking-issue, r=jackh726
[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    | --------------------------------- this function returns a `Result`
6 LL |     let a:Option<()> = Some(());
7 LL |     a?;
8    |      ^ use `.ok_or(...)?` to provide an error compatible with `Result<(), ()>`
9    |
10    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<(), ()>`
11    = help: the following other types implement trait `FromResidual<R>`:
12              <Result<T, F> as FromResidual<Result<Infallible, E>>>
13              <Result<T, F> as FromResidual<Yeet<E>>>
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    | ------------------------------- this function returns an `Option`
20 LL |     let a:Result<i32, i32> = Ok(5);
21 LL |     a?;
22    |      ^ use `.ok()?` if you want to discard the `Result<Infallible, i32>` error information
23    |
24    = help: the trait `FromResidual<Result<Infallible, i32>>` is not implemented for `Option<i32>`
25    = help: the following other types implement trait `FromResidual<R>`:
26              <Option<T> as FromResidual<Yeet<()>>>
27              <Option<T> as FromResidual>
28
29 error: aborting due to 2 previous errors
30
31 For more information about this error, try `rustc --explain E0277`.