Skip to main content

display_path

Function display_path 

Source
pub fn display_path(display_root: &Path, identity: &Path) -> String
Expand description

#1772: the path a diagnostic names, as a user would type it from the working directory: the build’s root as the caller spelled it, joined with the file’s identity path (relative to that root). A relative root is already relative to the working directory; an absolute one (bynk dev resolves the project root) is shown relative to the working directory when it lies inside it. This matches the path fmt reports for the same file, so a problem matcher resolving against the working directory finds it. Separators print as / on every platform.

#1774 review: a . component is dropped (bynk check’s default input is ., and Roots::trees already keeps ./ out of identity paths for the same reason), and an absolute path is compared against the cwd both as given and canonicalised, since a canonical root on Windows is a verbatim \\?\C:\… path that a plain cwd never prefixes. One that still isn’t under the cwd is shown absolute, without a verbatim prefix.