]> git.lizzy.rs Git - rust.git/blob - tests/run-pass-valgrind/coerce-match.rs
Rollup merge of #107780 - compiler-errors:instantiate-binder, r=lcnr
[rust.git] / tests / run-pass-valgrind / coerce-match.rs
1 // Check that coercions are propagated through match and if expressions.
2
3 // pretty-expanded FIXME #23616
4
5 pub fn main() {
6     let _: Box<[isize]> = if true {
7         let b: Box<_> = Box::new([1, 2, 3]);
8         b
9     } else {
10         let b: Box<_> = Box::new([1]);
11         b
12     };
13
14     let _: Box<[isize]> = match true {
15         true => { let b: Box<_> = Box::new([1, 2, 3]); b }
16         false => { let b: Box<_> = Box::new([1]); b }
17     };
18
19     // Check we don't get over-keen at propagating coercions in the case of casts.
20     let x = if true { 42 } else { 42u8 } as u16;
21     let x = match true { true => 42, false => 42u8 } as u16;
22 }