]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #107585 - compiler-errors:fndef-sig-cycle, r=oli-obk
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>
Fri, 3 Feb 2023 17:34:52 +0000 (23:04 +0530)
committerGitHub <noreply@github.com>
Fri, 3 Feb 2023 17:34:52 +0000 (23:04 +0530)
commitd6f0c51e98bf330b9d40d57ec4d8063940975505
tree5cd2bb9559ff71d8bf7164675e0e30735826ba86
parent815dc9c48097b4b31dd7d7a90e2fa0188895dc62
parent745d60c239d7cf66f1bebca921cf0df0c052ade0
Rollup merge of #107585 - compiler-errors:fndef-sig-cycle, r=oli-obk

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

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...
compiler/rustc_middle/src/ty/print/pretty.rs