Skip to content

Commit 06ed7a4

Browse files
committed
Add some asserts.
1 parent 6f353b5 commit 06ed7a4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/cargo/core/compiler/timings.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,24 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
162162

163163
/// Mark that the `.rmeta` file as generated.
164164
pub fn unit_rmeta_finished(&mut self, id: u32, unlocked: Vec<&Unit<'a>>) {
165+
// `id` may not always be active. "fresh" units unconditionally
166+
// generate `Message::Finish`, but this active map only tracks dirty
167+
// units.
165168
if let Some(unit_time) = self.active.get_mut(&id) {
166169
let t = d_as_f64(self.start.elapsed());
167170
unit_time.rmeta_time = Some(t - unit_time.start);
171+
assert!(unit_time.unlocked_rmeta_units.is_empty());
168172
unit_time.unlocked_rmeta_units.extend(unlocked);
169173
}
170174
}
171175

172176
/// Mark that a unit has finished running.
173177
pub fn unit_finished(&mut self, id: u32, unlocked: Vec<&Unit<'a>>) {
178+
// See note above in `unit_rmeta_finished`, this may not always be active.
174179
if let Some(mut unit_time) = self.active.remove(&id) {
175180
let t = d_as_f64(self.start.elapsed());
176181
unit_time.duration = t - unit_time.start;
182+
assert!(unit_time.unlocked_units.is_empty());
177183
unit_time.unlocked_units.extend(unlocked);
178184
if self.report_info {
179185
let msg = format!(

0 commit comments

Comments
 (0)