@@ -15,10 +15,8 @@ use rustc_data_structures::profiling::TimingGuard;
15
15
use rustc_data_structures:: profiling:: VerboseTimingGuard ;
16
16
use rustc_data_structures:: sync:: Lrc ;
17
17
use 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 } ;
22
20
use rustc_fs_util:: link_or_copy;
23
21
use rustc_hir:: def_id:: { CrateNum , LOCAL_CRATE } ;
24
22
use rustc_incremental:: {
@@ -38,6 +36,7 @@ use rustc_span::{BytePos, FileName, InnerSpan, Pos, Span};
38
36
use rustc_target:: spec:: { MergeFunctions , SanitizerSet } ;
39
37
40
38
use std:: any:: Any ;
39
+ use std:: borrow:: Cow ;
41
40
use std:: fs;
42
41
use std:: io;
43
42
use std:: marker:: PhantomData ;
@@ -969,8 +968,11 @@ pub enum Message<B: WriteBackendMethods> {
969
968
CodegenAborted ,
970
969
}
971
970
971
+ type DiagnosticArgName < ' source > = Cow < ' source , str > ;
972
+
972
973
struct Diagnostic {
973
- msg : String ,
974
+ msg : Vec < ( DiagnosticMessage , Style ) > ,
975
+ args : FxHashMap < DiagnosticArgName < ' static > , rustc_errors:: DiagnosticArgValue < ' static > > ,
974
976
code : Option < DiagnosticId > ,
975
977
lvl : Level ,
976
978
}
@@ -1743,15 +1745,18 @@ impl Translate for SharedEmitter {
1743
1745
1744
1746
impl Emitter for SharedEmitter {
1745
1747
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 ( ) ;
1747
1750
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 ( ) ,
1749
1753
code : diag. code . clone ( ) ,
1750
1754
lvl : diag. level ( ) ,
1751
1755
} ) ) ) ;
1752
1756
for child in & diag. children {
1753
1757
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 ( ) ,
1755
1760
code : None ,
1756
1761
lvl : child. level ,
1757
1762
} ) ) ) ;
@@ -1782,10 +1787,14 @@ impl SharedEmitterMain {
1782
1787
match message {
1783
1788
Ok ( SharedEmitterMessage :: Diagnostic ( diag) ) => {
1784
1789
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 ;
1786
1792
if let Some ( code) = diag. code {
1787
1793
d. code ( code) ;
1788
1794
}
1795
+ for ( name, arg) in diag. args {
1796
+ d. set_arg ( name, arg) ;
1797
+ }
1789
1798
handler. emit_diagnostic ( & mut d) ;
1790
1799
}
1791
1800
Ok ( SharedEmitterMessage :: InlineAsmError ( cookie, msg, level, source) ) => {
0 commit comments