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

Can only derive Combine from structs.

Error message

Can only derive Combine from structs.

What it means

A syn compile error from the Combine derive macro: it was applied to something other than a struct (e.g. an enum or union). The derive generates field-by-field combine_with logic, which only makes sense for structs.

Source

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

                    quote_spanned!(
                        member.span() => ty_combine::Combine::combine_with(&mut self.#member, other.#member)
                    )
                })
                .collect();

            Ok(quote! {
                #[automatically_derived]
                impl ty_combine::Combine for #ident {
                    #[allow(deprecated)]
                    fn combine_with(&mut self, other: Self) {
                        #(
                            #output
                        );*
                    }
                }
            })
        }
        _ => Err(syn::Error::new(
            ident.span(),
            "Can only derive Combine from structs.",
        )),
    }
}

View on GitHub (pinned to 26f38c119c)

Solutions

  1. Implement ty_combine::Combine manually for the non-struct type
  2. Apply the derive only to structs
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/ruff_macros/src/combine.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/28a430717189c076. Report an issue: GitHub.