@@ -59,7 +59,7 @@ use emitter::{DynEmitter, Emitter, is_case_difference, is_different};
5959use rustc_data_structures:: AtomicRef ;
6060use rustc_data_structures:: fx:: { FxHashSet , FxIndexMap , FxIndexSet } ;
6161use rustc_data_structures:: stable_hasher:: { Hash128 , StableHasher } ;
62- use rustc_data_structures:: sync:: Lock ;
62+ use rustc_data_structures:: sync:: { DynSend , Lock } ;
6363pub use rustc_error_messages:: {
6464 DiagMessage , FluentBundle , LanguageIdentifier , LazyFallbackBundle , MultiSpan , SpanLabel ,
6565 SubdiagMessage , fallback_fluent_bundle, fluent_bundle,
@@ -682,51 +682,40 @@ impl DiagCtxt {
682682 fatal_note : Option < String > ,
683683 emit_fatal_diagnostic : bool ,
684684 ) {
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.
702687 struct FalseEmitter ;
703688
704689 impl Emitter for FalseEmitter {
705690 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 `" )
707692 }
708693
709694 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 `" )
711696 }
712697 }
713698
714699 impl translation:: Translate for FalseEmitter {
715700 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 `" )
717702 }
718703
719704 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 `" )
721706 }
722707 }
723708
724709 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;
730719 }
731720
732721 /// Translate `message` eagerly with `args` to `SubdiagMessage::Eager`.
0 commit comments