From 00b4138857055ba3495a70a01eea0bc8d9fed690 Mon Sep 17 00:00:00 2001 From: Ben Blum Date: Tue, 25 Jun 2013 18:36:48 -0400 Subject: [PATCH] Make ^~~~~ colour dependent on error/warning/note level. Also correct spelling of squigglies. --- src/libsyntax/diagnostic.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 13fa01c96e12..a904416d7a44 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -231,7 +231,7 @@ pub fn emit(cmsp: Option<(@codemap::CodeMap, span)>, msg: &str, lvl: level) { let ss = cm.span_to_str(sp); let lines = cm.span_to_lines(sp); print_diagnostic(ss, lvl, msg); - highlight_lines(cm, sp, lines); + highlight_lines(cm, sp, lvl, lines); print_macro_backtrace(cm, sp); } None => { @@ -241,7 +241,7 @@ pub fn emit(cmsp: Option<(@codemap::CodeMap, span)>, msg: &str, lvl: level) { } fn highlight_lines(cm: @codemap::CodeMap, - sp: span, + sp: span, lvl: level, lines: @codemap::FileLines) { let fm = lines.file; @@ -293,18 +293,18 @@ fn highlight_lines(cm: @codemap::CodeMap, let curChar = (orig[pos] as char); s += match curChar { // Whenever a tab occurs on the previous '\t' => "\t", // line, we insert one on the error-point- - _ => " " // -squigly-line as well (instead of a - }; // space). This way the squigly-line will + _ => " " // -squiggly-line as well (instead of a + }; // space). This way the squiggly-line will } // usually appear in the correct position. io::stderr().write_str(s); let mut s = ~"^"; let hi = cm.lookup_char_pos(sp.hi); if hi.col != lo.col { // the ^ already takes up one space - let num_squiglies = hi.col.to_uint()-lo.col.to_uint()-1u; - for num_squiglies.times() { s += "~"; } + let num_squigglies = hi.col.to_uint()-lo.col.to_uint()-1u; + for num_squigglies.times() { s += "~"; } } - print_maybe_colored(s + "\n", term::color_bright_green); + print_maybe_colored(s + "\n", diagnosticcolor(lvl)); } }