[PATCH] rust: init: Fix generics in *_init! macros

Janne Grunau via B4 Relay posted 1 patch 3 months, 1 week ago
rust/kernel/init.rs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
[PATCH] rust: init: Fix generics in *_init! macros
Posted by Janne Grunau via B4 Relay 3 months, 1 week ago
From: Janne Grunau <j@jannau.net>

The match pattern for a optional trailing comma in the list of generics
is erroneously repeated in the code block resulting in following error:

| error: attempted to repeat an expression containing no syntax variables matched as repeating at this depth
|    --> rust/kernel/init.rs:301:73
|     |
| 301 |         ::pin_init::try_pin_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? {
|     |                                                                         ^^^

Remove "$(,)?" from all code blocks in the try_init! and try_pin_init!
definitions.

Fixes: 578eb8b6db13 ("rust: pin-init: move the default error behavior of `try_[pin_]init`")
Signed-off-by: Janne Grunau <j@jannau.net>
---
 rust/kernel/init.rs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs
index 8d228c23795445e379b40f662e1c355a934cbd13..21ef202ab0dbfa3cb28cd20d29d9bfdba4f1f97f 100644
--- a/rust/kernel/init.rs
+++ b/rust/kernel/init.rs
@@ -231,14 +231,14 @@ macro_rules! try_init {
     ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
         $($fields:tt)*
     }) => {
-        ::pin_init::try_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? {
+        ::pin_init::try_init!($(&$this in)? $t $(::<$($generics),*>)? {
             $($fields)*
         }? $crate::error::Error)
     };
     ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
         $($fields:tt)*
     }? $err:ty) => {
-        ::pin_init::try_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? {
+        ::pin_init::try_init!($(&$this in)? $t $(::<$($generics),*>)? {
             $($fields)*
         }? $err)
     };
@@ -291,14 +291,14 @@ macro_rules! try_pin_init {
     ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
         $($fields:tt)*
     }) => {
-        ::pin_init::try_pin_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? {
+        ::pin_init::try_pin_init!($(&$this in)? $t $(::<$($generics),*>)? {
             $($fields)*
         }? $crate::error::Error)
     };
     ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
         $($fields:tt)*
     }? $err:ty) => {
-        ::pin_init::try_pin_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? {
+        ::pin_init::try_pin_init!($(&$this in)? $t $(::<$($generics),*>)? {
             $($fields)*
         }? $err)
     };

---
base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
change-id: 20250628-rust_init_trailing_comma-e4f1c9855462

Best regards,
-- 
Janne Grunau <j@jannau.net>
Re: [PATCH] rust: init: Fix generics in *_init! macros
Posted by Miguel Ojeda 3 months, 1 week ago
On Sat, Jun 28, 2025 at 1:36 PM Janne Grunau via B4 Relay
<devnull+j.jannau.net@kernel.org> wrote:
>
> From: Janne Grunau <j@jannau.net>
>
> The match pattern for a optional trailing comma in the list of generics
> is erroneously repeated in the code block resulting in following error:
>
> | error: attempted to repeat an expression containing no syntax variables matched as repeating at this depth
> |    --> rust/kernel/init.rs:301:73
> |     |
> | 301 |         ::pin_init::try_pin_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? {
> |     |                                                                         ^^^
>
> Remove "$(,)?" from all code blocks in the try_init! and try_pin_init!
> definitions.
>
> Fixes: 578eb8b6db13 ("rust: pin-init: move the default error behavior of `try_[pin_]init`")
> Signed-off-by: Janne Grunau <j@jannau.net>

Applied to `rust-fixes` -- thanks everyone!

    Cc: stable@vger.kernel.org

Cheers,
Miguel
Re: [PATCH] rust: init: Fix generics in *_init! macros
Posted by Benno Lossin 3 months, 1 week ago
On Sat Jun 28, 2025 at 1:36 PM CEST, Janne Grunau via B4 Relay wrote:
> From: Janne Grunau <j@jannau.net>
>
> The match pattern for a optional trailing comma in the list of generics
> is erroneously repeated in the code block resulting in following error:
>
> | error: attempted to repeat an expression containing no syntax variables matched as repeating at this depth
> |    --> rust/kernel/init.rs:301:73
> |     |
> | 301 |         ::pin_init::try_pin_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? {
> |     |                                                                         ^^^
>
> Remove "$(,)?" from all code blocks in the try_init! and try_pin_init!
> definitions.

Oops, that's a good catch! Seems like nobody used the generics before...

Do you need this to go in as a fix into v6.16, or is it fine if I pick
it for v6.17, since it's only a build failure?

@Miguel any opinion?

---
Cheers,
Benno

> Fixes: 578eb8b6db13 ("rust: pin-init: move the default error behavior of `try_[pin_]init`")
> Signed-off-by: Janne Grunau <j@jannau.net>
> ---
>  rust/kernel/init.rs | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
Re: [PATCH] rust: init: Fix generics in *_init! macros
Posted by Janne Grunau 3 months, 1 week ago
On Sat, Jun 28, 2025 at 02:29:11PM +0200, Benno Lossin wrote:
> On Sat Jun 28, 2025 at 1:36 PM CEST, Janne Grunau via B4 Relay wrote:
> > From: Janne Grunau <j@jannau.net>
> >
> > The match pattern for a optional trailing comma in the list of generics
> > is erroneously repeated in the code block resulting in following error:
> >
> > | error: attempted to repeat an expression containing no syntax variables matched as repeating at this depth
> > |    --> rust/kernel/init.rs:301:73
> > |     |
> > | 301 |         ::pin_init::try_pin_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? {
> > |     |                                                                         ^^^
> >
> > Remove "$(,)?" from all code blocks in the try_init! and try_pin_init!
> > definitions.
> 
> Oops, that's a good catch! Seems like nobody used the generics before...

Nobody upstream, it's used downstream in the asahi tree.

> Do you need this to go in as a fix into v6.16, or is it fine if I pick
> it for v6.17, since it's only a build failure?

I don't need it since I have to carry it anyway in the downstream tree
but I think it would be good idea to fix it in v6.16.
Since it's in the kernel crate (the macros in pin-init are fine) I'd
propose that Miguel picks it with other rust fixes.

Janne
Re: [PATCH] rust: init: Fix generics in *_init! macros
Posted by Benno Lossin 3 months, 1 week ago
On Sat Jun 28, 2025 at 3:25 PM CEST, Janne Grunau wrote:
> On Sat, Jun 28, 2025 at 02:29:11PM +0200, Benno Lossin wrote:
>> On Sat Jun 28, 2025 at 1:36 PM CEST, Janne Grunau via B4 Relay wrote:
>> > From: Janne Grunau <j@jannau.net>
>> >
>> > The match pattern for a optional trailing comma in the list of generics
>> > is erroneously repeated in the code block resulting in following error:
>> >
>> > | error: attempted to repeat an expression containing no syntax variables matched as repeating at this depth
>> > |    --> rust/kernel/init.rs:301:73
>> > |     |
>> > | 301 |         ::pin_init::try_pin_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? {
>> > |     |                                                                         ^^^
>> >
>> > Remove "$(,)?" from all code blocks in the try_init! and try_pin_init!
>> > definitions.
>> 
>> Oops, that's a good catch! Seems like nobody used the generics before...
>
> Nobody upstream, it's used downstream in the asahi tree.
>
>> Do you need this to go in as a fix into v6.16, or is it fine if I pick
>> it for v6.17, since it's only a build failure?
>
> I don't need it since I have to carry it anyway in the downstream tree
> but I think it would be good idea to fix it in v6.16.
> Since it's in the kernel crate (the macros in pin-init are fine) I'd
> propose that Miguel picks it with other rust fixes.

Sounds good!

Reviewed-by: Benno Lossin <lossin@kernel.org>

---
Cheers,
Benno
Re: [PATCH] rust: init: Fix generics in *_init! macros
Posted by Miguel Ojeda 3 months, 1 week ago
On Sat, Jun 28, 2025 at 2:29 PM Benno Lossin <lossin@kernel.org> wrote:
>
> Oops, that's a good catch! Seems like nobody used the generics before...
>
> Do you need this to go in as a fix into v6.16, or is it fine if I pick
> it for v6.17, since it's only a build failure?
>
> @Miguel any opinion?

If it is a fix, then we can just pick it. I have to send others
anyway, so I will be doing a fixes PR in a week or so.

Cheers,
Miguel