{"record":{"id":"1e84aa715c0e8b23","repo":"astral-sh/ruff","slug":"a-new-type-index-cannot-have-any-fields","errorCode":null,"errorMessage":"A new type index cannot have any fields.","messagePattern":"A new type index cannot have any fields\\.","errorType":"exception","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/ruff_macros/src/newtype_index.rs","lineNumber":7,"sourceCode":"use quote::quote;\nuse syn::spanned::Spanned;\nuse syn::{Error, ItemStruct};\n\npub(super) fn generate_newtype_index(item: ItemStruct) -> syn::Result<proc_macro2::TokenStream> {\n    if !item.fields.is_empty() {\n        return Err(Error::new(\n            item.span(),\n            \"A new type index cannot have any fields.\",\n        ));\n    }\n\n    if !item.generics.params.is_empty() {\n        return Err(Error::new(\n            item.span(),\n            \"A new type index cannot be generic.\",\n        ));\n    }\n\n    let ItemStruct {\n        attrs,\n        vis,\n        struct_token,\n        ident,\n        generics: _,","sourceCodeStart":1,"sourceCodeEnd":25,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_macros/src/newtype_index.rs#L1-L25","documentation":"A syn compile error from the newtype_index macro: the annotated struct declares fields. Newtype indexes are zero-sized marker types wrapping an index elsewhere, so any field makes the generated index type invalid.","triggerScenarios":"Thrown at crates/ruff_macros/src/newtype_index.rs:7 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove all fields from the struct","Use a regular struct type if fields are needed"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"26f38c119cac42e4d320ba08f09224fdec74af2c","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}