Streamline Queries::linker.

This commit is contained in:
Nicholas Nethercote 2023-11-17 08:05:56 +11:00
parent 4770d91093
commit 3560122bfc

View File

@ -236,26 +236,20 @@ fn check_for_rustc_errors_attr(tcx: TyCtxt<'_>) {
} }
pub fn linker(&'tcx self, ongoing_codegen: Box<dyn Any>) -> Result<Linker> { pub fn linker(&'tcx self, ongoing_codegen: Box<dyn Any>) -> Result<Linker> {
let sess = self.session().clone(); self.global_ctxt()?.enter(|tcx| {
let codegen_backend = self.codegen_backend().clone();
let (crate_hash, prepare_outputs, dep_graph) = self.global_ctxt()?.enter(|tcx| {
(
if tcx.needs_crate_hash() { Some(tcx.crate_hash(LOCAL_CRATE)) } else { None },
tcx.output_filenames(()).clone(),
tcx.dep_graph.clone(),
)
});
Ok(Linker { Ok(Linker {
sess, sess: self.session().clone(),
codegen_backend, codegen_backend: self.codegen_backend().clone(),
dep_graph: tcx.dep_graph.clone(),
dep_graph, prepare_outputs: tcx.output_filenames(()).clone(),
prepare_outputs, crate_hash: if tcx.needs_crate_hash() {
crate_hash, Some(tcx.crate_hash(LOCAL_CRATE))
} else {
None
},
ongoing_codegen, ongoing_codegen,
}) })
})
} }
} }