Skip to content

Commit cdaee4a

Browse files
committed
pick off some easy cases for LUB/GLB in regions
the goal here is to minimize creating variables
1 parent ad6ca08 commit cdaee4a

File tree

1 file changed

+13
-12
lines changed
  • src/librustc/middle/infer/region_inference

1 file changed

+13
-12
lines changed

src/librustc/middle/infer/region_inference/mod.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -530,16 +530,14 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
530530
assert!(self.values_are_none());
531531

532532
debug!("RegionVarBindings: lub_regions({:?}, {:?})", a, b);
533-
match (a, b) {
534-
(ReStatic, _) | (_, ReStatic) => {
535-
ReStatic // nothing lives longer than static
536-
}
537-
538-
_ => {
539-
self.combine_vars(Lub, a, b, origin.clone(), |this, old_r, new_r| {
540-
this.make_subregion(origin.clone(), old_r, new_r)
541-
})
542-
}
533+
if a == ty::ReStatic || b == ty::ReStatic {
534+
ReStatic // nothing lives longer than static
535+
} else if a == b {
536+
a // LUB(a,a) = a
537+
} else {
538+
self.combine_vars(Lub, a, b, origin.clone(), |this, old_r, new_r| {
539+
this.make_subregion(origin.clone(), old_r, new_r)
540+
})
543541
}
544542
}
545543

@@ -550,8 +548,11 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
550548
debug!("RegionVarBindings: glb_regions({:?}, {:?})", a, b);
551549
match (a, b) {
552550
(ReStatic, r) | (r, ReStatic) => {
553-
// static lives longer than everything else
554-
r
551+
r // static lives longer than everything else
552+
}
553+
554+
_ if a == b => {
555+
a // GLB(a,a) = a
555556
}
556557

557558
_ => {

0 commit comments

Comments
 (0)