Skip to content

Commit c636ded

Browse files
committed
Improve the information provided when this assertion fails.
1 parent fefe816 commit c636ded

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/librustc_mir/borrow_check/borrow_set.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,14 +333,21 @@ impl<'a, 'gcx, 'tcx> GatherBorrows<'a, 'gcx, 'tcx> {
333333

334334
// Consider the borrow not activated to start. When we find an activation, we'll update
335335
// this field.
336-
let borrow_data = &mut self.idx_vec[borrow_index];
337-
borrow_data.activation_location = TwoPhaseActivation::NotActivated;
336+
{
337+
let borrow_data = &mut self.idx_vec[borrow_index];
338+
borrow_data.activation_location = TwoPhaseActivation::NotActivated;
339+
}
338340

339341
// Insert `temp` into the list of pending activations. From
340342
// now on, we'll be on the lookout for a use of it. Note that
341343
// we are guaranteed that this use will come after the
342344
// assignment.
343345
let old_value = self.pending_activations.insert(temp, borrow_index);
344-
assert!(old_value.is_none());
346+
if let Some(old_index) = old_value {
347+
span_bug!(self.mir.source_info(start_location).span,
348+
"found already pending activation for temp: {:?} \
349+
at borrow_index: {:?} with associated data {:?}",
350+
temp, old_index, self.idx_vec[old_index]);
351+
}
345352
}
346353
}

0 commit comments

Comments
 (0)