@@ -304,7 +304,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
304304 }
305305
306306 fn expansion ( & self , var_values : & mut LexicalRegionResolutions < ' tcx > ) {
307- self . iterate_until_fixed_point ( "Expansion" , |constraint| {
307+ self . iterate_until_fixed_point ( |constraint| {
308308 debug ! ( "expansion: constraint={:?}" , constraint) ;
309309 let ( a_region, b_vid, b_data, retain) = match * constraint {
310310 Constraint :: RegSubVar ( a_region, b_vid) => {
@@ -360,13 +360,21 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
360360 match * b_data {
361361 VarValue :: Value ( cur_region) => {
362362 // Identical scopes can show up quite often, if the fixed point
363- // iteration converges slowly, skip them
363+ // iteration converges slowly. Skip them. This is purely an
364+ // optimization.
364365 if let ( ReScope ( a_scope) , ReScope ( cur_scope) ) = ( a_region, cur_region) {
365366 if a_scope == cur_scope {
366367 return false ;
367368 }
368369 }
369370
371+ // This is a specialized version of the `lub_concrete_regions`
372+ // check below for a common case, here purely as an
373+ // optimization.
374+ if let ReEmpty = a_region {
375+ return false ;
376+ }
377+
370378 let mut lub = self . lub_concrete_regions ( a_region, cur_region) ;
371379 if lub == cur_region {
372380 return false ;
@@ -407,8 +415,6 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
407415
408416 /// Returns the smallest region `c` such that `a <= c` and `b <= c`.
409417 fn lub_concrete_regions ( & self , a : Region < ' tcx > , b : Region < ' tcx > ) -> Region < ' tcx > {
410- let tcx = self . tcx ( ) ;
411-
412418 match ( a, b) {
413419 ( & ty:: ReClosureBound ( ..) , _)
414420 | ( _, & ty:: ReClosureBound ( ..) )
@@ -468,15 +474,15 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
468474
469475 // otherwise, we don't know what the free region is,
470476 // so we must conservatively say the LUB is static:
471- tcx. lifetimes . re_static
477+ self . tcx ( ) . lifetimes . re_static
472478 }
473479
474480 ( & ReScope ( a_id) , & ReScope ( b_id) ) => {
475481 // The region corresponding to an outer block is a
476482 // subtype of the region corresponding to an inner
477483 // block.
478484 let lub = self . region_rels . region_scope_tree . nearest_common_ancestor ( a_id, b_id) ;
479- tcx. mk_region ( ReScope ( lub) )
485+ self . tcx ( ) . mk_region ( ReScope ( lub) )
480486 }
481487
482488 ( & ReEarlyBound ( _) , & ReEarlyBound ( _) )
@@ -490,7 +496,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
490496 if a == b {
491497 a
492498 } else {
493- tcx. lifetimes . re_static
499+ self . tcx ( ) . lifetimes . re_static
494500 }
495501 }
496502 }
@@ -860,7 +866,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
860866 }
861867 }
862868
863- fn iterate_until_fixed_point < F > ( & self , tag : & str , mut body : F )
869+ fn iterate_until_fixed_point < F > ( & self , mut body : F )
864870 where
865871 F : FnMut ( & Constraint < ' tcx > ) -> ( bool , bool ) ,
866872 {
@@ -870,7 +876,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
870876 while changed {
871877 changed = false ;
872878 iteration += 1 ;
873- debug ! ( "---- {} Iteration {}{}" , "#" , tag , iteration) ;
879+ debug ! ( "---- Expansion iteration {}" , iteration) ;
874880 constraints. retain ( |constraint| {
875881 let ( edge_changed, retain) = body ( constraint) ;
876882 if edge_changed {
@@ -880,7 +886,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
880886 retain
881887 } ) ;
882888 }
883- debug ! ( "---- {} Complete after {} iteration(s)" , tag , iteration) ;
889+ debug ! ( "---- Expansion complete after {} iteration(s)" , iteration) ;
884890 }
885891
886892 fn bound_is_met (
0 commit comments