about summary refs log tree commit diff
path: root/src/parse
diff options
context:
space:
mode:
authorDavid Wood <david.wood@huawei.com>2022-04-12 09:34:40 +0100
committerDavid Wood <david.wood@huawei.com>2022-04-13 02:44:59 +0100
commit0cf62ae103422c96000c10ebcc3ec76028647b1e (patch)
treefe83b2c2a28bfbc7f0c1a24bb1ce3887aa5cc638 /src/parse
parentb482bee00cc35017da249e2f6e26ea7e68ab8d92 (diff)
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>
Diffstat (limited to 'src/parse')
-rw-r--r--src/parse/session.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/parse/session.rs b/src/parse/session.rs
index 7125b2ee685..4408e20747a 100644
--- a/src/parse/session.rs
+++ b/src/parse/session.rs
@@ -36,7 +36,7 @@ impl Emitter for SilentEmitter {
     fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
         None
     }
-    fn fallback_fluent_bundle(&self) -> &Lrc<rustc_errors::FluentBundle> {
+    fn fallback_fluent_bundle(&self) -> &rustc_errors::FluentBundle {
         panic!("silent emitter attempted to translate a diagnostic");
     }
 }
@@ -93,7 +93,7 @@ impl Emitter for SilentOnIgnoredFilesEmitter {
         self.emitter.fluent_bundle()
     }
 
-    fn fallback_fluent_bundle(&self) -> &Lrc<rustc_errors::FluentBundle> {
+    fn fallback_fluent_bundle(&self) -> &rustc_errors::FluentBundle {
         self.emitter.fallback_fluent_bundle()
     }
 }
@@ -114,8 +114,8 @@ fn default_handler(
     let emitter = if hide_parse_errors {
         silent_emitter()
     } else {
-        let fallback_bundle = rustc_errors::fallback_fluent_bundle(false)
-            .expect("failed to load fallback fluent bundle");
+        let fallback_bundle =
+            rustc_errors::fallback_fluent_bundle(rustc_errors::DEFAULT_LOCALE_RESOURCES, false);
         Box::new(EmitterWriter::stderr(
             color_cfg,
             Some(source_map.clone()),
@@ -350,7 +350,7 @@ mod tests {
             fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
                 None
             }
-            fn fallback_fluent_bundle(&self) -> &Lrc<rustc_errors::FluentBundle> {
+            fn fallback_fluent_bundle(&self) -> &rustc_errors::FluentBundle {
                 panic!("test emitter attempted to translate a diagnostic");
             }
         }