@@ -548,12 +548,9 @@ impl Drop for HandlerInner {
548
548
549
549
impl Handler {
550
550
pub fn with_tty_emitter (
551
- can_emit_warnings : bool ,
552
551
sm : Option < Lrc < SourceMap > > ,
553
552
fallback_bundle : LazyFallbackBundle ,
554
553
) -> Self {
555
- let flags =
556
- HandlerFlags { can_emit_warnings, treat_err_as_bug : None , ..Default :: default ( ) } ;
557
554
let emitter = Box :: new ( EmitterWriter :: stderr (
558
555
ColorConfig :: Auto ,
559
556
sm,
@@ -562,34 +559,36 @@ impl Handler {
562
559
false ,
563
560
false ,
564
561
None ,
565
- flags . macro_backtrace ,
566
- flags . track_diagnostics ,
562
+ false ,
563
+ false ,
567
564
TerminalUrl :: No ,
568
565
) ) ;
569
- Self :: with_emitter_and_flags ( emitter, flags, None )
566
+ Self :: with_emitter ( emitter)
567
+ }
568
+ pub fn disable_warnings ( mut self ) -> Self {
569
+ self . inner . get_mut ( ) . flags . can_emit_warnings = false ;
570
+ self
570
571
}
571
572
572
- pub fn with_emitter (
573
- can_emit_warnings : bool ,
574
- treat_err_as_bug : Option < NonZeroUsize > ,
575
- emitter : Box < dyn Emitter + sync:: Send > ,
576
- ice_file : Option < PathBuf > ,
577
- ) -> Self {
578
- Handler :: with_emitter_and_flags (
579
- emitter,
580
- HandlerFlags { can_emit_warnings, treat_err_as_bug, ..Default :: default ( ) } ,
581
- ice_file,
582
- )
573
+ pub fn treat_err_as_bug ( mut self , treat_err_as_bug : NonZeroUsize ) -> Self {
574
+ self . inner . get_mut ( ) . flags . treat_err_as_bug = Some ( treat_err_as_bug) ;
575
+ self
583
576
}
584
577
585
- pub fn with_emitter_and_flags (
586
- emitter : Box < dyn Emitter + sync:: Send > ,
587
- flags : HandlerFlags ,
588
- ice_file : Option < PathBuf > ,
589
- ) -> Self {
578
+ pub fn with_flags ( mut self , flags : HandlerFlags ) -> Self {
579
+ self . inner . get_mut ( ) . flags = flags;
580
+ self
581
+ }
582
+
583
+ pub fn with_ice_file ( mut self , ice_file : PathBuf ) -> Self {
584
+ self . inner . get_mut ( ) . ice_file = Some ( ice_file) ;
585
+ self
586
+ }
587
+
588
+ pub fn with_emitter ( emitter : Box < dyn Emitter + sync:: Send > ) -> Self {
590
589
Self {
591
590
inner : Lock :: new ( HandlerInner {
592
- flags,
591
+ flags : HandlerFlags { can_emit_warnings : true , .. Default :: default ( ) } ,
593
592
lint_err_count : 0 ,
594
593
err_count : 0 ,
595
594
warn_count : 0 ,
@@ -607,7 +606,7 @@ impl Handler {
607
606
check_unstable_expect_diagnostics : false ,
608
607
unstable_expect_diagnostics : Vec :: new ( ) ,
609
608
fulfilled_expectations : Default :: default ( ) ,
610
- ice_file,
609
+ ice_file : None ,
611
610
} ) ,
612
611
}
613
612
}
0 commit comments