@@ -708,9 +708,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
708708 // for the branching codepaths that aren't covered, to point at them.
709709 let map = self . infcx . tcx . hir ( ) ;
710710 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 ! [ ] } ;
713712 visitor. visit_body ( & body) ;
713+ let spans = visitor. spans ;
714714
715715 let mut show_assign_sugg = false ;
716716 let isnt_initialized = if let InitializationRequiringAction :: PartialAssignment
@@ -4465,20 +4465,20 @@ impl<'hir> Visitor<'hir> for BreakFinder {
44654465
44664466/// Given a set of spans representing statements initializing the relevant binding, visit all the
44674467/// function expressions looking for branching code paths that *do not* initialize the binding.
4468- struct ConditionVisitor < ' b , ' tcx > {
4468+ struct ConditionVisitor < ' tcx > {
44694469 tcx : TyCtxt < ' tcx > ,
4470- spans : & ' b [ Span ] ,
4471- name : & ' b str ,
4470+ spans : Vec < Span > ,
4471+ name : String ,
44724472 errors : Vec < ( Span , String ) > ,
44734473}
44744474
4475- impl < ' b , ' v , ' tcx > Visitor < ' v > for ConditionVisitor < ' b , ' tcx > {
4475+ impl < ' v , ' tcx > Visitor < ' v > for ConditionVisitor < ' tcx > {
44764476 fn visit_expr ( & mut self , ex : & ' v hir:: Expr < ' v > ) {
44774477 match ex. kind {
44784478 hir:: ExprKind :: If ( cond, body, None ) => {
44794479 // `if` expressions with no `else` that initialize the binding might be missing an
44804480 // `else` arm.
4481- if ReferencedStatementsVisitor ( self . spans ) . visit_expr ( body) . is_break ( ) {
4481+ if ReferencedStatementsVisitor ( & self . spans ) . visit_expr ( body) . is_break ( ) {
44824482 self . errors . push ( (
44834483 cond. span ,
44844484 format ! (
@@ -4495,8 +4495,8 @@ impl<'b, 'v, 'tcx> Visitor<'v> for ConditionVisitor<'b, 'tcx> {
44954495 hir:: ExprKind :: If ( cond, body, Some ( other) ) => {
44964496 // `if` expressions where the binding is only initialized in one of the two arms
44974497 // 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 ( ) ;
45004500 match ( a, b) {
45014501 ( true , true ) | ( false , false ) => { }
45024502 ( true , false ) => {
@@ -4536,7 +4536,7 @@ impl<'b, 'v, 'tcx> Visitor<'v> for ConditionVisitor<'b, 'tcx> {
45364536 // arms might be missing an initialization.
45374537 let results: Vec < bool > = arms
45384538 . iter ( )
4539- . map ( |arm| ReferencedStatementsVisitor ( self . spans ) . visit_arm ( arm) . is_break ( ) )
4539+ . map ( |arm| ReferencedStatementsVisitor ( & self . spans ) . visit_arm ( arm) . is_break ( ) )
45404540 . collect ( ) ;
45414541 if results. iter ( ) . any ( |x| * x) && !results. iter ( ) . all ( |x| * x) {
45424542 for ( arm, seen) in arms. iter ( ) . zip ( results) {
0 commit comments