-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Function with impossible-to-satisfy higher-ranked bound triggers error when a closure is present #89409
Copy link
Copy link
Open
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)A-impossible-boundsArea: Issues related to have impossible trait bounds in scope (impossible predicates)Area: Issues related to have impossible trait bounds in scope (impossible predicates)A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-bugCategory: This is a bug.Category: This is a bug.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)A-impossible-boundsArea: Issues related to have impossible trait bounds in scope (impossible predicates)Area: Issues related to have impossible trait bounds in scope (impossible predicates)A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-bugCategory: This is a bug.Category: This is a bug.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
The following program compiles successfully:
The
whereclause onimpossibleis impossible to satisfy, since it is not the case that every choice of'aoutlives'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 (): 'staticholds, leading to an error. Normally, we will not try to prove this predicate during type-checking ofimpossibleitself.