Re: [PATCH 2/3] rust: clippy: disable `addr_of!` and `addr_of_mut` macros

From: kernel test robot
Date: Fri Mar 14 2025 - 01:54:56 EST


Hi Antonio,

kernel test robot noticed the following build warnings:

[auto build test WARNING on rust/rust-next]
[also build test WARNING on driver-core/driver-core-testing driver-core/driver-core-next driver-core/driver-core-linus shuah-kselftest/kunit shuah-kselftest/kunit-fixes pci/next pci/for-linus linus/master v6.14-rc6 next-20250313]
[cannot apply to rust/rust-block-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Antonio-Hickey/rust-clippy-disable-addr_of-and-addr_of_mut-macros/20250313-133646
base: https://github.com/Rust-for-Linux/linux rust-next
patch link: https://lore.kernel.org/r/010001958dfeb4c7-0ed042d2-613b-4023-bb91-0c64f8a84fc9-000000%40email.amazonses.com
patch subject: [PATCH 2/3] rust: clippy: disable `addr_of!` and `addr_of_mut` macros
config: x86_64-rhel-9.4-rust (https://download.01.org/0day-ci/archive/20250314/202503141300.7VvqEzvm-lkp@xxxxxxxxx/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
rustc: rustc 1.78.0 (9b00956e5 2024-04-29)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250314/202503141300.7VvqEzvm-lkp@xxxxxxxxx/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@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503141300.7VvqEzvm-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

>> warning: use of a disallowed macro `core::ptr::addr_of`
--> rust/kernel/fs/file.rs:334:18
|
334 | unsafe { core::ptr::addr_of!((*self.as_ptr()).f_flags).read_volatile() }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: use `&raw` instead `addr_of!` (from clippy.toml)
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros
--
>> warning: use of a disallowed macro `core::ptr::addr_of`
--> rust/kernel/list.rs:179:34
|
179 | unsafe { Opaque::raw_get(ptr::addr_of!((*me).inner)) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: use `&raw` instead `addr_of!` (from clippy.toml)
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros
--
>> warning: use of a disallowed macro `core::ptr::addr_of`
--> rust/kernel/sync/arc.rs:246:18
|
246 | unsafe { core::ptr::addr_of!((*ptr).data) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: use `&raw` instead `addr_of!` (from clippy.toml)
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros
--
>> warning: use of a disallowed macro `core::ptr::addr_of`
--> rust/kernel/task.rs:260:29
|
260 | let ptr = unsafe { *ptr::addr_of!((*self.as_ptr()).group_leader) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: use `&raw` instead `addr_of!` (from clippy.toml)
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros
--
>> warning: use of a disallowed macro `core::ptr::addr_of`
--> rust/kernel/task.rs:272:19
|
272 | unsafe { *ptr::addr_of!((*self.as_ptr()).pid) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: use `&raw` instead `addr_of!` (from clippy.toml)
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros
--
>> warning: use of a disallowed macro `core::ptr::addr_of`
--> rust/kernel/workqueue.rs:406:34
|
406 | unsafe { Opaque::raw_get(core::ptr::addr_of!((*ptr).work)) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: use `&raw` instead `addr_of!` (from clippy.toml)
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros

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