@@ -24,6 +24,7 @@ use rustc_infer::infer::NllRegionVariableOrigin;
2424use rustc_middle:: ty:: fold:: TypeFoldable ;
2525use rustc_middle:: ty:: { self , InlineConstSubsts , InlineConstSubstsParts , RegionVid , Ty , TyCtxt } ;
2626use rustc_middle:: ty:: { InternalSubsts , SubstsRef } ;
27+ use rustc_span:: symbol:: { kw, sym} ;
2728use rustc_span:: Symbol ;
2829use std:: iter;
2930
@@ -404,10 +405,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
404405 assert_eq ! ( FIRST_GLOBAL_INDEX , self . infcx. num_region_vars( ) ) ;
405406
406407 // Create the "global" region that is always free in all contexts: 'static.
407- let fr_static = self
408- . infcx
409- . next_nll_region_var ( FR , || RegionCtxt :: Free ( Symbol :: intern ( "static" ) ) )
410- . to_region_vid ( ) ;
408+ let fr_static =
409+ self . infcx . next_nll_region_var ( FR , || RegionCtxt :: Free ( kw:: Static ) ) . to_region_vid ( ) ;
411410
412411 // We've now added all the global regions. The next ones we
413412 // add will be external.
@@ -440,11 +439,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
440439 debug ! ( ?r) ;
441440 if !indices. indices . contains_key ( & r) {
442441 let region_vid = {
443- let name = match r. get_name ( ) {
444- Some ( name) => name,
445- _ => Symbol :: intern ( "anon" ) ,
446- } ;
447-
442+ let name = r. get_name_or_anon ( ) ;
448443 self . infcx . next_nll_region_var ( FR , || {
449444 RegionCtxt :: LateBound ( BoundRegionInfo :: Name ( name) )
450445 } )
@@ -478,11 +473,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
478473 debug ! ( ?r) ;
479474 if !indices. indices . contains_key ( & r) {
480475 let region_vid = {
481- let name = match r. get_name ( ) {
482- Some ( name) => name,
483- _ => Symbol :: intern ( "anon" ) ,
484- } ;
485-
476+ let name = r. get_name_or_anon ( ) ;
486477 self . infcx . next_nll_region_var ( FR , || {
487478 RegionCtxt :: LateBound ( BoundRegionInfo :: Name ( name) )
488479 } )
@@ -768,15 +759,10 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
768759 T : TypeFoldable < TyCtxt < ' tcx > > ,
769760 {
770761 self . infcx . tcx . fold_regions ( value, |region, _depth| {
771- let name = match region. get_name ( ) {
772- Some ( name) => name,
773- _ => Symbol :: intern ( "anon" ) ,
774- } ;
762+ let name = region. get_name_or_anon ( ) ;
775763 debug ! ( ?region, ?name) ;
776764
777- let reg_var = self . next_nll_region_var ( origin, || RegionCtxt :: Free ( name) ) ;
778-
779- reg_var
765+ self . next_nll_region_var ( origin, || RegionCtxt :: Free ( name) )
780766 } )
781767 }
782768
@@ -797,7 +783,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
797783 let region_vid = {
798784 let name = match br. kind . get_name ( ) {
799785 Some ( name) => name,
800- _ => Symbol :: intern ( " anon" ) ,
786+ _ => sym :: anon,
801787 } ;
802788
803789 self . next_nll_region_var ( origin, || RegionCtxt :: Bound ( BoundRegionInfo :: Name ( name) ) )
@@ -829,11 +815,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
829815 debug ! ( ?r) ;
830816 if !indices. indices . contains_key ( & r) {
831817 let region_vid = {
832- let name = match r. get_name ( ) {
833- Some ( name) => name,
834- _ => Symbol :: intern ( "anon" ) ,
835- } ;
836-
818+ let name = r. get_name_or_anon ( ) ;
837819 self . next_nll_region_var ( FR , || {
838820 RegionCtxt :: LateBound ( BoundRegionInfo :: Name ( name) )
839821 } )
@@ -855,11 +837,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
855837 debug ! ( ?r) ;
856838 if !indices. indices . contains_key ( & r) {
857839 let region_vid = {
858- let name = match r. get_name ( ) {
859- Some ( name) => name,
860- _ => Symbol :: intern ( "anon" ) ,
861- } ;
862-
840+ let name = r. get_name_or_anon ( ) ;
863841 self . next_nll_region_var ( FR , || {
864842 RegionCtxt :: LateBound ( BoundRegionInfo :: Name ( name) )
865843 } )
0 commit comments