diff options
| author | bors <bors@rust-lang.org> | 2017-11-04 23:09:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-11-04 23:09:19 +0000 |
| commit | 12e6b53744a0101f28855f25e6e4551e2d664857 (patch) | |
| tree | efa9116ee7711cb5512a48470041b99e23003d25 /src/librustc_errors | |
| parent | d762b1d6c67db12e117186d94d70e46cddb22965 (diff) | |
| parent | 272c2faa1d766fd4185141106959cdb58b88e6e9 (diff) | |
Auto merge of #45711 - tirr-c:unicode-span, r=estebank
Display spans correctly when there are zero-width or wide characters
Hopefully...
* fixes #45211
* fixes #8706
---
Before:
```
error: invalid width `7` for integer literal
--> unicode_2.rs:12:25
|
12 | let _ = ("a̐éö̲", 0u7);
| ^^^
|
= help: valid widths are 8, 16, 32, 64 and 128
error: invalid width `42` for integer literal
--> unicode_2.rs:13:20
|
13 | let _ = ("아あ", 1i42);
| ^^^^
|
= help: valid widths are 8, 16, 32, 64 and 128
error: aborting due to 2 previous errors
```
After:
```
error: invalid width `7` for integer literal
--> unicode_2.rs:12:25
|
12 | let _ = ("a̐éö̲", 0u7);
| ^^^
|
= help: valid widths are 8, 16, 32, 64 and 128
error: invalid width `42` for integer literal
--> unicode_2.rs:13:20
|
13 | let _ = ("아あ", 1i42);
| ^^^^
|
= help: valid widths are 8, 16, 32, 64 and 128
error: aborting due to 2 previous errors
```
Spans might display incorrectly on the browser.
r? @estebank
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/emitter.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 011be74ee7c..6c43c60686e 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -10,7 +10,7 @@ use self::Destination::*; -use syntax_pos::{DUMMY_SP, FileMap, Span, MultiSpan, CharPos}; +use syntax_pos::{DUMMY_SP, FileMap, Span, MultiSpan}; use {Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, CodeMapper, DiagnosticId}; use RenderSpan::*; @@ -201,8 +201,8 @@ impl EmitterWriter { // 6..7. This is degenerate input, but it's best to degrade // gracefully -- and the parser likes to supply a span like // that for EOF, in particular. - if lo.col == hi.col && lo.line == hi.line { - hi.col = CharPos(lo.col.0 + 1); + if lo.col_display == hi.col_display && lo.line == hi.line { + hi.col_display += 1; } let ann_type = if lo.line != hi.line { @@ -210,8 +210,8 @@ impl EmitterWriter { depth: 1, line_start: lo.line, line_end: hi.line, - start_col: lo.col.0, - end_col: hi.col.0, + start_col: lo.col_display, + end_col: hi.col_display, is_primary: span_label.is_primary, label: span_label.label.clone(), }; @@ -221,8 +221,8 @@ impl EmitterWriter { AnnotationType::Singleline }; let ann = Annotation { - start_col: lo.col.0, - end_col: hi.col.0, + start_col: lo.col_display, + end_col: hi.col_display, is_primary: span_label.is_primary, label: span_label.label.clone(), annotation_type: ann_type, |
