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 {
103
103
if start == end {
104
104
return ;
105
105
}
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
+ }
106
111
let _ = self . lines [ line] . drain ( start..( end - string. chars ( ) . count ( ) ) ) ;
107
112
for ( i, c) in string. chars ( ) . enumerate ( ) {
108
113
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
2891
2891
}
2892
2892
2893
2893
#[ test]
2894
- #[ should_panic( expected = "range end index 47 out of range for slice of length 26" ) ]
2895
2894
fn rustdoc_ui_diagnostic_width ( ) {
2896
2895
// tests/rustdoc-ui/diagnostic-width.rs
2897
2896
You can’t perform that action at this time.
0 commit comments