11use rustc_pattern_analysis:: errors:: Uncovered ;
22use rustc_pattern_analysis:: rustc:: {
3- Constructor , DeconstructedPat , MatchArm , RustcMatchCheckCtxt as MatchCheckCtxt , Usefulness ,
4- UsefulnessReport , WitnessPat ,
3+ Constructor , DeconstructedPat , MatchArm , RustcPatCtxt as PatCtxt , Usefulness , UsefulnessReport ,
4+ WitnessPat ,
55} ;
66
77use crate :: errors:: * ;
@@ -276,7 +276,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
276276
277277 fn lower_pattern (
278278 & mut self ,
279- cx : & MatchCheckCtxt < ' p , ' tcx > ,
279+ cx : & PatCtxt < ' p , ' tcx > ,
280280 pat : & ' p Pat < ' tcx > ,
281281 ) -> Result < & ' p DeconstructedPat < ' p , ' tcx > , ErrorGuaranteed > {
282282 if let Err ( err) = pat. pat_error_reported ( ) {
@@ -375,7 +375,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
375375 whole_match_span : Option < Span > ,
376376 scrutinee : Option < & Expr < ' tcx > > ,
377377 scrut_span : Span ,
378- ) -> MatchCheckCtxt < ' p , ' tcx > {
378+ ) -> PatCtxt < ' p , ' tcx > {
379379 let refutable = match refutability {
380380 Irrefutable => false ,
381381 Refutable => true ,
@@ -384,7 +384,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
384384 // require validity.
385385 let known_valid_scrutinee =
386386 scrutinee. map ( |scrut| self . is_known_valid_scrutinee ( scrut) ) . unwrap_or ( true ) ;
387- MatchCheckCtxt {
387+ PatCtxt {
388388 tcx : self . tcx ,
389389 typeck_results : self . typeck_results ,
390390 param_env : self . param_env ,
@@ -400,7 +400,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
400400
401401 fn analyze_patterns (
402402 & mut self ,
403- cx : & MatchCheckCtxt < ' p , ' tcx > ,
403+ cx : & PatCtxt < ' p , ' tcx > ,
404404 arms : & [ MatchArm < ' p , ' tcx > ] ,
405405 scrut_ty : Ty < ' tcx > ,
406406 ) -> Result < UsefulnessReport < ' p , ' tcx > , ErrorGuaranteed > {
@@ -584,7 +584,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
584584 pat : & ' p Pat < ' tcx > ,
585585 refutability : RefutableFlag ,
586586 scrut : Option < & Expr < ' tcx > > ,
587- ) -> Result < ( MatchCheckCtxt < ' p , ' tcx > , UsefulnessReport < ' p , ' tcx > ) , ErrorGuaranteed > {
587+ ) -> Result < ( PatCtxt < ' p , ' tcx > , UsefulnessReport < ' p , ' tcx > ) , ErrorGuaranteed > {
588588 let cx = self . new_cx ( refutability, None , scrut, pat. span ) ;
589589 let pat = self . lower_pattern ( & cx, pat) ?;
590590 let arms = [ MatchArm { pat, arm_data : self . lint_level , has_guard : false } ] ;
@@ -849,7 +849,7 @@ fn check_for_bindings_named_same_as_variants(
849849
850850/// Check that never patterns are only used on inhabited types.
851851fn check_never_pattern < ' tcx > (
852- cx : & MatchCheckCtxt < ' _ , ' tcx > ,
852+ cx : & PatCtxt < ' _ , ' tcx > ,
853853 pat : & Pat < ' tcx > ,
854854) -> Result < ( ) , ErrorGuaranteed > {
855855 if let PatKind :: Never = pat. kind {
@@ -884,7 +884,7 @@ fn report_irrefutable_let_patterns(
884884
885885/// Report unreachable arms, if any.
886886fn report_unreachable_pattern < ' p , ' tcx > (
887- cx : & MatchCheckCtxt < ' p , ' tcx > ,
887+ cx : & PatCtxt < ' p , ' tcx > ,
888888 hir_id : HirId ,
889889 span : Span ,
890890 catchall : Option < Span > ,
@@ -898,10 +898,7 @@ fn report_unreachable_pattern<'p, 'tcx>(
898898}
899899
900900/// Report unreachable arms, if any.
901- fn report_arm_reachability < ' p , ' tcx > (
902- cx : & MatchCheckCtxt < ' p , ' tcx > ,
903- report : & UsefulnessReport < ' p , ' tcx > ,
904- ) {
901+ fn report_arm_reachability < ' p , ' tcx > ( cx : & PatCtxt < ' p , ' tcx > , report : & UsefulnessReport < ' p , ' tcx > ) {
905902 let mut catchall = None ;
906903 for ( arm, is_useful) in report. arm_usefulness . iter ( ) {
907904 if matches ! ( is_useful, Usefulness :: Redundant ) {
@@ -926,7 +923,7 @@ fn pat_is_catchall(pat: &DeconstructedPat<'_, '_>) -> bool {
926923
927924/// Report that a match is not exhaustive.
928925fn report_non_exhaustive_match < ' p , ' tcx > (
929- cx : & MatchCheckCtxt < ' p , ' tcx > ,
926+ cx : & PatCtxt < ' p , ' tcx > ,
930927 thir : & Thir < ' tcx > ,
931928 scrut_ty : Ty < ' tcx > ,
932929 sp : Span ,
@@ -1126,7 +1123,7 @@ fn report_non_exhaustive_match<'p, 'tcx>(
11261123}
11271124
11281125fn joined_uncovered_patterns < ' p , ' tcx > (
1129- cx : & MatchCheckCtxt < ' p , ' tcx > ,
1126+ cx : & PatCtxt < ' p , ' tcx > ,
11301127 witnesses : & [ WitnessPat < ' p , ' tcx > ] ,
11311128) -> String {
11321129 const LIMIT : usize = 3 ;
@@ -1147,7 +1144,7 @@ fn joined_uncovered_patterns<'p, 'tcx>(
11471144}
11481145
11491146fn collect_non_exhaustive_tys < ' tcx > (
1150- cx : & MatchCheckCtxt < ' _ , ' tcx > ,
1147+ cx : & PatCtxt < ' _ , ' tcx > ,
11511148 pat : & WitnessPat < ' _ , ' tcx > ,
11521149 non_exhaustive_tys : & mut FxIndexSet < Ty < ' tcx > > ,
11531150) {
0 commit comments