Re: [PATCH 12/19] rust: replace `clippy::dbg_macro` with `disallowed_macros`

Geert Stappers
2024-09-05T05:20:50Z

On Wed, Sep 04, 2024 at 10:43:40PM +0200, Miguel Ojeda wrote:
> diff --git a/.clippy.toml b/.clippy.toml
> index f66554cd5c45..ad9f804fb677 100644
> --- a/.clippy.toml
> +++ b/.clippy.toml
> @@ -1 +1,7 @@
> # SPDX-License-Identifier: GPL-2.0
> +
> +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" },
> +]
> diff --git a/rust/kernel/std_vendor.rs b/rust/kernel/std_vendor.rs
> index 67bf9d37ddb5..085b23312c65 100644
> --- a/rust/kernel/std_vendor.rs
> +++ b/rust/kernel/std_vendor.rs
> @@ -14,7 +14,7 @@
> -/// # #[allow(clippy::dbg_macro)]
> +/// # #[allow(clippy::disallowed_macros)]
> @@ -52,7 +52,7 @@
> -/// # #[allow(clippy::dbg_macro)]
> +/// # #[allow(clippy::disallowed_macros)]
> @@ -71,7 +71,7 @@
> -/// # #[allow(clippy::dbg_macro)]
> +/// # #[allow(clippy::disallowed_macros)]
> @@ -118,7 +118,7 @@
> /// a tuple (and return it, too):
> ///
> /// ```
> -/// # #[allow(clippy::dbg_macro)]
> +/// # #![allow(clippy::disallowed_macros)]
> /// assert_eq!(dbg!(1usize, 2u32), (1, 2));
> /// ```
> ///

For what it is worth, the exclamation mark did surprise me.

> @@ -127,7 +127,7 @@
> ///
> /// ```
> -/// # #[allow(clippy::dbg_macro)]
> +/// # #[allow(clippy::disallowed_macros)]
> /// # {
> /// assert_eq!(1, dbg!(1u32,)); // trailing comma ignored
> /// assert_eq!((1,), dbg!((1u32,))); // 1-tuple

Groeten
Geert Stappers
--
Silence is hard to parse