]> git.lizzy.rs Git - rust.git/blob - tests/ui/packed-struct/packed-struct-generic-transmute.rs
Rollup merge of #106113 - krasimirgg:llvm-16-ext-tyid, r=nikic
[rust.git] / tests / ui / packed-struct / packed-struct-generic-transmute.rs
1 // This assumes the packed and non-packed structs are different sizes.
2
3 // the error points to the start of the file, not the line with the
4 // transmute
5
6 // error-pattern: cannot transmute between types of different sizes, or dependently-sized types
7
8 use std::mem;
9
10 #[repr(packed)]
11 struct Foo<T,S> {
12     bar: T,
13     baz: S
14 }
15
16 struct Oof<T, S> {
17     rab: T,
18     zab: S
19 }
20
21 fn main() {
22     let foo = Foo { bar: [1u8, 2, 3, 4, 5], baz: 10i32 };
23     unsafe {
24         let oof: Oof<[u8; 5], i32> = mem::transmute(foo);
25         println!("{:?} {:?}", &oof.rab[..], oof.zab);
26     }
27 }