@@ -59,7 +59,7 @@ use emitter::{DynEmitter, Emitter, is_case_difference, is_different};
59
59
use rustc_data_structures:: AtomicRef ;
60
60
use rustc_data_structures:: fx:: { FxHashSet , FxIndexMap , FxIndexSet } ;
61
61
use rustc_data_structures:: stable_hasher:: { Hash128 , StableHasher } ;
62
- use rustc_data_structures:: sync:: Lock ;
62
+ use rustc_data_structures:: sync:: { DynSend , Lock } ;
63
63
pub use rustc_error_messages:: {
64
64
DiagMessage , FluentBundle , LanguageIdentifier , LazyFallbackBundle , MultiSpan , SpanLabel ,
65
65
SubdiagMessage , fallback_fluent_bundle, fluent_bundle,
@@ -682,51 +682,40 @@ impl DiagCtxt {
682
682
fatal_note : Option < String > ,
683
683
emit_fatal_diagnostic : bool ,
684
684
) {
685
- self . wrap_emitter ( |old_dcx| {
686
- Box :: new ( emitter:: SilentEmitter {
687
- fallback_bundle,
688
- fatal_dcx : DiagCtxt { inner : Lock :: new ( old_dcx) } ,
689
- fatal_note,
690
- emit_fatal_diagnostic,
691
- } )
692
- } ) ;
693
- }
694
-
695
- fn wrap_emitter < F > ( & self , f : F )
696
- where
697
- F : FnOnce ( DiagCtxtInner ) -> Box < DynEmitter > ,
698
- {
699
- // A empty type that implements `Emitter` so that a `DiagCtxtInner` can be constructed
700
- // to temporarily swap in place of the real one, which will be used in constructing
701
- // its replacement.
685
+ // An empty type that implements `Emitter` to temporarily swap in place of the real one,
686
+ // which will be used in constructing its replacement.
702
687
struct FalseEmitter ;
703
688
704
689
impl Emitter for FalseEmitter {
705
690
fn emit_diagnostic ( & mut self , _: DiagInner , _: & Registry ) {
706
- unimplemented ! ( "false emitter must only used during `wrap_emitter `" )
691
+ unimplemented ! ( "false emitter must only used during `make_silent `" )
707
692
}
708
693
709
694
fn source_map ( & self ) -> Option < & SourceMap > {
710
- unimplemented ! ( "false emitter must only used during `wrap_emitter `" )
695
+ unimplemented ! ( "false emitter must only used during `make_silent `" )
711
696
}
712
697
}
713
698
714
699
impl translation:: Translate for FalseEmitter {
715
700
fn fluent_bundle ( & self ) -> Option < & FluentBundle > {
716
- unimplemented ! ( "false emitter must only used during `wrap_emitter `" )
701
+ unimplemented ! ( "false emitter must only used during `make_silent `" )
717
702
}
718
703
719
704
fn fallback_fluent_bundle ( & self ) -> & FluentBundle {
720
- unimplemented ! ( "false emitter must only used during `wrap_emitter `" )
705
+ unimplemented ! ( "false emitter must only used during `make_silent `" )
721
706
}
722
707
}
723
708
724
709
let mut inner = self . inner . borrow_mut ( ) ;
725
- let mut prev_dcx = DiagCtxtInner :: new ( Box :: new ( FalseEmitter ) ) ;
726
- std:: mem:: swap ( & mut * inner, & mut prev_dcx) ;
727
- let new_emitter = f ( prev_dcx) ;
728
- let mut new_dcx = DiagCtxtInner :: new ( new_emitter) ;
729
- std:: mem:: swap ( & mut * inner, & mut new_dcx) ;
710
+ let mut prev_emitter = Box :: new ( FalseEmitter ) as Box < dyn Emitter + DynSend > ;
711
+ std:: mem:: swap ( & mut inner. emitter , & mut prev_emitter) ;
712
+ let new_emitter = Box :: new ( emitter:: SilentEmitter {
713
+ fallback_bundle,
714
+ fatal_emitter : prev_emitter,
715
+ fatal_note,
716
+ emit_fatal_diagnostic,
717
+ } ) ;
718
+ inner. emitter = new_emitter;
730
719
}
731
720
732
721
/// Translate `message` eagerly with `args` to `SubdiagMessage::Eager`.
0 commit comments