diff options
Diffstat (limited to 'crates/ra_hir_ty')
-rw-r--r-- | crates/ra_hir_ty/src/infer/expr.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/lower.rs | 1 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/utils.rs | 3 |
4 files changed, 6 insertions, 4 deletions
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs index 31259a01d..97cb20cea 100644 --- a/crates/ra_hir_ty/src/infer/expr.rs +++ b/crates/ra_hir_ty/src/infer/expr.rs | |||
@@ -10,7 +10,7 @@ use hir_def::{ | |||
10 | resolver::resolver_for_expr, | 10 | resolver::resolver_for_expr, |
11 | AdtId, AssocContainerId, Lookup, StructFieldId, | 11 | AdtId, AssocContainerId, Lookup, StructFieldId, |
12 | }; | 12 | }; |
13 | use hir_expand::name::{name, Name}; | 13 | use hir_expand::name::Name; |
14 | use ra_syntax::ast::RangeOp; | 14 | use ra_syntax::ast::RangeOp; |
15 | 15 | ||
16 | use crate::{ | 16 | use crate::{ |
@@ -654,7 +654,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
654 | // Parent arguments are unknown, except for the receiver type | 654 | // Parent arguments are unknown, except for the receiver type |
655 | if let Some(parent_generics) = def_generics.as_ref().map(|p| p.iter_parent()) { | 655 | if let Some(parent_generics) = def_generics.as_ref().map(|p| p.iter_parent()) { |
656 | for (_id, param) in parent_generics { | 656 | for (_id, param) in parent_generics { |
657 | if param.name == name![Self] { | 657 | if param.provenance == hir_def::generics::TypeParamProvenance::TraitSelf { |
658 | substs.push(receiver_ty.clone()); | 658 | substs.push(receiver_ty.clone()); |
659 | } else { | 659 | } else { |
660 | substs.push(Ty::Unknown); | 660 | substs.push(Ty::Unknown); |
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index c64b81f98..cb7a60352 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs | |||
@@ -368,7 +368,7 @@ impl Substs { | |||
368 | /// Return Substs that replace each parameter by itself (i.e. `Ty::Param`). | 368 | /// Return Substs that replace each parameter by itself (i.e. `Ty::Param`). |
369 | pub(crate) fn identity(generic_params: &Generics) -> Substs { | 369 | pub(crate) fn identity(generic_params: &Generics) -> Substs { |
370 | Substs( | 370 | Substs( |
371 | generic_params.iter().map(|(idx, p)| Ty::Param { idx, name: p.name.clone() }).collect(), | 371 | generic_params.iter().map(|(idx, p)| Ty::Param { idx, name: p.name.clone().unwrap_or_else(Name::missing) }).collect(), |
372 | ) | 372 | ) |
373 | } | 373 | } |
374 | 374 | ||
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs index 39406d8ce..6f7681475 100644 --- a/crates/ra_hir_ty/src/lower.rs +++ b/crates/ra_hir_ty/src/lower.rs | |||
@@ -341,6 +341,7 @@ pub(super) fn substs_from_path_segment( | |||
341 | // Self type as an implicit first type parameter, but it can't be | 341 | // Self type as an implicit first type parameter, but it can't be |
342 | // actually provided in the type arguments | 342 | // actually provided in the type arguments |
343 | // (well, actually sometimes it can, in the form of type-relative paths: `<Foo as Default>::default()`) | 343 | // (well, actually sometimes it can, in the form of type-relative paths: `<Foo as Default>::default()`) |
344 | // TODO handle this using type param provenance | ||
344 | substs.push(Ty::Unknown); | 345 | substs.push(Ty::Unknown); |
345 | } | 346 | } |
346 | if let Some(generic_args) = &segment.args_and_bindings { | 347 | if let Some(generic_args) = &segment.args_and_bindings { |
diff --git a/crates/ra_hir_ty/src/utils.rs b/crates/ra_hir_ty/src/utils.rs index 0b1806a84..314a3241f 100644 --- a/crates/ra_hir_ty/src/utils.rs +++ b/crates/ra_hir_ty/src/utils.rs | |||
@@ -127,7 +127,8 @@ impl Generics { | |||
127 | self.find_param(param).0 | 127 | self.find_param(param).0 |
128 | } | 128 | } |
129 | pub(crate) fn param_name(&self, param: TypeParamId) -> Name { | 129 | pub(crate) fn param_name(&self, param: TypeParamId) -> Name { |
130 | self.find_param(param).1.name.clone() | 130 | // FIXME make this return Option |
131 | self.find_param(param).1.name.clone().unwrap_or_else(Name::missing) | ||
131 | } | 132 | } |
132 | fn find_param(&self, param: TypeParamId) -> (u32, &TypeParamData) { | 133 | fn find_param(&self, param: TypeParamId) -> (u32, &TypeParamData) { |
133 | if param.parent == self.def { | 134 | if param.parent == self.def { |