Skip to content

Commit f4b2d71

Browse files
committed
Fix additional run-pass tests for no drop in union
1 parent 0950bdf commit f4b2d71

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/test/run-pass/drop/dynamic-drop.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#![feature(slice_patterns)]
1111

1212
use std::cell::{Cell, RefCell};
13+
use std::mem::ManuallyDrop;
1314
use std::ops::Generator;
1415
use std::panic;
1516
use std::usize;
@@ -139,17 +140,16 @@ fn assignment1(a: &Allocator, c0: bool) {
139140
_v = _w;
140141
}
141142

142-
#[allow(unions_with_drop_fields)]
143143
union Boxy<T> {
144-
a: T,
145-
b: T,
144+
a: ManuallyDrop<T>,
145+
b: ManuallyDrop<T>,
146146
}
147147

148148
fn union1(a: &Allocator) {
149149
unsafe {
150-
let mut u = Boxy { a: a.alloc() };
151-
u.b = a.alloc();
152-
drop(u.a);
150+
let mut u = Boxy { a: ManuallyDrop::new(a.alloc()) };
151+
*u.b = a.alloc(); // drops first alloc
152+
drop(ManuallyDrop::into_inner(u.a));
153153
}
154154
}
155155

src/test/run-pass/self/self-in-typedefs.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
#![feature(untagged_unions)]
44

55
#![allow(dead_code)]
6-
#![allow(unions_with_drop_fields)]
6+
7+
use std::mem::ManuallyDrop;
78

89
enum A<'a, T: 'a>
910
where
@@ -24,6 +25,14 @@ where
2425
union C<'a, T: 'a>
2526
where
2627
Self: Send, T: PartialEq<Self>
28+
{
29+
foo: &'a Self,
30+
bar: ManuallyDrop<T>,
31+
}
32+
33+
union D<'a, T: 'a>
34+
where
35+
Self: Send, T: PartialEq<Self> + Copy
2736
{
2837
foo: &'a Self,
2938
bar: T,

0 commit comments

Comments
 (0)