Rollup merge of #106923 - mejrs:fluent_err, r=davidtwco
Restore behavior when primary bundle is missing Fixes https://github.com/rust-lang/rust/issues/106755 by restoring some of the behavior prior to https://github.com/rust-lang/rust/pull/106427 Still, I have no idea how this debug assertion can even hit while using `en-US` as primary bundle. r? ```@davidtwco```
This commit is contained in:
commit
6826a96067
@ -135,7 +135,10 @@ pub fn fluent_bundle(
|
||||
|
||||
let fallback_locale = langid!("en-US");
|
||||
let requested_fallback_locale = requested_locale.as_ref() == Some(&fallback_locale);
|
||||
|
||||
trace!(?requested_fallback_locale);
|
||||
if requested_fallback_locale && additional_ftl_path.is_none() {
|
||||
return Ok(None);
|
||||
}
|
||||
// If there is only `-Z additional-ftl-path`, assume locale is "en-US", otherwise use user
|
||||
// provided locale.
|
||||
let locale = requested_locale.clone().unwrap_or(fallback_locale);
|
||||
@ -153,7 +156,7 @@ pub fn fluent_bundle(
|
||||
bundle.set_use_isolating(with_directionality_markers);
|
||||
|
||||
// If the user requests the default locale then don't try to load anything.
|
||||
if !requested_fallback_locale && let Some(requested_locale) = requested_locale {
|
||||
if let Some(requested_locale) = requested_locale {
|
||||
let mut found_resources = false;
|
||||
for sysroot in user_provided_sysroot.iter_mut().chain(sysroot_candidates.iter_mut()) {
|
||||
sysroot.push("share");
|
||||
|
@ -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))?,
|
||||
|
||||
|
19
tests/ui/issues/issue-106755.rs
Normal file
19
tests/ui/issues/issue-106755.rs
Normal file
@ -0,0 +1,19 @@
|
||||
// compile-flags:-Ztranslate-lang=en_US
|
||||
|
||||
#![feature(negative_impls)]
|
||||
#![feature(marker_trait_attr)]
|
||||
|
||||
#[marker]
|
||||
trait MyTrait {}
|
||||
|
||||
struct TestType<T>(::std::marker::PhantomData<T>);
|
||||
|
||||
unsafe impl<T: MyTrait + 'static> Send for TestType<T> {}
|
||||
|
||||
impl<T: MyTrait> !Send for TestType<T> {} //~ ERROR found both positive and negative implementation
|
||||
|
||||
unsafe impl<T: 'static> Send for TestType<T> {} //~ ERROR conflicting implementations
|
||||
|
||||
impl !Send for TestType<i32> {}
|
||||
|
||||
fn main() {}
|
22
tests/ui/issues/issue-106755.stderr
Normal file
22
tests/ui/issues/issue-106755.stderr
Normal file
@ -0,0 +1,22 @@
|
||||
error[E0751]: found both positive and negative implementation of trait `Send` for type `TestType<_>`:
|
||||
--> $DIR/issue-106755.rs:13:1
|
||||
|
|
||||
LL | unsafe impl<T: MyTrait + 'static> Send for TestType<T> {}
|
||||
| ------------------------------------------------------ positive implementation here
|
||||
LL |
|
||||
LL | impl<T: MyTrait> !Send for TestType<T> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ negative implementation here
|
||||
|
||||
error[E0119]: conflicting implementations of trait `Send` for type `TestType<_>`
|
||||
--> $DIR/issue-106755.rs:15:1
|
||||
|
|
||||
LL | unsafe impl<T: MyTrait + 'static> Send for TestType<T> {}
|
||||
| ------------------------------------------------------ first implementation here
|
||||
...
|
||||
LL | unsafe impl<T: 'static> Send for TestType<T> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0119, E0751.
|
||||
For more information about an error, try `rustc --explain E0119`.
|
Loading…
x
Reference in New Issue
Block a user