diff options
author | Jonas Schievink <[email protected]> | 2021-04-04 01:56:11 +0100 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2021-04-04 01:56:11 +0100 |
commit | f774a56af20537f8a1e1da7ec98584bee8ceb635 (patch) | |
tree | e09d71efea4f64bdf957640111d9f7a037fb6538 /crates | |
parent | 234ddf34c743924a15cca7480fb3b4db4581308e (diff) |
Use exhaustive matches in shrink_to_fit impls
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir_def/src/item_scope.rs | 27 | ||||
-rw-r--r-- | crates/hir_def/src/nameres.rs | 24 |
2 files changed, 38 insertions, 13 deletions
diff --git a/crates/hir_def/src/item_scope.rs b/crates/hir_def/src/item_scope.rs index 4ddfd9ee6..a8ee5eeac 100644 --- a/crates/hir_def/src/item_scope.rs +++ b/crates/hir_def/src/item_scope.rs | |||
@@ -287,14 +287,25 @@ impl ItemScope { | |||
287 | } | 287 | } |
288 | 288 | ||
289 | pub(crate) fn shrink_to_fit(&mut self) { | 289 | pub(crate) fn shrink_to_fit(&mut self) { |
290 | self.types.shrink_to_fit(); | 290 | // Exhaustive match to require handling new fields. |
291 | self.values.shrink_to_fit(); | 291 | let Self { |
292 | self.macros.shrink_to_fit(); | 292 | types, |
293 | self.unresolved.shrink_to_fit(); | 293 | values, |
294 | self.defs.shrink_to_fit(); | 294 | macros, |
295 | self.impls.shrink_to_fit(); | 295 | unresolved, |
296 | self.unnamed_trait_imports.shrink_to_fit(); | 296 | defs, |
297 | self.legacy_macros.shrink_to_fit(); | 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(); | ||
298 | } | 309 | } |
299 | } | 310 | } |
300 | 311 | ||
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 { | |||
411 | } | 411 | } |
412 | 412 | ||
413 | fn shrink_to_fit(&mut self) { | 413 | fn shrink_to_fit(&mut self) { |
414 | self.extern_prelude.shrink_to_fit(); | 414 | // Exhaustive match to require handling new fields. |
415 | self.exported_proc_macros.shrink_to_fit(); | 415 | let Self { |
416 | self.diagnostics.shrink_to_fit(); | 416 | _c: _, |
417 | self.modules.shrink_to_fit(); | 417 | exported_proc_macros, |
418 | for (_, module) in self.modules.iter_mut() { | 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() { | ||
419 | module.children.shrink_to_fit(); | 433 | module.children.shrink_to_fit(); |
420 | module.scope.shrink_to_fit(); | 434 | module.scope.shrink_to_fit(); |
421 | } | 435 | } |