macros: add args for non-subdiagnostic fields
Non-subdiagnostic fields (i.e. those that don't have `#[label]` attributes or similar and are just additional context) have to be added as arguments for Fluent messages to refer them. This commit extends the `SessionDiagnostic` derive to do this for all fields that do not have attributes and introduces an `IntoDiagnosticArg` trait that is implemented on all types that can be converted to a argument for Fluent. Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
8677fef192
commit
9956d4f99d
6 changed files with 122 additions and 30 deletions
|
@ -1,8 +1,10 @@
|
|||
use crate::diagnostic::DiagnosticArgValue;
|
||||
use crate::{Diagnostic, DiagnosticId, DiagnosticMessage, DiagnosticStyledString, ErrorGuaranteed};
|
||||
use crate::{Handler, Level, MultiSpan, StashKey};
|
||||
use rustc_lint_defs::Applicability;
|
||||
|
||||
use rustc_span::Span;
|
||||
use std::borrow::Cow;
|
||||
use std::fmt::{self, Debug};
|
||||
use std::marker::PhantomData;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
@ -536,6 +538,11 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
|||
forward!(pub fn set_primary_message(&mut self, msg: impl Into<String>) -> &mut Self);
|
||||
forward!(pub fn set_span(&mut self, sp: impl Into<MultiSpan>) -> &mut Self);
|
||||
forward!(pub fn code(&mut self, s: DiagnosticId) -> &mut Self);
|
||||
forward!(pub fn set_arg(
|
||||
&mut self,
|
||||
name: impl Into<Cow<'static, str>>,
|
||||
arg: DiagnosticArgValue<'static>,
|
||||
) -> &mut Self);
|
||||
}
|
||||
|
||||
impl<G: EmissionGuarantee> Debug for DiagnosticBuilder<'_, G> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue