From c76bba74d93efcf8f8b8ab955295aa08854ee6c8 Mon Sep 17 00:00:00 2001 From: Ossi Herrala Date: Mon, 6 Nov 2023 13:24:33 +0200 Subject: [PATCH] forget() is no-op in CallocBackingStore's Drop implementation Calling core::mem::forget() for slice is no-op. Forget wants to have an ownership of the data, but it can't since slice is always a reference. While here, use take() instead of replace() as recommended by Clippy. --- src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e60f106..d5ffede 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -74,8 +74,7 @@ impl<'a, T : 'a> CallocBackingStore<'a, T> { } impl<'a, T:'a> Drop for CallocBackingStore<'a, T> { fn drop(self :&mut Self) { -// core::mem::forget(core::mem::replace(self.data, &mut[])); - core::mem::forget(core::mem::replace(&mut self.data, &mut[])); + _ = core::mem::take(&mut self.data); if !self.raw_data.is_null() { let local_free = self.free; unsafe {(local_free)(self.raw_data)};