From e980f19c9367871ac42864730f4a26728e68e6dd Mon Sep 17 00:00:00 2001 From: David Mak Date: Tue, 19 Mar 2024 18:22:41 +0800 Subject: [PATCH] core: Simplify typed value assertions --- nac3core/src/codegen/classes.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/nac3core/src/codegen/classes.rs b/nac3core/src/codegen/classes.rs index ff492c78..b74a2cdf 100644 --- a/nac3core/src/codegen/classes.rs +++ b/nac3core/src/codegen/classes.rs @@ -16,9 +16,7 @@ pub fn assert_is_list<'ctx>(_value: PointerValue<'ctx>, _llvm_usize: IntType<'ct #[cfg(debug_assertions)] pub fn assert_is_list<'ctx>(value: PointerValue<'ctx>, llvm_usize: IntType<'ctx>) { - if let Err(msg) = ListValue::is_instance(value, llvm_usize) { - panic!("{msg}") - } + ListValue::is_instance(value, llvm_usize).unwrap(); } /// Proxy type for accessing a `list` value in LLVM. @@ -254,9 +252,7 @@ pub fn assert_is_range(_value: PointerValue) {} #[cfg(debug_assertions)] pub fn assert_is_range(value: PointerValue) { - if let Err(msg) = RangeValue::is_instance(value) { - panic!("{msg}") - } + RangeValue::is_instance(value).unwrap(); } /// Proxy type for accessing a `range` value in LLVM. @@ -425,9 +421,7 @@ pub fn assert_is_ndarray<'ctx>(_value: PointerValue<'ctx>, _llvm_usize: IntType< #[cfg(debug_assertions)] pub fn assert_is_ndarray<'ctx>(value: PointerValue<'ctx>, llvm_usize: IntType<'ctx>) { - if let Err(msg) = NDArrayValue::is_instance(value, llvm_usize) { - panic!("{msg}") - } + NDArrayValue::is_instance(value, llvm_usize).unwrap(); } /// Proxy type for accessing an `NDArray` value in LLVM.