fix issue 69130
This commit is contained in:
parent
32fb4dcdd7
commit
57ed3d378d
4 changed files with 33 additions and 2 deletions
|
@ -231,7 +231,10 @@ impl CodeSuggestion {
|
|||
}
|
||||
}
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ error: internal compiler error: mutable allocation in constant
|
|||
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
|
||||
|
|
7
src/test/ui/issues/issue-69130.rs
Normal file
7
src/test/ui/issues/issue-69130.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
// 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() {}
|
21
src/test/ui/issues/issue-69130.stderr
Normal file
21
src/test/ui/issues/issue-69130.stderr
Normal file
|
@ -0,0 +1,21 @@
|
|||
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`.
|
Loading…
Add table
Reference in a new issue