From 8eccc63c46503adbc6ba91034324963b69a7523b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 28 Apr 2023 23:37:10 -0500 Subject: [PATCH] Fix tests in `--release` mode (#6308) Add `#[cfg]` annotations to some tests which rely on `debug_assert!` for panics. --- cranelift/codegen/src/ir/builder.rs | 5 ++++- cranelift/entity/src/lib.rs | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cranelift/codegen/src/ir/builder.rs b/cranelift/codegen/src/ir/builder.rs index e4c434cbf3..0b640e7606 100644 --- a/cranelift/codegen/src/ir/builder.rs +++ b/cranelift/codegen/src/ir/builder.rs @@ -218,7 +218,7 @@ mod tests { use crate::cursor::{Cursor, FuncCursor}; use crate::ir::condcodes::*; use crate::ir::types::*; - use crate::ir::{Function, InstBuilder, Opcode, TrapCode, ValueDef}; + use crate::ir::{Function, InstBuilder, ValueDef}; #[test] fn types() { @@ -266,7 +266,10 @@ mod tests { #[test] #[should_panic] + #[cfg(debug_assertions)] fn panics_when_inserting_wrong_opcode() { + use crate::ir::{Opcode, TrapCode}; + let mut func = Function::new(); let block0 = func.dfg.make_block(); let mut pos = FuncCursor::new(&mut func); diff --git a/cranelift/entity/src/lib.rs b/cranelift/entity/src/lib.rs index 02cf7e7a55..34fa46acdd 100644 --- a/cranelift/entity/src/lib.rs +++ b/cranelift/entity/src/lib.rs @@ -254,6 +254,7 @@ mod tests { } #[should_panic] + #[cfg(debug_assertions)] #[test] fn cannot_construct_from_reserved_u32() { use crate::packed_option::ReservedValue; @@ -262,6 +263,7 @@ mod tests { } #[should_panic] + #[cfg(debug_assertions)] #[test] fn cannot_construct_from_reserved_usize() { use crate::packed_option::ReservedValue;