// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(rustc_attrs)]
+#![feature(untagged_unions)]
use std::cell::{Cell, RefCell};
use std::panic;
}
}
-#[rustc_mir]
fn dynamic_init(a: &Allocator, c: bool) {
let _x;
if c {
}
}
-#[rustc_mir]
fn dynamic_drop(a: &Allocator, c: bool) {
let x = a.alloc();
if c {
};
}
-#[rustc_mir]
fn assignment2(a: &Allocator, c0: bool, c1: bool) {
let mut _v = a.alloc();
let mut _w = a.alloc();
}
}
-#[rustc_mir]
fn assignment1(a: &Allocator, c0: bool) {
let mut _v = a.alloc();
let mut _w = a.alloc();
_v = _w;
}
+#[allow(unions_with_drop_fields)]
+union Boxy<T> {
+ a: T,
+ b: T,
+}
+
+fn union1(a: &Allocator) {
+ unsafe {
+ let mut u = Boxy { a: a.alloc() };
+ u.b = a.alloc();
+ drop(u.a);
+ }
+}
+
fn run_test<F>(mut f: F)
where F: FnMut(&Allocator)
{
}
}
+fn run_test_nopanic<F>(mut f: F)
+ where F: FnMut(&Allocator)
+{
+ let first_alloc = Allocator::new(usize::MAX);
+ f(&first_alloc);
+}
+
fn main() {
run_test(|a| dynamic_init(a, false));
run_test(|a| dynamic_init(a, true));
run_test(|a| assignment1(a, false));
run_test(|a| assignment1(a, true));
+
+ run_test_nopanic(|a| union1(a));
}