1
Fork 0

macros: support translatable labels

Extends support for generating `DiagnosticMessage::FluentIdentifier`
messages from `SessionDiagnostic` derive to `#[label]`.

Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
David Wood 2022-03-31 10:24:46 +01:00
parent 72dec56028
commit a88717cef0
8 changed files with 140 additions and 95 deletions

View file

@ -277,7 +277,7 @@ impl Diagnostic {
///
/// This span is *not* considered a ["primary span"][`MultiSpan`]; only
/// the `Span` supplied when creating the diagnostic is primary.
pub fn span_label<T: Into<String>>(&mut self, span: Span, label: T) -> &mut Self {
pub fn span_label(&mut self, span: Span, label: impl Into<DiagnosticMessage>) -> &mut Self {
self.span.push_span_label(span, label.into());
self
}

View file

@ -408,7 +408,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
/// the diagnostic was constructed. However, the label span is *not* considered a
/// ["primary span"][`MultiSpan`]; only the `Span` supplied when creating the diagnostic is
/// primary.
pub fn span_label(&mut self, span: Span, label: impl Into<String>) -> &mut Self);
pub fn span_label(&mut self, span: Span, label: impl Into<DiagnosticMessage>) -> &mut Self);
forward!(
/// Labels all the given spans with the provided label.