{"record":{"id":"96556ee42dd53b3d","repo":"astral-sh/ruff","slug":"expected-option-or-vec-as-type","errorCode":null,"errorMessage":"Expected `Option<_>` or `Vec<_>` as type.","messagePattern":"Expected `Option<_>` or `Vec<_>` as type\\.","errorType":"exception","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/ruff_macros/src/combine_options.rs","lineNumber":55,"sourceCode":"}\n\nfn handle_field(field: &Field) -> syn::Result<proc_macro2::TokenStream> {\n    let ident = field\n        .ident\n        .as_ref()\n        .expect(\"Expected to handle named fields\");\n\n    match &field.ty {\n        Type::Path(TypePath {\n            path: Path { segments, .. },\n            ..\n        }) => match segments.first() {\n            Some(PathSegment {\n                ident: type_ident, ..\n            }) if type_ident == \"Option\" => Ok(quote_spanned!(\n                ident.span() => #ident: self.#ident.or(other.#ident)\n            )),\n            _ => Err(syn::Error::new(\n                ident.span(),\n                \"Expected `Option<_>` or `Vec<_>` as type.\",\n            )),\n        },\n        _ => Err(syn::Error::new(ident.span(), \"Expected type.\")),\n    }\n}\n","sourceCodeStart":37,"sourceCodeEnd":63,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_macros/src/combine_options.rs#L37-L63","documentation":"A syn compile error from CombineOptions::handle_field: the field's type is a path whose first segment is neither Option nor Vec. The derive only knows how to merge Optional (or-with) and Vec (concat) fields, so any other generic path is rejected at compile time.","triggerScenarios":"Thrown at crates/ruff_macros/src/combine_options.rs:55 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Change the field type to Option<_> or Vec<_>","Implement the option's combine logic manually instead of deriving"],"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-14T05:17:10.506Z"}