@@ -1362,23 +1362,16 @@ pub struct EarlyDiagCtxt {
13621362 dcx : DiagCtxt ,
13631363}
13641364
1365- impl Default for EarlyDiagCtxt {
1366- fn default ( ) -> Self {
1367- Self :: new ( ErrorOutputType :: default ( ) )
1368- }
1369- }
1370-
13711365impl EarlyDiagCtxt {
13721366 pub fn new ( output : ErrorOutputType ) -> Self {
13731367 let emitter = mk_emitter ( output) ;
13741368 Self { dcx : DiagCtxt :: new ( emitter) }
13751369 }
13761370
13771371 /// Swap out the underlying dcx once we acquire the user's preference on error emission
1378- /// format. Any errors prior to that will cause an abort and all stashed diagnostics of the
1379- /// previous dcx will be emitted.
1380- pub fn abort_if_error_and_set_error_format ( & mut self , output : ErrorOutputType ) {
1381- self . dcx . handle ( ) . abort_if_errors ( ) ;
1372+ /// format. If `early_err` was previously called this will panic.
1373+ pub fn set_error_format ( & mut self , output : ErrorOutputType ) {
1374+ assert ! ( self . dcx. handle( ) . has_errors( ) . is_none( ) ) ;
13821375
13831376 let emitter = mk_emitter ( output) ;
13841377 self . dcx = DiagCtxt :: new ( emitter) ;
@@ -1398,7 +1391,7 @@ impl EarlyDiagCtxt {
13981391
13991392 #[ allow( rustc:: untranslatable_diagnostic) ]
14001393 #[ allow( rustc:: diagnostic_outside_of_impl) ]
1401- #[ must_use = "ErrorGuaranteed must be returned from `run_compiler` in order to exit with a non-zero status code" ]
1394+ #[ must_use = "raise_fatal must be called on the returned ErrorGuaranteed in order to exit with a non-zero status code" ]
14021395 pub fn early_err ( & self , msg : impl Into < DiagMessage > ) -> ErrorGuaranteed {
14031396 self . dcx . handle ( ) . err ( msg)
14041397 }
0 commit comments