{"record":{"id":"6621677024b9075f","repo":"tracel-ai/burn","slug":"at-most-one-per-pattern","errorCode":null,"errorMessage":"at most one `..` per pattern","messagePattern":"at most one `\\.\\.` per pattern","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/burn-derive/src/shape/mod.rs","lineNumber":66,"sourceCode":"impl Parse for ShapeInput {\n    fn parse(input: ParseStream) -> syn::Result<Self> {\n        let krate: Path = input.parse()?;\n        input.parse::<Token![,]>()?;\n        let call = input.fork().parse::<TokenStream>()?.to_string();\n        let tensor: Expr = input.parse()?;\n        input.parse::<Token![,]>()?;\n        let content;\n        bracketed!(content in input);\n        let slots: Vec<Slot> = Punctuated::<Slot, Token![,]>::parse_terminated(&content)?\n            .into_iter()\n            .collect();\n        let mut rests = slots.iter().filter_map(|slot| match slot {\n            Slot::Rest(token) => Some(token),\n            _ => None,\n        });\n        rests.next();\n        if let Some(second) = rests.next() {\n            return Err(syn::Error::new(\n                second.span(),\n                \"at most one `..` per pattern\",\n            ));\n        }\n        Ok(ShapeInput {\n            krate,\n            call,\n            tensor,\n            slots,\n        })\n    }\n}\n\n/// Which macro is expanding. It decides the name in messages and the debug gating.\n#[derive(Clone, Copy)]\npub(crate) enum Mode {\n    Assert,\n    DebugAssert,","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-derive/src/shape/mod.rs#L48-L84","documentation":"This is a compile-time (proc-macro parse) error from burn's shape assertion macros. The `..` rest slot in the shape pattern acts as a catch-all for any number of dimensions, so allowing more than one would be ambiguous. The derive parser counts the `..` slots in the bracket list and rejects the macro invocation with this syn error pointing at the second `..`.","triggerScenarios":"Invoking a burn shape macro (assert_shape / debug_assert_shape style) with a slot list containing two or more `..` entries, e.g. `[.., 3, ..]` or `[.., ..]`. The error span points at the second `..`.","commonSituations":"Writing a pattern meant to say 'first dim anything, last dim anything' using `..` on both ends instead of naming dimensions; copying PyTorch-style ellipsis patterns that permit multiple ellipses; typos where a stray comma leaves an extra `..`.","solutions":["Remove all but one `..` from the shape pattern, keeping a single rest slot","Replace one `..` with an explicit dimension size or a named `_` wildcard slot","If both ends must be unconstrained, use `_` for the known-position dims and keep only one `..`"],"exampleFix":"// before\nassert_shape!(tensor, [.., 3, ..]);\n// after\nassert_shape!(tensor, [_, 3, ..]);","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use at most one `..` per shape pattern; put it at the end","Use `_` slots for individual unknown dimensions instead of extra `..`","Run `cargo check` after editing shape macros to catch parse errors immediately"],"tags":["proc-macro","compile-time","shape-pattern","syn"],"backgroundTag":"multiple-rest-patterns","analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}