Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions library/core/src/mem/maybe_dangling.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -109,3 +110,5 @@ impl<P: ?Sized> MaybeDangling<P> {
x
}
}

impl<T: ?Sized> StructuralPartialEq for MaybeDangling<T> {}
16 changes: 16 additions & 0 deletions tests/ui/consts/manually_drop_structural_eq.rs
Original file line number Diff line number Diff line change
@@ -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"),
}
}
Loading