]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/reassignment_immutable_fields_overlapping.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / reassignment_immutable_fields_overlapping.rs
1 // This should never be allowed -- `foo.a` and `foo.b` are
2 // overlapping, so since `x` is not `mut` we should not permit
3 // reassignment.
4
5 union Foo {
6     a: u32,
7     b: u32,
8 }
9
10 unsafe fn overlapping_fields() {
11     let x: Foo;
12     x.a = 1;  //~ ERROR
13     x.b = 22; //~ ERROR
14 }
15
16 fn main() { }