Skip to content

Commit e824550

Browse files
rylevmichaelwoerister
authored andcommitted
Fix wrong unreachable code in summarize aggregate
1 parent 2f68b69 commit e824550

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

summarize/src/aggregate.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ struct SamplePoints<'a> {
138138
/// so we just have to find the *only* thread's ID and require there is no other.
139139
expected_thread_id: u32,
140140

141+
/// Reversed events that do not contain integer payloads
141142
rev_events: std::iter::Peekable<Box<dyn Iterator<Item = Event<'a>> + 'a>>,
142143
stack: Vec<Event<'a>>,
143144
}
@@ -165,7 +166,11 @@ impl<'a> BackwardsIterator for SamplePoints<'a> {
165166
type Item = SamplePoint<WithParent<Event<'a>>>;
166167
fn next_back(&mut self) -> Option<Self::Item> {
167168
let sample_point = match self.rev_events.peek() {
168-
Some(peeked_event) if !peeked_event.payload.is_integer() => {
169+
Some(peeked_event) => {
170+
assert!(
171+
!peeked_event.payload.is_integer(),
172+
"Integer events accidentally included in `SamplePoints` events"
173+
);
169174
assert_eq!(
170175
peeked_event.thread_id, self.expected_thread_id,
171176
"more than one thread is not supported in `summarize aggregate`"
@@ -177,8 +182,6 @@ impl<'a> BackwardsIterator for SamplePoints<'a> {
177182
Some(top_event) if !top_event.contains(peeked_event) => {
178183
SamplePoint::Start(self.stack.pop().unwrap())
179184
}
180-
Some(_) => unreachable!(),
181-
182185
_ => {
183186
let event = self.rev_events.next().unwrap();
184187
match event.payload {
@@ -198,7 +201,6 @@ impl<'a> BackwardsIterator for SamplePoints<'a> {
198201
}
199202
}
200203
}
201-
Some(_) => unreachable!(),
202204

203205
// Ran out of events, but we might still have stack entries to leave.
204206
None => SamplePoint::Start(self.stack.pop()?),

0 commit comments

Comments
 (0)