2229: Annotate stdlib with insignficant dtors
This commit is contained in:
parent
95cfbe43d2
commit
099a34cd95
8 changed files with 9 additions and 0 deletions
|
@ -162,6 +162,7 @@ pub struct BTreeMap<K, V> {
|
|||
|
||||
#[stable(feature = "btree_drop", since = "1.7.0")]
|
||||
unsafe impl<#[may_dangle] K, #[may_dangle] V> Drop for BTreeMap<K, V> {
|
||||
#[rustc_insignificant_dtor]
|
||||
fn drop(&mut self) {
|
||||
drop(unsafe { ptr::read(self) }.into_iter())
|
||||
}
|
||||
|
@ -1459,6 +1460,7 @@ impl<K, V> IntoIterator for BTreeMap<K, V> {
|
|||
|
||||
#[stable(feature = "btree_drop", since = "1.7.0")]
|
||||
impl<K, V> Drop for IntoIter<K, V> {
|
||||
#[rustc_insignificant_dtor]
|
||||
fn drop(&mut self) {
|
||||
struct DropGuard<'a, K, V>(&'a mut IntoIter<K, V>);
|
||||
|
||||
|
|
|
@ -975,6 +975,7 @@ impl<T> LinkedList<T> {
|
|||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
unsafe impl<#[may_dangle] T> Drop for LinkedList<T> {
|
||||
#[rustc_insignificant_dtor]
|
||||
fn drop(&mut self) {
|
||||
struct DropGuard<'a, T>(&'a mut LinkedList<T>);
|
||||
|
||||
|
|
|
@ -130,6 +130,7 @@ impl<T: Clone, A: Allocator + Clone> Clone for VecDeque<T, A> {
|
|||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
unsafe impl<#[may_dangle] T, A: Allocator> Drop for VecDeque<T, A> {
|
||||
#[rustc_insignificant_dtor]
|
||||
fn drop(&mut self) {
|
||||
/// Runs the destructor for all items in the slice when it gets dropped (normally or
|
||||
/// during unwinding).
|
||||
|
|
|
@ -1441,6 +1441,7 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Rc<T> {
|
|||
/// drop(foo); // Doesn't print anything
|
||||
/// drop(foo2); // Prints "dropped!"
|
||||
/// ```
|
||||
#[rustc_insignificant_dtor]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
self.inner().dec_strong();
|
||||
|
|
|
@ -246,6 +246,7 @@ impl<T: Clone, A: Allocator + Clone> Clone for IntoIter<T, A> {
|
|||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
unsafe impl<#[may_dangle] T, A: Allocator> Drop for IntoIter<T, A> {
|
||||
#[rustc_insignificant_dtor]
|
||||
fn drop(&mut self) {
|
||||
struct DropGuard<'a, T, A: Allocator>(&'a mut IntoIter<T, A>);
|
||||
|
||||
|
|
|
@ -2746,6 +2746,7 @@ impl<T: Ord, A: Allocator> Ord for Vec<T, A> {
|
|||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
unsafe impl<#[may_dangle] T, A: Allocator> Drop for Vec<T, A> {
|
||||
#[rustc_insignificant_dtor]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
// use drop for [T]
|
||||
|
|
|
@ -180,6 +180,7 @@ impl<T, const N: usize> DoubleEndedIterator for IntoIter<T, N> {
|
|||
|
||||
#[stable(feature = "array_value_iter_impls", since = "1.40.0")]
|
||||
impl<T, const N: usize> Drop for IntoIter<T, N> {
|
||||
#[rustc_insignificant_dtor]
|
||||
fn drop(&mut self) {
|
||||
// SAFETY: This is safe: `as_mut_slice` returns exactly the sub-slice
|
||||
// of elements that have not been moved out yet and that remain
|
||||
|
|
|
@ -492,6 +492,7 @@ impl<T> SyncOnceCell<T> {
|
|||
}
|
||||
|
||||
unsafe impl<#[may_dangle] T> Drop for SyncOnceCell<T> {
|
||||
#[rustc_insignificant_dtor]
|
||||
fn drop(&mut self) {
|
||||
if self.is_initialized() {
|
||||
// SAFETY: The cell is initialized and being dropped, so it can't
|
||||
|
|
Loading…
Add table
Reference in a new issue