aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/infer/unify.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-16 16:42:58 +0000
committerGitHub <[email protected]>2020-03-16 16:42:58 +0000
commitadcc89137d3feea8f19fad461bbde6f4bce048e5 (patch)
tree160af959553ce57fdfcbc0a6c79bafcc3611aeea /crates/ra_hir_ty/src/infer/unify.rs
parent648df02953a6ebf87a5876668eceba208687e8a7 (diff)
parent9faea2364dee4fbc9391ad233c570b70256ef002 (diff)
Merge #3584
3584: Switch to dynamic dispatch r=matklad a=matklad Benches are in https://github.com/rust-analyzer/rust-analyzer/issues/1987#issuecomment-598807185 TL;DR: * 33% faster release build * slightly worse/same perf * no changes for debug build * slightly smaller binary cc @flodiebold I genuinely don't know if it is a good idea or not. Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/infer/unify.rs')
-rw-r--r--crates/ra_hir_ty/src/infer/unify.rs18
1 files changed, 7 insertions, 11 deletions
diff --git a/crates/ra_hir_ty/src/infer/unify.rs b/crates/ra_hir_ty/src/infer/unify.rs
index 82b85d570..0bf8fbd63 100644
--- a/crates/ra_hir_ty/src/infer/unify.rs
+++ b/crates/ra_hir_ty/src/infer/unify.rs
@@ -7,10 +7,10 @@ use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue};
7use test_utils::tested_by; 7use test_utils::tested_by;
8 8
9use super::{InferenceContext, Obligation}; 9use super::{InferenceContext, Obligation};
10use crate::{db::HirDatabase, Canonical, InEnvironment, InferTy, Substs, Ty, TypeCtor, TypeWalk}; 10use crate::{Canonical, InEnvironment, InferTy, Substs, Ty, TypeCtor, TypeWalk};
11 11
12impl<'a, D: HirDatabase> InferenceContext<'a, D> { 12impl<'a> InferenceContext<'a> {
13 pub(super) fn canonicalizer<'b>(&'b mut self) -> Canonicalizer<'a, 'b, D> 13 pub(super) fn canonicalizer<'b>(&'b mut self) -> Canonicalizer<'a, 'b>
14 where 14 where
15 'a: 'b, 15 'a: 'b,
16 { 16 {
@@ -18,11 +18,11 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
18 } 18 }
19} 19}
20 20
21pub(super) struct Canonicalizer<'a, 'b, D: HirDatabase> 21pub(super) struct Canonicalizer<'a, 'b>
22where 22where
23 'a: 'b, 23 'a: 'b,
24{ 24{
25 ctx: &'b mut InferenceContext<'a, D>, 25 ctx: &'b mut InferenceContext<'a>,
26 free_vars: Vec<InferTy>, 26 free_vars: Vec<InferTy>,
27 /// A stack of type variables that is used to detect recursive types (which 27 /// A stack of type variables that is used to detect recursive types (which
28 /// are an error, but we need to protect against them to avoid stack 28 /// are an error, but we need to protect against them to avoid stack
@@ -35,7 +35,7 @@ pub(super) struct Canonicalized<T> {
35 free_vars: Vec<InferTy>, 35 free_vars: Vec<InferTy>,
36} 36}
37 37
38impl<'a, 'b, D: HirDatabase> Canonicalizer<'a, 'b, D> 38impl<'a, 'b> Canonicalizer<'a, 'b>
39where 39where
40 'a: 'b, 40 'a: 'b,
41{ 41{
@@ -123,11 +123,7 @@ impl<T> Canonicalized<T> {
123 ty 123 ty
124 } 124 }
125 125
126 pub fn apply_solution( 126 pub fn apply_solution(&self, ctx: &mut InferenceContext<'_>, solution: Canonical<Vec<Ty>>) {
127 &self,
128 ctx: &mut InferenceContext<'_, impl HirDatabase>,
129 solution: Canonical<Vec<Ty>>,
130 ) {
131 // the solution may contain new variables, which we need to convert to new inference vars 127 // the solution may contain new variables, which we need to convert to new inference vars
132 let new_vars = Substs((0..solution.num_vars).map(|_| ctx.table.new_type_var()).collect()); 128 let new_vars = Substs((0..solution.num_vars).map(|_| ctx.table.new_type_var()).collect());
133 for (i, ty) in solution.value.into_iter().enumerate() { 129 for (i, ty) in solution.value.into_iter().enumerate() {