@@ -284,6 +284,7 @@ pub fn run_compiler(
284284 }
285285
286286 let linker = compiler. enter ( |queries| {
287+ let early_exit = || sess. compile_status ( ) . map ( |_| None ) ;
287288 queries. parse ( ) ?;
288289
289290 if let Some ( ppm) = & sess. opts . pretty {
@@ -309,20 +310,17 @@ pub fn run_compiler(
309310 compiler. output_file ( ) . as_ref ( ) . map ( |p| & * * p) ,
310311 ) ;
311312 }
312- sess. compile_status ( ) ?;
313- return Ok ( None ) ;
313+ return early_exit ( ) ;
314314 }
315315
316316 if callbacks. after_parsing ( compiler) == Compilation :: Stop {
317- sess. compile_status ( ) ?;
318- return Ok ( None ) ;
317+ return early_exit ( ) ;
319318 }
320319
321320 if sess. opts . debugging_opts . parse_only ||
322321 sess. opts . debugging_opts . show_span . is_some ( ) ||
323322 sess. opts . debugging_opts . ast_json_noexpand {
324- sess. compile_status ( ) ?;
325- return Ok ( None ) ;
323+ return early_exit ( ) ;
326324 }
327325
328326 {
@@ -331,32 +329,28 @@ pub fn run_compiler(
331329 // Lint plugins are registered; now we can process command line flags.
332330 if sess. opts . describe_lints {
333331 describe_lints ( & sess, & lint_store, true ) ;
334- sess. compile_status ( ) ?;
335- return Ok ( None ) ;
332+ return early_exit ( ) ;
336333 }
337334 }
338335
339336 queries. expansion ( ) ?;
340337 if callbacks. after_expansion ( compiler) == Compilation :: Stop {
341- sess. compile_status ( ) ?;
342- return Ok ( None ) ;
338+ return early_exit ( ) ;
343339 }
344340
345341 queries. prepare_outputs ( ) ?;
346342
347343 if sess. opts . output_types . contains_key ( & OutputType :: DepInfo )
348344 && sess. opts . output_types . len ( ) == 1
349345 {
350- sess. compile_status ( ) ?;
351- return Ok ( None ) ;
346+ return early_exit ( ) ;
352347 }
353348
354349 queries. global_ctxt ( ) ?;
355350
356351 if sess. opts . debugging_opts . no_analysis ||
357352 sess. opts . debugging_opts . ast_json {
358- sess. compile_status ( ) ?;
359- return Ok ( None ) ;
353+ return early_exit ( ) ;
360354 }
361355
362356 if sess. opts . debugging_opts . save_analysis {
@@ -390,8 +384,7 @@ pub fn run_compiler(
390384 queries. global_ctxt ( ) ?. peek_mut ( ) . enter ( |tcx| tcx. analysis ( LOCAL_CRATE ) ) ?;
391385
392386 if callbacks. after_analysis ( compiler) == Compilation :: Stop {
393- sess. compile_status ( ) ?;
394- return Ok ( None ) ;
387+ return early_exit ( ) ;
395388 }
396389
397390 if sess. opts . debugging_opts . save_analysis {
0 commit comments