diff options
Diffstat (limited to 'crates/ra_hir_def/src/generics.rs')
-rw-r--r-- | crates/ra_hir_def/src/generics.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs index e4e616519..f765e6edc 100644 --- a/crates/ra_hir_def/src/generics.rs +++ b/crates/ra_hir_def/src/generics.rs | |||
@@ -61,7 +61,7 @@ pub struct WherePredicate { | |||
61 | pub enum WherePredicateTarget { | 61 | pub enum WherePredicateTarget { |
62 | TypeRef(TypeRef), | 62 | TypeRef(TypeRef), |
63 | /// For desugared where predicates that can directly refer to a type param. | 63 | /// For desugared where predicates that can directly refer to a type param. |
64 | TypeParam(LocalTypeParamId) | 64 | TypeParam(LocalTypeParamId), |
65 | } | 65 | } |
66 | 66 | ||
67 | type SourceMap = ArenaMap<LocalTypeParamId, Either<ast::TraitDef, ast::TypeParam>>; | 67 | type SourceMap = ArenaMap<LocalTypeParamId, Either<ast::TraitDef, ast::TypeParam>>; |
@@ -197,7 +197,8 @@ impl GenericParams { | |||
197 | return; | 197 | return; |
198 | } | 198 | } |
199 | let bound = TypeBound::from_ast(bound); | 199 | let bound = TypeBound::from_ast(bound); |
200 | self.where_predicates.push(WherePredicate { target: WherePredicateTarget::TypeRef(type_ref), bound }); | 200 | self.where_predicates |
201 | .push(WherePredicate { target: WherePredicateTarget::TypeRef(type_ref), bound }); | ||
201 | } | 202 | } |
202 | 203 | ||
203 | fn fill_implicit_impl_trait_args(&mut self, type_ref: &TypeRef) { | 204 | fn fill_implicit_impl_trait_args(&mut self, type_ref: &TypeRef) { |
@@ -212,7 +213,7 @@ impl GenericParams { | |||
212 | for bound in bounds { | 213 | for bound in bounds { |
213 | self.where_predicates.push(WherePredicate { | 214 | self.where_predicates.push(WherePredicate { |
214 | target: WherePredicateTarget::TypeParam(param_id), | 215 | target: WherePredicateTarget::TypeParam(param_id), |
215 | bound: bound.clone() | 216 | bound: bound.clone(), |
216 | }); | 217 | }); |
217 | } | 218 | } |
218 | } | 219 | } |
@@ -226,9 +227,13 @@ impl GenericParams { | |||
226 | } | 227 | } |
227 | 228 | ||
228 | pub fn find_trait_self_param(&self) -> Option<LocalTypeParamId> { | 229 | pub fn find_trait_self_param(&self) -> Option<LocalTypeParamId> { |
229 | self.types | 230 | self.types.iter().find_map(|(id, p)| { |
230 | .iter() | 231 | if p.provenance == TypeParamProvenance::TraitSelf { |
231 | .find_map(|(id, p)| if p.provenance == TypeParamProvenance::TraitSelf { Some(id) } else { None }) | 232 | Some(id) |
233 | } else { | ||
234 | None | ||
235 | } | ||
236 | }) | ||
232 | } | 237 | } |
233 | } | 238 | } |
234 | 239 | ||