Skip to content

Commit 099b809

Browse files
committed
rename diags field
1 parent 8c86e52 commit 099b809

File tree

3 files changed

+26
-19
lines changed

3 files changed

+26
-19
lines changed

compiler/rustc_borrowck/src/diagnostics/mod.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ impl<'infcx, 'tcx> BorrowckDiagnosticsBuffer<'infcx, 'tcx> {
117117

118118
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
119119
pub(crate) fn buffer_error(&mut self, diag: Diag<'infcx>) {
120-
self.diags.buffered_diags.push(BufferedDiag::Error(diag));
120+
self.diags_buffer.buffered_diags.push(BufferedDiag::Error(diag));
121121
}
122122

123123
pub(crate) fn buffer_non_error(&mut self, diag: Diag<'infcx, ()>) {
124-
self.diags.buffer_non_error(diag);
124+
self.diags_buffer.buffer_non_error(diag);
125125
}
126126

127127
pub(crate) fn buffer_move_error(
@@ -130,7 +130,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
130130
place_and_err: (PlaceRef<'tcx>, Diag<'infcx>),
131131
) -> bool {
132132
if let Some((_, diag)) =
133-
self.diags.buffered_move_errors.insert(move_out_indices, place_and_err)
133+
self.diags_buffer.buffered_move_errors.insert(move_out_indices, place_and_err)
134134
{
135135
// Cancel the old diagnostic so we don't ICE
136136
diag.cancel();
@@ -142,22 +142,22 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
142142

143143
pub(crate) fn get_buffered_mut_error(&mut self, span: Span) -> Option<(Diag<'infcx>, usize)> {
144144
// FIXME(#120456) - is `swap_remove` correct?
145-
self.diags.buffered_mut_errors.swap_remove(&span)
145+
self.diags_buffer.buffered_mut_errors.swap_remove(&span)
146146
}
147147

148148
pub(crate) fn buffer_mut_error(&mut self, span: Span, diag: Diag<'infcx>, count: usize) {
149-
self.diags.buffered_mut_errors.insert(span, (diag, count));
149+
self.diags_buffer.buffered_mut_errors.insert(span, (diag, count));
150150
}
151151

152152
pub(crate) fn emit_errors(&mut self) -> Option<ErrorGuaranteed> {
153153
let mut res = self.infcx.tainted_by_errors();
154154

155155
// Buffer any move errors that we collected and de-duplicated.
156-
for (_, (_, diag)) in std::mem::take(&mut self.diags.buffered_move_errors) {
156+
for (_, (_, diag)) in std::mem::take(&mut self.diags_buffer.buffered_move_errors) {
157157
// We have already set tainted for this error, so just buffer it.
158158
self.buffer_error(diag);
159159
}
160-
for (_, (mut diag, count)) in std::mem::take(&mut self.diags.buffered_mut_errors) {
160+
for (_, (mut diag, count)) in std::mem::take(&mut self.diags_buffer.buffered_mut_errors) {
161161
if count > 10 {
162162
#[allow(rustc::diagnostic_outside_of_impl)]
163163
#[allow(rustc::untranslatable_diagnostic)]
@@ -166,9 +166,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
166166
self.buffer_error(diag);
167167
}
168168

169-
if !self.diags.buffered_diags.is_empty() {
170-
self.diags.buffered_diags.sort_by_key(|buffered_diag| buffered_diag.sort_span());
171-
for buffered_diag in self.diags.buffered_diags.drain(..) {
169+
if !self.diags_buffer.buffered_diags.is_empty() {
170+
self.diags_buffer.buffered_diags.sort_by_key(|buffered_diag| buffered_diag.sort_span());
171+
for buffered_diag in self.diags_buffer.buffered_diags.drain(..) {
172172
match buffered_diag {
173173
BufferedDiag::Error(diag) => res = Some(diag.emit()),
174174
BufferedDiag::NonError(diag) => diag.emit(),
@@ -180,14 +180,14 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
180180
}
181181

182182
pub(crate) fn has_buffered_diags(&self) -> bool {
183-
self.diags.buffered_diags.is_empty()
183+
self.diags_buffer.buffered_diags.is_empty()
184184
}
185185

186186
pub(crate) fn has_move_error(
187187
&self,
188188
move_out_indices: &[MoveOutIndex],
189189
) -> Option<&(PlaceRef<'tcx>, Diag<'infcx>)> {
190-
self.diags.buffered_move_errors.get(move_out_indices)
190+
self.diags_buffer.buffered_move_errors.get(move_out_indices)
191191
}
192192
}
193193

compiler/rustc_borrowck/src/lib.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,15 @@ fn do_mir_borrowck<'tcx>(
217217

218218
// We also have a `#[rustc_regions]` annotation that causes us to dump
219219
// information.
220-
let diags = &mut BorrowckDiagnosticsBuffer::default();
221-
nll::dump_annotation(&infcx, body, &regioncx, &opt_closure_req, &opaque_type_values, diags);
220+
let diags_buffer = &mut BorrowckDiagnosticsBuffer::default();
221+
nll::dump_annotation(
222+
&infcx,
223+
body,
224+
&regioncx,
225+
&opt_closure_req,
226+
&opaque_type_values,
227+
diags_buffer,
228+
);
222229

223230
let movable_coroutine =
224231
// The first argument is the coroutine type passed by value
@@ -257,7 +264,7 @@ fn do_mir_borrowck<'tcx>(
257264
next_region_name: RefCell::new(1),
258265
polonius_output: None,
259266
move_errors: Vec::new(),
260-
diags,
267+
diags_buffer,
261268
};
262269
MoveVisitor { ctxt: &mut promoted_mbcx }.visit_body(promoted_body);
263270
promoted_mbcx.report_move_errors();
@@ -296,7 +303,7 @@ fn do_mir_borrowck<'tcx>(
296303
next_region_name: RefCell::new(1),
297304
polonius_output,
298305
move_errors: Vec::new(),
299-
diags,
306+
diags_buffer,
300307
};
301308

302309
// Compute and report region errors, if any.
@@ -566,7 +573,7 @@ struct MirBorrowckCtxt<'a, 'infcx, 'tcx> {
566573
/// Results of Polonius analysis.
567574
polonius_output: Option<Box<PoloniusOutput>>,
568575

569-
diags: &'a mut BorrowckDiagnosticsBuffer<'infcx, 'tcx>,
576+
diags_buffer: &'a mut BorrowckDiagnosticsBuffer<'infcx, 'tcx>,
570577
move_errors: Vec<MoveError<'tcx>>,
571578
}
572579

compiler/rustc_borrowck/src/nll.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ pub(super) fn dump_annotation<'tcx, 'infcx>(
298298
regioncx: &RegionInferenceContext<'tcx>,
299299
closure_region_requirements: &Option<ClosureRegionRequirements<'tcx>>,
300300
opaque_type_values: &FxIndexMap<LocalDefId, OpaqueHiddenType<'tcx>>,
301-
diags: &mut BorrowckDiagnosticsBuffer<'infcx, 'tcx>,
301+
diagnostics_buffer: &mut BorrowckDiagnosticsBuffer<'infcx, 'tcx>,
302302
) {
303303
let tcx = infcx.tcx;
304304
let base_def_id = tcx.typeck_root_def_id(body.source.def_id());
@@ -344,7 +344,7 @@ pub(super) fn dump_annotation<'tcx, 'infcx>(
344344
err.note(format!("Inferred opaque type values:\n{opaque_type_values:#?}"));
345345
}
346346

347-
diags.buffer_non_error(err);
347+
diagnostics_buffer.buffer_non_error(err);
348348
}
349349

350350
fn for_each_region_constraint<'tcx>(

0 commit comments

Comments
 (0)