about summary refs log tree commit diff
path: root/src/librustdoc
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2024-10-31 14:43:23 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2024-12-14 14:24:35 +0000
commit6ece8036329ac01eca7724c3b4b691b258d04e16 (patch)
tree999f31984013365fba76f1f7c73f9f995e780d92 /src/librustdoc
parented141926048597e3649bb238ca3dc417904cd56c (diff)
Get rid of of the global_ctxt query
Diffstat (limited to 'src/librustdoc')
-rw-r--r--src/librustdoc/doctest.rs37
-rw-r--r--src/librustdoc/lib.rs4
2 files changed, 22 insertions, 19 deletions
diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs
index 70d9269ae5c..91088820610 100644
--- a/src/librustdoc/doctest.rs
+++ b/src/librustdoc/doctest.rs
@@ -175,23 +175,26 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, input: Input, options: RustdocOptions
         ..
     } = interface::run_compiler(config, |compiler| {
         compiler.enter(|queries| {
-            let collector = queries.global_ctxt().enter(|tcx| {
-                let crate_name = tcx.crate_name(LOCAL_CRATE).to_string();
-                let crate_attrs = tcx.hir().attrs(CRATE_HIR_ID);
-                let opts = scrape_test_config(crate_name, crate_attrs, args_path);
-                let enable_per_target_ignores = options.enable_per_target_ignores;
-
-                let mut collector = CreateRunnableDocTests::new(options, opts);
-                let hir_collector = HirCollector::new(
-                    ErrorCodes::from(compiler.sess.opts.unstable_features.is_nightly_build()),
-                    enable_per_target_ignores,
-                    tcx,
-                );
-                let tests = hir_collector.collect_crate();
-                tests.into_iter().for_each(|t| collector.add_test(t));
-
-                collector
-            });
+            let krate = queries.parse().steal();
+
+            let collector =
+                rustc_interface::create_and_enter_global_ctxt(&compiler, krate, |tcx| {
+                    let crate_name = tcx.crate_name(LOCAL_CRATE).to_string();
+                    let crate_attrs = tcx.hir().attrs(CRATE_HIR_ID);
+                    let opts = scrape_test_config(crate_name, crate_attrs, args_path);
+                    let enable_per_target_ignores = options.enable_per_target_ignores;
+
+                    let mut collector = CreateRunnableDocTests::new(options, opts);
+                    let hir_collector = HirCollector::new(
+                        ErrorCodes::from(compiler.sess.opts.unstable_features.is_nightly_build()),
+                        enable_per_target_ignores,
+                        tcx,
+                    );
+                    let tests = hir_collector.collect_crate();
+                    tests.into_iter().for_each(|t| collector.add_test(t));
+
+                    collector
+                });
             compiler.sess.dcx().abort_if_errors();
 
             collector
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index 5d82b8e309a..777f917bf1d 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -857,12 +857,12 @@ fn main_args(
         }
 
         compiler.enter(|queries| {
-            let mut gcx = queries.global_ctxt();
+            let krate = queries.parse().steal();
             if sess.dcx().has_errors().is_some() {
                 sess.dcx().fatal("Compilation failed, aborting rustdoc");
             }
 
-            gcx.enter(|tcx| {
+            rustc_interface::create_and_enter_global_ctxt(&compiler, krate, |tcx| {
                 let (krate, render_opts, mut cache) = sess.time("run_global_ctxt", || {
                     core::run_global_ctxt(tcx, show_coverage, render_options, output_format)
                 });