diff options
| author | David Wood <david.wood@huawei.com> | 2022-04-03 04:53:01 +0100 |
|---|---|---|
| committer | David Wood <david.wood@huawei.com> | 2022-04-05 07:01:03 +0100 |
| commit | 3c2f864ffbf0e3d01f3f684acbd0ee602619bf19 (patch) | |
| tree | 9a4bd3d308bf6a718e86e31784f1eddb738b8693 /compiler/rustc_error_messages/src | |
| parent | e27389b068a3b71c87cf81828d1d878d24a3b867 (diff) | |
| download | rust-3c2f864ffbf0e3d01f3f684acbd0ee602619bf19.tar.gz rust-3c2f864ffbf0e3d01f3f684acbd0ee602619bf19.zip | |
session: opt for enabling directionality markers
Add an option for enabling and disabling Fluent's directionality isolation markers in output. Disabled by default as these can render in some terminals and applications. Signed-off-by: David Wood <david.wood@huawei.com>
Diffstat (limited to 'compiler/rustc_error_messages/src')
| -rw-r--r-- | compiler/rustc_error_messages/src/lib.rs | 9 |
1 files changed, 6 insertions, 3 deletions
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) |
