@@ -199,12 +199,13 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> {
199
199
cx. pattern_arena . alloc ( DeconstructedPat :: from_pat ( cx, & pattern) )
200
200
}
201
201
202
- fn new_cx ( & self , hir_id : HirId ) -> MatchCheckCtxt < ' p , ' tcx > {
202
+ fn new_cx ( & self , hir_id : HirId , refutable : bool ) -> MatchCheckCtxt < ' p , ' tcx > {
203
203
MatchCheckCtxt {
204
204
tcx : self . tcx ,
205
205
param_env : self . param_env ,
206
206
module : self . tcx . parent_module ( hir_id) . to_def_id ( ) ,
207
207
pattern_arena : & self . pattern_arena ,
208
+ refutable,
208
209
}
209
210
}
210
211
@@ -214,7 +215,7 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> {
214
215
return ;
215
216
}
216
217
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 ) ;
218
219
let tpat = self . lower_pattern ( & mut cx, pat) ;
219
220
self . check_let_reachability ( & mut cx, self . lint_level , source, tpat, span) ;
220
221
}
@@ -226,7 +227,7 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> {
226
227
source : hir:: MatchSource ,
227
228
expr_span : Span ,
228
229
) {
229
- let mut cx = self . new_cx ( self . lint_level ) ;
230
+ let mut cx = self . new_cx ( self . lint_level , true ) ;
230
231
231
232
for & arm in arms {
232
233
// Check the arm for some things unrelated to exhaustiveness.
@@ -328,7 +329,7 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> {
328
329
debug ! ( ?expr, ?local_lint_level, "after scopes" ) ;
329
330
match expr. kind {
330
331
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 ) ;
332
333
let tpat = self . lower_pattern ( & mut ncx, pat) ;
333
334
let refutable = !is_let_irrefutable ( & mut ncx, local_lint_level, tpat) ;
334
335
Some ( ( expr. span , refutable) )
@@ -409,7 +410,7 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> {
409
410
410
411
#[ instrument( level = "trace" , skip( self ) ) ]
411
412
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 ) ;
413
414
414
415
let pattern = self . lower_pattern ( & mut cx, pat) ;
415
416
let pattern_ty = pattern. ty ( ) ;
0 commit comments