+16
-16
src/parse_error.rs
+16
-16
src/parse_error.rs
···
396
396
f,
397
397
"{}{}:{}:{}:",
398
398
" ".repeat(self.indent),
399
-
white_bold(&self.path.to_string_lossy()),
400
-
white_bold(&format!("{}", self.row + 1)),
401
-
white_bold(&format!("{}", self.columns.start + 1)),
399
+
header_style(&self.path.to_string_lossy()),
400
+
header_style(&format!("{}", self.row + 1)),
401
+
header_style(&format!("{}", self.columns.start + 1)),
402
402
)?;
403
403
if let Some(source) = self.source {
404
404
// first line: line number & source
···
406
406
f,
407
407
"{}{}{}{}",
408
408
" ".repeat(self.indent),
409
-
blue(&format!("{}", self.row + 1)),
410
-
blue(" | "),
409
+
prefix_style(&format!("{}", self.row + 1)),
410
+
prefix_style(" | "),
411
411
source,
412
412
)?;
413
413
// second line: caret
···
416
416
"{}{}{}{}{}",
417
417
" ".repeat(self.indent),
418
418
" ".repeat(self.gutter_width()),
419
-
blue(" | "),
419
+
prefix_style(" | "),
420
420
" ".repeat(self.columns.start),
421
-
green_bold(&"^".repeat(self.columns.len()))
421
+
underline_style(&"^".repeat(self.columns.len())),
422
422
)?;
423
423
} else {
424
424
writeln!(f, "{}{}", " ".repeat(self.indent), "<missing source>",)?;
···
430
430
// coloring functions
431
431
432
432
#[cfg(feature = "term-colors")]
433
-
fn blue(str: &str) -> impl std::fmt::Display {
434
-
str.blue()
433
+
fn header_style(str: &str) -> impl std::fmt::Display {
434
+
str.bold()
435
435
}
436
436
#[cfg(not(feature = "term-colors"))]
437
-
fn blue<'a>(str: &'a str) -> impl std::fmt::Display + 'a {
437
+
fn header_style<'a>(str: &'a str) -> impl std::fmt::Display + 'a {
438
438
str
439
439
}
440
440
441
441
#[cfg(feature = "term-colors")]
442
-
fn green_bold(str: &str) -> impl std::fmt::Display {
443
-
str.green().bold()
442
+
fn prefix_style(str: &str) -> impl std::fmt::Display {
443
+
str.dimmed()
444
444
}
445
445
#[cfg(not(feature = "term-colors"))]
446
-
fn green_bold<'a>(str: &'a str) -> impl std::fmt::Display + 'a {
446
+
fn prefix_style<'a>(str: &'a str) -> impl std::fmt::Display + 'a {
447
447
str
448
448
}
449
449
450
450
#[cfg(feature = "term-colors")]
451
-
fn white_bold(str: &str) -> impl std::fmt::Display {
452
-
str.white().bold()
451
+
fn underline_style(str: &str) -> impl std::fmt::Display {
452
+
str.green()
453
453
}
454
454
#[cfg(not(feature = "term-colors"))]
455
-
fn white_bold<'a>(str: &'a str) -> impl std::fmt::Display + 'a {
455
+
fn underline_style<'a>(str: &'a str) -> impl std::fmt::Display + 'a {
456
456
str
457
457
}