@@ -548,12 +548,9 @@ impl Drop for HandlerInner {
548548
549549impl Handler {
550550 pub fn with_tty_emitter (
551- can_emit_warnings : bool ,
552551 sm : Option < Lrc < SourceMap > > ,
553552 fallback_bundle : LazyFallbackBundle ,
554553 ) -> Self {
555- let flags =
556- HandlerFlags { can_emit_warnings, treat_err_as_bug : None , ..Default :: default ( ) } ;
557554 let emitter = Box :: new ( EmitterWriter :: stderr (
558555 ColorConfig :: Auto ,
559556 sm,
@@ -562,34 +559,36 @@ impl Handler {
562559 false ,
563560 false ,
564561 None ,
565- flags . macro_backtrace ,
566- flags . track_diagnostics ,
562+ false ,
563+ false ,
567564 TerminalUrl :: No ,
568565 ) ) ;
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
570571 }
571572
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
583576 }
584577
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 {
590589 Self {
591590 inner : Lock :: new ( HandlerInner {
592- flags,
591+ flags : HandlerFlags { can_emit_warnings : true , .. Default :: default ( ) } ,
593592 lint_err_count : 0 ,
594593 err_count : 0 ,
595594 warn_count : 0 ,
@@ -607,7 +606,7 @@ impl Handler {
607606 check_unstable_expect_diagnostics : false ,
608607 unstable_expect_diagnostics : Vec :: new ( ) ,
609608 fulfilled_expectations : Default :: default ( ) ,
610- ice_file,
609+ ice_file : None ,
611610 } ) ,
612611 }
613612 }
0 commit comments