slint-ui/slint · error · std::io::Error
Parsing failed.
Error message
Parsing failed.
What it means
`check_error` converts the boolean parse-failure result of the slint formatter into an `io::Error::InvalidData`. When the Slint (or embedded Rust/Markdown code block) source cannot be parsed, formatting cannot proceed, so the tool fails with "Parsing failed.".
Solutions
- Run `slint-viewer` or the LSP on the file to find and fix the syntax error reported by the compiler
- Check for newer Slint language syntax that this slint-fmt version doesn't support; update the tool
- If in a markdown file, ensure the fenced code block content is complete valid Slint (no prose/placeholder fragments)
Example fix
// before: file with syntax error
export component A { property<int x; }
// after: fixed syntax
export component A { property<int> x; } Defensive patterns
Strategy: try-catch
Validate before calling
let mut diag = Default::default();
let compiled = slint_interpreter::compile(source.as_str(), &path.to_string_lossy(), None, &mut diag);
if !diag.is_empty() { eprintln!("{}", diag); std::process::exit(1); } Try / catch
if let Err(e) = process_slint_file(&path) {
if e.kind() == std::io::ErrorKind::InvalidData {
eprintln!("{}: Slint syntax error — run the compiler/LSP to see diagnostics: {e}", path.display());
std::process::exit(1);
}
return Err(e);
} Prevention
- Run slint-fmt only on sources that already pass the Slint compiler (e.g. after CI linting)
- Pin slint-fmt to the same version as the Slint language your project uses
- For markdown files, validate each fenced slint block individually and skip intentionally incomplete snippets
When it happens
Trigger: `process_slint_code` returns `true` (parse error) — i.e. the source passed to the formatter contains a syntax error. Called from `process_rust_file`, `process_markdown_file`, or `process_slint_file` when formatting a file with invalid syntax.
Common situations: Running slint-fmt on a hand-edited .slint file with a typo; formatting a markdown file whose slint code block is intentionally invalid/partial; version mismatch where newer syntax is formatted by an older slint-fmt.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Callback ' ' in global ' ' cannot be used with a callback…
- Cannot create component instance
- Cannot create placeholder
- Cannot show component
- Cannot show placeholder
AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16).
Data as JSON: /api/errors/a3e5149eb65c2eb1.
Report an issue: GitHub.
Appendix: source
Thrown at tools/lsp/fmt/tool.rs:112
source_slice = &source_slice[code_end..];
had_error |= process_slint_code(code, &mut file, None)?;
}
file.write_all(source_slice.as_bytes())?;
check_error(had_error)
}
fn process_slint_file(
source: String,
path: &std::path::Path,
mut file: impl Write,
) -> std::io::Result<()> {
check_error(process_slint_code(source.as_str(), &mut file, Some(path))?)
}
fn check_error(error: bool) -> std::io::Result<()> {
if error {
Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "Parsing failed."))
} else {
Ok(())
}
}
fn process_file(
source: String,
path: &std::path::Path,
mut file: impl Write,
) -> std::io::Result<()> {
let result = match path.extension() {
Some(ext) if ext == "rs" => process_rust_file(source, file),
Some(ext) if ext == "md" => process_markdown_file(source, file),
Some(ext) if ext == "slint" => process_slint_file(source, path, file),
_ => {
// This allows usage like `cat x.slint | slint-lsp format /dev/stdin`
if path == Path::new("/dev/stdin") {
return process_slint_file(source, path, file);View on GitHub (pinned to bb937076de)