]>
Commit | Line | Data |
---|---|---|
17df50a5 XL |
1 | error[E0277]: `?` couldn't convert the error to `u8` |
2 | --> $DIR/bad-interconversion.rs:6:20 | |
3 | | | |
4 | LL | fn result_to_result() -> Result<u64, u8> { | |
5 | | --------------- expected `u8` because of this | |
6 | LL | Ok(Err(123_i32)?) | |
7 | | ^ the trait `From<i32>` is not implemented for `u8` | |
8 | | | |
9 | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait | |
10 | = help: the following implementations were found: | |
11 | <u8 as From<NonZeroU8>> | |
12 | <u8 as From<bool>> | |
13 | = note: required because of the requirements on the impl of `FromResidual<Result<Infallible, i32>>` for `Result<u64, u8>` | |
17df50a5 XL |
14 | |
15 | error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result` | |
16 | --> $DIR/bad-interconversion.rs:11:12 | |
17 | | | |
18 | LL | / fn option_to_result() -> Result<u64, String> { | |
19 | LL | | Some(3)?; | |
20 | | | ^ use `.ok_or(...)?` to provide an error compatible with `Result<u64, String>` | |
21 | LL | | | |
22 | LL | | Ok(10) | |
23 | LL | | } | |
24 | | |_- this function returns a `Result` | |
25 | | | |
26 | = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<u64, String>` | |
17df50a5 XL |
27 | |
28 | error[E0277]: the `?` operator can only be used on `Result`s in a function that returns `Result` | |
29 | --> $DIR/bad-interconversion.rs:17:31 | |
30 | | | |
31 | LL | / fn control_flow_to_result() -> Result<u64, String> { | |
32 | LL | | Ok(ControlFlow::Break(123)?) | |
33 | | | ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Result<u64, String>` | |
34 | LL | | | |
35 | LL | | } | |
36 | | |_- this function returns a `Result` | |
37 | | | |
38 | = help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Result<u64, String>` | |
17df50a5 XL |
39 | |
40 | error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option` | |
41 | --> $DIR/bad-interconversion.rs:22:22 | |
42 | | | |
43 | LL | / fn result_to_option() -> Option<u16> { | |
44 | LL | | Some(Err("hello")?) | |
45 | | | ^ use `.ok()?` if you want to discard the `Result<Infallible, &str>` error information | |
46 | LL | | | |
47 | LL | | } | |
48 | | |_- this function returns an `Option` | |
49 | | | |
50 | = help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `Option<u16>` | |
17df50a5 XL |
51 | |
52 | error[E0277]: the `?` operator can only be used on `Option`s in a function that returns `Option` | |
53 | --> $DIR/bad-interconversion.rs:27:33 | |
54 | | | |
55 | LL | / fn control_flow_to_option() -> Option<u64> { | |
56 | LL | | Some(ControlFlow::Break(123)?) | |
57 | | | ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Option<u64>` | |
58 | LL | | | |
59 | LL | | } | |
60 | | |_- this function returns an `Option` | |
61 | | | |
62 | = help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Option<u64>` | |
17df50a5 XL |
63 | |
64 | error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow` | |
65 | --> $DIR/bad-interconversion.rs:32:39 | |
66 | | | |
67 | LL | / fn result_to_control_flow() -> ControlFlow<String> { | |
68 | LL | | ControlFlow::Continue(Err("hello")?) | |
69 | | | ^ this `?` produces `Result<Infallible, &str>`, which is incompatible with `ControlFlow<String>` | |
70 | LL | | | |
71 | LL | | } | |
72 | | |_- this function returns a `ControlFlow` | |
73 | | | |
74 | = help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `ControlFlow<String>` | |
17df50a5 XL |
75 | |
76 | error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow` | |
77 | --> $DIR/bad-interconversion.rs:37:12 | |
78 | | | |
79 | LL | / fn option_to_control_flow() -> ControlFlow<u64> { | |
80 | LL | | Some(3)?; | |
81 | | | ^ this `?` produces `Option<Infallible>`, which is incompatible with `ControlFlow<u64>` | |
82 | LL | | | |
83 | LL | | ControlFlow::Break(10) | |
84 | LL | | } | |
85 | | |_- this function returns a `ControlFlow` | |
86 | | | |
87 | = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `ControlFlow<u64>` | |
17df50a5 XL |
88 | |
89 | error[E0277]: the `?` operator in a function that returns `ControlFlow<B, _>` can only be used on other `ControlFlow<B, _>`s (with the same Break type) | |
90 | --> $DIR/bad-interconversion.rs:43:29 | |
91 | | | |
92 | LL | / fn control_flow_to_control_flow() -> ControlFlow<i64> { | |
93 | LL | | ControlFlow::Break(4_u8)?; | |
94 | | | ^ this `?` produces `ControlFlow<u8, Infallible>`, which is incompatible with `ControlFlow<i64>` | |
95 | LL | | | |
96 | LL | | ControlFlow::Continue(()) | |
97 | LL | | } | |
98 | | |_- this function returns a `ControlFlow` | |
99 | | | |
100 | = help: the trait `FromResidual<ControlFlow<u8, Infallible>>` is not implemented for `ControlFlow<i64>` | |
101 | = note: unlike `Result`, there's no `From`-conversion performed for `ControlFlow` | |
17df50a5 XL |
102 | |
103 | error: aborting due to 8 previous errors | |
104 | ||
105 | For more information about this error, try `rustc --explain E0277`. |