]> git.proxmox.com Git - rustc.git/blame - src/test/ui/try-trait/bad-interconversion.stderr
New upstream version 1.58.1+dfsg1
[rustc.git] / src / test / ui / try-trait / bad-interconversion.stderr
CommitLineData
17df50a5
XL
1error[E0277]: `?` couldn't convert the error to `u8`
2 --> $DIR/bad-interconversion.rs:6:20
3 |
4LL | fn result_to_result() -> Result<u64, u8> {
5 | --------------- expected `u8` because of this
6LL | 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 implementations were found:
11 <u8 as From<NonZeroU8>>
12 <u8 as From<bool>>
13 = note: required because of the requirements on the impl of `FromResidual<Result<Infallible, i32>>` for `Result<u64, u8>`
17df50a5
XL
14
15error[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
17 |
18LL | / fn option_to_result() -> Result<u64, String> {
19LL | | Some(3)?;
20 | | ^ use `.ok_or(...)?` to provide an error compatible with `Result<u64, String>`
21LL | |
22LL | | Ok(10)
23LL | | }
24 | |_- this function returns a `Result`
25 |
26 = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<u64, String>`
17df50a5
XL
27
28error[E0277]: the `?` operator can only be used on `Result`s in a function that returns `Result`
29 --> $DIR/bad-interconversion.rs:17:31
30 |
31LL | / fn control_flow_to_result() -> Result<u64, String> {
32LL | | Ok(ControlFlow::Break(123)?)
33 | | ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Result<u64, String>`
34LL | |
35LL | | }
36 | |_- this function returns a `Result`
37 |
38 = help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Result<u64, String>`
17df50a5
XL
39
40error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option`
41 --> $DIR/bad-interconversion.rs:22:22
42 |
43LL | / fn result_to_option() -> Option<u16> {
44LL | | Some(Err("hello")?)
45 | | ^ use `.ok()?` if you want to discard the `Result<Infallible, &str>` error information
46LL | |
47LL | | }
48 | |_- this function returns an `Option`
49 |
50 = help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `Option<u16>`
17df50a5
XL
51
52error[E0277]: the `?` operator can only be used on `Option`s in a function that returns `Option`
53 --> $DIR/bad-interconversion.rs:27:33
54 |
55LL | / fn control_flow_to_option() -> Option<u64> {
56LL | | Some(ControlFlow::Break(123)?)
57 | | ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Option<u64>`
58LL | |
59LL | | }
60 | |_- this function returns an `Option`
61 |
62 = help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Option<u64>`
17df50a5
XL
63
64error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
65 --> $DIR/bad-interconversion.rs:32:39
66 |
67LL | / fn result_to_control_flow() -> ControlFlow<String> {
68LL | | ControlFlow::Continue(Err("hello")?)
69 | | ^ this `?` produces `Result<Infallible, &str>`, which is incompatible with `ControlFlow<String>`
70LL | |
71LL | | }
72 | |_- this function returns a `ControlFlow`
73 |
74 = help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `ControlFlow<String>`
17df50a5
XL
75
76error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
77 --> $DIR/bad-interconversion.rs:37:12
78 |
79LL | / fn option_to_control_flow() -> ControlFlow<u64> {
80LL | | Some(3)?;
81 | | ^ this `?` produces `Option<Infallible>`, which is incompatible with `ControlFlow<u64>`
82LL | |
83LL | | ControlFlow::Break(10)
84LL | | }
85 | |_- this function returns a `ControlFlow`
86 |
87 = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `ControlFlow<u64>`
17df50a5
XL
88
89error[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
91 |
92LL | / fn control_flow_to_control_flow() -> ControlFlow<i64> {
93LL | | ControlFlow::Break(4_u8)?;
94 | | ^ this `?` produces `ControlFlow<u8, Infallible>`, which is incompatible with `ControlFlow<i64>`
95LL | |
96LL | | ControlFlow::Continue(())
97LL | | }
98 | |_- this function returns a `ControlFlow`
99 |
100 = help: the trait `FromResidual<ControlFlow<u8, Infallible>>` is not implemented for `ControlFlow<i64>`
101 = note: unlike `Result`, there's no `From`-conversion performed for `ControlFlow`
17df50a5
XL
102
103error: aborting due to 8 previous errors
104
105For more information about this error, try `rustc --explain E0277`.