diff options
| author | Lukas Markeffsky <@> | 2023-11-23 10:25:25 +0000 |
|---|---|---|
| committer | Lukas Markeffsky <@> | 2024-02-16 13:10:52 +0100 |
| commit | ec95d259e41a9da382cf0b35769f71fe23b49986 (patch) | |
| tree | 13f3d078b8d0f6acfc1971b8f7c8c78ff79c1d4d | |
| parent | dfa88b328f969871d12dba3b2c0257ab3ea6703a (diff) | |
| download | rust-ec95d259e41a9da382cf0b35769f71fe23b49986.tar.gz rust-ec95d259e41a9da382cf0b35769f71fe23b49986.zip | |
simplify codegen for trivially droppable types
| -rw-r--r-- | library/alloc/src/collections/vec_deque/drain.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/library/alloc/src/collections/vec_deque/drain.rs b/library/alloc/src/collections/vec_deque/drain.rs index 0be274a3822..7d40ce65ad7 100644 --- a/library/alloc/src/collections/vec_deque/drain.rs +++ b/library/alloc/src/collections/vec_deque/drain.rs @@ -96,8 +96,9 @@ impl<T, A: Allocator> Drop for Drain<'_, T, A> { struct DropGuard<'r, 'a, T, A: Allocator>(&'r mut Drain<'a, T, A>); impl<'r, 'a, T, A: Allocator> Drop for DropGuard<'r, 'a, T, A> { + #[inline] fn drop(&mut self) { - if self.0.remaining != 0 { + if mem::needs_drop::<T>() && self.0.remaining != 0 { unsafe { // SAFETY: We just checked that `self.remaining != 0`. let (front, back) = self.0.as_slices(); @@ -158,7 +159,7 @@ impl<T, A: Allocator> Drop for Drain<'_, T, A> { } let guard = DropGuard(self); - if guard.0.remaining != 0 { + if mem::needs_drop::<T>() && guard.0.remaining != 0 { unsafe { // SAFETY: We just checked that `self.remaining != 0`. let (front, back) = guard.0.as_slices(); |
