aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir_def/src/generics.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs
index 94ce83564..b3e345082 100644
--- a/crates/ra_hir_def/src/generics.rs
+++ b/crates/ra_hir_def/src/generics.rs
@@ -58,11 +58,12 @@ impl GenericParams {
58 GenericDefId::TraitId(it) => { 58 GenericDefId::TraitId(it) => {
59 // traits get the Self type as an implicit first type parameter 59 // traits get the Self type as an implicit first type parameter
60 generics.params.alloc(GenericParamData { name: name::SELF_TYPE, default: None }); 60 generics.params.alloc(GenericParamData { name: name::SELF_TYPE, default: None });
61 generics.fill(&it.source(db).value);
62 // add super traits as bounds on Self 61 // add super traits as bounds on Self
63 // i.e., trait Foo: Bar is equivalent to trait Foo where Self: Bar 62 // i.e., trait Foo: Bar is equivalent to trait Foo where Self: Bar
64 let self_param = TypeRef::Path(name::SELF_TYPE.into()); 63 let self_param = TypeRef::Path(name::SELF_TYPE.into());
65 generics.fill_bounds(&it.source(db).value, self_param); 64 generics.fill_bounds(&it.source(db).value, self_param);
65
66 generics.fill(&it.source(db).value);
66 } 67 }
67 GenericDefId::TypeAliasId(it) => generics.fill(&it.lookup(db).source(db).value), 68 GenericDefId::TypeAliasId(it) => generics.fill(&it.lookup(db).source(db).value),
68 // Note that we don't add `Self` here: in `impl`s, `Self` is not a 69 // Note that we don't add `Self` here: in `impl`s, `Self` is not a
@@ -75,7 +76,7 @@ impl GenericParams {
75 generics 76 generics
76 } 77 }
77 78
78 fn fill(&mut self, node: &impl TypeParamsOwner) { 79 fn fill(&mut self, node: &dyn TypeParamsOwner) {
79 if let Some(params) = node.type_param_list() { 80 if let Some(params) = node.type_param_list() {
80 self.fill_params(params) 81 self.fill_params(params)
81 } 82 }
@@ -84,7 +85,7 @@ impl GenericParams {
84 } 85 }
85 } 86 }
86 87
87 fn fill_bounds(&mut self, node: &impl ast::TypeBoundsOwner, type_ref: TypeRef) { 88 fn fill_bounds(&mut self, node: &dyn ast::TypeBoundsOwner, type_ref: TypeRef) {
88 for bound in 89 for bound in
89 node.type_bound_list().iter().flat_map(|type_bound_list| type_bound_list.bounds()) 90 node.type_bound_list().iter().flat_map(|type_bound_list| type_bound_list.bounds())
90 { 91 {