Skip to content

Commit

Permalink
Rollup merge of #71064 - dwrensha:issue-69130, r=eddyb
Browse files Browse the repository at this point in the history
fix issue 69130

Closes #69130.
  • Loading branch information
Dylan-DPC authored Apr 12, 2020
2 parents c076da0 + 57ed3d3 commit ebb1a8b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/librustc_errors/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/consts/miri_unleashed/mutable_const2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/test/ui/issues/issue-69130.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 21 additions & 0 deletions src/test/ui/issues/issue-69130.stderr
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit ebb1a8b

Please sign in to comment.