errors: move translation logic into module
Just moving code around so that triagebot can ping relevant parties when translation logic is modified. Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
6ce76091c7
commit
510ba031dc
8 changed files with 201 additions and 164 deletions
|
@ -13,6 +13,7 @@ use rustc_span::source_map::{FilePathMapping, SourceMap};
|
|||
|
||||
use crate::emitter::{Emitter, HumanReadableErrorType};
|
||||
use crate::registry::Registry;
|
||||
use crate::translation::Translate;
|
||||
use crate::DiagnosticId;
|
||||
use crate::{
|
||||
CodeSuggestion, FluentBundle, LazyFallbackBundle, MultiSpan, SpanLabel, SubDiagnostic,
|
||||
|
@ -122,6 +123,16 @@ impl JsonEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
impl Translate for JsonEmitter {
|
||||
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
|
||||
self.fluent_bundle.as_ref()
|
||||
}
|
||||
|
||||
fn fallback_fluent_bundle(&self) -> &FluentBundle {
|
||||
&**self.fallback_bundle
|
||||
}
|
||||
}
|
||||
|
||||
impl Emitter for JsonEmitter {
|
||||
fn emit_diagnostic(&mut self, diag: &crate::Diagnostic) {
|
||||
let data = Diagnostic::from_errors_diagnostic(diag, self);
|
||||
|
@ -189,14 +200,6 @@ impl Emitter for JsonEmitter {
|
|||
Some(&self.sm)
|
||||
}
|
||||
|
||||
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
|
||||
self.fluent_bundle.as_ref()
|
||||
}
|
||||
|
||||
fn fallback_fluent_bundle(&self) -> &FluentBundle {
|
||||
&**self.fallback_bundle
|
||||
}
|
||||
|
||||
fn should_show_explain(&self) -> bool {
|
||||
!matches!(self.json_rendered, HumanReadableErrorType::Short(_))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue