Skip to content

Commit 8169e48

Browse files
ojedaYuryNorov
authored andcommitted
rust: bitmap: clean Rust 1.92.0 unused_unsafe warning
Starting with Rust 1.92.0 (expected 2025-12-11), Rust allows to safely take the address of a union field [1][2]: CLIPPY L rust/kernel.o error: unnecessary `unsafe` block --> rust/kernel/bitmap.rs:169:13 | 169 | unsafe { core::ptr::addr_of!(self.repr.bitmap) } | ^^^^^^ unnecessary `unsafe` block | = note: `-D unused-unsafe` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(unused_unsafe)]` error: unnecessary `unsafe` block --> rust/kernel/bitmap.rs:185:13 | 185 | unsafe { core::ptr::addr_of_mut!(self.repr.bitmap) } | ^^^^^^ unnecessary `unsafe` block Thus allow both instances to clean the warning in newer compilers. Link: rust-lang/rust#141264 [1] Link: rust-lang/rust#141469 [2] Signed-off-by: Miguel Ojeda <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Signed-off-by: Yury Norov (NVIDIA) <[email protected]>
1 parent 3a86608 commit 8169e48

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

rust/kernel/bitmap.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ impl core::ops::Deref for BitmapVec {
166166
fn deref(&self) -> &Bitmap {
167167
let ptr = if self.nbits <= BITS_PER_LONG {
168168
// SAFETY: Bitmap is represented inline.
169+
#[allow(unused_unsafe, reason = "Safe since Rust 1.92.0")]
169170
unsafe { core::ptr::addr_of!(self.repr.bitmap) }
170171
} else {
171172
// SAFETY: Bitmap is represented as array of `unsigned long`.
@@ -182,6 +183,7 @@ impl core::ops::DerefMut for BitmapVec {
182183
fn deref_mut(&mut self) -> &mut Bitmap {
183184
let ptr = if self.nbits <= BITS_PER_LONG {
184185
// SAFETY: Bitmap is represented inline.
186+
#[allow(unused_unsafe, reason = "Safe since Rust 1.92.0")]
185187
unsafe { core::ptr::addr_of_mut!(self.repr.bitmap) }
186188
} else {
187189
// SAFETY: Bitmap is represented as array of `unsigned long`.

0 commit comments

Comments
 (0)