Skip to content
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

Do not ICE on malformed suggestion spans #68256

Merged
merged 2 commits into from
Jan 18, 2020
Merged

Conversation

estebank
Copy link
Contributor

Under the assumption that suggestions are by their very nature always "best effort", it is ok if we don't display them instead of having an ICE. The underlying issue of the malformed span being created is left unaddressed.

Fix #67567.

r? @petrochenkov

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 15, 2020
@estebank
Copy link
Contributor Author

estebank commented Jan 15, 2020

The original report produces, the following, where we see we're already emitting an invalid span in the primary diagnostic window, but handling it gracefully there:

error: expected identifier, found `)`
  --> src/ice.rs:24:9
   |
24 |         }
   |         ^ expected identifier

error: mismatched closing delimiter: `}`
  --> src/ice.rs:24:9
   |
22 |         } else {
   |                - closing delimiter possibly meant for this
23 |             return Err(m1::E1::
   |                       - unclosed delimiter
24 |         }
   |         ^ mismatched closing delimiter

error[E0308]: mismatched types
  --> src/main.rs:1:1
   |
1  | / mod ice;
2  | | fn main() {
3  | | }
...  |
   |
   = note: expected enum `std::result::Result<ice::m1::S1, ()>`
            found struct `ice::m1::S1`

Fixing the syntax error in the original report produces reasonable spans:

error[E0308]: mismatched types
  --> src/ice.rs:19:20
   |
19 |               return m1::S1 {
   |  ____________________^
20 | |                 v1: format!(""),
21 | |             }
   | |_____________^ expected enum `std::result::Result`, found struct `ice::m1::S1`
   |
   = note: expected enum `std::result::Result<ice::m1::S1, ()>`
            found struct `ice::m1::S1`
help: try using a variant of the expected enum
   |
19 |             return Ok(m1::S1 {
20 |                 v1: format!(""),
21 |             })
   |

The underlying issue is that we're taking a span from main.rs and combining it (without checking) with an end point from ice.rs.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 15, 2020
@bors
Copy link
Contributor

bors commented Jan 16, 2020

☔ The latest upstream changes (presumably #68272) made this pull request unmergeable. Please resolve the merge conflicts.

@estebank estebank added beta-nominated Nominated for backporting to the compiler in the beta channel. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 17, 2020
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jan 17, 2020

📌 Commit 03240e1 has been approved by petrochenkov

@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 17, 2020
tmandry added a commit to tmandry/rust that referenced this pull request Jan 18, 2020
Do not ICE on malformed suggestion spans

Under the assumption that suggestions are by their very nature always "best effort", it is ok if we don't display them instead of having an ICE. The underlying issue of the malformed span being _created_ is left unaddressed.

Fix rust-lang#67567.

r? @petrochenkov
tmandry added a commit to tmandry/rust that referenced this pull request Jan 18, 2020
Do not ICE on malformed suggestion spans

Under the assumption that suggestions are by their very nature always "best effort", it is ok if we don't display them instead of having an ICE. The underlying issue of the malformed span being _created_ is left unaddressed.

Fix rust-lang#67567.

r? @petrochenkov
bors added a commit that referenced this pull request Jan 18, 2020
Rollup of 9 pull requests

Successful merges:

 - #66660 (Don't warn about snake case for field puns.)
 - #68093 (Fix deref impl typedef)
 - #68204 (Use named fields for `{ast,hir}::ItemKind::Impl`)
 - #68256 (Do not ICE on malformed suggestion spans)
 - #68279 (Clean up E0198 explanation)
 - #68291 (Update sanitizer tests)
 - #68312 (Add regression test for integer literals in generic arguments in where clauses)
 - #68314 (Stop treating `FalseEdges` and `FalseUnwind` as having semantic value for const eval)
 - #68317 (Clean up E0199 explanation)

Failed merges:

r? @ghost
@bors bors merged commit 03240e1 into rust-lang:master Jan 18, 2020
@pnkfelix
Copy link
Member

discussed at T-compiler meeting. approved for beta-backport.

@pnkfelix pnkfelix added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Jan 23, 2020
@Mark-Simulacrum
Copy link
Member

@estebank This PR does not backport to beta cleanly, and the set of merge conflicts. Can you prepare a commit that backports this onto origin/beta?

@Mark-Simulacrum
Copy link
Member

Never mind. I forgot about the rustfmt changes on master, applying those to beta allowed this to backport cleanly atop them.

@Mark-Simulacrum Mark-Simulacrum removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jan 23, 2020
bors added a commit that referenced this pull request Jan 24, 2020
[beta] backports

This backports:
 * Do not ICE on malformed suggestion spans #68256
 * Distinguish between private items and hidden items in rustdoc #67875
 *  Revert parts of #66405. #67471

It also includes a few formatting commits to permit the backports to proceed cleanly (those are scoped to the relevant files, but still generate noise, of course). This was deemed easier than attempting to manually deal with the formatting.

r? @ghost
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Jan 25, 2020
Do not ICE on multipart suggestions touching multiple files

When encountering a multipart suggestion with spans belonging to
different contexts, skip that suggestion.

Fix rust-lang#68449. Similar to rust-lang#68256.
bors added a commit that referenced this pull request Jan 25, 2020
Do not ICE on multipart suggestions touching multiple files

When encountering a multipart suggestion with spans belonging to
different contexts, skip that suggestion.

Fix #68449. Similar to #68256.
@estebank estebank deleted the bad-sugg-span branch November 9, 2023 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE on invalid syntax in proc macro attr
6 participants