Paths are shown with a forward slash
Path values and ordinary path displays are /-separated on every host: C:/blah/bleh, //server/share/x, src/x/f. Native diagnostic operands preserve the original units instead. core::path::show::shown owns ordinary display; fold_for is its separator fold.
- One value on every host. A script’s
globorcwdyields the same string on Windows as on Unix, so a test or a model prompt need not know the host. - Escapes cannot eat it. In a
"…"literal\nis a newline; aC:\newprinted back and pasted would be corrupted./is inert there. - Input already reads either. The resolver accepts both separators, so showing with
/loses nothing. - The verbatim exception. A
\\?\C:\…head is dropped (dunce::simplified) where the path means the same without it. A path only the OS can read literally (\\?\UNC\…,\\.\pipe\…, a long or reserved-name verbatim path) is shown exactly as given, since/is not a separator there:showaskslex::parse_bytesunder Windows rules (Parsed::has_os_namespace_head), the backslash-onlyHeadSpellingreading of a namespace head the OS hands back. - The echo exception. A command head written as a path (
.\build.cmd,C:\tools\x) is shown as the user typed it, not folded:Command.shownincore/src/shell/exec/command.rsechoes the word the user wrote, since the refusal answers that word. This echo does not useshown; a~head is still shown throughTildePath::shown. - The diagnostic exception. Native error operands use
text::quote_nativebefore any lossy conversion or separator folding. The portable string includes its quotes and escapes; the reason renders it exactly once. Invalid bytes or code units remain distinct from a literal replacement character or escape-looking filename. - The native boundary. A path ral hands to the OS (
PWD, sandbox rules, DACL calls, internal identity and matching) stays native.
On Unicode Unix paths shown is the identity; on non-Unicode paths it is lossy
and cannot supply native diagnostic evidence.
Enforcement
clippy.toml bans Path::display, Path::to_string_lossy, Path::to_str, OsStr::to_string_lossy and OsStr::to_str, each naming shown as the replacement: shown is the one lossy conversion, for display only, and path::utf8 the one strict conversion, for a path that must travel as text. A path a builtin returns as a ral string is path::to_text, the two composed: refused where not UTF-8, else shown, so a value never names another path. A conversion that is genuinely native (a path handed to the OS, an env value, a non-UTF-8 check) is a typed site! whose Silent variant says why it shows nothing, so every site that does not show a path is a named one (typed-sites).