]> git.lizzy.rs Git - rust.git/blob - src/test/ui/try-trait/bad-interconversion.stderr
Auto merge of #101514 - nvzqz:nvzqz/stabilize-nonzero-bits, r=thomcc
[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 68 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    | -------------------------------------------- this function returns a `Result`
27 LL |     Some(3)?;
28    |            ^ use `.ok_or(...)?` to provide an error compatible with `Result<u64, String>`
29    |
30    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<u64, String>`
31    = help: the following other types implement trait `FromResidual<R>`:
32              <Result<T, F> as FromResidual<Result<Infallible, E>>>
33              <Result<T, F> as FromResidual<Yeet<E>>>
34
35 error[E0277]: the `?` operator can only be used on `Result`s in a function that returns `Result`
36   --> $DIR/bad-interconversion.rs:17:31
37    |
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>`
42    |
43    = help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Result<u64, String>`
44    = help: the following other types implement trait `FromResidual<R>`:
45              <Result<T, F> as FromResidual<Result<Infallible, E>>>
46              <Result<T, F> as FromResidual<Yeet<E>>>
47
48 error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option`
49   --> $DIR/bad-interconversion.rs:22:22
50    |
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
55    |
56    = help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `Option<u16>`
57    = help: the following other types implement trait `FromResidual<R>`:
58              <Option<T> as FromResidual<Yeet<()>>>
59              <Option<T> as FromResidual>
60
61 error[E0277]: the `?` operator can only be used on `Option`s in a function that returns `Option`
62   --> $DIR/bad-interconversion.rs:27:33
63    |
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>`
68    |
69    = help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Option<u64>`
70    = help: the following other types implement trait `FromResidual<R>`:
71              <Option<T> as FromResidual<Yeet<()>>>
72              <Option<T> as FromResidual>
73
74 error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
75   --> $DIR/bad-interconversion.rs:32:39
76    |
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>`
81    |
82    = help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `ControlFlow<String>`
83    = help: the trait `FromResidual` is implemented for `ControlFlow<B, C>`
84
85 error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
86   --> $DIR/bad-interconversion.rs:37:12
87    |
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>`
92    |
93    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `ControlFlow<u64>`
94    = help: the trait `FromResidual` is implemented for `ControlFlow<B, C>`
95
96 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)
97   --> $DIR/bad-interconversion.rs:43:29
98    |
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>`
103    |
104    = help: the trait `FromResidual<ControlFlow<u8, Infallible>>` is not implemented for `ControlFlow<i64>`
105    = note: unlike `Result`, there's no `From`-conversion performed for `ControlFlow`
106    = help: the trait `FromResidual` is implemented for `ControlFlow<B, C>`
107
108 error: aborting due to 8 previous errors
109
110 For more information about this error, try `rustc --explain E0277`.