{"record":{"id":"2a4fd524004158f6","repo":"slint-ui/slint","slug":"one-token","errorCode":null,"errorMessage":"one token","messagePattern":"one token","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/compiler/generator/slint_sc.rs","lineNumber":192,"sourceCode":"    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.\nfn stamped(span: Span, tokens: TokenStream) -> TokenStream {","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/internal/compiler/generator/slint_sc.rs#L174-L210","documentation":"`point_span` expects the token stream from parsing `p<id>` to yield at least one token; `\"p{id}\"` always lexes to exactly one identifier token, so an empty stream means the token-source machinery is broken.","triggerScenarios":"`format!(\"p{id}\").parse::<TokenStream>()` returning an empty stream — only possible if the lexer dropped the token or the parse silently produced nothing due to a proc-macro2 runtime issue.","commonSituations":"Seen only when the compiler is embedded in an environment where string-to-TokenStream parsing misbehaves, or after a lexer regression.","solutions":["Check that the proc-macro2 runtime is functional in your build (e.g. wasm builds need the correct feature set)","File a compiler bug: the token stream for `p<id>` must be non-empty for all usize ids","Pin/upgrade proc-macro2 to a version where `parse` on a simple identifier works"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"debug_assert!(tokens.into_iter().count() >= 1, \"p<id> must lex to one token\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify lexer/proc-macro2 works in your target environment (wasm needs special setup)","Report non-empty-stream violations upstream rather than working around them"],"tags":["rust","compiler","panic","lexer"],"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"}