Skip to content

Commit 0cf62ae

Browse files
committed
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 <[email protected]>
1 parent b482bee commit 0cf62ae

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/parse/session.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl Emitter for SilentEmitter {
3636
fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
3737
None
3838
}
39-
fn fallback_fluent_bundle(&self) -> &Lrc<rustc_errors::FluentBundle> {
39+
fn fallback_fluent_bundle(&self) -> &rustc_errors::FluentBundle {
4040
panic!("silent emitter attempted to translate a diagnostic");
4141
}
4242
}
@@ -93,7 +93,7 @@ impl Emitter for SilentOnIgnoredFilesEmitter {
9393
self.emitter.fluent_bundle()
9494
}
9595

96-
fn fallback_fluent_bundle(&self) -> &Lrc<rustc_errors::FluentBundle> {
96+
fn fallback_fluent_bundle(&self) -> &rustc_errors::FluentBundle {
9797
self.emitter.fallback_fluent_bundle()
9898
}
9999
}
@@ -114,8 +114,8 @@ fn default_handler(
114114
let emitter = if hide_parse_errors {
115115
silent_emitter()
116116
} else {
117-
let fallback_bundle = rustc_errors::fallback_fluent_bundle(false)
118-
.expect("failed to load fallback fluent bundle");
117+
let fallback_bundle =
118+
rustc_errors::fallback_fluent_bundle(rustc_errors::DEFAULT_LOCALE_RESOURCES, false);
119119
Box::new(EmitterWriter::stderr(
120120
color_cfg,
121121
Some(source_map.clone()),
@@ -350,7 +350,7 @@ mod tests {
350350
fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
351351
None
352352
}
353-
fn fallback_fluent_bundle(&self) -> &Lrc<rustc_errors::FluentBundle> {
353+
fn fallback_fluent_bundle(&self) -> &rustc_errors::FluentBundle {
354354
panic!("test emitter attempted to translate a diagnostic");
355355
}
356356
}

0 commit comments

Comments
 (0)