about summary refs log tree commit diff
path: root/src/test/ui/option-to-result.stderr
blob: 5fa06778389d9754c056948f3b04b1a0e42ff6ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
error[E0277]: `?` couldn't convert the error to `()`
  --> $DIR/option-to-result.rs:5:6
   |
LL | fn test_result() -> Result<(),()> {
   |                     ------------- expected `()` because of this
LL |     let a:Option<()> = Some(());
LL |     a?;
   |      ^ the trait `std::convert::From<std::option::NoneError>` is not implemented for `()`
   |
   = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
   = note: required by `std::convert::From::from`
help: consider converting the `Option<T>` into a `Result<T, _>` using `Option::ok_or` or `Option::ok_or_else`
   |
LL |     a.ok_or_else(|| /* error value */)?;
   |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0277]: `?` couldn't convert the error to `std::option::NoneError`
  --> $DIR/option-to-result.rs:11:6
   |
LL | fn test_option() -> Option<i32>{
   |                     ----------- expected `std::option::NoneError` because of this
LL |     let a:Result<i32, i32> = Ok(5);
LL |     a?;
   |      ^ the trait `std::convert::From<i32>` is not implemented for `std::option::NoneError`
   |
   = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
   = note: required by `std::convert::From::from`
help: consider converting the `Result<T, _>` into an `Option<T>` using `Result::ok`
   |
LL |     a.ok()?;
   |      ^^^^^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.