about summary refs log tree commit diff
path: root/compiler/rustc_errors/src/styled_buffer.rs
diff options
context:
space:
mode:
authorThe Miri Cronjob Bot <miri@cron.bot>2025-03-11 05:21:51 +0000
committerThe Miri Cronjob Bot <miri@cron.bot>2025-03-11 05:21:51 +0000
commit4f2a03c011dce98a354bf1947814ea9b428d0f1b (patch)
tree8ed0a4f28637b7609ac6771ecf499f8f2445a52b /compiler/rustc_errors/src/styled_buffer.rs
parent5889b95f4e04716058da56a5162b4f62338cd922 (diff)
parentc5fc1931a05f48fe3b4adf213ad3fcefb4e4434b (diff)
downloadrust-4f2a03c011dce98a354bf1947814ea9b428d0f1b.tar.gz
rust-4f2a03c011dce98a354bf1947814ea9b428d0f1b.zip
Merge from rustc
Diffstat (limited to 'compiler/rustc_errors/src/styled_buffer.rs')
-rw-r--r--compiler/rustc_errors/src/styled_buffer.rs13
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) {