Skip to content

Commit d0d66ed

Browse files
authored
Rollup merge of rust-lang#147708 - clarfonthey:const-drop, r=oli-obk
const `mem::drop` I'm putting this under the `const Destruct` feature flag since it doesn't really feel relevant to put it elsewhere… it's just an empty function body, so, it doesn't have any particular weirdness attached to it (unlike `drop_in_place`, for example). r? wg-const-eval
2 parents 66b39af + 43f708c commit d0d66ed

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

core/src/mem/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#![stable(feature = "rust1", since = "1.0.0")]
77

88
use crate::alloc::Layout;
9-
use crate::marker::DiscriminantKind;
9+
use crate::marker::{Destruct, DiscriminantKind};
1010
use crate::panic::const_assert;
1111
use crate::{clone, cmp, fmt, hash, intrinsics, ptr};
1212

@@ -958,8 +958,13 @@ pub const fn replace<T>(dest: &mut T, src: T) -> T {
958958
/// [`RefCell`]: crate::cell::RefCell
959959
#[inline]
960960
#[stable(feature = "rust1", since = "1.0.0")]
961+
#[rustc_const_unstable(feature = "const_destruct", issue = "133214")]
961962
#[rustc_diagnostic_item = "mem_drop"]
962-
pub fn drop<T>(_x: T) {}
963+
pub const fn drop<T>(_x: T)
964+
where
965+
T: [const] Destruct,
966+
{
967+
}
963968

964969
/// Bitwise-copies a value.
965970
///

0 commit comments

Comments
 (0)