]> git.lizzy.rs Git - rust.git/blob - src/test/ui/try-trait/bad-interconversion.stderr
implement IsZero for Saturating and Wrapping
[rust.git] / src / test / ui / try-trait / bad-interconversion.stderr
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 other types implement trait `From<T>`:
11              <f32 as From<i16>>
12              <f32 as From<i8>>
13              <f32 as From<u16>>
14              <f32 as From<u8>>
15              <f64 as From<f32>>
16              <f64 as From<i16>>
17              <f64 as From<i32>>
18              <f64 as From<i8>>
19            and 67 others
20    = note: required for `Result<u64, u8>` to implement `FromResidual<Result<Infallible, i32>>`
21
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
24    |
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`
32    |
33    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<u64, String>`
34    = help: the following other types implement trait `FromResidual<R>`:
35              <Result<T, F> as FromResidual<Result<Infallible, E>>>
36              <Result<T, F> as FromResidual<Yeet<E>>>
37
38 error[E0277]: the `?` operator can only be used on `Result`s in a function that returns `Result`
39   --> $DIR/bad-interconversion.rs:17:31
40    |
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`
47    |
48    = help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Result<u64, String>`
49    = help: the following other types implement trait `FromResidual<R>`:
50              <Result<T, F> as FromResidual<Result<Infallible, E>>>
51              <Result<T, F> as FromResidual<Yeet<E>>>
52
53 error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option`
54   --> $DIR/bad-interconversion.rs:22:22
55    |
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`
62    |
63    = help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `Option<u16>`
64    = help: the following other types implement trait `FromResidual<R>`:
65              <Option<T> as FromResidual<Yeet<()>>>
66              <Option<T> as FromResidual>
67
68 error[E0277]: the `?` operator can only be used on `Option`s in a function that returns `Option`
69   --> $DIR/bad-interconversion.rs:27:33
70    |
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`
77    |
78    = help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Option<u64>`
79    = help: the following other types implement trait `FromResidual<R>`:
80              <Option<T> as FromResidual<Yeet<()>>>
81              <Option<T> as FromResidual>
82
83 error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
84   --> $DIR/bad-interconversion.rs:32:39
85    |
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`
92    |
93    = help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `ControlFlow<String>`
94    = help: the trait `FromResidual` is implemented for `ControlFlow<B, C>`
95
96 error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
97   --> $DIR/bad-interconversion.rs:37:12
98    |
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`
106    |
107    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `ControlFlow<u64>`
108    = help: the trait `FromResidual` is implemented for `ControlFlow<B, C>`
109
110 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)
111   --> $DIR/bad-interconversion.rs:43:29
112    |
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`
120    |
121    = help: the trait `FromResidual<ControlFlow<u8, Infallible>>` is not implemented for `ControlFlow<i64>`
122    = note: unlike `Result`, there's no `From`-conversion performed for `ControlFlow`
123    = help: the trait `FromResidual` is implemented for `ControlFlow<B, C>`
124
125 error: aborting due to 8 previous errors
126
127 For more information about this error, try `rustc --explain E0277`.