Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TasmObject derive can't handle trailing comma in where clause. #91

Open
dan-da opened this issue Mar 26, 2024 · 0 comments
Open

TasmObject derive can't handle trailing comma in where clause. #91

dan-da opened this issue Mar 26, 2024 · 0 comments

Comments

@dan-da
Copy link
Contributor

dan-da commented Mar 26, 2024

TasmObject derive macro output fails to build when the target struct has a trailing comma in a where clause.

Does not build:

case: where clause, trailing comma, TasmObject derive

#[derive(BFieldCodec, TasmObject)]
pub struct Foo<T>
where T: BFieldCodec, {
    t_list: Vec<T>,
}

Error:

error: expected one of `{`, lifetime, or type, found `,`
  --> src/util_types/mmr/mmr_accumulator.rs:30:23
   |
30 | #[derive(BFieldCodec, TasmObject)]
   |                       ^^^^^^^^^^ expected one of `{`, lifetime, or type
   |
   = note: this error originates in the derive macro `TasmObject` (in Nightly builds, run with -Z macro-backtrace for more info)

error: proc-macro derive produced unparsable tokens
  --> src/util_types/mmr/mmr_accumulator.rs:30:23
   |
30 | #[derive(BFieldCodec, TasmObject)]
   |                       ^^^^^^^^^^

Variations that build

case: where clause, trailing comma, no TasmObject derive

#[derive(BFieldCodec)]
pub struct Foo<T>
where T: BFieldCodec, {
    t_list: Vec<T>,
}

case: no where clause, no trailing comma, TasmObject derive

#[derive(BFieldCodec, TasmObject)]
pub struct Foo<T: BFieldCodec> {
    t_list: Vec<T>,
}

case: no where clause, trailing comma, TasmObject derive

#[derive(BFieldCodec, TasmObject)]
pub struct Foo<T: BFieldCodec,> {
    t_list: Vec<T>,
}

case: where clause, no trailing comma, TasmObject derive

#[derive(BFieldCodec, TasmObject)]
pub struct Foo<T>
where T: BFieldCodec {
    t_list: Vec<T>,
}
dan-da added a commit that referenced this issue Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant