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

Don't cause a cycle when formatting query description that references a FnDef #107585

Merged
merged 2 commits into from
Feb 3, 2023

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Feb 2, 2023

When a function returns -> _, we use typeck to compute what the resulting type of the body should be. If we call another query inside of typeck and hit a cycle error, we attempt to report the cycle error which requires us to compute all of the query descriptions for the stack.

However, if one of the queries in that cycle has a query description that references this function as a FnDef type, we'll cause a second cycle error from within the cycle error reporting code, since rendering a FnDef requires us to compute its signature. This causes an unwrap to ICE, since during the second cycle reporting code, we try to look for a job that isn't in the active jobs list.

We can avoid this by using with_no_queries! when computing these query descriptions.

Fixes #107089

The only drawback is that the rendering of opaque types in cycles regresses a bit :| I'm open to alternate suggestions about how we may handle this...

@rustbot
Copy link
Collaborator

rustbot commented Feb 2, 2023

r? @oli-obk

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

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 2, 2023
@oli-obk
Copy link
Contributor

oli-obk commented Feb 3, 2023

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Feb 3, 2023

📌 Commit 745d60c has been approved by oli-obk

It is now in the queue for this repository.

@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 Feb 3, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 3, 2023
Rollup of 6 pull requests

Successful merges:

 - rust-lang#107082 (Autotrait bounds on dyn-safe trait methods)
 - rust-lang#107427 (Add candidates for DiscriminantKind builtin)
 - rust-lang#107539 (Emit warnings on unused parens in index expressions)
 - rust-lang#107544 (Improve `TokenCursor`.)
 - rust-lang#107585 (Don't cause a cycle when formatting query description that references a FnDef)
 - rust-lang#107633 (Fix suggestion for coercing Option<&String> to Option<&str>)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit d6f0c51 into rust-lang:master Feb 3, 2023
@rustbot rustbot added this to the 1.69.0 milestone Feb 3, 2023
@compiler-errors compiler-errors deleted the fndef-sig-cycle branch August 11, 2023 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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]: None in query system
4 participants