Remove force_print_diagnostic
.
There are a couple of places where we call `inner.emitter.emit_diagnostic` directly rather than going through `inner.emit_diagnostic`, to guarantee the diagnostic is printed. This feels dubious to me, particularly the bypassing of `TRACK_DIAGNOSTIC`. This commit removes those. - In `print_error_count`, it uses `ForceWarning` instead of `Warning`. - It removes `DiagCtxtInner::failure_note`, because it only has three uses and direct use of `emit_diagnostic` is consistent with other similar locations. - It removes `force_print_diagnostic`, and adds `struct_failure_note`, and updates `print_query_stack` accordingly, which makes it more normal. That location doesn't seem to need forced printing anyway.
This commit is contained in:
parent
bdc6d82f9a
commit
c1ffb0b675
2 changed files with 34 additions and 29 deletions
|
@ -4,7 +4,7 @@ use crate::query::plumbing::CycleError;
|
|||
use crate::query::DepKind;
|
||||
use crate::query::{QueryContext, QueryStackFrame};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::{DiagCtxt, Diagnostic, DiagnosticBuilder, Level};
|
||||
use rustc_errors::{DiagCtxt, DiagnosticBuilder};
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::Span;
|
||||
|
@ -628,15 +628,15 @@ pub fn print_query_stack<Qcx: QueryContext>(
|
|||
};
|
||||
if Some(count_printed) < num_frames || num_frames.is_none() {
|
||||
// Only print to stderr as many stack frames as `num_frames` when present.
|
||||
let mut diag = Diagnostic::new(
|
||||
Level::FailureNote,
|
||||
format!(
|
||||
"#{} [{:?}] {}",
|
||||
count_printed, query_info.query.dep_kind, query_info.query.description
|
||||
),
|
||||
);
|
||||
diag.span = query_info.job.span.into();
|
||||
dcx.force_print_diagnostic(diag);
|
||||
// FIXME: needs translation
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
dcx.struct_failure_note(format!(
|
||||
"#{} [{:?}] {}",
|
||||
count_printed, query_info.query.dep_kind, query_info.query.description
|
||||
))
|
||||
.with_span(query_info.job.span)
|
||||
.emit();
|
||||
count_printed += 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue