1
Fork 0

errors: lazily load fallback fluent bundle

Loading the fallback bundle in compilation sessions that won't go on to
emit any errors unnecessarily degrades compile time performance, so
lazily create the Fluent bundle when it is first required.

Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
David Wood 2022-04-12 09:34:40 +01:00
parent f6cef572d6
commit 9bfe0e39e4
19 changed files with 94 additions and 81 deletions

View file

@ -33,7 +33,7 @@ use rustc_data_structures::sync::{self, Lock, Lrc};
use rustc_data_structures::AtomicRef;
pub use rustc_error_messages::{
fallback_fluent_bundle, fluent_bundle, DiagnosticMessage, FluentBundle, LanguageIdentifier,
MultiSpan, SpanLabel,
LazyFallbackBundle, MultiSpan, SpanLabel, DEFAULT_LOCALE_RESOURCES,
};
pub use rustc_lint_defs::{pluralize, Applicability};
use rustc_serialize::json::Json;
@ -547,7 +547,7 @@ impl Handler {
treat_err_as_bug: Option<NonZeroUsize>,
sm: Option<Lrc<SourceMap>>,
fluent_bundle: Option<Lrc<FluentBundle>>,
fallback_bundle: Lrc<FluentBundle>,
fallback_bundle: LazyFallbackBundle,
) -> Self {
Self::with_tty_emitter_and_flags(
color_config,
@ -562,7 +562,7 @@ impl Handler {
color_config: ColorConfig,
sm: Option<Lrc<SourceMap>>,
fluent_bundle: Option<Lrc<FluentBundle>>,
fallback_bundle: Lrc<FluentBundle>,
fallback_bundle: LazyFallbackBundle,
flags: HandlerFlags,
) -> Self {
let emitter = Box::new(EmitterWriter::stderr(