Only enable library UB checks in const-eval/Miri when debug_assertions are enabled

Co-authored-by: Ralf Jung <post@ralfj.de>
This commit is contained in:
Ben Kimock 2024-03-09 11:34:15 -05:00 committed by GitHub
parent 50d0bea153
commit 27cf4bb985
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 // But we want to disable checks for language UB, because the interpreter
// has its own better checks for that. // has its own better checks for that.
let should_check = match kind { let should_check = match kind {
mir::UbKind::LibraryUb => true, mir::UbKind::LibraryUb => self.tcx.sess.opts.debug_assertions,
mir::UbKind::LanguageUb => false, mir::UbKind::LanguageUb => false,
}; };
Scalar::from_bool(should_check) Scalar::from_bool(should_check)