1
Fork 0

errors: set_arg takes IntoDiagnosticArg

Manual implementors of translatable diagnostics will need to call
`set_arg`, not just the derive, so make this function a bit more
ergonomic by taking `IntoDiagnosticArg` rather than
`DiagnosticArgValue`.

Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
David Wood 2022-05-07 07:26:03 +01:00
parent b5545f1b0c
commit de3e8ca2f3
6 changed files with 22 additions and 13 deletions

View file

@ -821,9 +821,9 @@ impl Diagnostic {
pub fn set_arg(
&mut self,
name: impl Into<Cow<'static, str>>,
arg: DiagnosticArgValue<'static>,
arg: impl IntoDiagnosticArg,
) -> &mut Self {
self.args.push((name.into(), arg));
self.args.push((name.into(), arg.into_diagnostic_arg()));
self
}

View file

@ -1,4 +1,4 @@
use crate::diagnostic::DiagnosticArgValue;
use crate::diagnostic::IntoDiagnosticArg;
use crate::{Diagnostic, DiagnosticId, DiagnosticMessage, DiagnosticStyledString, ErrorGuaranteed};
use crate::{Handler, Level, MultiSpan, StashKey};
use rustc_lint_defs::Applicability;
@ -528,7 +528,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
forward!(pub fn set_arg(
&mut self,
name: impl Into<Cow<'static, str>>,
arg: DiagnosticArgValue<'static>,
arg: impl IntoDiagnosticArg,
) -> &mut Self);
forward!(pub fn subdiagnostic(