From: "Gary Guo" <gary@garyguo.net>
To: "Alice Ryhl" <aliceryhl@google.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Danilo Krummrich" <dakr@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>
Cc: <driver-core@lists.linux.dev>, <rust-for-linux@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH] rust: device: avoid trailing ; in printing macros
Date: Thu, 16 Jul 2026 15:00:03 +0100 [thread overview]
Message-ID: <DK01SW0X7PXH.15BGNJS3Q18BL@garyguo.net> (raw)
In-Reply-To: <20260716-device-trail-semicolon-v1-1-f48e9dcfae15@google.com>
On Thu Jul 16, 2026 at 11:22 AM BST, Alice Ryhl wrote:
> These macros are used like expressions, so they should must not emit a
> semicolon. This is being turned into a hard error in a future release of
> Rust.
>
> error: trailing semicolon in macro used in expression position
> --> drivers/gpu/nova-core/firmware/fsp.rs:79:34
> |
> 79 | .inspect_err(|_| dev_err!(dev, "FMC firmware missing '{}' section\n", name))
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> |
> = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
> = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
> = note: this error originates in the macro `dev_err` (in Nightly builds, run with -Z macro-backtrace for more info)
>
> Cc: stable@vger.kernel.org
> Fixes: 5c7ca6fa603f ("rust: add `dev_*` print macros.")
I suppose this can also be argued to be a fix to the user that use them in
non-statement positions (by saying that original implementation is for
statement-position only and expression-position usage is an improvement).
But either way:
Reviewed-by: Gary Guo <gary@garyguo.net>
Best,
Gary
> Link: https://github.com/rust-lang/rust/issues/79813
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
> ---
> rust/kernel/device.rs | 20 +++++++++-----------
> 1 file changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/rust/kernel/device.rs b/rust/kernel/device.rs
> index 645afc49a27d..1a38b3bbdfb7 100644
> --- a/rust/kernel/device.rs
> +++ b/rust/kernel/device.rs
> @@ -708,9 +708,7 @@ macro_rules! impl_device_context_into_aref {
> #[macro_export]
> macro_rules! dev_printk {
> ($method:ident, $dev:expr, $($f:tt)*) => {
> - {
> - $crate::device::Device::$method($dev.as_ref(), $crate::prelude::fmt!($($f)*))
> - }
> + $crate::device::Device::$method($dev.as_ref(), $crate::prelude::fmt!($($f)*))
> }
> }
>
> @@ -737,7 +735,7 @@ macro_rules! dev_printk {
> /// ```
> #[macro_export]
> macro_rules! dev_emerg {
> - ($($f:tt)*) => { $crate::dev_printk!(pr_emerg, $($f)*); }
> + ($($f:tt)*) => { $crate::dev_printk!(pr_emerg, $($f)*) }
> }
>
> /// Prints an alert-level message (level 1) prefixed with device information.
> @@ -763,7 +761,7 @@ macro_rules! dev_emerg {
> /// ```
> #[macro_export]
> macro_rules! dev_alert {
> - ($($f:tt)*) => { $crate::dev_printk!(pr_alert, $($f)*); }
> + ($($f:tt)*) => { $crate::dev_printk!(pr_alert, $($f)*) }
> }
>
> /// Prints a critical-level message (level 2) prefixed with device information.
> @@ -789,7 +787,7 @@ macro_rules! dev_alert {
> /// ```
> #[macro_export]
> macro_rules! dev_crit {
> - ($($f:tt)*) => { $crate::dev_printk!(pr_crit, $($f)*); }
> + ($($f:tt)*) => { $crate::dev_printk!(pr_crit, $($f)*) }
> }
>
> /// Prints an error-level message (level 3) prefixed with device information.
> @@ -815,7 +813,7 @@ macro_rules! dev_crit {
> /// ```
> #[macro_export]
> macro_rules! dev_err {
> - ($($f:tt)*) => { $crate::dev_printk!(pr_err, $($f)*); }
> + ($($f:tt)*) => { $crate::dev_printk!(pr_err, $($f)*) }
> }
>
> /// Prints a warning-level message (level 4) prefixed with device information.
> @@ -841,7 +839,7 @@ macro_rules! dev_err {
> /// ```
> #[macro_export]
> macro_rules! dev_warn {
> - ($($f:tt)*) => { $crate::dev_printk!(pr_warn, $($f)*); }
> + ($($f:tt)*) => { $crate::dev_printk!(pr_warn, $($f)*) }
> }
>
> /// Prints a notice-level message (level 5) prefixed with device information.
> @@ -867,7 +865,7 @@ macro_rules! dev_warn {
> /// ```
> #[macro_export]
> macro_rules! dev_notice {
> - ($($f:tt)*) => { $crate::dev_printk!(pr_notice, $($f)*); }
> + ($($f:tt)*) => { $crate::dev_printk!(pr_notice, $($f)*) }
> }
>
> /// Prints an info-level message (level 6) prefixed with device information.
> @@ -893,7 +891,7 @@ macro_rules! dev_notice {
> /// ```
> #[macro_export]
> macro_rules! dev_info {
> - ($($f:tt)*) => { $crate::dev_printk!(pr_info, $($f)*); }
> + ($($f:tt)*) => { $crate::dev_printk!(pr_info, $($f)*) }
> }
>
> /// Prints a debug-level message (level 7) prefixed with device information.
> @@ -919,5 +917,5 @@ macro_rules! dev_info {
> /// ```
> #[macro_export]
> macro_rules! dev_dbg {
> - ($($f:tt)*) => { $crate::dev_printk!(pr_dbg, $($f)*); }
> + ($($f:tt)*) => { $crate::dev_printk!(pr_dbg, $($f)*) }
> }
>
> ---
> base-commit: a13c140cc289c0b7b3770bce5b3ad42ab35074aa
> change-id: 20260716-device-trail-semicolon-1c02e29ea1cf
>
> Best regards,
next prev parent reply other threads:[~2026-07-16 14:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 10:22 [PATCH] rust: device: avoid trailing ; in printing macros Alice Ryhl
2026-07-16 12:17 ` Miguel Ojeda
2026-07-16 13:48 ` Danilo Krummrich
2026-07-16 14:28 ` Miguel Ojeda
2026-07-16 14:00 ` Gary Guo [this message]
2026-07-16 14:28 ` Miguel Ojeda
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=DK01SW0X7PXH.15BGNJS3Q18BL@garyguo.net \
--to=gary@garyguo.net \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox