Description
#![allow(unused)]
#[derive(Clone, Copy, Default)]
struct S {
a: u8,
b: u8,
}
#[derive(Clone, Copy, Default)]
struct Z {
c: u8,
d: u8,
}
union U {
s: S,
z: Z,
}
fn main() { unsafe {
let mut u = U { s: Default::default() };
let mref = &mut u.s.a;
let err = &u.z.c; // This line compiles, but it certainly shouldn't ...
drop(mref); // ... (at least if `mref` is used after `err`)
}}
"Cousins" of borrowed union sub-fields (and their further children) are not marked as borrowed.
The same bug should happen with move checking as well, but I haven't made an example yet.
Metadata
Metadata
Assignees
Labels
Area: The borrow checkerCategory: This is a bug.Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the language team, which will review and decide on the PR/issue.Bugs fixed, but only when NLL is enabled.