Skip to content

Commit

Permalink
Fix additional run-pass tests for no drop in union
Browse files Browse the repository at this point in the history
  • Loading branch information
bluss committed Jan 13, 2019
1 parent 0950bdf commit f4b2d71
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/test/run-pass/drop/dynamic-drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#![feature(slice_patterns)]

use std::cell::{Cell, RefCell};
use std::mem::ManuallyDrop;
use std::ops::Generator;
use std::panic;
use std::usize;
Expand Down Expand Up @@ -139,17 +140,16 @@ fn assignment1(a: &Allocator, c0: bool) {
_v = _w;
}

#[allow(unions_with_drop_fields)]
union Boxy<T> {
a: T,
b: T,
a: ManuallyDrop<T>,
b: ManuallyDrop<T>,
}

fn union1(a: &Allocator) {
unsafe {
let mut u = Boxy { a: a.alloc() };
u.b = a.alloc();
drop(u.a);
let mut u = Boxy { a: ManuallyDrop::new(a.alloc()) };
*u.b = a.alloc(); // drops first alloc
drop(ManuallyDrop::into_inner(u.a));
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/test/run-pass/self/self-in-typedefs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#![feature(untagged_unions)]

#![allow(dead_code)]
#![allow(unions_with_drop_fields)]

use std::mem::ManuallyDrop;

enum A<'a, T: 'a>
where
Expand All @@ -24,6 +25,14 @@ where
union C<'a, T: 'a>
where
Self: Send, T: PartialEq<Self>
{
foo: &'a Self,
bar: ManuallyDrop<T>,
}

union D<'a, T: 'a>
where
Self: Send, T: PartialEq<Self> + Copy
{
foo: &'a Self,
bar: T,
Expand Down

0 comments on commit f4b2d71

Please sign in to comment.