linux-yocto/rust/kernel
Miguel Ojeda a01b7b2c1e rust: replace clippy::dbg_macro with disallowed_macros
commit 8577c9dca799bd74377f7c30015d8cdc53a53ca2 upstream.

Back when we used Rust 1.60.0 (before Rust was merged in the kernel),
we added `-Wclippy::dbg_macro` to the compilation flags. This worked
great with our custom `dbg!` macro (vendored from `std`, but slightly
modified to use the kernel printing facilities).

However, in the very next version, 1.61.0, it stopped working [1] since
the lint started to use a Rust diagnostic item rather than a path to find
the `dbg!` macro [1]. This behavior remains until the current nightly
(1.83.0).

Therefore, currently, the `dbg_macro` is not doing anything, which
explains why we can invoke `dbg!` in samples/rust/rust_print.rs`, as well
as why changing the `#[allow()]`s to `#[expect()]`s in `std_vendor.rs`
doctests does not work since they are not fulfilled.

One possible workaround is using `rustc_attrs` like the standard library
does. However, this is intended to be internal, and we just started
supporting several Rust compiler versions, so it is best to avoid it.

Therefore, instead, use `disallowed_macros`. It is a stable lint and
is more flexible (in that we can provide different macros), although
its diagnostic message(s) are not as nice as the specialized one (yet),
and does not allow to set different lint levels per macro/path [2].

In turn, this requires allowing the (intentional) `dbg!` use in the
sample, as one would have expected.

Finally, in a single case, the `allow` is fixed to be an inner attribute,
since otherwise it was not being applied.

Link: https://github.com/rust-lang/rust-clippy/issues/11303 [1]
Link: https://github.com/rust-lang/rust-clippy/issues/11307 [2]
Tested-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://lore.kernel.org/r/20240904204347.168520-13-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-03-13 13:01:42 +01:00
..
alloc rust: enable clippy::undocumented_unsafe_blocks lint 2025-03-13 13:01:41 +01:00
block rust: block: fix formatting in GenDisk doc 2025-03-13 13:01:39 +01:00
init rust: enable clippy::undocumented_unsafe_blocks lint 2025-03-13 13:01:41 +01:00
list rust: enable arbitrary_self_types and remove Receiver 2024-12-14 20:03:34 +01:00
net Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2024-09-05 20:37:20 -07:00
sync rust: sync: remove unneeded #[allow(clippy::non_send_fields_in_send_ty)] 2025-03-13 13:01:41 +01:00
alloc.rs rust: add abstraction for struct page 2024-07-08 23:44:01 +02:00
block.rs rust: block: introduce kernel::block::mq module 2024-06-14 07:45:04 -06:00
build_assert.rs rust: upgrade to Rust 1.68.2 2023-05-31 17:35:03 +02:00
device.rs rust: device: change the from_raw() function 2024-10-03 13:54:48 +02:00
error.rs rust: enable clippy::undocumented_unsafe_blocks lint 2025-03-13 13:01:41 +01:00
firmware.rs rust: device: change the from_raw() function 2024-10-03 13:54:48 +02:00
init.rs rust: init: remove unneeded #[allow(clippy::disallowed_names)] 2025-03-13 13:01:41 +01:00
ioctl.rs rust: kernel: mark code fragments in docs with backticks 2024-02-18 21:22:27 +01:00
kunit.rs rust: kunit: use C-string literals to clean warning 2024-10-01 23:46:42 +02:00
lib.rs rust: enable arbitrary_self_types and remove Receiver 2024-12-14 20:03:34 +01:00
list.rs rust: enable clippy::undocumented_unsafe_blocks lint 2025-03-13 13:01:41 +01:00
net.rs rust: core abstractions for network PHY drivers 2023-12-15 09:35:50 +00:00
page.rs rust: add abstraction for struct page 2024-07-08 23:44:01 +02:00
prelude.rs rust: init: add write_[pin_]init functions 2024-08-22 00:16:16 +02:00
print.rs rust: enable clippy::undocumented_unsafe_blocks lint 2025-03-13 13:01:41 +01:00
rbtree.rs rust: rbtree: fix overindented list item 2025-02-21 14:01:34 +01:00
sizes.rs rust: sizes: add commonly used constants 2024-08-30 10:27:34 +01:00
static_assert.rs rust: static_assert: add static_assert! macro 2022-12-04 01:59:16 +01:00
std_vendor.rs rust: replace clippy::dbg_macro with disallowed_macros 2025-03-13 13:01:42 +01:00
str.rs rust: enable clippy::undocumented_unsafe_blocks lint 2025-03-13 13:01:41 +01:00
sync.rs rust: sync: implement Default for LockClassKey 2024-05-05 19:22:25 +02:00
task.rs rust: kernel: remove redundant imports 2024-05-05 19:22:25 +02:00
time.rs rust: time: doc: Add missing C header links 2024-05-01 00:04:47 +02:00
types.rs rust: enable clippy::ignored_unit_patterns lint 2025-03-13 13:01:41 +01:00
uaccess.rs rust: uaccess: add typed accessors for userspace pointers 2024-07-08 23:44:01 +02:00
workqueue.rs rust: enable clippy::unnecessary_safety_comment lint 2025-03-13 13:01:41 +01:00