1
1
use rustc_pattern_analysis:: constructor:: Constructor ;
2
+ use rustc_pattern_analysis:: cx:: MatchCheckCtxt ;
2
3
use rustc_pattern_analysis:: errors:: Uncovered ;
3
4
use rustc_pattern_analysis:: pat:: { DeconstructedPat , WitnessPat } ;
4
5
use rustc_pattern_analysis:: usefulness:: {
5
- compute_match_usefulness, MatchArm , MatchCheckCtxt , Usefulness , UsefulnessReport ,
6
+ compute_match_usefulness, MatchArm , Usefulness , UsefulnessReport ,
6
7
} ;
7
8
8
9
use crate :: errors:: * ;
@@ -286,7 +287,7 @@ impl<'thir, 'p, 'tcx> MatchVisitor<'thir, 'p, 'tcx> {
286
287
check_borrow_conflicts_in_at_patterns ( self , pat) ;
287
288
check_for_bindings_named_same_as_variants ( self , pat, refutable) ;
288
289
} ) ;
289
- Ok ( cx. pattern_arena . alloc ( DeconstructedPat :: from_pat ( cx , pat) ) )
290
+ Ok ( cx. pattern_arena . alloc ( cx . lower_pat ( pat) ) )
290
291
}
291
292
}
292
293
@@ -926,7 +927,7 @@ fn report_non_exhaustive_match<'p, 'tcx>(
926
927
pattern = if witnesses. len ( ) < 4 {
927
928
witnesses
928
929
. iter ( )
929
- . map ( |witness| witness . to_diagnostic_pat ( cx ) . to_string ( ) )
930
+ . map ( |witness| cx . hoist_witness_pat ( witness ) . to_string ( ) )
930
931
. collect :: < Vec < String > > ( )
931
932
. join ( " | " )
932
933
} else {
@@ -950,7 +951,7 @@ fn report_non_exhaustive_match<'p, 'tcx>(
950
951
if !is_empty_match {
951
952
let mut non_exhaustive_tys = FxHashSet :: default ( ) ;
952
953
// Look at the first witness.
953
- collect_non_exhaustive_tys ( cx. tcx , & witnesses[ 0 ] , & mut non_exhaustive_tys) ;
954
+ collect_non_exhaustive_tys ( cx, & witnesses[ 0 ] , & mut non_exhaustive_tys) ;
954
955
955
956
for ty in non_exhaustive_tys {
956
957
if ty. is_ptr_sized_integral ( ) {
@@ -1085,13 +1086,13 @@ fn joined_uncovered_patterns<'p, 'tcx>(
1085
1086
witnesses : & [ WitnessPat < ' tcx > ] ,
1086
1087
) -> String {
1087
1088
const LIMIT : usize = 3 ;
1088
- let pat_to_str = |pat : & WitnessPat < ' tcx > | pat . to_diagnostic_pat ( cx ) . to_string ( ) ;
1089
+ let pat_to_str = |pat : & WitnessPat < ' tcx > | cx . hoist_witness_pat ( pat ) . to_string ( ) ;
1089
1090
match witnesses {
1090
1091
[ ] => bug ! ( ) ,
1091
- [ witness] => format ! ( "`{}`" , witness . to_diagnostic_pat ( cx ) ) ,
1092
+ [ witness] => format ! ( "`{}`" , cx . hoist_witness_pat ( witness ) ) ,
1092
1093
[ head @ .., tail] if head. len ( ) < LIMIT => {
1093
1094
let head: Vec < _ > = head. iter ( ) . map ( pat_to_str) . collect ( ) ;
1094
- format ! ( "`{}` and `{}`" , head. join( "`, `" ) , tail . to_diagnostic_pat ( cx ) )
1095
+ format ! ( "`{}` and `{}`" , head. join( "`, `" ) , cx . hoist_witness_pat ( tail ) )
1095
1096
}
1096
1097
_ => {
1097
1098
let ( head, tail) = witnesses. split_at ( LIMIT ) ;
@@ -1102,21 +1103,21 @@ fn joined_uncovered_patterns<'p, 'tcx>(
1102
1103
}
1103
1104
1104
1105
fn collect_non_exhaustive_tys < ' tcx > (
1105
- tcx : TyCtxt < ' tcx > ,
1106
+ cx : & MatchCheckCtxt < ' _ , ' tcx > ,
1106
1107
pat : & WitnessPat < ' tcx > ,
1107
1108
non_exhaustive_tys : & mut FxHashSet < Ty < ' tcx > > ,
1108
1109
) {
1109
1110
if matches ! ( pat. ctor( ) , Constructor :: NonExhaustive ) {
1110
1111
non_exhaustive_tys. insert ( pat. ty ( ) ) ;
1111
1112
}
1112
1113
if let Constructor :: IntRange ( range) = pat. ctor ( ) {
1113
- if range . is_beyond_boundaries ( pat. ty ( ) , tcx ) {
1114
+ if cx . is_range_beyond_boundaries ( range , pat. ty ( ) ) {
1114
1115
// The range denotes the values before `isize::MIN` or the values after `usize::MAX`/`isize::MAX`.
1115
1116
non_exhaustive_tys. insert ( pat. ty ( ) ) ;
1116
1117
}
1117
1118
}
1118
1119
pat. iter_fields ( )
1119
- . for_each ( |field_pat| collect_non_exhaustive_tys ( tcx , field_pat, non_exhaustive_tys) )
1120
+ . for_each ( |field_pat| collect_non_exhaustive_tys ( cx , field_pat, non_exhaustive_tys) )
1120
1121
}
1121
1122
1122
1123
fn report_adt_defined_here < ' tcx > (
0 commit comments