summaryrefslogtreecommitdiffstats
path: root/tests/ui/dst/dst-bad-coerce4.rs
blob: f63da60d281d7069e3fee802bd3cfba3368ae6cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Attempt to coerce from unsized to sized.

#![feature(unsized_tuple_coercion)]

struct Fat<T: ?Sized> {
    ptr: T
}

pub fn main() {
    // With a vec of isizes.
    let f1: &Fat<[isize]> = &Fat { ptr: [1, 2, 3] };
    let f2: &Fat<[isize; 3]> = f1;
    //~^ ERROR mismatched types
    //~| expected array `[isize; 3]`, found slice `[isize]`
    //~| expected reference `&Fat<[isize; 3]>`
    //~| found reference `&Fat<[isize]>`

    // Tuple with a vec of isizes.
    let f1: &([isize],) = &([1, 2, 3],);
    let f2: &([isize; 3],) = f1;
    //~^ ERROR mismatched types
    //~| expected array `[isize; 3]`, found slice `[isize]`
    //~| expected reference `&([isize; 3],)`
    //~| found reference `&([isize],)`
}