aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-02-07 14:13:15 +0000
committerFlorian Diebold <[email protected]>2020-02-07 17:28:10 +0000
commitdded90a748737c3661aad043524f2248e324c867 (patch)
treef871cdf435b0c4d5cafa9f4c3f5c725e823e8088 /crates/ra_hir_def
parent6787f124b5557120cd1e4557cbdb59aa7f215be6 (diff)
Formatting
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r--crates/ra_hir_def/src/generics.rs17
-rw-r--r--crates/ra_hir_def/src/type_ref.rs4
2 files changed, 12 insertions, 9 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 {
61pub enum WherePredicateTarget { 61pub 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
67type SourceMap = ArenaMap<LocalTypeParamId, Either<ast::TraitDef, ast::TypeParam>>; 67type 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
diff --git a/crates/ra_hir_def/src/type_ref.rs b/crates/ra_hir_def/src/type_ref.rs
index 109414770..102fdb13d 100644
--- a/crates/ra_hir_def/src/type_ref.rs
+++ b/crates/ra_hir_def/src/type_ref.rs
@@ -131,9 +131,7 @@ impl TypeRef {
131 fn go(type_ref: &TypeRef, f: &mut impl FnMut(&TypeRef)) { 131 fn go(type_ref: &TypeRef, f: &mut impl FnMut(&TypeRef)) {
132 f(type_ref); 132 f(type_ref);
133 match type_ref { 133 match type_ref {
134 TypeRef::Fn(types) | TypeRef::Tuple(types) => { 134 TypeRef::Fn(types) | TypeRef::Tuple(types) => types.iter().for_each(|t| go(t, f)),
135 types.iter().for_each(|t| go(t, f))
136 }
137 TypeRef::RawPtr(type_ref, _) 135 TypeRef::RawPtr(type_ref, _)
138 | TypeRef::Reference(type_ref, _) 136 | TypeRef::Reference(type_ref, _)
139 | TypeRef::Array(type_ref) 137 | TypeRef::Array(type_ref)