linebender/druid · error

Expected attribute list (the form #[lens(one, two)])

Error message

Expected attribute list (the form #[lens(one, two)])

What it means

The #[lens(...)] helper attribute must be a meta list of the form #[lens(one, two)]. If it appears as a bare path (#[lens]) or in name-value form (#[lens = "x"]), the parser emits this compile-time error describing the expected shape.

Solutions

  1. Use the list form: #[lens(ignore)] or #[lens(name = "...")].
  2. Remove the attribute entirely if no option is needed.
  3. Consult the derive docs for the exact accepted syntax in your druid version.

Example fix

// before
#[lens]
inner: Vec<Widget>,
// after
#[lens(ignore)]
inner: Vec<Widget>,
Defensive patterns

Strategy: validation

Validate before calling

// Ensure every lens helper attribute uses list form before compiling:
fn assert_list_form(attr_src: &str) {
    assert!(attr_src.contains("lens("), "#[lens(...)] must use list form: {}", attr_src);
}

Prevention

When it happens

Trigger: Using #[lens] with no arguments on a field, or #[lens = "value"], when parse_ast expects a parenthesized attribute list.

Common situations: Forgetting parentheses, thinking the bare attribute alone marks the field, syntax carried over from other derive crates.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of linebender/druid@0f8b1195e4 (2026-09-10). Data as JSON: /api/errors/926406fdb654ec94. Report an issue: GitHub.

Appendix: source

Thrown at druid-derive/src/attr.rs:244

                                    }
                                    ignore = true;
                                }
                                NestedMeta::Meta(Meta::NameValue(meta))
                                    if meta.path.is_ident(LENS_NAME_OVERRIDE_ATTR_PATH) =>
                                {
                                    if lens_name_override.is_some() {
                                        return Err(Error::new(meta.span(), "Duplicate attribute"));
                                    }

                                    let ident = parse_lit_into_ident(&meta.lit)?;
                                    lens_name_override = Some(ident);
                                }
                                other => return Err(Error::new(other.span(), "Unknown attribute")),
                            }
                        }
                    }
                    other => {
                        return Err(Error::new(
                            other.span(),
                            "Expected attribute list (the form #[lens(one, two)])",
                        ));
                    }
                }
            }
        }
        Ok(Field {
            ident,
            ty,
            attrs: LensAttrs {
                ignore,
                lens_name_override,
            },
        })
    }
}

View on GitHub (pinned to 0f8b1195e4)