Skip to content

Commit 2615288

Browse files
committed
Merge Queries::{ongoing_codegen,linker}.
There is no real need for them to be separate.
1 parent 599c3e2 commit 2615288

File tree

3 files changed

+14
-22
lines changed

3 files changed

+14
-22
lines changed

compiler/rustc_driver_impl/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ fn run_compiler(
453453
return early_exit();
454454
}
455455

456-
let ongoing_codegen = queries.ongoing_codegen()?;
456+
let linker = queries.codegen_and_build_linker()?;
457457

458458
// This must run after monomorphization so that all generic types
459459
// have been instantiated.
@@ -467,7 +467,6 @@ fn run_compiler(
467467
sess.code_stats.print_vtable_sizes(crate_name);
468468
}
469469

470-
let linker = queries.linker(ongoing_codegen)?;
471470
Ok(Some(linker))
472471
})?;
473472

compiler/rustc_interface/src/queries.rs

+12-18
Original file line numberDiff line numberDiff line change
@@ -180,22 +180,6 @@ impl<'tcx> Queries<'tcx> {
180180
})
181181
}
182182

183-
pub fn ongoing_codegen(&'tcx self) -> Result<Box<dyn Any>> {
184-
self.global_ctxt()?.enter(|tcx| {
185-
// Don't do code generation if there were any errors
186-
self.compiler.sess.compile_status()?;
187-
188-
// If we have any delayed bugs, for example because we created TyKind::Error earlier,
189-
// it's likely that codegen will only cause more ICEs, obscuring the original problem
190-
self.compiler.sess.diagnostic().flush_delayed();
191-
192-
// Hook for UI tests.
193-
Self::check_for_rustc_errors_attr(tcx);
194-
195-
Ok(passes::start_codegen(&*self.compiler.codegen_backend, tcx))
196-
})
197-
}
198-
199183
/// Check for the `#[rustc_error]` annotation, which forces an error in codegen. This is used
200184
/// to write UI tests that actually test that compilation succeeds without reporting
201185
/// an error.
@@ -230,8 +214,18 @@ impl<'tcx> Queries<'tcx> {
230214
}
231215
}
232216

233-
pub fn linker(&'tcx self, ongoing_codegen: Box<dyn Any>) -> Result<Linker> {
217+
pub fn codegen_and_build_linker(&'tcx self) -> Result<Linker> {
234218
self.global_ctxt()?.enter(|tcx| {
219+
// Don't do code generation if there were any errors
220+
self.compiler.sess.compile_status()?;
221+
222+
// If we have any delayed bugs, for example because we created TyKind::Error earlier,
223+
// it's likely that codegen will only cause more ICEs, obscuring the original problem
224+
self.compiler.sess.diagnostic().flush_delayed();
225+
226+
// Hook for UI tests.
227+
Self::check_for_rustc_errors_attr(tcx);
228+
235229
Ok(Linker {
236230
dep_graph: tcx.dep_graph.clone(),
237231
output_filenames: tcx.output_filenames(()).clone(),
@@ -240,7 +234,7 @@ impl<'tcx> Queries<'tcx> {
240234
} else {
241235
None
242236
},
243-
ongoing_codegen,
237+
ongoing_codegen: passes::start_codegen(&*self.compiler.codegen_backend, tcx),
244238
})
245239
})
246240
}

tests/run-make-fulldeps/issue-19371/foo.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ fn compile(code: String, output: PathBuf, sysroot: PathBuf) {
6969
interface::run_compiler(config, |compiler| {
7070
let linker = compiler.enter(|queries| {
7171
queries.global_ctxt()?.enter(|tcx| tcx.analysis(()))?;
72-
let ongoing_codegen = queries.ongoing_codegen()?;
73-
queries.linker(ongoing_codegen)
72+
queries.codegen_and_build_linker()
7473
});
7574
linker.unwrap().link(&compiler.sess, &*compiler.codegen_backend).unwrap();
7675
});

0 commit comments

Comments
 (0)