@@ -284,6 +284,7 @@ pub fn run_compiler(
284
284
}
285
285
286
286
let linker = compiler. enter ( |queries| {
287
+ let early_exit = || sess. compile_status ( ) . map ( |_| None ) ;
287
288
queries. parse ( ) ?;
288
289
289
290
if let Some ( ppm) = & sess. opts . pretty {
@@ -309,20 +310,17 @@ pub fn run_compiler(
309
310
compiler. output_file ( ) . as_ref ( ) . map ( |p| & * * p) ,
310
311
) ;
311
312
}
312
- sess. compile_status ( ) ?;
313
- return Ok ( None ) ;
313
+ return early_exit ( ) ;
314
314
}
315
315
316
316
if callbacks. after_parsing ( compiler) == Compilation :: Stop {
317
- sess. compile_status ( ) ?;
318
- return Ok ( None ) ;
317
+ return early_exit ( ) ;
319
318
}
320
319
321
320
if sess. opts . debugging_opts . parse_only ||
322
321
sess. opts . debugging_opts . show_span . is_some ( ) ||
323
322
sess. opts . debugging_opts . ast_json_noexpand {
324
- sess. compile_status ( ) ?;
325
- return Ok ( None ) ;
323
+ return early_exit ( ) ;
326
324
}
327
325
328
326
{
@@ -331,32 +329,28 @@ pub fn run_compiler(
331
329
// Lint plugins are registered; now we can process command line flags.
332
330
if sess. opts . describe_lints {
333
331
describe_lints ( & sess, & lint_store, true ) ;
334
- sess. compile_status ( ) ?;
335
- return Ok ( None ) ;
332
+ return early_exit ( ) ;
336
333
}
337
334
}
338
335
339
336
queries. expansion ( ) ?;
340
337
if callbacks. after_expansion ( compiler) == Compilation :: Stop {
341
- sess. compile_status ( ) ?;
342
- return Ok ( None ) ;
338
+ return early_exit ( ) ;
343
339
}
344
340
345
341
queries. prepare_outputs ( ) ?;
346
342
347
343
if sess. opts . output_types . contains_key ( & OutputType :: DepInfo )
348
344
&& sess. opts . output_types . len ( ) == 1
349
345
{
350
- sess. compile_status ( ) ?;
351
- return Ok ( None ) ;
346
+ return early_exit ( ) ;
352
347
}
353
348
354
349
queries. global_ctxt ( ) ?;
355
350
356
351
if sess. opts . debugging_opts . no_analysis ||
357
352
sess. opts . debugging_opts . ast_json {
358
- sess. compile_status ( ) ?;
359
- return Ok ( None ) ;
353
+ return early_exit ( ) ;
360
354
}
361
355
362
356
if sess. opts . debugging_opts . save_analysis {
@@ -390,8 +384,7 @@ pub fn run_compiler(
390
384
queries. global_ctxt ( ) ?. peek_mut ( ) . enter ( |tcx| tcx. analysis ( LOCAL_CRATE ) ) ?;
391
385
392
386
if callbacks. after_analysis ( compiler) == Compilation :: Stop {
393
- sess. compile_status ( ) ?;
394
- return Ok ( None ) ;
387
+ return early_exit ( ) ;
395
388
}
396
389
397
390
if sess. opts . debugging_opts . save_analysis {
0 commit comments