@@ -2399,18 +2399,19 @@ mod error {
2399
2399
/// and we want only the best of those errors.
2400
2400
///
2401
2401
/// The `report_use_of_moved_or_uninitialized` function checks this map and replaces the
2402
- /// diagnostic (if there is one) if the `Place` of the error being reported is a prefix of the
2403
- /// `Place` of the previous most diagnostic. This happens instead of buffering the error. Once
2404
- /// all move errors have been reported, any diagnostics in this map are added to the buffer
2405
- /// to be emitted.
2402
+ /// diagnostic (if there is one) if the `Place` of the error being reported is a prefix of
2403
+ /// the `Place` of the previous most diagnostic. This happens instead of buffering the
2404
+ /// error. Once all move errors have been reported, any diagnostics in this map are added
2405
+ /// to the buffer to be emitted.
2406
2406
///
2407
2407
/// `BTreeMap` is used to preserve the order of insertions when iterating. This is necessary
2408
2408
/// when errors in the map are being re-added to the error buffer so that errors with the
2409
2409
/// same primary span come out in a consistent order.
2410
2410
buffered_move_errors :
2411
2411
BTreeMap < Vec < MoveOutIndex > , ( PlaceRef < ' tcx > , DiagnosticBuilder < ' tcx > ) > ,
2412
2412
buffered_mut_errors : FxIndexMap < Span , ( DiagnosticBuilder < ' tcx > , usize ) > ,
2413
- /// Diagnostics to be reported buffer.
2413
+ /// Buffer of diagnostics to be reported. Uses `Diagnostic` rather than `DiagnosticBuilder`
2414
+ /// because it has a mixture of error diagnostics and non-error diagnostics.
2414
2415
buffered : Vec < Diagnostic > ,
2415
2416
/// Set to Some if we emit an error during borrowck
2416
2417
tainted_by_errors : Option < ErrorGuaranteed > ,
@@ -2434,11 +2435,11 @@ mod error {
2434
2435
"diagnostic buffered but not emitted" ,
2435
2436
) )
2436
2437
}
2437
- t . buffer ( & mut self . buffered ) ;
2438
+ self . buffered . push ( t . into_diagnostic ( ) ) ;
2438
2439
}
2439
2440
2440
2441
pub fn buffer_non_error_diag ( & mut self , t : DiagnosticBuilder < ' _ , ( ) > ) {
2441
- t . buffer ( & mut self . buffered ) ;
2442
+ self . buffered . push ( t . into_diagnostic ( ) ) ;
2442
2443
}
2443
2444
2444
2445
pub fn set_tainted_by_errors ( & mut self , e : ErrorGuaranteed ) {
@@ -2486,13 +2487,13 @@ mod error {
2486
2487
// Buffer any move errors that we collected and de-duplicated.
2487
2488
for ( _, ( _, diag) ) in std:: mem:: take ( & mut self . errors . buffered_move_errors ) {
2488
2489
// We have already set tainted for this error, so just buffer it.
2489
- diag . buffer ( & mut self . errors . buffered ) ;
2490
+ self . errors . buffered . push ( diag . into_diagnostic ( ) ) ;
2490
2491
}
2491
2492
for ( _, ( mut diag, count) ) in std:: mem:: take ( & mut self . errors . buffered_mut_errors ) {
2492
2493
if count > 10 {
2493
2494
diag. note ( format ! ( "...and {} other attempted mutable borrows" , count - 10 ) ) ;
2494
2495
}
2495
- diag . buffer ( & mut self . errors . buffered ) ;
2496
+ self . errors . buffered . push ( diag . into_diagnostic ( ) ) ;
2496
2497
}
2497
2498
2498
2499
if !self . errors . buffered . is_empty ( ) {
0 commit comments