@@ -1362,23 +1362,16 @@ pub struct EarlyDiagCtxt {
1362
1362
dcx : DiagCtxt ,
1363
1363
}
1364
1364
1365
- impl Default for EarlyDiagCtxt {
1366
- fn default ( ) -> Self {
1367
- Self :: new ( ErrorOutputType :: default ( ) )
1368
- }
1369
- }
1370
-
1371
1365
impl EarlyDiagCtxt {
1372
1366
pub fn new ( output : ErrorOutputType ) -> Self {
1373
1367
let emitter = mk_emitter ( output) ;
1374
1368
Self { dcx : DiagCtxt :: new ( emitter) }
1375
1369
}
1376
1370
1377
1371
/// 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( ) ) ;
1382
1375
1383
1376
let emitter = mk_emitter ( output) ;
1384
1377
self . dcx = DiagCtxt :: new ( emitter) ;
@@ -1398,7 +1391,7 @@ impl EarlyDiagCtxt {
1398
1391
1399
1392
#[ allow( rustc:: untranslatable_diagnostic) ]
1400
1393
#[ 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" ]
1402
1395
pub fn early_err ( & self , msg : impl Into < DiagMessage > ) -> ErrorGuaranteed {
1403
1396
self . dcx . handle ( ) . err ( msg)
1404
1397
}
0 commit comments