@@ -199,12 +199,13 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> {
199199 cx. pattern_arena . alloc ( DeconstructedPat :: from_pat ( cx, & pattern) )
200200 }
201201
202- fn new_cx ( & self , hir_id : HirId ) -> MatchCheckCtxt < ' p , ' tcx > {
202+ fn new_cx ( & self , hir_id : HirId , refutable : bool ) -> MatchCheckCtxt < ' p , ' tcx > {
203203 MatchCheckCtxt {
204204 tcx : self . tcx ,
205205 param_env : self . param_env ,
206206 module : self . tcx . parent_module ( hir_id) . to_def_id ( ) ,
207207 pattern_arena : & self . pattern_arena ,
208+ refutable,
208209 }
209210 }
210211
@@ -214,7 +215,7 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> {
214215 return ;
215216 }
216217 self . check_patterns ( pat, Refutable ) ;
217- let mut cx = self . new_cx ( self . lint_level ) ;
218+ let mut cx = self . new_cx ( self . lint_level , true ) ;
218219 let tpat = self . lower_pattern ( & mut cx, pat) ;
219220 self . check_let_reachability ( & mut cx, self . lint_level , source, tpat, span) ;
220221 }
@@ -226,7 +227,7 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> {
226227 source : hir:: MatchSource ,
227228 expr_span : Span ,
228229 ) {
229- let mut cx = self . new_cx ( self . lint_level ) ;
230+ let mut cx = self . new_cx ( self . lint_level , true ) ;
230231
231232 for & arm in arms {
232233 // Check the arm for some things unrelated to exhaustiveness.
@@ -328,7 +329,7 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> {
328329 debug ! ( ?expr, ?local_lint_level, "after scopes" ) ;
329330 match expr. kind {
330331 ExprKind :: Let { box ref pat, expr : _ } => {
331- let mut ncx = self . new_cx ( local_lint_level) ;
332+ let mut ncx = self . new_cx ( local_lint_level, true ) ;
332333 let tpat = self . lower_pattern ( & mut ncx, pat) ;
333334 let refutable = !is_let_irrefutable ( & mut ncx, local_lint_level, tpat) ;
334335 Some ( ( expr. span , refutable) )
@@ -409,7 +410,7 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> {
409410
410411 #[ instrument( level = "trace" , skip( self ) ) ]
411412 fn check_irrefutable ( & self , pat : & Pat < ' tcx > , origin : & str , sp : Option < Span > ) {
412- let mut cx = self . new_cx ( self . lint_level ) ;
413+ let mut cx = self . new_cx ( self . lint_level , false ) ;
413414
414415 let pattern = self . lower_pattern ( & mut cx, pat) ;
415416 let pattern_ty = pattern. ty ( ) ;
0 commit comments