@@ -4,7 +4,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
44use rustc_data_structures:: sync:: { IntoDynSyncSend , Lrc } ;
55use rustc_errors:: emitter:: { DynEmitter , Emitter , EmitterWriter } ;
66use rustc_errors:: translation:: Translate ;
7- use rustc_errors:: { ColorConfig , Diagnostic , Handler , Level as DiagnosticLevel } ;
7+ use rustc_errors:: { ColorConfig , DiagCtxt , Diagnostic , Level as DiagnosticLevel } ;
88use rustc_session:: parse:: ParseSess as RawParseSess ;
99use rustc_span:: {
1010 source_map:: { FilePathMapping , SourceMap } ,
@@ -118,13 +118,13 @@ impl From<Color> for ColorConfig {
118118 }
119119}
120120
121- fn default_handler (
121+ fn default_dcx (
122122 source_map : Lrc < SourceMap > ,
123123 ignore_path_set : Lrc < IgnorePathSet > ,
124124 can_reset : Lrc < AtomicBool > ,
125125 show_parse_errors : bool ,
126126 color : Color ,
127- ) -> Handler {
127+ ) -> DiagCtxt {
128128 let supports_color = term:: stderr ( ) . map_or ( false , |term| term. supports_color ( ) ) ;
129129 let emit_color = if supports_color {
130130 ColorConfig :: from ( color)
@@ -141,7 +141,7 @@ fn default_handler(
141141 ) ;
142142 Box :: new ( EmitterWriter :: stderr ( emit_color, fallback_bundle) . sm ( Some ( source_map. clone ( ) ) ) )
143143 } ;
144- Handler :: with_emitter ( Box :: new ( SilentOnIgnoredFilesEmitter {
144+ DiagCtxt :: with_emitter ( Box :: new ( SilentOnIgnoredFilesEmitter {
145145 has_non_ignorable_parser_errors : false ,
146146 source_map,
147147 emitter,
@@ -159,14 +159,14 @@ impl ParseSess {
159159 let source_map = Lrc :: new ( SourceMap :: new ( FilePathMapping :: empty ( ) ) ) ;
160160 let can_reset_errors = Lrc :: new ( AtomicBool :: new ( false ) ) ;
161161
162- let handler = default_handler (
162+ let dcx = default_dcx (
163163 Lrc :: clone ( & source_map) ,
164164 Lrc :: clone ( & ignore_path_set) ,
165165 Lrc :: clone ( & can_reset_errors) ,
166166 config. show_parse_errors ( ) ,
167167 config. color ( ) ,
168168 ) ;
169- let parse_sess = RawParseSess :: with_span_handler ( handler , source_map) ;
169+ let parse_sess = RawParseSess :: with_dcx ( dcx , source_map) ;
170170
171171 Ok ( ParseSess {
172172 parse_sess,
@@ -218,7 +218,7 @@ impl ParseSess {
218218 }
219219
220220 pub ( crate ) fn set_silent_emitter ( & mut self ) {
221- self . parse_sess . span_diagnostic = Handler :: with_emitter ( silent_emitter ( ) ) ;
221+ self . parse_sess . dcx = DiagCtxt :: with_emitter ( silent_emitter ( ) ) ;
222222 }
223223
224224 pub ( crate ) fn span_to_filename ( & self , span : Span ) -> FileName {
@@ -284,10 +284,8 @@ impl ParseSess {
284284// Methods that should be restricted within the parse module.
285285impl ParseSess {
286286 pub ( super ) fn emit_diagnostics ( & self , diagnostics : Vec < Diagnostic > ) {
287- for mut diagnostic in diagnostics {
288- self . parse_sess
289- . span_diagnostic
290- . emit_diagnostic ( & mut diagnostic) ;
287+ for diagnostic in diagnostics {
288+ self . parse_sess . dcx . emit_diagnostic ( diagnostic) ;
291289 }
292290 }
293291
@@ -296,11 +294,11 @@ impl ParseSess {
296294 }
297295
298296 pub ( super ) fn has_errors ( & self ) -> bool {
299- self . parse_sess . span_diagnostic . has_errors ( ) . is_some ( )
297+ self . parse_sess . dcx . has_errors ( ) . is_some ( )
300298 }
301299
302300 pub ( super ) fn reset_errors ( & self ) {
303- self . parse_sess . span_diagnostic . reset_err_count ( ) ;
301+ self . parse_sess . dcx . reset_err_count ( ) ;
304302 }
305303}
306304
@@ -372,7 +370,7 @@ mod tests {
372370
373371 fn build_diagnostic ( level : DiagnosticLevel , span : Option < MultiSpan > ) -> Diagnostic {
374372 let mut diag = Diagnostic :: new ( level, "" ) ;
375- diag. message . clear ( ) ;
373+ diag. messages . clear ( ) ;
376374 if let Some ( span) = span {
377375 diag. span = span;
378376 }
0 commit comments