diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 95683e0613e..39c623de677 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -3789,14 +3789,16 @@ impl<'tcx> TraitObligation<'tcx> { } impl<'tcx> SelectionCache<'tcx> { + /// Actually frees the underlying memory in contrast to what stdlib containers do on `clear` pub fn clear(&self) { - self.hashmap.borrow_mut().clear(); + *self.hashmap.borrow_mut() = Default::default(); } } impl<'tcx> EvaluationCache<'tcx> { + /// Actually frees the underlying memory in contrast to what stdlib containers do on `clear` pub fn clear(&self) { - self.hashmap.borrow_mut().clear(); + *self.hashmap.borrow_mut() = Default::default(); } } diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index f02a5e2bc5d..9bd95e8262f 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -398,7 +398,8 @@ impl Handler { /// tools that want to reuse a `Parser` cleaning the previously emitted diagnostics as well as /// the overall count of emitted error diagnostics. pub fn reset_err_count(&self) { - self.emitted_diagnostics.borrow_mut().clear(); + // actually frees the underlying memory (which `clear` would not do) + *self.emitted_diagnostics.borrow_mut() = Default::default(); self.err_count.store(0, SeqCst); }