]> git.lizzy.rs Git - rust.git/blob - tests/ui/type/type-check/coerce-result-return-value-2.stderr
Rollup merge of #106856 - vadorovsky:fix-atomic-annotations, r=joshtriplett
[rust.git] / tests / ui / type / type-check / coerce-result-return-value-2.stderr
1 error[E0308]: mismatched types
2   --> $DIR/coerce-result-return-value-2.rs:8:17
3    |
4 LL | fn foo4(x: Result<(), A>) -> Result<(), B> {
5    |                              ------------- expected `Result<(), B>` because of return type
6 LL |     match true {
7 LL |         true => x,
8    |                 ^ expected struct `B`, found struct `A`
9    |
10    = note: expected enum `Result<_, B>`
11               found enum `Result<_, A>`
12 help: use `?` to coerce and return an appropriate `Err`, and wrap the resulting value in `Ok` so the expression remains of type `Result`
13    |
14 LL |         true => Ok(x?),
15    |                 +++ ++
16
17 error[E0308]: mismatched types
18   --> $DIR/coerce-result-return-value-2.rs:14:24
19    |
20 LL | fn foo5(x: Result<(), A>) -> Result<(), B> {
21    |                              ------------- expected `Result<(), B>` because of return type
22 LL |     match true {
23 LL |         true => return x,
24    |                        ^ expected struct `B`, found struct `A`
25    |
26    = note: expected enum `Result<_, B>`
27               found enum `Result<_, A>`
28 help: use `?` to coerce and return an appropriate `Err`, and wrap the resulting value in `Ok` so the expression remains of type `Result`
29    |
30 LL |         true => return Ok(x?),
31    |                        +++ ++
32
33 error[E0308]: mismatched types
34   --> $DIR/coerce-result-return-value-2.rs:21:28
35    |
36 LL |       let _: Result<(), B> = {
37    |  ____________________________^
38 LL | |         Err(A);
39 LL | |     };
40    | |_____^ expected enum `Result`, found `()`
41    |
42    = note:   expected enum `Result<(), B>`
43            found unit type `()`
44
45 error: aborting due to 3 previous errors
46
47 For more information about this error, try `rustc --explain E0308`.