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.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/crates/ra_hir/src/generics.rs b/crates/ra_hir/src/generics.rs
index 2e52c5871..826117ba5 100644
--- a/crates/ra_hir/src/generics.rs
+++ b/crates/ra_hir/src/generics.rs
@@ -8,7 +8,7 @@ use std::sync::Arc;
8use ra_syntax::ast::{self, NameOwner, TypeParamsOwner, TypeBoundsOwner}; 8use ra_syntax::ast::{self, NameOwner, TypeParamsOwner, TypeBoundsOwner};
9 9
10use crate::{ 10use crate::{
11 db::DefDatabase, 11 db::{ HirDatabase, DefDatabase},
12 Name, AsName, Function, Struct, Enum, Trait, TypeAlias, ImplBlock, Container, path::Path, type_ref::TypeRef, AdtDef 12 Name, AsName, Function, Struct, Enum, Trait, TypeAlias, ImplBlock, Container, path::Path, type_ref::TypeRef, AdtDef
13}; 13};
14 14
@@ -32,8 +32,8 @@ pub struct GenericParams {
32/// where clauses like `where T: Foo + Bar` are turned into multiple of these. 32/// where clauses like `where T: Foo + Bar` are turned into multiple of these.
33#[derive(Clone, PartialEq, Eq, Debug)] 33#[derive(Clone, PartialEq, Eq, Debug)]
34pub struct WherePredicate { 34pub struct WherePredicate {
35 type_ref: TypeRef, 35 pub(crate) type_ref: TypeRef,
36 trait_ref: Path, 36 pub(crate) trait_ref: Path,
37} 37}
38 38
39// FIXME: consts can have type parameters from their parents (i.e. associated consts of traits) 39// FIXME: consts can have type parameters from their parents (i.e. associated consts of traits)
@@ -148,6 +148,19 @@ impl GenericParams {
148 } 148 }
149} 149}
150 150
151impl GenericDef {
152 pub(crate) fn resolver(&self, db: &impl HirDatabase) -> crate::Resolver {
153 match self {
154 GenericDef::Function(inner) => inner.resolver(db),
155 GenericDef::Struct(inner) => inner.resolver(db),
156 GenericDef::Enum(inner) => inner.resolver(db),
157 GenericDef::Trait(inner) => inner.resolver(db),
158 GenericDef::TypeAlias(inner) => inner.resolver(db),
159 GenericDef::ImplBlock(inner) => inner.resolver(db),
160 }
161 }
162}
163
151impl From<Container> for GenericDef { 164impl From<Container> for GenericDef {
152 fn from(c: Container) -> Self { 165 fn from(c: Container) -> Self {
153 match c { 166 match c {