@@ -44,7 +44,6 @@ use rustc_target::spec::{
4444use std:: cell:: { self , RefCell } ;
4545use std:: env;
4646use std:: fmt;
47- use std:: io:: Write ;
4847use std:: ops:: { Div , Mul } ;
4948use std:: path:: { Path , PathBuf } ;
5049use std:: str:: FromStr ;
@@ -1213,11 +1212,10 @@ fn default_emitter(
12131212 source_map : Lrc < SourceMap > ,
12141213 bundle : Option < Lrc < FluentBundle > > ,
12151214 fallback_bundle : LazyFallbackBundle ,
1216- emitter_dest : Option < Box < dyn Write + Send > > ,
12171215) -> Box < dyn Emitter + sync:: Send > {
12181216 let macro_backtrace = sopts. unstable_opts . macro_backtrace ;
1219- match ( sopts. error_format , emitter_dest ) {
1220- ( config:: ErrorOutputType :: HumanReadable ( kind) , dst ) => {
1217+ match sopts. error_format {
1218+ config:: ErrorOutputType :: HumanReadable ( kind) => {
12211219 let ( short, color_config) = kind. unzip ( ) ;
12221220
12231221 if let HumanReadableErrorType :: AnnotateSnippet ( _) = kind {
@@ -1230,33 +1228,20 @@ fn default_emitter(
12301228 ) ;
12311229 Box :: new ( emitter. ui_testing ( sopts. unstable_opts . ui_testing ) )
12321230 } else {
1233- let emitter = match dst {
1234- None => EmitterWriter :: stderr (
1235- color_config,
1236- Some ( source_map) ,
1237- bundle,
1238- fallback_bundle,
1239- short,
1240- sopts. unstable_opts . teach ,
1241- sopts. diagnostic_width ,
1242- macro_backtrace,
1243- ) ,
1244- Some ( dst) => EmitterWriter :: new (
1245- dst,
1246- Some ( source_map) ,
1247- bundle,
1248- fallback_bundle,
1249- short,
1250- false , // no teach messages when writing to a buffer
1251- false , // no colors when writing to a buffer
1252- None , // no diagnostic width
1253- macro_backtrace,
1254- ) ,
1255- } ;
1231+ let emitter = EmitterWriter :: stderr (
1232+ color_config,
1233+ Some ( source_map) ,
1234+ bundle,
1235+ fallback_bundle,
1236+ short,
1237+ sopts. unstable_opts . teach ,
1238+ sopts. diagnostic_width ,
1239+ macro_backtrace,
1240+ ) ;
12561241 Box :: new ( emitter. ui_testing ( sopts. unstable_opts . ui_testing ) )
12571242 }
12581243 }
1259- ( config:: ErrorOutputType :: Json { pretty, json_rendered } , None ) => Box :: new (
1244+ config:: ErrorOutputType :: Json { pretty, json_rendered } => Box :: new (
12601245 JsonEmitter :: stderr (
12611246 Some ( registry) ,
12621247 source_map,
@@ -1269,36 +1254,16 @@ fn default_emitter(
12691254 )
12701255 . ui_testing ( sopts. unstable_opts . ui_testing ) ,
12711256 ) ,
1272- ( config:: ErrorOutputType :: Json { pretty, json_rendered } , Some ( dst) ) => Box :: new (
1273- JsonEmitter :: new (
1274- dst,
1275- Some ( registry) ,
1276- source_map,
1277- bundle,
1278- fallback_bundle,
1279- pretty,
1280- json_rendered,
1281- sopts. diagnostic_width ,
1282- macro_backtrace,
1283- )
1284- . ui_testing ( sopts. unstable_opts . ui_testing ) ,
1285- ) ,
12861257 }
12871258}
12881259
1289- pub enum DiagnosticOutput {
1290- Default ,
1291- Raw ( Box < dyn Write + Send > ) ,
1292- }
1293-
12941260// JUSTIFICATION: literally session construction
12951261#[ allow( rustc:: bad_opt_access) ]
12961262pub fn build_session (
12971263 sopts : config:: Options ,
12981264 local_crate_source_file : Option < PathBuf > ,
12991265 bundle : Option < Lrc < rustc_errors:: FluentBundle > > ,
13001266 registry : rustc_errors:: registry:: Registry ,
1301- diagnostics_output : DiagnosticOutput ,
13021267 driver_lint_caps : FxHashMap < lint:: LintId , lint:: Level > ,
13031268 file_loader : Option < Box < dyn FileLoader + Send + Sync + ' static > > ,
13041269 target_override : Option < Target > ,
@@ -1314,11 +1279,6 @@ pub fn build_session(
13141279 let cap_lints_allow = sopts. lint_cap . map_or ( false , |cap| cap == lint:: Allow ) ;
13151280 let can_emit_warnings = !( warnings_allow || cap_lints_allow) ;
13161281
1317- let write_dest = match diagnostics_output {
1318- DiagnosticOutput :: Default => None ,
1319- DiagnosticOutput :: Raw ( write) => Some ( write) ,
1320- } ;
1321-
13221282 let sysroot = match & sopts. maybe_sysroot {
13231283 Some ( sysroot) => sysroot. clone ( ) ,
13241284 None => filesearch:: get_or_default_sysroot ( ) ,
@@ -1351,8 +1311,7 @@ pub fn build_session(
13511311 rustc_errors:: DEFAULT_LOCALE_RESOURCES ,
13521312 sopts. unstable_opts . translate_directionality_markers ,
13531313 ) ;
1354- let emitter =
1355- default_emitter ( & sopts, registry, source_map. clone ( ) , bundle, fallback_bundle, write_dest) ;
1314+ let emitter = default_emitter ( & sopts, registry, source_map. clone ( ) , bundle, fallback_bundle) ;
13561315
13571316 let span_diagnostic = rustc_errors:: Handler :: with_emitter_and_flags (
13581317 emitter,
0 commit comments