diff options
| author | mejrs <59372212+mejrs@users.noreply.github.com> | 2023-01-16 00:08:30 +0100 |
|---|---|---|
| committer | mejrs <59372212+mejrs@users.noreply.github.com> | 2023-02-23 01:14:10 +0100 |
| commit | 6f92031233770dadde40bcaa140c73537c87206c (patch) | |
| tree | b9dac0f014be3cfaf727fe9111498b9af3167507 /compiler/rustc_errors/src | |
| parent | fdbc4329cb781c7768ffa6d76c8fa2d032d3fe20 (diff) | |
| download | rust-6f92031233770dadde40bcaa140c73537c87206c.tar.gz rust-6f92031233770dadde40bcaa140c73537c87206c.zip | |
Restore behavior when primary bundle is missing
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/translation.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/compiler/rustc_errors/src/translation.rs b/compiler/rustc_errors/src/translation.rs index 1ac9b8e03c7..ed35eb1b6c4 100644 --- a/compiler/rustc_errors/src/translation.rs +++ b/compiler/rustc_errors/src/translation.rs @@ -1,4 +1,4 @@ -use crate::error::TranslateError; +use crate::error::{TranslateError, TranslateErrorKind}; use crate::snippet::Style; use crate::{DiagnosticArg, DiagnosticMessage, FluentBundle}; use rustc_data_structures::sync::Lrc; @@ -95,6 +95,16 @@ pub trait Translate { // The primary bundle was present and translation succeeded Some(Ok(t)) => t, + // If `translate_with_bundle` returns `Err` with the primary bundle, this is likely + // just that the primary bundle doesn't contain the message being translated, so + // proceed to the fallback bundle. + Some(Err( + primary @ TranslateError::One { + kind: TranslateErrorKind::MessageMissing, .. + }, + )) => translate_with_bundle(self.fallback_fluent_bundle()) + .map_err(|fallback| primary.and(fallback))?, + // Always yeet out for errors on debug (unless // `RUSTC_TRANSLATION_NO_DEBUG_ASSERT` is set in the environment - this allows // local runs of the test suites, of builds with debug assertions, to test the @@ -106,9 +116,8 @@ pub trait Translate { do yeet primary } - // If `translate_with_bundle` returns `Err` with the primary bundle, this is likely - // just that the primary bundle doesn't contain the message being translated or - // something else went wrong) so proceed to the fallback bundle. + // ..otherwise, for end users, an error about this wouldn't be useful or actionable, so + // just hide it and try with the fallback bundle. Some(Err(primary)) => translate_with_bundle(self.fallback_fluent_bundle()) .map_err(|fallback| primary.and(fallback))?, |
