2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2018-09-25 21:51:35 +00:00
|
|
|
#![allow(dead_code)]
|
|
|
|
#![allow(unused_variables)]
|
2017-12-26 09:41:56 +00:00
|
|
|
#![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;
|
|
|
|
}
|