Add level
arg to into_diagnostic
.
And make all hand-written `IntoDiagnostic` impls generic, by using `DiagnosticBuilder::new(dcx, level, ...)` instead of e.g. `dcx.struct_err(...)`. This means the `create_*` functions are the source of the error level. This change will let us remove `struct_diagnostic`. Note: `#[rustc_lint_diagnostics]` is added to `DiagnosticBuilder::new`, it's necessary to pass diagnostics tests now that it's used in `into_diagnostic` functions.
This commit is contained in:
parent
31df50c897
commit
e7724a2e31
24 changed files with 307 additions and 288 deletions
|
@ -1,6 +1,6 @@
|
|||
//! Errors emitted by symbol_mangling.
|
||||
|
||||
use rustc_errors::{ErrorGuaranteed, IntoDiagnostic};
|
||||
use rustc_errors::{DiagCtxt, DiagnosticBuilder, EmissionGuarantee, IntoDiagnostic, Level};
|
||||
use rustc_span::Span;
|
||||
use std::fmt;
|
||||
|
||||
|
@ -13,15 +13,12 @@ pub struct TestOutput {
|
|||
// This diagnostic doesn't need translation because (a) it doesn't contain any
|
||||
// natural language, and (b) it's only used in tests. So we construct it
|
||||
// manually and avoid the fluent machinery.
|
||||
impl IntoDiagnostic<'_> for TestOutput {
|
||||
fn into_diagnostic(
|
||||
self,
|
||||
dcx: &'_ rustc_errors::DiagCtxt,
|
||||
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for TestOutput {
|
||||
fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> {
|
||||
let TestOutput { span, kind, content } = self;
|
||||
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
let mut diag = dcx.struct_err(format!("{kind}({content})"));
|
||||
let mut diag = DiagnosticBuilder::new(dcx, level, format!("{kind}({content})"));
|
||||
diag.set_span(span);
|
||||
diag
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue