Skip to content

Commit

Permalink
Auto merge of #30077 - nrc:save-abs-crate, r=eddyb
Browse files Browse the repository at this point in the history
  • Loading branch information
bors committed Nov 26, 2015
2 parents 8baaf0a + befa29e commit 1727dee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/librustc_trans/save/recorder.rs
Expand Up @@ -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);
}

Expand Down
13 changes: 12 additions & 1 deletion src/librustc_trans/save/span_utils.rs
Expand Up @@ -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::*;
Expand All @@ -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 {
Expand All @@ -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())
}
Expand Down

0 comments on commit 1727dee

Please sign in to comment.