-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Reorder span suggestions to appear below main labels #43251
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nit. Lgtm otherwise
src/librustc_errors/emitter.rs
Outdated
@@ -347,8 +347,7 @@ impl EmitterWriter { | |||
|
|||
// Sort the annotations by (start, end col) | |||
let mut annotations = line.annotations.clone(); | |||
annotations.sort(); | |||
annotations.reverse(); | |||
annotations.sort_by(|a,b| b.start_col.cmp(&a.start_col)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment here about what and why this is done, the reversing is pretty subtle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that a comment would be good. I personally have no idea why this yields the correct result. =) But the change looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have a list of annotations (A1, A2, C1, C2, B1, B2) where the letter signifies the span, since we are only sorting by the span, the order of the elements with the same span will never change. Since we are reversing the ordering (|a, b|
but b.cmp(a)
), you get (C1, C2, B1, B2, A1, A2). All the elements with the same span are still ordered first to last, but all the elements with different spans are ordered by their spans in last to first order. Last to first order is important, because the jiggly lines and |
are on the left, so the rightmost span needs to be rendered first, otherwise the lines would end up needing to go over a message.
If the above is comprehensible, I think it can be copy pasted as the requested comment ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we are only sorting by the span, the order of the elements with the same span will never change
This is because our sort is stable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nikomatsakis the documentation says that sort_by
is stable though. @oli-obk @evolarium
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a pretty decent description. =)
hmm, bors does't like review comments. I'm not a reviewer, so: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment explaining why the sort produces the desired effect would be good! But otherwise looks nice.
☔ The latest upstream changes (presumably #42033) made this pull request unmergeable. Please resolve the merge conflicts. |
e38877f
to
66f3c07
Compare
@bors r+ |
📌 Commit 66f3c07 has been approved by |
You have some trailing whitespace in
|
@oli-obk fixed the tidy errors. |
@bors r+ |
📌 Commit 601a7a9 has been approved by |
Could you squash the commits down? |
db9b62b
to
26a8357
Compare
@bors r+ |
📌 Commit 26a8357 has been approved by |
⌛ Testing commit 26a8357 with merge 67cdb87d51c55b3a1b2e70f37992f70f8fcda9e9... |
💔 Test failed - status-travis |
@bors retry |
⌛ Testing commit 26a8357 with merge f868a5ba86c3e204cfde67a7ec9405bd6433bbee... |
💔 Test failed - status-appveyor |
spurious?
|
Network connectivity issues? |
@bors: retry
…On Wed, Jul 19, 2017 at 4:02 AM, bors ***@***.***> wrote:
💔 Test failed - status-appveyor
<https://ci.appveyor.com/project/rust-lang/rust/build/1.0.3972>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#43251 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AaPN0C1dUzhMugaxuquAokDAsrfW3imXks5sPcYkgaJpZM4OZAep>
.
--
You received this message because you are subscribed to the Google Groups
"rust-ops" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ***@***.***
To post to this group, send email to ***@***.***
To view this discussion on the web visit https://groups.google.com/d/
msgid/rust-ops/rust-lang/rust/pull/43251/c316320506%40github.com
<https://groups.google.com/d/msgid/rust-ops/rust-lang/rust/pull/43251/c316320506%40github.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
|
@nagbot-rs: 🔑 Insufficient privileges: and not in try users |
@bors: retry |
Reorder span suggestions to appear below main labels A fix to #41698 r? @nikomatsakis
☀️ Test successful - status-appveyor, status-travis |
A fix to #41698
r? @nikomatsakis