From 1aadaea2fcc9e7f61659e6d6526866a66a5a569a Mon Sep 17 00:00:00 2001 From: lcnr Date: Fri, 20 Dec 2024 18:15:46 +0100 Subject: [PATCH 1/3] region-outlives propagation --- src/borrow_check/region_inference/closure_constraints.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/borrow_check/region_inference/closure_constraints.md b/src/borrow_check/region_inference/closure_constraints.md index b4efd2661..44aab2cb4 100644 --- a/src/borrow_check/region_inference/closure_constraints.md +++ b/src/borrow_check/region_inference/closure_constraints.md @@ -15,7 +15,11 @@ While borrow-checking a closure inside of `RegionInferenceContext::solve` we sep ### Region-outlive constraints -If we fail to prove a region-outlives constraint, we try to propagate it in `fn try_propagate_universal_region_error`. +If `RegionInferenceContext::check_universal_regions` fails to prove some outlives constraint `'longer_fr: 'shorter_fr`, we try to propagate it in `fn try_propagate_universal_region_error`. Both these universal regions are either local to the closure or an external region. + +In case `'longer_fr` is a local universal region, we search for the largest external region `'fr_minus` which outlives `'longer_fr`, i.e. `'fr_minus: 'longer_fr`. There may be multiple such regions, we pick the `mutual_immediate_postdominator` in this case; the fixpoint of repeatedly computing the GLB of all GLBs, see [TransitiveRelation::postdom_upper_bound](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_data_structures/transitive_relation/struct.TransitiveRelation.html#method.postdom_upper_bound) for more details. + +If `'fr_minus` exists we require it to outlive all non-local upper bounds of `'shorter_fr`. There will always be at least one non-local upper bound `'static`. ### Type-outlive constraints From ca851b755cb53ff910e149bf2c247ceb46441dd1 Mon Sep 17 00:00:00 2001 From: lcnr Date: Fri, 20 Dec 2024 18:19:36 +0100 Subject: [PATCH 2/3] woops --- src/borrow_check/region_inference/closure_constraints.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/borrow_check/region_inference/closure_constraints.md b/src/borrow_check/region_inference/closure_constraints.md index 44aab2cb4..a804a3fbb 100644 --- a/src/borrow_check/region_inference/closure_constraints.md +++ b/src/borrow_check/region_inference/closure_constraints.md @@ -17,7 +17,7 @@ While borrow-checking a closure inside of `RegionInferenceContext::solve` we sep If `RegionInferenceContext::check_universal_regions` fails to prove some outlives constraint `'longer_fr: 'shorter_fr`, we try to propagate it in `fn try_propagate_universal_region_error`. Both these universal regions are either local to the closure or an external region. -In case `'longer_fr` is a local universal region, we search for the largest external region `'fr_minus` which outlives `'longer_fr`, i.e. `'fr_minus: 'longer_fr`. There may be multiple such regions, we pick the `mutual_immediate_postdominator` in this case; the fixpoint of repeatedly computing the GLB of all GLBs, see [TransitiveRelation::postdom_upper_bound](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_data_structures/transitive_relation/struct.TransitiveRelation.html#method.postdom_upper_bound) for more details. +In case `'longer_fr` is a local universal region, we search for the largest external region `'fr_minus` which is outlived by `'longer_fr`, i.e. `'longer_fr: 'fr_minus`. There may be multiple such regions, we pick the `mutual_immediate_postdominator` in this case; the fixpoint of repeatedly computing the GLB of all GLBs, see [TransitiveRelation::postdom_upper_bound](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_data_structures/transitive_relation/struct.TransitiveRelation.html#method.postdom_upper_bound) for more details. If `'fr_minus` exists we require it to outlive all non-local upper bounds of `'shorter_fr`. There will always be at least one non-local upper bound `'static`. From 5568dcbb1ee183841d3a45456706f0e557503f6f Mon Sep 17 00:00:00 2001 From: lcnr Date: Fri, 20 Dec 2024 18:21:27 +0100 Subject: [PATCH 3/3] gamer --- src/borrow_check/region_inference/closure_constraints.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/borrow_check/region_inference/closure_constraints.md b/src/borrow_check/region_inference/closure_constraints.md index a804a3fbb..be279b773 100644 --- a/src/borrow_check/region_inference/closure_constraints.md +++ b/src/borrow_check/region_inference/closure_constraints.md @@ -17,7 +17,7 @@ While borrow-checking a closure inside of `RegionInferenceContext::solve` we sep If `RegionInferenceContext::check_universal_regions` fails to prove some outlives constraint `'longer_fr: 'shorter_fr`, we try to propagate it in `fn try_propagate_universal_region_error`. Both these universal regions are either local to the closure or an external region. -In case `'longer_fr` is a local universal region, we search for the largest external region `'fr_minus` which is outlived by `'longer_fr`, i.e. `'longer_fr: 'fr_minus`. There may be multiple such regions, we pick the `mutual_immediate_postdominator` in this case; the fixpoint of repeatedly computing the GLB of all GLBs, see [TransitiveRelation::postdom_upper_bound](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_data_structures/transitive_relation/struct.TransitiveRelation.html#method.postdom_upper_bound) for more details. +In case `'longer_fr` is a local universal region, we search for the largest external region `'fr_minus` which is outlived by `'longer_fr`, i.e. `'longer_fr: 'fr_minus`. In case there are multiple such regions, we pick the `mutual_immediate_postdominator`: the fixpoint of repeatedly computing the GLB of all GLBs, see [TransitiveRelation::postdom_upper_bound](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_data_structures/transitive_relation/struct.TransitiveRelation.html#method.postdom_upper_bound) for more details. If `'fr_minus` exists we require it to outlive all non-local upper bounds of `'shorter_fr`. There will always be at least one non-local upper bound `'static`.