Closed
Description
Code:
#![feature(untagged_unions)]
#![allow(unused)]
struct S;
struct Z;
impl Drop for S { fn drop(&mut self) { println!("S"); } }
impl Drop for Z { fn drop(&mut self) { println!("Z"); } }
#[allow(unions_with_drop_fields)]
union U {
s: S,
z: Z,
}
fn main() {
let u = U { s: S };
let s = unsafe { u.s }; // Move `u.s` out of `u`.
// Drop `s`.
// Drop `u`, noop.
}
Expected output:
S
Actual output:
S
Z
i.e. u.z
is dropped too for some reason.
This is probably caused by some union-specific logic missing from librustc_borrowck/borrowck/fragments.rs
and librustc_borrowck/borrowck/mir/
.