]> git.lizzy.rs Git - rust.git/blob - src/test/ui/try-block/try-block-bad-type.stderr
722b7a3b60a63443aaa0cb23f512129be621440f
[rust.git] / src / test / ui / try-block / try-block-bad-type.stderr
1 error[E0277]: `?` couldn't convert the error to `i32`
2   --> $DIR/try-block-bad-type.rs:7:16
3    |
4 LL |         Err("")?;
5    |                ^ the trait `std::convert::From<&str>` is not implemented for `i32`
6    |
7    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
8    = help: the following implementations were found:
9              <i32 as std::convert::From<bool>>
10              <i32 as std::convert::From<i16>>
11              <i32 as std::convert::From<i8>>
12              <i32 as std::convert::From<std::num::NonZeroI32>>
13            and 2 others
14    = note: required by `std::convert::From::from`
15
16 error[E0271]: type mismatch resolving `<std::result::Result<i32, i32> as std::ops::Try>::Ok == &str`
17   --> $DIR/try-block-bad-type.rs:12:9
18    |
19 LL |         ""
20    |         ^^ expected i32, found &str
21    |
22    = note:   expected type `i32`
23            found reference `&str`
24
25 error[E0271]: type mismatch resolving `<std::result::Result<i32, i32> as std::ops::Try>::Ok == ()`
26   --> $DIR/try-block-bad-type.rs:15:39
27    |
28 LL |     let res: Result<i32, i32> = try { };
29    |                                       ^ expected i32, found ()
30    |
31    = note:   expected type `i32`
32            found unit type `()`
33
34 error[E0277]: the trait bound `(): std::ops::Try` is not satisfied
35   --> $DIR/try-block-bad-type.rs:17:23
36    |
37 LL |     let res: () = try { };
38    |                       ^^^ the trait `std::ops::Try` is not implemented for `()`
39    |
40    = note: required by `std::ops::Try::from_ok`
41
42 error[E0277]: the trait bound `i32: std::ops::Try` is not satisfied
43   --> $DIR/try-block-bad-type.rs:19:24
44    |
45 LL |     let res: i32 = try { 5 };
46    |                        ^^^^^ the trait `std::ops::Try` is not implemented for `i32`
47    |
48    = note: required by `std::ops::Try::from_ok`
49
50 error: aborting due to 5 previous errors
51
52 Some errors have detailed explanations: E0271, E0277.
53 For more information about an error, try `rustc --explain E0271`.