Implement check mode

Fixes #973
This commit is contained in:
bjorn3 2020-04-18 21:13:09 +02:00
parent 5b4a8091d5
commit e64a7ebcb0
3 changed files with 15 additions and 2 deletions

View File

@ -146,7 +146,13 @@ pub(super) fn run_aot(
) -> Box<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>)> {
let mut work_products = FxHashMap::default();
let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE);
let cgus = if tcx.sess.opts.output_types.should_codegen() {
tcx.collect_and_partition_mono_items(LOCAL_CRATE).1
} else {
// If only `--emit metadata` is used, we shouldn't perform any codegen.
// Also `tcx.collect_and_partition_mono_items` may panic in that case.
&[]
};
if tcx.dep_graph.is_fully_enabled() {
for cgu in &*cgus {
@ -239,6 +245,10 @@ pub(super) fn run_aot(
None
};
if tcx.sess.opts.output_types.should_codegen() {
rustc_incremental::assert_module_sources::assert_module_sources(tcx);
}
Box::new((CodegenResults {
crate_name: tcx.crate_name(LOCAL_CRATE),
modules,

View File

@ -39,6 +39,10 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
.declare_function("main", Linkage::Import, &sig)
.unwrap();
if !tcx.sess.opts.output_types.should_codegen() {
tcx.sess.fatal("JIT mode doesn't work with `cargo check`.");
}
let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE);
let mono_items = cgus
.iter()

View File

@ -200,7 +200,6 @@ impl CodegenBackend for CraneliftCodegenBackend {
) -> Box<dyn Any> {
let res = driver::codegen_crate(tcx, metadata, need_metadata_module);
rustc_incremental::assert_module_sources::assert_module_sources(tcx);
rustc_symbol_mangling::test::report_symbol_names(tcx);
res