Skip to content

Commit

Permalink
Auto merge of rust-lang#95968 - davidtwco:translation-lazy-fallback, …
Browse files Browse the repository at this point in the history
…r=oli-obk

errors: lazily load fallback fluent bundle

Addresses (hopefully) rust-lang#95667 (comment).

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)
  • Loading branch information
bors committed Apr 13, 2022
2 parents 27634b0 + 5b7df24 commit a377ebc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions clippy_lints/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a377ebc

Please sign in to comment.