]> git.lizzy.rs Git - rust.git/blob - src/test/ui/try-block/try-block-bad-type.rs
Rollup merge of #99479 - Enselic:import-can-be-without-id, r=camelid
[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 a `try` block must return `Result` or `Option`
19
20     let res: i32 = try { 5 }; //~ ERROR a `try` block must return `Result` or `Option`
21 }