File tree 4 files changed +6
-28
lines changed
src/tools/rustfmt/src/parse
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 {
540
540
/// Fatal diagnostics are forwarded to `fatal_emitter` to avoid silent
541
541
/// failures of rustc, as witnessed e.g. in issue #89358.
542
542
pub struct SilentEmitter {
543
- pub fallback_bundle : LazyFallbackBundle ,
544
543
pub fatal_emitter : Box < dyn Emitter + DynSend > ,
545
544
pub fatal_note : Option < String > ,
546
545
pub emit_fatal_diagnostic : bool ,
@@ -552,9 +551,7 @@ impl Translate for SilentEmitter {
552
551
}
553
552
554
553
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 ( )
558
555
}
559
556
}
560
557
Original file line number Diff line number Diff line change @@ -676,12 +676,7 @@ impl DiagCtxt {
676
676
Self { inner : Lock :: new ( DiagCtxtInner :: new ( emitter) ) }
677
677
}
678
678
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 ) {
685
680
// An empty type that implements `Emitter` to temporarily swap in place of the real one,
686
681
// which will be used in constructing its replacement.
687
682
struct FalseEmitter ;
@@ -710,7 +705,6 @@ impl DiagCtxt {
710
705
let mut prev_emitter = Box :: new ( FalseEmitter ) as Box < dyn Emitter + DynSend > ;
711
706
std:: mem:: swap ( & mut inner. emitter , & mut prev_emitter) ;
712
707
let new_emitter = Box :: new ( emitter:: SilentEmitter {
713
- fallback_bundle,
714
708
fatal_emitter : prev_emitter,
715
709
fatal_note,
716
710
emit_fatal_diagnostic,
Original file line number Diff line number Diff line change @@ -277,12 +277,9 @@ impl ParseSess {
277
277
) -> Self {
278
278
let fallback_bundle = fallback_fluent_bundle ( locale_resources, false ) ;
279
279
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) ) ;
284
282
let dcx = DiagCtxt :: new ( Box :: new ( SilentEmitter {
285
- fallback_bundle,
286
283
fatal_emitter,
287
284
fatal_note : Some ( fatal_note) ,
288
285
emit_fatal_diagnostic,
Original file line number Diff line number Diff line change @@ -114,13 +114,12 @@ fn default_dcx(
114
114
false ,
115
115
) ;
116
116
let emitter = Box :: new (
117
- HumanEmitter :: new ( stderr_destination ( emit_color) , fallback_bundle. clone ( ) )
117
+ HumanEmitter :: new ( stderr_destination ( emit_color) , fallback_bundle)
118
118
. sm ( Some ( source_map. clone ( ) ) ) ,
119
119
) ;
120
120
121
121
let emitter: Box < DynEmitter > = if !show_parse_errors {
122
122
Box :: new ( SilentEmitter {
123
- fallback_bundle,
124
123
fatal_emitter : emitter,
125
124
fatal_note : None ,
126
125
emit_fatal_diagnostic : false ,
@@ -205,16 +204,7 @@ impl ParseSess {
205
204
}
206
205
207
206
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 ) ;
218
208
}
219
209
220
210
pub ( crate ) fn span_to_filename ( & self , span : Span ) -> FileName {
You can’t perform that action at this time.
0 commit comments