@@ -708,9 +708,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
708
708
// for the branching codepaths that aren't covered, to point at them.
709
709
let map = self . infcx . tcx . hir ( ) ;
710
710
let body = map. body_owned_by ( self . mir_def_id ( ) ) ;
711
- let mut visitor =
712
- ConditionVisitor { tcx : self . infcx . tcx , spans : & spans, name : & name, errors : vec ! [ ] } ;
711
+ let mut visitor = ConditionVisitor { tcx : self . infcx . tcx , spans, name, errors : vec ! [ ] } ;
713
712
visitor. visit_body ( & body) ;
713
+ let spans = visitor. spans ;
714
714
715
715
let mut show_assign_sugg = false ;
716
716
let isnt_initialized = if let InitializationRequiringAction :: PartialAssignment
@@ -4465,20 +4465,20 @@ impl<'hir> Visitor<'hir> for BreakFinder {
4465
4465
4466
4466
/// Given a set of spans representing statements initializing the relevant binding, visit all the
4467
4467
/// function expressions looking for branching code paths that *do not* initialize the binding.
4468
- struct ConditionVisitor < ' b , ' tcx > {
4468
+ struct ConditionVisitor < ' tcx > {
4469
4469
tcx : TyCtxt < ' tcx > ,
4470
- spans : & ' b [ Span ] ,
4471
- name : & ' b str ,
4470
+ spans : Vec < Span > ,
4471
+ name : String ,
4472
4472
errors : Vec < ( Span , String ) > ,
4473
4473
}
4474
4474
4475
- impl < ' b , ' v , ' tcx > Visitor < ' v > for ConditionVisitor < ' b , ' tcx > {
4475
+ impl < ' v , ' tcx > Visitor < ' v > for ConditionVisitor < ' tcx > {
4476
4476
fn visit_expr ( & mut self , ex : & ' v hir:: Expr < ' v > ) {
4477
4477
match ex. kind {
4478
4478
hir:: ExprKind :: If ( cond, body, None ) => {
4479
4479
// `if` expressions with no `else` that initialize the binding might be missing an
4480
4480
// `else` arm.
4481
- if ReferencedStatementsVisitor ( self . spans ) . visit_expr ( body) . is_break ( ) {
4481
+ if ReferencedStatementsVisitor ( & self . spans ) . visit_expr ( body) . is_break ( ) {
4482
4482
self . errors . push ( (
4483
4483
cond. span ,
4484
4484
format ! (
@@ -4495,8 +4495,8 @@ impl<'b, 'v, 'tcx> Visitor<'v> for ConditionVisitor<'b, 'tcx> {
4495
4495
hir:: ExprKind :: If ( cond, body, Some ( other) ) => {
4496
4496
// `if` expressions where the binding is only initialized in one of the two arms
4497
4497
// might be missing a binding initialization.
4498
- let a = ReferencedStatementsVisitor ( self . spans ) . visit_expr ( body) . is_break ( ) ;
4499
- let b = ReferencedStatementsVisitor ( self . spans ) . visit_expr ( other) . is_break ( ) ;
4498
+ let a = ReferencedStatementsVisitor ( & self . spans ) . visit_expr ( body) . is_break ( ) ;
4499
+ let b = ReferencedStatementsVisitor ( & self . spans ) . visit_expr ( other) . is_break ( ) ;
4500
4500
match ( a, b) {
4501
4501
( true , true ) | ( false , false ) => { }
4502
4502
( true , false ) => {
@@ -4536,7 +4536,7 @@ impl<'b, 'v, 'tcx> Visitor<'v> for ConditionVisitor<'b, 'tcx> {
4536
4536
// arms might be missing an initialization.
4537
4537
let results: Vec < bool > = arms
4538
4538
. iter ( )
4539
- . map ( |arm| ReferencedStatementsVisitor ( self . spans ) . visit_arm ( arm) . is_break ( ) )
4539
+ . map ( |arm| ReferencedStatementsVisitor ( & self . spans ) . visit_arm ( arm) . is_break ( ) )
4540
4540
. collect ( ) ;
4541
4541
if results. iter ( ) . any ( |x| * x) && !results. iter ( ) . all ( |x| * x) {
4542
4542
for ( arm, seen) in arms. iter ( ) . zip ( results) {
0 commit comments