{"record":{"id":"83cdcffeece241e1","repo":"rust-lang/rust-analyzer","slug":"unsupported-constraint-type","errorCode":null,"errorMessage":"Unsupported constraint type '{}'","messagePattern":"Unsupported constraint type '(.+?)'","errorType":"validation","errorClass":"SsrError","httpStatus":null,"severity":"error","filePath":"crates/ide-ssr/src/parsing.rs","lineNumber":329,"sourceCode":"    match constraint_type.as_str() {\n        \"kind\" => {\n            expect_token(tokens, \"(\")?;\n            let t = tokens.next().ok_or_else(|| {\n                SsrError::new(\"Unexpected end of constraint while looking for kind\")\n            })?;\n            if t.kind != SyntaxKind::IDENT {\n                bail!(\"Expected ident, found {:?} while parsing kind constraint\", t.kind);\n            }\n            expect_token(tokens, \")\")?;\n            Ok(Constraint::Kind(NodeKind::from(&t.text)?))\n        }\n        \"not\" => {\n            expect_token(tokens, \"(\")?;\n            let sub = parse_constraint(tokens)?;\n            expect_token(tokens, \")\")?;\n            Ok(Constraint::Not(Box::new(sub)))\n        }\n        x => bail!(\"Unsupported constraint type '{}'\", x),\n    }\n}\n\nfn expect_token(tokens: &mut std::vec::IntoIter<Token>, expected: &str) -> Result<(), SsrError> {\n    if let Some(t) = tokens.next() {\n        if t.text == expected {\n            return Ok(());\n        }\n        bail!(\"Expected {} found {}\", expected, t.text);\n    }\n    bail!(\"Expected {} found end of stream\", expected);\n}\n\nimpl NodeKind {\n    fn from(name: &SmolStr) -> Result<NodeKind, SsrError> {\n        Ok(match name.as_str() {\n            \"literal\" => NodeKind::Literal,\n            _ => bail!(\"Unknown node kind '{}'\", name),","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/rust-lang/rust-analyzer/blob/e8f7e90aa3e7b26aa9a000200f606c1078da99ec/crates/ide-ssr/src/parsing.rs#L311-L347","documentation":"SSR currently supports only two constraint types: kind(...) and not(...). parse_constraint matches the constraint name against these; anything else (after lexing as an ident) triggers this error naming the unsupported constraint. Note that constraints can also be separated by ',' inside a placeholder, each parsed recursively.","triggerScenarios":"Writing ${name:has_type(...)}, ${name:parent(...)} or any constraint keyword other than kind/not in a pattern placeholder.","commonSituations":"Assuming SSR supports type or trait constraints like IDE 'live template' constraints; porting patterns from other structural-search tools (e.g. Semgrep/Comby) that have richer constraint vocabularies; typos like kindz or Kind.","solutions":["Use only kind(...) or not(...) constraints","Express the desired restriction differently, e.g. not(kind(literal)) for negative kinds","Check spelling and case: constraint names are lowercase 'kind' and 'not'"],"exampleFix":"// before\nlet pattern = \"$x:has_type(u32)\";\n// after\nlet pattern = \"$x:kind(literal)\"; // or nest: not(kind(literal))","handlingStrategy":"validation","validationCode":"const ALLOWED_CONSTRAINTS: &[&str] = &[\"kind\", \"not\"];\nfn has_supported_constraints(p: &str) -> bool {\n    // extract identifier before each '(' that follows ':' or ',' inside a placeholder\n    p.split(|c: char| c == '$' || c == '{' || c == '}')\n        .flat_map(|seg| seg.split(':'))\n        .filter_map(|c| c.split_once('('))\n        .all(|(name, _)| ALLOWED_CONSTRAINTS.contains(&name.trim()))\n}\n","typeGuard":null,"tryCatchPattern":"match parse_pattern(pattern) {\n    Ok(p) => use_pattern(p),\n    Err(e) if e.message.contains(\"Unsupported constraint type\") => {\n        eprintln!(\"Only kind(...) and not(...) constraints are supported\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Restrict patterns to kind and not constraints","Do not port constraint syntax from other structural-search tools","Check spelling/case of constraint names","Consult SSR docs before assuming a constraint exists"],"tags":["rust","parsing","ssr","constraints"],"backgroundTag":"ssr-pattern-parse-error","analyzedSha":"e8f7e90aa3e7b26aa9a000200f606c1078da99ec","analyzedAt":"2026-09-03T21:08:06.959Z","contentChangedAt":"2026-09-03T21:08:06.959Z","schemaVersion":2},"datasetVersion":"2026-09-11T07:07:21.782Z"}