slint-ui/slint · error

unsupported field type; only path types are handled

Error message

unsupported field type; only path types are handled

What it means

type_name extracts the final path segment of a field's type, which is all the type maps need. It panics for any syn::Type that is not a Type::Path — e.g. references (&T), slices/arrays, tuples, or Option<...> written as a non-path? (actually Option is a path; this hits things like &str or [T; N]). It is a guard stating the generator only supports plain path-typed fields; a new field with a compound type trips it.

Solutions

  1. Change the WindowEvent field from a non-path type (e.g. reference, trait object, array, or fn pointer) to a plain path type in the Rust enum
  2. Extend type_name in api/node/build.rs to handle the additional syn::Type variant and extract a usable name
  3. If the field is an Option or Box wrapper, unwrap it in type_name before taking the last path segment
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at api/node/build.rs:636 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/a5bbf2808dd27e90. Report an issue: GitHub.

Appendix: source

Thrown at api/node/build.rs:636

            if let Ok(value) = meta.value()
                && let Ok(text) = value.parse::<syn::LitStr>()
                && is_match
            {
                found = Some(text.value());
            }
            Ok(())
        });
    }
    found
}

/// The last segment of a type path, which is all the type maps need.
fn type_name(ty: &syn::Type) -> String {
    match ty {
        syn::Type::Path(path) => {
            path.path.segments.last().expect("empty type path").ident.to_string()
        }
        _ => panic!("unsupported field type; only path types are handled"),
    }
}

/// Convert `snake_case` to `camelCase`, the way `#[napi(js_name = "…")]` spells fields.
fn to_camel_case(s: &str) -> String {
    let mut out = String::with_capacity(s.len());
    let mut capitalize = false;
    for c in s.chars() {
        if c == '_' {
            capitalize = true;
        } else if capitalize {
            out.extend(c.to_uppercase());
            capitalize = false;
        } else {
            out.push(c);
        }
    }
    out

View on GitHub (pinned to bb937076de)