Skip to content

Commit 46b6233

Browse files
committed
Add an enum variant per review comment
1 parent 13bc9c9 commit 46b6233

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/test/ui/manually_drop_attr/manually_drop-destructor.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,17 @@ impl<'a> Drop for ManuallyDropped<'a> {
3030

3131
#[manually_drop]
3232
enum ManuallyDroppedEnum<'a> {
33-
A(DropCounter<'a>, DropCounter<'a>),
33+
_A,
34+
B(DropCounter<'a>, DropCounter<'a>),
3435
}
3536

3637
impl<'a> Drop for ManuallyDroppedEnum<'a> {
3738
fn drop(&mut self) {
3839
// just do a LITTLE dropping.
39-
let ManuallyDroppedEnum::A(a, _) = self;
40-
unsafe {
41-
core::ptr::drop_in_place(a);
40+
if let ManuallyDroppedEnum::B(a, _) = self {
41+
unsafe {
42+
core::ptr::drop_in_place(a);
43+
}
4244
}
4345
}
4446
}
@@ -56,7 +58,7 @@ fn test_destruction() {
5658
assert_eq!(counter.get(), 1);
5759
assert!(core::mem::needs_drop::<ManuallyDropped>());
5860

59-
core::mem::drop(ManuallyDroppedEnum::A(DropCounter(&counter), DropCounter(&counter)));
61+
core::mem::drop(ManuallyDroppedEnum::B(DropCounter(&counter), DropCounter(&counter)));
6062
assert_eq!(counter.get(), 2);
6163
assert!(core::mem::needs_drop::<ManuallyDroppedEnum>());
6264

src/test/ui/manually_drop_attr/manually_drop-nodestructor.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ struct ManuallyDropped<'a> {
2222

2323
#[manually_drop]
2424
enum ManuallyDroppedEnum<'a> {
25-
A(DropCounter<'a>, DropCounter<'a>),
25+
_A,
26+
B(DropCounter<'a>, DropCounter<'a>),
2627
}
2728

28-
/// Dropping a `#[manually_drop]` struct does not implicitly drop its fields.
29+
/// Dropping a `#[manually_drop]` type does not implicitly drop its fields.
2930
fn test_destruction() {
3031
let counter = Cell::new(0);
3132
core::mem::drop(ManuallyDropped {
@@ -35,7 +36,7 @@ fn test_destruction() {
3536
assert_eq!(counter.get(), 0);
3637
assert!(!core::mem::needs_drop::<ManuallyDropped>());
3738

38-
core::mem::drop(ManuallyDroppedEnum::A(DropCounter(&counter), DropCounter(&counter)));
39+
core::mem::drop(ManuallyDroppedEnum::B(DropCounter(&counter), DropCounter(&counter)));
3940
assert_eq!(counter.get(), 0);
4041
assert!(!core::mem::needs_drop::<ManuallyDroppedEnum>());
4142
}

0 commit comments

Comments
 (0)