slint-ui/slint · error

cannot parse

Error message

cannot parse {}: {err}

What it means

After reading the enum source, parse_rust_enum hands it to syn::parse_file; this panic is that Result's error handler. It means the referenced .rs file is not syntactically valid Rust from syn's point of view — usually an in-progress edit that broke syntax, or an exotic/unstable syntax the pinned syn version rejects. The build stops instead of generating bindings from a half-parsed file.

Solutions

  1. Read the {err} details for the syn parse error and line/column; fix the syntax error or unsupported construct in the referenced enum source file
  2. Check that the source parses with the syn version pinned by the build script; a syn major-version bump can reject previously valid syntax
  3. If the file uses cfg-gated syntax that hides an enum under the active feature set, adjust features so a parseable variant is visible
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at api/node/build.rs:554 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16). Data as JSON: /api/errors/9063113096184684. Report an issue: GitHub.

Appendix: source

Thrown at api/node/build.rs:554

    /// Whether the variant is `#[doc(hidden)]`.
    hidden: bool,
    fields: Vec<RustField>,
}

struct RustField {
    /// `None` for a field of a tuple variant.
    name: Option<String>,
    js_name: Option<String>,
    /// Last segment of the field's type path.
    ty: String,
    docs: Vec<String>,
}

fn parse_rust_enum(path: &std::path::Path, name: &str) -> RustEnum {
    let source = std::fs::read_to_string(path)
        .unwrap_or_else(|err| panic!("cannot read {}: {err}", path.display()));
    let file = syn::parse_file(&source)
        .unwrap_or_else(|err| panic!("cannot parse {}: {err}", path.display()));
    let item = file
        .items
        .iter()
        .find_map(|item| match item {
            syn::Item::Enum(item) if item.ident == name => Some(item),
            _ => None,
        })
        .unwrap_or_else(|| panic!("no `enum {name}` in {}", path.display()));

    RustEnum {
        docs: doc_lines(&item.attrs),
        attrs: item.attrs.clone(),
        variants: item
            .variants
            .iter()
            .map(|variant| RustVariant {
                name: variant.ident.to_string(),
                docs: doc_lines(&variant.attrs),

View on GitHub (pinned to bb937076de)