@@ -23,6 +23,8 @@ use rustc_data_structures::sync::{
2323
2424use errors:: { DiagnosticBuilder , DiagnosticId , Applicability } ;
2525use errors:: emitter:: { Emitter , EmitterWriter } ;
26+ use errors:: emitter:: HumanReadableErrorType ;
27+ use errors:: annotate_rs_emitter:: { AnnotateRsEmitterWriter } ;
2628use syntax:: ast:: { self , NodeId } ;
2729use syntax:: edition:: Edition ;
2830use syntax:: feature_gate:: { self , AttributeType } ;
@@ -1031,22 +1033,31 @@ fn default_emitter(
10311033 match ( sopts. error_format , emitter_dest) {
10321034 ( config:: ErrorOutputType :: HumanReadable ( kind) , dst) => {
10331035 let ( short, color_config) = kind. unzip ( ) ;
1034- let emitter = match dst {
1035- None => EmitterWriter :: stderr (
1036- color_config,
1037- Some ( source_map. clone ( ) ) ,
1038- short,
1039- sopts. debugging_opts . teach ,
1040- ) ,
1041- Some ( dst) => EmitterWriter :: new (
1042- dst,
1036+
1037+ if let HumanReadableErrorType :: AnnotateRs ( _) = kind {
1038+ let emitter = AnnotateRsEmitterWriter :: new (
10431039 Some ( source_map. clone ( ) ) ,
10441040 short,
1045- false , // no teach messages when writing to a buffer
1046- false , // no colors when writing to a buffer
1047- ) ,
1048- } ;
1049- Box :: new ( emitter. ui_testing ( sopts. debugging_opts . ui_testing ) )
1041+ ) ;
1042+ Box :: new ( emitter. ui_testing ( sopts. debugging_opts . ui_testing ) )
1043+ } else {
1044+ let emitter = match dst {
1045+ None => EmitterWriter :: stderr (
1046+ color_config,
1047+ Some ( source_map. clone ( ) ) ,
1048+ short,
1049+ sopts. debugging_opts . teach ,
1050+ ) ,
1051+ Some ( dst) => EmitterWriter :: new (
1052+ dst,
1053+ Some ( source_map. clone ( ) ) ,
1054+ short,
1055+ false , // no teach messages when writing to a buffer
1056+ false , // no colors when writing to a buffer
1057+ ) ,
1058+ } ;
1059+ Box :: new ( emitter. ui_testing ( sopts. debugging_opts . ui_testing ) )
1060+ }
10501061 } ,
10511062 ( config:: ErrorOutputType :: Json { pretty, json_rendered } , None ) => Box :: new (
10521063 JsonEmitter :: stderr (
0 commit comments