diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-04-06 14:43:37 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-06 14:43:37 +0100 |
commit | 7d39b13996e312a8a738ed0dfccab45978fc42f8 (patch) | |
tree | 91761b9bf78d9015fbb6083b9245eb9f6133e234 /crates/hir_ty/src | |
parent | 12e86433ab57ee8b1c96b8da0480fd311752487b (diff) | |
parent | 4e2a6ac7eae3ff193962421cc3c86e5d8f9a7e31 (diff) |
Merge #8364
8364: Memory usage improvements r=jonas-schievink a=alexmaco
These are mostly focused on splitting up enum variants with large size differences between variants by `Box`-ing things up.
In my testing this reduces the memory usage somewhere in the low percentages, even though the measurements are quite noisy.
Co-authored-by: Alexandru Macovei <[email protected]>
Diffstat (limited to 'crates/hir_ty/src')
-rw-r--r-- | crates/hir_ty/src/infer/expr.rs | 10 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/pat.rs | 4 |
2 files changed, 10 insertions, 4 deletions
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index dab137ae1..5b3cdab4e 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -318,7 +318,13 @@ impl<'a> InferenceContext<'a> { | |||
318 | self.normalize_associated_types_in(ret_ty) | 318 | self.normalize_associated_types_in(ret_ty) |
319 | } | 319 | } |
320 | Expr::MethodCall { receiver, args, method_name, generic_args } => self | 320 | Expr::MethodCall { receiver, args, method_name, generic_args } => self |
321 | .infer_method_call(tgt_expr, *receiver, &args, &method_name, generic_args.as_ref()), | 321 | .infer_method_call( |
322 | tgt_expr, | ||
323 | *receiver, | ||
324 | &args, | ||
325 | &method_name, | ||
326 | generic_args.as_deref(), | ||
327 | ), | ||
322 | Expr::Match { expr, arms } => { | 328 | Expr::Match { expr, arms } => { |
323 | let input_ty = self.infer_expr(*expr, &Expectation::none()); | 329 | let input_ty = self.infer_expr(*expr, &Expectation::none()); |
324 | 330 | ||
@@ -399,7 +405,7 @@ impl<'a> InferenceContext<'a> { | |||
399 | TyKind::Never.intern(&Interner) | 405 | TyKind::Never.intern(&Interner) |
400 | } | 406 | } |
401 | Expr::RecordLit { path, fields, spread } => { | 407 | Expr::RecordLit { path, fields, spread } => { |
402 | let (ty, def_id) = self.resolve_variant(path.as_ref()); | 408 | let (ty, def_id) = self.resolve_variant(path.as_deref()); |
403 | if let Some(variant) = def_id { | 409 | if let Some(variant) = def_id { |
404 | self.write_variant_resolution(tgt_expr.into(), variant); | 410 | self.write_variant_resolution(tgt_expr.into(), variant); |
405 | } | 411 | } |
diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index fc2bc3ef8..12431ae07 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs | |||
@@ -174,7 +174,7 @@ impl<'a> InferenceContext<'a> { | |||
174 | TyKind::Ref(mutability, static_lifetime(), subty).intern(&Interner) | 174 | TyKind::Ref(mutability, static_lifetime(), subty).intern(&Interner) |
175 | } | 175 | } |
176 | Pat::TupleStruct { path: p, args: subpats, ellipsis } => self.infer_tuple_struct_pat( | 176 | Pat::TupleStruct { path: p, args: subpats, ellipsis } => self.infer_tuple_struct_pat( |
177 | p.as_ref(), | 177 | p.as_deref(), |
178 | subpats, | 178 | subpats, |
179 | expected, | 179 | expected, |
180 | default_bm, | 180 | default_bm, |
@@ -182,7 +182,7 @@ impl<'a> InferenceContext<'a> { | |||
182 | *ellipsis, | 182 | *ellipsis, |
183 | ), | 183 | ), |
184 | Pat::Record { path: p, args: fields, ellipsis: _ } => { | 184 | Pat::Record { path: p, args: fields, ellipsis: _ } => { |
185 | self.infer_record_pat(p.as_ref(), fields, expected, default_bm, pat) | 185 | self.infer_record_pat(p.as_deref(), fields, expected, default_bm, pat) |
186 | } | 186 | } |
187 | Pat::Path(path) => { | 187 | Pat::Path(path) => { |
188 | // FIXME use correct resolver for the surrounding expression | 188 | // FIXME use correct resolver for the surrounding expression |