diff options
| author | kennytm <kennytm@gmail.com> | 2018-01-18 01:57:16 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-01-18 01:57:16 +0800 |
| commit | bd8aa02ff4b76a6aa9c03ad8ab80aaab21080e9c (patch) | |
| tree | b2988ced186bb5dd1c5bf5118c2b6e7b959964fe /src/librustc_errors | |
| parent | e7087f0f4f5300734f37498d4ed9059aafdfcf0a (diff) | |
| parent | efe3d69ad827cc359b1a120b0e5c58dd87a2935b (diff) | |
| download | rust-bd8aa02ff4b76a6aa9c03ad8ab80aaab21080e9c.tar.gz rust-bd8aa02ff4b76a6aa9c03ad8ab80aaab21080e9c.zip | |
Rollup merge of #47407 - gaurikholkar:master, r=estebank
fix mispositioned span
This fixes #47377
The output now looks like this
```
error[E0369]: binary operation `+` cannot be applied to type `&str`
--> h.rs:3:11
|
3 | let _a = b + ", World!";
| ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings
help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
|
3 | let _a = b.to_owned() + ", World!";
| ^^^^^^^^^
error: aborting due to previous error
```
For the case when emojis are involved, it gives the new output for proper indentation.
But for an indentation as follows,
```
fn main() {
let b = "hello";
let _a = b + ", World!";
}
```
it still mispositions the span
```
3 | println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!";
| ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings
|
3 | println!("🦀🦀🦀🦀🦀"); let _a = b.to_owned() + ", World!";
| ^^^^^^^
error: aborting due to previous erro
```
cc @estebank @est31
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/emitter.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 1c3d4af9e18..58f851aea38 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -1187,8 +1187,8 @@ impl EmitterWriter { let sub_len = parts[0].snippet.trim().chars().fold(0, |acc, ch| { acc + unicode_width::UnicodeWidthChar::width(ch).unwrap_or(0) }); - let underline_start = span_start_pos.col.0 + start; - let underline_end = span_start_pos.col.0 + start + sub_len; + let underline_start = span_start_pos.col_display + start; + let underline_end = span_start_pos.col_display + start + sub_len; for p in underline_start..underline_end { buffer.putc(row_num, max_line_num_len + 3 + p, |
