@@ -85,7 +85,8 @@ impl<'infcx> BufferedDiag<'infcx> {
85
85
}
86
86
}
87
87
88
- pub ( crate ) struct BorrowckDiags < ' infcx , ' tcx > {
88
+ #[ derive( Default ) ]
89
+ pub ( crate ) struct BorrowckDiagnosticsBuffer < ' infcx , ' tcx > {
89
90
/// This field keeps track of move errors that are to be reported for given move indices.
90
91
///
91
92
/// 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> {
108
109
buffered_diags : Vec < BufferedDiag < ' infcx > > ,
109
110
}
110
111
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 > {
124
113
pub ( crate ) fn buffer_non_error ( & mut self , diag : Diag < ' infcx , ( ) > ) {
125
114
self . buffered_diags . push ( BufferedDiag :: NonError ( diag) ) ;
126
115
}
127
116
}
128
117
129
118
impl < ' infcx , ' tcx > MirBorrowckCtxt < ' _ , ' infcx , ' tcx > {
130
119
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) ) ;
132
121
}
133
122
134
123
pub ( crate ) fn buffer_non_error ( & mut self , diag : Diag < ' infcx , ( ) > ) {
@@ -166,15 +155,15 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
166
155
// Buffer any move errors that we collected and de-duplicated.
167
156
for ( _, ( _, diag) ) in std:: mem:: take ( & mut self . diags . buffered_move_errors ) {
168
157
// We have already set tainted for this error, so just buffer it.
169
- self . diags . buffer_error ( diag) ;
158
+ self . buffer_error ( diag) ;
170
159
}
171
160
for ( _, ( mut diag, count) ) in std:: mem:: take ( & mut self . diags . buffered_mut_errors ) {
172
161
if count > 10 {
173
162
#[ allow( rustc:: diagnostic_outside_of_impl) ]
174
163
#[ allow( rustc:: untranslatable_diagnostic) ]
175
164
diag. note ( format ! ( "...and {} other attempted mutable borrows" , count - 10 ) ) ;
176
165
}
177
- self . diags . buffer_error ( diag) ;
166
+ self . buffer_error ( diag) ;
178
167
}
179
168
180
169
if !self . diags . buffered_diags . is_empty ( ) {
0 commit comments