summary refs log tree commit diff
path: root/compiler/rustc_interface/src
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2023-04-09 09:42:57 +0000
committerCamille GILLOT <gillot.camille@gmail.com>2023-04-21 16:14:43 +0000
commited7e50e08b67eee7a6d1f4da897f204e3e70c6a0 (patch)
tree6beb52788d114b382b632145d37f4a3894f96666 /compiler/rustc_interface/src
parent409661936f929b254ffc8adb644cf35d1f9765c4 (diff)
downloadrust-ed7e50e08b67eee7a6d1f4da897f204e3e70c6a0.tar.gz
rust-ed7e50e08b67eee7a6d1f4da897f204e3e70c6a0.zip
Ensure mir_drops_elaborated_and_const_checked when requiring codegen.
Diffstat (limited to 'compiler/rustc_interface/src')
-rw-r--r--compiler/rustc_interface/src/passes.rs8
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()));
             }
         }
     });