diff options
Diffstat (limited to 'crates/ra_hir_ty/src/lower.rs')
-rw-r--r-- | crates/ra_hir_ty/src/lower.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs index d31f6a2d2..eab91229e 100644 --- a/crates/ra_hir_ty/src/lower.rs +++ b/crates/ra_hir_ty/src/lower.rs | |||
@@ -321,9 +321,8 @@ pub(super) fn substs_from_path_segment( | |||
321 | let mut substs = Vec::new(); | 321 | let mut substs = Vec::new(); |
322 | let def_generics = def_generic.map(|def| generics(db, def.into())); | 322 | let def_generics = def_generic.map(|def| generics(db, def.into())); |
323 | 323 | ||
324 | let (parent_param_count, param_count) = | 324 | let (total_len, parent_len, child_len) = def_generics.map_or((0, 0, 0), |g| g.len_split()); |
325 | def_generics.map_or((0, 0), |g| (g.count_parent_params(), g.params.params.len())); | 325 | substs.extend(iter::repeat(Ty::Unknown).take(parent_len)); |
326 | substs.extend(iter::repeat(Ty::Unknown).take(parent_param_count)); | ||
327 | if add_self_param { | 326 | if add_self_param { |
328 | // FIXME this add_self_param argument is kind of a hack: Traits have the | 327 | // FIXME this add_self_param argument is kind of a hack: Traits have the |
329 | // Self type as an implicit first type parameter, but it can't be | 328 | // Self type as an implicit first type parameter, but it can't be |
@@ -334,8 +333,8 @@ pub(super) fn substs_from_path_segment( | |||
334 | if let Some(generic_args) = &segment.args_and_bindings { | 333 | if let Some(generic_args) = &segment.args_and_bindings { |
335 | // if args are provided, it should be all of them, but we can't rely on that | 334 | // if args are provided, it should be all of them, but we can't rely on that |
336 | let self_param_correction = if add_self_param { 1 } else { 0 }; | 335 | let self_param_correction = if add_self_param { 1 } else { 0 }; |
337 | let param_count = param_count - self_param_correction; | 336 | let child_len = child_len + self_param_correction; |
338 | for arg in generic_args.args.iter().take(param_count) { | 337 | for arg in generic_args.args.iter().take(child_len) { |
339 | match arg { | 338 | match arg { |
340 | GenericArg::Type(type_ref) => { | 339 | GenericArg::Type(type_ref) => { |
341 | let ty = Ty::from_hir(db, resolver, type_ref); | 340 | let ty = Ty::from_hir(db, resolver, type_ref); |
@@ -346,10 +345,10 @@ pub(super) fn substs_from_path_segment( | |||
346 | } | 345 | } |
347 | // add placeholders for args that were not provided | 346 | // add placeholders for args that were not provided |
348 | let supplied_params = substs.len(); | 347 | let supplied_params = substs.len(); |
349 | for _ in supplied_params..parent_param_count + param_count { | 348 | for _ in supplied_params..total_len { |
350 | substs.push(Ty::Unknown); | 349 | substs.push(Ty::Unknown); |
351 | } | 350 | } |
352 | assert_eq!(substs.len(), parent_param_count + param_count); | 351 | assert_eq!(substs.len(), total_len); |
353 | 352 | ||
354 | // handle defaults | 353 | // handle defaults |
355 | if let Some(def_generic) = def_generic { | 354 | if let Some(def_generic) = def_generic { |