use truncate, not pop (#1837)

This commit is contained in:
Addison Crump 2024-02-05 20:48:17 +01:00 committed by GitHub
parent 054d0a6b19
commit c3473e5631
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -556,13 +556,7 @@ impl<I, C, R, SC> HasCurrentStage for StdState<I, C, R, SC> {
}
fn clear_stage(&mut self) -> Result<(), Error> {
self.stage_idx_stack.pop();
// ensure we are in the right frame
if self.stage_depth != self.stage_idx_stack.len() {
return Err(Error::illegal_state(
"we somehow cleared too many or too few states!",
));
}
self.stage_idx_stack.truncate(self.stage_depth);
Ok(())
}