diff options
| author | bors <bors@rust-lang.org> | 2023-04-21 17:28:37 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-04-21 17:28:37 +0000 |
| commit | fa4cc63a6bd6f32903269e52b8f59b284d0e76c4 (patch) | |
| tree | bc92bd2b66d8b30464253995ad5b07aea9d5edc4 /compiler/rustc_interface/src | |
| parent | 4a03f14b099bf19f0124872b3f6d99ef00db7902 (diff) | |
| parent | 7e214bfc8a550e4dc37c46c236676791ccb1fcc9 (diff) | |
| download | rust-fa4cc63a6bd6f32903269e52b8f59b284d0e76c4.tar.gz rust-fa4cc63a6bd6f32903269e52b8f59b284d0e76c4.zip | |
Auto merge of #110107 - cjgillot:const-prop-lint-junk, r=oli-obk
Ensure mir_drops_elaborated_and_const_checked when requiring codegen. mir_drops_elaborated_and_const_checked may emit errors while codegen has started, and the compiler would exit leaving object code files around. Found by `@cuviper` in https://github.com/rust-lang/rust/issues/109731
Diffstat (limited to 'compiler/rustc_interface/src')
| -rw-r--r-- | compiler/rustc_interface/src/passes.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 5fe9d344654..de78f26eec6 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -794,8 +794,14 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> { } tcx.ensure().has_ffi_unwind_calls(def_id); - if tcx.hir().body_const_context(def_id).is_some() { + // If we need to codegen, ensure that we emit all errors from + // `mir_drops_elaborated_and_const_checked` now, to avoid discovering + // them later during codegen. + if tcx.sess.opts.output_types.should_codegen() + || tcx.hir().body_const_context(def_id).is_some() + { tcx.ensure().mir_drops_elaborated_and_const_checked(def_id); + tcx.ensure().unused_generic_params(ty::InstanceDef::Item(def_id.to_def_id())); } } }); |
