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
|
@ -2075,7 +2075,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
{
|
||||
diag.span_suggestion(
|
||||
span,
|
||||
msg,
|
||||
*msg,
|
||||
format!("{}.as_ref()", snippet),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
|
|
|
@ -41,8 +41,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
let mut err = self.tcx().sess.struct_span_err(cause.span, "incompatible lifetime on type");
|
||||
// FIXME: we should point at the lifetime
|
||||
let mut multi_span: MultiSpan = vec![binding_span].into();
|
||||
multi_span
|
||||
.push_span_label(binding_span, "introduces a `'static` lifetime requirement".into());
|
||||
multi_span.push_span_label(binding_span, "introduces a `'static` lifetime requirement");
|
||||
err.span_note(multi_span, "because this has an unmet lifetime requirement");
|
||||
note_and_explain_region(self.tcx(), &mut err, "", sup, "...", Some(binding_span));
|
||||
if let Some(impl_node) = self.tcx().hir().get_if_local(*impl_def_id) {
|
||||
|
|
|
@ -7,7 +7,7 @@ use rustc_middle::ty::{self, Region};
|
|||
|
||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
pub(super) fn note_region_origin(&self, err: &mut Diagnostic, origin: &SubregionOrigin<'tcx>) {
|
||||
let mut label_or_note = |span, msg| {
|
||||
let mut label_or_note = |span, msg: &str| {
|
||||
let sub_count = err.children.iter().filter(|d| d.span.is_dummy()).count();
|
||||
let expanded_sub_count = err.children.iter().filter(|d| !d.span.is_dummy()).count();
|
||||
let span_is_primary = err.span.primary_spans().iter().all(|&sp| sp == span);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue