File tree Expand file tree Collapse file tree 4 files changed +33
-2
lines changed Expand file tree Collapse file tree 4 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -231,7 +231,10 @@ impl CodeSuggestion {
231231 }
232232 }
233233 if let Some ( cur_line) = sf. get_line ( cur_lo. line - 1 ) {
234- let end = std:: cmp:: min ( cur_line. len ( ) , cur_lo. col . to_usize ( ) ) ;
234+ let end = match cur_line. char_indices ( ) . nth ( cur_lo. col . to_usize ( ) ) {
235+ Some ( ( i, _) ) => i,
236+ None => cur_line. len ( ) ,
237+ } ;
235238 buf. push_str ( & cur_line[ ..end] ) ;
236239 }
237240 }
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ error: internal compiler error: mutable allocation in constant
1212LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
1313 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1414
15- thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:363 :17
15+ thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:366 :17
1616note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
1717
1818error: internal compiler error: unexpected panic
Original file line number Diff line number Diff line change 1+ // Issue 69130: character indexing bug in rustc_errors::CodeSuggestion::splice_lines().
2+
3+ enum F {
4+ M ( §& u8 ) }
5+ //~^ ERROR unknown start of token
6+ //~| missing lifetime specifier
7+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error: unknown start of token: \u{a7}
2+ --> $DIR/issue-69130.rs:4:4
3+ |
4+ LL | M (§& u8)}
5+ | ^
6+
7+ error[E0106]: missing lifetime specifier
8+ --> $DIR/issue-69130.rs:4:5
9+ |
10+ LL | M (§& u8)}
11+ | ^ expected named lifetime parameter
12+ |
13+ help: consider introducing a named lifetime parameter
14+ |
15+ LL | enum F<'a> {
16+ LL | M (§&'a u8)}
17+ |
18+
19+ error: aborting due to 2 previous errors
20+
21+ For more information about this error, try `rustc --explain E0106`.
You can’t perform that action at this time.
0 commit comments