From ff5a628153a5d29fc1ac76f03cf91639c6cae109 Mon Sep 17 00:00:00 2001 From: Joel Uckelman Date: Fri, 14 Aug 2026 00:56:00 +0100 Subject: [PATCH] Added track_caller to functions called on the way to panics; this way, a failing assert_eq_unordered* macro backtrace will list the line where the macro was called, just like assert_eq! does. --- src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index ec81143..0c8af5d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -265,6 +265,7 @@ pub enum CompareResult { #[cfg(feature = "color")] #[doc(hidden)] #[inline] +#[track_caller] pub fn pass_or_panic(result: CompareResult, msg: Option) { if init_color() { color_pass_or_panic(result, msg) @@ -276,11 +277,13 @@ pub fn pass_or_panic(result: CompareResult, msg: Option) { #[cfg(not(feature = "color"))] #[doc(hidden)] #[inline] +#[track_caller] pub fn pass_or_panic(result: CompareResult, msg: Option) { plain_pass_or_panic(result, msg); } #[cfg(feature = "color")] +#[track_caller] fn color_pass_or_panic(result: CompareResult, msg: Option) { match result { CompareResult::NotEqualDiffElements(in_both, in_left_not_right, in_right_not_left) => { @@ -308,6 +311,7 @@ fn color_pass_or_panic(result: CompareResult, msg: Option) { } } +#[track_caller] fn plain_pass_or_panic(result: CompareResult, msg: Option) { match result { CompareResult::NotEqualDiffElements(in_both, in_left_not_right, in_right_not_left) => {