]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_save_analysis/src/span_utils.rs
Auto merge of #85178 - cjgillot:local-crate, r=oli-obk
[rust.git] / compiler / rustc_save_analysis / src / span_utils.rs
index edcd4925773743270fc2b97e280b6a3e1599e6d4..1947b04f441c30025dad52f7152a5ad43fc17a09 100644 (file)
@@ -16,8 +16,7 @@ pub fn new(sess: &'a Session) -> SpanUtils<'a> {
 
     pub fn make_filename_string(&self, file: &SourceFile) -> String {
         match &file.name {
-            FileName::Real(name) if !file.name_was_remapped => {
-                let path = name.local_path();
+            FileName::Real(RealFileName::LocalPath(path)) => {
                 if path.is_absolute() {
                     self.sess
                         .source_map()
@@ -27,12 +26,15 @@ pub fn make_filename_string(&self, file: &SourceFile) -> String {
                         .display()
                         .to_string()
                 } else {
-                    self.sess.working_dir.0.join(&path).display().to_string()
+                    self.sess
+                        .working_dir
+                        .remapped_path_if_available()
+                        .join(&path)
+                        .display()
+                        .to_string()
                 }
             }
-            // If the file name is already remapped, we assume the user
-            // configured it the way they wanted to, so use that directly
-            filename => filename.to_string(),
+            filename => filename.prefer_remapped().to_string(),
         }
     }