Skip to content

Commit c5c7d2b

Browse files
committedFeb 24, 2023
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
·
1.87.01.69.0
2 parents 07c993e + c77cf40 commit c5c7d2b

File tree

144 files changed

+741
-408
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+741
-408
lines changed
 

‎compiler/rustc_error_messages/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,10 @@ pub fn fluent_bundle(
135135

136136
let fallback_locale = langid!("en-US");
137137
let requested_fallback_locale = requested_locale.as_ref() == Some(&fallback_locale);
138-
138+
trace!(?requested_fallback_locale);
139+
if requested_fallback_locale && additional_ftl_path.is_none() {
140+
return Ok(None);
141+
}
139142
// If there is only `-Z additional-ftl-path`, assume locale is "en-US", otherwise use user
140143
// provided locale.
141144
let locale = requested_locale.clone().unwrap_or(fallback_locale);
@@ -153,7 +156,7 @@ pub fn fluent_bundle(
153156
bundle.set_use_isolating(with_directionality_markers);
154157

155158
// If the user requests the default locale then don't try to load anything.
156-
if !requested_fallback_locale && let Some(requested_locale) = requested_locale {
159+
if let Some(requested_locale) = requested_locale {
157160
let mut found_resources = false;
158161
for sysroot in user_provided_sysroot.iter_mut().chain(sysroot_candidates.iter_mut()) {
159162
sysroot.push("share");

‎compiler/rustc_errors/src/translation.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::error::TranslateError;
1+
use crate::error::{TranslateError, TranslateErrorKind};
22
use crate::snippet::Style;
33
use crate::{DiagnosticArg, DiagnosticMessage, FluentBundle};
44
use rustc_data_structures::sync::Lrc;
@@ -95,6 +95,16 @@ pub trait Translate {
9595
// The primary bundle was present and translation succeeded
9696
Some(Ok(t)) => t,
9797

98+
// If `translate_with_bundle` returns `Err` with the primary bundle, this is likely
99+
// just that the primary bundle doesn't contain the message being translated, so
100+
// proceed to the fallback bundle.
101+
Some(Err(
102+
primary @ TranslateError::One {
103+
kind: TranslateErrorKind::MessageMissing, ..
104+
},
105+
)) => translate_with_bundle(self.fallback_fluent_bundle())
106+
.map_err(|fallback| primary.and(fallback))?,
107+
98108
// Always yeet out for errors on debug (unless
99109
// `RUSTC_TRANSLATION_NO_DEBUG_ASSERT` is set in the environment - this allows
100110
// local runs of the test suites, of builds with debug assertions, to test the
@@ -106,9 +116,8 @@ pub trait Translate {
106116
do yeet primary
107117
}
108118

109-
// If `translate_with_bundle` returns `Err` with the primary bundle, this is likely
110-
// just that the primary bundle doesn't contain the message being translated or
111-
// something else went wrong) so proceed to the fallback bundle.
119+
// ..otherwise, for end users, an error about this wouldn't be useful or actionable, so
120+
// just hide it and try with the fallback bundle.
112121
Some(Err(primary)) => translate_with_bundle(self.fallback_fluent_bundle())
113122
.map_err(|fallback| primary.and(fallback))?,
114123

0 commit comments

Comments
 (0)
Please sign in to comment.