diff options
| author | Laurențiu Nicola <lnicola@dend.ro> | 2025-03-10 10:41:53 +0200 |
|---|---|---|
| committer | Laurențiu Nicola <lnicola@dend.ro> | 2025-03-10 10:41:53 +0200 |
| commit | e1da1b09bfcc94a109c01f19923d6ba4a3994915 (patch) | |
| tree | 99dbdd51585c5e7c1fd6bb15463fe61b1363b24b /compiler/rustc_errors/src/styled_buffer.rs | |
| parent | fdee1c1455481516e61381dcd93a0adab2b64dbf (diff) | |
| parent | 2c6a12ec44d0426c8939123c2f2cf27d2217de13 (diff) | |
| download | rust-e1da1b09bfcc94a109c01f19923d6ba4a3994915.tar.gz rust-e1da1b09bfcc94a109c01f19923d6ba4a3994915.zip | |
Merge from rust-lang/rust
Diffstat (limited to 'compiler/rustc_errors/src/styled_buffer.rs')
| -rw-r--r-- | compiler/rustc_errors/src/styled_buffer.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_errors/src/styled_buffer.rs b/compiler/rustc_errors/src/styled_buffer.rs index 5ca9e9b18f3..790efd0286e 100644 --- a/compiler/rustc_errors/src/styled_buffer.rs +++ b/compiler/rustc_errors/src/styled_buffer.rs @@ -89,6 +89,19 @@ impl StyledBuffer { } } + pub(crate) fn replace(&mut self, line: usize, start: usize, end: usize, string: &str) { + if start == end { + return; + } + if start > self.lines[line].len() || end > self.lines[line].len() { + return; + } + let _ = self.lines[line].drain(start..(end - string.chars().count())); + for (i, c) in string.chars().enumerate() { + self.lines[line][start + i] = StyledChar::new(c, Style::LineNumber); + } + } + /// For given `line` inserts `string` with `style` before old content of that line, /// adding lines if needed pub(crate) fn prepend(&mut self, line: usize, string: &str, style: Style) { |
