Skip to content

Commit 00b4138

Browse files
bblumemberian
authored andcommitted
Make ^~~~~ colour dependent on error/warning/note level. Also correct spelling of squigglies.
1 parent 41f953a commit 00b4138

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/libsyntax/diagnostic.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ pub fn emit(cmsp: Option<(@codemap::CodeMap, span)>, msg: &str, lvl: level) {
231231
let ss = cm.span_to_str(sp);
232232
let lines = cm.span_to_lines(sp);
233233
print_diagnostic(ss, lvl, msg);
234-
highlight_lines(cm, sp, lines);
234+
highlight_lines(cm, sp, lvl, lines);
235235
print_macro_backtrace(cm, sp);
236236
}
237237
None => {
@@ -241,7 +241,7 @@ pub fn emit(cmsp: Option<(@codemap::CodeMap, span)>, msg: &str, lvl: level) {
241241
}
242242

243243
fn highlight_lines(cm: @codemap::CodeMap,
244-
sp: span,
244+
sp: span, lvl: level,
245245
lines: @codemap::FileLines) {
246246
let fm = lines.file;
247247

@@ -293,18 +293,18 @@ fn highlight_lines(cm: @codemap::CodeMap,
293293
let curChar = (orig[pos] as char);
294294
s += match curChar { // Whenever a tab occurs on the previous
295295
'\t' => "\t", // line, we insert one on the error-point-
296-
_ => " " // -squigly-line as well (instead of a
297-
}; // space). This way the squigly-line will
296+
_ => " " // -squiggly-line as well (instead of a
297+
}; // space). This way the squiggly-line will
298298
} // usually appear in the correct position.
299299
io::stderr().write_str(s);
300300
let mut s = ~"^";
301301
let hi = cm.lookup_char_pos(sp.hi);
302302
if hi.col != lo.col {
303303
// the ^ already takes up one space
304-
let num_squiglies = hi.col.to_uint()-lo.col.to_uint()-1u;
305-
for num_squiglies.times() { s += "~"; }
304+
let num_squigglies = hi.col.to_uint()-lo.col.to_uint()-1u;
305+
for num_squigglies.times() { s += "~"; }
306306
}
307-
print_maybe_colored(s + "\n", term::color_bright_green);
307+
print_maybe_colored(s + "\n", diagnosticcolor(lvl));
308308
}
309309
}
310310

0 commit comments

Comments
 (0)