Skip to content

Commit ab3f37e

Browse files
committed
Free some memory instead of just dropping elements
1 parent 55f7662 commit ab3f37e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/librustc/traits/select.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3789,14 +3789,16 @@ impl<'tcx> TraitObligation<'tcx> {
37893789
}
37903790

37913791
impl<'tcx> SelectionCache<'tcx> {
3792+
/// Actually frees the underlying memory in contrast to what stdlib containers do on `clear`
37923793
pub fn clear(&self) {
3793-
self.hashmap.borrow_mut().clear();
3794+
*self.hashmap.borrow_mut() = Default::default();
37943795
}
37953796
}
37963797

37973798
impl<'tcx> EvaluationCache<'tcx> {
3799+
/// Actually frees the underlying memory in contrast to what stdlib containers do on `clear`
37983800
pub fn clear(&self) {
3799-
self.hashmap.borrow_mut().clear();
3801+
*self.hashmap.borrow_mut() = Default::default();
38003802
}
38013803
}
38023804

src/librustc_errors/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,8 @@ impl Handler {
398398
/// tools that want to reuse a `Parser` cleaning the previously emitted diagnostics as well as
399399
/// the overall count of emitted error diagnostics.
400400
pub fn reset_err_count(&self) {
401-
self.emitted_diagnostics.borrow_mut().clear();
401+
// actually frees the underlying memory (which `clear` would not do)
402+
*self.emitted_diagnostics.borrow_mut() = Default::default();
402403
self.err_count.store(0, SeqCst);
403404
}
404405

0 commit comments

Comments
 (0)