All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Benno Lossin" <lossin@kernel.org>
To: "Maurice Hieronymus" <mhi@mailbox.org>, <dakr@kernel.org>
Cc: aliceryhl@google.com, acourbot@nvidia.com, simona@ffwll.ch,
	nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, ojeda@kernel.org,
	boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com,
	a.hindborg@kernel.org, tmgross@umich.edu,
	rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v2 1/2] rust: macros: Add derive Display for enums
Date: Mon, 05 Jan 2026 10:02:59 +0100	[thread overview]
Message-ID: <DFGJ8UBULO54.NRW84R2DTHIK@kernel.org> (raw)
In-Reply-To: <20260104200733.190494-2-mhi@mailbox.org>

On Sun Jan 4, 2026 at 9:07 PM CET, Maurice Hieronymus wrote:
> Add a derive macro that implements kernel::fmt::Display for enums.
> The macro outputs the exact variant name as written, preserving case.
>
> This supports all enum variant types: unit, tuple, and struct variants.
> For variants with data, only the variant name is displayed.

I don't think we should be adding this. Display is designed for
user-facing output and so it should always be carefully designed and no
automation should exist for it.

The use-case in the second patch is also much better served by either a
manual match on the enum:

    impl fmt::Display for Chipset {
        fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
            match self {
                Chipset::Variant => write!(f, "Variant"),
                // ...
            }
        }
    }

Or by adding the respective code in the declarative macro already used
to define it.

Cheers,
Benno

> Signed-off-by: Maurice Hieronymus <mhi@mailbox.org>
> ---
>  rust/macros/display.rs | 52 ++++++++++++++++++++++++++++++++++++++++++
>  rust/macros/lib.rs     | 42 ++++++++++++++++++++++++++++++++++
>  2 files changed, 94 insertions(+)
>  create mode 100644 rust/macros/display.rs

WARNING: multiple messages have this Message-ID (diff)
From: "Benno Lossin" <lossin@kernel.org>
To: "Maurice Hieronymus" <mhi@mailbox.org>, <dakr@kernel.org>
Cc: <aliceryhl@google.com>, <acourbot@nvidia.com>,
	<airlied@gmail.com>, <simona@ffwll.ch>,
	<nouveau@lists.freedesktop.org>,
	<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
	<ojeda@kernel.org>, <boqun.feng@gmail.com>, <gary@garyguo.net>,
	<bjorn3_gh@protonmail.com>, <a.hindborg@kernel.org>,
	<tmgross@umich.edu>, <rust-for-linux@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] rust: macros: Add derive Display for enums
Date: Mon, 05 Jan 2026 10:02:59 +0100	[thread overview]
Message-ID: <DFGJ8UBULO54.NRW84R2DTHIK@kernel.org> (raw)
In-Reply-To: <20260104200733.190494-2-mhi@mailbox.org>

On Sun Jan 4, 2026 at 9:07 PM CET, Maurice Hieronymus wrote:
> Add a derive macro that implements kernel::fmt::Display for enums.
> The macro outputs the exact variant name as written, preserving case.
>
> This supports all enum variant types: unit, tuple, and struct variants.
> For variants with data, only the variant name is displayed.

I don't think we should be adding this. Display is designed for
user-facing output and so it should always be carefully designed and no
automation should exist for it.

The use-case in the second patch is also much better served by either a
manual match on the enum:

    impl fmt::Display for Chipset {
        fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
            match self {
                Chipset::Variant => write!(f, "Variant"),
                // ...
            }
        }
    }

Or by adding the respective code in the declarative macro already used
to define it.

Cheers,
Benno

> Signed-off-by: Maurice Hieronymus <mhi@mailbox.org>
> ---
>  rust/macros/display.rs | 52 ++++++++++++++++++++++++++++++++++++++++++
>  rust/macros/lib.rs     | 42 ++++++++++++++++++++++++++++++++++
>  2 files changed, 94 insertions(+)
>  create mode 100644 rust/macros/display.rs

  reply	other threads:[~2026-01-05  9:03 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-04 20:07 [PATCH v2 0/2] rust: macros: Add derive Display for enums Maurice Hieronymus
2026-01-04 20:07 ` Maurice Hieronymus
2026-01-04 20:07 ` [PATCH v2 1/2] " Maurice Hieronymus
2026-01-04 20:07   ` Maurice Hieronymus
2026-01-05  9:02   ` Benno Lossin [this message]
2026-01-05  9:02     ` Benno Lossin
2026-01-05 10:29     ` Danilo Krummrich
2026-01-05 10:29       ` Danilo Krummrich
2026-01-05 14:42       ` Benno Lossin
2026-01-05 14:42         ` Benno Lossin
2026-01-05 15:00         ` Danilo Krummrich
2026-01-05 15:00           ` Danilo Krummrich
2026-01-05 15:23           ` Maurice Hieronymus
2026-01-05 15:23             ` Maurice Hieronymus
2026-01-05 16:11       ` Gary Guo
2026-01-05 16:11         ` Gary Guo
2026-01-05 21:11         ` Maurice Hieronymus
2026-01-05 21:11           ` Maurice Hieronymus
2026-01-05 22:03           ` Danilo Krummrich
2026-01-05 22:03             ` Danilo Krummrich
2026-01-06  5:56             ` Maurice Hieronymus
2026-01-06  5:56               ` Maurice Hieronymus
2026-01-06 12:56               ` Benno Lossin
2026-01-06 12:56                 ` Benno Lossin
2026-01-04 20:07 ` [PATCH v2 2/2] gpu: nova-core: Use derive Display for Chipset enum Maurice Hieronymus
2026-01-04 20:07   ` Maurice Hieronymus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DFGJ8UBULO54.NRW84R2DTHIK@kernel.org \
    --to=lossin@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhi@mailbox.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tmgross@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.