aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/generics.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-05-05 13:21:00 +0100
committerFlorian Diebold <[email protected]>2019-05-11 15:21:20 +0100
commit50bbf9eb09dc34781cc34e10bfba5f154e833123 (patch)
tree6ed1ff97c8923ddeea085c75d417d5185493ef11 /crates/ra_hir/src/generics.rs
parent940c538ecf42a53e5a0e0e9ebad7267c1fe843ca (diff)
Handle where clauses in trait solving
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 {