- OutlivesBound::RegionSubRegion(r_a, r_b) => {
- if let (ReEarlyBound(_) | ReFree(_), ReVar(vid_b)) = (r_a.kind(), r_b.kind()) {
- infcx
- .expect("no infcx provided but region vars found")
- .add_given(r_a, vid_b);
- } else {
- // In principle, we could record (and take
- // advantage of) every relationship here, but
- // we are also free not to -- it simply means
- // strictly less that we can successfully type
- // check. Right now we only look for things
- // relationships between free regions. (It may
- // also be that we should revise our inference
- // system to be more general and to make use
- // of *every* relationship that arises here,
- // but presently we do not.)
- if r_a.is_free_or_static() && r_b.is_free() {
- self.region_relation.add(r_a, r_b)
- }
- }
- }
+ OutlivesBound::RegionSubRegion(r_a, r_b) => match (*r_a, *r_b) {
+ (
+ ty::ReStatic | ty::ReEarlyBound(_) | ty::ReFree(_),
+ ty::ReStatic | ty::ReEarlyBound(_) | ty::ReFree(_),
+ ) => self.region_relation.add(r_a, r_b),
+ (ty::ReError(_), _) | (_, ty::ReError(_)) => {}
+ // FIXME(#109628): We shouldn't have existential variables in implied bounds.
+ // Panic here once the linked issue is resolved!
+ (ty::ReVar(_), _) | (_, ty::ReVar(_)) => {}
+ _ => bug!("add_outlives_bounds: unexpected regions: ({r_a:?}, {r_b:?})"),
+ },