errors: simplify referring to fluent attributes
To render the message of a Fluent attribute, the identifier of the Fluent message must be known. `DiagnosticMessage::FluentIdentifier` contains both the message's identifier and optionally the identifier of an attribute. Generated constants for each attribute would therefore need to be named uniquely (amongst all error messages) or be able to refer to only the attribute identifier which will be combined with a message identifier later. In this commit, the latter strategy is implemented as part of the `Diagnostic` type's functions for adding subdiagnostics of various kinds. Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
855fc022fe
commit
f669b78ffc
13 changed files with 190 additions and 150 deletions
|
@ -277,7 +277,7 @@ impl<'a> SessionDiagnostic<'a> for MissingTypeParams {
|
|||
.join(", "),
|
||||
);
|
||||
|
||||
err.span_label(self.def_span, rustc_errors::fluent::typeck::missing_type_params_label);
|
||||
err.span_label(self.def_span, rustc_errors::fluent::typeck::label);
|
||||
|
||||
let mut suggested = false;
|
||||
if let (Ok(snippet), true) = (
|
||||
|
@ -295,7 +295,7 @@ impl<'a> SessionDiagnostic<'a> for MissingTypeParams {
|
|||
// least we can clue them to the correct syntax `Iterator<Type>`.
|
||||
err.span_suggestion(
|
||||
self.span,
|
||||
rustc_errors::fluent::typeck::missing_type_params_suggestion,
|
||||
rustc_errors::fluent::typeck::suggestion,
|
||||
format!("{}<{}>", snippet, self.missing_type_params.join(", ")),
|
||||
Applicability::HasPlaceholders,
|
||||
);
|
||||
|
@ -303,13 +303,10 @@ impl<'a> SessionDiagnostic<'a> for MissingTypeParams {
|
|||
}
|
||||
}
|
||||
if !suggested {
|
||||
err.span_label(
|
||||
self.span,
|
||||
rustc_errors::fluent::typeck::missing_type_params_no_suggestion_label,
|
||||
);
|
||||
err.span_label(self.span, rustc_errors::fluent::typeck::no_suggestion_label);
|
||||
}
|
||||
|
||||
err.note(rustc_errors::fluent::typeck::missing_type_params_note);
|
||||
err.note(rustc_errors::fluent::typeck::note);
|
||||
err
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue