Make translate_message return result and add tests
This commit is contained in:
@@ -46,6 +46,7 @@ use rustc_span::{Loc, Span};
|
||||
|
||||
use std::any::Any;
|
||||
use std::borrow::Cow;
|
||||
use std::error::Report;
|
||||
use std::fmt;
|
||||
use std::hash::Hash;
|
||||
use std::num::NonZeroUsize;
|
||||
@@ -65,6 +66,8 @@ mod lock;
|
||||
pub mod registry;
|
||||
mod snippet;
|
||||
mod styled_buffer;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
pub mod translation;
|
||||
|
||||
pub use diagnostic_builder::IntoDiagnostic;
|
||||
@@ -627,7 +630,14 @@ impl Handler {
|
||||
) -> SubdiagnosticMessage {
|
||||
let inner = self.inner.borrow();
|
||||
let args = crate::translation::to_fluent_args(args);
|
||||
SubdiagnosticMessage::Eager(inner.emitter.translate_message(&message, &args).to_string())
|
||||
SubdiagnosticMessage::Eager(
|
||||
inner
|
||||
.emitter
|
||||
.translate_message(&message, &args)
|
||||
.map_err(Report::new)
|
||||
.unwrap()
|
||||
.to_string(),
|
||||
)
|
||||
}
|
||||
|
||||
// This is here to not allow mutation of flags;
|
||||
|
||||
Reference in New Issue
Block a user