@@ -231,28 +231,21 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
231231 let sess = & compiler. sess ;
232232 let codegen_backend = & * compiler. codegen_backend ;
233233
234- // This is used for early exits unrelated to errors. E.g. when just
235- // printing some information without compiling, or exiting immediately
236- // after parsing, etc.
237- let early_exit = || {
238- sess. dcx ( ) . abort_if_errors ( ) ;
239- } ;
240-
241234 // This implements `-Whelp`. It should be handled very early, like
242235 // `--help`/`-Zhelp`/`-Chelp`. This is the earliest it can run, because
243236 // it must happen after lints are registered, during session creation.
244237 if sess. opts . describe_lints {
245238 describe_lints ( sess, registered_lints) ;
246- return early_exit ( ) ;
239+ return ;
247240 }
248241
249242 // We have now handled all help options, exit
250243 if help_only {
251- return early_exit ( ) ;
244+ return ;
252245 }
253246
254247 if print_crate_info ( codegen_backend, sess, has_input) == Compilation :: Stop {
255- return early_exit ( ) ;
248+ return ;
256249 }
257250
258251 if !has_input {
@@ -261,12 +254,12 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
261254
262255 if !sess. opts . unstable_opts . ls . is_empty ( ) {
263256 list_metadata ( sess, & * codegen_backend. metadata_loader ( ) ) ;
264- return early_exit ( ) ;
257+ return ;
265258 }
266259
267260 if sess. opts . unstable_opts . link_only {
268261 process_rlink ( sess, compiler) ;
269- return early_exit ( ) ;
262+ return ;
270263 }
271264
272265 // Parse the crate root source code (doesn't parse submodules yet)
@@ -285,28 +278,23 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
285278 pretty:: print ( sess, pp_mode, pretty:: PrintExtra :: AfterParsing { krate : & krate } ) ;
286279 }
287280 trace ! ( "finished pretty-printing" ) ;
288- return early_exit ( ) ;
281+ return ;
289282 }
290283
291284 if callbacks. after_crate_root_parsing ( compiler, & mut krate) == Compilation :: Stop {
292- return early_exit ( ) ;
285+ return ;
293286 }
294287
295288 if sess. opts . unstable_opts . parse_crate_root_only {
296- return early_exit ( ) ;
289+ return ;
297290 }
298291
299292 let linker = create_and_enter_global_ctxt ( compiler, krate, |tcx| {
300- let early_exit = || {
301- sess. dcx ( ) . abort_if_errors ( ) ;
302- None
303- } ;
304-
305293 // Make sure name resolution and macro expansion is run.
306294 let _ = tcx. resolver_for_lowering ( ) ;
307295
308296 if callbacks. after_expansion ( compiler, tcx) == Compilation :: Stop {
309- return early_exit ( ) ;
297+ return None ;
310298 }
311299
312300 passes:: write_dep_info ( tcx) ;
@@ -316,11 +304,11 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
316304 if sess. opts . output_types . contains_key ( & OutputType :: DepInfo )
317305 && sess. opts . output_types . len ( ) == 1
318306 {
319- return early_exit ( ) ;
307+ return None ;
320308 }
321309
322310 if sess. opts . unstable_opts . no_analysis {
323- return early_exit ( ) ;
311+ return None ;
324312 }
325313
326314 tcx. ensure_ok ( ) . analysis ( ( ) ) ;
@@ -330,16 +318,16 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
330318 }
331319
332320 if callbacks. after_analysis ( compiler, tcx) == Compilation :: Stop {
333- return early_exit ( ) ;
321+ return None ;
334322 }
335323
336- if tcx . sess . opts . output_types . contains_key ( & OutputType :: Mir ) {
324+ if sess. opts . output_types . contains_key ( & OutputType :: Mir ) {
337325 if let Err ( error) = pretty:: emit_mir ( tcx) {
338326 tcx. dcx ( ) . emit_fatal ( CantEmitMIR { error } ) ;
339327 }
340328 }
341329
342- let linker = Linker :: codegen_and_build_linker ( tcx, & * compiler . codegen_backend ) ;
330+ let linker = Linker :: codegen_and_build_linker ( tcx, codegen_backend) ;
343331
344332 tcx. report_unused_features ( ) ;
345333
0 commit comments