diff options
| -rw-r--r-- | compiler/rustc_driver/src/lib.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_error_messages/src/lib.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/json/tests.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_expand/src/tests.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_session/src/options.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_session/src/parse.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 8 | ||||
| -rw-r--r-- | src/librustdoc/core.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/doctest.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/passes/check_code_block_syntax.rs | 4 | ||||
| -rw-r--r-- | src/tools/clippy/clippy_lints/src/doc.rs | 2 | ||||
| -rw-r--r-- | src/tools/clippy/src/driver.rs | 2 | ||||
| -rw-r--r-- | src/tools/rustfmt/src/parse/session.rs | 2 |
13 files changed, 27 insertions, 18 deletions
diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index 7fa3c1d17b0..febdd0ed746 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -1173,7 +1173,7 @@ static DEFAULT_HOOK: SyncLazy<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + /// hook. pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { let fallback_bundle = - rustc_errors::fallback_fluent_bundle().expect("failed to load fallback fluent bundle"); + rustc_errors::fallback_fluent_bundle(false).expect("failed to load fallback fluent bundle"); let emitter = Box::new(rustc_errors::emitter::EmitterWriter::stderr( rustc_errors::ColorConfig::Auto, None, diff --git a/compiler/rustc_error_messages/src/lib.rs b/compiler/rustc_error_messages/src/lib.rs index ceead29f51a..508d419cdb6 100644 --- a/compiler/rustc_error_messages/src/lib.rs +++ b/compiler/rustc_error_messages/src/lib.rs @@ -101,6 +101,7 @@ pub fn fluent_bundle( sysroot: &Path, requested_locale: Option<LanguageIdentifier>, additional_ftl_path: Option<&Path>, + with_directionality_markers: bool, ) -> Result<Option<Lrc<FluentBundle>>, TranslationBundleError> { if requested_locale.is_none() && additional_ftl_path.is_none() { return Ok(None); @@ -120,7 +121,7 @@ pub fn fluent_bundle( // vice-versa). These are disabled because they are sometimes visible in the error output, but // may be worth investigating in future (for example: if type names are left-to-right and the // surrounding diagnostic messages are right-to-left, then these might be helpful). - bundle.set_use_isolating(false); + 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 { @@ -169,13 +170,15 @@ pub fn fluent_bundle( /// Return the default `FluentBundle` with standard "en-US" diagnostic messages. #[instrument(level = "trace")] -pub fn fallback_fluent_bundle() -> Result<Lrc<FluentBundle>, TranslationBundleError> { +pub fn fallback_fluent_bundle( + with_directionality_markers: bool, +) -> Result<Lrc<FluentBundle>, TranslationBundleError> { let fallback_resource = FluentResource::try_new(FALLBACK_FLUENT_RESOURCE.to_string()) .map_err(TranslationBundleError::from)?; trace!(?fallback_resource); let mut fallback_bundle = FluentBundle::new(vec![langid!("en-US")]); // See comment in `fluent_bundle`. - fallback_bundle.set_use_isolating(false); + fallback_bundle.set_use_isolating(with_directionality_markers); fallback_bundle.add_resource(fallback_resource).map_err(TranslationBundleError::from)?; let fallback_bundle = Lrc::new(fallback_bundle); Ok(fallback_bundle) diff --git a/compiler/rustc_errors/src/json/tests.rs b/compiler/rustc_errors/src/json/tests.rs index 4174a85204f..0f175c732c1 100644 --- a/compiler/rustc_errors/src/json/tests.rs +++ b/compiler/rustc_errors/src/json/tests.rs @@ -40,7 +40,7 @@ fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) { let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); sm.new_source_file(Path::new("test.rs").to_owned().into(), code.to_owned()); let fallback_bundle = - crate::fallback_fluent_bundle().expect("failed to load fallback fluent bundle"); + crate::fallback_fluent_bundle(false).expect("failed to load fallback fluent bundle"); let output = Arc::new(Mutex::new(Vec::new())); let je = JsonEmitter::new( diff --git a/compiler/rustc_expand/src/tests.rs b/compiler/rustc_expand/src/tests.rs index 406095ab5e0..88f3cf9d722 100644 --- a/compiler/rustc_expand/src/tests.rs +++ b/compiler/rustc_expand/src/tests.rs @@ -127,8 +127,8 @@ fn test_harness(file_text: &str, span_labels: Vec<SpanLabel>, expected_output: & create_default_session_if_not_set_then(|_| { let output = Arc::new(Mutex::new(Vec::new())); - let fallback_bundle = - rustc_errors::fallback_fluent_bundle().expect("failed to load fallback fluent bundle"); + let fallback_bundle = rustc_errors::fallback_fluent_bundle(false) + .expect("failed to load fallback fluent bundle"); let source_map = Lrc::new(SourceMap::new(FilePathMapping::empty())); source_map.new_source_file(Path::new("test.rs").to_owned().into(), file_text.to_owned()); diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 7303d701ae1..4994f8eaeb2 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1482,6 +1482,8 @@ options! { "language identifier for diagnostic output"), translate_additional_ftl: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED], "additional fluent translation to preferentially use (for testing translation)"), + translate_directionality_markers: bool = (false, parse_bool, [TRACKED], + "emit directionality isolation markers in translated diagnostics"), tune_cpu: Option<String> = (None, parse_opt_string, [TRACKED], "select processor to schedule for (`rustc --print target-cpus` for details)"), thinlto: Option<bool> = (None, parse_opt_bool, [TRACKED], diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index 6b99e011c45..0b9c27c2cd6 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -175,7 +175,7 @@ impl ParseSess { /// Used for testing. pub fn new(file_path_mapping: FilePathMapping) -> Self { let fallback_bundle = - fallback_fluent_bundle().expect("failed to load fallback fluent bundle"); + fallback_fluent_bundle(false).expect("failed to load fallback fluent bundle"); let sm = Lrc::new(SourceMap::new(file_path_mapping)); let handler = Handler::with_tty_emitter( ColorConfig::Auto, @@ -214,7 +214,7 @@ impl ParseSess { pub fn with_silent_emitter(fatal_note: Option<String>) -> Self { let fallback_bundle = - fallback_fluent_bundle().expect("failed to load fallback fluent bundle"); + fallback_fluent_bundle(false).expect("failed to load fallback fluent bundle"); let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let fatal_handler = Handler::with_tty_emitter(ColorConfig::Auto, false, None, None, None, fallback_bundle); diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 74c0f67e633..9881046ddfa 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -1218,9 +1218,12 @@ pub fn build_session( &sysroot, sopts.debugging_opts.translate_lang.clone(), sopts.debugging_opts.translate_additional_ftl.as_deref(), + sopts.debugging_opts.translate_directionality_markers, ) .expect("failed to load fluent bundle"); - let fallback_bundle = fallback_fluent_bundle().expect("failed to load fallback fluent bundle"); + let fallback_bundle = + fallback_fluent_bundle(sopts.debugging_opts.translate_directionality_markers) + .expect("failed to load fallback fluent bundle"); let emitter = default_emitter(&sopts, registry, source_map.clone(), bundle, fallback_bundle, write_dest); @@ -1455,7 +1458,8 @@ pub enum IncrCompSession { } fn early_error_handler(output: config::ErrorOutputType) -> rustc_errors::Handler { - let fallback_bundle = fallback_fluent_bundle().expect("failed to load fallback fluent bundle"); + let fallback_bundle = + fallback_fluent_bundle(false).expect("failed to load fallback fluent bundle"); let emitter: Box<dyn Emitter + sync::Send> = match output { config::ErrorOutputType::HumanReadable(kind) => { let (short, color_config) = kind.unzip(); diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 7cd799d84f0..a32b9caa30f 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -144,7 +144,7 @@ crate fn new_handler( debugging_opts: &DebuggingOptions, ) -> rustc_errors::Handler { let fallback_bundle = - rustc_errors::fallback_fluent_bundle().expect("failed to load fallback fluent bundle"); + rustc_errors::fallback_fluent_bundle(false).expect("failed to load fallback fluent bundle"); let emitter: Box<dyn Emitter + sync::Send> = match error_format { ErrorOutputType::HumanReadable(kind) => { let (short, color_config) = kind.unzip(); diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 94e3c996400..63b744133a2 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -537,7 +537,7 @@ crate fn make_test( // Any errors in parsing should also appear when the doctest is compiled for real, so just // send all the errors that librustc_ast emits directly into a `Sink` instead of stderr. let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); - let fallback_bundle = rustc_errors::fallback_fluent_bundle() + let fallback_bundle = rustc_errors::fallback_fluent_bundle(false) .expect("failed to load fallback fluent bundle"); supports_color = EmitterWriter::stderr( ColorConfig::Auto, diff --git a/src/librustdoc/passes/check_code_block_syntax.rs b/src/librustdoc/passes/check_code_block_syntax.rs index 01bfc522e1b..465dd523ff4 100644 --- a/src/librustdoc/passes/check_code_block_syntax.rs +++ b/src/librustdoc/passes/check_code_block_syntax.rs @@ -32,8 +32,8 @@ struct SyntaxChecker<'a, 'tcx> { impl<'a, 'tcx> SyntaxChecker<'a, 'tcx> { fn check_rust_syntax(&self, item: &clean::Item, dox: &str, code_block: RustCodeBlock) { let buffer = Lrc::new(Lock::new(Buffer::default())); - let fallback_bundle = - rustc_errors::fallback_fluent_bundle().expect("failed to load fallback fluent bundle"); + let fallback_bundle = rustc_errors::fallback_fluent_bundle(false) + .expect("failed to load fallback fluent bundle"); let emitter = BufferEmitter { buffer: Lrc::clone(&buffer), fallback_bundle }; let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); diff --git a/src/tools/clippy/clippy_lints/src/doc.rs b/src/tools/clippy/clippy_lints/src/doc.rs index e08e9e49993..92cf82bcd6a 100644 --- a/src/tools/clippy/clippy_lints/src/doc.rs +++ b/src/tools/clippy/clippy_lints/src/doc.rs @@ -621,7 +621,7 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) { let filename = FileName::anon_source_code(&code); let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); - let fallback_bundle = rustc_errors::fallback_fluent_bundle() + let fallback_bundle = rustc_errors::fallback_fluent_bundle(false) .expect("failed to load fallback fluent bundle"); let emitter = EmitterWriter::new( Box::new(io::sink()), diff --git a/src/tools/clippy/src/driver.rs b/src/tools/clippy/src/driver.rs index f04535b2bea..bc1b0d74575 100644 --- a/src/tools/clippy/src/driver.rs +++ b/src/tools/clippy/src/driver.rs @@ -165,7 +165,7 @@ fn report_clippy_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { // Separate the output with an empty line eprintln!(); - let fallback_bundle = rustc_errors::fallback_fluent_bundle() + let fallback_bundle = rustc_errors::fallback_fluent_bundle(false) .expect("failed to load fallback fluent bundle"); let emitter = Box::new(rustc_errors::emitter::EmitterWriter::stderr( rustc_errors::ColorConfig::Auto, diff --git a/src/tools/rustfmt/src/parse/session.rs b/src/tools/rustfmt/src/parse/session.rs index 6967028d55f..7125b2ee685 100644 --- a/src/tools/rustfmt/src/parse/session.rs +++ b/src/tools/rustfmt/src/parse/session.rs @@ -114,7 +114,7 @@ fn default_handler( let emitter = if hide_parse_errors { silent_emitter() } else { - let fallback_bundle = rustc_errors::fallback_fluent_bundle() + let fallback_bundle = rustc_errors::fallback_fluent_bundle(false) .expect("failed to load fallback fluent bundle"); Box::new(EmitterWriter::stderr( color_cfg, |
