@@ -252,11 +252,11 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
252252
253253 hir:: ExprKind :: Match ( ref discr, arms, _) => {
254254 let discr_place = return_if_err ! ( self . mc. cat_expr( discr) ) ;
255- self . maybe_read_scrutinee (
255+ return_if_err ! ( self . maybe_read_scrutinee(
256256 discr,
257257 discr_place. clone( ) ,
258258 arms. iter( ) . map( |arm| arm. pat) ,
259- ) ;
259+ ) ) ;
260260
261261 // treatment of the discriminant is handled while walking the arms.
262262 for arm in arms {
@@ -390,15 +390,15 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
390390 discr : & Expr < ' _ > ,
391391 discr_place : PlaceWithHirId < ' tcx > ,
392392 pats : impl Iterator < Item = & ' t hir:: Pat < ' t > > ,
393- ) {
393+ ) -> Result < ( ) , ( ) > {
394394 // Matching should not always be considered a use of the place, hence
395395 // discr does not necessarily need to be borrowed.
396396 // We only want to borrow discr if the pattern contain something other
397397 // than wildcards.
398398 let ExprUseVisitor { ref mc, body_owner : _, delegate : _ } = * self ;
399399 let mut needs_to_be_read = false ;
400400 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| {
402402 match & pat. kind {
403403 PatKind :: Binding ( .., opt_sub_pat) => {
404404 // If the opt_sub_pat is None, than the binding does not count as
@@ -453,7 +453,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
453453 // examined
454454 }
455455 }
456- } ) ) ;
456+ } ) ?
457457 }
458458
459459 if needs_to_be_read {
@@ -474,6 +474,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
474474 // that the discriminant has been initialized.
475475 self . walk_expr ( discr) ;
476476 }
477+ Ok ( ( ) )
477478 }
478479
479480 fn walk_local < F > (
@@ -490,7 +491,11 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
490491 f ( self ) ;
491492 if let Some ( els) = els {
492493 // 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+ ) ) ;
494499 self . walk_block ( els)
495500 }
496501 self . walk_irrefutable_pat ( & expr_place, & pat) ;
0 commit comments