aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty')
-rw-r--r--crates/ra_hir_ty/src/infer.rs11
-rw-r--r--crates/ra_hir_ty/src/infer/coerce.rs6
-rw-r--r--crates/ra_hir_ty/src/infer/expr.rs20
-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/lib.rs4
-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/traits/builtin.rs6
-rw-r--r--crates/ra_hir_ty/src/traits/chalk.rs10
10 files changed, 66 insertions, 76 deletions
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..4a0eabdfc 100644
--- a/crates/ra_hir_ty/src/infer/coerce.rs
+++ b/crates/ra_hir_ty/src/infer/coerce.rs
@@ -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
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs
index 39d8bc0ca..0af94ae32 100644
--- a/crates/ra_hir_ty/src/infer/expr.rs
+++ b/crates/ra_hir_ty/src/infer/expr.rs
@@ -127,10 +127,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
127 TypeCtor::FnPtr { num_args: sig_tys.len() as u16 - 1 }, 127 TypeCtor::FnPtr { num_args: sig_tys.len() as u16 - 1 },
128 Substs(sig_tys.into()), 128 Substs(sig_tys.into()),
129 ); 129 );
130 let closure_ty = Ty::apply_one( 130 let closure_ty =
131 TypeCtor::Closure { def: self.owner.into(), expr: tgt_expr }, 131 Ty::apply_one(TypeCtor::Closure { def: self.owner, expr: tgt_expr }, sig_ty);
132 sig_ty,
133 );
134 132
135 // Eagerly try to relate the closure type with the expected 133 // Eagerly try to relate the closure type with the expected
136 // type, otherwise we often won't have enough information to 134 // type, otherwise we often won't have enough information to
@@ -165,7 +163,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
165 Expr::Match { expr, arms } => { 163 Expr::Match { expr, arms } => {
166 let input_ty = self.infer_expr(*expr, &Expectation::none()); 164 let input_ty = self.infer_expr(*expr, &Expectation::none());
167 165
168 let mut result_ty = if arms.len() == 0 { 166 let mut result_ty = if arms.is_empty() {
169 Ty::simple(TypeCtor::Never) 167 Ty::simple(TypeCtor::Never)
170 } else { 168 } else {
171 self.table.new_type_var() 169 self.table.new_type_var()
@@ -188,7 +186,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
188 } 186 }
189 Expr::Path(p) => { 187 Expr::Path(p) => {
190 // FIXME this could be more efficient... 188 // FIXME this could be more efficient...
191 let resolver = resolver_for_expr(self.db, self.owner.into(), tgt_expr); 189 let resolver = resolver_for_expr(self.db, self.owner, tgt_expr);
192 self.infer_path(&resolver, p, tgt_expr.into()).unwrap_or(Ty::Unknown) 190 self.infer_path(&resolver, p, tgt_expr.into()).unwrap_or(Ty::Unknown)
193 } 191 }
194 Expr::Continue => Ty::simple(TypeCtor::Never), 192 Expr::Continue => Ty::simple(TypeCtor::Never),
@@ -217,8 +215,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
217 self.unify(&ty, &expected.ty); 215 self.unify(&ty, &expected.ty);
218 216
219 let substs = ty.substs().unwrap_or_else(Substs::empty); 217 let substs = ty.substs().unwrap_or_else(Substs::empty);
220 let field_types = 218 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)); 219 let variant_data = def_id.map(|it| variant_data(self.db, it));
223 for (field_idx, field) in fields.iter().enumerate() { 220 for (field_idx, field) in fields.iter().enumerate() {
224 let field_def = 221 let field_def =
@@ -264,7 +261,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
264 .and_then(|idx| a_ty.parameters.0.get(idx).cloned()), 261 .and_then(|idx| a_ty.parameters.0.get(idx).cloned()),
265 TypeCtor::Adt(AdtId::StructId(s)) => { 262 TypeCtor::Adt(AdtId::StructId(s)) => {
266 self.db.struct_data(s).variant_data.field(name).map(|local_id| { 263 self.db.struct_data(s).variant_data.field(name).map(|local_id| {
267 let field = StructFieldId { parent: s.into(), local_id }.into(); 264 let field = StructFieldId { parent: s.into(), local_id };
268 self.write_field_resolution(tgt_expr, field); 265 self.write_field_resolution(tgt_expr, field);
269 self.db.field_types(s.into())[field.local_id] 266 self.db.field_types(s.into())[field.local_id]
270 .clone() 267 .clone()
@@ -700,10 +697,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
700 // construct a TraitDef 697 // construct a TraitDef
701 let substs = 698 let substs =
702 a_ty.parameters.prefix(generics(self.db, trait_.into()).len()); 699 a_ty.parameters.prefix(generics(self.db, trait_.into()).len());
703 self.obligations.push(Obligation::Trait(TraitRef { 700 self.obligations.push(Obligation::Trait(TraitRef { trait_, substs }));
704 trait_: trait_.into(),
705 substs,
706 }));
707 } 701 }
708 } 702 }
709 CallableDef::StructId(_) | CallableDef::EnumVariantId(_) => {} 703 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/lib.rs b/crates/ra_hir_ty/src/lib.rs
index 571579cc4..302bb8aa2 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 {
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/traits/builtin.rs b/crates/ra_hir_ty/src/traits/builtin.rs
index dd41176f0..67120abf6 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,7 +118,7 @@ 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
@@ -139,7 +139,7 @@ fn closure_fn_trait_output_assoc_ty_value(
139) -> BuiltinImplAssocTyValueData { 139) -> BuiltinImplAssocTyValueData {
140 let impl_ = Impl::ClosureFnTraitImpl(data.clone()); 140 let impl_ = Impl::ClosureFnTraitImpl(data.clone());
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..306909ec2 100644
--- a/crates/ra_hir_ty/src/traits/chalk.rs
+++ b/crates/ra_hir_ty/src/traits/chalk.rs
@@ -565,10 +565,10 @@ where
565 // and will panic if the trait can't be resolved. 565 // and will panic if the trait can't be resolved.
566 let mut result: Vec<_> = self 566 let mut result: Vec<_> = self
567 .db 567 .db
568 .impls_for_trait(self.krate, trait_.into()) 568 .impls_for_trait(self.krate, trait_)
569 .iter() 569 .iter()
570 .copied() 570 .copied()
571 .map(|it| Impl::ImplBlock(it.into())) 571 .map(Impl::ImplBlock)
572 .map(|impl_| impl_.to_chalk(self.db)) 572 .map(|impl_| impl_.to_chalk(self.db))
573 .collect(); 573 .collect();
574 574
@@ -586,7 +586,7 @@ where
586 false // FIXME 586 false // FIXME
587 } 587 }
588 fn associated_ty_value(&self, id: AssociatedTyValueId) -> Arc<AssociatedTyValue> { 588 fn associated_ty_value(&self, id: AssociatedTyValueId) -> Arc<AssociatedTyValue> {
589 self.db.associated_ty_value(self.krate.into(), id) 589 self.db.associated_ty_value(self.krate, id)
590 } 590 }
591 fn custom_clauses(&self) -> Vec<chalk_ir::ProgramClause<TypeFamily>> { 591 fn custom_clauses(&self) -> Vec<chalk_ir::ProgramClause<TypeFamily>> {
592 vec![] 592 vec![]
@@ -674,7 +674,7 @@ pub(crate) fn struct_datum_query(
674 let where_clauses = type_ctor 674 let where_clauses = type_ctor
675 .as_generic_def() 675 .as_generic_def()
676 .map(|generic_def| { 676 .map(|generic_def| {
677 let generic_params = generics(db, generic_def.into()); 677 let generic_params = generics(db, generic_def);
678 let bound_vars = Substs::bound_vars(&generic_params); 678 let bound_vars = Substs::bound_vars(&generic_params);
679 convert_where_clauses(db, generic_def, &bound_vars) 679 convert_where_clauses(db, generic_def, &bound_vars)
680 }) 680 })
@@ -805,7 +805,7 @@ fn type_alias_associated_ty_value(
805 let ty = db.ty(type_alias.into()); 805 let ty = db.ty(type_alias.into());
806 let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: ty.value.to_chalk(db) }; 806 let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: ty.value.to_chalk(db) };
807 let value = chalk_rust_ir::AssociatedTyValue { 807 let value = chalk_rust_ir::AssociatedTyValue {
808 impl_id: Impl::ImplBlock(impl_id.into()).to_chalk(db), 808 impl_id: Impl::ImplBlock(impl_id).to_chalk(db),
809 associated_ty_id: assoc_ty.to_chalk(db), 809 associated_ty_id: assoc_ty.to_chalk(db),
810 value: make_binders(value_bound, ty.num_binders), 810 value: make_binders(value_bound, ty.num_binders),
811 }; 811 };