@@ -13,7 +13,7 @@ pub use self::RenderSpan::*;
1313pub use self :: ColorConfig :: * ;
1414use self :: Destination :: * ;
1515
16- use codemap:: { Pos , Span } ;
16+ use codemap:: { COMMAND_LINE_SP , Pos , Span } ;
1717use codemap;
1818use 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 {
390393fn 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