@@ -162,7 +162,7 @@ fn do_mir_borrowck<'tcx>(
162
162
}
163
163
}
164
164
165
- let mut diags = diags:: BorrowckDiags :: new ( ) ;
165
+ let diags = & mut diags:: BorrowckDiags :: new ( ) ;
166
166
167
167
// Gather the upvars of a closure, if any.
168
168
if let Some ( e) = input_body. tainted_by_errors {
@@ -227,14 +227,7 @@ fn do_mir_borrowck<'tcx>(
227
227
228
228
// We also have a `#[rustc_regions]` annotation that causes us to dump
229
229
// 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) ;
238
231
239
232
// The various `flow_*` structures can be large. We drop `flow_inits` here
240
233
// so it doesn't overlap with the others below. This reduces peak memory
@@ -299,7 +292,6 @@ fn do_mir_borrowck<'tcx>(
299
292
} ;
300
293
MoveVisitor { ctxt : & mut promoted_mbcx } . visit_body ( promoted_body) ;
301
294
promoted_mbcx. report_move_errors ( ) ;
302
- diags = promoted_mbcx. diags ;
303
295
304
296
struct MoveVisitor < ' a , ' b , ' infcx , ' tcx > {
305
297
ctxt : & ' a mut MirBorrowckCtxt < ' b , ' infcx , ' tcx > ,
@@ -587,7 +579,7 @@ struct MirBorrowckCtxt<'a, 'infcx, 'tcx> {
587
579
/// Results of Polonius analysis.
588
580
polonius_output : Option < Box < PoloniusOutput > > ,
589
581
590
- diags : diags:: BorrowckDiags < ' infcx , ' tcx > ,
582
+ diags : & ' a mut diags:: BorrowckDiags < ' infcx , ' tcx > ,
591
583
move_errors : Vec < MoveError < ' tcx > > ,
592
584
}
593
585
@@ -2506,15 +2498,15 @@ mod diags {
2506
2498
// Buffer any move errors that we collected and de-duplicated.
2507
2499
for ( _, ( _, diag) ) in std:: mem:: take ( & mut self . diags . buffered_move_errors ) {
2508
2500
// 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) ;
2510
2502
}
2511
2503
for ( _, ( mut diag, count) ) in std:: mem:: take ( & mut self . diags . buffered_mut_errors ) {
2512
2504
if count > 10 {
2513
2505
#[ allow( rustc:: diagnostic_outside_of_impl) ]
2514
2506
#[ allow( rustc:: untranslatable_diagnostic) ]
2515
2507
diag. note ( format ! ( "...and {} other attempted mutable borrows" , count - 10 ) ) ;
2516
2508
}
2517
- self . diags . buffered_diags . push ( BufferedDiag :: Error ( diag) ) ;
2509
+ self . diags . buffer_error ( diag) ;
2518
2510
}
2519
2511
2520
2512
if !self . diags . buffered_diags . is_empty ( ) {
0 commit comments