Skip to main content

Module path_label

Module path_label 

Source
Expand description

Classify a resolved source path into a human-readable label for the source pane title.

Categories tried in order:

  1. 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 after library/ (core, alloc, std).
  2. Cargo registry crate — path under $CARGO_HOME/registry/src/<index>/<name>-<version>/.
  3. Cargo git checkout — path under $CARGO_HOME/git/checkouts/<repo>-<hash>/<rev>/....
  4. Workspace member — path under the workspace root. Walks up looking for the nearest Cargo.toml to surface the package name.
  5. Unknown — show the full path verbatim.

Falls through to “unknown” rather than panicking on weird inputs.

Structs§

PathLabel
What we render in the source pane title.

Functions§

canonicalize
Best-effort canonicalization. Returns path verbatim on failure so the caller doesn’t have to unwrap. Used to defang /tmp/private/tmp drift 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.