From 27cf4bb98516c801c8b24d80cd78cd5eee8edaff Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sat, 9 Mar 2024 11:34:15 -0500 Subject: [PATCH] Only enable library UB checks in const-eval/Miri when debug_assertions are enabled Co-authored-by: Ralf Jung --- compiler/rustc_const_eval/src/interpret/step.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs index 752fdc2c6f8..54bac70da38 100644 --- a/compiler/rustc_const_eval/src/interpret/step.rs +++ b/compiler/rustc_const_eval/src/interpret/step.rs @@ -264,7 +264,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // But we want to disable checks for language UB, because the interpreter // has its own better checks for that. let should_check = match kind { - mir::UbKind::LibraryUb => true, + mir::UbKind::LibraryUb => self.tcx.sess.opts.debug_assertions, mir::UbKind::LanguageUb => false, }; Scalar::from_bool(should_check)