Closed
Description
#![feature(untagged_unions)]
union Test {
a: A,
b: B
}
#[derive(Debug)]
struct A(i32);
impl Drop for A {
fn drop(&mut self) { println!("A"); }
}
#[derive(Debug)]
struct B(f32);
impl Drop for B {
fn drop(&mut self) { println!("B"); }
}
fn main() {
let mut test = Test { a: A(3) };
println!("{:?}", unsafe { test.b });
unsafe { test.b = B(0.5); }
}
error: internal compiler error: /checkout/src/librustc_borrowck/borrowck/mir/elaborate_drops.rs:313: drop of untracked, uninitialized value bb8, lv (_1.1: B) (Parent(Some(mp1)))
--> <anon>:23:14
|
23 | unsafe { test.b = B(0.5); }
|
Full backtrace can be seen on the playground
https://play.rust-lang.org/?gist=bc93f5b222b09b31d3fd286cfc10858a&version=nightly&backtrace=2