Browse Source

Fix debug asserts for dwarf transform (#1413)

* Fix debug asserts for dwarf transform

* feedback
pull/1398/head
Yury Delendik 5 years ago
committed by GitHub
parent
commit
27bf044ca2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      crates/debug/src/transform/address_transform.rs

13
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));
}

Loading…
Cancel
Save