Skip to content

Commit 68bcf7c

Browse files
committed
implement StructuralPartialEq for MaybeDangling
This fixes a stable-to-stable regression where constants of type `ManuallyDrop<T>` would not be allowed to be used as a pattern due to `MaybeDangling<T>` in `ManuallyDrop<T>` not implementing `StructuralPartialEq`.
1 parent 906ca7f commit 68bcf7c

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

library/core/src/mem/maybe_dangling.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![unstable(feature = "maybe_dangling", issue = "118166")]
22

3+
use crate::marker::StructuralPartialEq;
34
use crate::{mem, ptr};
45

56
/// Allows wrapped [references] and [boxes] to dangle.
@@ -109,3 +110,5 @@ impl<P: ?Sized> MaybeDangling<P> {
109110
x
110111
}
111112
}
113+
114+
impl<T: ?Sized> StructuralPartialEq for MaybeDangling<T> {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Check that `ManuallyDrop` types can be used as a constant when matching.
2+
// I.e. that `ManuallyDrop` implements `StructuralPartialEq`.
3+
//
4+
//@ check-pass
5+
use std::mem::ManuallyDrop;
6+
7+
fn main() {
8+
const X: ManuallyDrop<u32> = ManuallyDrop::new(1);
9+
10+
match ManuallyDrop::new(1) {
11+
X => println!("blah"),
12+
_ => println!("bleh"),
13+
}
14+
}

0 commit comments

Comments
 (0)