summaryrefslogtreecommitdiffstats
path: root/samples/rust/rust_print.rs
diff options
context:
space:
mode:
authorMiguel Ojeda <ojeda@kernel.org>2024-09-04 22:43:40 +0200
committerMiguel Ojeda <ojeda@kernel.org>2024-10-07 21:39:05 +0200
commit8577c9dca799bd74377f7c30015d8cdc53a53ca2 (patch)
tree78663eb452bc0c76ac423465aaa4d152bd11132a /samples/rust/rust_print.rs
parentrust: introduce `.clippy.toml` (diff)
downloadlinux-8577c9dca799bd74377f7c30015d8cdc53a53ca2.tar.xz
linux-8577c9dca799bd74377f7c30015d8cdc53a53ca2.zip
rust: replace `clippy::dbg_macro` with `disallowed_macros`
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>
Diffstat (limited to '')
-rw-r--r--samples/rust/rust_print.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/samples/rust/rust_print.rs b/samples/rust/rust_print.rs
index 6eabb0d79ea3..ed1137ab2018 100644
--- a/samples/rust/rust_print.rs
+++ b/samples/rust/rust_print.rs
@@ -15,6 +15,7 @@ module! {
struct RustPrint;
+#[allow(clippy::disallowed_macros)]
fn arc_print() -> Result {
use kernel::sync::*;