about summary refs log tree commit diff
path: root/compiler/rustc_interface/src/queries.rs
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2024-06-30 18:44:11 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2024-07-01 11:00:49 +0000
commitbd2ff518cefe1dc9e1dcd328319eead618eed67a (patch)
tree8fc97ce9b86546600f4752a97a396abcedf988e2 /compiler/rustc_interface/src/queries.rs
parent8127461b0ed54dea8ca9cf430b1d231611e1b477 (diff)
downloadrust-bd2ff518cefe1dc9e1dcd328319eead618eed67a.tar.gz
rust-bd2ff518cefe1dc9e1dcd328319eead618eed67a.zip
Move codegen_and_build_linker from Queries to Linker
Diffstat (limited to 'compiler/rustc_interface/src/queries.rs')
-rw-r--r--compiler/rustc_interface/src/queries.rs59
1 files changed, 30 insertions, 29 deletions
diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs
index 5f00d7a76b2..e78576c8e43 100644
--- a/compiler/rustc_interface/src/queries.rs
+++ b/compiler/rustc_interface/src/queries.rs
@@ -116,35 +116,6 @@ impl<'tcx> Queries<'tcx> {
             )
         })
     }
-
-    pub fn codegen_and_build_linker(&'tcx self) -> Result<Linker> {
-        self.global_ctxt()?.enter(|tcx| {
-            let ongoing_codegen = passes::start_codegen(&*self.compiler.codegen_backend, tcx)?;
-
-            // This must run after monomorphization so that all generic types
-            // have been instantiated.
-            if tcx.sess.opts.unstable_opts.print_type_sizes {
-                tcx.sess.code_stats.print_type_sizes();
-            }
-
-            if tcx.sess.opts.unstable_opts.print_vtable_sizes {
-                let crate_name = tcx.crate_name(LOCAL_CRATE);
-
-                tcx.sess.code_stats.print_vtable_sizes(crate_name);
-            }
-
-            Ok(Linker {
-                dep_graph: tcx.dep_graph.clone(),
-                output_filenames: tcx.output_filenames(()).clone(),
-                crate_hash: if tcx.needs_crate_hash() {
-                    Some(tcx.crate_hash(LOCAL_CRATE))
-                } else {
-                    None
-                },
-                ongoing_codegen,
-            })
-        })
-    }
 }
 
 pub struct Linker {
@@ -156,6 +127,36 @@ pub struct Linker {
 }
 
 impl Linker {
+    pub fn codegen_and_build_linker(
+        tcx: TyCtxt<'_>,
+        codegen_backend: &dyn CodegenBackend,
+    ) -> Result<Linker> {
+        let ongoing_codegen = passes::start_codegen(codegen_backend, tcx)?;
+
+        // This must run after monomorphization so that all generic types
+        // have been instantiated.
+        if tcx.sess.opts.unstable_opts.print_type_sizes {
+            tcx.sess.code_stats.print_type_sizes();
+        }
+
+        if tcx.sess.opts.unstable_opts.print_vtable_sizes {
+            let crate_name = tcx.crate_name(LOCAL_CRATE);
+
+            tcx.sess.code_stats.print_vtable_sizes(crate_name);
+        }
+
+        Ok(Linker {
+            dep_graph: tcx.dep_graph.clone(),
+            output_filenames: tcx.output_filenames(()).clone(),
+            crate_hash: if tcx.needs_crate_hash() {
+                Some(tcx.crate_hash(LOCAL_CRATE))
+            } else {
+                None
+            },
+            ongoing_codegen,
+        })
+    }
+
     pub fn link(self, sess: &Session, codegen_backend: &dyn CodegenBackend) -> Result<()> {
         let (codegen_results, work_products) =
             codegen_backend.join_codegen(self.ongoing_codegen, sess, &self.output_filenames);