Skip to content

Commit b0d39c6

Browse files
committed
Fix #104639, find the right lower bound region in the scenario of partial order relations
1 parent 11432fe commit b0d39c6

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
@@ -758,27 +758,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
758758
// Otherwise, we need to find the minimum remaining choice, if
759759
// any, and take that.
760760
debug!("choice_regions remaining are {:#?}", choice_regions);
761-
let min = |r1: ty::RegionVid, r2: ty::RegionVid| -> Option<ty::RegionVid> {
762-
let r1_outlives_r2 = self.universal_region_relations.outlives(r1, r2);
763-
let r2_outlives_r1 = self.universal_region_relations.outlives(r2, r1);
764-
match (r1_outlives_r2, r2_outlives_r1) {
765-
(true, true) => Some(r1.min(r2)),
766-
(true, false) => Some(r2),
767-
(false, true) => Some(r1),
768-
(false, false) => None,
769-
}
761+
let Some(&min_choice) = choice_regions.iter().find(|&r1| {
762+
choice_regions.iter().all(|&r2| {
763+
self.universal_region_relations.outlives(r2, *r1)
764+
})
765+
}) else {
766+
debug!("no choice region outlived by all others");
767+
return false;
770768
};
771-
let mut min_choice = choice_regions[0];
772-
for &other_option in &choice_regions[1..] {
773-
debug!(?min_choice, ?other_option,);
774-
match min(min_choice, other_option) {
775-
Some(m) => min_choice = m,
776-
None => {
777-
debug!(?min_choice, ?other_option, "incomparable; no min choice",);
778-
return false;
779-
}
780-
}
781-
}
782769

783770
let min_choice_scc = self.constraint_sccs.scc(min_choice);
784771
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)