@@ -15,10 +15,8 @@ use rustc_data_structures::profiling::TimingGuard;
1515use rustc_data_structures:: profiling:: VerboseTimingGuard ;
1616use rustc_data_structures:: sync:: Lrc ;
1717use rustc_errors:: emitter:: Emitter ;
18- use rustc_errors:: {
19- translation:: { to_fluent_args, Translate } ,
20- DiagnosticId , FatalError , Handler , Level ,
21- } ;
18+ use rustc_errors:: { translation:: Translate , DiagnosticId , FatalError , Handler , Level } ;
19+ use rustc_errors:: { DiagnosticMessage , Style } ;
2220use rustc_fs_util:: link_or_copy;
2321use rustc_hir:: def_id:: { CrateNum , LOCAL_CRATE } ;
2422use rustc_incremental:: {
@@ -38,6 +36,7 @@ use rustc_span::{BytePos, FileName, InnerSpan, Pos, Span};
3836use rustc_target:: spec:: { MergeFunctions , SanitizerSet } ;
3937
4038use std:: any:: Any ;
39+ use std:: borrow:: Cow ;
4140use std:: fs;
4241use std:: io;
4342use std:: marker:: PhantomData ;
@@ -969,8 +968,11 @@ pub enum Message<B: WriteBackendMethods> {
969968 CodegenAborted ,
970969}
971970
971+ type DiagnosticArgName < ' source > = Cow < ' source , str > ;
972+
972973struct Diagnostic {
973- msg : String ,
974+ msg : Vec < ( DiagnosticMessage , Style ) > ,
975+ args : FxHashMap < DiagnosticArgName < ' static > , rustc_errors:: DiagnosticArgValue < ' static > > ,
974976 code : Option < DiagnosticId > ,
975977 lvl : Level ,
976978}
@@ -1743,15 +1745,18 @@ impl Translate for SharedEmitter {
17431745
17441746impl Emitter for SharedEmitter {
17451747 fn emit_diagnostic ( & mut self , diag : & rustc_errors:: Diagnostic ) {
1746- let fluent_args = to_fluent_args ( diag. args ( ) ) ;
1748+ let args: FxHashMap < Cow < ' _ , str > , rustc_errors:: DiagnosticArgValue < ' _ > > =
1749+ diag. args ( ) . map ( |( name, arg) | ( name. clone ( ) , arg. clone ( ) ) ) . collect ( ) ;
17471750 drop ( self . sender . send ( SharedEmitterMessage :: Diagnostic ( Diagnostic {
1748- msg : self . translate_messages ( & diag. message , & fluent_args) . to_string ( ) ,
1751+ msg : diag. message . clone ( ) ,
1752+ args : args. clone ( ) ,
17491753 code : diag. code . clone ( ) ,
17501754 lvl : diag. level ( ) ,
17511755 } ) ) ) ;
17521756 for child in & diag. children {
17531757 drop ( self . sender . send ( SharedEmitterMessage :: Diagnostic ( Diagnostic {
1754- msg : self . translate_messages ( & child. message , & fluent_args) . to_string ( ) ,
1758+ msg : child. message . clone ( ) ,
1759+ args : args. clone ( ) ,
17551760 code : None ,
17561761 lvl : child. level ,
17571762 } ) ) ) ;
@@ -1782,10 +1787,14 @@ impl SharedEmitterMain {
17821787 match message {
17831788 Ok ( SharedEmitterMessage :: Diagnostic ( diag) ) => {
17841789 let handler = sess. diagnostic ( ) ;
1785- let mut d = rustc_errors:: Diagnostic :: new ( diag. lvl , & diag. msg ) ;
1790+ let mut d = rustc_errors:: Diagnostic :: new ( diag. lvl , String :: new ( ) ) ;
1791+ d. message = diag. msg ;
17861792 if let Some ( code) = diag. code {
17871793 d. code ( code) ;
17881794 }
1795+ for ( name, arg) in diag. args {
1796+ d. set_arg ( name, arg) ;
1797+ }
17891798 handler. emit_diagnostic ( & mut d) ;
17901799 }
17911800 Ok ( SharedEmitterMessage :: InlineAsmError ( cookie, msg, level, source) ) => {
0 commit comments