From 8b0a25df98348de12c1bd066aa5c1b9c4068b041 Mon Sep 17 00:00:00 2001 From: burlinchen Date: Fri, 9 Aug 2024 11:10:30 +0800 Subject: [PATCH] fix: Ensure `Guard`'s `drop` method is removed at `opt-level=s` for `Copy` types Added `#[inline]` to the `drop` method in the `Guard` implementation to ensure that the method is removed by the compiler at optimization level `opt-level=s` for `Copy` types. This change aims to align the method's behavior with optimization expectations and ensure it does not affect performance. --- core/src/array/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/array/mod.rs b/core/src/array/mod.rs index 5c826b9993f86..61c713c9e81cf 100644 --- a/core/src/array/mod.rs +++ b/core/src/array/mod.rs @@ -889,6 +889,7 @@ impl Guard<'_, T> { } impl Drop for Guard<'_, T> { + #[inline] fn drop(&mut self) { debug_assert!(self.initialized <= self.array_mut.len());