@@ -649,7 +649,7 @@ pub struct FileWithAnnotatedLines {
649
649
650
650
impl EmitterWriter {
651
651
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) ;
653
653
Self :: create ( dst, fallback_bundle)
654
654
}
655
655
@@ -673,7 +673,7 @@ impl EmitterWriter {
673
673
dst : Box < dyn WriteColor + Send > ,
674
674
fallback_bundle : LazyFallbackBundle ,
675
675
) -> EmitterWriter {
676
- Self :: create ( Destination ( dst) , fallback_bundle)
676
+ Self :: create ( dst, fallback_bundle)
677
677
}
678
678
679
679
fn maybe_anonymized ( & self , line_num : usize ) -> Cow < ' static , str > {
@@ -2156,11 +2156,10 @@ impl EmitterWriter {
2156
2156
Err ( e) => panic ! ( "failed to emit error: {e}" ) ,
2157
2157
}
2158
2158
2159
- let dst = self . dst . writable ( ) ;
2160
- match writeln ! ( dst) {
2159
+ match writeln ! ( self . dst) {
2161
2160
Err ( e) => panic ! ( "failed to emit error: {e}" ) ,
2162
2161
_ => {
2163
- if let Err ( e) = dst. flush ( ) {
2162
+ if let Err ( e) = self . dst . flush ( ) {
2164
2163
panic ! ( "failed to emit error: {e}" )
2165
2164
}
2166
2165
}
@@ -2571,8 +2570,6 @@ fn emit_to_destination(
2571
2570
) -> io:: Result < ( ) > {
2572
2571
use crate :: lock;
2573
2572
2574
- let dst = dst. writable ( ) ;
2575
-
2576
2573
// In order to prevent error message interleaving, where multiple error lines get intermixed
2577
2574
// when multiple compiler processes error simultaneously, we emit errors with additional
2578
2575
// steps.
@@ -2601,7 +2598,7 @@ fn emit_to_destination(
2601
2598
Ok ( ( ) )
2602
2599
}
2603
2600
2604
- pub struct Destination ( pub ( crate ) Box < ( dyn WriteColor + Send ) > ) ;
2601
+ pub type Destination = Box < ( dyn WriteColor + Send ) > ;
2605
2602
2606
2603
struct Buffy {
2607
2604
buffer_writer : BufferWriter ,
@@ -2634,30 +2631,20 @@ impl WriteColor for Buffy {
2634
2631
}
2635
2632
}
2636
2633
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 } )
2661
2648
}
2662
2649
}
2663
2650
0 commit comments