@@ -15,10 +15,7 @@ use rustc_data_structures::profiling::{SelfProfilerRef, VerboseTimingGuard};
15
15
use rustc_data_structures:: sync:: Lrc ;
16
16
use rustc_errors:: emitter:: Emitter ;
17
17
use 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 } ;
22
19
use rustc_fs_util:: link_or_copy;
23
20
use rustc_hir:: def_id:: { CrateNum , LOCAL_CRATE } ;
24
21
use rustc_incremental:: {
@@ -39,7 +36,6 @@ use rustc_target::spec::{MergeFunctions, SanitizerSet};
39
36
40
37
use crate :: errors:: ErrorCreatingRemarkDir ;
41
38
use std:: any:: Any ;
42
- use std:: borrow:: Cow ;
43
39
use std:: fs;
44
40
use std:: io;
45
41
use std:: marker:: PhantomData ;
@@ -998,13 +994,6 @@ pub(crate) enum Message<B: WriteBackendMethods> {
998
994
/// process another codegen unit.
999
995
pub struct CguMessage ;
1000
996
1001
- struct Diagnostic {
1002
- msgs : Vec < ( DiagnosticMessage , Style ) > ,
1003
- args : FxHashMap < DiagnosticArgName , DiagnosticArgValue > ,
1004
- code : Option < ErrCode > ,
1005
- lvl : Level ,
1006
- }
1007
-
1008
997
#[ derive( PartialEq , Clone , Copy , Debug ) ]
1009
998
enum MainThreadState {
1010
999
/// Doing nothing.
@@ -1765,7 +1754,6 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
1765
1754
enum SharedEmitterMessage {
1766
1755
Diagnostic ( Diagnostic ) ,
1767
1756
InlineAsmError ( u32 , String , Level , Option < ( String , Vec < InnerSpan > ) > ) ,
1768
- AbortIfErrors ,
1769
1757
Fatal ( String ) ,
1770
1758
}
1771
1759
@@ -1811,24 +1799,8 @@ impl Translate for SharedEmitter {
1811
1799
}
1812
1800
1813
1801
impl 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) ) ) ;
1832
1804
}
1833
1805
1834
1806
fn source_map ( & self ) -> Option < & Lrc < SourceMap > > {
@@ -1853,13 +1825,8 @@ impl SharedEmitterMain {
1853
1825
1854
1826
match message {
1855
1827
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 ( ) ;
1863
1830
}
1864
1831
Ok ( SharedEmitterMessage :: InlineAsmError ( cookie, msg, level, source) ) => {
1865
1832
assert ! ( matches!( level, Level :: Error | Level :: Warning | Level :: Note ) ) ;
@@ -1892,9 +1859,6 @@ impl SharedEmitterMain {
1892
1859
1893
1860
err. emit ( ) ;
1894
1861
}
1895
- Ok ( SharedEmitterMessage :: AbortIfErrors ) => {
1896
- sess. dcx ( ) . abort_if_errors ( ) ;
1897
- }
1898
1862
Ok ( SharedEmitterMessage :: Fatal ( msg) ) => {
1899
1863
sess. dcx ( ) . fatal ( msg) ;
1900
1864
}
0 commit comments