@@ -1003,12 +1003,11 @@ impl<'p, 'tcx: 'p> PatCx for RustcPatCtxt<'p, 'tcx> {
10031003 }
10041004 // `pat` is an exclusive range like `lo..gap`. `gapped_with` contains ranges that start with
10051005 // `gap+1`.
1006- let suggested_range: thir :: Pat < ' _ > = {
1006+ let suggested_range: String = {
10071007 // Suggest `lo..=gap` instead.
1008- let mut suggested_range = thir_pat. clone ( ) ;
1009- let thir:: PatKind :: Range ( range) = & mut suggested_range. kind else { unreachable ! ( ) } ;
1010- range. end = rustc_hir:: RangeEnd :: Included ;
1011- suggested_range
1008+ let mut suggested_range = PatRange :: clone ( range) ;
1009+ suggested_range. end = rustc_hir:: RangeEnd :: Included ;
1010+ suggested_range. to_string ( )
10121011 } ;
10131012 let gap_as_pat = self . hoist_pat_range ( & gap, * pat. ty ( ) ) ;
10141013 if gapped_with. is_empty ( ) {
@@ -1023,7 +1022,7 @@ impl<'p, 'tcx: 'p> PatCx for RustcPatCtxt<'p, 'tcx> {
10231022 // That's the gap that isn't covered.
10241023 max : gap_as_pat. to_string ( ) ,
10251024 // Suggest `lo..=max` instead.
1026- suggestion : suggested_range. to_string ( ) ,
1025+ suggestion : suggested_range,
10271026 } ,
10281027 ) ;
10291028 } else {
@@ -1037,15 +1036,15 @@ impl<'p, 'tcx: 'p> PatCx for RustcPatCtxt<'p, 'tcx> {
10371036 // That's the gap that isn't covered.
10381037 gap : gap_as_pat. to_string ( ) ,
10391038 // Suggest `lo..=gap` instead.
1040- suggestion : suggested_range. to_string ( ) ,
1039+ suggestion : suggested_range,
10411040 // All these ranges skipped over `gap` which we think is probably a
10421041 // mistake.
10431042 gap_with : gapped_with
10441043 . iter ( )
10451044 . map ( |pat| errors:: GappedRange {
10461045 span : pat. data ( ) . span ,
10471046 gap : gap_as_pat. to_string ( ) ,
1048- first_range : thir_pat . to_string ( ) ,
1047+ first_range : range . to_string ( ) ,
10491048 } )
10501049 . collect ( ) ,
10511050 } ,
0 commit comments