diff options
| author | Urgau <urgau@numericable.fr> | 2024-03-22 15:27:17 +0100 |
|---|---|---|
| committer | Urgau <urgau@numericable.fr> | 2024-03-28 18:47:26 +0100 |
| commit | fefb8f1f9cb830e1ca0b0ba449db7c8e7d4ff7ba (patch) | |
| tree | b768c3b57ac8013ca10494c76b2a5ad85f9908b1 /compiler/rustc_span | |
| parent | 4f4fa42b0ee1cf6c988d3f7ed6bcb4a51e788282 (diff) | |
| download | rust-fefb8f1f9cb830e1ca0b0ba449db7c8e7d4ff7ba.tar.gz rust-fefb8f1f9cb830e1ca0b0ba449db7c8e7d4ff7ba.zip | |
Replace Session should_remap_filepaths with filename_display_preference
Diffstat (limited to 'compiler/rustc_span')
| -rw-r--r-- | compiler/rustc_span/src/lib.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 0c974ef4ca3..7ce879807ca 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -271,6 +271,18 @@ impl RealFileName { } } + /// Return the path remmapped or not depending on the [`FileNameDisplayPreference`]. + /// + /// For the purpose of this function, local and short preference are equal. + pub fn to_path(&self, display_pref: FileNameDisplayPreference) -> &Path { + match display_pref { + FileNameDisplayPreference::Local | FileNameDisplayPreference::Short => { + self.local_path_if_available() + } + FileNameDisplayPreference::Remapped => self.remapped_path_if_available(), + } + } + pub fn to_string_lossy(&self, display_pref: FileNameDisplayPreference) -> Cow<'_, str> { match display_pref { FileNameDisplayPreference::Local => self.local_path_if_available().to_string_lossy(), |
