about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-04-13 21:04:19 +0000
committerbors <bors@rust-lang.org>2022-04-13 21:04:19 +0000
commita377ebc82e51afbb6ec11f7defe20cec5b2d87a4 (patch)
treedce8274287dc765ceab741f47db15c1dca29c15f
parent27634b03ea78262816ee8b48f8e3538ec32b965b (diff)
parent5b7df246cffdfeeadb95412a0143442a36c08496 (diff)
downloadrust-a377ebc82e51afbb6ec11f7defe20cec5b2d87a4.tar.gz
rust-a377ebc82e51afbb6ec11f7defe20cec5b2d87a4.zip
Auto merge of #95968 - davidtwco:translation-lazy-fallback, r=oli-obk
errors: lazily load fallback fluent bundle

Addresses (hopefully) https://github.com/rust-lang/rust/pull/95667#issuecomment-1094794087.

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.

r? `@ghost` (just for perf initially)
-rw-r--r--clippy_lints/src/doc.rs6
-rw-r--r--src/driver.rs3
2 files changed, 6 insertions, 3 deletions
diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs
index 28d0c75fde6..503cef76775 100644
--- a/clippy_lints/src/doc.rs
+++ b/clippy_lints/src/doc.rs
@@ -621,8 +621,10 @@ 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(false).expect("failed to load fallback fluent bundle");
+                let fallback_bundle = rustc_errors::fallback_fluent_bundle(
+                    rustc_errors::DEFAULT_LOCALE_RESOURCES,
+                    false
+                );
                 let emitter = EmitterWriter::new(
                     Box::new(io::sink()),
                     None,
diff --git a/src/driver.rs b/src/driver.rs
index 00dc916b217..32a09fdb9d9 100644
--- a/src/driver.rs
+++ b/src/driver.rs
@@ -165,7 +165,8 @@ 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(false).expect("failed to load fallback fluent bundle");
+    let fallback_bundle =
+        rustc_errors::fallback_fluent_bundle(rustc_errors::DEFAULT_LOCALE_RESOURCES, false);
     let emitter = Box::new(rustc_errors::emitter::EmitterWriter::stderr(
         rustc_errors::ColorConfig::Auto,
         None,