rename diags
field
This commit is contained in:
parent
8c86e52ed7
commit
099b80923b
3 changed files with 26 additions and 19 deletions
|
@ -117,11 +117,11 @@ impl<'infcx, 'tcx> BorrowckDiagnosticsBuffer<'infcx, 'tcx> {
|
||||||
|
|
||||||
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
||||||
pub(crate) fn buffer_error(&mut self, diag: Diag<'infcx>) {
|
pub(crate) fn buffer_error(&mut self, diag: Diag<'infcx>) {
|
||||||
self.diags.buffered_diags.push(BufferedDiag::Error(diag));
|
self.diags_buffer.buffered_diags.push(BufferedDiag::Error(diag));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn buffer_non_error(&mut self, diag: Diag<'infcx, ()>) {
|
pub(crate) fn buffer_non_error(&mut self, diag: Diag<'infcx, ()>) {
|
||||||
self.diags.buffer_non_error(diag);
|
self.diags_buffer.buffer_non_error(diag);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn buffer_move_error(
|
pub(crate) fn buffer_move_error(
|
||||||
|
@ -130,7 +130,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
||||||
place_and_err: (PlaceRef<'tcx>, Diag<'infcx>),
|
place_and_err: (PlaceRef<'tcx>, Diag<'infcx>),
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if let Some((_, diag)) =
|
if let Some((_, diag)) =
|
||||||
self.diags.buffered_move_errors.insert(move_out_indices, place_and_err)
|
self.diags_buffer.buffered_move_errors.insert(move_out_indices, place_and_err)
|
||||||
{
|
{
|
||||||
// Cancel the old diagnostic so we don't ICE
|
// Cancel the old diagnostic so we don't ICE
|
||||||
diag.cancel();
|
diag.cancel();
|
||||||
|
@ -142,22 +142,22 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
||||||
|
|
||||||
pub(crate) fn get_buffered_mut_error(&mut self, span: Span) -> Option<(Diag<'infcx>, usize)> {
|
pub(crate) fn get_buffered_mut_error(&mut self, span: Span) -> Option<(Diag<'infcx>, usize)> {
|
||||||
// FIXME(#120456) - is `swap_remove` correct?
|
// FIXME(#120456) - is `swap_remove` correct?
|
||||||
self.diags.buffered_mut_errors.swap_remove(&span)
|
self.diags_buffer.buffered_mut_errors.swap_remove(&span)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn buffer_mut_error(&mut self, span: Span, diag: Diag<'infcx>, count: usize) {
|
pub(crate) fn buffer_mut_error(&mut self, span: Span, diag: Diag<'infcx>, count: usize) {
|
||||||
self.diags.buffered_mut_errors.insert(span, (diag, count));
|
self.diags_buffer.buffered_mut_errors.insert(span, (diag, count));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn emit_errors(&mut self) -> Option<ErrorGuaranteed> {
|
pub(crate) fn emit_errors(&mut self) -> Option<ErrorGuaranteed> {
|
||||||
let mut res = self.infcx.tainted_by_errors();
|
let mut res = self.infcx.tainted_by_errors();
|
||||||
|
|
||||||
// Buffer any move errors that we collected and de-duplicated.
|
// Buffer any move errors that we collected and de-duplicated.
|
||||||
for (_, (_, diag)) in std::mem::take(&mut self.diags.buffered_move_errors) {
|
for (_, (_, diag)) in std::mem::take(&mut self.diags_buffer.buffered_move_errors) {
|
||||||
// We have already set tainted for this error, so just buffer it.
|
// We have already set tainted for this error, so just buffer it.
|
||||||
self.buffer_error(diag);
|
self.buffer_error(diag);
|
||||||
}
|
}
|
||||||
for (_, (mut diag, count)) in std::mem::take(&mut self.diags.buffered_mut_errors) {
|
for (_, (mut diag, count)) in std::mem::take(&mut self.diags_buffer.buffered_mut_errors) {
|
||||||
if count > 10 {
|
if count > 10 {
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
#[allow(rustc::untranslatable_diagnostic)]
|
||||||
|
@ -166,9 +166,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
||||||
self.buffer_error(diag);
|
self.buffer_error(diag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.diags.buffered_diags.is_empty() {
|
if !self.diags_buffer.buffered_diags.is_empty() {
|
||||||
self.diags.buffered_diags.sort_by_key(|buffered_diag| buffered_diag.sort_span());
|
self.diags_buffer.buffered_diags.sort_by_key(|buffered_diag| buffered_diag.sort_span());
|
||||||
for buffered_diag in self.diags.buffered_diags.drain(..) {
|
for buffered_diag in self.diags_buffer.buffered_diags.drain(..) {
|
||||||
match buffered_diag {
|
match buffered_diag {
|
||||||
BufferedDiag::Error(diag) => res = Some(diag.emit()),
|
BufferedDiag::Error(diag) => res = Some(diag.emit()),
|
||||||
BufferedDiag::NonError(diag) => diag.emit(),
|
BufferedDiag::NonError(diag) => diag.emit(),
|
||||||
|
@ -180,14 +180,14 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn has_buffered_diags(&self) -> bool {
|
pub(crate) fn has_buffered_diags(&self) -> bool {
|
||||||
self.diags.buffered_diags.is_empty()
|
self.diags_buffer.buffered_diags.is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn has_move_error(
|
pub(crate) fn has_move_error(
|
||||||
&self,
|
&self,
|
||||||
move_out_indices: &[MoveOutIndex],
|
move_out_indices: &[MoveOutIndex],
|
||||||
) -> Option<&(PlaceRef<'tcx>, Diag<'infcx>)> {
|
) -> Option<&(PlaceRef<'tcx>, Diag<'infcx>)> {
|
||||||
self.diags.buffered_move_errors.get(move_out_indices)
|
self.diags_buffer.buffered_move_errors.get(move_out_indices)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -217,8 +217,15 @@ fn do_mir_borrowck<'tcx>(
|
||||||
|
|
||||||
// We also have a `#[rustc_regions]` annotation that causes us to dump
|
// We also have a `#[rustc_regions]` annotation that causes us to dump
|
||||||
// information.
|
// information.
|
||||||
let diags = &mut BorrowckDiagnosticsBuffer::default();
|
let diags_buffer = &mut BorrowckDiagnosticsBuffer::default();
|
||||||
nll::dump_annotation(&infcx, body, ®ioncx, &opt_closure_req, &opaque_type_values, diags);
|
nll::dump_annotation(
|
||||||
|
&infcx,
|
||||||
|
body,
|
||||||
|
®ioncx,
|
||||||
|
&opt_closure_req,
|
||||||
|
&opaque_type_values,
|
||||||
|
diags_buffer,
|
||||||
|
);
|
||||||
|
|
||||||
let movable_coroutine =
|
let movable_coroutine =
|
||||||
// The first argument is the coroutine type passed by value
|
// The first argument is the coroutine type passed by value
|
||||||
|
@ -257,7 +264,7 @@ fn do_mir_borrowck<'tcx>(
|
||||||
next_region_name: RefCell::new(1),
|
next_region_name: RefCell::new(1),
|
||||||
polonius_output: None,
|
polonius_output: None,
|
||||||
move_errors: Vec::new(),
|
move_errors: Vec::new(),
|
||||||
diags,
|
diags_buffer,
|
||||||
};
|
};
|
||||||
MoveVisitor { ctxt: &mut promoted_mbcx }.visit_body(promoted_body);
|
MoveVisitor { ctxt: &mut promoted_mbcx }.visit_body(promoted_body);
|
||||||
promoted_mbcx.report_move_errors();
|
promoted_mbcx.report_move_errors();
|
||||||
|
@ -296,7 +303,7 @@ fn do_mir_borrowck<'tcx>(
|
||||||
next_region_name: RefCell::new(1),
|
next_region_name: RefCell::new(1),
|
||||||
polonius_output,
|
polonius_output,
|
||||||
move_errors: Vec::new(),
|
move_errors: Vec::new(),
|
||||||
diags,
|
diags_buffer,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Compute and report region errors, if any.
|
// Compute and report region errors, if any.
|
||||||
|
@ -566,7 +573,7 @@ struct MirBorrowckCtxt<'a, 'infcx, 'tcx> {
|
||||||
/// Results of Polonius analysis.
|
/// Results of Polonius analysis.
|
||||||
polonius_output: Option<Box<PoloniusOutput>>,
|
polonius_output: Option<Box<PoloniusOutput>>,
|
||||||
|
|
||||||
diags: &'a mut BorrowckDiagnosticsBuffer<'infcx, 'tcx>,
|
diags_buffer: &'a mut BorrowckDiagnosticsBuffer<'infcx, 'tcx>,
|
||||||
move_errors: Vec<MoveError<'tcx>>,
|
move_errors: Vec<MoveError<'tcx>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -298,7 +298,7 @@ pub(super) fn dump_annotation<'tcx, 'infcx>(
|
||||||
regioncx: &RegionInferenceContext<'tcx>,
|
regioncx: &RegionInferenceContext<'tcx>,
|
||||||
closure_region_requirements: &Option<ClosureRegionRequirements<'tcx>>,
|
closure_region_requirements: &Option<ClosureRegionRequirements<'tcx>>,
|
||||||
opaque_type_values: &FxIndexMap<LocalDefId, OpaqueHiddenType<'tcx>>,
|
opaque_type_values: &FxIndexMap<LocalDefId, OpaqueHiddenType<'tcx>>,
|
||||||
diags: &mut BorrowckDiagnosticsBuffer<'infcx, 'tcx>,
|
diagnostics_buffer: &mut BorrowckDiagnosticsBuffer<'infcx, 'tcx>,
|
||||||
) {
|
) {
|
||||||
let tcx = infcx.tcx;
|
let tcx = infcx.tcx;
|
||||||
let base_def_id = tcx.typeck_root_def_id(body.source.def_id());
|
let base_def_id = tcx.typeck_root_def_id(body.source.def_id());
|
||||||
|
@ -344,7 +344,7 @@ pub(super) fn dump_annotation<'tcx, 'infcx>(
|
||||||
err.note(format!("Inferred opaque type values:\n{opaque_type_values:#?}"));
|
err.note(format!("Inferred opaque type values:\n{opaque_type_values:#?}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
diags.buffer_non_error(err);
|
diagnostics_buffer.buffer_non_error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn for_each_region_constraint<'tcx>(
|
fn for_each_region_constraint<'tcx>(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue