@@ -252,11 +252,11 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
252
252
253
253
hir:: ExprKind :: Match ( ref discr, arms, _) => {
254
254
let discr_place = return_if_err ! ( self . mc. cat_expr( discr) ) ;
255
- self . maybe_read_scrutinee (
255
+ return_if_err ! ( self . maybe_read_scrutinee(
256
256
discr,
257
257
discr_place. clone( ) ,
258
258
arms. iter( ) . map( |arm| arm. pat) ,
259
- ) ;
259
+ ) ) ;
260
260
261
261
// treatment of the discriminant is handled while walking the arms.
262
262
for arm in arms {
@@ -390,15 +390,15 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
390
390
discr : & Expr < ' _ > ,
391
391
discr_place : PlaceWithHirId < ' tcx > ,
392
392
pats : impl Iterator < Item = & ' t hir:: Pat < ' t > > ,
393
- ) {
393
+ ) -> Result < ( ) , ( ) > {
394
394
// Matching should not always be considered a use of the place, hence
395
395
// discr does not necessarily need to be borrowed.
396
396
// We only want to borrow discr if the pattern contain something other
397
397
// than wildcards.
398
398
let ExprUseVisitor { ref mc, body_owner : _, delegate : _ } = * self ;
399
399
let mut needs_to_be_read = false ;
400
400
for pat in pats {
401
- return_if_err ! ( mc. cat_pattern( discr_place. clone( ) , pat, |place, pat| {
401
+ mc. cat_pattern ( discr_place. clone ( ) , pat, |place, pat| {
402
402
match & pat. kind {
403
403
PatKind :: Binding ( .., opt_sub_pat) => {
404
404
// If the opt_sub_pat is None, than the binding does not count as
@@ -453,7 +453,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
453
453
// examined
454
454
}
455
455
}
456
- } ) ) ;
456
+ } ) ?
457
457
}
458
458
459
459
if needs_to_be_read {
@@ -474,6 +474,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
474
474
// that the discriminant has been initialized.
475
475
self . walk_expr ( discr) ;
476
476
}
477
+ Ok ( ( ) )
477
478
}
478
479
479
480
fn walk_local < F > (
@@ -490,7 +491,11 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
490
491
f ( self ) ;
491
492
if let Some ( els) = els {
492
493
// borrowing because we need to test the discriminant
493
- self . maybe_read_scrutinee ( expr, expr_place. clone ( ) , from_ref ( pat) . iter ( ) ) ;
494
+ return_if_err ! ( self . maybe_read_scrutinee(
495
+ expr,
496
+ expr_place. clone( ) ,
497
+ from_ref( pat) . iter( )
498
+ ) ) ;
494
499
self . walk_block ( els)
495
500
}
496
501
self . walk_irrefutable_pat ( & expr_place, & pat) ;
0 commit comments