(&ty::ReFree(_), &ty::ReEarlyBound(_)) |
(&ty::ReEarlyBound(_), &ty::ReFree(_)) |
(&ty::ReFree(_), &ty::ReFree(_)) =>
- self.free_regions.relation.contains(&sub_region, &super_region),
+ self.free_regions.sub_free_regions(&sub_region, &super_region),
_ =>
false,
}
}
- // Record that `'sup:'sub`. Or, put another way, `'sub <= 'sup`.
- // (with the exception that `'static: 'x` is not notable)
+ /// Record that `'sup:'sub`. Or, put another way, `'sub <= 'sup`.
+ /// (with the exception that `'static: 'x` is not notable)
pub fn relate_regions(&mut self, sub: Region<'tcx>, sup: Region<'tcx>) {
+ debug!("relate_regions(sub={:?}, sup={:?})", sub, sup);
if (is_free(sub) || *sub == ty::ReStatic) && is_free(sup) {
self.relation.add(sub, sup)
}
}
+ /// True if `r_a <= r_b` is known to hold. Both `r_a` and `r_b`
+ /// must be free regions from the function header.
+ pub fn sub_free_regions<'a, 'gcx>(&self,
+ r_a: Region<'tcx>,
+ r_b: Region<'tcx>)
+ -> bool {
+ debug!("sub_free_regions(r_a={:?}, r_b={:?})", r_a, r_b);
+ assert!(is_free(r_a));
+ assert!(is_free(r_b));
+ let result = r_a == r_b || self.relation.contains(&r_a, &r_b);
+ debug!("sub_free_regions: result={}", result);
+ result
+ }
+
+ /// Compute the least-upper-bound of two free regions. In some
+ /// cases, this is more conservative than necessary, in order to
+ /// avoid making arbitrary choices. See
+ /// `TransitiveRelation::postdom_upper_bound` for more details.
pub fn lub_free_regions<'a, 'gcx>(&self,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
r_a: Region<'tcx>,
r_b: Region<'tcx>)
-> Region<'tcx> {
+ debug!("lub_free_regions(r_a={:?}, r_b={:?})", r_a, r_b);
assert!(is_free(r_a));
assert!(is_free(r_b));
let result = if r_a == r_b { r_a } else {