diff --git a/library/core/src/mem/maybe_dangling.rs b/library/core/src/mem/maybe_dangling.rs index c85576b5778cc..2c9c435c24085 100644 --- a/library/core/src/mem/maybe_dangling.rs +++ b/library/core/src/mem/maybe_dangling.rs @@ -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 @@ impl MaybeDangling

{ x } } + +impl StructuralPartialEq for MaybeDangling {} diff --git a/tests/ui/consts/manually_drop_structural_eq.rs b/tests/ui/consts/manually_drop_structural_eq.rs new file mode 100644 index 0000000000000..1768ebd5f9c4e --- /dev/null +++ b/tests/ui/consts/manually_drop_structural_eq.rs @@ -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 . +// +//@ check-pass +use std::mem::ManuallyDrop; + +fn main() { + const X: ManuallyDrop = ManuallyDrop::new(1); + + match ManuallyDrop::new(1) { + X => println!("blah"), + _ => println!("bleh"), + } +}