diff options
| author | Kornel <kornel@geekhood.net> | 2024-03-01 13:37:08 +0000 |
|---|---|---|
| committer | Kornel <kornel@geekhood.net> | 2024-03-27 14:57:37 +0000 |
| commit | 89ceced6f6cb60143db400cb9c668fe2d36c0e4e (patch) | |
| tree | b31123872f89d5576dc5204357959907744aa79e /compiler/rustc_span/src | |
| parent | 10a7aa14fed9b528b74b0f098c4899c37c09a9c7 (diff) | |
| download | rust-89ceced6f6cb60143db400cb9c668fe2d36c0e4e.tar.gz rust-89ceced6f6cb60143db400cb9c668fe2d36c0e4e.zip | |
Helper function for resolve_path
Diffstat (limited to 'compiler/rustc_span/src')
| -rw-r--r-- | compiler/rustc_span/src/lib.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 616a7ccc7c6..0c974ef4ca3 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -427,6 +427,17 @@ impl FileName { src.hash(&mut hasher); FileName::InlineAsm(hasher.finish()) } + + /// Returns the path suitable for reading from the file system on the local host, + /// if this information exists. + /// Avoid embedding this in build artifacts; see `remapped_path_if_available()` for that. + pub fn into_local_path(self) -> Option<PathBuf> { + match self { + FileName::Real(path) => path.into_local_path(), + FileName::DocTest(path, _) => Some(path), + _ => None, + } + } } /// Represents a span. |
