errors: implement fallback diagnostic translation
This commit updates the signatures of all diagnostic functions to accept types that can be converted into a `DiagnosticMessage`. This enables existing diagnostic calls to continue to work as before and Fluent identifiers to be provided. The `SessionDiagnostic` derive just generates normal diagnostic calls, so these APIs had to be modified to accept Fluent identifiers. In addition, loading of the "fallback" Fluent bundle, which contains the built-in English messages, has been implemented. Each diagnostic now has "arguments" which correspond to variables in the Fluent messages (necessary to render a Fluent message) but no API for adding arguments has been added yet. Therefore, diagnostics (that do not require interpolation) can be converted to use Fluent identifiers and will be output as before.
This commit is contained in:
@@ -1703,7 +1703,7 @@ impl<'a> Parser<'a> {
|
||||
if matches!(expr.kind, ExprKind::Err) {
|
||||
let mut err = self
|
||||
.diagnostic()
|
||||
.struct_span_err(self.token.span, &"invalid interpolated expression");
|
||||
.struct_span_err(self.token.span, "invalid interpolated expression");
|
||||
err.downgrade_to_delayed_bug();
|
||||
return err;
|
||||
}
|
||||
@@ -1820,7 +1820,7 @@ impl<'a> Parser<'a> {
|
||||
} else if let Some(fixed) = fix_base_capitalisation(suf) {
|
||||
let msg = "invalid base prefix for number literal";
|
||||
|
||||
self.struct_span_err(span, &msg)
|
||||
self.struct_span_err(span, msg)
|
||||
.note("base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase")
|
||||
.span_suggestion(
|
||||
span,
|
||||
|
||||
Reference in New Issue
Block a user