Skip to content

Commit 23773bd

Browse files
tamirdojeda
authored andcommitted
rust: enable clippy::as_ptr_cast_mut lint
In Rust 1.66.0, Clippy introduced the `as_ptr_cast_mut` lint [1]: > Since `as_ptr` takes a `&self`, the pointer won’t have write > permissions unless interior mutability is used, making it unlikely > that having it as a mutable pointer is correct. There is only one affected callsite, and the change amounts to replacing `as _` with `.cast_mut().cast()`. This doesn't change the semantics, but is more descriptive of what's going on. Apply this change and enable the lint -- no functional change intended. Link: https://rust-lang.github.io/rust-clippy/master/index.html#as_ptr_cast_mut [1] Reviewed-by: Benno Lossin <benno.lossin@proton.me> Reviewed-by: Boqun Feng <boqun.feng@gmail.com> Signed-off-by: Tamir Duberstein <tamird@gmail.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Danilo Krummrich <dakr@kernel.org> Link: https://lore.kernel.org/r/20250615-ptr-as-ptr-v12-3-f43b024581e8@gmail.com Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent d8c9e73 commit 23773bd

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ export rust_common_flags := --edition=2021 \
479479
-Wrust_2018_idioms \
480480
-Wunreachable_pub \
481481
-Wclippy::all \
482+
-Wclippy::as_ptr_cast_mut \
482483
-Wclippy::ignored_unit_patterns \
483484
-Wclippy::mut_mut \
484485
-Wclippy::needless_bitwise_bool \

rust/kernel/devres.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl<T> DevresInner<T> {
143143
bindings::devm_remove_action_nowarn(
144144
this.dev.as_raw(),
145145
Some(this.callback),
146-
this.as_ptr() as _,
146+
this.as_ptr().cast_mut().cast(),
147147
)
148148
} == 0;
149149

0 commit comments

Comments
 (0)