diff options
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/infer.rs | 21 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/lower.rs | 14 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 8 |
3 files changed, 22 insertions, 21 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index 69b13baef..471bdc387 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs | |||
@@ -22,6 +22,7 @@ use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue}; | |||
22 | use rustc_hash::FxHashMap; | 22 | use rustc_hash::FxHashMap; |
23 | 23 | ||
24 | use hir_def::{ | 24 | use hir_def::{ |
25 | data::{ConstData, FunctionData}, | ||
25 | path::known, | 26 | path::known, |
26 | resolver::{HasResolver, Resolver, TypeNs}, | 27 | resolver::{HasResolver, Resolver, TypeNs}, |
27 | type_ref::{Mutability, TypeRef}, | 28 | type_ref::{Mutability, TypeRef}, |
@@ -43,8 +44,8 @@ use crate::{ | |||
43 | db::HirDatabase, | 44 | db::HirDatabase, |
44 | expr::{BindingAnnotation, Body, ExprId, PatId}, | 45 | expr::{BindingAnnotation, Body, ExprId, PatId}, |
45 | ty::infer::diagnostics::InferenceDiagnostic, | 46 | ty::infer::diagnostics::InferenceDiagnostic, |
46 | Adt, AssocItem, ConstData, DefWithBody, FloatTy, FnData, Function, HasBody, IntTy, Path, | 47 | Adt, AssocItem, DefWithBody, FloatTy, Function, HasBody, IntTy, Path, StructField, Trait, |
47 | StructField, Trait, VariantDef, | 48 | VariantDef, |
48 | }; | 49 | }; |
49 | 50 | ||
50 | macro_rules! ty_app { | 51 | macro_rules! ty_app { |
@@ -68,10 +69,10 @@ pub fn infer_query(db: &impl HirDatabase, def: DefWithBody) -> Arc<InferenceResu | |||
68 | let resolver = DefWithBodyId::from(def).resolver(db); | 69 | let resolver = DefWithBodyId::from(def).resolver(db); |
69 | let mut ctx = InferenceContext::new(db, def, resolver); | 70 | let mut ctx = InferenceContext::new(db, def, resolver); |
70 | 71 | ||
71 | match def { | 72 | match &def { |
72 | DefWithBody::Const(ref c) => ctx.collect_const(&c.data(db)), | 73 | DefWithBody::Const(c) => ctx.collect_const(&db.const_data(c.id)), |
73 | DefWithBody::Function(ref f) => ctx.collect_fn(&f.data(db)), | 74 | DefWithBody::Function(f) => ctx.collect_fn(&db.function_data(f.id)), |
74 | DefWithBody::Static(ref s) => ctx.collect_const(&s.data(db)), | 75 | DefWithBody::Static(s) => ctx.collect_const(&db.static_data(s.id)), |
75 | } | 76 | } |
76 | 77 | ||
77 | ctx.infer_body(); | 78 | ctx.infer_body(); |
@@ -559,17 +560,17 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
559 | } | 560 | } |
560 | 561 | ||
561 | fn collect_const(&mut self, data: &ConstData) { | 562 | fn collect_const(&mut self, data: &ConstData) { |
562 | self.return_ty = self.make_ty(data.type_ref()); | 563 | self.return_ty = self.make_ty(&data.type_ref); |
563 | } | 564 | } |
564 | 565 | ||
565 | fn collect_fn(&mut self, data: &FnData) { | 566 | fn collect_fn(&mut self, data: &FunctionData) { |
566 | let body = Arc::clone(&self.body); // avoid borrow checker problem | 567 | let body = Arc::clone(&self.body); // avoid borrow checker problem |
567 | for (type_ref, pat) in data.params().iter().zip(body.params()) { | 568 | for (type_ref, pat) in data.params.iter().zip(body.params()) { |
568 | let ty = self.make_ty(type_ref); | 569 | let ty = self.make_ty(type_ref); |
569 | 570 | ||
570 | self.infer_pat(*pat, &ty, BindingMode::default()); | 571 | self.infer_pat(*pat, &ty, BindingMode::default()); |
571 | } | 572 | } |
572 | self.return_ty = self.make_ty(data.ret_type()); | 573 | self.return_ty = self.make_ty(&data.ret_type); |
573 | } | 574 | } |
574 | 575 | ||
575 | fn infer_body(&mut self) { | 576 | fn infer_body(&mut self) { |
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs index 75c552569..2272510e8 100644 --- a/crates/ra_hir/src/ty/lower.rs +++ b/crates/ra_hir/src/ty/lower.rs | |||
@@ -622,10 +622,10 @@ pub(crate) fn generic_defaults_query(db: &impl HirDatabase, def: GenericDef) -> | |||
622 | } | 622 | } |
623 | 623 | ||
624 | fn fn_sig_for_fn(db: &impl HirDatabase, def: Function) -> FnSig { | 624 | fn fn_sig_for_fn(db: &impl HirDatabase, def: Function) -> FnSig { |
625 | let data = def.data(db); | 625 | let data = db.function_data(def.id); |
626 | let resolver = def.id.resolver(db); | 626 | let resolver = def.id.resolver(db); |
627 | let params = data.params().iter().map(|tr| Ty::from_hir(db, &resolver, tr)).collect::<Vec<_>>(); | 627 | let params = data.params.iter().map(|tr| Ty::from_hir(db, &resolver, tr)).collect::<Vec<_>>(); |
628 | let ret = Ty::from_hir(db, &resolver, data.ret_type()); | 628 | let ret = Ty::from_hir(db, &resolver, &data.ret_type); |
629 | FnSig::from_params_and_return(params, ret) | 629 | FnSig::from_params_and_return(params, ret) |
630 | } | 630 | } |
631 | 631 | ||
@@ -639,18 +639,18 @@ fn type_for_fn(db: &impl HirDatabase, def: Function) -> Ty { | |||
639 | 639 | ||
640 | /// Build the declared type of a const. | 640 | /// Build the declared type of a const. |
641 | fn type_for_const(db: &impl HirDatabase, def: Const) -> Ty { | 641 | fn type_for_const(db: &impl HirDatabase, def: Const) -> Ty { |
642 | let data = def.data(db); | 642 | let data = db.const_data(def.id); |
643 | let resolver = def.id.resolver(db); | 643 | let resolver = def.id.resolver(db); |
644 | 644 | ||
645 | Ty::from_hir(db, &resolver, data.type_ref()) | 645 | Ty::from_hir(db, &resolver, &data.type_ref) |
646 | } | 646 | } |
647 | 647 | ||
648 | /// Build the declared type of a static. | 648 | /// Build the declared type of a static. |
649 | fn type_for_static(db: &impl HirDatabase, def: Static) -> Ty { | 649 | fn type_for_static(db: &impl HirDatabase, def: Static) -> Ty { |
650 | let data = def.data(db); | 650 | let data = db.static_data(def.id); |
651 | let resolver = def.id.resolver(db); | 651 | let resolver = def.id.resolver(db); |
652 | 652 | ||
653 | Ty::from_hir(db, &resolver, data.type_ref()) | 653 | Ty::from_hir(db, &resolver, &data.type_ref) |
654 | } | 654 | } |
655 | 655 | ||
656 | /// Build the declared type of a static. | 656 | /// Build the declared type of a static. |
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index 64adb814d..f61c27218 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs | |||
@@ -233,7 +233,7 @@ fn iterate_trait_method_candidates<T>( | |||
233 | .chain(traits_from_env) | 233 | .chain(traits_from_env) |
234 | .chain(resolver.traits_in_scope(db).into_iter().map(Trait::from)); | 234 | .chain(resolver.traits_in_scope(db).into_iter().map(Trait::from)); |
235 | 'traits: for t in traits { | 235 | 'traits: for t in traits { |
236 | let data = t.trait_data(db); | 236 | let data = db.trait_data(t.id); |
237 | 237 | ||
238 | // we'll be lazy about checking whether the type implements the | 238 | // we'll be lazy about checking whether the type implements the |
239 | // trait, but if we find out it doesn't, we'll skip the rest of the | 239 | // trait, but if we find out it doesn't, we'll skip the rest of the |
@@ -291,9 +291,9 @@ fn is_valid_candidate( | |||
291 | ) -> bool { | 291 | ) -> bool { |
292 | match item { | 292 | match item { |
293 | AssocItem::Function(m) => { | 293 | AssocItem::Function(m) => { |
294 | let data = m.data(db); | 294 | let data = db.function_data(m.id); |
295 | name.map_or(true, |name| data.name() == name) | 295 | name.map_or(true, |name| data.name == *name) |
296 | && (data.has_self_param() || mode == LookupMode::Path) | 296 | && (data.has_self_param || mode == LookupMode::Path) |
297 | } | 297 | } |
298 | AssocItem::Const(c) => { | 298 | AssocItem::Const(c) => { |
299 | name.map_or(true, |name| Some(name) == c.name(db).as_ref()) | 299 | name.map_or(true, |name| Some(name) == c.name(db).as_ref()) |