From 27bf044ca282abf9814e5519f0ed15b84dcc32eb Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Thu, 26 Mar 2020 12:25:26 -0500 Subject: [PATCH] Fix debug asserts for dwarf transform (#1413) * Fix debug asserts for dwarf transform * feedback --- crates/debug/src/transform/address_transform.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/debug/src/transform/address_transform.rs b/crates/debug/src/transform/address_transform.rs index bd49358eeb..c89c9ea92b 100644 --- a/crates/debug/src/transform/address_transform.rs +++ b/crates/debug/src/transform/address_transform.rs @@ -357,6 +357,7 @@ pub struct TransformRangeIter<'a> { end_it: TransformRangeEndIter<'a>, last_start: Option<(GeneratedAddress, RangeIndex)>, last_end: Option<(GeneratedAddress, RangeIndex)>, + last_item: Option<(GeneratedAddress, GeneratedAddress)>, } impl<'a> TransformRangeIter<'a> { @@ -371,6 +372,7 @@ impl<'a> TransformRangeIter<'a> { end_it, last_start, last_end, + last_item: None, } } } @@ -409,9 +411,6 @@ impl<'a> Iterator for TransformRangeIter<'a> { Some(range_start) => { // Consume start iterator. self.last_start = self.start_it.next(); - debug_assert!( - self.last_start.is_none() || range_start < self.last_start.unwrap().0 - ); range_start } None => { @@ -423,7 +422,6 @@ impl<'a> Iterator for TransformRangeIter<'a> { Some(range_end) => { // Consume end iterator. self.last_end = self.end_it.next(); - debug_assert!(self.last_end.is_none() || range_end < self.last_end.unwrap().0); range_end } None => { @@ -432,6 +430,13 @@ impl<'a> Iterator for TransformRangeIter<'a> { } }; + if cfg!(debug_assertions) { + match self.last_item.replace((range_start, range_end)) { + Some((_, last_end)) => debug_assert!(last_end <= range_start), + None => (), + } + } + if range_start < range_end { return Some((range_start, range_end)); }