Skip to content

Commit befa29e

Browse files
committed
save-analysis: use absolute paths for file names
1 parent 498f08d commit befa29e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/librustc_trans/save/recorder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ impl<'a, 'tcx: 'a> FmtStrs<'a, 'tcx> {
665665
pub fn external_crate_str(&mut self, span: Span, name: &str, num: ast::CrateNum) {
666666
let lo_loc = self.span.sess.codemap().lookup_char_pos(span.lo);
667667
self.record_without_span(ExternalCrate,
668-
svec!(name, num, lo_loc.file.name),
668+
svec!(name, num, SpanUtils::make_path_string(&lo_loc.file.name)),
669669
span);
670670
}
671671

src/librustc_trans/save/span_utils.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ use rustc::session::Session;
1313
use save::generated_code;
1414

1515
use std::cell::Cell;
16+
use std::env;
17+
use std::path::Path;
1618

1719
use syntax::ast;
1820
use syntax::codemap::*;
@@ -35,6 +37,15 @@ impl<'a> SpanUtils<'a> {
3537
}
3638
}
3739

40+
pub fn make_path_string(file_name: &str) -> String {
41+
let path = Path::new(file_name);
42+
if path.is_absolute() {
43+
path.clone().display().to_string()
44+
} else {
45+
env::current_dir().unwrap().join(&path).display().to_string()
46+
}
47+
}
48+
3849
// Standard string for extents/location.
3950
#[rustfmt_skip]
4051
pub fn extent_str(&self, span: Span) -> String {
@@ -47,7 +58,7 @@ impl<'a> SpanUtils<'a> {
4758

4859
format!("file_name,\"{}\",file_line,{},file_col,{},extent_start,{},extent_start_bytes,{},\
4960
file_line_end,{},file_col_end,{},extent_end,{},extent_end_bytes,{}",
50-
lo_loc.file.name,
61+
SpanUtils::make_path_string(&lo_loc.file.name),
5162
lo_loc.line, lo_loc.col.to_usize(), lo_pos.to_usize(), lo_pos_byte.to_usize(),
5263
hi_loc.line, hi_loc.col.to_usize(), hi_pos.to_usize(), hi_pos_byte.to_usize())
5364
}

0 commit comments

Comments
 (0)