2014-12-11 23:48:44 -06:00
|
|
|
// Check that coercions are propagated through match and if expressions.
|
|
|
|
|
2015-03-22 15:13:15 -05:00
|
|
|
//@ pretty-expanded FIXME #23616
|
|
|
|
|
2014-12-11 23:48:44 -06:00
|
|
|
pub fn main() {
|
2022-07-06 21:36:10 -05:00
|
|
|
let _: Box<[isize]> = if true {
|
|
|
|
let b: Box<_> = Box::new([1, 2, 3]);
|
|
|
|
b
|
|
|
|
} else {
|
|
|
|
let b: Box<_> = Box::new([1]);
|
|
|
|
b
|
|
|
|
};
|
2014-12-11 23:48:44 -06:00
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
let _: Box<[isize]> = match true {
|
2024-06-03 01:06:52 -05:00
|
|
|
true => {
|
|
|
|
let b: Box<_> = Box::new([1, 2, 3]);
|
|
|
|
b
|
|
|
|
}
|
|
|
|
false => {
|
|
|
|
let b: Box<_> = Box::new([1]);
|
|
|
|
b
|
|
|
|
}
|
2015-02-17 14:41:32 -06:00
|
|
|
};
|
2014-12-11 23:48:44 -06:00
|
|
|
|
|
|
|
// Check we don't get over-keen at propagating coercions in the case of casts.
|
|
|
|
let x = if true { 42 } else { 42u8 } as u16;
|
2024-06-03 01:06:52 -05:00
|
|
|
let x = match true {
|
|
|
|
true => 42,
|
|
|
|
false => 42u8,
|
|
|
|
} as u16;
|
2014-12-11 23:48:44 -06:00
|
|
|
}
|