Expand description
Classify a resolved source path into a human-readable label for the source pane title.
Categories tried in order:
- Stdlib — path lies under one of the platform-tools rewrite
targets (e.g.
~/.cache/solana/v1.52/.../rust/library/). The crate name is the first segment afterlibrary/(core,alloc,std). - Cargo registry crate — path under
$CARGO_HOME/registry/src/<index>/<name>-<version>/. - Cargo git checkout — path under
$CARGO_HOME/git/checkouts/<repo>-<hash>/<rev>/.... - Workspace member — path under the workspace root. Walks up
looking for the nearest
Cargo.tomlto surface the package name. - Unknown — show the full path verbatim.
Falls through to “unknown” rather than panicking on weird inputs.
Structs§
- Path
Label - What we render in the source pane title.
Functions§
- canonicalize
- Best-effort canonicalization. Returns
pathverbatim on failure so the caller doesn’t have to unwrap. Used to defang/tmp↔/private/tmpdrift on macOS before prefix matching. - classify
- Classify a resolved source path for the source pane title.
- is_
src_ dir - Helper to detect that a single path component is “src” — used by callers that want to prettify in-crate display further. Kept here so the policy lives next to the other path heuristics.