blob: c1a7d55dda0a2d16ecb521b2477648933b319068 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#![deny(safe_packed_borrows)]
// Refs: https://github.com/rust-lang/rust/issues/46043
#[repr(packed)]
struct A {
field: u32,
}
#[repr(packed(2))]
struct B {
field: u32,
}
fn main() {
let a = A { field: 1 };
&a.field; //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
let b = B { field: 1 };
&b.field; //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
}
|