{"record":{"id":"57f8a1061f9d1538","repo":"diesel-rs/diesel","slug":"only-the-env-macro-is-expected-here","errorCode":null,"errorMessage":"only the `env!` macro is expected here","messagePattern":"only the `env!` macro is expected here","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"diesel_derives/src/diesel_for_each_tuple.rs","lineNumber":60,"sourceCode":"        #input! {\n            #(#out)*\n        }\n    }\n}\n\npub struct ForEachTupleInput {\n    inner: Ident,\n    max_size: u16,\n}\n\nimpl syn::parse::Parse for ForEachTupleInput {\n    fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {\n        let inner = input.parse()?;\n        input.parse::<syn::Token![,]>()?;\n        let max_size = if input.peek(syn::Ident) {\n            let macro_ident = input.parse::<syn::Ident>()?;\n            if macro_ident != \"env\" {\n                return Err(syn::Error::new(\n                    macro_ident.span(),\n                    \"only the `env!` macro is expected here\",\n                ));\n            }\n            let _bang = input.parse::<syn::Token![!]>()?;\n            let name;\n            syn::parenthesized!(name in input);\n            let s = name.parse::<syn::LitStr>()?;\n            std::env::var(s.value())\n                .map_err(|_| {\n                    syn::Error::new(\n                        s.span(),\n                        format!(\"Expected `{}` to be set as environment variable\", s.value()),\n                    )\n                })?\n                .parse::<u16>()\n                .map_err(|_| {\n                    syn::Error::new(","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/diesel-rs/diesel/blob/6fa6ed01b24b24248ab2a611698d0a7c6a2e9120/diesel_derives/src/diesel_for_each_tuple.rs#L42-L78","documentation":"In the `diesel_for_each_tuple!` macro invocation, the second positional argument for the maximum tuple size may be given either as an integer literal or as `env!(VAR_NAME)`. If a macro-like token appears but its identifier is not `env`, the parser rejects it with this compile error.","triggerScenarios":"Writing `diesel_for_each_tuple!(..., other_macro!(SOME_VAR));` — any macro name other than `env` in the max-size position.","commonSituations":"Typo like `envn!` or `ENV!`, or attempting to reuse a custom macro/environment helper where the grammar only allows `env!`.","solutions":["Replace the macro call with `env!(YOUR_VAR)`.","Pass the max tuple size directly as an integer literal instead.","Fix the capitalization/typo so the identifier is exactly `env`."],"exampleFix":"// before\ndiesel_for_each_tuple!(my_table, getenv!(MAX_TUPLE_SIZE));\n\n// after\ndiesel_for_each_tuple!(my_table, env!(MAX_TUPLE_SIZE));","handlingStrategy":"validation","validationCode":"// Only env! is accepted as a macro form for the tuple-size argument\nfn validate_size_arg(arg: &str) -> Result<(), String> {\n    if arg.ends_with('!') && !arg.starts_with(\"env!\") {\n        return Err(format!(\"{arg} is not allowed; use env! or a literal\"));\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the literal-integer form unless a build-time env override is genuinely needed","Copy the exact `env!(VAR)` spelling from the macro docs","Avoid abstractions like custom wrappers around the size argument"],"tags":["diesel","proc-macro","rust","macro-syntax"],"backgroundTag":"invalid-argument-format","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"}