diff options
author | Florian Diebold <flodiebold@gmail.com> | 2021-04-04 11:48:10 +0100 |
---|---|---|
committer | Florian Diebold <flodiebold@gmail.com> | 2021-04-04 12:16:39 +0100 |
commit | 584d1c9e5bc39402e2855d0ffa9394ae5a066060 (patch) | |
tree | e225359ace25491de64b57e094689257db74c5a9 /crates/hir_ty/src/infer | |
parent | 505ca65216e7d1ea87a235170106338272b36a10 (diff) |
Replace last uses of SubstsBuilder by TyBuilder
Diffstat (limited to 'crates/hir_ty/src/infer')
-rw-r--r-- | crates/hir_ty/src/infer/expr.rs | 3 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/path.rs | 5 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/unify.rs | 13 |
3 files changed, 7 insertions, 14 deletions
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 9f5624eb0..c584a2c08 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -75,14 +75,13 @@ impl<'a> InferenceContext<'a> { | |||
75 | self.db.trait_data(fn_once_trait).associated_type_by_name(&name![Output])?; | 75 | self.db.trait_data(fn_once_trait).associated_type_by_name(&name![Output])?; |
76 | 76 | ||
77 | let mut arg_tys = vec![]; | 77 | let mut arg_tys = vec![]; |
78 | let parameters = Substitution::builder(num_args) | 78 | let arg_ty = TyBuilder::tuple(num_args) |
79 | .fill(repeat_with(|| { | 79 | .fill(repeat_with(|| { |
80 | let arg = self.table.new_type_var(); | 80 | let arg = self.table.new_type_var(); |
81 | arg_tys.push(arg.clone()); | 81 | arg_tys.push(arg.clone()); |
82 | arg | 82 | arg |
83 | })) | 83 | })) |
84 | .build(); | 84 | .build(); |
85 | let arg_ty = TyKind::Tuple(num_args, parameters).intern(&Interner); | ||
86 | 85 | ||
87 | let projection = { | 86 | let projection = { |
88 | let b = TyBuilder::assoc_type_projection(self.db, output_assoc_type); | 87 | let b = TyBuilder::assoc_type_projection(self.db, output_assoc_type); |
diff --git a/crates/hir_ty/src/infer/path.rs b/crates/hir_ty/src/infer/path.rs index c9219776b..d55ae4900 100644 --- a/crates/hir_ty/src/infer/path.rs +++ b/crates/hir_ty/src/infer/path.rs | |||
@@ -93,16 +93,13 @@ impl<'a> InferenceContext<'a> { | |||
93 | ValueNs::GenericParam(it) => return Some(self.db.const_param_ty(it)), | 93 | ValueNs::GenericParam(it) => return Some(self.db.const_param_ty(it)), |
94 | }; | 94 | }; |
95 | 95 | ||
96 | let ty = self.db.value_ty(typable); | ||
97 | // self_subst is just for the parent | ||
98 | let parent_substs = self_subst.unwrap_or_else(|| Substitution::empty(&Interner)); | 96 | let parent_substs = self_subst.unwrap_or_else(|| Substitution::empty(&Interner)); |
99 | let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver); | 97 | let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver); |
100 | let substs = ctx.substs_from_path(path, typable, true); | 98 | let substs = ctx.substs_from_path(path, typable, true); |
101 | let full_substs = Substitution::builder(substs.len(&Interner)) | 99 | let ty = TyBuilder::value_ty(self.db, typable) |
102 | .use_parent_substs(&parent_substs) | 100 | .use_parent_substs(&parent_substs) |
103 | .fill(substs.interned(&Interner)[parent_substs.len(&Interner)..].iter().cloned()) | 101 | .fill(substs.interned(&Interner)[parent_substs.len(&Interner)..].iter().cloned()) |
104 | .build(); | 102 | .build(); |
105 | let ty = ty.subst(&full_substs); | ||
106 | Some(ty) | 103 | Some(ty) |
107 | } | 104 | } |
108 | 105 | ||
diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index d2496db3b..a04b935ef 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs | |||
@@ -186,14 +186,11 @@ pub(crate) fn unify(tys: &Canonical<(Ty, Ty)>) -> Option<Substitution> { | |||
186 | ); | 186 | ); |
187 | } | 187 | } |
188 | } | 188 | } |
189 | Some( | 189 | Some(Substitution::from_iter( |
190 | Substitution::builder(tys.binders.len(&Interner)) | 190 | &Interner, |
191 | .fill( | 191 | vars.iter(&Interner) |
192 | vars.iter(&Interner) | 192 | .map(|v| table.resolve_ty_completely(v.assert_ty_ref(&Interner).clone())), |
193 | .map(|v| table.resolve_ty_completely(v.assert_ty_ref(&Interner).clone())), | 193 | )) |
194 | ) | ||
195 | .build(), | ||
196 | ) | ||
197 | } | 194 | } |
198 | 195 | ||
199 | #[derive(Clone, Debug)] | 196 | #[derive(Clone, Debug)] |