You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When two diagnostic spans are of the same width/location (effectively the same) and only one of them has a label, the output is the same as for a single one. There's a corner case where having a zero-width span (which get's rendered as a 1-char-wide span) fall in the same place as a 1-char-wide span without a label, resulting in the following output:
{foo(bar {}}
- ^
| |
| help: `)` may belong here
|
unclosed delimiter
This should instead be
{foo(bar {}}
- ^ help: `)` may belong here
|
unclosed delimiter
// Watch out for "empty spans". If we get a span like 6..6, we
// want to just display a `^` at 6, so convert that to
// 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_display == hi.col_display && lo.line == hi.line{
hi.col_display += 1;
}
and finally here is the logic for displaying spans, which is a bit verbose, but at least it has some comments that explain what is supposed to be going on (this is where I would expect the fix to consider zero-width spans as a 1 char wide span to be made)
Please take a look at The Forge, which has a lot of relevant information on how to work with the rustc codebase, particularly how to run tests (usually, ./x.py test src/test/ui --stage 1 --bless).
On Feb 26, 2019, at 4:15 PM, Gargi Sharma ***@***.***> wrote:
@relchar Are you working on this? If not can I work on this issue? Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
@xldenis zero width annotations are not always zero width conceptually. They mark a place in between two characters, and are often used for suggestions to mark a place where we'll add code or by diagnostics to point at a place in between two tokens. Sometimes having a label doesn't increase the understanding of the error. In the example shown above, we have a suggestion to add ) in between the two } characters and we also have the primary span pointing at the closing }. Does that make sense?
Activity
relchar commentedon Feb 7, 2019
Happy to take this on if no one else has. It'll be my first time contributing to Rust.
estebank commentedon Feb 8, 2019
@relchar that'd be awesome!
The actual case that made the bug evident is being introduced in #57944 (if you look at https://github.com/rust-lang/rust/pull/57944/files#diff-beb01736b1c52103f2dcd2eac341b810R4).
The following is the code that turns small suggestions into an inline label:
rust/src/librustc_errors/emitter.rs
Lines 37 to 63 in d173180
the following is the code where we account for zero-width spans
rust/src/librustc_errors/emitter.rs
Lines 220 to 227 in d173180
and finally here is the logic for displaying spans, which is a bit verbose, but at least it has some comments that explain what is supposed to be going on (this is where I would expect the fix to consider zero-width spans as a 1 char wide span to be made)
rust/src/librustc_errors/emitter.rs
Lines 400 to 521 in d173180
Feel free to reach out to anyone in the team either here or at https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fdiagnostics
Please take a look at The Forge, which has a lot of relevant information on how to work with the
rustccodebase, particularly how to run tests (usually,./x.py test src/test/ui --stage 1 --bless).gs0510 commentedon Feb 27, 2019
@relchar Are you working on this? If not can I work on this issue? Thanks!
relchar commentedon Feb 27, 2019
saleemjaffer commentedon Mar 13, 2019
@gs0510 Are you working on this? Please let me know if I can work on this.
gs0510 commentedon Mar 13, 2019
Hi @saleemjaffer, yes I'm working on it. :) I will have a PR open by EOD today.
xldenis commentedon Apr 16, 2019
@gs0510 have you had a chance to work on this? Or would you like me to take over?
gs0510 commentedon Apr 16, 2019
hey @xldenis, please feel free to take over. Thanks!
xldenis commentedon Apr 16, 2019
@estebank is there any reason to ever keep a zero width annotation with no label?
estebank commentedon Apr 17, 2019
@xldenis zero width annotations are not always zero width conceptually. They mark a place in between two characters, and are often used for suggestions to mark a place where we'll add code or by diagnostics to point at a place in between two tokens. Sometimes having a label doesn't increase the understanding of the error. In the example shown above, we have a suggestion to add
)in between the two}characters and we also have the primary span pointing at the closing}. Does that make sense?xldenis commentedon Apr 18, 2019
yea it does, I need to do some more debugging and investigating but I think I'll be able to come up with a fix for this edge-case soon :)
Rollup merge of rust-lang#60160 - xldenis:fix-overlapping-zero-width-…
Auto merge of #60250 - Centril:rollup-d9tehhr, r=Centril