File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,11 @@ impl StyledBuffer {
103103 if start == end {
104104 return ;
105105 }
106+ // If the replacement range would be out of bounds, do nothing, as we
107+ // can't replace things that don't exist.
108+ if start > self . lines [ line] . len ( ) || end > self . lines [ line] . len ( ) {
109+ return ;
110+ }
106111 let _ = self . lines [ line] . drain ( start..( end - string. chars ( ) . count ( ) ) ) ;
107112 for ( i, c) in string. chars ( ) . enumerate ( ) {
108113 self . lines [ line] [ start + i] = StyledChar :: new ( c, ElementStyle :: LineNumber ) ;
Original file line number Diff line number Diff line change @@ -2891,7 +2891,6 @@ $DIR/short-error-format.rs:8:7: error[E0599]: no method named `salut` found for
28912891}
28922892
28932893#[ test]
2894- #[ should_panic( expected = "range end index 47 out of range for slice of length 26" ) ]
28952894fn rustdoc_ui_diagnostic_width ( ) {
28962895 // tests/rustdoc-ui/diagnostic-width.rs
28972896
You can’t perform that action at this time.
0 commit comments