Skip to content

Commit 3b791a4

Browse files
author
Lukas Markeffsky
committed
simplify codegen for trivially droppable types
1 parent 4ae1e79 commit 3b791a4

File tree

1 file changed

+3
-2
lines changed
  • library/alloc/src/collections/vec_deque

1 file changed

+3
-2
lines changed

library/alloc/src/collections/vec_deque/drain.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ impl<T, A: Allocator> Drop for Drain<'_, T, A> {
9696
struct DropGuard<'r, 'a, T, A: Allocator>(&'r mut Drain<'a, T, A>);
9797

9898
impl<'r, 'a, T, A: Allocator> Drop for DropGuard<'r, 'a, T, A> {
99+
#[inline]
99100
fn drop(&mut self) {
100-
if self.0.remaining != 0 {
101+
if mem::needs_drop::<T>() && self.0.remaining != 0 {
101102
unsafe {
102103
// SAFETY: We just checked that `self.remaining != 0`.
103104
let (front, back) = self.0.as_slices();
@@ -158,7 +159,7 @@ impl<T, A: Allocator> Drop for Drain<'_, T, A> {
158159
}
159160

160161
let guard = DropGuard(self);
161-
if guard.0.remaining != 0 {
162+
if mem::needs_drop::<T>() && guard.0.remaining != 0 {
162163
unsafe {
163164
// SAFETY: We just checked that `self.remaining != 0`.
164165
let (front, back) = guard.0.as_slices();

0 commit comments

Comments
 (0)