diff options
| author | mejrs <> | 2023-01-08 23:35:43 +0100 |
|---|---|---|
| committer | mejrs <> | 2023-01-08 23:35:43 +0100 |
| commit | 262ff86138730c1eb65f3ec39dd9c93222ed77e7 (patch) | |
| tree | 9d7f20bab8a92573aca545ef45c0e7165f6d5a59 /compiler/rustc_errors/src/lib.rs | |
| parent | 0b5d6ae5dbbbe6b05a85bdcccc8aedbb96feedf4 (diff) | |
Make translate_message return result and add tests
Diffstat (limited to 'compiler/rustc_errors/src/lib.rs')
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 6f411c5174a..0b5bfdc8e89 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -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; |
