@@ -85,7 +85,8 @@ impl<'infcx> BufferedDiag<'infcx> {
8585 }
8686}
8787
88- pub ( crate ) struct BorrowckDiags < ' infcx , ' tcx > {
88+ #[ derive( Default ) ]
89+ pub ( crate ) struct BorrowckDiagnosticsBuffer < ' infcx , ' tcx > {
8990 /// This field keeps track of move errors that are to be reported for given move indices.
9091 ///
9192 /// There are situations where many errors can be reported for a single move out (see
@@ -108,27 +109,15 @@ pub(crate) struct BorrowckDiags<'infcx, 'tcx> {
108109 buffered_diags : Vec < BufferedDiag < ' infcx > > ,
109110}
110111
111- impl < ' infcx , ' tcx > BorrowckDiags < ' infcx , ' tcx > {
112- pub ( crate ) fn new ( ) -> Self {
113- BorrowckDiags {
114- buffered_move_errors : BTreeMap :: new ( ) ,
115- buffered_mut_errors : Default :: default ( ) ,
116- buffered_diags : Default :: default ( ) ,
117- }
118- }
119-
120- pub ( crate ) fn buffer_error ( & mut self , diag : Diag < ' infcx > ) {
121- self . buffered_diags . push ( BufferedDiag :: Error ( diag) ) ;
122- }
123-
112+ impl < ' infcx , ' tcx > BorrowckDiagnosticsBuffer < ' infcx , ' tcx > {
124113 pub ( crate ) fn buffer_non_error ( & mut self , diag : Diag < ' infcx , ( ) > ) {
125114 self . buffered_diags . push ( BufferedDiag :: NonError ( diag) ) ;
126115 }
127116}
128117
129118impl < ' infcx , ' tcx > MirBorrowckCtxt < ' _ , ' infcx , ' tcx > {
130119 pub ( crate ) fn buffer_error ( & mut self , diag : Diag < ' infcx > ) {
131- self . diags . buffer_error ( diag) ;
120+ self . diags . buffered_diags . push ( BufferedDiag :: Error ( diag) ) ;
132121 }
133122
134123 pub ( crate ) fn buffer_non_error ( & mut self , diag : Diag < ' infcx , ( ) > ) {
@@ -166,15 +155,15 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
166155 // Buffer any move errors that we collected and de-duplicated.
167156 for ( _, ( _, diag) ) in std:: mem:: take ( & mut self . diags . buffered_move_errors ) {
168157 // We have already set tainted for this error, so just buffer it.
169- self . diags . buffer_error ( diag) ;
158+ self . buffer_error ( diag) ;
170159 }
171160 for ( _, ( mut diag, count) ) in std:: mem:: take ( & mut self . diags . buffered_mut_errors ) {
172161 if count > 10 {
173162 #[ allow( rustc:: diagnostic_outside_of_impl) ]
174163 #[ allow( rustc:: untranslatable_diagnostic) ]
175164 diag. note ( format ! ( "...and {} other attempted mutable borrows" , count - 10 ) ) ;
176165 }
177- self . diags . buffer_error ( diag) ;
166+ self . buffer_error ( diag) ;
178167 }
179168
180169 if !self . diags . buffered_diags . is_empty ( ) {
0 commit comments