mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
Handle where clauses in trait solving
This commit is contained in:
parent
940c538ecf
commit
50bbf9eb09
6 changed files with 188 additions and 29 deletions
|
@ -8,7 +8,7 @@ use std::sync::Arc;
|
|||
use ra_syntax::ast::{self, NameOwner, TypeParamsOwner, TypeBoundsOwner};
|
||||
|
||||
use crate::{
|
||||
db::DefDatabase,
|
||||
db::{ HirDatabase, DefDatabase},
|
||||
Name, AsName, Function, Struct, Enum, Trait, TypeAlias, ImplBlock, Container, path::Path, type_ref::TypeRef, AdtDef
|
||||
};
|
||||
|
||||
|
@ -32,8 +32,8 @@ pub struct GenericParams {
|
|||
/// where clauses like `where T: Foo + Bar` are turned into multiple of these.
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct WherePredicate {
|
||||
type_ref: TypeRef,
|
||||
trait_ref: Path,
|
||||
pub(crate) type_ref: TypeRef,
|
||||
pub(crate) trait_ref: Path,
|
||||
}
|
||||
|
||||
// FIXME: consts can have type parameters from their parents (i.e. associated consts of traits)
|
||||
|
@ -148,6 +148,19 @@ impl GenericParams {
|
|||
}
|
||||
}
|
||||
|
||||
impl GenericDef {
|
||||
pub(crate) fn resolver(&self, db: &impl HirDatabase) -> crate::Resolver {
|
||||
match self {
|
||||
GenericDef::Function(inner) => inner.resolver(db),
|
||||
GenericDef::Struct(inner) => inner.resolver(db),
|
||||
GenericDef::Enum(inner) => inner.resolver(db),
|
||||
GenericDef::Trait(inner) => inner.resolver(db),
|
||||
GenericDef::TypeAlias(inner) => inner.resolver(db),
|
||||
GenericDef::ImplBlock(inner) => inner.resolver(db),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Container> for GenericDef {
|
||||
fn from(c: Container) -> Self {
|
||||
match c {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue