leptos-rs/leptos · error

keyword argument repeated: `impl_deref`

Error message

keyword argument repeated: `impl_deref`

What it means

The #[server] macro parses each keyword argument only once. When the same keyword (here `impl_from`) appears a second time in the attribute list, the parser raises this syn error at the duplicated key's span, because re-assigning a single Option field would silently override the first value.

Source

Thrown at server_fn_macro/src/lib.rs:1173

                    } 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`",
                            ));
                        }
                        impl_deref = Some(stream.parse()?);
                    } else if key == "protocol" {
                        if protocol.is_some() {
                            return Err(syn::Error::new(
                                key.span(),
                                "keyword argument repeated: `protocol`",

View on GitHub (pinned to 32d20f6c9d)

Solutions

  1. Remove the duplicate `impl_from` key, keeping only one occurrence.
  2. If both values differ, decide which behavior you want and keep that one.
  3. Split genuinely different configuration into distinct options (e.g. `impl_from` vs `custom`) rather than repeating a key.

Example fix

// before
#[server(impl_from = true, impl_from = false)]
// after
#[server(impl_from = true)]
Defensive patterns

Strategy: validation

Validate before calling

// Check the attribute before compiling:
// grep -c 'impl_from' on the #[server(...)] line must be <= 1
let attr = "#[server(impl_from = true, impl_from = false)]";
let count = attr.matches("impl_from").count();
assert!(count <= 1, "duplicate `impl_from` in #[server]");

Prevention

When it happens

Trigger: Writing #[server(impl_from = true, impl_from = false)] on an async fn; copy-pasting attribute options and leaving a duplicate key; merging two #[server(...)] attribute lines into one and keeping both `impl_from` entries.

Common situations: Developers scaffolding many server functions from a template, or combining macro options during a refactor (e.g. adding `impl_from` while an older copy of the option was already present).

Related errors


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