zed-industries/zed · error

failed to parse rust semantic_token_rules.json

Error message

failed to parse rust semantic_token_rules.json

What it means

Panics when the Rust rules JSONC fails to deserialize into SemanticTokenRules. File and type ship in lockstep, so this signals schema drift between the vendored JSON and the Rust struct (renamed/removed fields), surfacing the first time Rust semantic token rules are needed.

Source

Thrown at crates/languages/src/rust.rs:43

    borrow::Cow,
    path::{Path, PathBuf},
    sync::{Arc, LazyLock},
};
use task::{TaskTemplate, TaskTemplates, TaskVariables, VariableName};
use util::command::{Stdio, new_command};
use util::fs::{make_file_executable, remove_matching};
use util::merge_json_value_into;
use util::rel_path::RelPath;
use util::{ResultExt, maybe};

use crate::language_settings::LanguageSettings;

pub(crate) fn semantic_token_rules() -> SemanticTokenRules {
    let content = grammars::get_file("rust/semantic_token_rules.json")
        .expect("missing rust/semantic_token_rules.json");
    let json = std::str::from_utf8(&content.data).expect("invalid utf-8 in semantic_token_rules");
    settings::parse_json_with_comments::<SemanticTokenRules>(json)
        .expect("failed to parse rust semantic_token_rules.json")
}

pub struct RustLspAdapter;

#[cfg(target_os = "macos")]
impl RustLspAdapter {
    const GITHUB_ASSET_KIND: AssetKind = AssetKind::Gz;
    const ARCH_SERVER_NAME: &str = "apple-darwin";
}

#[cfg(target_os = "linux")]
impl RustLspAdapter {
    const GITHUB_ASSET_KIND: AssetKind = AssetKind::Gz;
    const ARCH_SERVER_NAME: &str = "unknown-linux";
}

#[cfg(target_os = "freebsd")]
impl RustLspAdapter {

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Write a unit test parsing rust/semantic_token_rules.json into SemanticTokenRules to expose the serde error
  2. Fix whichever side drifted (JSON file or struct fields)
  3. Fall back to default rules with a warning instead of unwrapping
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/languages/src/rust.rs:43 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20). Data as JSON: /api/errors/26c578f645acb68a. Report an issue: GitHub.