Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: https://github.com/rust-lang/rust/issues/141264 [1]
Link: https://github.com/rust-lang/rust/pull/141469 [2]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>

authored by

Miguel Ojeda and committed by
Yury Norov (NVIDIA)
0f587883 9b332cec

+2
+2
rust/kernel/bitmap.rs
··· 166 166 fn deref(&self) -> &Bitmap { 167 167 let ptr = if self.nbits <= BITS_PER_LONG { 168 168 // SAFETY: Bitmap is represented inline. 169 + #[allow(unused_unsafe, reason = "Safe since Rust 1.92.0")] 169 170 unsafe { core::ptr::addr_of!(self.repr.bitmap) } 170 171 } else { 171 172 // SAFETY: Bitmap is represented as array of `unsigned long`. ··· 183 182 fn deref_mut(&mut self) -> &mut Bitmap { 184 183 let ptr = if self.nbits <= BITS_PER_LONG { 185 184 // SAFETY: Bitmap is represented inline. 185 + #[allow(unused_unsafe, reason = "Safe since Rust 1.92.0")] 186 186 unsafe { core::ptr::addr_of_mut!(self.repr.bitmap) } 187 187 } else { 188 188 // SAFETY: Bitmap is represented as array of `unsigned long`.