Skip to content

Commit 939a3dd

Browse files
committed
Auto merge of #104765 - chenyukang:yukang-fix-104639-lifetime-check, r=oli-obk
Find the right lower bound region in the scenario of partial order relations Fixes #104639
2 parents 16990de + b0d39c6 commit 939a3dd

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

compiler/rustc_borrowck/src/region_infer/mod.rs

+7-20
Original file line numberDiff line numberDiff line change
@@ -747,27 +747,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
747747
// Otherwise, we need to find the minimum remaining choice, if
748748
// any, and take that.
749749
debug!("choice_regions remaining are {:#?}", choice_regions);
750-
let min = |r1: ty::RegionVid, r2: ty::RegionVid| -> Option<ty::RegionVid> {
751-
let r1_outlives_r2 = self.universal_region_relations.outlives(r1, r2);
752-
let r2_outlives_r1 = self.universal_region_relations.outlives(r2, r1);
753-
match (r1_outlives_r2, r2_outlives_r1) {
754-
(true, true) => Some(r1.min(r2)),
755-
(true, false) => Some(r2),
756-
(false, true) => Some(r1),
757-
(false, false) => None,
758-
}
750+
let Some(&min_choice) = choice_regions.iter().find(|&r1| {
751+
choice_regions.iter().all(|&r2| {
752+
self.universal_region_relations.outlives(r2, *r1)
753+
})
754+
}) else {
755+
debug!("no choice region outlived by all others");
756+
return false;
759757
};
760-
let mut min_choice = choice_regions[0];
761-
for &other_option in &choice_regions[1..] {
762-
debug!(?min_choice, ?other_option,);
763-
match min(min_choice, other_option) {
764-
Some(m) => min_choice = m,
765-
None => {
766-
debug!(?min_choice, ?other_option, "incomparable; no min choice",);
767-
return false;
768-
}
769-
}
770-
}
771758

772759
let min_choice_scc = self.constraint_sccs.scc(min_choice);
773760
debug!(?min_choice, ?min_choice_scc);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// edition:2018
2+
// check-pass
3+
4+
#![allow(dead_code)]
5+
async fn fail<'a, 'b, 'c>(_: &'static str) where 'a: 'c, 'b: 'c, {}
6+
async fn pass<'a, 'c, 'b>(_: &'static str) where 'a: 'c, 'b: 'c, {}
7+
async fn pass2<'a, 'b, 'c>(_: &'static str) where 'a: 'c, 'b: 'c, 'c: 'a, {}
8+
async fn pass3<'a, 'b, 'c>(_: &'static str) where 'a: 'b, 'b: 'c, 'c: 'a, {}
9+
10+
fn main() { }

0 commit comments

Comments
 (0)