{"record":{"id":"e80f81523d5f5b93","repo":"yewstack/yew","slug":"match-expression-must-have-at-least-one-arm","errorCode":null,"errorMessage":"`match` expression must have at least one arm","messagePattern":"`match` expression must have at least one arm","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"packages/yew-macro/src/html_tree/html_match.rs","lineNumber":78,"sourceCode":"        }\n\n        if input.is_empty() {\n            return Err(syn::Error::new(\n                expr.span(),\n                \"this `match` expression has a scrutinee, but no body\",\n            ));\n        }\n\n        let content;\n        let brace = braced!(content in input);\n\n        let mut arms = Vec::new();\n        while !content.is_empty() {\n            arms.push(content.parse::<HtmlMatchArm>()?);\n        }\n\n        if arms.is_empty() {\n            return Err(syn::Error::new(\n                brace.span.span(),\n                \"`match` expression must have at least one arm\",\n            ));\n        }\n\n        Ok(HtmlMatch {\n            match_token,\n            expr,\n            _brace: brace,\n            arms,\n        })\n    }\n}\n\nimpl Parse for HtmlMatchArm {\n    fn parse(input: ParseStream) -> syn::Result<Self> {\n        let pat = Pat::parse_multi_with_leading_vert(input)?;\n","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/yewstack/yew/blob/0e4a05472fac4e5fce1befe60fa4a1e43a36b6a3/packages/yew-macro/src/html_tree/html_match.rs#L60-L96","documentation":"`HtmlMatch::parse` collects arms until the brace content is exhausted, then requires at least one arm (html_match.rs:72-80); an empty `{}` body yields this error on the brace span. Plain Rust also requires at least one match arm, but the macro reports it earlier while expanding `html!`, with the span pointing at the empty braces.","triggerScenarios":"`html! { match value {} }` — braces present but zero arms inside.","commonSituations":"Scaffolding a match and not finishing it, deleting all arms during a refactor, or assuming a default arm exists implicitly.","solutions":["Add the missing arms, typically ending with a catch-all: `_ => <em/>`","Let exhaustiveness help: list each enum variant; the expanded code is a real `match`, so rustc flags gaps afterward","If the match is unnecessary, replace it with a plain expression child"],"exampleFix":"// before\nhtml! { match value {} }\n\n// after\nhtml! { match value { Some(v) => <p>{ v }</p>, _ => <em/> } }","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never leave `match x {}` empty — scaffold at least `_ => <em/>` right away","Prefer exhaustive variant arms plus a catch-all so later enum growth still compiles","Delete the whole match if it renders nothing, instead of leaving hollow braces"],"tags":["rust","yew","html-macro","match-expression","empty-arms"],"backgroundTag":"incomplete-match-expression","analyzedSha":"0e4a05472fac4e5fce1befe60fa4a1e43a36b6a3","analyzedAt":"2026-08-22T21:16:31.212Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}