astral-sh/ruff · error · syn::Error
only named fields are supported
Error message
only named fields are supported
What it means
A syn compile error from the RuleNamespace derive: the input is not an enum (the destructuring expects Data::Enum with named-field variants). The derive builds prefix-to-linter mappings from enum variants, so structs/unions are rejected.
Source
Thrown at crates/ruff_macros/src/rule_namespace.rs:15
use std::cmp::Reverse;
use std::collections::HashSet;
use quote::quote;
use syn::spanned::Spanned;
use syn::{Attribute, Data, DataEnum, DeriveInput, Error, ExprLit, Lit, Meta, MetaNameValue};
pub(crate) fn derive_impl(input: DeriveInput) -> syn::Result<proc_macro2::TokenStream> {
let DeriveInput {
ident,
data: Data::Enum(DataEnum { variants, .. }),
..
} = input
else {
return Err(Error::new(
input.ident.span(),
"only named fields are supported",
));
};
let mut parsed = Vec::new();
let mut common_prefix_match_arms = quote!();
let mut name_match_arms =
quote!(Self::Ruff => "Ruff-specific rules", Self::Numpy => "NumPy-specific rules", );
let mut url_match_arms = quote!(Self::Ruff => None, Self::Numpy => None, );
let mut all_prefixes = HashSet::new();
for variant in variants {
let mut first_chars = HashSet::new();
let prefixes: Result<Vec<_>, _> = variant
.attrsView on GitHub (pinned to 26f38c119c)
Solutions
- Apply the derive only to enums with named fields
- Implement the namespace mapping manually for other shapes
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/ruff_macros/src/rule_namespace.rs:15 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/3d51b6330f3cc1fd.
Report an issue: GitHub.