aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-18 14:37:34 +0000
committerGitHub <[email protected]>2020-02-18 14:37:34 +0000
commitcecf25b72f2af84fc1535cf52d6f3c1b52802565 (patch)
tree37c8dde0a459caacae6629da08d86be270469ef5 /crates/ra_hir_ty/src
parenteab80cd961919b9321e1d34343ae3f3adb0502e5 (diff)
parentf6816c253b96e8436f1156d6bd6b0942ee9fb4d3 (diff)
Merge #3220
3220: Fix clippy warnings, update Cargo.toml versions r=matklad a=SomeoneToIgnore In the `cargo xtask lint` ouptut, there were two interesting Clippy warnings that might be interesting to investigate further: * warning: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) * warning: large size difference between variants Co-authored-by: Kirill Bulatov <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src')
-rw-r--r--crates/ra_hir_ty/src/diagnostics.rs2
-rw-r--r--crates/ra_hir_ty/src/expr.rs2
-rw-r--r--crates/ra_hir_ty/src/infer.rs11
-rw-r--r--crates/ra_hir_ty/src/infer/coerce.rs13
-rw-r--r--crates/ra_hir_ty/src/infer/expr.rs36
-rw-r--r--crates/ra_hir_ty/src/infer/pat.rs4
-rw-r--r--crates/ra_hir_ty/src/infer/path.rs47
-rw-r--r--crates/ra_hir_ty/src/infer/unify.rs5
-rw-r--r--crates/ra_hir_ty/src/lib.rs9
-rw-r--r--crates/ra_hir_ty/src/lower.rs22
-rw-r--r--crates/ra_hir_ty/src/method_resolution.rs12
-rw-r--r--crates/ra_hir_ty/src/op.rs24
-rw-r--r--crates/ra_hir_ty/src/test_db.rs7
-rw-r--r--crates/ra_hir_ty/src/tests.rs8
-rw-r--r--crates/ra_hir_ty/src/traits.rs9
-rw-r--r--crates/ra_hir_ty/src/traits/builtin.rs10
-rw-r--r--crates/ra_hir_ty/src/traits/chalk.rs13
17 files changed, 104 insertions, 130 deletions
diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs
index 5054189cc..6eafdc8f6 100644
--- a/crates/ra_hir_ty/src/diagnostics.rs
+++ b/crates/ra_hir_ty/src/diagnostics.rs
@@ -40,7 +40,7 @@ impl Diagnostic for MissingFields {
40 use std::fmt::Write; 40 use std::fmt::Write;
41 let mut message = String::from("Missing structure fields:\n"); 41 let mut message = String::from("Missing structure fields:\n");
42 for field in &self.missed_fields { 42 for field in &self.missed_fields {
43 write!(message, "- {}\n", field).unwrap(); 43 writeln!(message, "- {}", field).unwrap();
44 } 44 }
45 message 45 message
46 } 46 }
diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs
index f752a9f09..0d11b537c 100644
--- a/crates/ra_hir_ty/src/expr.rs
+++ b/crates/ra_hir_ty/src/expr.rs
@@ -138,7 +138,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
138 _ => return, 138 _ => return,
139 }; 139 };
140 140
141 if params.len() == 2 && &params[0] == &mismatch.actual { 141 if params.len() == 2 && params[0] == mismatch.actual {
142 let (_, source_map) = db.body_with_source_map(self.func.into()); 142 let (_, source_map) = db.body_with_source_map(self.func.into());
143 143
144 if let Some(source_ptr) = source_map.expr_syntax(id) { 144 if let Some(source_ptr) = source_map.expr_syntax(id) {
diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs
index a9d958c8b..76069eb9c 100644
--- a/crates/ra_hir_ty/src/infer.rs
+++ b/crates/ra_hir_ty/src/infer.rs
@@ -225,14 +225,14 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
225 coerce_unsized_map: Self::init_coerce_unsized_map(db, &resolver), 225 coerce_unsized_map: Self::init_coerce_unsized_map(db, &resolver),
226 db, 226 db,
227 owner, 227 owner,
228 body: db.body(owner.into()), 228 body: db.body(owner),
229 resolver, 229 resolver,
230 } 230 }
231 } 231 }
232 232
233 fn resolve_all(mut self) -> InferenceResult { 233 fn resolve_all(mut self) -> InferenceResult {
234 // FIXME resolve obligations as well (use Guidance if necessary) 234 // FIXME resolve obligations as well (use Guidance if necessary)
235 let mut result = mem::replace(&mut self.result, InferenceResult::default()); 235 let mut result = std::mem::take(&mut self.result);
236 for ty in result.type_of_expr.values_mut() { 236 for ty in result.type_of_expr.values_mut() {
237 let resolved = self.table.resolve_ty_completely(mem::replace(ty, Ty::Unknown)); 237 let resolved = self.table.resolve_ty_completely(mem::replace(ty, Ty::Unknown));
238 *ty = resolved; 238 *ty = resolved;
@@ -261,7 +261,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
261 } 261 }
262 262
263 fn write_assoc_resolution(&mut self, id: ExprOrPatId, item: AssocItemId) { 263 fn write_assoc_resolution(&mut self, id: ExprOrPatId, item: AssocItemId) {
264 self.result.assoc_resolutions.insert(id, item.into()); 264 self.result.assoc_resolutions.insert(id, item);
265 } 265 }
266 266
267 fn write_pat_ty(&mut self, pat: PatId, ty: Ty) { 267 fn write_pat_ty(&mut self, pat: PatId, ty: Ty) {
@@ -312,9 +312,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
312 for obligation in obligations { 312 for obligation in obligations {
313 let in_env = InEnvironment::new(self.trait_env.clone(), obligation.clone()); 313 let in_env = InEnvironment::new(self.trait_env.clone(), obligation.clone());
314 let canonicalized = self.canonicalizer().canonicalize_obligation(in_env); 314 let canonicalized = self.canonicalizer().canonicalize_obligation(in_env);
315 let solution = self 315 let solution =
316 .db 316 self.db.trait_solve(self.resolver.krate().unwrap(), canonicalized.value.clone());
317 .trait_solve(self.resolver.krate().unwrap().into(), canonicalized.value.clone());
318 317
319 match solution { 318 match solution {
320 Some(Solution::Unique(substs)) => { 319 Some(Solution::Unique(substs)) => {
diff --git a/crates/ra_hir_ty/src/infer/coerce.rs b/crates/ra_hir_ty/src/infer/coerce.rs
index f68a1439f..fb6a51b12 100644
--- a/crates/ra_hir_ty/src/infer/coerce.rs
+++ b/crates/ra_hir_ty/src/infer/coerce.rs
@@ -26,7 +26,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
26 /// Note that it is only possible that one type are coerced to another. 26 /// Note that it is only possible that one type are coerced to another.
27 /// Coercing both types to another least upper bound type is not possible in rustc, 27 /// Coercing both types to another least upper bound type is not possible in rustc,
28 /// which will simply result in "incompatible types" error. 28 /// which will simply result in "incompatible types" error.
29 pub(super) fn coerce_merge_branch<'t>(&mut self, ty1: &Ty, ty2: &Ty) -> Ty { 29 pub(super) fn coerce_merge_branch(&mut self, ty1: &Ty, ty2: &Ty) -> Ty {
30 if self.coerce(ty1, ty2) { 30 if self.coerce(ty1, ty2) {
31 ty2.clone() 31 ty2.clone()
32 } else if self.coerce(ty2, ty1) { 32 } else if self.coerce(ty2, ty1) {
@@ -44,10 +44,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
44 resolver: &Resolver, 44 resolver: &Resolver,
45 ) -> FxHashMap<(TypeCtor, TypeCtor), usize> { 45 ) -> FxHashMap<(TypeCtor, TypeCtor), usize> {
46 let krate = resolver.krate().unwrap(); 46 let krate = resolver.krate().unwrap();
47 let impls = match db.lang_item(krate.into(), "coerce_unsized".into()) { 47 let impls = match db.lang_item(krate, "coerce_unsized".into()) {
48 Some(LangItemTarget::TraitId(trait_)) => { 48 Some(LangItemTarget::TraitId(trait_)) => db.impls_for_trait(krate, trait_),
49 db.impls_for_trait(krate.into(), trait_.into())
50 }
51 _ => return FxHashMap::default(), 49 _ => return FxHashMap::default(),
52 }; 50 };
53 51
@@ -254,15 +252,14 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
254 let unsize_generic_index = { 252 let unsize_generic_index = {
255 let mut index = None; 253 let mut index = None;
256 let mut multiple_param = false; 254 let mut multiple_param = false;
257 field_tys[last_field_id].value.walk(&mut |ty| match ty { 255 field_tys[last_field_id].value.walk(&mut |ty| {
258 &Ty::Bound(idx) => { 256 if let &Ty::Bound(idx) = ty {
259 if index.is_none() { 257 if index.is_none() {
260 index = Some(idx); 258 index = Some(idx);
261 } else if Some(idx) != index { 259 } else if Some(idx) != index {
262 multiple_param = true; 260 multiple_param = true;
263 } 261 }
264 } 262 }
265 _ => {}
266 }); 263 });
267 264
268 if multiple_param { 265 if multiple_param {
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs
index 39d8bc0ca..9d5f75625 100644
--- a/crates/ra_hir_ty/src/infer/expr.rs
+++ b/crates/ra_hir_ty/src/infer/expr.rs
@@ -35,8 +35,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
35 TypeMismatch { expected: expected.ty.clone(), actual: ty.clone() }, 35 TypeMismatch { expected: expected.ty.clone(), actual: ty.clone() },
36 ); 36 );
37 } 37 }
38 let ty = self.resolve_ty_as_possible(ty); 38 self.resolve_ty_as_possible(ty)
39 ty
40 } 39 }
41 40
42 /// Infer type of expression with possibly implicit coerce to the expected type. 41 /// Infer type of expression with possibly implicit coerce to the expected type.
@@ -127,10 +126,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
127 TypeCtor::FnPtr { num_args: sig_tys.len() as u16 - 1 }, 126 TypeCtor::FnPtr { num_args: sig_tys.len() as u16 - 1 },
128 Substs(sig_tys.into()), 127 Substs(sig_tys.into()),
129 ); 128 );
130 let closure_ty = Ty::apply_one( 129 let closure_ty =
131 TypeCtor::Closure { def: self.owner.into(), expr: tgt_expr }, 130 Ty::apply_one(TypeCtor::Closure { def: self.owner, expr: tgt_expr }, sig_ty);
132 sig_ty,
133 );
134 131
135 // Eagerly try to relate the closure type with the expected 132 // Eagerly try to relate the closure type with the expected
136 // type, otherwise we often won't have enough information to 133 // type, otherwise we often won't have enough information to
@@ -157,15 +154,14 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
157 }; 154 };
158 self.register_obligations_for_call(&callee_ty); 155 self.register_obligations_for_call(&callee_ty);
159 self.check_call_arguments(args, &param_tys); 156 self.check_call_arguments(args, &param_tys);
160 let ret_ty = self.normalize_associated_types_in(ret_ty); 157 self.normalize_associated_types_in(ret_ty)
161 ret_ty
162 } 158 }
163 Expr::MethodCall { receiver, args, method_name, generic_args } => self 159 Expr::MethodCall { receiver, args, method_name, generic_args } => self
164 .infer_method_call(tgt_expr, *receiver, &args, &method_name, generic_args.as_ref()), 160 .infer_method_call(tgt_expr, *receiver, &args, &method_name, generic_args.as_ref()),
165 Expr::Match { expr, arms } => { 161 Expr::Match { expr, arms } => {
166 let input_ty = self.infer_expr(*expr, &Expectation::none()); 162 let input_ty = self.infer_expr(*expr, &Expectation::none());
167 163
168 let mut result_ty = if arms.len() == 0 { 164 let mut result_ty = if arms.is_empty() {
169 Ty::simple(TypeCtor::Never) 165 Ty::simple(TypeCtor::Never)
170 } else { 166 } else {
171 self.table.new_type_var() 167 self.table.new_type_var()
@@ -188,7 +184,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
188 } 184 }
189 Expr::Path(p) => { 185 Expr::Path(p) => {
190 // FIXME this could be more efficient... 186 // FIXME this could be more efficient...
191 let resolver = resolver_for_expr(self.db, self.owner.into(), tgt_expr); 187 let resolver = resolver_for_expr(self.db, self.owner, tgt_expr);
192 self.infer_path(&resolver, p, tgt_expr.into()).unwrap_or(Ty::Unknown) 188 self.infer_path(&resolver, p, tgt_expr.into()).unwrap_or(Ty::Unknown)
193 } 189 }
194 Expr::Continue => Ty::simple(TypeCtor::Never), 190 Expr::Continue => Ty::simple(TypeCtor::Never),
@@ -217,8 +213,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
217 self.unify(&ty, &expected.ty); 213 self.unify(&ty, &expected.ty);
218 214
219 let substs = ty.substs().unwrap_or_else(Substs::empty); 215 let substs = ty.substs().unwrap_or_else(Substs::empty);
220 let field_types = 216 let field_types = def_id.map(|it| self.db.field_types(it)).unwrap_or_default();
221 def_id.map(|it| self.db.field_types(it.into())).unwrap_or_default();
222 let variant_data = def_id.map(|it| variant_data(self.db, it)); 217 let variant_data = def_id.map(|it| variant_data(self.db, it));
223 for (field_idx, field) in fields.iter().enumerate() { 218 for (field_idx, field) in fields.iter().enumerate() {
224 let field_def = 219 let field_def =
@@ -264,7 +259,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
264 .and_then(|idx| a_ty.parameters.0.get(idx).cloned()), 259 .and_then(|idx| a_ty.parameters.0.get(idx).cloned()),
265 TypeCtor::Adt(AdtId::StructId(s)) => { 260 TypeCtor::Adt(AdtId::StructId(s)) => {
266 self.db.struct_data(s).variant_data.field(name).map(|local_id| { 261 self.db.struct_data(s).variant_data.field(name).map(|local_id| {
267 let field = StructFieldId { parent: s.into(), local_id }.into(); 262 let field = StructFieldId { parent: s.into(), local_id };
268 self.write_field_resolution(tgt_expr, field); 263 self.write_field_resolution(tgt_expr, field);
269 self.db.field_types(s.into())[field.local_id] 264 self.db.field_types(s.into())[field.local_id]
270 .clone() 265 .clone()
@@ -283,14 +278,11 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
283 } 278 }
284 Expr::Await { expr } => { 279 Expr::Await { expr } => {
285 let inner_ty = self.infer_expr_inner(*expr, &Expectation::none()); 280 let inner_ty = self.infer_expr_inner(*expr, &Expectation::none());
286 let ty = 281 self.resolve_associated_type(inner_ty, self.resolve_future_future_output())
287 self.resolve_associated_type(inner_ty, self.resolve_future_future_output());
288 ty
289 } 282 }
290 Expr::Try { expr } => { 283 Expr::Try { expr } => {
291 let inner_ty = self.infer_expr_inner(*expr, &Expectation::none()); 284 let inner_ty = self.infer_expr_inner(*expr, &Expectation::none());
292 let ty = self.resolve_associated_type(inner_ty, self.resolve_ops_try_ok()); 285 self.resolve_associated_type(inner_ty, self.resolve_ops_try_ok())
293 ty
294 } 286 }
295 Expr::Cast { expr, type_ref } => { 287 Expr::Cast { expr, type_ref } => {
296 let _inner_ty = self.infer_expr_inner(*expr, &Expectation::none()); 288 let _inner_ty = self.infer_expr_inner(*expr, &Expectation::none());
@@ -614,8 +606,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
614 self.unify(&expected_receiver_ty, &actual_receiver_ty); 606 self.unify(&expected_receiver_ty, &actual_receiver_ty);
615 607
616 self.check_call_arguments(args, &param_tys); 608 self.check_call_arguments(args, &param_tys);
617 let ret_ty = self.normalize_associated_types_in(ret_ty); 609 self.normalize_associated_types_in(ret_ty)
618 ret_ty
619 } 610 }
620 611
621 fn check_call_arguments(&mut self, args: &[ExprId], param_tys: &[Ty]) { 612 fn check_call_arguments(&mut self, args: &[ExprId], param_tys: &[Ty]) {
@@ -700,10 +691,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
700 // construct a TraitDef 691 // construct a TraitDef
701 let substs = 692 let substs =
702 a_ty.parameters.prefix(generics(self.db, trait_.into()).len()); 693 a_ty.parameters.prefix(generics(self.db, trait_.into()).len());
703 self.obligations.push(Obligation::Trait(TraitRef { 694 self.obligations.push(Obligation::Trait(TraitRef { trait_, substs }));
704 trait_: trait_.into(),
705 substs,
706 }));
707 } 695 }
708 } 696 }
709 CallableDef::StructId(_) | CallableDef::EnumVariantId(_) => {} 697 CallableDef::StructId(_) | CallableDef::EnumVariantId(_) => {}
diff --git a/crates/ra_hir_ty/src/infer/pat.rs b/crates/ra_hir_ty/src/infer/pat.rs
index a5dfdf6c4..a495ecbfe 100644
--- a/crates/ra_hir_ty/src/infer/pat.rs
+++ b/crates/ra_hir_ty/src/infer/pat.rs
@@ -28,7 +28,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
28 28
29 let substs = ty.substs().unwrap_or_else(Substs::empty); 29 let substs = ty.substs().unwrap_or_else(Substs::empty);
30 30
31 let field_tys = def.map(|it| self.db.field_types(it.into())).unwrap_or_default(); 31 let field_tys = def.map(|it| self.db.field_types(it)).unwrap_or_default();
32 32
33 for (i, &subpat) in subpats.iter().enumerate() { 33 for (i, &subpat) in subpats.iter().enumerate() {
34 let expected_ty = var_data 34 let expected_ty = var_data
@@ -60,7 +60,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
60 60
61 let substs = ty.substs().unwrap_or_else(Substs::empty); 61 let substs = ty.substs().unwrap_or_else(Substs::empty);
62 62
63 let field_tys = def.map(|it| self.db.field_types(it.into())).unwrap_or_default(); 63 let field_tys = def.map(|it| self.db.field_types(it)).unwrap_or_default();
64 for subpat in subpats { 64 for subpat in subpats {
65 let matching_field = var_data.as_ref().and_then(|it| it.field(&subpat.name)); 65 let matching_field = var_data.as_ref().and_then(|it| it.field(&subpat.name));
66 let expected_ty = 66 let expected_ty =
diff --git a/crates/ra_hir_ty/src/infer/path.rs b/crates/ra_hir_ty/src/infer/path.rs
index 686ce7a21..471d60342 100644
--- a/crates/ra_hir_ty/src/infer/path.rs
+++ b/crates/ra_hir_ty/src/infer/path.rs
@@ -104,8 +104,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
104 let segment = 104 let segment =
105 remaining_segments.last().expect("there should be at least one segment here"); 105 remaining_segments.last().expect("there should be at least one segment here");
106 let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver); 106 let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver);
107 let trait_ref = 107 let trait_ref = TraitRef::from_resolved_path(&ctx, trait_, resolved_segment, None);
108 TraitRef::from_resolved_path(&ctx, trait_.into(), resolved_segment, None);
109 self.resolve_trait_assoc_item(trait_ref, segment, id) 108 self.resolve_trait_assoc_item(trait_ref, segment, id)
110 } 109 }
111 (def, _) => { 110 (def, _) => {
@@ -144,30 +143,32 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
144 id: ExprOrPatId, 143 id: ExprOrPatId,
145 ) -> Option<(ValueNs, Option<Substs>)> { 144 ) -> Option<(ValueNs, Option<Substs>)> {
146 let trait_ = trait_ref.trait_; 145 let trait_ = trait_ref.trait_;
147 let item = self 146 let item =
148 .db 147 self.db.trait_data(trait_).items.iter().map(|(_name, id)| (*id)).find_map(|item| {
149 .trait_data(trait_) 148 match item {
150 .items 149 AssocItemId::FunctionId(func) => {
151 .iter() 150 if segment.name == &self.db.function_data(func).name {
152 .map(|(_name, id)| (*id).into()) 151 Some(AssocItemId::FunctionId(func))
153 .find_map(|item| match item { 152 } else {
154 AssocItemId::FunctionId(func) => { 153 None
155 if segment.name == &self.db.function_data(func).name { 154 }
156 Some(AssocItemId::FunctionId(func))
157 } else {
158 None
159 } 155 }
160 }
161 156
162 AssocItemId::ConstId(konst) => { 157 AssocItemId::ConstId(konst) => {
163 if self.db.const_data(konst).name.as_ref().map_or(false, |n| n == segment.name) 158 if self
164 { 159 .db
165 Some(AssocItemId::ConstId(konst)) 160 .const_data(konst)
166 } else { 161 .name
167 None 162 .as_ref()
163 .map_or(false, |n| n == segment.name)
164 {
165 Some(AssocItemId::ConstId(konst))
166 } else {
167 None
168 }
168 } 169 }
170 AssocItemId::TypeAliasId(_) => None,
169 } 171 }
170 AssocItemId::TypeAliasId(_) => None,
171 })?; 172 })?;
172 let def = match item { 173 let def = match item {
173 AssocItemId::FunctionId(f) => ValueNs::FunctionId(f), 174 AssocItemId::FunctionId(f) => ValueNs::FunctionId(f),
@@ -233,7 +234,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
233 AssocContainerId::ContainerId(_) => None, 234 AssocContainerId::ContainerId(_) => None,
234 }; 235 };
235 236
236 self.write_assoc_resolution(id, item.into()); 237 self.write_assoc_resolution(id, item);
237 Some((def, substs)) 238 Some((def, substs))
238 }, 239 },
239 ) 240 )
diff --git a/crates/ra_hir_ty/src/infer/unify.rs b/crates/ra_hir_ty/src/infer/unify.rs
index 1dc842f40..9c7996572 100644
--- a/crates/ra_hir_ty/src/infer/unify.rs
+++ b/crates/ra_hir_ty/src/infer/unify.rs
@@ -140,13 +140,12 @@ where
140impl<T> Canonicalized<T> { 140impl<T> Canonicalized<T> {
141 pub fn decanonicalize_ty(&self, mut ty: Ty) -> Ty { 141 pub fn decanonicalize_ty(&self, mut ty: Ty) -> Ty {
142 ty.walk_mut_binders( 142 ty.walk_mut_binders(
143 &mut |ty, binders| match ty { 143 &mut |ty, binders| {
144 &mut Ty::Bound(idx) => { 144 if let &mut Ty::Bound(idx) = ty {
145 if idx as usize >= binders && (idx as usize - binders) < self.free_vars.len() { 145 if idx as usize >= binders && (idx as usize - binders) < self.free_vars.len() {
146 *ty = Ty::Infer(self.free_vars[idx as usize - binders]); 146 *ty = Ty::Infer(self.free_vars[idx as usize - binders]);
147 } 147 }
148 } 148 }
149 _ => {}
150 }, 149 },
151 0, 150 0,
152 ); 151 );
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs
index 571579cc4..13c5e6c6b 100644
--- a/crates/ra_hir_ty/src/lib.rs
+++ b/crates/ra_hir_ty/src/lib.rs
@@ -167,7 +167,7 @@ impl TypeCtor {
167 | TypeCtor::Closure { .. } // 1 param representing the signature of the closure 167 | TypeCtor::Closure { .. } // 1 param representing the signature of the closure
168 => 1, 168 => 1,
169 TypeCtor::Adt(adt) => { 169 TypeCtor::Adt(adt) => {
170 let generic_params = generics(db, AdtId::from(adt).into()); 170 let generic_params = generics(db, adt.into());
171 generic_params.len() 171 generic_params.len()
172 } 172 }
173 TypeCtor::FnDef(callable) => { 173 TypeCtor::FnDef(callable) => {
@@ -247,7 +247,7 @@ pub struct ProjectionTy {
247 247
248impl ProjectionTy { 248impl ProjectionTy {
249 pub fn trait_ref(&self, db: &impl HirDatabase) -> TraitRef { 249 pub fn trait_ref(&self, db: &impl HirDatabase) -> TraitRef {
250 TraitRef { trait_: self.trait_(db).into(), substs: self.parameters.clone() } 250 TraitRef { trait_: self.trait_(db), substs: self.parameters.clone() }
251 } 251 }
252 252
253 fn trait_(&self, db: &impl HirDatabase) -> TraitId { 253 fn trait_(&self, db: &impl HirDatabase) -> TraitId {
@@ -763,8 +763,8 @@ pub trait TypeWalk {
763 Self: Sized, 763 Self: Sized,
764 { 764 {
765 self.walk_mut_binders( 765 self.walk_mut_binders(
766 &mut |ty, binders| match ty { 766 &mut |ty, binders| {
767 &mut Ty::Bound(idx) => { 767 if let &mut Ty::Bound(idx) = ty {
768 if idx as usize >= binders && (idx as usize - binders) < substs.len() { 768 if idx as usize >= binders && (idx as usize - binders) < substs.len() {
769 *ty = substs.0[idx as usize - binders].clone(); 769 *ty = substs.0[idx as usize - binders].clone();
770 } else if idx as usize >= binders + substs.len() { 770 } else if idx as usize >= binders + substs.len() {
@@ -772,7 +772,6 @@ pub trait TypeWalk {
772 *ty = Ty::Bound(idx - substs.len() as u32); 772 *ty = Ty::Bound(idx - substs.len() as u32);
773 } 773 }
774 } 774 }
775 _ => {}
776 }, 775 },
777 0, 776 0,
778 ); 777 );
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs
index c2a3703fa..52da34574 100644
--- a/crates/ra_hir_ty/src/lower.rs
+++ b/crates/ra_hir_ty/src/lower.rs
@@ -361,10 +361,8 @@ impl Ty {
361 for t in traits { 361 for t in traits {
362 if let Some(associated_ty) = ctx.db.trait_data(t).associated_type_by_name(&segment.name) 362 if let Some(associated_ty) = ctx.db.trait_data(t).associated_type_by_name(&segment.name)
363 { 363 {
364 let substs = Substs::build_for_def(ctx.db, t) 364 let substs =
365 .push(self_ty.clone()) 365 Substs::build_for_def(ctx.db, t).push(self_ty).fill_with_unknown().build();
366 .fill_with_unknown()
367 .build();
368 // FIXME handle type parameters on the segment 366 // FIXME handle type parameters on the segment
369 return Ty::Projection(ProjectionTy { associated_ty, parameters: substs }); 367 return Ty::Projection(ProjectionTy { associated_ty, parameters: substs });
370 } 368 }
@@ -428,7 +426,7 @@ pub(super) fn substs_from_path_segment(
428 _add_self_param: bool, 426 _add_self_param: bool,
429) -> Substs { 427) -> Substs {
430 let mut substs = Vec::new(); 428 let mut substs = Vec::new();
431 let def_generics = def_generic.map(|def| generics(ctx.db, def.into())); 429 let def_generics = def_generic.map(|def| generics(ctx.db, def));
432 430
433 let (parent_params, self_params, type_params, impl_trait_params) = 431 let (parent_params, self_params, type_params, impl_trait_params) =
434 def_generics.map_or((0, 0, 0, 0), |g| g.provenance_split()); 432 def_generics.map_or((0, 0, 0, 0), |g| g.provenance_split());
@@ -459,7 +457,7 @@ pub(super) fn substs_from_path_segment(
459 457
460 // handle defaults 458 // handle defaults
461 if let Some(def_generic) = def_generic { 459 if let Some(def_generic) = def_generic {
462 let default_substs = ctx.db.generic_defaults(def_generic.into()); 460 let default_substs = ctx.db.generic_defaults(def_generic);
463 assert_eq!(substs.len(), default_substs.len()); 461 assert_eq!(substs.len(), default_substs.len());
464 462
465 for (i, default_ty) in default_substs.iter().enumerate() { 463 for (i, default_ty) in default_substs.iter().enumerate() {
@@ -483,7 +481,7 @@ impl TraitRef {
483 _ => return None, 481 _ => return None,
484 }; 482 };
485 let segment = path.segments().last().expect("path should have at least one segment"); 483 let segment = path.segments().last().expect("path should have at least one segment");
486 Some(TraitRef::from_resolved_path(ctx, resolved.into(), segment, explicit_self_ty)) 484 Some(TraitRef::from_resolved_path(ctx, resolved, segment, explicit_self_ty))
487 } 485 }
488 486
489 pub(crate) fn from_resolved_path( 487 pub(crate) fn from_resolved_path(
@@ -728,7 +726,7 @@ pub(crate) fn generic_predicates_query(
728pub(crate) fn generic_defaults_query(db: &impl HirDatabase, def: GenericDefId) -> Substs { 726pub(crate) fn generic_defaults_query(db: &impl HirDatabase, def: GenericDefId) -> Substs {
729 let resolver = def.resolver(db); 727 let resolver = def.resolver(db);
730 let ctx = TyLoweringContext::new(db, &resolver); 728 let ctx = TyLoweringContext::new(db, &resolver);
731 let generic_params = generics(db, def.into()); 729 let generic_params = generics(db, def);
732 730
733 let defaults = generic_params 731 let defaults = generic_params
734 .iter() 732 .iter()
@@ -792,7 +790,7 @@ fn type_for_builtin(def: BuiltinType) -> Ty {
792} 790}
793 791
794fn fn_sig_for_struct_constructor(db: &impl HirDatabase, def: StructId) -> PolyFnSig { 792fn fn_sig_for_struct_constructor(db: &impl HirDatabase, def: StructId) -> PolyFnSig {
795 let struct_data = db.struct_data(def.into()); 793 let struct_data = db.struct_data(def);
796 let fields = struct_data.variant_data.fields(); 794 let fields = struct_data.variant_data.fields();
797 let resolver = def.resolver(db); 795 let resolver = def.resolver(db);
798 let ctx = 796 let ctx =
@@ -805,7 +803,7 @@ fn fn_sig_for_struct_constructor(db: &impl HirDatabase, def: StructId) -> PolyFn
805 803
806/// Build the type of a tuple struct constructor. 804/// Build the type of a tuple struct constructor.
807fn type_for_struct_constructor(db: &impl HirDatabase, def: StructId) -> Binders<Ty> { 805fn type_for_struct_constructor(db: &impl HirDatabase, def: StructId) -> Binders<Ty> {
808 let struct_data = db.struct_data(def.into()); 806 let struct_data = db.struct_data(def);
809 if let StructKind::Unit = struct_data.variant_data.kind() { 807 if let StructKind::Unit = struct_data.variant_data.kind() {
810 return type_for_adt(db, def.into()); 808 return type_for_adt(db, def.into());
811 } 809 }
@@ -836,7 +834,7 @@ fn type_for_enum_variant_constructor(db: &impl HirDatabase, def: EnumVariantId)
836 } 834 }
837 let generics = generics(db, def.parent.into()); 835 let generics = generics(db, def.parent.into());
838 let substs = Substs::bound_vars(&generics); 836 let substs = Substs::bound_vars(&generics);
839 Binders::new(substs.len(), Ty::apply(TypeCtor::FnDef(EnumVariantId::from(def).into()), substs)) 837 Binders::new(substs.len(), Ty::apply(TypeCtor::FnDef(def.into()), substs))
840} 838}
841 839
842fn type_for_adt(db: &impl HirDatabase, adt: AdtId) -> Binders<Ty> { 840fn type_for_adt(db: &impl HirDatabase, adt: AdtId) -> Binders<Ty> {
@@ -964,6 +962,6 @@ pub(crate) fn impl_trait_query(
964 let target_trait = impl_data.target_trait.as_ref()?; 962 let target_trait = impl_data.target_trait.as_ref()?;
965 Some(Binders::new( 963 Some(Binders::new(
966 self_ty.num_binders, 964 self_ty.num_binders,
967 TraitRef::from_hir(&ctx, target_trait, Some(self_ty.value.clone()))?, 965 TraitRef::from_hir(&ctx, target_trait, Some(self_ty.value))?,
968 )) 966 ))
969} 967}
diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/ra_hir_ty/src/method_resolution.rs
index 4f8c52433..964acdb09 100644
--- a/crates/ra_hir_ty/src/method_resolution.rs
+++ b/crates/ra_hir_ty/src/method_resolution.rs
@@ -214,7 +214,7 @@ pub fn iterate_method_candidates<T>(
214 // the methods by autoderef order of *receiver types*, not *self 214 // the methods by autoderef order of *receiver types*, not *self
215 // types*. 215 // types*.
216 216
217 let deref_chain: Vec<_> = autoderef::autoderef(db, Some(krate), ty.clone()).collect(); 217 let deref_chain: Vec<_> = autoderef::autoderef(db, Some(krate), ty).collect();
218 for i in 0..deref_chain.len() { 218 for i in 0..deref_chain.len() {
219 if let Some(result) = iterate_method_candidates_with_autoref( 219 if let Some(result) = iterate_method_candidates_with_autoref(
220 &deref_chain[i..], 220 &deref_chain[i..],
@@ -290,7 +290,7 @@ fn iterate_method_candidates_with_autoref<T>(
290 &ref_muted, 290 &ref_muted,
291 deref_chain, 291 deref_chain,
292 db, 292 db,
293 env.clone(), 293 env,
294 krate, 294 krate,
295 &traits_in_scope, 295 &traits_in_scope,
296 name, 296 name,
@@ -391,17 +391,17 @@ fn iterate_trait_method_candidates<T>(
391 // iteration 391 // iteration
392 let mut known_implemented = false; 392 let mut known_implemented = false;
393 for (_name, item) in data.items.iter() { 393 for (_name, item) in data.items.iter() {
394 if !is_valid_candidate(db, name, receiver_ty, (*item).into(), self_ty) { 394 if !is_valid_candidate(db, name, receiver_ty, *item, self_ty) {
395 continue; 395 continue;
396 } 396 }
397 if !known_implemented { 397 if !known_implemented {
398 let goal = generic_implements_goal(db, env.clone(), t, self_ty.clone()); 398 let goal = generic_implements_goal(db, env.clone(), t, self_ty.clone());
399 if db.trait_solve(krate.into(), goal).is_none() { 399 if db.trait_solve(krate, goal).is_none() {
400 continue 'traits; 400 continue 'traits;
401 } 401 }
402 } 402 }
403 known_implemented = true; 403 known_implemented = true;
404 if let Some(result) = callback(&self_ty.value, (*item).into()) { 404 if let Some(result) = callback(&self_ty.value, *item) {
405 return Some(result); 405 return Some(result);
406 } 406 }
407 } 407 }
@@ -521,7 +521,7 @@ pub fn implements_trait(
521 return true; 521 return true;
522 } 522 }
523 let goal = generic_implements_goal(db, env, trait_, ty.clone()); 523 let goal = generic_implements_goal(db, env, trait_, ty.clone());
524 let solution = db.trait_solve(krate.into(), goal); 524 let solution = db.trait_solve(krate, goal);
525 525
526 solution.is_some() 526 solution.is_some()
527} 527}
diff --git a/crates/ra_hir_ty/src/op.rs b/crates/ra_hir_ty/src/op.rs
index ae253ca04..54e2bd05a 100644
--- a/crates/ra_hir_ty/src/op.rs
+++ b/crates/ra_hir_ty/src/op.rs
@@ -30,20 +30,18 @@ pub(super) fn binary_op_return_ty(op: BinaryOp, lhs_ty: Ty, rhs_ty: Ty) -> Ty {
30pub(super) fn binary_op_rhs_expectation(op: BinaryOp, lhs_ty: Ty) -> Ty { 30pub(super) fn binary_op_rhs_expectation(op: BinaryOp, lhs_ty: Ty) -> Ty {
31 match op { 31 match op {
32 BinaryOp::LogicOp(..) => Ty::simple(TypeCtor::Bool), 32 BinaryOp::LogicOp(..) => Ty::simple(TypeCtor::Bool),
33 BinaryOp::Assignment { op: None } | BinaryOp::CmpOp(CmpOp::Eq { negated: _ }) => { 33 BinaryOp::Assignment { op: None } | BinaryOp::CmpOp(CmpOp::Eq { .. }) => match lhs_ty {
34 match lhs_ty { 34 Ty::Apply(ApplicationTy { ctor, .. }) => match ctor {
35 Ty::Apply(ApplicationTy { ctor, .. }) => match ctor { 35 TypeCtor::Int(..)
36 TypeCtor::Int(..) 36 | TypeCtor::Float(..)
37 | TypeCtor::Float(..) 37 | TypeCtor::Str
38 | TypeCtor::Str 38 | TypeCtor::Char
39 | TypeCtor::Char 39 | TypeCtor::Bool => lhs_ty,
40 | TypeCtor::Bool => lhs_ty,
41 _ => Ty::Unknown,
42 },
43 Ty::Infer(InferTy::IntVar(..)) | Ty::Infer(InferTy::FloatVar(..)) => lhs_ty,
44 _ => Ty::Unknown, 40 _ => Ty::Unknown,
45 } 41 },
46 } 42 Ty::Infer(InferTy::IntVar(..)) | Ty::Infer(InferTy::FloatVar(..)) => lhs_ty,
43 _ => Ty::Unknown,
44 },
47 BinaryOp::ArithOp(ArithOp::Shl) | BinaryOp::ArithOp(ArithOp::Shr) => Ty::Unknown, 45 BinaryOp::ArithOp(ArithOp::Shl) | BinaryOp::ArithOp(ArithOp::Shr) => Ty::Unknown,
48 BinaryOp::CmpOp(CmpOp::Ord { .. }) 46 BinaryOp::CmpOp(CmpOp::Ord { .. })
49 | BinaryOp::Assignment { op: Some(_) } 47 | BinaryOp::Assignment { op: Some(_) }
diff --git a/crates/ra_hir_ty/src/test_db.rs b/crates/ra_hir_ty/src/test_db.rs
index 1a31b587b..c794f7b84 100644
--- a/crates/ra_hir_ty/src/test_db.rs
+++ b/crates/ra_hir_ty/src/test_db.rs
@@ -86,15 +86,14 @@ impl TestDB {
86 pub fn diagnostics(&self) -> String { 86 pub fn diagnostics(&self) -> String {
87 let mut buf = String::new(); 87 let mut buf = String::new();
88 let crate_graph = self.crate_graph(); 88 let crate_graph = self.crate_graph();
89 for krate in crate_graph.iter().next() { 89 for krate in crate_graph.iter() {
90 let crate_def_map = self.crate_def_map(krate); 90 let crate_def_map = self.crate_def_map(krate);
91 91
92 let mut fns = Vec::new(); 92 let mut fns = Vec::new();
93 for (module_id, _) in crate_def_map.modules.iter() { 93 for (module_id, _) in crate_def_map.modules.iter() {
94 for decl in crate_def_map[module_id].scope.declarations() { 94 for decl in crate_def_map[module_id].scope.declarations() {
95 match decl { 95 if let ModuleDefId::FunctionId(f) = decl {
96 ModuleDefId::FunctionId(f) => fns.push(f), 96 fns.push(f)
97 _ => (),
98 } 97 }
99 } 98 }
100 99
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs
index d1f10e675..240cc03a2 100644
--- a/crates/ra_hir_ty/src/tests.rs
+++ b/crates/ra_hir_ty/src/tests.rs
@@ -101,9 +101,9 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String {
101 (src_ptr.value.range(), node.text().to_string().replace("\n", " ")) 101 (src_ptr.value.range(), node.text().to_string().replace("\n", " "))
102 }; 102 };
103 let macro_prefix = if src_ptr.file_id != file_id.into() { "!" } else { "" }; 103 let macro_prefix = if src_ptr.file_id != file_id.into() { "!" } else { "" };
104 write!( 104 writeln!(
105 acc, 105 acc,
106 "{}{} '{}': {}\n", 106 "{}{} '{}': {}",
107 macro_prefix, 107 macro_prefix,
108 range, 108 range,
109 ellipsize(text, 15), 109 ellipsize(text, 15),
@@ -118,9 +118,9 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String {
118 for (src_ptr, mismatch) in &mismatches { 118 for (src_ptr, mismatch) in &mismatches {
119 let range = src_ptr.value.range(); 119 let range = src_ptr.value.range();
120 let macro_prefix = if src_ptr.file_id != file_id.into() { "!" } else { "" }; 120 let macro_prefix = if src_ptr.file_id != file_id.into() { "!" } else { "" };
121 write!( 121 writeln!(
122 acc, 122 acc,
123 "{}{}: expected {}, got {}\n", 123 "{}{}: expected {}, got {}",
124 macro_prefix, 124 macro_prefix,
125 range, 125 range,
126 mismatch.expected.display(&db), 126 mismatch.expected.display(&db),
diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/ra_hir_ty/src/traits.rs
index ff8e75b48..e83449957 100644
--- a/crates/ra_hir_ty/src/traits.rs
+++ b/crates/ra_hir_ty/src/traits.rs
@@ -248,12 +248,9 @@ fn solution_from_chalk(
248 let value = subst 248 let value = subst
249 .value 249 .value
250 .into_iter() 250 .into_iter()
251 .map(|p| { 251 .map(|p| match p.ty() {
252 let ty = match p.ty() { 252 Some(ty) => from_chalk(db, ty.clone()),
253 Some(ty) => from_chalk(db, ty.clone()), 253 None => unimplemented!(),
254 None => unimplemented!(),
255 };
256 ty
257 }) 254 })
258 .collect(); 255 .collect();
259 let result = Canonical { value, num_vars: subst.binders.len() }; 256 let result = Canonical { value, num_vars: subst.binders.len() };
diff --git a/crates/ra_hir_ty/src/traits/builtin.rs b/crates/ra_hir_ty/src/traits/builtin.rs
index dd41176f0..a537420a5 100644
--- a/crates/ra_hir_ty/src/traits/builtin.rs
+++ b/crates/ra_hir_ty/src/traits/builtin.rs
@@ -98,7 +98,7 @@ fn closure_fn_trait_impl_datum(
98 // the existence of the Fn trait has been checked before 98 // the existence of the Fn trait has been checked before
99 .expect("fn trait for closure impl missing"); 99 .expect("fn trait for closure impl missing");
100 100
101 let num_args: u16 = match &db.body(data.def.into())[data.expr] { 101 let num_args: u16 = match &db.body(data.def)[data.expr] {
102 Expr::Lambda { args, .. } => args.len() as u16, 102 Expr::Lambda { args, .. } => args.len() as u16,
103 _ => { 103 _ => {
104 log::warn!("closure for closure type {:?} not found", data); 104 log::warn!("closure for closure type {:?} not found", data);
@@ -118,11 +118,11 @@ fn closure_fn_trait_impl_datum(
118 let self_ty = Ty::apply_one(TypeCtor::Closure { def: data.def, expr: data.expr }, sig_ty); 118 let self_ty = Ty::apply_one(TypeCtor::Closure { def: data.def, expr: data.expr }, sig_ty);
119 119
120 let trait_ref = TraitRef { 120 let trait_ref = TraitRef {
121 trait_: trait_.into(), 121 trait_,
122 substs: Substs::build_for_def(db, trait_).push(self_ty).push(arg_ty).build(), 122 substs: Substs::build_for_def(db, trait_).push(self_ty).push(arg_ty).build(),
123 }; 123 };
124 124
125 let output_ty_id = AssocTyValue::ClosureFnTraitImplOutput(data.clone()); 125 let output_ty_id = AssocTyValue::ClosureFnTraitImplOutput(data);
126 126
127 BuiltinImplData { 127 BuiltinImplData {
128 num_vars: num_args as usize + 1, 128 num_vars: num_args as usize + 1,
@@ -137,9 +137,9 @@ fn closure_fn_trait_output_assoc_ty_value(
137 krate: CrateId, 137 krate: CrateId,
138 data: super::ClosureFnTraitImplData, 138 data: super::ClosureFnTraitImplData,
139) -> BuiltinImplAssocTyValueData { 139) -> BuiltinImplAssocTyValueData {
140 let impl_ = Impl::ClosureFnTraitImpl(data.clone()); 140 let impl_ = Impl::ClosureFnTraitImpl(data);
141 141
142 let num_args: u16 = match &db.body(data.def.into())[data.expr] { 142 let num_args: u16 = match &db.body(data.def)[data.expr] {
143 Expr::Lambda { args, .. } => args.len() as u16, 143 Expr::Lambda { args, .. } => args.len() as u16,
144 _ => { 144 _ => {
145 log::warn!("closure for closure type {:?} not found", data); 145 log::warn!("closure for closure type {:?} not found", data);
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs
index 882160fa8..1bdf13e48 100644
--- a/crates/ra_hir_ty/src/traits/chalk.rs
+++ b/crates/ra_hir_ty/src/traits/chalk.rs
@@ -409,8 +409,7 @@ where
409 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Canonical<T::Chalk> { 409 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Canonical<T::Chalk> {
410 let parameter = chalk_ir::ParameterKind::Ty(chalk_ir::UniverseIndex::ROOT); 410 let parameter = chalk_ir::ParameterKind::Ty(chalk_ir::UniverseIndex::ROOT);
411 let value = self.value.to_chalk(db); 411 let value = self.value.to_chalk(db);
412 let canonical = chalk_ir::Canonical { value, binders: vec![parameter; self.num_vars] }; 412 chalk_ir::Canonical { value, binders: vec![parameter; self.num_vars] }
413 canonical
414 } 413 }
415 414
416 fn from_chalk(db: &impl HirDatabase, canonical: chalk_ir::Canonical<T::Chalk>) -> Canonical<T> { 415 fn from_chalk(db: &impl HirDatabase, canonical: chalk_ir::Canonical<T::Chalk>) -> Canonical<T> {
@@ -565,10 +564,10 @@ where
565 // and will panic if the trait can't be resolved. 564 // and will panic if the trait can't be resolved.
566 let mut result: Vec<_> = self 565 let mut result: Vec<_> = self
567 .db 566 .db
568 .impls_for_trait(self.krate, trait_.into()) 567 .impls_for_trait(self.krate, trait_)
569 .iter() 568 .iter()
570 .copied() 569 .copied()
571 .map(|it| Impl::ImplBlock(it.into())) 570 .map(Impl::ImplBlock)
572 .map(|impl_| impl_.to_chalk(self.db)) 571 .map(|impl_| impl_.to_chalk(self.db))
573 .collect(); 572 .collect();
574 573
@@ -586,7 +585,7 @@ where
586 false // FIXME 585 false // FIXME
587 } 586 }
588 fn associated_ty_value(&self, id: AssociatedTyValueId) -> Arc<AssociatedTyValue> { 587 fn associated_ty_value(&self, id: AssociatedTyValueId) -> Arc<AssociatedTyValue> {
589 self.db.associated_ty_value(self.krate.into(), id) 588 self.db.associated_ty_value(self.krate, id)
590 } 589 }
591 fn custom_clauses(&self) -> Vec<chalk_ir::ProgramClause<TypeFamily>> { 590 fn custom_clauses(&self) -> Vec<chalk_ir::ProgramClause<TypeFamily>> {
592 vec![] 591 vec![]
@@ -674,7 +673,7 @@ pub(crate) fn struct_datum_query(
674 let where_clauses = type_ctor 673 let where_clauses = type_ctor
675 .as_generic_def() 674 .as_generic_def()
676 .map(|generic_def| { 675 .map(|generic_def| {
677 let generic_params = generics(db, generic_def.into()); 676 let generic_params = generics(db, generic_def);
678 let bound_vars = Substs::bound_vars(&generic_params); 677 let bound_vars = Substs::bound_vars(&generic_params);
679 convert_where_clauses(db, generic_def, &bound_vars) 678 convert_where_clauses(db, generic_def, &bound_vars)
680 }) 679 })
@@ -805,7 +804,7 @@ fn type_alias_associated_ty_value(
805 let ty = db.ty(type_alias.into()); 804 let ty = db.ty(type_alias.into());
806 let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: ty.value.to_chalk(db) }; 805 let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: ty.value.to_chalk(db) };
807 let value = chalk_rust_ir::AssociatedTyValue { 806 let value = chalk_rust_ir::AssociatedTyValue {
808 impl_id: Impl::ImplBlock(impl_id.into()).to_chalk(db), 807 impl_id: Impl::ImplBlock(impl_id).to_chalk(db),
809 associated_ty_id: assoc_ty.to_chalk(db), 808 associated_ty_id: assoc_ty.to_chalk(db),
810 value: make_binders(value_bound, ty.num_binders), 809 value: make_binders(value_bound, ty.num_binders),
811 }; 810 };