about summary refs log tree commit diff
path: root/library/core/src/array
diff options
context:
space:
mode:
authorburlinchen <chenbeiliuhuo@gmail.com>2024-08-09 11:10:30 +0800
committerburlinchen <chenbeiliuhuo@gmail.com>2024-08-09 11:10:30 +0800
commitbca0c5f2a939999dcb8d83d06a793f39f4815736 (patch)
tree80f63470ed849fcc3cfae090cc82c4697846ed27 /library/core/src/array
parentc7b0d4e81f56da02d41f73fb5a85673a29f6cbc9 (diff)
downloadrust-bca0c5f2a939999dcb8d83d06a793f39f4815736.tar.gz
rust-bca0c5f2a939999dcb8d83d06a793f39f4815736.zip
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.
Diffstat (limited to 'library/core/src/array')
-rw-r--r--library/core/src/array/mod.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs
index 5c826b9993f..61c713c9e81 100644
--- a/library/core/src/array/mod.rs
+++ b/library/core/src/array/mod.rs
@@ -889,6 +889,7 @@ impl<T> Guard<'_, T> {
 }
 
 impl<T> Drop for Guard<'_, T> {
+    #[inline]
     fn drop(&mut self) {
         debug_assert!(self.initialized <= self.array_mut.len());