Skip to content

Commit 0ca36e1

Browse files
authored
Rollup merge of #115313 - gurry:issue-114918-cycle-detected, r=compiler-errors
Make `get_return_block()` return `Some` only for HIR nodes in body Fixes #114918 The issue occurred while compiling the following input: ```rust fn uwu() -> [(); { () }] { loop {} } ``` It was caused by the code below trying to suggest a missing return type which resulted in a const eval cycle: https://github.com/rust-lang/rust/blob/1bd043098e05839afb557bd7a2858cb09a4054ca/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs#L68-L75 The root cause was `get_return_block()` returning an `Fn` node for a node in the return type (i.e. the second `()` in the return type `[(); { () }]` of the input) although it is supposed to do so only for nodes that lie in the body of the function and return `None` otherwise (at least as per my understanding). The PR fixes the issue by fixing this behaviour of `get_return_block()`.
2 parents 5e2569c + 6659ca3 commit 0ca36e1

File tree

0 file changed

+0
-0
lines changed

    0 file changed

    +0
    -0
    lines changed

    0 commit comments

    Comments
     (0)