* [PATCH] rust: bitmap: clean Rust 1.92.0 `unused_unsafe` warning
@ 2025-10-13 0:14 Miguel Ojeda
2025-10-13 9:20 ` Alice Ryhl
0 siblings, 1 reply; 6+ messages in thread
From: Miguel Ojeda @ 2025-10-13 0:14 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor, Alice Ryhl, Burak Emir
Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Trevor Gross, Danilo Krummrich, rust-for-linux,
Yury Norov, linux-kernel, patches
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>
---
rust/kernel/bitmap.rs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/rust/kernel/bitmap.rs b/rust/kernel/bitmap.rs
index f45915694454..711b8368b38f 100644
--- a/rust/kernel/bitmap.rs
+++ b/rust/kernel/bitmap.rs
@@ -166,6 +166,7 @@ impl core::ops::Deref for BitmapVec {
fn deref(&self) -> &Bitmap {
let ptr = if self.nbits <= BITS_PER_LONG {
// SAFETY: Bitmap is represented inline.
+ #[allow(unused_unsafe, reason = "Safe since Rust 1.92.0")]
unsafe { core::ptr::addr_of!(self.repr.bitmap) }
} else {
// SAFETY: Bitmap is represented as array of `unsigned long`.
@@ -182,6 +183,7 @@ impl core::ops::DerefMut for BitmapVec {
fn deref_mut(&mut self) -> &mut Bitmap {
let ptr = if self.nbits <= BITS_PER_LONG {
// SAFETY: Bitmap is represented inline.
+ #[allow(unused_unsafe, reason = "Safe since Rust 1.92.0")]
unsafe { core::ptr::addr_of_mut!(self.repr.bitmap) }
} else {
// SAFETY: Bitmap is represented as array of `unsigned long`.
base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787
--
2.51.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] rust: bitmap: clean Rust 1.92.0 `unused_unsafe` warning
2025-10-13 0:14 [PATCH] rust: bitmap: clean Rust 1.92.0 `unused_unsafe` warning Miguel Ojeda
@ 2025-10-13 9:20 ` Alice Ryhl
2025-10-14 16:09 ` Yury Norov
0 siblings, 1 reply; 6+ messages in thread
From: Alice Ryhl @ 2025-10-13 9:20 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Alex Gaynor, Burak Emir, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, rust-for-linux, Yury Norov,
linux-kernel, patches
On Mon, Oct 13, 2025 at 02:14:22AM +0200, Miguel Ojeda wrote:
> 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>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rust: bitmap: clean Rust 1.92.0 `unused_unsafe` warning
2025-10-13 9:20 ` Alice Ryhl
@ 2025-10-14 16:09 ` Yury Norov
2025-10-14 16:21 ` Alice Ryhl
0 siblings, 1 reply; 6+ messages in thread
From: Yury Norov @ 2025-10-14 16:09 UTC (permalink / raw)
To: Alice Ryhl
Cc: Miguel Ojeda, Alex Gaynor, Burak Emir, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel,
patches
On Mon, Oct 13, 2025 at 09:20:15AM +0000, Alice Ryhl wrote:
> On Mon, Oct 13, 2025 at 02:14:22AM +0200, Miguel Ojeda wrote:
> > 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>
Added in bitmap-for-next.
Thanks,
Yury
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rust: bitmap: clean Rust 1.92.0 `unused_unsafe` warning
2025-10-14 16:09 ` Yury Norov
@ 2025-10-14 16:21 ` Alice Ryhl
2025-10-14 16:23 ` Yury Norov
0 siblings, 1 reply; 6+ messages in thread
From: Alice Ryhl @ 2025-10-14 16:21 UTC (permalink / raw)
To: Yury Norov
Cc: Miguel Ojeda, Alex Gaynor, Burak Emir, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel,
patches
On Tue, Oct 14, 2025 at 12:09:09PM -0400, Yury Norov wrote:
> On Mon, Oct 13, 2025 at 09:20:15AM +0000, Alice Ryhl wrote:
> > On Mon, Oct 13, 2025 at 02:14:22AM +0200, Miguel Ojeda wrote:
> > > 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>
>
> Added in bitmap-for-next.
Is there any possibility of landing this for an -rc of 6.18 instead of
for 6.19-rc1? That way, the warning won't be present when compiling 6.18
with rustc 1.92.0 and newer.
Alice
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rust: bitmap: clean Rust 1.92.0 `unused_unsafe` warning
2025-10-14 16:21 ` Alice Ryhl
@ 2025-10-14 16:23 ` Yury Norov
2025-10-14 16:42 ` Miguel Ojeda
0 siblings, 1 reply; 6+ messages in thread
From: Yury Norov @ 2025-10-14 16:23 UTC (permalink / raw)
To: Alice Ryhl
Cc: Miguel Ojeda, Alex Gaynor, Burak Emir, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel,
patches
On Tue, Oct 14, 2025 at 04:21:51PM +0000, Alice Ryhl wrote:
> On Tue, Oct 14, 2025 at 12:09:09PM -0400, Yury Norov wrote:
> > On Mon, Oct 13, 2025 at 09:20:15AM +0000, Alice Ryhl wrote:
> > > On Mon, Oct 13, 2025 at 02:14:22AM +0200, Miguel Ojeda wrote:
> > > > 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>
> >
> > Added in bitmap-for-next.
>
> Is there any possibility of landing this for an -rc of 6.18 instead of
> for 6.19-rc1? That way, the warning won't be present when compiling 6.18
> with rustc 1.92.0 and newer.
OK, will do -rc1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rust: bitmap: clean Rust 1.92.0 `unused_unsafe` warning
2025-10-14 16:23 ` Yury Norov
@ 2025-10-14 16:42 ` Miguel Ojeda
0 siblings, 0 replies; 6+ messages in thread
From: Miguel Ojeda @ 2025-10-14 16:42 UTC (permalink / raw)
To: Yury Norov
Cc: Alice Ryhl, Miguel Ojeda, Alex Gaynor, Burak Emir, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel,
patches
On Tue, Oct 14, 2025 at 6:23 PM Yury Norov <yury.norov@gmail.com> wrote:
>
> OK, will do -rc1
Thanks Yury!
Yeah, these should generally be sent as "fixes" to Linus; otherwise we
will have red CIs.
(I don't add the Fixes tag for this sort of change because the
original code is fine).
Cheers,
Miguel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-10-14 16:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-13 0:14 [PATCH] rust: bitmap: clean Rust 1.92.0 `unused_unsafe` warning Miguel Ojeda
2025-10-13 9:20 ` Alice Ryhl
2025-10-14 16:09 ` Yury Norov
2025-10-14 16:21 ` Alice Ryhl
2025-10-14 16:23 ` Yury Norov
2025-10-14 16:42 ` Miguel Ojeda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).