Add representations of associated types

This adds three different representations, copied from the Chalk model:
 - `Ty::Projection` is an associated type projection written somewhere in the
   code, like `<Foo as Trait>::Bar`.
 - `Ty::UnselectedProjection` is similar, but we don't know the trait
   yet (`Foo::Bar`).
 - The above representations are normalized to their actual types during type
   inference. When that isn't possible, for example for `T::Item` inside an `fn
   foo<T: Iterator>`, the type is normalized to an application type with
   `TypeCtor::AssociatedType`.
This commit is contained in:
Florian Diebold 2019-08-05 21:13:34 +02:00
parent 3a9a0bc968
commit 6cfdfdecba
3 changed files with 113 additions and 0 deletions

View file

@ -838,6 +838,10 @@ impl TypeAlias {
self.id.module(db)
}
pub fn krate(self, db: &impl DefDatabase) -> Option<Crate> {
self.module(db).krate(db)
}
/// The containing impl block, if this is a method.
pub fn impl_block(self, db: &impl DefDatabase) -> Option<ImplBlock> {
let module_impls = db.impls_in_module(self.module(db));