-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
unnecessary closure constraint propagation V2 #154267
Copy link
Copy link
Open
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-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-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-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-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-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.
I tried this code (credit to @lcnr):
This should compile fine, but instead this error is reported:
So what's happening here is that during the type test
T: 'awe have to propagate some requirements so we can prove the type test. This happens here:rust/compiler/rustc_borrowck/src/region_infer/mod.rs
Lines 712 to 736 in 13e2aba
We loop over
lower_bound_universal_regionsof'a, these are['a, 'c].Then for each of these regions we loop over their
non_local_upper_boundsand propagateT: 'ub. Nothing special happens with'abut it does with'c. Itsnon_local_upper_boundsare['a, 'b]and we thus propagateT: 'aandT: 'b, propagatingT: 'bis incorrect and results in the above error.