{"record":{"id":"6b2598785c3d7f5e","repo":"diesel-rs/diesel","slug":"type-name-and-type-case-are-mutually-exclusive","errorCode":null,"errorMessage":"type_name and type_case are mutually exclusive","messagePattern":"type_name and type_case are mutually exclusive","errorType":"exception","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"dsl_auto_type/src/auto_type/mod.rs","lineNumber":96,"sourceCode":"        settings_input.type_case,\n    ) {\n        (false, None, None) => None,\n        (true, None, None) => {\n            // By default be consistent with call expressions, for when other will refer\n            // this query fragment in another auto_type function\n            Some(\n                inferrer_settings\n                    .function_types_case\n                    .ident_with_case(function_name),\n            )\n        }\n        (_, Some(ident), None) => Some(ident),\n        (_, None, Some(case)) => {\n            let case = Case::from_str(case.as_str(), case.span())?;\n            Some(case.ident_with_case(function_name))\n        }\n        (_, Some(_), Some(type_case)) => {\n            return Err(syn::Error::new(\n                type_case.span(),\n                \"type_name and type_case are mutually exclusive\",\n            )\n            .into());\n        }\n    };\n\n    let last_statement = input_function.block.stmts.last().ok_or_else(|| {\n        syn::Error::new(\n            input_function.span(),\n            \"function body should not be empty for auto_type\",\n        )\n    })?;\n    let mut errors = Vec::new();\n    let return_type = match input_function.sig.output {\n        syn::ReturnType::Type(_, return_type) => {\n            let return_expression = match last_statement {\n                syn::Stmt::Expr(expr, None) => expr,","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/diesel-rs/diesel/blob/6fa6ed01b24b24248ab2a611698d0a7c6a2e9120/dsl_auto_type/src/auto_type/mod.rs#L78-L114","documentation":"`type_name` (an explicit identifier for the generated type alias) and `type_case` (which naming convention/case to apply to the function name) are two ways to determine the alias's name and are mutually exclusive; specifying both is ambiguous, so auto_type_impl returns this compile error from the attribute-option match arm.","triggerScenarios":"`#[auto_type(type_alias, type_name = \"MyAlias\", type_case = \"PascalCase\")]` — both Some(ident) and Some(case) reaching the (_, Some(_), Some(type_case)) arm.","commonSituations":"Users who set type_name for explicit control and later add type_case to adjust casing, not realizing type_case only applies when type_name is absent; also examples copy-pasted from older docs.","solutions":["Keep only `type_name` if you want a fixed alias name (apply casing yourself).","Keep only `type_case` if you want the alias derived from the function name in that case.","Remove both to use the default naming."],"exampleFix":"// before\n#[auto_type(type_alias, type_name = \"MyOut\", type_case = \"PascalCase\")]\nfn f() -> _ { 1 }\n// after\n#[auto_type(type_alias, type_name = \"MyOut\")]\nfn f() -> _ { 1 }","handlingStrategy":"validation","validationCode":"let has_type_name = attr_contains(\"type_name\");\nlet has_type_case = attr_contains(\"type_case\");\nassert!(!(has_type_name && has_type_case), \"use type_name or type_case, not both\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use type_case alone when you just want casing; reserve type_name for exact control.","Document the mutually exclusive pairs in your team's macro guidelines."],"tags":["rust","proc-macro","attribute-options","compile-time"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"6fa6ed01b24b24248ab2a611698d0a7c6a2e9120","analyzedAt":"2026-09-07T01:50:13.074Z","contentChangedAt":"2026-09-07T01:50:13.074Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}