1 error[E0277]: `?` couldn't convert the error to `u8`
2 --> $DIR/bad-interconversion.rs:6:20
4 LL | fn result_to_result() -> Result<u64, u8> {
5 | --------------- expected `u8` because of this
7 | ^ the trait `From<i32>` is not implemented for `u8`
9 = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
10 = help: the following other types implement trait `From<T>`:
11 <u8 as From<NonZeroU8>>
13 = note: required for `Result<u64, u8>` to implement `FromResidual<Result<Infallible, i32>>`
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
18 LL | fn option_to_result() -> Result<u64, String> {
19 | -------------------------------------------- this function returns a `Result`
21 | ^ use `.ok_or(...)?` to provide an error compatible with `Result<u64, String>`
23 = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<u64, String>`
24 = help: the following other types implement trait `FromResidual<R>`:
25 <Result<T, F> as FromResidual<Result<Infallible, E>>>
26 <Result<T, F> as FromResidual<Yeet<E>>>
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
31 LL | fn control_flow_to_result() -> Result<u64, String> {
32 | -------------------------------------------------- this function returns a `Result`
33 LL | Ok(ControlFlow::Break(123)?)
34 | ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Result<u64, String>`
36 = help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Result<u64, String>`
37 = help: the following other types implement trait `FromResidual<R>`:
38 <Result<T, F> as FromResidual<Result<Infallible, E>>>
39 <Result<T, F> as FromResidual<Yeet<E>>>
41 error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option`
42 --> $DIR/bad-interconversion.rs:22:22
44 LL | fn result_to_option() -> Option<u16> {
45 | ------------------------------------ this function returns an `Option`
46 LL | Some(Err("hello")?)
47 | ^ use `.ok()?` if you want to discard the `Result<Infallible, &str>` error information
49 = help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `Option<u16>`
50 = help: the following other types implement trait `FromResidual<R>`:
51 <Option<T> as FromResidual<Yeet<()>>>
52 <Option<T> as FromResidual>
54 error[E0277]: the `?` operator can only be used on `Option`s in a function that returns `Option`
55 --> $DIR/bad-interconversion.rs:27:33
57 LL | fn control_flow_to_option() -> Option<u64> {
58 | ------------------------------------------ this function returns an `Option`
59 LL | Some(ControlFlow::Break(123)?)
60 | ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Option<u64>`
62 = help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Option<u64>`
63 = help: the following other types implement trait `FromResidual<R>`:
64 <Option<T> as FromResidual<Yeet<()>>>
65 <Option<T> as FromResidual>
67 error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
68 --> $DIR/bad-interconversion.rs:32:39
70 LL | fn result_to_control_flow() -> ControlFlow<String> {
71 | -------------------------------------------------- this function returns a `ControlFlow`
72 LL | ControlFlow::Continue(Err("hello")?)
73 | ^ this `?` produces `Result<Infallible, &str>`, which is incompatible with `ControlFlow<String>`
75 = help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `ControlFlow<String>`
76 = help: the trait `FromResidual` is implemented for `ControlFlow<B, C>`
78 error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
79 --> $DIR/bad-interconversion.rs:37:12
81 LL | fn option_to_control_flow() -> ControlFlow<u64> {
82 | ----------------------------------------------- this function returns a `ControlFlow`
84 | ^ this `?` produces `Option<Infallible>`, which is incompatible with `ControlFlow<u64>`
86 = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `ControlFlow<u64>`
87 = help: the trait `FromResidual` is implemented for `ControlFlow<B, C>`
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
92 LL | fn control_flow_to_control_flow() -> ControlFlow<i64> {
93 | ----------------------------------------------------- this function returns a `ControlFlow`
94 LL | ControlFlow::Break(4_u8)?;
95 | ^ this `?` produces `ControlFlow<u8, Infallible>`, which is incompatible with `ControlFlow<i64>`
97 = help: the trait `FromResidual<ControlFlow<u8, Infallible>>` is not implemented for `ControlFlow<i64>`
98 = note: unlike `Result`, there's no `From`-conversion performed for `ControlFlow`
99 = help: the trait `FromResidual` is implemented for `ControlFlow<B, C>`
101 error: aborting due to 8 previous errors
103 For more information about this error, try `rustc --explain E0277`.