diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2024-10-31 15:46:11 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2024-12-14 14:24:49 +0000 |
| commit | 87802536f4abb1792994becc5bd66110fe5db8fa (patch) | |
| tree | bb61bdc56caf92e4d91ca0f6f8c21817ef93f907 /compiler/rustc_driver_impl | |
| parent | 6ece8036329ac01eca7724c3b4b691b258d04e16 (diff) | |
| download | rust-87802536f4abb1792994becc5bd66110fe5db8fa.tar.gz rust-87802536f4abb1792994becc5bd66110fe5db8fa.zip | |
Remove the parse query
Diffstat (limited to 'compiler/rustc_driver_impl')
| -rw-r--r-- | compiler/rustc_driver_impl/src/lib.rs | 99 |
1 files changed, 44 insertions, 55 deletions
diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 397e477d471..536eeb5a846 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -387,80 +387,69 @@ fn run_compiler( return early_exit(); } - let linker = compiler.enter(|queries| { + // Parse the crate root source code (doesn't parse submodules yet) + // Everything else is parsed during macro expansion. + let krate = passes::parse(sess); + + // If pretty printing is requested: Figure out the representation, print it and exit + if let Some(pp_mode) = sess.opts.pretty { + if pp_mode.needs_ast_map() { + create_and_enter_global_ctxt(&compiler, krate, |tcx| { + tcx.ensure().early_lint_checks(()); + pretty::print(sess, pp_mode, pretty::PrintExtra::NeedsAstMap { tcx }); + passes::write_dep_info(tcx); + }); + } else { + pretty::print(sess, pp_mode, pretty::PrintExtra::AfterParsing { krate: &krate }); + } + trace!("finished pretty-printing"); + return early_exit(); + } + + if callbacks.after_crate_root_parsing(compiler, &krate) == Compilation::Stop { + return early_exit(); + } + + if sess.opts.unstable_opts.parse_crate_root_only { + return early_exit(); + } + + let linker = create_and_enter_global_ctxt(&compiler, krate, |tcx| { let early_exit = || { sess.dcx().abort_if_errors(); None }; - // Parse the crate root source code (doesn't parse submodules yet) - // Everything else is parsed during macro expansion. - queries.parse(); + // Make sure name resolution and macro expansion is run. + let _ = tcx.resolver_for_lowering(); - // If pretty printing is requested: Figure out the representation, print it and exit - if let Some(pp_mode) = sess.opts.pretty { - if pp_mode.needs_ast_map() { - let krate = queries.parse().steal(); + if let Some(metrics_dir) = &sess.opts.unstable_opts.metrics_dir { + dump_feature_usage_metrics(tcx, metrics_dir); + } - create_and_enter_global_ctxt(&compiler, krate, |tcx| { - tcx.ensure().early_lint_checks(()); - pretty::print(sess, pp_mode, pretty::PrintExtra::NeedsAstMap { tcx }); - passes::write_dep_info(tcx); - }); - } else { - let krate = queries.parse(); - pretty::print(sess, pp_mode, pretty::PrintExtra::AfterParsing { - krate: &*krate.borrow(), - }); - } - trace!("finished pretty-printing"); + if callbacks.after_expansion(compiler, tcx) == Compilation::Stop { return early_exit(); } - if callbacks.after_crate_root_parsing(compiler, &*queries.parse().borrow()) - == Compilation::Stop + passes::write_dep_info(tcx); + + if sess.opts.output_types.contains_key(&OutputType::DepInfo) + && sess.opts.output_types.len() == 1 { return early_exit(); } - if sess.opts.unstable_opts.parse_crate_root_only { + if sess.opts.unstable_opts.no_analysis { return early_exit(); } - let krate = queries.parse().steal(); + tcx.ensure().analysis(()); - create_and_enter_global_ctxt(&compiler, krate, |tcx| { - // Make sure name resolution and macro expansion is run. - let _ = tcx.resolver_for_lowering(); - - if let Some(metrics_dir) = &sess.opts.unstable_opts.metrics_dir { - dump_feature_usage_metrics(tcx, metrics_dir); - } - - if callbacks.after_expansion(compiler, tcx) == Compilation::Stop { - return early_exit(); - } - - passes::write_dep_info(tcx); - - if sess.opts.output_types.contains_key(&OutputType::DepInfo) - && sess.opts.output_types.len() == 1 - { - return early_exit(); - } - - if sess.opts.unstable_opts.no_analysis { - return early_exit(); - } - - tcx.ensure().analysis(()); - - if callbacks.after_analysis(compiler, tcx) == Compilation::Stop { - return early_exit(); - } + if callbacks.after_analysis(compiler, tcx) == Compilation::Stop { + return early_exit(); + } - Some(Linker::codegen_and_build_linker(tcx, &*compiler.codegen_backend)) - }) + Some(Linker::codegen_and_build_linker(tcx, &*compiler.codegen_backend)) }); // Linking is done outside the `compiler.enter()` so that the |
