]> git.lizzy.rs Git - rust.git/blob - tests/ui/try-block/try-block-bad-type.stderr
Rollup merge of #103702 - WaffleLapkin:lift-sized-bounds-from-pointer-methods-where...
[rust.git] / tests / ui / try-block / try-block-bad-type.stderr
1 error[E0277]: `?` couldn't convert the error to `TryFromSliceError`
2   --> $DIR/try-block-bad-type.rs:7:16
3    |
4 LL |         Err("")?;
5    |                ^ the trait `From<&str>` is not implemented for `TryFromSliceError`
6    |
7    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
8    = help: the trait `From<Infallible>` is implemented for `TryFromSliceError`
9    = note: required for `Result<u32, TryFromSliceError>` to implement `FromResidual<Result<Infallible, &str>>`
10
11 error[E0271]: type mismatch resolving `<Result<i32, i32> as Try>::Output == &str`
12   --> $DIR/try-block-bad-type.rs:12:9
13    |
14 LL |         ""
15    |         ^^ expected `i32`, found `&str`
16
17 error[E0271]: type mismatch resolving `<Result<i32, i32> as Try>::Output == ()`
18   --> $DIR/try-block-bad-type.rs:15:39
19    |
20 LL |     let res: Result<i32, i32> = try { };
21    |                                       ^ expected `i32`, found `()`
22
23 error[E0277]: a `try` block must return `Result` or `Option` (or another type that implements `Try`)
24   --> $DIR/try-block-bad-type.rs:17:25
25    |
26 LL |     let res: () = try { };
27    |                         ^ could not wrap the final value of the block as `()` doesn't implement `Try`
28    |
29    = help: the trait `Try` is not implemented for `()`
30
31 error[E0277]: a `try` block must return `Result` or `Option` (or another type that implements `Try`)
32   --> $DIR/try-block-bad-type.rs:20:26
33    |
34 LL |     let res: i32 = try { 5 };
35    |                          ^ could not wrap the final value of the block as `i32` doesn't implement `Try`
36    |
37    = help: the trait `Try` is not implemented for `i32`
38
39 error: aborting due to 5 previous errors
40
41 Some errors have detailed explanations: E0271, E0277.
42 For more information about an error, try `rustc --explain E0271`.