diff options
author | Seivan Heidari <[email protected]> | 2019-11-22 00:54:34 +0000 |
---|---|---|
committer | Seivan Heidari <[email protected]> | 2019-11-22 00:54:34 +0000 |
commit | a63a269ec84192114cc1ac7f079e96144ae877a1 (patch) | |
tree | bfa5b8496a958e825423d09f6abbdf5db5c54efa /crates/ra_hir/src/ty/infer/expr.rs | |
parent | 358a1bcd708c622836723e5201b6de77cc9ff327 (diff) | |
parent | c9273828b3c44fba62d1b989480c287d923839d2 (diff) |
Merge branch 'master' of https://github.com/rust-analyzer/rust-analyzer into feature/themes
Diffstat (limited to 'crates/ra_hir/src/ty/infer/expr.rs')
-rw-r--r-- | crates/ra_hir/src/ty/infer/expr.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/crates/ra_hir/src/ty/infer/expr.rs b/crates/ra_hir/src/ty/infer/expr.rs index 5e68a1678..20a7e9352 100644 --- a/crates/ra_hir/src/ty/infer/expr.rs +++ b/crates/ra_hir/src/ty/infer/expr.rs | |||
@@ -5,15 +5,15 @@ use std::sync::Arc; | |||
5 | 5 | ||
6 | use hir_def::{ | 6 | use hir_def::{ |
7 | builtin_type::Signedness, | 7 | builtin_type::Signedness, |
8 | generics::GenericParams, | ||
8 | path::{GenericArg, GenericArgs}, | 9 | path::{GenericArg, GenericArgs}, |
10 | resolver::resolver_for_expr, | ||
9 | }; | 11 | }; |
10 | use hir_expand::name; | 12 | use hir_expand::name; |
11 | 13 | ||
12 | use super::{BindingMode, Expectation, InferenceContext, InferenceDiagnostic, TypeMismatch}; | ||
13 | use crate::{ | 14 | use crate::{ |
14 | db::HirDatabase, | 15 | db::HirDatabase, |
15 | expr::{self, Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp}, | 16 | expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp}, |
16 | generics::{GenericParams, HasGenericParams}, | ||
17 | ty::{ | 17 | ty::{ |
18 | autoderef, method_resolution, op, CallableDef, InferTy, IntTy, Mutability, Namespace, | 18 | autoderef, method_resolution, op, CallableDef, InferTy, IntTy, Mutability, Namespace, |
19 | Obligation, ProjectionPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor, TypeWalk, | 19 | Obligation, ProjectionPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor, TypeWalk, |
@@ -22,6 +22,8 @@ use crate::{ | |||
22 | Adt, Name, | 22 | Adt, Name, |
23 | }; | 23 | }; |
24 | 24 | ||
25 | use super::{BindingMode, Expectation, InferenceContext, InferenceDiagnostic, TypeMismatch}; | ||
26 | |||
25 | impl<'a, D: HirDatabase> InferenceContext<'a, D> { | 27 | impl<'a, D: HirDatabase> InferenceContext<'a, D> { |
26 | pub(super) fn infer_expr(&mut self, tgt_expr: ExprId, expected: &Expectation) -> Ty { | 28 | pub(super) fn infer_expr(&mut self, tgt_expr: ExprId, expected: &Expectation) -> Ty { |
27 | let ty = self.infer_expr_inner(tgt_expr, expected); | 29 | let ty = self.infer_expr_inner(tgt_expr, expected); |
@@ -186,7 +188,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
186 | } | 188 | } |
187 | Expr::Path(p) => { | 189 | Expr::Path(p) => { |
188 | // FIXME this could be more efficient... | 190 | // FIXME this could be more efficient... |
189 | let resolver = expr::resolver_for_expr(self.db, self.owner, tgt_expr); | 191 | let resolver = resolver_for_expr(self.db, self.owner.into(), tgt_expr); |
190 | self.infer_path(&resolver, p, tgt_expr.into()).unwrap_or(Ty::Unknown) | 192 | self.infer_path(&resolver, p, tgt_expr.into()).unwrap_or(Ty::Unknown) |
191 | } | 193 | } |
192 | Expr::Continue => Ty::simple(TypeCtor::Never), | 194 | Expr::Continue => Ty::simple(TypeCtor::Never), |
@@ -532,7 +534,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
532 | ( | 534 | ( |
533 | ty, | 535 | ty, |
534 | self.db.type_for_def(func.into(), Namespace::Values), | 536 | self.db.type_for_def(func.into(), Namespace::Values), |
535 | Some(func.generic_params(self.db)), | 537 | Some(self.db.generic_params(func.id.into())), |
536 | ) | 538 | ) |
537 | } | 539 | } |
538 | None => (receiver_ty, Ty::Unknown, None), | 540 | None => (receiver_ty, Ty::Unknown, None), |
@@ -643,7 +645,9 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
643 | if let Some(trait_) = f.parent_trait(self.db) { | 645 | if let Some(trait_) = f.parent_trait(self.db) { |
644 | // construct a TraitDef | 646 | // construct a TraitDef |
645 | let substs = a_ty.parameters.prefix( | 647 | let substs = a_ty.parameters.prefix( |
646 | trait_.generic_params(self.db).count_params_including_parent(), | 648 | self.db |
649 | .generic_params(trait_.id.into()) | ||
650 | .count_params_including_parent(), | ||
647 | ); | 651 | ); |
648 | self.obligations.push(Obligation::Trait(TraitRef { trait_, substs })); | 652 | self.obligations.push(Obligation::Trait(TraitRef { trait_, substs })); |
649 | } | 653 | } |