]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_errors/src/emitter.rs
Auto merge of #96441 - ChrisDenton:sync-pipes, r=m-ou-se
[rust.git] / compiler / rustc_errors / src / emitter.rs
index 6a763d4d1404b1e6bc6183a4645c3b6bbf40f5dc..5dd743e8d00236b93dfd4e79600a65af700c77ce 100644 (file)
@@ -16,7 +16,8 @@
 use crate::styled_buffer::StyledBuffer;
 use crate::{
     CodeSuggestion, Diagnostic, DiagnosticArg, DiagnosticId, DiagnosticMessage, FluentBundle,
-    Handler, Level, MultiSpan, SubDiagnostic, SubstitutionHighlight, SuggestionStyle,
+    Handler, LazyFallbackBundle, Level, MultiSpan, SubDiagnostic, SubstitutionHighlight,
+    SuggestionStyle,
 };
 
 use rustc_lint_defs::pluralize;
@@ -60,7 +61,7 @@ pub fn new_emitter(
         dst: Box<dyn Write + Send>,
         source_map: Option<Lrc<SourceMap>>,
         bundle: Option<Lrc<FluentBundle>>,
-        fallback_bundle: Lrc<FluentBundle>,
+        fallback_bundle: LazyFallbackBundle,
         teach: bool,
         terminal_width: Option<usize>,
         macro_backtrace: bool,
@@ -211,7 +212,12 @@ fn emit_artifact_notification(&mut self, _path: &Path, _artifact_type: &str) {}
     fn emit_future_breakage_report(&mut self, _diags: Vec<Diagnostic>) {}
 
     /// Emit list of unused externs
-    fn emit_unused_externs(&mut self, _lint_level: &str, _unused_externs: &[&str]) {}
+    fn emit_unused_externs(
+        &mut self,
+        _lint_level: rustc_lint_defs::Level,
+        _unused_externs: &[&str],
+    ) {
+    }
 
     /// Checks if should show explanations about "rustc --explain"
     fn should_show_explain(&self) -> bool {
@@ -233,7 +239,7 @@ fn supports_color(&self) -> bool {
     /// Return `FluentBundle` with localized diagnostics for the default locale of the compiler.
     /// Used when the user has not requested a specific language or when a localized diagnostic is
     /// unavailable for the requested locale.
-    fn fallback_fluent_bundle(&self) -> &Lrc<FluentBundle>;
+    fn fallback_fluent_bundle(&self) -> &FluentBundle;
 
     /// Convert diagnostic arguments (a rustc internal type that exists to implement
     /// `Encodable`/`Decodable`) into `FluentArgs` which is necessary to perform translation.
@@ -579,8 +585,8 @@ fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
         self.fluent_bundle.as_ref()
     }
 
-    fn fallback_fluent_bundle(&self) -> &Lrc<FluentBundle> {
-        &self.fallback_bundle
+    fn fallback_fluent_bundle(&self) -> &FluentBundle {
+        &**self.fallback_bundle
     }
 
     fn emit_diagnostic(&mut self, diag: &Diagnostic) {
@@ -635,7 +641,7 @@ fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
         None
     }
 
-    fn fallback_fluent_bundle(&self) -> &Lrc<FluentBundle> {
+    fn fallback_fluent_bundle(&self) -> &FluentBundle {
         panic!("silent emitter attempted to translate message")
     }
 
@@ -695,7 +701,7 @@ pub struct EmitterWriter {
     dst: Destination,
     sm: Option<Lrc<SourceMap>>,
     fluent_bundle: Option<Lrc<FluentBundle>>,
-    fallback_bundle: Lrc<FluentBundle>,
+    fallback_bundle: LazyFallbackBundle,
     short_message: bool,
     teach: bool,
     ui_testing: bool,
@@ -716,7 +722,7 @@ pub fn stderr(
         color_config: ColorConfig,
         source_map: Option<Lrc<SourceMap>>,
         fluent_bundle: Option<Lrc<FluentBundle>>,
-        fallback_bundle: Lrc<FluentBundle>,
+        fallback_bundle: LazyFallbackBundle,
         short_message: bool,
         teach: bool,
         terminal_width: Option<usize>,
@@ -740,7 +746,7 @@ pub fn new(
         dst: Box<dyn Write + Send>,
         source_map: Option<Lrc<SourceMap>>,
         fluent_bundle: Option<Lrc<FluentBundle>>,
-        fallback_bundle: Lrc<FluentBundle>,
+        fallback_bundle: LazyFallbackBundle,
         short_message: bool,
         teach: bool,
         colored: bool,