From f774a56af20537f8a1e1da7ec98584bee8ceb635 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sun, 4 Apr 2021 02:56:11 +0200 Subject: Use exhaustive matches in shrink_to_fit impls --- crates/hir_def/src/nameres.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'crates/hir_def/src/nameres.rs') diff --git a/crates/hir_def/src/nameres.rs b/crates/hir_def/src/nameres.rs index 6a09ad420..7dd68219f 100644 --- a/crates/hir_def/src/nameres.rs +++ b/crates/hir_def/src/nameres.rs @@ -411,11 +411,25 @@ impl DefMap { } fn shrink_to_fit(&mut self) { - self.extern_prelude.shrink_to_fit(); - self.exported_proc_macros.shrink_to_fit(); - self.diagnostics.shrink_to_fit(); - self.modules.shrink_to_fit(); - for (_, module) in self.modules.iter_mut() { + // Exhaustive match to require handling new fields. + let Self { + _c: _, + exported_proc_macros, + extern_prelude, + diagnostics, + modules, + block: _, + edition: _, + krate: _, + prelude: _, + root: _, + } = self; + + extern_prelude.shrink_to_fit(); + exported_proc_macros.shrink_to_fit(); + diagnostics.shrink_to_fit(); + modules.shrink_to_fit(); + for (_, module) in modules.iter_mut() { module.children.shrink_to_fit(); module.scope.shrink_to_fit(); } -- cgit v1.2.3