mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-05 13:13:40 +00:00
17 lines
293 B
Rust
17 lines
293 B
Rust
|
// This should never be allowed -- `foo.a` and `foo.b` are
|
||
|
// overlapping, so since `x` is not `mut` we should not permit
|
||
|
// reassignment.
|
||
|
|
||
|
union Foo {
|
||
|
a: u32,
|
||
|
b: u32,
|
||
|
}
|
||
|
|
||
|
unsafe fn overlapping_fields() {
|
||
|
let x: Foo;
|
||
|
x.a = 1; //~ ERROR
|
||
|
x.b = 22; //~ ERROR
|
||
|
}
|
||
|
|
||
|
fn main() { }
|