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 error when emitting suggestion for mismatched fn type #69936

Merged
merged 1 commit into from
Mar 27, 2020

Conversation

Aaron1011
Copy link
Member

Fixes #66667

Previously, we called tcx.typeck_tables_of when determining whether or
not to emit a suggestion for a type error. However, we might already be
type-checking the DefId we pass to typeck_tables_of (it could be
anywhere in the query stack).

Fortunately, we only need the function signature, not the entire
TypeckTables. By using tcx.fn_sig, we avoid the possibility of cycle
errors while retaining the ability to emit a suggestion.

Fixes rust-lang#66667

Previously, we called `tcx.typeck_tables_of` when determining whether or
not to emit a suggestion for a type error. However, we might already be
type-checking the `DefId` we pass to `typeck_tables_of` (it could be
anywhere in the query stack).

Fortunately, we only need the function signature, not the entire
`TypeckTables`. By using `tcx.fn_sig`, we avoid the possibility of cycle
errors while retaining the ability to emit a suggestion.
@rust-highfive
Copy link
Collaborator

r? @varkor

(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 Mar 11, 2020
@varkor
Copy link
Member

varkor commented Mar 26, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Mar 26, 2020

📌 Commit ff65bff has been approved by varkor

@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 Mar 26, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 27, 2020
Rollup of 5 pull requests

Successful merges:

 - rust-lang#69644 (Remove framework in `dataflow/mod.rs` in favor of "generic" one)
 - rust-lang#69936 (Fix cycle error when emitting suggestion for mismatched `fn` type)
 - rust-lang#70048 (Allow obtaining &mut OsStr)
 - rust-lang#70344 (Decouple `rustc_hir::print` into `rustc_hir_pretty`)
 - rust-lang#70435 (Add regression test for rust-lang#66706)

Failed merges:

r? @ghost
@bors bors merged commit f635c37 into rust-lang:master Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

Cycle error when accidentally comparing a function inside itself
4 participants