From d7608db14af8be7f0004da1c4cc740ffdb496682 Mon Sep 17 00:00:00 2001 From: Jonas Date: Fri, 30 Sep 2022 14:52:52 +0200 Subject: [PATCH] Try using both types of join --- .../prusti-specs/src/specifications/preparser.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/prusti-contracts/prusti-specs/src/specifications/preparser.rs b/prusti-contracts/prusti-specs/src/specifications/preparser.rs index a29fd343a5d..df45fbad30a 100644 --- a/prusti-contracts/prusti-specs/src/specifications/preparser.rs +++ b/prusti-contracts/prusti-specs/src/specifications/preparser.rs @@ -905,8 +905,15 @@ impl RustOp { } fn join_spans(s1: Span, s2: Span) -> Span { - // This works even when compiled with stable, compared to `s1.join(s2)` - s1.unwrap().join(s2.unwrap()).expect("Failed to join spans!").into() + // Tests don't run in the proc macro context + let is_proc_macro = std::panic::catch_unwind(|| s1.unwrap()).is_ok(); + if is_proc_macro { + // This works even when compiled with stable + s1.unwrap().join(s2.unwrap()).expect("Failed to join spans!").into() + } else { + // During tests we don't care so much about returning a default + s1.join(s2).unwrap_or(s1) + } } #[cfg(test)]