diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2016-03-17 05:22:53 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2016-03-18 16:38:29 -0400 |
| commit | cdaee4aba76bf3c5a3a817715e4ee33f738e3644 (patch) | |
| tree | cb087a48b8b31fa93093321c6204036341d6180e | |
| parent | ad6ca084e7ac47b59714356c08eeb274a6e239ca (diff) | |
| download | rust-cdaee4aba76bf3c5a3a817715e4ee33f738e3644.tar.gz rust-cdaee4aba76bf3c5a3a817715e4ee33f738e3644.zip | |
pick off some easy cases for LUB/GLB in regions
the goal here is to minimize creating variables
| -rw-r--r-- | src/librustc/middle/infer/region_inference/mod.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/librustc/middle/infer/region_inference/mod.rs b/src/librustc/middle/infer/region_inference/mod.rs index 36462b68288..0772641dbde 100644 --- a/src/librustc/middle/infer/region_inference/mod.rs +++ b/src/librustc/middle/infer/region_inference/mod.rs @@ -530,16 +530,14 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { assert!(self.values_are_none()); debug!("RegionVarBindings: lub_regions({:?}, {:?})", a, b); - match (a, b) { - (ReStatic, _) | (_, ReStatic) => { - ReStatic // nothing lives longer than static - } - - _ => { - self.combine_vars(Lub, a, b, origin.clone(), |this, old_r, new_r| { - this.make_subregion(origin.clone(), old_r, new_r) - }) - } + if a == ty::ReStatic || b == ty::ReStatic { + 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| { + this.make_subregion(origin.clone(), old_r, new_r) + }) } } @@ -550,8 +548,11 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { debug!("RegionVarBindings: glb_regions({:?}, {:?})", a, b); match (a, b) { (ReStatic, r) | (r, ReStatic) => { - // static lives longer than everything else - r + r // static lives longer than everything else + } + + _ if a == b => { + a // GLB(a,a) = a } _ => { |
