File tree 3 files changed +15
-2
lines changed
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(
146
146
) -> Box < ( CodegenResults , FxHashMap < WorkProductId , WorkProduct > ) > {
147
147
let mut work_products = FxHashMap :: default ( ) ;
148
148
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
+ } ;
150
156
151
157
if tcx. dep_graph . is_fully_enabled ( ) {
152
158
for cgu in & * cgus {
@@ -239,6 +245,10 @@ pub(super) fn run_aot(
239
245
None
240
246
} ;
241
247
248
+ if tcx. sess . opts . output_types . should_codegen ( ) {
249
+ rustc_incremental:: assert_module_sources:: assert_module_sources ( tcx) ;
250
+ }
251
+
242
252
Box :: new ( ( CodegenResults {
243
253
crate_name : tcx. crate_name ( LOCAL_CRATE ) ,
244
254
modules,
Original file line number Diff line number Diff line change @@ -39,6 +39,10 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
39
39
. declare_function ( "main" , Linkage :: Import , & sig)
40
40
. unwrap ( ) ;
41
41
42
+ if !tcx. sess . opts . output_types . should_codegen ( ) {
43
+ tcx. sess . fatal ( "JIT mode doesn't work with `cargo check`." ) ;
44
+ }
45
+
42
46
let ( _, cgus) = tcx. collect_and_partition_mono_items ( LOCAL_CRATE ) ;
43
47
let mono_items = cgus
44
48
. iter ( )
Original file line number Diff line number Diff line change @@ -200,7 +200,6 @@ impl CodegenBackend for CraneliftCodegenBackend {
200
200
) -> Box < dyn Any > {
201
201
let res = driver:: codegen_crate ( tcx, metadata, need_metadata_module) ;
202
202
203
- rustc_incremental:: assert_module_sources:: assert_module_sources ( tcx) ;
204
203
rustc_symbol_mangling:: test:: report_symbol_names ( tcx) ;
205
204
206
205
res
You can’t perform that action at this time.
0 commit comments