diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/packed/issue-46152.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/ui/packed/issue-46152.rs b/src/test/ui/packed/issue-46152.rs new file mode 100644 index 000000000..fb1c9fb78 --- /dev/null +++ b/src/test/ui/packed/issue-46152.rs @@ -0,0 +1,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; +} |