@@ -162,7 +162,7 @@ fn do_mir_borrowck<'tcx>(
162162 }
163163 }
164164
165- let mut diags = diags:: BorrowckDiags :: new ( ) ;
165+ let diags = & mut diags:: BorrowckDiags :: new ( ) ;
166166
167167 // Gather the upvars of a closure, if any.
168168 if let Some ( e) = input_body. tainted_by_errors {
@@ -227,14 +227,7 @@ fn do_mir_borrowck<'tcx>(
227227
228228 // We also have a `#[rustc_regions]` annotation that causes us to dump
229229 // information.
230- nll:: dump_annotation (
231- & infcx,
232- body,
233- & regioncx,
234- & opt_closure_req,
235- & opaque_type_values,
236- & mut diags,
237- ) ;
230+ nll:: dump_annotation ( & infcx, body, & regioncx, & opt_closure_req, & opaque_type_values, diags) ;
238231
239232 // The various `flow_*` structures can be large. We drop `flow_inits` here
240233 // so it doesn't overlap with the others below. This reduces peak memory
@@ -299,7 +292,6 @@ fn do_mir_borrowck<'tcx>(
299292 } ;
300293 MoveVisitor { ctxt : & mut promoted_mbcx } . visit_body ( promoted_body) ;
301294 promoted_mbcx. report_move_errors ( ) ;
302- diags = promoted_mbcx. diags ;
303295
304296 struct MoveVisitor < ' a , ' b , ' infcx , ' tcx > {
305297 ctxt : & ' a mut MirBorrowckCtxt < ' b , ' infcx , ' tcx > ,
@@ -587,7 +579,7 @@ struct MirBorrowckCtxt<'a, 'infcx, 'tcx> {
587579 /// Results of Polonius analysis.
588580 polonius_output : Option < Box < PoloniusOutput > > ,
589581
590- diags : diags:: BorrowckDiags < ' infcx , ' tcx > ,
582+ diags : & ' a mut diags:: BorrowckDiags < ' infcx , ' tcx > ,
591583 move_errors : Vec < MoveError < ' tcx > > ,
592584}
593585
@@ -2506,15 +2498,15 @@ mod diags {
25062498 // Buffer any move errors that we collected and de-duplicated.
25072499 for ( _, ( _, diag) ) in std:: mem:: take ( & mut self . diags . buffered_move_errors ) {
25082500 // We have already set tainted for this error, so just buffer it.
2509- self . diags . buffered_diags . push ( BufferedDiag :: Error ( diag) ) ;
2501+ self . diags . buffer_error ( diag) ;
25102502 }
25112503 for ( _, ( mut diag, count) ) in std:: mem:: take ( & mut self . diags . buffered_mut_errors ) {
25122504 if count > 10 {
25132505 #[ allow( rustc:: diagnostic_outside_of_impl) ]
25142506 #[ allow( rustc:: untranslatable_diagnostic) ]
25152507 diag. note ( format ! ( "...and {} other attempted mutable borrows" , count - 10 ) ) ;
25162508 }
2517- self . diags . buffered_diags . push ( BufferedDiag :: Error ( diag) ) ;
2509+ self . diags . buffer_error ( diag) ;
25182510 }
25192511
25202512 if !self . diags . buffered_diags . is_empty ( ) {
0 commit comments