leptos-rs/leptos · error

keyword argument repeated: `impl_from`

Error message

keyword argument repeated: `impl_from`

What it means

This error is raised when the `impl_from` keyword argument appears more than once in a #[server] attribute. `impl_from` is a boolean flag that generates From impls; repeating it is ambiguous (or contradictory if the values differ), so the parser fails compilation with a span on the repeated key.

Source

Thrown at server_fn_macro/src/lib.rs:1165

                    } else if key == "server" {
                        if server.is_some() {
                            return Err(syn::Error::new(
                                key.span(),
                                "keyword argument repeated: `server`",
                            ));
                        }
                        server = Some(stream.parse()?);
                    } else if key == "client" {
                        if client.is_some() {
                            return Err(syn::Error::new(
                                key.span(),
                                "keyword argument repeated: `client`",
                            ));
                        }
                        client = Some(stream.parse()?);
                    } else if key == "custom" {
                        if custom_wrapper.is_some() {
                            return Err(syn::Error::new(
                                key.span(),
                                "keyword argument repeated: `custom`",
                            ));
                        }
                        custom_wrapper = Some(stream.parse()?);
                    } else if key == "impl_from" {
                        if impl_from.is_some() {
                            return Err(syn::Error::new(
                                key.span(),
                                "keyword argument repeated: `impl_from`",
                            ));
                        }
                        impl_from = Some(stream.parse()?);
                    } else if key == "impl_deref" {
                        if impl_deref.is_some() {
                            return Err(syn::Error::new(
                                key.span(),
                                "keyword argument repeated: `impl_deref`",

View on GitHub (pinned to 32d20f6c9d)

Solutions

  1. Keep a single `impl_from = ...` entry.
  2. Remove the flag entirely to accept the default behavior.
  3. Make wrapper macros append `impl_from` only when the caller did not specify it.

Example fix

// before
#[server(impl_from = true, impl_from = false)]
async fn save(data: String) -> Result<(), ServerFnError> { todo!() }

// after
#[server(impl_from = true)]
async fn save(data: String) -> Result<(), ServerFnError> { todo!() }
Defensive patterns

Strategy: validation

Validate before calling

// Pre-commit check for duplicate `impl_from` args:
// grep -rnE '#\[server\([^)\n]*impl_from\s*=[^)\n]*impl_from\s*=' src/ && exit 1 || exit 0

Prevention

When it happens

Trigger: Writing #[server(impl_from = true, impl_from = false)] or any other duplicate of `impl_from`, often from a macro wrapper adding the flag on top of a user-supplied value.

Common situations: Copy-paste of attribute lines, macro_rules! wrappers that unconditionally append impl_from, refactoring flag values without deleting the old entry.

Related errors


AI-assisted analysis of leptos-rs/leptos@32d20f6c9d (2026-09-01). Data as JSON: /api/errors/f776798890e66d18. Report an issue: GitHub.