File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -146,7 +146,13 @@ pub(super) fn run_aot(
146146) -> Box < ( CodegenResults , FxHashMap < WorkProductId , WorkProduct > ) > {
147147 let mut work_products = FxHashMap :: default ( ) ;
148148
149- let ( _, cgus) = tcx. collect_and_partition_mono_items ( LOCAL_CRATE ) ;
149+ let cgus = if tcx. sess . opts . output_types . should_codegen ( ) {
150+ tcx. collect_and_partition_mono_items ( LOCAL_CRATE ) . 1
151+ } else {
152+ // If only `--emit metadata` is used, we shouldn't perform any codegen.
153+ // Also `tcx.collect_and_partition_mono_items` may panic in that case.
154+ & [ ]
155+ } ;
150156
151157 if tcx. dep_graph . is_fully_enabled ( ) {
152158 for cgu in & * cgus {
@@ -239,6 +245,10 @@ pub(super) fn run_aot(
239245 None
240246 } ;
241247
248+ if tcx. sess . opts . output_types . should_codegen ( ) {
249+ rustc_incremental:: assert_module_sources:: assert_module_sources ( tcx) ;
250+ }
251+
242252 Box :: new ( ( CodegenResults {
243253 crate_name : tcx. crate_name ( LOCAL_CRATE ) ,
244254 modules,
Original file line number Diff line number Diff line change @@ -39,6 +39,10 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
3939 . declare_function ( "main" , Linkage :: Import , & sig)
4040 . unwrap ( ) ;
4141
42+ if !tcx. sess . opts . output_types . should_codegen ( ) {
43+ tcx. sess . fatal ( "JIT mode doesn't work with `cargo check`." ) ;
44+ }
45+
4246 let ( _, cgus) = tcx. collect_and_partition_mono_items ( LOCAL_CRATE ) ;
4347 let mono_items = cgus
4448 . iter ( )
Original file line number Diff line number Diff line change @@ -200,7 +200,6 @@ impl CodegenBackend for CraneliftCodegenBackend {
200200 ) -> Box < dyn Any > {
201201 let res = driver:: codegen_crate ( tcx, metadata, need_metadata_module) ;
202202
203- rustc_incremental:: assert_module_sources:: assert_module_sources ( tcx) ;
204203 rustc_symbol_mangling:: test:: report_symbol_names ( tcx) ;
205204
206205 res
You can’t perform that action at this time.
0 commit comments