@@ -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 {
@@ -228,14 +228,7 @@ fn do_mir_borrowck<'tcx>(
228
228
229
229
// We also have a `#[rustc_regions]` annotation that causes us to dump
230
230
// information.
231
- nll:: dump_annotation (
232
- & infcx,
233
- body,
234
- & regioncx,
235
- & opt_closure_req,
236
- & opaque_type_values,
237
- & mut diags,
238
- ) ;
231
+ nll:: dump_annotation ( & infcx, body, & regioncx, & opt_closure_req, & opaque_type_values, diags) ;
239
232
240
233
let flow_borrows = Borrows :: new ( tcx, body, & regioncx, & borrow_set)
241
234
. into_engine ( tcx, body)
@@ -292,7 +285,6 @@ fn do_mir_borrowck<'tcx>(
292
285
} ;
293
286
MoveVisitor { ctxt : & mut promoted_mbcx } . visit_body ( promoted_body) ;
294
287
promoted_mbcx. report_move_errors ( ) ;
295
- diags = promoted_mbcx. diags ;
296
288
297
289
struct MoveVisitor < ' a , ' b , ' infcx , ' tcx > {
298
290
ctxt : & ' a mut MirBorrowckCtxt < ' b , ' infcx , ' tcx > ,
@@ -580,7 +572,7 @@ struct MirBorrowckCtxt<'a, 'infcx, 'tcx> {
580
572
/// Results of Polonius analysis.
581
573
polonius_output : Option < Box < PoloniusOutput > > ,
582
574
583
- diags : diags:: BorrowckDiags < ' infcx , ' tcx > ,
575
+ diags : & ' a mut diags:: BorrowckDiags < ' infcx , ' tcx > ,
584
576
move_errors : Vec < MoveError < ' tcx > > ,
585
577
}
586
578
@@ -2499,15 +2491,15 @@ mod diags {
2499
2491
// Buffer any move errors that we collected and de-duplicated.
2500
2492
for ( _, ( _, diag) ) in std:: mem:: take ( & mut self . diags . buffered_move_errors ) {
2501
2493
// We have already set tainted for this error, so just buffer it.
2502
- self . diags . buffered_diags . push ( BufferedDiag :: Error ( diag) ) ;
2494
+ self . diags . buffer_error ( diag) ;
2503
2495
}
2504
2496
for ( _, ( mut diag, count) ) in std:: mem:: take ( & mut self . diags . buffered_mut_errors ) {
2505
2497
if count > 10 {
2506
2498
#[ allow( rustc:: diagnostic_outside_of_impl) ]
2507
2499
#[ allow( rustc:: untranslatable_diagnostic) ]
2508
2500
diag. note ( format ! ( "...and {} other attempted mutable borrows" , count - 10 ) ) ;
2509
2501
}
2510
- self . diags . buffered_diags . push ( BufferedDiag :: Error ( diag) ) ;
2502
+ self . diags . buffer_error ( diag) ;
2511
2503
}
2512
2504
2513
2505
if !self . diags . buffered_diags . is_empty ( ) {
0 commit comments