]> git.lizzy.rs Git - rust.git/blobdiff - src/librustdoc/passes/check_code_block_syntax.rs
Rollup merge of #102883 - Urgau:fix-stabilization-half_open_range_patterns, r=lcnr
[rust.git] / src / librustdoc / passes / check_code_block_syntax.rs
index 23f87838544df9a4115e46324787aa05925fb54d..2e651b5387419fa2441abbda60e515a66b00e4c1 100644 (file)
@@ -1,8 +1,9 @@
 //! Validates syntax inside Rust code blocks (\`\`\`rust).
 use rustc_data_structures::sync::{Lock, Lrc};
 use rustc_errors::{
-    emitter::Emitter, translation::Translate, Applicability, Diagnostic, Handler,
-    LazyFallbackBundle,
+    emitter::Emitter,
+    translation::{to_fluent_args, Translate},
+    Applicability, Diagnostic, Handler, LazyFallbackBundle,
 };
 use rustc_parse::parse_stream_from_source_str;
 use rustc_session::parse::ParseSess;
@@ -192,8 +193,11 @@ fn fallback_fluent_bundle(&self) -> &rustc_errors::FluentBundle {
 impl Emitter for BufferEmitter {
     fn emit_diagnostic(&mut self, diag: &Diagnostic) {
         let mut buffer = self.buffer.borrow_mut();
-        // FIXME(davidtwco): need to support translation here eventually
-        buffer.messages.push(format!("error from rustc: {}", diag.message[0].0.expect_str()));
+
+        let fluent_args = to_fluent_args(diag.args());
+        let translated_main_message = self.translate_message(&diag.message[0].0, &fluent_args);
+
+        buffer.messages.push(format!("error from rustc: {}", translated_main_message));
         if diag.is_error() {
             buffer.has_errors = true;
         }