rust: init: Fix generics in *_init! macros
Subsystems (2)
PATCH 1/1 rust: init: Fix generics in *_init! macros
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.
--- rust/kernel/init.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
rust/kernel/init.rs +4 -4
@@ -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,
Signature · 1 line
Janne Grunau <[email protected]>
Benno Lossin
maintainerQuoted 5 lines · On Sat Jun 28, 2025 at 1:36 PM CEST, Janne Grunau via B4 Relay wrote:
From: Janne Grunau <[email protected]>
The match pattern for a optional trailing comma in the list of generics is erroneously repeated in the code block resulting in following error:
Quoted 8 lines
| 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! andtry_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
Quoted 5 lines
Fixes 578eb8b6db13 ("rust: pin-init: move the default error behavior of `try_[pin_]init`")Signed-off-by Janne Grunau <[email protected]>--- rust/kernel/init.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Quoted 7 lines · Benno Lossin
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
Quoted 12 lines · Benno Lossin
Quoted 11 lines · On Sat Jun 28, 2025 at 1:36 PM CEST, Janne Grunau via B4 Relay wrote:
From: Janne Grunau <[email protected]>
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),* $(,)?>)? { | | ^^^
Quoted 4 lines
Quoted 2 lines
Remove "$(,)?" from all code blocks in the
try_init! andtry_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.
Quoted 2 lines
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
Quoted 20 lines · Janne Grunau
Quoted 12 lines · Benno Lossin
Quoted 11 lines · On Sat Jun 28, 2025 at 1:36 PM CEST, Janne Grunau via B4 Relay wrote:
From: Janne Grunau <[email protected]>
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),* $(,)?>)? { | | ^^^Quoted 4 lines
Quoted 2 lines
Remove "$(,)?" from all code blocks in the
try_init! andtry_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.
Quoted 7 lines
Quoted 2 lines
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!
---
Cheers,
Benno
Miguel Ojeda
AppliedQuoted 12 lines · On Sat, Jun 28, 2025 at 1:36 PM Janne Grunau via B4 Relay…
From: Janne Grunau <[email protected]>
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),* $(,)?>)? { | | ^^^
Quoted 5 lines
Remove "$(,)?" from all code blocks in the
try_init! andtry_pin_init! definitions.Fixes 578eb8b6db13 ("rust: pin-init: move the default error behavior of `try_[pin_]init`")Signed-off-by Janne Grunau <[email protected]>
Applied to rust-fixes -- thanks everyone!
Cheers,
Miguel