@@ -22,13 +22,10 @@ LL | Ok(Err(123_i32)?)
2222error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result`
2323 --> $DIR/bad-interconversion.rs:11:12
2424 |
25- LL | / fn option_to_result() -> Result<u64, String> {
26- LL | | Some(3)?;
27- | | ^ use `.ok_or(...)?` to provide an error compatible with `Result<u64, String>`
28- LL | |
29- LL | | Ok(10)
30- LL | | }
31- | |_- this function returns a `Result`
25+ LL | fn option_to_result() -> Result<u64, String> {
26+ | -------------------------------------------- this function returns a `Result`
27+ LL | Some(3)?;
28+ | ^ use `.ok_or(...)?` to provide an error compatible with `Result<u64, String>`
3229 |
3330 = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<u64, String>`
3431 = help: the following other types implement trait `FromResidual<R>`:
@@ -38,12 +35,10 @@ LL | | }
3835error[E0277]: the `?` operator can only be used on `Result`s in a function that returns `Result`
3936 --> $DIR/bad-interconversion.rs:17:31
4037 |
41- LL | / fn control_flow_to_result() -> Result<u64, String> {
42- LL | | Ok(ControlFlow::Break(123)?)
43- | | ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Result<u64, String>`
44- LL | |
45- LL | | }
46- | |_- this function returns a `Result`
38+ LL | fn control_flow_to_result() -> Result<u64, String> {
39+ | -------------------------------------------------- this function returns a `Result`
40+ LL | Ok(ControlFlow::Break(123)?)
41+ | ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Result<u64, String>`
4742 |
4843 = help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Result<u64, String>`
4944 = help: the following other types implement trait `FromResidual<R>`:
@@ -53,12 +48,10 @@ LL | | }
5348error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option`
5449 --> $DIR/bad-interconversion.rs:22:22
5550 |
56- LL | / fn result_to_option() -> Option<u16> {
57- LL | | Some(Err("hello")?)
58- | | ^ use `.ok()?` if you want to discard the `Result<Infallible, &str>` error information
59- LL | |
60- LL | | }
61- | |_- this function returns an `Option`
51+ LL | fn result_to_option() -> Option<u16> {
52+ | ------------------------------------ this function returns an `Option`
53+ LL | Some(Err("hello")?)
54+ | ^ use `.ok()?` if you want to discard the `Result<Infallible, &str>` error information
6255 |
6356 = help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `Option<u16>`
6457 = help: the following other types implement trait `FromResidual<R>`:
@@ -68,12 +61,10 @@ LL | | }
6861error[E0277]: the `?` operator can only be used on `Option`s in a function that returns `Option`
6962 --> $DIR/bad-interconversion.rs:27:33
7063 |
71- LL | / fn control_flow_to_option() -> Option<u64> {
72- LL | | Some(ControlFlow::Break(123)?)
73- | | ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Option<u64>`
74- LL | |
75- LL | | }
76- | |_- this function returns an `Option`
64+ LL | fn control_flow_to_option() -> Option<u64> {
65+ | ------------------------------------------ this function returns an `Option`
66+ LL | Some(ControlFlow::Break(123)?)
67+ | ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Option<u64>`
7768 |
7869 = help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Option<u64>`
7970 = help: the following other types implement trait `FromResidual<R>`:
@@ -83,40 +74,32 @@ LL | | }
8374error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
8475 --> $DIR/bad-interconversion.rs:32:39
8576 |
86- LL | / fn result_to_control_flow() -> ControlFlow<String> {
87- LL | | ControlFlow::Continue(Err("hello")?)
88- | | ^ this `?` produces `Result<Infallible, &str>`, which is incompatible with `ControlFlow<String>`
89- LL | |
90- LL | | }
91- | |_- this function returns a `ControlFlow`
77+ LL | fn result_to_control_flow() -> ControlFlow<String> {
78+ | -------------------------------------------------- this function returns a `ControlFlow`
79+ LL | ControlFlow::Continue(Err("hello")?)
80+ | ^ this `?` produces `Result<Infallible, &str>`, which is incompatible with `ControlFlow<String>`
9281 |
9382 = help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `ControlFlow<String>`
9483 = help: the trait `FromResidual` is implemented for `ControlFlow<B, C>`
9584
9685error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
9786 --> $DIR/bad-interconversion.rs:37:12
9887 |
99- LL | / fn option_to_control_flow() -> ControlFlow<u64> {
100- LL | | Some(3)?;
101- | | ^ this `?` produces `Option<Infallible>`, which is incompatible with `ControlFlow<u64>`
102- LL | |
103- LL | | ControlFlow::Break(10)
104- LL | | }
105- | |_- this function returns a `ControlFlow`
88+ LL | fn option_to_control_flow() -> ControlFlow<u64> {
89+ | ----------------------------------------------- this function returns a `ControlFlow`
90+ LL | Some(3)?;
91+ | ^ this `?` produces `Option<Infallible>`, which is incompatible with `ControlFlow<u64>`
10692 |
10793 = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `ControlFlow<u64>`
10894 = help: the trait `FromResidual` is implemented for `ControlFlow<B, C>`
10995
11096error[E0277]: the `?` operator in a function that returns `ControlFlow<B, _>` can only be used on other `ControlFlow<B, _>`s (with the same Break type)
11197 --> $DIR/bad-interconversion.rs:43:29
11298 |
113- LL | / fn control_flow_to_control_flow() -> ControlFlow<i64> {
114- LL | | ControlFlow::Break(4_u8)?;
115- | | ^ this `?` produces `ControlFlow<u8, Infallible>`, which is incompatible with `ControlFlow<i64>`
116- LL | |
117- LL | | ControlFlow::Continue(())
118- LL | | }
119- | |_- this function returns a `ControlFlow`
99+ LL | fn control_flow_to_control_flow() -> ControlFlow<i64> {
100+ | ----------------------------------------------------- this function returns a `ControlFlow`
101+ LL | ControlFlow::Break(4_u8)?;
102+ | ^ this `?` produces `ControlFlow<u8, Infallible>`, which is incompatible with `ControlFlow<i64>`
120103 |
121104 = help: the trait `FromResidual<ControlFlow<u8, Infallible>>` is not implemented for `ControlFlow<i64>`
122105 = note: unlike `Result`, there's no `From`-conversion performed for `ControlFlow`
0 commit comments