mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
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`.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#![unstable(feature = "maybe_dangling", issue = "118166")]
|
||||
|
||||
use crate::marker::StructuralPartialEq;
|
||||
use crate::{mem, ptr};
|
||||
|
||||
/// Allows wrapped [references] and [boxes] to dangle.
|
||||
@@ -109,3 +110,5 @@ pub const fn into_inner(self) -> P
|
||||
x
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: ?Sized> StructuralPartialEq for MaybeDangling<T> {}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// Check that `ManuallyDrop` types can be used as a constant when matching.
|
||||
// I.e. that `ManuallyDrop` implements `StructuralPartialEq`.
|
||||
//
|
||||
// Regression test for <https://github.com/rust-lang/rust/issues/154890>.
|
||||
//
|
||||
//@ check-pass
|
||||
use std::mem::ManuallyDrop;
|
||||
|
||||
fn main() {
|
||||
const X: ManuallyDrop<u32> = ManuallyDrop::new(1);
|
||||
|
||||
match ManuallyDrop::new(1) {
|
||||
X => println!("blah"),
|
||||
_ => println!("bleh"),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user