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
|
@ -2,8 +2,8 @@
|
|||
|
||||
use crate::fluent_generated as fluent;
|
||||
use rustc_errors::{
|
||||
error_code, Applicability, DiagCtxt, DiagnosticBuilder, ErrorGuaranteed, IntoDiagnostic,
|
||||
MultiSpan,
|
||||
error_code, Applicability, DiagCtxt, DiagnosticBuilder, EmissionGuarantee, IntoDiagnostic,
|
||||
Level, MultiSpan,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||
use rustc_middle::ty::Ty;
|
||||
|
@ -315,14 +315,12 @@ pub struct MissingTypeParams {
|
|||
}
|
||||
|
||||
// Manual implementation of `IntoDiagnostic` to be able to call `span_to_snippet`.
|
||||
impl<'a> IntoDiagnostic<'a> for MissingTypeParams {
|
||||
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for MissingTypeParams {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(self, dcx: &'a DiagCtxt) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
let mut err = dcx.struct_span_err_with_code(
|
||||
self.span,
|
||||
fluent::hir_analysis_missing_type_params,
|
||||
error_code!(E0393),
|
||||
);
|
||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> {
|
||||
let mut err = DiagnosticBuilder::new(dcx, level, fluent::hir_analysis_missing_type_params);
|
||||
err.set_span(self.span);
|
||||
err.code(error_code!(E0393));
|
||||
err.set_arg("parameterCount", self.missing_type_params.len());
|
||||
err.set_arg(
|
||||
"parameters",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue