aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/infer
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src/infer')
-rw-r--r--crates/ra_hir_ty/src/infer/expr.rs18
1 files changed, 8 insertions, 10 deletions
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs
index e52040eb5..2c296987c 100644
--- a/crates/ra_hir_ty/src/infer/expr.rs
+++ b/crates/ra_hir_ty/src/infer/expr.rs
@@ -660,10 +660,9 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
660 generic_args: Option<&GenericArgs>, 660 generic_args: Option<&GenericArgs>,
661 receiver_ty: &Ty, 661 receiver_ty: &Ty,
662 ) -> Substs { 662 ) -> Substs {
663 let (parent_param_count, param_count) = def_generics 663 let (total_len, _parent_len, child_len) =
664 .as_ref() 664 def_generics.as_ref().map_or((0, 0, 0), |g| g.len_split());
665 .map_or((0, 0), |g| (g.count_parent_params(), g.params.params.len())); 665 let mut substs = Vec::with_capacity(total_len);
666 let mut substs = Vec::with_capacity(parent_param_count + param_count);
667 // Parent arguments are unknown, except for the receiver type 666 // Parent arguments are unknown, except for the receiver type
668 if let Some(parent_generics) = def_generics.as_ref().map(|p| p.iter_parent()) { 667 if let Some(parent_generics) = def_generics.as_ref().map(|p| p.iter_parent()) {
669 for (_id, param) in parent_generics { 668 for (_id, param) in parent_generics {
@@ -677,7 +676,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
677 // handle provided type arguments 676 // handle provided type arguments
678 if let Some(generic_args) = generic_args { 677 if let Some(generic_args) = generic_args {
679 // if args are provided, it should be all of them, but we can't rely on that 678 // if args are provided, it should be all of them, but we can't rely on that
680 for arg in generic_args.args.iter().take(param_count) { 679 for arg in generic_args.args.iter().take(child_len) {
681 match arg { 680 match arg {
682 GenericArg::Type(type_ref) => { 681 GenericArg::Type(type_ref) => {
683 let ty = self.make_ty(type_ref); 682 let ty = self.make_ty(type_ref);
@@ -687,10 +686,10 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
687 } 686 }
688 }; 687 };
689 let supplied_params = substs.len(); 688 let supplied_params = substs.len();
690 for _ in supplied_params..parent_param_count + param_count { 689 for _ in supplied_params..total_len {
691 substs.push(Ty::Unknown); 690 substs.push(Ty::Unknown);
692 } 691 }
693 assert_eq!(substs.len(), parent_param_count + param_count); 692 assert_eq!(substs.len(), total_len);
694 Substs(substs.into()) 693 Substs(substs.into())
695 } 694 }
696 695
@@ -709,9 +708,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
709 CallableDef::FunctionId(f) => { 708 CallableDef::FunctionId(f) => {
710 if let ContainerId::TraitId(trait_) = f.lookup(self.db).container { 709 if let ContainerId::TraitId(trait_) = f.lookup(self.db).container {
711 // construct a TraitDef 710 // construct a TraitDef
712 let substs = a_ty.parameters.prefix( 711 let substs =
713 generics(self.db, trait_.into()).count_params_including_parent(), 712 a_ty.parameters.prefix(generics(self.db, trait_.into()).len());
714 );
715 self.obligations.push(Obligation::Trait(TraitRef { 713 self.obligations.push(Obligation::Trait(TraitRef {
716 trait_: trait_.into(), 714 trait_: trait_.into(),
717 substs, 715 substs,