]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #53110 - Xanewok:save-analysis-remap-path, r=nrc
authorkennytm <kennytm@gmail.com>
Thu, 9 Aug 2018 08:58:42 +0000 (16:58 +0800)
committerGitHub <noreply@github.com>
Thu, 9 Aug 2018 08:58:42 +0000 (16:58 +0800)
Account for --remap-path-prefix in save-analysis

Fixes #52549.

Didn't add a test since save-analysis is still unstable, only tested this locally. Should I add a test for that? If so, is run-make-fulldeps an appropriate format?

Session is already created with remapped working directory, so use that instead of the actual cwd.
This was the only place affected, since the rest of the paths in save-analysis are directly derived from files in spans from `sess.codemap()`, which already creates remapped ones.

r? @nrc

src/librustc_save_analysis/lib.rs
src/librustc_save_analysis/span_utils.rs

index 703489f56c1fdd5cc557281fe6320b60f437f679..e256f1761f146655aa8b76de226997cad52f949c 100644 (file)
@@ -125,7 +125,7 @@ pub fn get_external_crates(&self) -> Vec<ExternalCrateData> {
             result.push(ExternalCrateData {
                 // FIXME: change file_name field to PathBuf in rls-data
                 // https://github.com/nrc/rls-data/issues/7
-                file_name: SpanUtils::make_path_string(&lo_loc.file.name),
+                file_name: self.span_utils.make_path_string(&lo_loc.file.name),
                 num: n.as_u32(),
                 id: GlobalCrateId {
                     name: self.tcx.crate_name(n).to_string(),
index 4d93e81a78fa128b09bb66cb10d594ff203b6976..85dd2a3a20683e79dfe13a1ce40566c046bbc739 100644 (file)
@@ -13,7 +13,6 @@
 use generated_code;
 
 use std::cell::Cell;
-use std::env;
 
 use syntax::parse::lexer::{self, StringReader};
 use syntax::parse::token::{self, Token};
@@ -36,11 +35,10 @@ pub fn new(sess: &'a Session) -> SpanUtils<'a> {
         }
     }
 
-    pub fn make_path_string(path: &FileName) -> String {
+    pub fn make_path_string(&self, path: &FileName) -> String {
         match *path {
             FileName::Real(ref path) if !path.is_absolute() =>
-                env::current_dir()
-                    .unwrap()
+                self.sess.working_dir.0
                     .join(&path)
                     .display()
                     .to_string(),