rust: clippy: disable `addr_of!` and `addr_of_mut` macros
Benno Lossin
Reviewed-byQuoted 5 lines · Antonio Hickey
With the
raw_ref_opfeature enabled we no longer want to allow use ofaddr_of!andaddr_of_mut!macros.We instead want to use
&rawand&raw mutto get raw pointers to a place.
To what line length are you wrapping this commit message? I usually do 72 (and I think checkpatch also checks for that?).
Also it would be useful if you could link to
https://github.com/rust-lang/rust-clippy/issues/11431
and note that the lint isn't currently reliable, but we enable it nevertheless to 1) document that one shouldn't use the addr_of! macros and 2) when the lint becomes useful, we already have it enabled.
Quoted 1 line
Suggested-by Benno Lossin <[email protected]>
Please change my email to <[email protected]>.
Quoted 11 lines
Signed-off-by Antonio Hickey <[email protected]>--- .clippy.toml | 4 ++++ 1 file changed, 4 insertions(+).clippy.toml +0
-0
.clippy.toml disallowed-macros = [ · line 14
Quoted 7 lines
.clippy.toml +4
-0@@ -8,4 +8,8 @@ disallowed-macros = [ # The `clippy::dbg_macro` lint only works with `std::dbg!`, thus we simulate # it here, see: https://github.com/rust-lang/rust-clippy/issues/11303. { path = "kernel::dbg", reason = "the `dbg!` macro is intended as a debugging tool" }, + # With `raw_ref_op` feature enabled we no longer want to allow use of `addr_of!` + # and `addr_of_mut!` macros, but instead use `&raw` or `&raw mut`. + { path = "core::ptr::addr_of_mut", reason = "use `&raw mut` instead `addr_of_mut!`" }, + { path = "core::ptr::addr_of", reason = "use `&raw` instead `addr_of!`" },
This should be &raw const. With this and the above changes done, you may add:
---
Cheers,
Benno