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,25 +236,19 @@ 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(); Ok(Linker {
sess: self.session().clone(),
let (crate_hash, prepare_outputs, dep_graph) = self.global_ctxt()?.enter(|tcx| { codegen_backend: self.codegen_backend().clone(),
( dep_graph: tcx.dep_graph.clone(),
if tcx.needs_crate_hash() { Some(tcx.crate_hash(LOCAL_CRATE)) } else { None }, prepare_outputs: tcx.output_filenames(()).clone(),
tcx.output_filenames(()).clone(), crate_hash: if tcx.needs_crate_hash() {
tcx.dep_graph.clone(), Some(tcx.crate_hash(LOCAL_CRATE))
) } else {
}); None
},
Ok(Linker { ongoing_codegen,
sess, })
codegen_backend,
dep_graph,
prepare_outputs,
crate_hash,
ongoing_codegen,
}) })
} }
} }