From befa29e0dc4219b7d96ec92ef1d5765c21153e39 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Thu, 26 Nov 2015 18:05:32 +1300 Subject: [PATCH] save-analysis: use absolute paths for file names --- src/librustc_trans/save/recorder.rs | 2 +- src/librustc_trans/save/span_utils.rs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/librustc_trans/save/recorder.rs b/src/librustc_trans/save/recorder.rs index 34eb1d28263..8108eb5484b 100644 --- a/src/librustc_trans/save/recorder.rs +++ b/src/librustc_trans/save/recorder.rs @@ -665,7 +665,7 @@ impl<'a, 'tcx: 'a> FmtStrs<'a, 'tcx> { pub fn external_crate_str(&mut self, span: Span, name: &str, num: ast::CrateNum) { let lo_loc = self.span.sess.codemap().lookup_char_pos(span.lo); self.record_without_span(ExternalCrate, - svec!(name, num, lo_loc.file.name), + svec!(name, num, SpanUtils::make_path_string(&lo_loc.file.name)), span); } diff --git a/src/librustc_trans/save/span_utils.rs b/src/librustc_trans/save/span_utils.rs index aa197680438..773d5caea5f 100644 --- a/src/librustc_trans/save/span_utils.rs +++ b/src/librustc_trans/save/span_utils.rs @@ -13,6 +13,8 @@ use rustc::session::Session; use save::generated_code; use std::cell::Cell; +use std::env; +use std::path::Path; use syntax::ast; use syntax::codemap::*; @@ -35,6 +37,15 @@ impl<'a> SpanUtils<'a> { } } + pub fn make_path_string(file_name: &str) -> String { + let path = Path::new(file_name); + if path.is_absolute() { + path.clone().display().to_string() + } else { + env::current_dir().unwrap().join(&path).display().to_string() + } + } + // Standard string for extents/location. #[rustfmt_skip] pub fn extent_str(&self, span: Span) -> String { @@ -47,7 +58,7 @@ impl<'a> SpanUtils<'a> { format!("file_name,\"{}\",file_line,{},file_col,{},extent_start,{},extent_start_bytes,{},\ file_line_end,{},file_col_end,{},extent_end,{},extent_end_bytes,{}", - lo_loc.file.name, + SpanUtils::make_path_string(&lo_loc.file.name), lo_loc.line, lo_loc.col.to_usize(), lo_pos.to_usize(), lo_pos_byte.to_usize(), hi_loc.line, hi_loc.col.to_usize(), hi_pos.to_usize(), hi_pos_byte.to_usize()) }