File tree Expand file tree Collapse file tree 4 files changed +6
-28
lines changed
src/tools/rustfmt/src/parse Expand file tree Collapse file tree 4 files changed +6
-28
lines changed Original file line number Diff line number Diff line change @@ -540,7 +540,6 @@ impl Emitter for HumanEmitter {
540540/// Fatal diagnostics are forwarded to `fatal_emitter` to avoid silent
541541/// failures of rustc, as witnessed e.g. in issue #89358.
542542pub struct SilentEmitter {
543- pub fallback_bundle : LazyFallbackBundle ,
544543 pub fatal_emitter : Box < dyn Emitter + DynSend > ,
545544 pub fatal_note : Option < String > ,
546545 pub emit_fatal_diagnostic : bool ,
@@ -552,9 +551,7 @@ impl Translate for SilentEmitter {
552551 }
553552
554553 fn fallback_fluent_bundle ( & self ) -> & FluentBundle {
555- // Ideally this field wouldn't be necessary and the fallback bundle in `fatal_dcx` would be
556- // used but the lock prevents this.
557- & self . fallback_bundle
554+ self . fatal_emitter . fallback_fluent_bundle ( )
558555 }
559556}
560557
Original file line number Diff line number Diff line change @@ -676,12 +676,7 @@ impl DiagCtxt {
676676 Self { inner : Lock :: new ( DiagCtxtInner :: new ( emitter) ) }
677677 }
678678
679- pub fn make_silent (
680- & self ,
681- fallback_bundle : LazyFallbackBundle ,
682- fatal_note : Option < String > ,
683- emit_fatal_diagnostic : bool ,
684- ) {
679+ pub fn make_silent ( & self , fatal_note : Option < String > , emit_fatal_diagnostic : bool ) {
685680 // An empty type that implements `Emitter` to temporarily swap in place of the real one,
686681 // which will be used in constructing its replacement.
687682 struct FalseEmitter ;
@@ -710,7 +705,6 @@ impl DiagCtxt {
710705 let mut prev_emitter = Box :: new ( FalseEmitter ) as Box < dyn Emitter + DynSend > ;
711706 std:: mem:: swap ( & mut inner. emitter , & mut prev_emitter) ;
712707 let new_emitter = Box :: new ( emitter:: SilentEmitter {
713- fallback_bundle,
714708 fatal_emitter : prev_emitter,
715709 fatal_note,
716710 emit_fatal_diagnostic,
Original file line number Diff line number Diff line change @@ -277,12 +277,9 @@ impl ParseSess {
277277 ) -> Self {
278278 let fallback_bundle = fallback_fluent_bundle ( locale_resources, false ) ;
279279 let sm = Lrc :: new ( SourceMap :: new ( FilePathMapping :: empty ( ) ) ) ;
280- let fatal_emitter = Box :: new ( HumanEmitter :: new (
281- stderr_destination ( ColorConfig :: Auto ) ,
282- Lrc :: clone ( & fallback_bundle) ,
283- ) ) ;
280+ let fatal_emitter =
281+ Box :: new ( HumanEmitter :: new ( stderr_destination ( ColorConfig :: Auto ) , fallback_bundle) ) ;
284282 let dcx = DiagCtxt :: new ( Box :: new ( SilentEmitter {
285- fallback_bundle,
286283 fatal_emitter,
287284 fatal_note : Some ( fatal_note) ,
288285 emit_fatal_diagnostic,
Original file line number Diff line number Diff line change @@ -114,13 +114,12 @@ fn default_dcx(
114114 false ,
115115 ) ;
116116 let emitter = Box :: new (
117- HumanEmitter :: new ( stderr_destination ( emit_color) , fallback_bundle. clone ( ) )
117+ HumanEmitter :: new ( stderr_destination ( emit_color) , fallback_bundle)
118118 . sm ( Some ( source_map. clone ( ) ) ) ,
119119 ) ;
120120
121121 let emitter: Box < DynEmitter > = if !show_parse_errors {
122122 Box :: new ( SilentEmitter {
123- fallback_bundle,
124123 fatal_emitter : emitter,
125124 fatal_note : None ,
126125 emit_fatal_diagnostic : false ,
@@ -205,16 +204,7 @@ impl ParseSess {
205204 }
206205
207206 pub ( crate ) fn set_silent_emitter ( & mut self ) {
208- // Ideally this invocation wouldn't be necessary and the fallback bundle in
209- // `self.parse_sess.dcx` could be used, but the lock in `DiagCtxt` prevents this.
210- // See `<rustc_errors::SilentEmitter as Translate>::fallback_fluent_bundle`.
211- let fallback_bundle = rustc_errors:: fallback_fluent_bundle (
212- rustc_driver:: DEFAULT_LOCALE_RESOURCES . to_vec ( ) ,
213- false ,
214- ) ;
215- self . raw_psess
216- . dcx ( )
217- . make_silent ( fallback_bundle, None , false ) ;
207+ self . raw_psess . dcx ( ) . make_silent ( None , false ) ;
218208 }
219209
220210 pub ( crate ) fn span_to_filename ( & self , span : Span ) -> FileName {
You can’t perform that action at this time.
0 commit comments