-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Span off-by-one error in diagnostics #58270
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Happy to take this on if no one else has. It'll be my first time contributing to Rust. |
@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 |
@relchar Are you working on this? If not can I work on this issue? Thanks! |
Hey Gargi, feel free to take it. I haven’t been able to take a look yet.
… 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.
|
@gs0510 Are you working on this? Please let me know if I can work on this. |
Hi @saleemjaffer, yes I'm working on it. :) I will have a PR open by EOD today. |
@gs0510 have you had a chance to work on this? Or would you like me to take over? |
hey @xldenis, please feel free to take over. Thanks! |
@estebank is there any reason to ever keep a zero width annotation with no label? |
@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 |
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 :) |
…annotation, r=estebank Fix rust-lang#58270, fix off-by-one error in error diagnostics. This fixes rust-lang#58270 by checking if two diagnostics overlap completely when we're calculating the line offset for each message.
Rollup of 6 pull requests Successful merges: - #59560 (MIR generation cleanup) - #59697 (tweak unresolved label suggestion) - #60038 (Add codegen test for PGO instrumentation.) - #60160 (Fix #58270, fix off-by-one error in error diagnostics.) - #60185 (Reexport IntErrorKind in std) - #60243 (Add regression test for #53249.) Failed merges: r? @ghost
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:
This should instead be
The text was updated successfully, but these errors were encountered: