]> git.lizzy.rs Git - rust.git/blob - src/test/ui/try-block/try-block-bad-type.rs
try-back-block-type test: Use TryFromSliceError for From test
[rust.git] / src / test / ui / try-block / try-block-bad-type.rs
1 // compile-flags: --edition 2018
2
3 #![feature(try_blocks)]
4
5 pub fn main() {
6     let res: Result<u32, std::array::TryFromSliceError> = try {
7         Err("")?; //~ ERROR `?` couldn't convert the error
8         5
9     };
10
11     let res: Result<i32, i32> = try {
12         "" //~ ERROR type mismatch
13     };
14
15     let res: Result<i32, i32> = try { }; //~ ERROR type mismatch
16
17     let res: () = try { };
18     //~^ ERROR the trait bound `(): Try` is not satisfied
19     //~| ERROR the trait bound `(): Try` is not satisfied
20
21     let res: i32 = try { 5 }; //~ ERROR the trait bound `i32: Try` is not satisfied
22 }