@@ -34,13 +34,13 @@ pub(crate) enum RegionNameSource {
34
34
/// The `'static` region.
35
35
Static ,
36
36
/// The free region corresponding to the environment of a closure.
37
- SynthesizedFreeEnvRegion ( Span , String ) ,
37
+ SynthesizedFreeEnvRegion ( Span , & ' static str ) ,
38
38
/// The region corresponding to an argument.
39
39
AnonRegionFromArgument ( RegionNameHighlight ) ,
40
40
/// The region corresponding to a closure upvar.
41
- AnonRegionFromUpvar ( Span , String ) ,
41
+ AnonRegionFromUpvar ( Span , Symbol ) ,
42
42
/// The region corresponding to the return type of a closure.
43
- AnonRegionFromOutput ( RegionNameHighlight , String ) ,
43
+ AnonRegionFromOutput ( RegionNameHighlight , & ' static str ) ,
44
44
/// The region from a type yielded by a generator.
45
45
AnonRegionFromYieldTy ( Span , String ) ,
46
46
/// An anonymous region from an async fn.
@@ -110,7 +110,7 @@ impl RegionName {
110
110
}
111
111
RegionNameSource :: SynthesizedFreeEnvRegion ( span, note) => {
112
112
diag. span_label ( * span, format ! ( "lifetime `{self}` represents this closure's body" ) ) ;
113
- diag. note ( note) ;
113
+ diag. note ( * note) ;
114
114
}
115
115
RegionNameSource :: AnonRegionFromArgument ( RegionNameHighlight :: CannotMatchHirTy (
116
116
span,
@@ -350,10 +350,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
350
350
351
351
Some ( RegionName {
352
352
name : region_name,
353
- source : RegionNameSource :: SynthesizedFreeEnvRegion (
354
- fn_decl_span,
355
- note. to_string ( ) ,
356
- ) ,
353
+ source : RegionNameSource :: SynthesizedFreeEnvRegion ( fn_decl_span, note) ,
357
354
} )
358
355
}
359
356
@@ -678,7 +675,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
678
675
679
676
Some ( RegionName {
680
677
name : region_name,
681
- source : RegionNameSource :: AnonRegionFromUpvar ( upvar_span, upvar_name. to_string ( ) ) ,
678
+ source : RegionNameSource :: AnonRegionFromUpvar ( upvar_span, upvar_name) ,
682
679
} )
683
680
}
684
681
@@ -756,7 +753,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
756
753
757
754
Some ( RegionName {
758
755
name : self . synthesize_region_name ( ) ,
759
- source : RegionNameSource :: AnonRegionFromOutput ( highlight, mir_description. to_string ( ) ) ,
756
+ source : RegionNameSource :: AnonRegionFromOutput ( highlight, mir_description) ,
760
757
} )
761
758
}
762
759
0 commit comments