Skip to content

Commit c83e2fc

Browse files
committed
---
yaml --- r: 171623 b: refs/heads/batch c: 0bd022c h: refs/heads/master i: 171621: 6b08173 171619: 7314c85 171615: 2e058df v: v3
1 parent af4d40b commit c83e2fc

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2929
refs/heads/issue-18208-method-dispatch-2: 9e1eae4fb9b6527315b4441cf8a0f5ca911d1671
3030
refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
32-
refs/heads/batch: c41cafb10c3e1cd5063bcacd663d0fc17fddc8c3
32+
refs/heads/batch: 0bd022c893b00e0bb76d84bbbf8ccf7f685aad9c
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 496dc4eae7de9d14cd49511a9acfbf5f11ae6c3f
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928

branches/batch/src/librustc/metadata/creader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use syntax::ast;
2626
use syntax::abi;
2727
use syntax::attr;
2828
use syntax::attr::AttrMetaMethods;
29-
use syntax::codemap::{DUMMY_SP, Span, mk_sp};
29+
use syntax::codemap::{COMMAND_LINE_SP, Span, mk_sp};
3030
use syntax::parse;
3131
use syntax::parse::token::InternedString;
3232
use syntax::parse::token;
@@ -456,7 +456,7 @@ impl<'a> CrateReader<'a> {
456456
ident: s.to_string(),
457457
id: ast::DUMMY_NODE_ID,
458458
should_link: true,
459-
}, DUMMY_SP)
459+
}, COMMAND_LINE_SP)
460460
}
461461
};
462462
let target_triple = &self.sess.opts.target_triple[];

branches/batch/src/libsyntax/codemap.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ pub struct Span {
105105

106106
pub const DUMMY_SP: Span = Span { lo: BytePos(0), hi: BytePos(0), expn_id: NO_EXPANSION };
107107

108+
// Generic span to be used for code originating from the command line
109+
pub const COMMAND_LINE_SP: Span = Span { lo: BytePos(0),
110+
hi: BytePos(0),
111+
expn_id: COMMAND_LINE_EXPN };
112+
108113
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
109114
pub struct Spanned<T> {
110115
pub node: T,
@@ -235,6 +240,8 @@ pub struct ExpnInfo {
235240
pub struct ExpnId(u32);
236241

237242
pub const NO_EXPANSION: ExpnId = ExpnId(-1);
243+
// For code appearing from the command line
244+
pub const COMMAND_LINE_EXPN: ExpnId = ExpnId(-2);
238245

239246
impl ExpnId {
240247
pub fn from_llvm_cookie(cookie: c_uint) -> ExpnId {

branches/batch/src/libsyntax/diagnostic.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub use self::RenderSpan::*;
1313
pub use self::ColorConfig::*;
1414
use self::Destination::*;
1515

16-
use codemap::{Pos, Span};
16+
use codemap::{COMMAND_LINE_SP, Pos, Span};
1717
use codemap;
1818
use diagnostics;
1919

@@ -368,6 +368,9 @@ impl Emitter for EmitterWriter {
368368
cmsp: Option<(&codemap::CodeMap, Span)>,
369369
msg: &str, code: Option<&str>, lvl: Level) {
370370
let error = match cmsp {
371+
Some((cm, COMMAND_LINE_SP)) => emit(self, cm,
372+
FileLine(COMMAND_LINE_SP),
373+
msg, code, lvl, false),
371374
Some((cm, sp)) => emit(self, cm, FullSpan(sp), msg, code, lvl, false),
372375
None => print_diagnostic(self, "", lvl, msg, code),
373376
};
@@ -390,8 +393,11 @@ impl Emitter for EmitterWriter {
390393
fn emit(dst: &mut EmitterWriter, cm: &codemap::CodeMap, rsp: RenderSpan,
391394
msg: &str, code: Option<&str>, lvl: Level, custom: bool) -> io::IoResult<()> {
392395
let sp = rsp.span();
393-
let ss = cm.span_to_string(sp);
394-
let lines = cm.span_to_lines(sp);
396+
let ss = if sp == COMMAND_LINE_SP {
397+
"<command line option>".to_string()
398+
} else {
399+
cm.span_to_string(sp)
400+
};
395401
if custom {
396402
// we want to tell compiletest/runtest to look at the last line of the
397403
// span (since `custom_highlight_lines` displays an arrow to the end of
@@ -400,15 +406,17 @@ fn emit(dst: &mut EmitterWriter, cm: &codemap::CodeMap, rsp: RenderSpan,
400406
let ses = cm.span_to_string(span_end);
401407
try!(print_diagnostic(dst, &ses[], lvl, msg, code));
402408
if rsp.is_full_span() {
403-
try!(custom_highlight_lines(dst, cm, sp, lvl, lines));
409+
try!(custom_highlight_lines(dst, cm, sp, lvl, cm.span_to_lines(sp)));
404410
}
405411
} else {
406412
try!(print_diagnostic(dst, &ss[], lvl, msg, code));
407413
if rsp.is_full_span() {
408-
try!(highlight_lines(dst, cm, sp, lvl, lines));
414+
try!(highlight_lines(dst, cm, sp, lvl, cm.span_to_lines(sp)));
409415
}
410416
}
411-
try!(print_macro_backtrace(dst, cm, sp));
417+
if sp != COMMAND_LINE_SP {
418+
try!(print_macro_backtrace(dst, cm, sp));
419+
}
412420
match code {
413421
Some(code) =>
414422
match dst.registry.as_ref().and_then(|registry| registry.find_description(code)) {

0 commit comments

Comments
 (0)