Closed
Description
#![feature(untagged_unions)]
#![allow(unused)]
#[allow(unions_with_drop_fields)]
union U {
x: (Vec<u8>, Vec<u8>),
y: Vec<u8>,
}
fn main() { unsafe {
let u = U { x: (Vec::new(), Vec::new()) };
let a = u.x.0;
let a = u.y; // This is incorrectly accepted despite u.y being "collaterally moved"
}}
When implementing move checking for unions I incorrectly assumed that moves automatically "propagate" to parent "loan paths", like in borrow checker, e.g.
let a = &mut u.x.0;
let a = &u.y; // This currently gives correct error due to u.y being "collaterally borrowed"
, this turns out to not be the case.
This case was missed in tests, so the error went unnoticed.
I have some quick fix, will submit tomorrow.