]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rust: enable `clippy::cast_lossless` lint
authorTamir Duberstein <tamird@gmail.com>
Sun, 15 Jun 2025 20:55:09 +0000 (16:55 -0400)
committerMiguel Ojeda <ojeda@kernel.org>
Sun, 22 Jun 2025 21:09:25 +0000 (23:09 +0200)
commitb7c8d7a8d251ab63fba3cc964f1928a216c28081
tree77d8a0719fec174a8afcdb51d799934bb6b260b7
parent5e30550558b1eace5fa4af4e2257216fa8a7c90f
rust: enable `clippy::cast_lossless` lint

Before Rust 1.29.0, Clippy introduced the `cast_lossless` lint [1]:

> Rust’s `as` keyword will perform many kinds of conversions, including
> silently lossy conversions. Conversion functions such as `i32::from`
> will only perform lossless conversions. Using the conversion functions
> prevents conversions from becoming silently lossy if the input types
> ever change, and makes it clear for people reading the code that the
> conversion is lossless.

While this doesn't eliminate unchecked `as` conversions, it makes such
conversions easier to scrutinize.  It also has the slight benefit of
removing a degree of freedom on which to bikeshed. Thus apply the
changes and enable the lint -- no functional change intended.

Link: https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless
Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/all/D8ORTXSUTKGL.1KOJAGBM8F8TN@proton.me/
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: FUJITA Tomonori <fujita.tomonori@gmail.com>
Acked-by: Jocelyn Falempe <jfalempe@redhat.com>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Link: https://lore.kernel.org/r/20250615-ptr-as-ptr-v12-5-f43b024581e8@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Makefile
drivers/gpu/drm/drm_panic_qr.rs
drivers/gpu/nova-core/regs.rs
drivers/gpu/nova-core/regs/macros.rs
rust/bindings/lib.rs
rust/kernel/net/phy.rs
rust/uapi/lib.rs