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<bool>`:
20 = note: required because of the requirements on the impl of `FromResidual<Result<Infallible, i32>>` for `Result<u64, u8>`
22 error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result`
23 --> $DIR/bad-interconversion.rs:11:12
25 LL | / fn option_to_result() -> Result<u64, String> {
27 | | ^ use `.ok_or(...)?` to provide an error compatible with `Result<u64, String>`
31 | |_- this function returns a `Result`
33 = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<u64, String>`
34 = help: the trait `FromResidual<Result<Infallible, E>>` is implemented for `Result<T, F>`
36 error[E0277]: the `?` operator can only be used on `Result`s in a function that returns `Result`
37 --> $DIR/bad-interconversion.rs:17:31
39 LL | / fn control_flow_to_result() -> Result<u64, String> {
40 LL | | Ok(ControlFlow::Break(123)?)
41 | | ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Result<u64, String>`
44 | |_- this function returns a `Result`
46 = help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Result<u64, String>`
47 = help: the trait `FromResidual<Result<Infallible, E>>` is implemented for `Result<T, F>`
49 error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option`
50 --> $DIR/bad-interconversion.rs:22:22
52 LL | / fn result_to_option() -> Option<u16> {
53 LL | | Some(Err("hello")?)
54 | | ^ use `.ok()?` if you want to discard the `Result<Infallible, &str>` error information
57 | |_- this function returns an `Option`
59 = help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `Option<u16>`
60 = help: the trait `FromResidual` is implemented for `Option<T>`
62 error[E0277]: the `?` operator can only be used on `Option`s in a function that returns `Option`
63 --> $DIR/bad-interconversion.rs:27:33
65 LL | / fn control_flow_to_option() -> Option<u64> {
66 LL | | Some(ControlFlow::Break(123)?)
67 | | ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Option<u64>`
70 | |_- this function returns an `Option`
72 = help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Option<u64>`
73 = help: the trait `FromResidual` is implemented for `Option<T>`
75 error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
76 --> $DIR/bad-interconversion.rs:32:39
78 LL | / fn result_to_control_flow() -> ControlFlow<String> {
79 LL | | ControlFlow::Continue(Err("hello")?)
80 | | ^ this `?` produces `Result<Infallible, &str>`, which is incompatible with `ControlFlow<String>`
83 | |_- this function returns a `ControlFlow`
85 = help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `ControlFlow<String>`
86 = help: the trait `FromResidual` is implemented for `ControlFlow<B, C>`
88 error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
89 --> $DIR/bad-interconversion.rs:37:12
91 LL | / fn option_to_control_flow() -> ControlFlow<u64> {
93 | | ^ this `?` produces `Option<Infallible>`, which is incompatible with `ControlFlow<u64>`
95 LL | | ControlFlow::Break(10)
97 | |_- this function returns a `ControlFlow`
99 = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `ControlFlow<u64>`
100 = help: the trait `FromResidual` is implemented for `ControlFlow<B, C>`
102 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)
103 --> $DIR/bad-interconversion.rs:43:29
105 LL | / fn control_flow_to_control_flow() -> ControlFlow<i64> {
106 LL | | ControlFlow::Break(4_u8)?;
107 | | ^ this `?` produces `ControlFlow<u8, Infallible>`, which is incompatible with `ControlFlow<i64>`
109 LL | | ControlFlow::Continue(())
111 | |_- this function returns a `ControlFlow`
113 = help: the trait `FromResidual<ControlFlow<u8, Infallible>>` is not implemented for `ControlFlow<i64>`
114 = note: unlike `Result`, there's no `From`-conversion performed for `ControlFlow`
115 = help: the trait `FromResidual` is implemented for `ControlFlow<B, C>`
117 error: aborting due to 8 previous errors
119 For more information about this error, try `rustc --explain E0277`.