@@ -15,10 +15,7 @@ use rustc_data_structures::profiling::{SelfProfilerRef, VerboseTimingGuard};
1515use rustc_data_structures:: sync:: Lrc ;
1616use rustc_errors:: emitter:: Emitter ;
1717use rustc_errors:: translation:: Translate ;
18- use rustc_errors:: {
19- DiagCtxt , DiagnosticArgName , DiagnosticArgValue , DiagnosticBuilder , DiagnosticMessage , ErrCode ,
20- FatalError , FluentBundle , Level , Style ,
21- } ;
18+ use rustc_errors:: { DiagCtxt , Diagnostic , DiagnosticBuilder , FatalError , FluentBundle , Level } ;
2219use rustc_fs_util:: link_or_copy;
2320use rustc_hir:: def_id:: { CrateNum , LOCAL_CRATE } ;
2421use rustc_incremental:: {
@@ -39,7 +36,6 @@ use rustc_target::spec::{MergeFunctions, SanitizerSet};
3936
4037use crate :: errors:: ErrorCreatingRemarkDir ;
4138use std:: any:: Any ;
42- use std:: borrow:: Cow ;
4339use std:: fs;
4440use std:: io;
4541use std:: marker:: PhantomData ;
@@ -998,13 +994,6 @@ pub(crate) enum Message<B: WriteBackendMethods> {
998994/// process another codegen unit.
999995pub struct CguMessage ;
1000996
1001- struct Diagnostic {
1002- msgs : Vec < ( DiagnosticMessage , Style ) > ,
1003- args : FxHashMap < DiagnosticArgName , DiagnosticArgValue > ,
1004- code : Option < ErrCode > ,
1005- lvl : Level ,
1006- }
1007-
1008997#[ derive( PartialEq , Clone , Copy , Debug ) ]
1009998enum MainThreadState {
1010999 /// Doing nothing.
@@ -1765,7 +1754,6 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
17651754enum SharedEmitterMessage {
17661755 Diagnostic ( Diagnostic ) ,
17671756 InlineAsmError ( u32 , String , Level , Option < ( String , Vec < InnerSpan > ) > ) ,
1768- AbortIfErrors ,
17691757 Fatal ( String ) ,
17701758}
17711759
@@ -1811,24 +1799,8 @@ impl Translate for SharedEmitter {
18111799}
18121800
18131801impl Emitter for SharedEmitter {
1814- fn emit_diagnostic ( & mut self , diag : & rustc_errors:: Diagnostic ) {
1815- let args: FxHashMap < Cow < ' _ , str > , DiagnosticArgValue > =
1816- diag. args ( ) . map ( |( name, arg) | ( name. clone ( ) , arg. clone ( ) ) ) . collect ( ) ;
1817- drop ( self . sender . send ( SharedEmitterMessage :: Diagnostic ( Diagnostic {
1818- msgs : diag. messages . clone ( ) ,
1819- args : args. clone ( ) ,
1820- code : diag. code . clone ( ) ,
1821- lvl : diag. level ( ) ,
1822- } ) ) ) ;
1823- for child in & diag. children {
1824- drop ( self . sender . send ( SharedEmitterMessage :: Diagnostic ( Diagnostic {
1825- msgs : child. messages . clone ( ) ,
1826- args : args. clone ( ) ,
1827- code : None ,
1828- lvl : child. level ,
1829- } ) ) ) ;
1830- }
1831- drop ( self . sender . send ( SharedEmitterMessage :: AbortIfErrors ) ) ;
1802+ fn emit_diagnostic ( & mut self , diag : rustc_errors:: Diagnostic ) {
1803+ drop ( self . sender . send ( SharedEmitterMessage :: Diagnostic ( diag) ) ) ;
18321804 }
18331805
18341806 fn source_map ( & self ) -> Option < & Lrc < SourceMap > > {
@@ -1853,13 +1825,8 @@ impl SharedEmitterMain {
18531825
18541826 match message {
18551827 Ok ( SharedEmitterMessage :: Diagnostic ( diag) ) => {
1856- let dcx = sess. dcx ( ) ;
1857- let mut d = rustc_errors:: Diagnostic :: new_with_messages ( diag. lvl , diag. msgs ) ;
1858- if let Some ( code) = diag. code {
1859- d. code ( code) ;
1860- }
1861- d. replace_args ( diag. args ) ;
1862- dcx. emit_diagnostic ( d) ;
1828+ sess. dcx ( ) . emit_diagnostic ( diag) ;
1829+ sess. dcx ( ) . abort_if_errors ( ) ;
18631830 }
18641831 Ok ( SharedEmitterMessage :: InlineAsmError ( cookie, msg, level, source) ) => {
18651832 assert ! ( matches!( level, Level :: Error | Level :: Warning | Level :: Note ) ) ;
@@ -1892,9 +1859,6 @@ impl SharedEmitterMain {
18921859
18931860 err. emit ( ) ;
18941861 }
1895- Ok ( SharedEmitterMessage :: AbortIfErrors ) => {
1896- sess. dcx ( ) . abort_if_errors ( ) ;
1897- }
18981862 Ok ( SharedEmitterMessage :: Fatal ( msg) ) => {
18991863 sess. dcx ( ) . fatal ( msg) ;
19001864 }
0 commit comments