{"record":{"id":"a52311782697173c","repo":"diesel-rs/diesel","slug":"type-alias-and-no-type-alias-are-mutually-exclusiv","errorCode":null,"errorMessage":"type_alias and no_type_alias are mutually exclusive","messagePattern":"type_alias and no_type_alias are mutually exclusive","errorType":"exception","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"dsl_auto_type/src/auto_type/mod.rs","lineNumber":68,"sourceCode":"    let inferrer_settings = InferrerSettings {\n        dsl_path: settings_input\n            .dsl_path\n            .unwrap_or(derive_settings.default_dsl_path),\n        method_types_case: derive_settings.default_method_type_case,\n        function_types_case: derive_settings.default_function_type_case,\n    };\n\n    let function_name = &input_function.sig.ident;\n    let type_alias = match (\n        settings_input.type_alias.is_present(),\n        settings_input.no_type_alias.is_present(),\n        derive_settings.default_generate_type_alias,\n    ) {\n        (false, false, b) => b,\n        (true, false, _) => true,\n        (false, true, _) => false,\n        (true, true, _) => {\n            return Err(syn::Error::new(\n                Span::mixed_site(),\n                \"type_alias and no_type_alias are mutually exclusive\",\n            )\n            .into());\n        }\n    };\n    let type_alias: Option<syn::Ident> = match (\n        type_alias,\n        settings_input.type_name,\n        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","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/diesel-rs/diesel/blob/6fa6ed01b24b24248ab2a611698d0a7c6a2e9120/dsl_auto_type/src/auto_type/mod.rs#L50-L86","documentation":"The #[auto_type] attribute accepts both `type_alias` and `no_type_alias` flags to force the generated type alias on or off. Specifying both is contradictory — the macro cannot honor both — so auto_type_impl fails expansion at the settings-resolution match arm.","triggerScenarios":"`#[auto_type(type_alias, no_type_alias)]` on a function, typically by stacking conflicting helper attributes or copy-pasting attribute options.","commonSituations":"Users migrating between macro versions where the default changed and they add the opposite flag 'just in case'; or combining wrapper macros that each inject one of the flags.","solutions":["Remove one of the two conflicting flags, keeping only `type_alias` or `no_type_alias`.","If relying on the default, remove both flags entirely.","If a wrapper macro injects one flag, stop passing the other manually."],"exampleFix":"// before\n#[auto_type(type_alias, no_type_alias)]\nfn f() -> _ { 1 }\n// after\n#[auto_type(type_alias)]\nfn f() -> _ { 1 }","handlingStrategy":"validation","validationCode":"// Attribute sanity check before applying:\nlet opts = [\"type_alias\", \"no_type_alias\"];\nlet chosen: Vec<_> = opts.iter().filter(|o| attr_contains(o)).collect();\nassert!(chosen.len() <= 1, \"pick only one alias flag\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Memorize the option matrix: alias flags and naming options are single-choice.","Lint attribute usage in CI with a grep for both flags on one line."],"tags":["rust","proc-macro","attribute-options","compile-time"],"backgroundTag":"mutually-exclusive-flags","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"}