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
|
@ -51,7 +51,11 @@ impl<'a> DiagnosticDerive<'a> {
|
|||
Some(slug) => {
|
||||
slugs.borrow_mut().push(slug.clone());
|
||||
quote! {
|
||||
let mut diag = dcx.struct_diagnostic(crate::fluent_generated::#slug);
|
||||
let mut diag = rustc_errors::DiagnosticBuilder::new(
|
||||
dcx,
|
||||
level,
|
||||
crate::fluent_generated::#slug
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -77,7 +81,8 @@ impl<'a> DiagnosticDerive<'a> {
|
|||
#[track_caller]
|
||||
fn into_diagnostic(
|
||||
self,
|
||||
dcx: &'_sess rustc_errors::DiagCtxt
|
||||
dcx: &'_sess rustc_errors::DiagCtxt,
|
||||
level: rustc_errors::Level
|
||||
) -> rustc_errors::DiagnosticBuilder<'_sess, G> {
|
||||
#implementation
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue