@@ -649,7 +649,7 @@ pub struct FileWithAnnotatedLines {
649649
650650impl EmitterWriter {
651651 pub fn stderr ( color_config : ColorConfig , fallback_bundle : LazyFallbackBundle ) -> EmitterWriter {
652- let dst = Destination :: from_stderr ( color_config) ;
652+ let dst = from_stderr ( color_config) ;
653653 Self :: create ( dst, fallback_bundle)
654654 }
655655
@@ -673,7 +673,7 @@ impl EmitterWriter {
673673 dst : Box < dyn WriteColor + Send > ,
674674 fallback_bundle : LazyFallbackBundle ,
675675 ) -> EmitterWriter {
676- Self :: create ( Destination ( dst) , fallback_bundle)
676+ Self :: create ( dst, fallback_bundle)
677677 }
678678
679679 fn maybe_anonymized ( & self , line_num : usize ) -> Cow < ' static , str > {
@@ -2156,11 +2156,10 @@ impl EmitterWriter {
21562156 Err ( e) => panic ! ( "failed to emit error: {e}" ) ,
21572157 }
21582158
2159- let dst = self . dst . writable ( ) ;
2160- match writeln ! ( dst) {
2159+ match writeln ! ( self . dst) {
21612160 Err ( e) => panic ! ( "failed to emit error: {e}" ) ,
21622161 _ => {
2163- if let Err ( e) = dst. flush ( ) {
2162+ if let Err ( e) = self . dst . flush ( ) {
21642163 panic ! ( "failed to emit error: {e}" )
21652164 }
21662165 }
@@ -2571,8 +2570,6 @@ fn emit_to_destination(
25712570) -> io:: Result < ( ) > {
25722571 use crate :: lock;
25732572
2574- let dst = dst. writable ( ) ;
2575-
25762573 // In order to prevent error message interleaving, where multiple error lines get intermixed
25772574 // when multiple compiler processes error simultaneously, we emit errors with additional
25782575 // steps.
@@ -2601,7 +2598,7 @@ fn emit_to_destination(
26012598 Ok ( ( ) )
26022599}
26032600
2604- pub struct Destination ( pub ( crate ) Box < ( dyn WriteColor + Send ) > ) ;
2601+ pub type Destination = Box < ( dyn WriteColor + Send ) > ;
26052602
26062603struct Buffy {
26072604 buffer_writer : BufferWriter ,
@@ -2634,30 +2631,20 @@ impl WriteColor for Buffy {
26342631 }
26352632}
26362633
2637- impl Destination {
2638- fn from_stderr ( color : ColorConfig ) -> Destination {
2639- let choice = color. to_color_choice ( ) ;
2640- // On Windows we'll be performing global synchronization on the entire
2641- // system for emitting rustc errors, so there's no need to buffer
2642- // anything.
2643- //
2644- // On non-Windows we rely on the atomicity of `write` to ensure errors
2645- // don't get all jumbled up.
2646- if cfg ! ( windows) {
2647- Destination ( Box :: new ( StandardStream :: stderr ( choice) ) )
2648- } else {
2649- let buffer_writer = BufferWriter :: stderr ( choice) ;
2650- let buffer = buffer_writer. buffer ( ) ;
2651- Destination ( Box :: new ( Buffy { buffer_writer, buffer } ) )
2652- }
2653- }
2654-
2655- fn writable ( & mut self ) -> & mut dyn WriteColor {
2656- & mut self . 0
2657- }
2658-
2659- fn supports_color ( & self ) -> bool {
2660- self . 0 . supports_color ( )
2634+ fn from_stderr ( color : ColorConfig ) -> Destination {
2635+ let choice = color. to_color_choice ( ) ;
2636+ // On Windows we'll be performing global synchronization on the entire
2637+ // system for emitting rustc errors, so there's no need to buffer
2638+ // anything.
2639+ //
2640+ // On non-Windows we rely on the atomicity of `write` to ensure errors
2641+ // don't get all jumbled up.
2642+ if cfg ! ( windows) {
2643+ Box :: new ( StandardStream :: stderr ( choice) )
2644+ } else {
2645+ let buffer_writer = BufferWriter :: stderr ( choice) ;
2646+ let buffer = buffer_writer. buffer ( ) ;
2647+ Box :: new ( Buffy { buffer_writer, buffer } )
26612648 }
26622649}
26632650
0 commit comments