Build correct SourceAnalyzer for traits

This commit is contained in:
Aleksey Kladov 2019-12-10 13:52:04 +01:00
parent baae1b3d00
commit d89996fd5b

View File

@ -62,6 +62,10 @@ fn try_get_resolver_for_node(db: &impl HirDatabase, node: InFile<&SyntaxNode>) -
let src = node.with_value(it);
Some(ImplBlock::from_source(db, src)?.id.resolver(db))
},
ast::TraitDef(it) => {
let src = node.with_value(it);
Some(Trait::from_source(db, src)?.id.resolver(db))
},
_ => match node.value.kind() {
FN_DEF | CONST_DEF | STATIC_DEF => {
let def = def_with_body_from_child_node(db, node)?;
@ -411,20 +415,6 @@ impl SourceAnalyzer {
)
}
// pub fn autoderef<'a>(
// &'a self,
// db: &'a impl HirDatabase,
// ty: Ty,
// ) -> impl Iterator<Item = Ty> + 'a {
// // There should be no inference vars in types passed here
// // FIXME check that?
// let canonical = Canonical { value: ty, num_vars: 0 };
// let krate = self.resolver.krate();
// let environment = TraitEnvironment::lower(db, &self.resolver);
// let ty = crate::ty::InEnvironment { value: canonical, environment };
// crate::ty::autoderef(db, krate, ty).map(|canonical| canonical.value)
// }
/// Checks that particular type `ty` implements `std::future::Future`.
/// This function is used in `.await` syntax completion.
pub fn impls_future(&self, db: &impl HirDatabase, ty: Type) -> bool {