|
1 | 1 | use std::{error::Error, fmt, str::CharIndices}; |
2 | 2 |
|
3 | | -use ansi_term::{Color, Style}; |
4 | | - |
5 | 3 | #[derive(Debug)] |
6 | 4 | pub struct InvalidReplaceCapture { |
7 | 5 | original_replace: String, |
@@ -53,21 +51,19 @@ impl fmt::Display for InvalidReplaceCapture { |
53 | 51 | // Build up the error to show the user |
54 | 52 | let mut formatted = String::new(); |
55 | 53 | let mut arrows_start = Span::start_at(0); |
56 | | - let special = Style::new().bold(); |
57 | | - let error = Style::from(Color::Red).bold(); |
58 | 54 | for (byte_index, c) in original_replace.char_indices() { |
59 | 55 | let (prefix, suffix, text) = match SpecialChar::new(c) { |
60 | 56 | Some(c) => { |
61 | | - (Some(special.prefix()), Some(special.suffix()), c.render()) |
| 57 | + (Some("" /* special prefix */), Some("" /* special suffix */), c.render()) |
62 | 58 | } |
63 | 59 | None => { |
64 | 60 | let (prefix, suffix) = if byte_index == invalid_ident.start |
65 | 61 | { |
66 | | - (Some(error.prefix()), None) |
| 62 | + (Some("" /* error prefix */), None) |
67 | 63 | } else if byte_index |
68 | 64 | == invalid_ident.end.checked_sub(1).unwrap() |
69 | 65 | { |
70 | | - (None, Some(error.suffix())) |
| 66 | + (None, Some("" /* error suffix */)) |
71 | 67 | } else { |
72 | 68 | (None, None) |
73 | 69 | }; |
@@ -99,20 +95,20 @@ impl fmt::Display for InvalidReplaceCapture { |
99 | 95 | let mut arrows = " ".repeat(arrows_span.start); |
100 | 96 | arrows.push_str(&format!( |
101 | 97 | "{}", |
102 | | - Style::new().bold().paint("^".repeat(arrows_span.len())) |
| 98 | + "^".repeat(arrows_span.len()) |
103 | 99 | )); |
104 | 100 |
|
105 | 101 | let ident = invalid_ident.slice(original_replace); |
106 | 102 | let (number, the_rest) = ident.split_at(*num_leading_digits); |
107 | 103 | let disambiguous = format!("${{{number}}}{the_rest}"); |
108 | 104 | let error_message = format!( |
109 | 105 | "The numbered capture group `{}` in the replacement text is ambiguous.", |
110 | | - Style::new().bold().paint(format!("${}", number).to_string()) |
| 106 | + format!("${}", number).to_string() |
111 | 107 | ); |
112 | 108 | let hint_message = format!( |
113 | 109 | "{}: Use curly braces to disambiguate it `{}`.", |
114 | | - Style::from(Color::Blue).bold().paint("hint"), |
115 | | - Style::new().bold().paint(disambiguous) |
| 110 | + "hint", |
| 111 | + disambiguous |
116 | 112 | ); |
117 | 113 |
|
118 | 114 | writeln!(f, "{}", error_message)?; |
|
0 commit comments