- Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed
Labels
A-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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/.
Metadata
Metadata
Assignees
Labels
A-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.