diff options
author | Florian Diebold <[email protected]> | 2019-04-09 21:04:59 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-04-14 10:28:53 +0100 |
commit | 9339241b78ef7474e88de37738bdbece7767d333 (patch) | |
tree | c253d26db406b0f6cac5db67a054f4334b016486 /crates/ra_hir/src/ty/lower.rs | |
parent | a1ed53a4f183b5826162eb9e998207b92be9c57f (diff) |
Some cleanup
Diffstat (limited to 'crates/ra_hir/src/ty/lower.rs')
-rw-r--r-- | crates/ra_hir/src/ty/lower.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs index ccacb5e73..bb8fdd8c7 100644 --- a/crates/ra_hir/src/ty/lower.rs +++ b/crates/ra_hir/src/ty/lower.rs | |||
@@ -5,6 +5,7 @@ | |||
5 | //! - Building the type for an item: This happens through the `type_for_def` query. | 5 | //! - Building the type for an item: This happens through the `type_for_def` query. |
6 | //! | 6 | //! |
7 | //! This usually involves resolving names, collecting generic arguments etc. | 7 | //! This usually involves resolving names, collecting generic arguments etc. |
8 | use std::iter; | ||
8 | 9 | ||
9 | use crate::{ | 10 | use crate::{ |
10 | Function, Struct, StructField, Enum, EnumVariant, Path, | 11 | Function, Struct, StructField, Enum, EnumVariant, Path, |
@@ -172,16 +173,18 @@ pub(super) fn substs_from_path_segment( | |||
172 | ) -> Substs { | 173 | ) -> Substs { |
173 | let mut substs = Vec::new(); | 174 | let mut substs = Vec::new(); |
174 | let parent_param_count = def_generics.count_parent_params(); | 175 | let parent_param_count = def_generics.count_parent_params(); |
175 | substs.extend((0..parent_param_count).map(|_| Ty::Unknown)); | 176 | substs.extend(iter::repeat(Ty::Unknown).take(parent_param_count)); |
176 | if add_self_param { | 177 | if add_self_param { |
177 | // FIXME this add_self_param argument is kind of a hack: Traits have the | 178 | // FIXME this add_self_param argument is kind of a hack: Traits have the |
178 | // Self type as an implicit first type parameter, but it can't be | 179 | // Self type as an implicit first type parameter, but it can't be |
179 | // actually provided in the type arguments | 180 | // actually provided in the type arguments |
181 | // (well, actually sometimes it can, in the form of type-relative paths: `<Foo as Default>::default()`) | ||
180 | substs.push(Ty::Unknown); | 182 | substs.push(Ty::Unknown); |
181 | } | 183 | } |
182 | if let Some(generic_args) = &segment.args_and_bindings { | 184 | if let Some(generic_args) = &segment.args_and_bindings { |
183 | // if args are provided, it should be all of them, but we can't rely on that | 185 | // if args are provided, it should be all of them, but we can't rely on that |
184 | let param_count = def_generics.params.len(); | 186 | let self_param_correction = if add_self_param { 1 } else { 0 }; |
187 | let param_count = def_generics.params.len() - self_param_correction; | ||
185 | for arg in generic_args.args.iter().take(param_count) { | 188 | for arg in generic_args.args.iter().take(param_count) { |
186 | match arg { | 189 | match arg { |
187 | GenericArg::Type(type_ref) => { | 190 | GenericArg::Type(type_ref) => { |