@@ -4,7 +4,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
4
4
use rustc_data_structures:: sync:: { IntoDynSyncSend , Lrc } ;
5
5
use rustc_errors:: emitter:: { DynEmitter , Emitter , EmitterWriter } ;
6
6
use rustc_errors:: translation:: Translate ;
7
- use rustc_errors:: { ColorConfig , Diagnostic , Handler , Level as DiagnosticLevel } ;
7
+ use rustc_errors:: { ColorConfig , DiagCtxt , Diagnostic , Level as DiagnosticLevel } ;
8
8
use rustc_session:: parse:: ParseSess as RawParseSess ;
9
9
use rustc_span:: {
10
10
source_map:: { FilePathMapping , SourceMap } ,
@@ -118,13 +118,13 @@ impl From<Color> for ColorConfig {
118
118
}
119
119
}
120
120
121
- fn default_handler (
121
+ fn default_dcx (
122
122
source_map : Lrc < SourceMap > ,
123
123
ignore_path_set : Lrc < IgnorePathSet > ,
124
124
can_reset : Lrc < AtomicBool > ,
125
125
show_parse_errors : bool ,
126
126
color : Color ,
127
- ) -> Handler {
127
+ ) -> DiagCtxt {
128
128
let supports_color = term:: stderr ( ) . map_or ( false , |term| term. supports_color ( ) ) ;
129
129
let emit_color = if supports_color {
130
130
ColorConfig :: from ( color)
@@ -141,7 +141,7 @@ fn default_handler(
141
141
) ;
142
142
Box :: new ( EmitterWriter :: stderr ( emit_color, fallback_bundle) . sm ( Some ( source_map. clone ( ) ) ) )
143
143
} ;
144
- Handler :: with_emitter ( Box :: new ( SilentOnIgnoredFilesEmitter {
144
+ DiagCtxt :: with_emitter ( Box :: new ( SilentOnIgnoredFilesEmitter {
145
145
has_non_ignorable_parser_errors : false ,
146
146
source_map,
147
147
emitter,
@@ -159,14 +159,14 @@ impl ParseSess {
159
159
let source_map = Lrc :: new ( SourceMap :: new ( FilePathMapping :: empty ( ) ) ) ;
160
160
let can_reset_errors = Lrc :: new ( AtomicBool :: new ( false ) ) ;
161
161
162
- let handler = default_handler (
162
+ let dcx = default_dcx (
163
163
Lrc :: clone ( & source_map) ,
164
164
Lrc :: clone ( & ignore_path_set) ,
165
165
Lrc :: clone ( & can_reset_errors) ,
166
166
config. show_parse_errors ( ) ,
167
167
config. color ( ) ,
168
168
) ;
169
- let parse_sess = RawParseSess :: with_span_handler ( handler , source_map) ;
169
+ let parse_sess = RawParseSess :: with_dcx ( dcx , source_map) ;
170
170
171
171
Ok ( ParseSess {
172
172
parse_sess,
@@ -218,7 +218,7 @@ impl ParseSess {
218
218
}
219
219
220
220
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 ( ) ) ;
222
222
}
223
223
224
224
pub ( crate ) fn span_to_filename ( & self , span : Span ) -> FileName {
@@ -284,10 +284,8 @@ impl ParseSess {
284
284
// Methods that should be restricted within the parse module.
285
285
impl ParseSess {
286
286
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) ;
291
289
}
292
290
}
293
291
@@ -296,11 +294,11 @@ impl ParseSess {
296
294
}
297
295
298
296
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 ( )
300
298
}
301
299
302
300
pub ( super ) fn reset_errors ( & self ) {
303
- self . parse_sess . span_diagnostic . reset_err_count ( ) ;
301
+ self . parse_sess . dcx . reset_err_count ( ) ;
304
302
}
305
303
}
306
304
@@ -372,7 +370,7 @@ mod tests {
372
370
373
371
fn build_diagnostic ( level : DiagnosticLevel , span : Option < MultiSpan > ) -> Diagnostic {
374
372
let mut diag = Diagnostic :: new ( level, "" ) ;
375
- diag. message . clear ( ) ;
373
+ diag. messages . clear ( ) ;
376
374
if let Some ( span) = span {
377
375
diag. span = span;
378
376
}
0 commit comments