zed-industries/zed · error
valid regex
Error message
valid regex
What it means
LazyLock initializer for the Emacs modeline regex; the regex crate failed to compile the constant pattern `-\*-\s*(.+?)\s*-\*-`. Because the pattern is a compile-time constant written by developers, failure can only come from a regex crate version change altering syntax/limits — never from file content. The assert documents that the constant is known-valid.
Source
Thrown at crates/language/src/modeline.rs:79
}
Some(settings).filter(|s| s.has_settings())
}
fn parse_modelines(modelines: &[&str], settings: &mut ModelineSettings) {
for line in modelines {
parse_emacs_modeline(line, settings);
// if emacs is set, do not check for vim modelines
if settings.has_settings() {
return;
}
}
parse_vim_modelines(modelines, settings);
}
static EMACS_MODELINE_RE: LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"-\*-\s*(.+?)\s*-\*-").expect("valid regex"));
/// Parse Emacs-style modelines
/// Format: -*- mode: rust; tab-width: 4; indent-tabs-mode: nil; -*-
/// See Emacs (set-auto-mode)
fn parse_emacs_modeline(line: &str, settings: &mut ModelineSettings) {
let Some(captures) = EMACS_MODELINE_RE.captures(line) else {
return;
};
let Some(modeline_content) = captures.get(1).map(|m| m.as_str()) else {
return;
};
for part in modeline_content.split(';') {
parse_emacs_key_value(part, settings, true);
}
}
/// Parse Emacs-style Local Variables block
///View on GitHub (pinned to f4178619ac)
Solutions
- Run the regex in a unit test (Regex::new on the same literal) to surface the compile error and adjust syntax
- Pin the regex crate version if a SemVer-incompatible change introduced new syntax rules
- Simplify the pattern if it exceeds default size limits
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/language/src/modeline.rs:79 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/396be4b0fb6dfbc1.
Report an issue: GitHub.