@@ -557,8 +557,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
557
557
// for the branching codepaths that aren't covered, to point at them.
558
558
let map = self . infcx . tcx . hir ( ) ;
559
559
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 ! [ ] } ;
562
562
visitor. visit_body ( & body) ;
563
563
564
564
let mut show_assign_sugg = false ;
@@ -4372,13 +4372,14 @@ impl<'hir> Visitor<'hir> for BreakFinder {
4372
4372
4373
4373
/// Given a set of spans representing statements initializing the relevant binding, visit all the
4374
4374
/// 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 > ,
4376
4377
spans : & ' b [ Span ] ,
4377
4378
name : & ' b str ,
4378
4379
errors : Vec < ( Span , String ) > ,
4379
4380
}
4380
4381
4381
- impl < ' b , ' v > Visitor < ' v > for ConditionVisitor < ' b > {
4382
+ impl < ' b , ' v , ' tcx > Visitor < ' v > for ConditionVisitor < ' b , ' tcx > {
4382
4383
fn visit_expr ( & mut self , ex : & ' v hir:: Expr < ' v > ) {
4383
4384
match ex. kind {
4384
4385
hir:: ExprKind :: If ( cond, body, None ) => {
@@ -4464,6 +4465,12 @@ impl<'b, 'v> Visitor<'v> for ConditionVisitor<'b> {
4464
4465
) ,
4465
4466
) ) ;
4466
4467
} 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
+ }
4467
4474
self . errors . push ( (
4468
4475
arm. pat . span . to ( guard. span ) ,
4469
4476
format ! (
@@ -4473,6 +4480,12 @@ impl<'b, 'v> Visitor<'v> for ConditionVisitor<'b> {
4473
4480
) ,
4474
4481
) ) ;
4475
4482
} 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
+ }
4476
4489
self . errors . push ( (
4477
4490
arm. pat . span ,
4478
4491
format ! (
0 commit comments