diff --git a/compiler/rustc_error_messages/src/lib.rs b/compiler/rustc_error_messages/src/lib.rs index 40ed10e716597..010e5f060bf0b 100644 --- a/compiler/rustc_error_messages/src/lib.rs +++ b/compiler/rustc_error_messages/src/lib.rs @@ -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"); diff --git a/compiler/rustc_errors/src/translation.rs b/compiler/rustc_errors/src/translation.rs index 1ac9b8e03c7c3..ed35eb1b6c4ad 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))?, diff --git a/tests/ui/issues/issue-106755.rs b/tests/ui/issues/issue-106755.rs new file mode 100644 index 0000000000000..46ece725fb7c1 --- /dev/null +++ b/tests/ui/issues/issue-106755.rs @@ -0,0 +1,19 @@ +// compile-flags:-Ztranslate-lang=en_US + +#![feature(negative_impls)] +#![feature(marker_trait_attr)] + +#[marker] +trait MyTrait {} + +struct TestType(::std::marker::PhantomData); + +unsafe impl Send for TestType {} + +impl !Send for TestType {} //~ ERROR found both positive and negative implementation + +unsafe impl Send for TestType {} //~ ERROR conflicting implementations + +impl !Send for TestType {} + +fn main() {} diff --git a/tests/ui/issues/issue-106755.stderr b/tests/ui/issues/issue-106755.stderr new file mode 100644 index 0000000000000..543970340620d --- /dev/null +++ b/tests/ui/issues/issue-106755.stderr @@ -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 Send for TestType {} + | ------------------------------------------------------ positive implementation here +LL | +LL | impl !Send for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ negative implementation here + +error[E0119]: conflicting implementations of trait `Send` for type `TestType<_>` + --> $DIR/issue-106755.rs:15:1 + | +LL | unsafe impl Send for TestType {} + | ------------------------------------------------------ first implementation here +... +LL | unsafe impl Send for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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`.