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 cycle when debug-printing opaque types #66594

Merged
merged 2 commits into from Nov 24, 2019

Conversation

@Aaron1011
Copy link
Contributor

Aaron1011 commented Nov 21, 2019

Fixes #61577

When printing an opaque type in non-verbose mode, we use the
tcx.predicates_of query to retrieve the opaque type's bounds for
pretty-printing. However, the pervasiveness of logging within librustc
means that we may already be executing tcx.predicates_of for the
opaque type we're trying to print, leading to a cycle error.

This commit adds a new 'no queries' thread-local flag to the pretty
printer. This flag is enabled during the computation of predicates_of
for opaque types, and causes us to print the opaque type in 'verbose'
mode (which does not require computing any additinal queries). This
should only affect debug logging for highly nested log messages, not any
user-visible output.

Fixes #61577

When printing an opaque type in non-verbose mode, we use the
`tcx.predicates_of` query to retrieve the opaque type's bounds for
pretty-printing. However, the pervasiveness of logging within librustc
means that we may already be executing `tcx.predicates_of` for the
opaque type we're trying to print, leading to a cycle error.

This commit adds a new 'no queries' thread-local flag to the pretty
printer. This flag is enabled during the computation of `predicates_of`
for opaque types, and causes us to print the opaque type in 'verbose'
mode (which does not require computing any additinal queries). This
should only affect debug logging for highly nested log messages, not any
user-visible output.
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Nov 21, 2019

r? @matthewjasper

(rust_highfive has picked a reviewer for you, use r? to override)

Copy link
Contributor

matthewjasper left a comment

r=me with comment addressed

src/librustc_typeck/collect.rs Outdated Show resolved Hide resolved
@Aaron1011

This comment has been minimized.

Copy link
Contributor Author

Aaron1011 commented Nov 23, 2019

@matthewjasper

This comment has been minimized.

Copy link
Contributor

matthewjasper commented Nov 23, 2019

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 23, 2019

📌 Commit 2ba982d has been approved by matthewjasper

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 23, 2019

🌲 The tree is currently closed for pull requests below priority 10, this pull request will be tested once the tree is reopened

Centril added a commit to Centril/rust that referenced this pull request Nov 24, 2019
…matthewjasper

Fix cycle when debug-printing opaque types

Fixes rust-lang#61577

When printing an opaque type in non-verbose mode, we use the
`tcx.predicates_of` query to retrieve the opaque type's bounds for
pretty-printing. However, the pervasiveness of logging within librustc
means that we may already be executing `tcx.predicates_of` for the
opaque type we're trying to print, leading to a cycle error.

This commit adds a new 'no queries' thread-local flag to the pretty
printer. This flag is enabled during the computation of `predicates_of`
for opaque types, and causes us to print the opaque type in 'verbose'
mode (which does not require computing any additinal queries). This
should only affect debug logging for highly nested log messages, not any
user-visible output.
bors added a commit that referenced this pull request Nov 24, 2019
Rollup of 5 pull requests

Successful merges:

 - #64856 (Scope format! temporaries)
 - #66411 (mem::forget docs: mention ManuallyDrop)
 - #66594 (Fix cycle when debug-printing opaque types)
 - #66641 (parser: recover on nested ADTs as enum variants)
 - #66659 (make `./x.py bench` again)

Failed merges:

r? @ghost
@bors bors merged commit 2ba982d into rust-lang:master Nov 24, 2019
4 checks passed
4 checks passed
pr #20191123.34 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-6.0) Linux x86_64-gnu-llvm-6.0 succeeded
Details
pr (Linux x86_64-gnu-tools) Linux x86_64-gnu-tools succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.