Skip to content

Commit 5b7df24

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 62d912e commit 5b7df24

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

clippy_lints/src/doc.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,10 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) {
621621
let filename = FileName::anon_source_code(&code);
622622

623623
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
624-
let fallback_bundle =
625-
rustc_errors::fallback_fluent_bundle(false).expect("failed to load fallback fluent bundle");
624+
let fallback_bundle = rustc_errors::fallback_fluent_bundle(
625+
rustc_errors::DEFAULT_LOCALE_RESOURCES,
626+
false
627+
);
626628
let emitter = EmitterWriter::new(
627629
Box::new(io::sink()),
628630
None,

src/driver.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ fn report_clippy_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
165165
// Separate the output with an empty line
166166
eprintln!();
167167

168-
let fallback_bundle = rustc_errors::fallback_fluent_bundle(false).expect("failed to load fallback fluent bundle");
168+
let fallback_bundle =
169+
rustc_errors::fallback_fluent_bundle(rustc_errors::DEFAULT_LOCALE_RESOURCES, false);
169170
let emitter = Box::new(rustc_errors::emitter::EmitterWriter::stderr(
170171
rustc_errors::ColorConfig::Auto,
171172
None,

0 commit comments

Comments
 (0)