Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue 69130 #71064

Merged
merged 1 commit into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`.