Skip to content

Commit 2fd285c

Browse files
authored
Rollup merge of #97675 - nvzqz:unsized-needs-drop, r=dtolnay
Make `std::mem::needs_drop` accept `?Sized` This change attempts to make `needs_drop` work with types like `[u8]` and `str`. This enables code in types like `Arc<T>` that was not possible before, such as rust-lang/rust#97676.
2 parents f454671 + 3ab81af commit 2fd285c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

core/src/intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ extern "rust-intrinsic" {
11621162
///
11631163
/// The stabilized version of this intrinsic is [`mem::needs_drop`](crate::mem::needs_drop).
11641164
#[rustc_const_stable(feature = "const_needs_drop", since = "1.40.0")]
1165-
pub fn needs_drop<T>() -> bool;
1165+
pub fn needs_drop<T: ?Sized>() -> bool;
11661166

11671167
/// Calculates the offset from a pointer.
11681168
///

core/src/mem/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ pub const unsafe fn align_of_val_raw<T: ?Sized>(val: *const T) -> usize {
592592
#[stable(feature = "needs_drop", since = "1.21.0")]
593593
#[rustc_const_stable(feature = "const_mem_needs_drop", since = "1.36.0")]
594594
#[rustc_diagnostic_item = "needs_drop"]
595-
pub const fn needs_drop<T>() -> bool {
595+
pub const fn needs_drop<T: ?Sized>() -> bool {
596596
intrinsics::needs_drop::<T>()
597597
}
598598

0 commit comments

Comments
 (0)