@@ -13,7 +13,7 @@ pub use self::RenderSpan::*;
13
13
pub use self :: ColorConfig :: * ;
14
14
use self :: Destination :: * ;
15
15
16
- use codemap:: { Pos , Span } ;
16
+ use codemap:: { COMMAND_LINE_SP , Pos , Span } ;
17
17
use codemap;
18
18
use diagnostics;
19
19
@@ -368,6 +368,9 @@ impl Emitter for EmitterWriter {
368
368
cmsp : Option < ( & codemap:: CodeMap , Span ) > ,
369
369
msg : & str , code : Option < & str > , lvl : Level ) {
370
370
let error = match cmsp {
371
+ Some ( ( cm, COMMAND_LINE_SP ) ) => emit ( self , cm,
372
+ FileLine ( COMMAND_LINE_SP ) ,
373
+ msg, code, lvl, false ) ,
371
374
Some ( ( cm, sp) ) => emit ( self , cm, FullSpan ( sp) , msg, code, lvl, false ) ,
372
375
None => print_diagnostic ( self , "" , lvl, msg, code) ,
373
376
} ;
@@ -390,8 +393,11 @@ impl Emitter for EmitterWriter {
390
393
fn emit ( dst : & mut EmitterWriter , cm : & codemap:: CodeMap , rsp : RenderSpan ,
391
394
msg : & str , code : Option < & str > , lvl : Level , custom : bool ) -> io:: IoResult < ( ) > {
392
395
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
+ } ;
395
401
if custom {
396
402
// we want to tell compiletest/runtest to look at the last line of the
397
403
// 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,
400
406
let ses = cm. span_to_string ( span_end) ;
401
407
try!( print_diagnostic ( dst, & ses[ ] , lvl, msg, code) ) ;
402
408
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 ) ) ) ;
404
410
}
405
411
} else {
406
412
try!( print_diagnostic ( dst, & ss[ ] , lvl, msg, code) ) ;
407
413
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 ) ) ) ;
409
415
}
410
416
}
411
- try!( print_macro_backtrace ( dst, cm, sp) ) ;
417
+ if sp != COMMAND_LINE_SP {
418
+ try!( print_macro_backtrace ( dst, cm, sp) ) ;
419
+ }
412
420
match code {
413
421
Some ( code) =>
414
422
match dst. registry . as_ref ( ) . and_then ( |registry| registry. find_description ( code) ) {
0 commit comments