All of lore.kernel.org
 help / color / mirror / Atom feed
* [jfern:nova/dev-bitstruct 8/8] warning: casts from `u8` to `u32` can be expressed infallibly using `From`
@ 2025-09-21  8:12 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2025-09-21  8:12 UTC (permalink / raw)
  To: Joel Fernandes; +Cc: oe-kbuild-all

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jfern/linux.git nova/dev-bitstruct
head:   88ed8df883ccc4292779f4a55de116730bffbda3
commit: 88ed8df883ccc4292779f4a55de116730bffbda3 [8/8] rust: bitfield: Use 'as' operator for setter type conversion
config: x86_64-rhel-9.4-rust (https://download.01.org/0day-ci/archive/20250921/202509211019.shmVL9ew-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
rustc: rustc 1.88.0 (6b00bc388 2025-06-23)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250921/202509211019.shmVL9ew-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202509211019.shmVL9ew-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> warning: casts from `u8` to `u32` can be expressed infallibly using `From`
   --> rust/kernel/bits/bitfield.rs:248:38
   |
   248 |               { |f| <$into_type>::from(f as $type) } $into_type => $into_type $(, $comment)?;);
   |                                        ^
   ...
   456 | /     bitfield! {
   457 | |         struct TestWideFields: u8 {
   458 | |             3:0       nibble      as u32;
   459 | |             7:4       high_nibble as u32;
   ...   |
   462 | |     }
   | |_____- in this macro invocation
   |
   = help: an `as` cast can become silently lossy if the types change in the future
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless
   = note: this warning originates in the macro `::kernel::bitfield` which comes from the expansion of the macro `bitfield` (in Nightly builds, run with -Z macro-backtrace for more info)
   help: use `<$type>::from` instead
   |
   248 -             { |f| <$into_type>::from(f as $type) } $into_type => $into_type $(, $comment)?;);
   248 +             { |f| <$into_type>::from(<$type>::from(f) as $type) } $into_type => $into_type $(, $comment)?;);
   |
--
>> warning: casts from `bool` to `u64` can be expressed infallibly using `From`
   --> rust/kernel/bits/bitfield.rs:303:26
   |
   303 |               let value = ((value as $storage) << SHIFT) & MASK;
   |                            ^^^^^^^^^^^^^^^^^^^
   ...
   414 | /     bitfield! {
   415 | |         struct TestPageTableEntry: u64 {
   416 | |             0:0       present     as bool;
   417 | |             1:1       writable    as bool;
   ...   |
   425 | |     }
   | |_____- in this macro invocation
   |
   = help: an `as` cast can become silently lossy if the types change in the future
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless
   = note: requested on the command line with `-W clippy::cast-lossless`
   = note: this warning originates in the macro `::kernel::bitfield` which comes from the expansion of the macro `bitfield` (in Nightly builds, run with -Z macro-backtrace for more info)
   help: use `<u64>::from` instead
   |
   303 -             let value = ((value as $storage) << SHIFT) & MASK;
   303 +             let value = (<u64>::from(value) << SHIFT) & MASK;
   |
--
>> warning: casts from `bool` to `u64` can be expressed infallibly using `From`
   --> rust/kernel/bits/bitfield.rs:303:26
   |
   303 |               let value = ((value as $storage) << SHIFT) & MASK;
   |                            ^^^^^^^^^^^^^^^^^^^
   ...
   414 | /     bitfield! {
   415 | |         struct TestPageTableEntry: u64 {
   416 | |             0:0       present     as bool;
   417 | |             1:1       writable    as bool;
   ...   |
   425 | |     }
   | |_____- in this macro invocation
   |
   = help: an `as` cast can become silently lossy if the types change in the future
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless
   = note: this warning originates in the macro `::kernel::bitfield` which comes from the expansion of the macro `bitfield` (in Nightly builds, run with -Z macro-backtrace for more info)
   help: use `<u64>::from` instead
   |
   303 -             let value = ((value as $storage) << SHIFT) & MASK;
   303 +             let value = (<u64>::from(value) << SHIFT) & MASK;
   |
--
>> warning: casts from `bool` to `u16` can be expressed infallibly using `From`
   --> rust/kernel/bits/bitfield.rs:303:26
   |
   303 |               let value = ((value as $storage) << SHIFT) & MASK;
   |                            ^^^^^^^^^^^^^^^^^^^
   ...
   427 | /     bitfield! {
   428 | |         struct TestControlRegister: u16 {
   429 | |             0:0       enable      as bool;
   430 | |             3:1       mode        as u8;
   ...   |
   435 | |     }
   | |_____- in this macro invocation
   |
   = help: an `as` cast can become silently lossy if the types change in the future
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless
   = note: this warning originates in the macro `::kernel::bitfield` which comes from the expansion of the macro `bitfield` (in Nightly builds, run with -Z macro-backtrace for more info)
   help: use `<u16>::from` instead
   |
   303 -             let value = ((value as $storage) << SHIFT) & MASK;
   303 +             let value = (<u16>::from(value) << SHIFT) & MASK;
   |
--
>> warning: casts from `bool` to `u8` can be expressed infallibly using `From`
   --> rust/kernel/bits/bitfield.rs:303:26
   |
   303 |               let value = ((value as $storage) << SHIFT) & MASK;
   |                            ^^^^^^^^^^^^^^^^^^^
   ...
   437 | /     bitfield! {
   438 | |         struct TestStatusRegister: u8 {
   439 | |             0:0       ready       as bool;
   440 | |             1:1       error       as bool;
   ...   |
   445 | |     }
   | |_____- in this macro invocation
   |
   = help: an `as` cast can become silently lossy if the types change in the future
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless
   = note: this warning originates in the macro `::kernel::bitfield` which comes from the expansion of the macro `bitfield` (in Nightly builds, run with -Z macro-backtrace for more info)
   help: use `<u8>::from` instead
   |
   303 -             let value = ((value as $storage) << SHIFT) & MASK;
   303 +             let value = (<u8>::from(value) << SHIFT) & MASK;
   |
--
>> warning: casts from `bool` to `u8` can be expressed infallibly using `From`
   --> rust/kernel/bits/bitfield.rs:303:26
   |
   303 |               let value = ((value as $storage) << SHIFT) & MASK;
   |                            ^^^^^^^^^^^^^^^^^^^
   ...
   447 | /     bitfield! {
   448 | |         struct TestPartialBits: u8 {
   449 | |             0:0       ready       as bool;
   450 | |             1:1       error       as bool;
   ...   |
   453 | |     }
   | |_____- in this macro invocation
   |
   = help: an `as` cast can become silently lossy if the types change in the future
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless
   = note: this warning originates in the macro `::kernel::bitfield` which comes from the expansion of the macro `bitfield` (in Nightly builds, run with -Z macro-backtrace for more info)
   help: use `<u8>::from` instead
   |
   303 -             let value = ((value as $storage) << SHIFT) & MASK;
   303 +             let value = (<u8>::from(value) << SHIFT) & MASK;
   |

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-09-21  8:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-21  8:12 [jfern:nova/dev-bitstruct 8/8] warning: casts from `u8` to `u32` can be expressed infallibly using `From` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.