Skip to content

syntax: Don't put quotes around filenames in codemap #21617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/libsyntax/codemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,10 @@ impl CodeMap {
};

// Append '\n' in case it's not already there.
// This is a workaround to prevent CodeMap.lookup_filemap_idx from accidentally
// overflowing into the next filemap in case the last byte of span is also the last
// byte of filemap, which leads to incorrect results from CodeMap.span_to_*.
// This is a workaround to prevent CodeMap.lookup_filemap_idx from
// accidentally overflowing into the next filemap in case the last byte
// of span is also the last byte of filemap, which leads to incorrect
// results from CodeMap.span_to_*.
if src.len() > 0 && !src.ends_with("\n") {
src.push('\n');
}
Expand Down
8 changes: 4 additions & 4 deletions src/libsyntax/ext/source_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
let bytes = match File::open(&file).read_to_end() {
Err(e) => {
cx.span_err(sp,
&format!("couldn't read {:?}: {}",
&format!("couldn't read {}: {}",
file.display(),
e)[]);
return DummyResult::expr(sp);
Expand All @@ -146,15 +146,15 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
Ok(src) => {
// Add this input file to the code map to make it available as
// dependency information
let filename = format!("{:?}", file.display());
let filename = format!("{}", file.display());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't format! here redundant?

let interned = token::intern_and_get_ident(&src[]);
cx.codemap().new_filemap(filename, src);

base::MacExpr::new(cx.expr_str(sp, interned))
}
Err(_) => {
cx.span_err(sp,
&format!("{:?} wasn't a utf-8 file",
&format!("{} wasn't a utf-8 file",
file.display())[]);
return DummyResult::expr(sp);
}
Expand All @@ -171,7 +171,7 @@ pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
match File::open(&file).read_to_end() {
Err(e) => {
cx.span_err(sp,
&format!("couldn't read {:?}: {}", file.display(), e)[]);
&format!("couldn't read {}: {}", file.display(), e)[]);
return DummyResult::expr(sp);
}
Ok(bytes) => {
Expand Down