@@ -23,6 +23,8 @@ use rustc_data_structures::sync::{
23
23
24
24
use errors:: { DiagnosticBuilder , DiagnosticId , Applicability } ;
25
25
use errors:: emitter:: { Emitter , EmitterWriter } ;
26
+ use errors:: emitter:: HumanReadableErrorType ;
27
+ use errors:: annotate_rs_emitter:: { AnnotateRsEmitterWriter } ;
26
28
use syntax:: ast:: { self , NodeId } ;
27
29
use syntax:: edition:: Edition ;
28
30
use syntax:: feature_gate:: { self , AttributeType } ;
@@ -1031,22 +1033,31 @@ fn default_emitter(
1031
1033
match ( sopts. error_format , emitter_dest) {
1032
1034
( config:: ErrorOutputType :: HumanReadable ( kind) , dst) => {
1033
1035
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 (
1043
1039
Some ( source_map. clone ( ) ) ,
1044
1040
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
+ }
1050
1061
} ,
1051
1062
( config:: ErrorOutputType :: Json { pretty, json_rendered } , None ) => Box :: new (
1052
1063
JsonEmitter :: stderr (
0 commit comments