Function with impossible-to-satisfy higher-ranked bound triggers error when a closure is present #89409
Labels
A-borrow-checker
Area: The borrow checker
A-higher-ranked
Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)
A-lifetimes
Area: Lifetimes / regions
C-bug
Category: This is a bug.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
The following program compiles successfully:
The
where
clause onimpossible
is impossible to satisfy, since it is not the case that every choice of'a
outlives'static
. However, we never callimpossible
, so this program compiles (similar to an unsatisfiable trait bound likewhere String: Copy
).If we add a closure to the function:
then it stops compiling (note that this occurs both with and without
#![feature(nll)]
):The issue occurs here:
rust/compiler/rustc_borrowck/src/type_check/mod.rs
Line 2688 in 6dc08b9
When we instantiate the predicates of the closure during type-checking of
impossible
, we also instantiate the predicates for the parent of the closure - that is, the predicates ofimpossible
. This results in us trying to prove thatfor<'a> &'a (): 'static
holds, leading to an error. Normally, we will not try to prove this predicate during type-checking ofimpossible
itself.The text was updated successfully, but these errors were encountered: