@@ -24,6 +24,7 @@ use rustc_infer::infer::NllRegionVariableOrigin;
24
24
use rustc_middle:: ty:: fold:: TypeFoldable ;
25
25
use rustc_middle:: ty:: { self , InlineConstSubsts , InlineConstSubstsParts , RegionVid , Ty , TyCtxt } ;
26
26
use rustc_middle:: ty:: { InternalSubsts , SubstsRef } ;
27
+ use rustc_span:: symbol:: { kw, sym} ;
27
28
use rustc_span:: Symbol ;
28
29
use std:: iter;
29
30
@@ -404,10 +405,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
404
405
assert_eq ! ( FIRST_GLOBAL_INDEX , self . infcx. num_region_vars( ) ) ;
405
406
406
407
// 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 ( ) ;
411
410
412
411
// We've now added all the global regions. The next ones we
413
412
// add will be external.
@@ -440,11 +439,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
440
439
debug ! ( ?r) ;
441
440
if !indices. indices . contains_key ( & r) {
442
441
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 ( ) ;
448
443
self . infcx . next_nll_region_var ( FR , || {
449
444
RegionCtxt :: LateBound ( BoundRegionInfo :: Name ( name) )
450
445
} )
@@ -478,11 +473,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
478
473
debug ! ( ?r) ;
479
474
if !indices. indices . contains_key ( & r) {
480
475
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 ( ) ;
486
477
self . infcx . next_nll_region_var ( FR , || {
487
478
RegionCtxt :: LateBound ( BoundRegionInfo :: Name ( name) )
488
479
} )
@@ -768,15 +759,10 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
768
759
T : TypeFoldable < TyCtxt < ' tcx > > ,
769
760
{
770
761
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 ( ) ;
775
763
debug ! ( ?region, ?name) ;
776
764
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) )
780
766
} )
781
767
}
782
768
@@ -797,7 +783,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
797
783
let region_vid = {
798
784
let name = match br. kind . get_name ( ) {
799
785
Some ( name) => name,
800
- _ => Symbol :: intern ( " anon" ) ,
786
+ _ => sym :: anon,
801
787
} ;
802
788
803
789
self . next_nll_region_var ( origin, || RegionCtxt :: Bound ( BoundRegionInfo :: Name ( name) ) )
@@ -829,11 +815,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
829
815
debug ! ( ?r) ;
830
816
if !indices. indices . contains_key ( & r) {
831
817
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 ( ) ;
837
819
self . next_nll_region_var ( FR , || {
838
820
RegionCtxt :: LateBound ( BoundRegionInfo :: Name ( name) )
839
821
} )
@@ -855,11 +837,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
855
837
debug ! ( ?r) ;
856
838
if !indices. indices . contains_key ( & r) {
857
839
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 ( ) ;
863
841
self . next_nll_region_var ( FR , || {
864
842
RegionCtxt :: LateBound ( BoundRegionInfo :: Name ( name) )
865
843
} )
0 commit comments