summaryrefslogtreecommitdiffstats
path: root/tests/ui/packed/issue-46152.rs
blob: fb1c9fb78f3619d4bcce4b160ead135fe79ec5ff (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
// run-pass
#![allow(dead_code)]
#![allow(unused_variables)]
#![feature(unsize, coerce_unsized)]

#[repr(packed)]
struct UnalignedPtr<'a, T: ?Sized>
    where T: 'a,
{
    data: &'a T,
}

fn main() {

    impl<'a, T, U> std::ops::CoerceUnsized<UnalignedPtr<'a, U>> for UnalignedPtr<'a, T>
        where
        T: std::marker::Unsize<U> + ?Sized,
        U: ?Sized,
    { }

    let arr = [1, 2, 3];
    let arr_unaligned: UnalignedPtr<[i32; 3]> = UnalignedPtr { data: &arr };
    let arr_unaligned: UnalignedPtr<[i32]> = arr_unaligned;
}