@@ -557,8 +557,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
557557 // for the branching codepaths that aren't covered, to point at them.
558558 let map = self . infcx . tcx . hir ( ) ;
559559 let body = map. body_owned_by ( self . mir_def_id ( ) ) ;
560-
561- let mut visitor = ConditionVisitor { spans : & spans, name : & name, errors : vec ! [ ] } ;
560+ let mut visitor =
561+ ConditionVisitor { tcx : self . infcx . tcx , spans : & spans, name : & name, errors : vec ! [ ] } ;
562562 visitor. visit_body ( & body) ;
563563
564564 let mut show_assign_sugg = false ;
@@ -4372,13 +4372,14 @@ impl<'hir> Visitor<'hir> for BreakFinder {
43724372
43734373/// Given a set of spans representing statements initializing the relevant binding, visit all the
43744374/// function expressions looking for branching code paths that *do not* initialize the binding.
4375- struct ConditionVisitor < ' b > {
4375+ struct ConditionVisitor < ' b , ' tcx > {
4376+ tcx : TyCtxt < ' tcx > ,
43764377 spans : & ' b [ Span ] ,
43774378 name : & ' b str ,
43784379 errors : Vec < ( Span , String ) > ,
43794380}
43804381
4381- impl < ' b , ' v > Visitor < ' v > for ConditionVisitor < ' b > {
4382+ impl < ' b , ' v , ' tcx > Visitor < ' v > for ConditionVisitor < ' b , ' tcx > {
43824383 fn visit_expr ( & mut self , ex : & ' v hir:: Expr < ' v > ) {
43834384 match ex. kind {
43844385 hir:: ExprKind :: If ( cond, body, None ) => {
@@ -4464,6 +4465,12 @@ impl<'b, 'v> Visitor<'v> for ConditionVisitor<'b> {
44644465 ) ,
44654466 ) ) ;
44664467 } else if let Some ( guard) = & arm. guard {
4468+ if matches ! (
4469+ self . tcx. hir_node( arm. body. hir_id) ,
4470+ hir:: Node :: Expr ( hir:: Expr { kind: hir:: ExprKind :: Ret ( _) , .. } )
4471+ ) {
4472+ continue ;
4473+ }
44674474 self . errors . push ( (
44684475 arm. pat . span . to ( guard. span ) ,
44694476 format ! (
@@ -4473,6 +4480,12 @@ impl<'b, 'v> Visitor<'v> for ConditionVisitor<'b> {
44734480 ) ,
44744481 ) ) ;
44754482 } else {
4483+ if matches ! (
4484+ self . tcx. hir_node( arm. body. hir_id) ,
4485+ hir:: Node :: Expr ( hir:: Expr { kind: hir:: ExprKind :: Ret ( _) , .. } )
4486+ ) {
4487+ continue ;
4488+ }
44764489 self . errors . push ( (
44774490 arm. pat . span ,
44784491 format ! (
0 commit comments