astral-sh/ruff · error · syn::Error

Can only derive CombineOptions from structs with named…

Error message

Can only derive CombineOptions from structs with named fields.

What it means

A syn compile error from the CombineOptions derive macro: the target is not a struct with named fields (tuple struct, unit struct, enum, or union). The generated combine logic assigns fields by name, so other shapes are rejected.

Solutions

  1. Give the struct named fields
  2. Implement CombineOptions manually for this shape
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/ruff_macros/src/combine_options.rs:32 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of astral-sh/ruff@26f38c119c (2026-09-05). Data as JSON: /api/errors/dd0345dacaf9ace6. Report an issue: GitHub.

Appendix: source

Thrown at crates/ruff_macros/src/combine_options.rs:32

                .iter()
                .map(handle_field)
                .collect::<Result<Vec<_>, _>>()?;

            Ok(quote! {
                #[automatically_derived]
                impl crate::configuration::CombinePluginOptions for #ident {
                    fn combine(self, other: Self) -> Self {
                        #[expect(deprecated)]
                        Self {
                        #(
                            #output
                        ),*
                        }
                    }
                }
            })
        }
        _ => Err(syn::Error::new(
            ident.span(),
            "Can only derive CombineOptions from structs with named fields.",
        )),
    }
}

fn handle_field(field: &Field) -> syn::Result<proc_macro2::TokenStream> {
    let ident = field
        .ident
        .as_ref()
        .expect("Expected to handle named fields");

    match &field.ty {
        Type::Path(TypePath {
            path: Path { segments, .. },
            ..
        }) => match segments.first() {
            Some(PathSegment {

View on GitHub (pinned to 26f38c119c)