Skip to content

Commit 6b43a51

Browse files
Merge #8321
8321: Use exhaustive matches in shrink_to_fit impls r=jonas-schievink a=jonas-schievink bors r+ Co-authored-by: Jonas Schievink <[email protected]>
2 parents 234ddf3 + f774a56 commit 6b43a51

File tree

2 files changed

+38
-13
lines changed

2 files changed

+38
-13
lines changed

crates/hir_def/src/item_scope.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,14 +287,25 @@ impl ItemScope {
287287
}
288288

289289
pub(crate) fn shrink_to_fit(&mut self) {
290-
self.types.shrink_to_fit();
291-
self.values.shrink_to_fit();
292-
self.macros.shrink_to_fit();
293-
self.unresolved.shrink_to_fit();
294-
self.defs.shrink_to_fit();
295-
self.impls.shrink_to_fit();
296-
self.unnamed_trait_imports.shrink_to_fit();
297-
self.legacy_macros.shrink_to_fit();
290+
// Exhaustive match to require handling new fields.
291+
let Self {
292+
types,
293+
values,
294+
macros,
295+
unresolved,
296+
defs,
297+
impls,
298+
unnamed_trait_imports,
299+
legacy_macros,
300+
} = self;
301+
types.shrink_to_fit();
302+
values.shrink_to_fit();
303+
macros.shrink_to_fit();
304+
unresolved.shrink_to_fit();
305+
defs.shrink_to_fit();
306+
impls.shrink_to_fit();
307+
unnamed_trait_imports.shrink_to_fit();
308+
legacy_macros.shrink_to_fit();
298309
}
299310
}
300311

crates/hir_def/src/nameres.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,25 @@ impl DefMap {
411411
}
412412

413413
fn shrink_to_fit(&mut self) {
414-
self.extern_prelude.shrink_to_fit();
415-
self.exported_proc_macros.shrink_to_fit();
416-
self.diagnostics.shrink_to_fit();
417-
self.modules.shrink_to_fit();
418-
for (_, module) in self.modules.iter_mut() {
414+
// Exhaustive match to require handling new fields.
415+
let Self {
416+
_c: _,
417+
exported_proc_macros,
418+
extern_prelude,
419+
diagnostics,
420+
modules,
421+
block: _,
422+
edition: _,
423+
krate: _,
424+
prelude: _,
425+
root: _,
426+
} = self;
427+
428+
extern_prelude.shrink_to_fit();
429+
exported_proc_macros.shrink_to_fit();
430+
diagnostics.shrink_to_fit();
431+
modules.shrink_to_fit();
432+
for (_, module) in modules.iter_mut() {
419433
module.children.shrink_to_fit();
420434
module.scope.shrink_to_fit();
421435
}

0 commit comments

Comments
 (0)