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

Cycle error when accidentally comparing a function inside itself #66667

Closed
RalfJung opened this issue Nov 23, 2019 · 0 comments · Fixed by #69936
Closed

Cycle error when accidentally comparing a function inside itself #66667

RalfJung opened this issue Nov 23, 2019 · 0 comments · Fixed by #69936
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. D-confusing Diagnostics: Confusing error or lint that should be reworked. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@RalfJung
Copy link
Member

The following code leads to an inscrutable error message:

fn up() {
    up == 1
}
error[E0391]: cycle detected when processing `up`
 --> src/lib.rs:1:1
  |
1 | fn up() {
  | ^^^^^^^
  |
  = note: ...which again requires processing `up`, completing the cycle
  = note: cycle used when type-checking all item bodies

error: aborting due to previous error

I had this happen in a 10-line function and it took me a bit to realize that I typo'd the function instead of a variable name somewhere. There is no indication where inside the function the bad use is.

@jonas-schievink jonas-schievink added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Nov 23, 2019
@estebank estebank added D-confusing Diagnostics: Confusing error or lint that should be reworked. D-papercut Diagnostics: An error or lint that needs small tweaks. labels Jan 13, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Mar 27, 2020
…arkor

Fix cycle error when emitting suggestion for mismatched `fn` type

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.
@bors bors closed this as completed in ff65bff Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. D-confusing Diagnostics: Confusing error or lint that should be reworked. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants