1 // A version of coerce-expect-unsized that uses type ascription.
2 // Doesn't work so far, but supposed to work eventually
4 #![feature(box_syntax, type_ascription)]
9 let _ = box { [1, 2, 3] }: Box<[i32]>; //~ ERROR mismatched types
10 let _ = box if true { [1, 2, 3] } else { [1, 3, 4] }: Box<[i32]>; //~ ERROR mismatched types
11 let _ = box match true { true => [1, 2, 3], false => [1, 3, 4] }: Box<[i32]>;
12 //~^ ERROR mismatched types
13 let _ = box { |x| (x as u8) }: Box<dyn Fn(i32) -> _>; //~ ERROR mismatched types
14 let _ = box if true { false } else { true }: Box<dyn Debug>; //~ ERROR mismatched types
15 let _ = box match true { true => 'a', false => 'b' }: Box<dyn Debug>; //~ ERROR mismatched types
17 let _ = &{ [1, 2, 3] }: &[i32]; //~ ERROR mismatched types
18 let _ = &if true { [1, 2, 3] } else { [1, 3, 4] }: &[i32]; //~ ERROR mismatched types
19 let _ = &match true { true => [1, 2, 3], false => [1, 3, 4] }: &[i32];
20 //~^ ERROR mismatched types
21 let _ = &{ |x| (x as u8) }: &dyn Fn(i32) -> _; //~ ERROR mismatched types
22 let _ = &if true { false } else { true }: &dyn Debug; //~ ERROR mismatched types
23 let _ = &match true { true => 'a', false => 'b' }: &dyn Debug; //~ ERROR mismatched types
25 let _ = Box::new([1, 2, 3]): Box<[i32]>; //~ ERROR mismatched types
26 let _ = Box::new(|x| (x as u8)): Box<dyn Fn(i32) -> _>; //~ ERROR mismatched types
29 Box::new(|x| (x as u8)),
30 box |x| (x as i16 as u8),
31 ]: Vec<Box<dyn Fn(i32) -> _>>;