@@ -2399,18 +2399,19 @@ mod error {
23992399 /// and we want only the best of those errors.
24002400 ///
24012401 /// 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.
24062406 ///
24072407 /// `BTreeMap` is used to preserve the order of insertions when iterating. This is necessary
24082408 /// when errors in the map are being re-added to the error buffer so that errors with the
24092409 /// same primary span come out in a consistent order.
24102410 buffered_move_errors :
24112411 BTreeMap < Vec < MoveOutIndex > , ( PlaceRef < ' tcx > , DiagnosticBuilder < ' tcx > ) > ,
24122412 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.
24142415 buffered : Vec < Diagnostic > ,
24152416 /// Set to Some if we emit an error during borrowck
24162417 tainted_by_errors : Option < ErrorGuaranteed > ,
@@ -2434,11 +2435,11 @@ mod error {
24342435 "diagnostic buffered but not emitted" ,
24352436 ) )
24362437 }
2437- t . buffer ( & mut self . buffered ) ;
2438+ self . buffered . push ( t . into_diagnostic ( ) ) ;
24382439 }
24392440
24402441 pub fn buffer_non_error_diag ( & mut self , t : DiagnosticBuilder < ' _ , ( ) > ) {
2441- t . buffer ( & mut self . buffered ) ;
2442+ self . buffered . push ( t . into_diagnostic ( ) ) ;
24422443 }
24432444
24442445 pub fn set_tainted_by_errors ( & mut self , e : ErrorGuaranteed ) {
@@ -2486,13 +2487,13 @@ mod error {
24862487 // Buffer any move errors that we collected and de-duplicated.
24872488 for ( _, ( _, diag) ) in std:: mem:: take ( & mut self . errors . buffered_move_errors ) {
24882489 // 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 ( ) ) ;
24902491 }
24912492 for ( _, ( mut diag, count) ) in std:: mem:: take ( & mut self . errors . buffered_mut_errors ) {
24922493 if count > 10 {
24932494 diag. note ( format ! ( "...and {} other attempted mutable borrows" , count - 10 ) ) ;
24942495 }
2495- diag . buffer ( & mut self . errors . buffered ) ;
2496+ self . errors . buffered . push ( diag . into_diagnostic ( ) ) ;
24962497 }
24972498
24982499 if !self . errors . buffered . is_empty ( ) {
0 commit comments