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:
parent
c45f29595d
commit
7f91697b50
46 changed files with 919 additions and 293 deletions
|
@ -1341,7 +1341,7 @@ impl<'a> Resolver<'a> {
|
|||
let def_span = self.session.source_map().guess_head_span(binding.span);
|
||||
let mut note_span = MultiSpan::from_span(def_span);
|
||||
if !first && binding.vis.is_public() {
|
||||
note_span.push_span_label(def_span, "consider importing it directly".into());
|
||||
note_span.push_span_label(def_span, "consider importing it directly");
|
||||
}
|
||||
err.span_note(note_span, &msg);
|
||||
}
|
||||
|
|
|
@ -739,7 +739,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
|
|||
|
||||
if let Some((_, UnresolvedImportError { note, .. })) = errors.iter().last() {
|
||||
for message in note {
|
||||
diag.note(&message);
|
||||
diag.note(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1140,7 +1140,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
}
|
||||
err.span_suggestion(
|
||||
span,
|
||||
&"use this syntax instead",
|
||||
"use this syntax instead",
|
||||
path_str.to_string(),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue