|
| 1 | +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT |
| 2 | +// file at the top-level directory of this distribution and at |
| 3 | +// http://rust-lang.org/COPYRIGHT. |
| 4 | +// |
| 5 | +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 6 | +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 7 | +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 8 | +// option. This file may not be copied, modified, or distributed |
| 9 | +// except according to those terms. |
| 10 | + |
| 11 | +// A version of coerce-expect-unsized that uses type ascription. |
| 12 | +// Doesn't work so far, but supposed to work eventually |
| 13 | + |
| 14 | +#![feature(box_syntax, type_ascription)] |
| 15 | + |
| 16 | +use std::fmt::Debug; |
| 17 | + |
| 18 | +pub fn main() { |
| 19 | + let _ = box { [1, 2, 3] }: Box<[i32]>; //~ ERROR mismatched types |
| 20 | + let _ = box if true { [1, 2, 3] } else { [1, 3, 4] }: Box<[i32]>; //~ ERROR mismatched types |
| 21 | + let _ = box match true { true => [1, 2, 3], false => [1, 3, 4] }: Box<[i32]>; |
| 22 | + //~^ ERROR mismatched types |
| 23 | + let _ = box { |x| (x as u8) }: Box<Fn(i32) -> _>; //~ ERROR mismatched types |
| 24 | + let _ = box if true { false } else { true }: Box<Debug>; //~ ERROR mismatched types |
| 25 | + let _ = box match true { true => 'a', false => 'b' }: Box<Debug>; //~ ERROR mismatched types |
| 26 | + |
| 27 | + let _ = &{ [1, 2, 3] }: &[i32]; //~ ERROR mismatched types |
| 28 | + let _ = &if true { [1, 2, 3] } else { [1, 3, 4] }: &[i32]; //~ ERROR mismatched types |
| 29 | + let _ = &match true { true => [1, 2, 3], false => [1, 3, 4] }: &[i32]; |
| 30 | + //~^ ERROR mismatched types |
| 31 | + let _ = &{ |x| (x as u8) }: &Fn(i32) -> _; //~ ERROR mismatched types |
| 32 | + let _ = &if true { false } else { true }: &Debug; //~ ERROR mismatched types |
| 33 | + let _ = &match true { true => 'a', false => 'b' }: &Debug; //~ ERROR mismatched types |
| 34 | + |
| 35 | + let _ = Box::new([1, 2, 3]): Box<[i32]>; //~ ERROR mismatched types |
| 36 | + let _ = Box::new(|x| (x as u8)): Box<Fn(i32) -> _>; //~ ERROR mismatched types |
| 37 | + |
| 38 | + let _ = vec![ |
| 39 | + Box::new(|x| (x as u8)), |
| 40 | + box |x| (x as i16 as u8), |
| 41 | + ]: Vec<Box<Fn(i32) -> _>>; |
| 42 | +} |
0 commit comments