]> git.lizzy.rs Git - rust.git/blob - src/test/ui/option-to-result.stderr
Auto merge of #81507 - weiznich:add_diesel_to_cargo_test, r=Mark-Simulacrum
[rust.git] / src / test / ui / option-to-result.stderr
1 error[E0277]: `?` couldn't convert the error to `()`
2   --> $DIR/option-to-result.rs:5:6
3    |
4 LL | fn test_result() -> Result<(),()> {
5    |                     ------------- expected `()` because of this
6 LL |     let a:Option<()> = Some(());
7 LL |     a?;
8    |      ^ the trait `From<NoneError>` is not implemented for `()`
9    |
10    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
11    = note: required by `from`
12 help: consider converting the `Option<T>` into a `Result<T, _>` using `Option::ok_or` or `Option::ok_or_else`
13    |
14 LL |     a.ok_or_else(|| /* error value */)?;
15    |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16
17 error[E0277]: `?` couldn't convert the error to `NoneError`
18   --> $DIR/option-to-result.rs:11:6
19    |
20 LL | fn test_option() -> Option<i32>{
21    |                     ----------- expected `NoneError` because of this
22 LL |     let a:Result<i32, i32> = Ok(5);
23 LL |     a?;
24    |      ^ the trait `From<i32>` is not implemented for `NoneError`
25    |
26    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
27    = note: required by `from`
28 help: consider converting the `Result<T, _>` into an `Option<T>` using `Result::ok`
29    |
30 LL |     a.ok()?;
31    |      ^^^^^
32
33 error: aborting due to 2 previous errors
34
35 For more information about this error, try `rustc --explain E0277`.