pick off some easy cases for LUB/GLB in regions
the goal here is to minimize creating variables
This commit is contained in:
parent
ad6ca084e7
commit
cdaee4aba7
1 changed files with 13 additions and 12 deletions
|
@ -530,18 +530,16 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
||||||
assert!(self.values_are_none());
|
assert!(self.values_are_none());
|
||||||
|
|
||||||
debug!("RegionVarBindings: lub_regions({:?}, {:?})", a, b);
|
debug!("RegionVarBindings: lub_regions({:?}, {:?})", a, b);
|
||||||
match (a, b) {
|
if a == ty::ReStatic || b == ty::ReStatic {
|
||||||
(ReStatic, _) | (_, ReStatic) => {
|
|
||||||
ReStatic // nothing lives longer than static
|
ReStatic // nothing lives longer than static
|
||||||
}
|
} else if a == b {
|
||||||
|
a // LUB(a,a) = a
|
||||||
_ => {
|
} else {
|
||||||
self.combine_vars(Lub, a, b, origin.clone(), |this, old_r, new_r| {
|
self.combine_vars(Lub, a, b, origin.clone(), |this, old_r, new_r| {
|
||||||
this.make_subregion(origin.clone(), old_r, new_r)
|
this.make_subregion(origin.clone(), old_r, new_r)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pub fn glb_regions(&self, origin: SubregionOrigin<'tcx>, a: Region, b: Region) -> Region {
|
pub fn glb_regions(&self, origin: SubregionOrigin<'tcx>, a: Region, b: Region) -> Region {
|
||||||
// cannot add constraints once regions are resolved
|
// cannot add constraints once regions are resolved
|
||||||
|
@ -550,8 +548,11 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
||||||
debug!("RegionVarBindings: glb_regions({:?}, {:?})", a, b);
|
debug!("RegionVarBindings: glb_regions({:?}, {:?})", a, b);
|
||||||
match (a, b) {
|
match (a, b) {
|
||||||
(ReStatic, r) | (r, ReStatic) => {
|
(ReStatic, r) | (r, ReStatic) => {
|
||||||
// static lives longer than everything else
|
r // static lives longer than everything else
|
||||||
r
|
}
|
||||||
|
|
||||||
|
_ if a == b => {
|
||||||
|
a // GLB(a,a) = a
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue