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

Fix ICE with -Zunpretty=hir,typed #86645

Merged
merged 3 commits into from
Jun 27, 2021
Merged

Conversation

FabianWolff
Copy link
Contributor

This PR fixes #82328. The -Zunpretty=hir,typed pretty-printer maintains an Option with type-checking results and sets the Option to Some when entering a body. However, this leads to an ICE if an expression occurs in a function signature (i.e. outside of a body), such as 128 in

fn foo(-128..=127: i8) {}

This PR fixes the ICE by checking (if necessary) whether the expression's owner has a body, and retrieving type-checking results for that on the fly.

@rust-highfive
Copy link
Collaborator

r? @LeSeulArtichaut

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 26, 2021
Copy link
Contributor

@LeSeulArtichaut LeSeulArtichaut left a comment

Choose a reason for hiding this comment

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

I thought that it might be easier to update the typeck results when entering an item instead of a body, but it gets harder when you throw closures into the mix, so this LGTM.

Left two nits

compiler/rustc_driver/src/pretty.rs Outdated Show resolved Hide resolved
src/test/ui/unpretty-expr-fn-arg.rs Outdated Show resolved Hide resolved
@LeSeulArtichaut
Copy link
Contributor

Thanks for the PR! @bors r+

@bors
Copy link
Contributor

bors commented Jun 26, 2021

📌 Commit e8ebf98 has been approved by LeSeulArtichaut

@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 Jun 26, 2021
@bors
Copy link
Contributor

bors commented Jun 26, 2021

⌛ Testing commit e8ebf98 with merge b37ef75b1eb535511dc83fd831f4e06b6424a03c...

@rust-log-analyzer
Copy link
Collaborator

The job dist-x86_64-apple-alt failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
      Memory: 14 GB
      Boot ROM Version: VMW71.00V.13989454.B64.1906190538
      Apple ROM Info: [MS_VM_CERT/SHA1/27d66596a61c48dd3dc7216fd715126e33f59ae7]Welcome to the Virtual Machine
      SMC Version (system): 2.8f0
      Serial Number (system): VMyFXmVnVEue

hw.ncpu: 3
hw.byteorder: 1234
hw.memsize: 15032385536
---
[TIMING] ToolBuild { compiler: Compiler { stage: 0, host: TargetSelection { triple: "x86_64-apple-darwin", file: None } }, target: TargetSelection { triple: "x86_64-apple-darwin", file: None }, tool: "unstable-book-gen", path: "src/tools/unstable-book-gen", mode: ToolBootstrap, is_optional_tool: false, source_type: InTree, extra_features: [] } -- 86.074
[TIMING] UnstableBookGen { compiler: Compiler { stage: 0, host: TargetSelection { triple: "x86_64-apple-darwin", file: None } }, target: TargetSelection { triple: "x86_64-apple-darwin", file: None } } -- 0.000


command did not execute successfully: "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-tools-bin/unstable-book-gen" "/Users/runner/work/rust/rust/library" "/Users/runner/work/rust/rust/compiler" "/Users/runner/work/rust/rust/src" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/md-doc/unstable-book"
expected success, got: signal: 9

failed to run: /Users/runner/work/rust/rust/build/bootstrap/debug/bootstrap dist
Build completed unsuccessfully in 0:01:27

@bors
Copy link
Contributor

bors commented Jun 26, 2021

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 26, 2021
@LeSeulArtichaut
Copy link
Contributor

@bors retry

@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 Jun 27, 2021
@bors
Copy link
Contributor

bors commented Jun 27, 2021

⌛ Testing commit e8ebf98 with merge a5b7511...

@bors
Copy link
Contributor

bors commented Jun 27, 2021

☀️ Test successful - checks-actions
Approved by: LeSeulArtichaut
Pushing a5b7511 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 27, 2021
@bors bors merged commit a5b7511 into rust-lang:master Jun 27, 2021
@rustbot rustbot added this to the 1.55.0 milestone Jun 27, 2021
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.

ICE: TypedAnnotation::typeck_results called outside of body: foo(-128..=127: i8) with -Zunpretty=hir,typed
6 participants