aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/generics.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/generics.rs')
-rw-r--r--crates/ra_hir/src/generics.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/crates/ra_hir/src/generics.rs b/crates/ra_hir/src/generics.rs
index 77fb76bfc..ccb777492 100644
--- a/crates/ra_hir/src/generics.rs
+++ b/crates/ra_hir/src/generics.rs
@@ -26,8 +26,9 @@ pub struct GenericParam {
26} 26}
27 27
28/// Data about the generic parameters of a function, struct, impl, etc. 28/// Data about the generic parameters of a function, struct, impl, etc.
29#[derive(Clone, PartialEq, Eq, Debug, Default)] 29#[derive(Clone, PartialEq, Eq, Debug)]
30pub struct GenericParams { 30pub struct GenericParams {
31 pub(crate) def: GenericDef,
31 pub(crate) parent_params: Option<Arc<GenericParams>>, 32 pub(crate) parent_params: Option<Arc<GenericParams>>,
32 pub(crate) params: Vec<GenericParam>, 33 pub(crate) params: Vec<GenericParam>,
33 pub(crate) where_predicates: Vec<WherePredicate>, 34 pub(crate) where_predicates: Vec<WherePredicate>,
@@ -69,7 +70,6 @@ impl GenericParams {
69 db: &(impl DefDatabase + AstDatabase), 70 db: &(impl DefDatabase + AstDatabase),
70 def: GenericDef, 71 def: GenericDef,
71 ) -> Arc<GenericParams> { 72 ) -> Arc<GenericParams> {
72 let mut generics = GenericParams::default();
73 let parent = match def { 73 let parent = match def {
74 GenericDef::Function(it) => it.container(db).map(GenericDef::from), 74 GenericDef::Function(it) => it.container(db).map(GenericDef::from),
75 GenericDef::TypeAlias(it) => it.container(db).map(GenericDef::from), 75 GenericDef::TypeAlias(it) => it.container(db).map(GenericDef::from),
@@ -77,7 +77,12 @@ impl GenericParams {
77 GenericDef::Adt(_) | GenericDef::Trait(_) => None, 77 GenericDef::Adt(_) | GenericDef::Trait(_) => None,
78 GenericDef::ImplBlock(_) => None, 78 GenericDef::ImplBlock(_) => None,
79 }; 79 };
80 generics.parent_params = parent.map(|p| db.generic_params(p)); 80 let mut generics = GenericParams {
81 def,
82 params: Vec::new(),
83 parent_params: parent.map(|p| db.generic_params(p)),
84 where_predicates: Vec::new(),
85 };
81 let start = generics.parent_params.as_ref().map(|p| p.params.len()).unwrap_or(0) as u32; 86 let start = generics.parent_params.as_ref().map(|p| p.params.len()).unwrap_or(0) as u32;
82 // FIXME: add `: Sized` bound for everything except for `Self` in traits 87 // FIXME: add `: Sized` bound for everything except for `Self` in traits
83 match def { 88 match def {