about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2025-02-27 22:29:22 +0000
committerEsteban Küber <esteban@kuber.com.ar>2025-03-07 17:55:08 +0000
commitcb82b79f02b79620f766d94c0e4a8c20a3ce23ee (patch)
treeae16b48ca679a4116447f50a7cdd5d4cb4a8c2c5
parentf1c751bc1a08e3439a9d0c482cbb0ea0fc8f644f (diff)
downloadrust-cb82b79f02b79620f766d94c0e4a8c20a3ce23ee.tar.gz
rust-cb82b79f02b79620f766d94c0e4a8c20a3ce23ee.zip
Fix rustdoc test
-rw-r--r--compiler/rustc_errors/src/styled_buffer.rs3
-rw-r--r--tests/rustdoc-ui/diagnostic-width.stderr4
2 files changed, 5 insertions, 2 deletions
diff --git a/compiler/rustc_errors/src/styled_buffer.rs b/compiler/rustc_errors/src/styled_buffer.rs
index b0f4ec84a89..790efd0286e 100644
--- a/compiler/rustc_errors/src/styled_buffer.rs
+++ b/compiler/rustc_errors/src/styled_buffer.rs
@@ -93,6 +93,9 @@ impl StyledBuffer {
         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);
diff --git a/tests/rustdoc-ui/diagnostic-width.stderr b/tests/rustdoc-ui/diagnostic-width.stderr
index d8c4934a576..94fc2343faf 100644
--- a/tests/rustdoc-ui/diagnostic-width.stderr
+++ b/tests/rustdoc-ui/diagnostic-width.stderr
@@ -8,8 +8,8 @@ LL | ... a http://link.com
 note: the lint level is defined here
   --> $DIR/diagnostic-width.rs:2:9
    |
-LL | ...ny(rustdoc::bare_url...
-   |       ^^^^^^^^^^^^^^^^^^
+LL | ...ny(ru...are_urls)]
+   |       ^^...^^^^^^^^
 help: use an automatic link instead
    |
 LL | /// This is a long line that contains a <http://link.com>