Skip to content

Avoid ICE in macro's diagnostics#68633

Merged
bors merged 2 commits into
rust-lang:masterfrom
JohnTitor:avoid-ice-in-diagnostics
Feb 1, 2020
Merged

Avoid ICE in macro's diagnostics#68633
bors merged 2 commits into
rust-lang:masterfrom
JohnTitor:avoid-ice-in-diagnostics

Conversation

@JohnTitor

Copy link
Copy Markdown
Member

Fixes #68629

r? @estebank

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 29, 2020
Comment thread src/librustc_parse/parser/item.rs Outdated
"change the delimiters to curly braces",
vec![
(self.prev_span.with_hi(self.prev_span.lo() + BytePos(1)), '{'.to_string()),
(self.prev_span.with_lo(self.prev_span.hi() - BytePos(1)), '}'.to_string()),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like there's a missing Span method here (self.prev_span.shift_left(...))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find the shift_left method: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/struct.Span.html
Am I still missing something?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm saying that we could add a higher level operation to avoid dealing with primitives like this. :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so we can add this tweak as a pub method of Span, right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that would be the idea, if we think it's a good one. cc also @petrochenkov

@JohnTitor JohnTitor Jan 30, 2020

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel it'd be nice that we'll do it as follow-up work, how about?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SourceMap::next_point let's you advance 1 char at a time (and is now unicode aware). We don't have a method to move left. It is in SourceMap instead of Span because you need to look at the underlying code for the span to be validated as not falling in the middle of a character.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this might work better with shrink_to_hi and shrink_to_lo instead of with_*.

@JohnTitor

Copy link
Copy Markdown
Member Author

I think it's ready to review, could you confirm the diagnostics are valid? @estebank

@estebank

Copy link
Copy Markdown
Contributor

@JohnTitor The output is fine 👍

@estebank

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Jan 31, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit b1c91ee has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 31, 2020
@bors

bors commented Jan 31, 2020

Copy link
Copy Markdown
Collaborator

⌛ Testing commit b1c91ee with merge cdd41ea...

bors added a commit that referenced this pull request Jan 31, 2020
@bors

bors commented Feb 1, 2020

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-azure
Approved by: estebank
Pushing cdd41ea to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 1, 2020
@bors bors merged commit b1c91ee into rust-lang:master Feb 1, 2020
@rust-highfive

Copy link
Copy Markdown
Contributor

📣 Toolstate changed by #68633!

Tested on commit cdd41ea.
Direct link to PR: #68633

💔 rustc-guide on linux: test-pass → test-fail (cc @JohnTitor @amanjeev @spastorino @mark-i-m, @rust-lang/infra).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Feb 1, 2020
Tested on commit rust-lang/rust@cdd41ea.
Direct link to PR: <rust-lang/rust#68633>

💔 rustc-guide on linux: test-pass → test-fail (cc @JohnTitor @amanjeev @spastorino @mark-i-m, @rust-lang/infra).
@JohnTitor JohnTitor deleted the avoid-ice-in-diagnostics branch February 1, 2020 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

internal compiler error: "byte index 15 is not a char boundary"

6 participants