}
}
if let Some(cur_line) = sf.get_line(cur_lo.line - 1) {
- let end = std::cmp::min(cur_line.len(), cur_lo.col.to_usize());
+ let end = match cur_line.char_indices().nth(cur_lo.col.to_usize()) {
+ Some((i, _)) => i,
+ None => cur_line.len(),
+ };
buf.push_str(&cur_line[..end]);
}
}
LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:363:17
+thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:366:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: internal compiler error: unexpected panic
--- /dev/null
+// Issue 69130: character indexing bug in rustc_errors::CodeSuggestion::splice_lines().
+
+enum F {
+M (§& u8)}
+//~^ ERROR unknown start of token
+//~| missing lifetime specifier
+fn main() {}
--- /dev/null
+error: unknown start of token: \u{a7}
+ --> $DIR/issue-69130.rs:4:4
+ |
+LL | M (§& u8)}
+ | ^
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/issue-69130.rs:4:5
+ |
+LL | M (§& u8)}
+ | ^ expected named lifetime parameter
+ |
+help: consider introducing a named lifetime parameter
+ |
+LL | enum F<'a> {
+LL | M (§&'a u8)}
+ |
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0106`.