From 9224bfc3411c9fd4997f7097c5620fcd68523e85 Mon Sep 17 00:00:00 2001 From: Alejandro Vaz Date: Mon, 21 Sep 2026 17:07:13 +0200 Subject: [PATCH] feat: kill may dangle --- Cargo.toml | 1 - src/lib.rs | 26 -------------------------- 2 files changed, 27 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5c056a8..9dfe5e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,6 @@ strip = true [features] default = ["allocator-api2"] internals = [] -may_dangle = [] rayon = ["std", "dep:rayon"] serde = ["dep:serde_core"] specialization = [] diff --git a/src/lib.rs b/src/lib.rs index 0ad6441..f74661b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,6 @@ #![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(feature = "specialization", allow(incomplete_features))] #![cfg_attr(feature = "specialization", feature(specialization, trusted_len))] -#![cfg_attr(feature = "may_dangle", feature(dropck_eyepatch))] #![cfg_attr(not(feature = "allocator-api2"), feature(allocator_api))] extern crate alloc; @@ -1721,31 +1720,6 @@ impl Drop for DropDealloc<'_, A> { } } -#[cfg(feature = "may_dangle")] -unsafe impl<#[may_dangle] T, const N: usize, A: Allocator> Drop for SmallVec { - fn drop(&mut self) { - let (len, on_heap) = self.len.parts(); - let ptr = unsafe { self.raw.as_mut_ptr(on_heap) }; - // SAFETY: we first drop the elements, then `_drop_dealloc` is dropped, - // releasing memory we used to own - unsafe { - let _drop_dealloc = if on_heap { - let capacity = self.raw.inner.heap.1; - Some(DropDealloc { - ptr: NonNull::new_unchecked(ptr as *mut u8), - size_bytes: capacity * size_of::(), - align: align_of::(), - alloc: &self.raw.alloc - }) - } else { - None - }; - core::ptr::slice_from_raw_parts_mut(ptr, len).drop_in_place(); - } - } -} - -#[cfg(not(feature = "may_dangle"))] impl Drop for SmallVec { fn drop(&mut self) { let (len, on_heap) = self.len.parts();