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

Components w/ const generics and other generics yields compilation error #1455

Closed
awesomelemonade opened this issue Jul 28, 2023 · 2 comments
Labels

Comments

@awesomelemonade
Copy link

Describe the bug
I wanted to do something like

#[component]
fn InfoGrid<const NUM_ROWS: usize, const NUM_COLS: usize>(
    cx: Scope,
    data: [[u32; NUM_ROWS]; NUM_COLS],
) -> impl IntoView {
    todo!()
}

which gets you

error: expected type, found `,`
   --> src/app.rs:108:1
    |
108 | #[component]
    | ^^^^^^^^^^^^
    | |
    | expected type
    | while parsing this struct
    |
    = note: this error originates in the derive macro `::leptos::typed_builder::TypedBuilder` (in Nightly builds, run with -Z macro-backtrace for more info)

error: proc-macro derive produced unparsable tokens
   --> src/app.rs:108:1
    |
108 | #[component]
    | ^^^^^^^^^^^^
    |
    = note: this error originates in the attribute macro `component` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0609]: no field `phantom` on type `InfoGridPropsBuilder<NUM_ROWS, NUM_COLS, ((), __cell_height, __data)>`
   --> src/app.rs:108:1
    |
108 | #[component]
    | ^^^^^^^^^^^^ unknown field
    |
    = note: available fields are: `fields`
    = note: this error originates in the derive macro `::leptos::typed_builder::TypedBuilder` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0609]: no field `phantom` on type `InfoGridPropsBuilder<NUM_ROWS, NUM_COLS, (__cell_width, (), __data)>`
   --> src/app.rs:108:1
    |
108 | #[component]
    | ^^^^^^^^^^^^ unknown field
    |
    = note: available fields are: `fields`
    = note: this error originates in the derive macro `::leptos::typed_builder::TypedBuilder` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0609]: no field `phantom` on type `InfoGridPropsBuilder<NUM_ROWS, NUM_COLS, (__cell_width, __cell_height, ())>`
   --> src/app.rs:108:1
    |
108 | #[component]
    | ^^^^^^^^^^^^ unknown field
    |
    = note: available fields are: `fields`
    = note: this error originates in the derive macro `::leptos::typed_builder::TypedBuilder` (in Nightly builds, run with -Z macro-backtrace for more info)

Investigating this, I realized it's a bug in deriving TypedBuilder. See idanarye/rust-typed-builder#106. Leptos would need to update its dependencies once fixed.

Leptos Dependencies

leptos = { version = "0.4", features = ["csr", "nightly"] }
leptos_meta = { version = "0.4", features = ["csr", "nightly"] }
leptos_router = { version = "0.4", features = ["csr", "nightly"] }
@gbj
Copy link
Collaborator

gbj commented Jul 29, 2023

Reading this and the linked issue it looks like something that needs to be fixed in typed-builder and that you've identified pretty specifically. I'd suggest that if you want to see it resolved here, making a PR there to fix the issue with the extra comma would be the fastest way!

@gbj gbj added the FYI label Jul 29, 2023
@awesomelemonade
Copy link
Author

Reading this and the linked issue it looks like something that needs to be fixed in typed-builder and that you've identified pretty specifically. I'd suggest that if you want to see it resolved here, making a PR there to fix the issue with the extra comma would be the fastest way!

made a PR and maintainer has merged it - we just need to bump the version from typed-builder = "0.14" to typed-builder = "0.15"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants