diff options
| author | bors <bors@rust-lang.org> | 2023-02-24 20:49:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-02-24 20:49:11 +0000 |
| commit | c5c7d2b37780dac1092e75f12ab97dd56c30861d (patch) | |
| tree | 49c2d2c3260c227c8505e60f115981e27183caef /compiler/rustc_errors/src | |
| parent | 07c993eba8b76eae497e98433ae075b00f01be10 (diff) | |
| parent | c77cf40df0bb75aceb85ab4908fbdb103538df9a (diff) | |
| download | rust-c5c7d2b37780dac1092e75f12ab97dd56c30861d.tar.gz rust-c5c7d2b37780dac1092e75f12ab97dd56c30861d.zip | |
Auto merge of #108421 - Dylan-DPC:rollup-mpeovxd, r=Dylan-DPC
Rollup of 10 pull requests Successful merges: - #106541 (implement const iterator using `rustc_do_not_const_check`) - #106918 (Rebuild BinaryHeap on unwind from retain) - #106923 (Restore behavior when primary bundle is missing) - #108169 (Make query keys `Copy`) - #108287 (Add test for bad cast with deferred projection equality) - #108370 (std: time: Avoid to use "was created" in elapsed() description) - #108377 (Fix ICE in 'duplicate diagnostic item' diagnostic) - #108388 (parser: provide better suggestions and errors on closures with braces missing) - #108391 (Fix `is_terminal`'s handling of long paths on Windows.) - #108401 (diagnostics: remove inconsistent English article "this" from E0107) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
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))?, |
