Skip to main content

file_id_for

Function file_id_for 

Source
pub fn file_id_for(path: &Path) -> FileId
Expand description

The durable FileId for path — assigned once, on first use, and stable for the life of the process from then on, even across content edits to that same path (a FileId is a path identity, not a content one; cached_parse’s own content-keyed cache is what tracks edits).

PR #1520’s own bot review (finding #1): recovers from a poisoned lock rather than propagating the poison — a parser panic on one input (a real, reachable failure mode this codebase already handles at the wasm boundary, bynk-wasm/src/lib.rs’s own catch_unwind) must not brick every later, perfectly valid parse for the life of the process. Safe specifically because this cache’s own invariants — file_ids maps a path to a stable id; entries[id].content is the content entries[id].result was parsed from — both hold even mid-panic: a panic during the parse call in cached_parse_in happens strictly before that entry would have been inserted, so the state a panicked lock holder left behind is never a half-written entry, only a possibly-stale (never wrong) one.