From: kernel test robot <lkp@intel.com>
To: Joel Fernandes <joelagnelf@nvidia.com>
Cc: oe-kbuild-all@lists.linux.dev
Subject: [jfern:nova/dev-bitstruct 8/8] warning: casts from `u8` to `u32` can be expressed infallibly using `From`
Date: Sun, 21 Sep 2025 10:12:36 +0200 [thread overview]
Message-ID: <202509211019.shmVL9ew-lkp@intel.com> (raw)
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
reply other threads:[~2025-09-21 8:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202509211019.shmVL9ew-lkp@intel.com \
--to=lkp@intel.com \
--cc=joelagnelf@nvidia.com \
--cc=oe-kbuild-all@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.