slint-ui/slint · error

can't load style metrics

Error message

can't load style metrics

What it means

Error "can't load style metrics" thrown in slint-ui/slint.

Source

Thrown at internal/compiler/passes.rs:95

        }
    }
}

pub async fn run_passes(
    doc: &mut crate::object_tree::Document,
    type_loader: &mut crate::typeloader::TypeLoader,
    keep_raw: bool,
    diag: &mut crate::diagnostics::BuildDiagnostics,
) -> Option<crate::typeloader::TypeLoader> {
    let style_metrics = {
        // Ignore import errors
        let mut build_diags_to_ignore = crate::diagnostics::BuildDiagnostics::default();
        // Import from style-base.slint instead of std-widgets.slint to avoid loading
        // the entire widget library just to get StyleMetrics.
        type_loader
            .import_component("style-base.slint", "StyleMetrics", &mut build_diags_to_ignore)
            .await
            .unwrap_or_else(|| panic!("can't load style metrics"))
    };

    let palette = {
        // Ignore import errors
        let mut build_diags_to_ignore = crate::diagnostics::BuildDiagnostics::default();
        // Import from style-base.slint instead of std-widgets.slint to avoid loading
        // the entire widget library just to get Palette.
        type_loader
            .import_component("style-base.slint", "Palette", &mut build_diags_to_ignore)
            .await
            .unwrap_or_else(|| panic!("can't load palette"))
    };

    let global_type_registry = type_loader.global_type_registry.clone();
    // The shared symbol-name counters, handed to the passes that generate names.
    let symbol_counters = type_loader.symbol_counters.clone();

    run_import_passes(doc, type_loader, diag);

View on GitHub (pinned to 3fd8f2ec03)

Solutions

  1. Ensure the selected style exists and its metrics file is available in the compiler resources.
  2. Check the style name passed to the compiler.

When it happens

Trigger: Thrown at internal/compiler/passes.rs:95 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of slint-ui/slint@3fd8f2ec03 (2026-08-19). Data as JSON: /api/errors/ef672ad056c7c16c. Report an issue: GitHub.