{"record":{"id":"3f2aad5b9a0da7b3","repo":"slint-ui/slint","slug":"an-identifier","errorCode":null,"errorMessage":"an identifier","messagePattern":"an identifier","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/compiler/generator/slint_sc.rs","lineNumber":191,"sourceCode":"    let written = elem.debug.first().and_then(|d| d.node.QualifiedName());\n    match written {\n        Some(name) => name.text().to_string().trim().to_string(),\n        None => elem.base_type.to_string(),\n    }\n}\n\n/// The name of a property as the source writes it: `move_declarations` hoists\n/// a declaration onto the root element under a name of its own making.\nfn source_name(elem: &Element, name: &SmolStr) -> SmolStr {\n    let moved_from = elem.property_declarations.get(name).and_then(|d| d.moved_from.clone());\n    moved_from.unwrap_or_else(|| name.clone())\n}\n\n/// A span naming point `id`: the span of a token parsed from the text\n/// `p<id>`, which `source_text` gives back. Fallback spans can be made in no\n/// other way, and the printer is the only reader.\nfn point_span(id: usize) -> Span {\n    let tokens: TokenStream = format!(\"p{id}\").parse().expect(\"an identifier\");\n    tokens.into_iter().next().expect(\"one token\").span()\n}\n\n/// The point a span names, if any.\nfn point_id(span: Span) -> Option<usize> {\n    span.source_text()?.strip_prefix('p')?.parse().ok()\n}\n\n/// The tokens as the range of the point, when they are one. See `stamped`.\nfn stamped_at(point: Option<Span>, tokens: TokenStream) -> TokenStream {\n    match point {\n        Some(span) => stamped(span, tokens),\n        None => tokens,\n    }\n}\n\n/// The tokens as a point's range: a group without delimiters, which prints\n/// as the tokens alone, stamped with the point's span.","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/internal/compiler/generator/slint_sc.rs#L173-L209","documentation":"This panic fires in `point_span` when the string `p<id>` (e.g. `p3`) fails to lex as a Slint identifier. The function fabricates a fallback `Span` by parsing a synthetic token, and the compiler treats its own ability to parse that token as an invariant.","triggerScenarios":"Calling `point_span` with an id such that `format!(\"p{id}\")` is not a valid identifier token — practically impossible since every usize yields `p` + digits, so a failure would indicate a broken lexer or `proc_macro2` token stream in a non-compiler context (e.g. invoking the generator outside `proc-macro` mode where `parse::<TokenStream>()` on strings is unavailable).","commonSituations":"Hitting this while porting the slint-sc generator to a context without proc-macro token source support, or a regression in the lexer rejecting digit-suffixed identifiers.","solutions":["Ensure the generator runs inside the compiler where `str::parse::<TokenStream>()` is supported (proc-macro runtime available)","Update proc-macro2/proc-macro dependency; a broken token source usually means a bad proc-macro2 runtime","Report as a compiler bug — the invariant `p<id>` is always an identifier should hold for every usize"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"assert!(!format!(\"p{id}\").is_empty(), \"point_span id must produce a token\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only call point_span from within the compiler's normal codegen path","Keep proc-macro2 features enabled in all build targets","Treat any hit as a compiler bug and file it with the id value"],"tags":["rust","compiler","panic","invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"bb937076de3f7919766c1f25e2e969367cf77e9a","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}