Skip to content

Commit 2ccebe3

Browse files
fix: replace unwrap_or_else closures in macros to avoid llvm-cov empty function name error
#[macro_export] macros containing closures (|x| ...) cause llvm-cov to emit a "function name is empty" error. Replaced unwrap_or_else(|e| panic!(...)) with match expressions to eliminate closures from macro expansions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b4cb481 commit 2ccebe3

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

vm/src/test_helpers/test_utils.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,36 @@ macro_rules! load_cairo_program {
2323
.join(file!())
2424
.with_file_name($name);
2525

26-
let bytes = std::fs::read(&json_path).unwrap_or_else(|err| {
27-
panic!(
26+
let bytes = match std::fs::read(&json_path) {
27+
Ok(b) => b,
28+
Err(err) => panic!(
2829
"Cairo program not found at {json_path:?}: {err}\n\
2930
Did you run `make cairo_test_suite_programs`?"
30-
)
31-
});
31+
),
32+
};
3233

33-
$crate::types::program::Program::from_bytes(&bytes, None)
34-
.unwrap_or_else(|e| panic!("Failed to parse Cairo program at {json_path:?}: {e}"))
34+
match $crate::types::program::Program::from_bytes(&bytes, None) {
35+
Ok(p) => p,
36+
Err(e) => panic!("Failed to parse Cairo program at {json_path:?}: {e}"),
37+
}
3538
}};
3639
}
3740

3841
/// Asserts that a `MaybeRelocatable` reference equals a value convertible into `MaybeRelocatable`.
3942
#[macro_export]
4043
macro_rules! assert_mr_eq {
4144
($left:expr, $right:expr) => {{
42-
let right_mr = ($right)
43-
.try_into()
44-
.unwrap_or_else(|e| panic!("conversion to MaybeRelocatable failed: {e:?}"));
45+
let right_mr = match ($right).try_into() {
46+
Ok(v) => v,
47+
Err(e) => panic!("conversion to MaybeRelocatable failed: {e:?}"),
48+
};
4549
assert_eq!($left, &right_mr);
4650
}};
4751
($left:expr, $right:expr, $($arg:tt)+) => {{
48-
let right_mr = ($right)
49-
.try_into()
50-
.unwrap_or_else(|e| panic!("conversion to MaybeRelocatable failed: {e:?}"));
52+
let right_mr = match ($right).try_into() {
53+
Ok(v) => v,
54+
Err(e) => panic!("conversion to MaybeRelocatable failed: {e:?}"),
55+
};
5156
assert_eq!($left, &right_mr, $($arg)+);
5257
}};
5358
}

0 commit comments

Comments
 (0)