Support path starting with a type

This commit is contained in:
uHOOCCOOHu 2019-09-12 02:01:07 +08:00
parent 2d79a1ad83
commit 4926bed426
No known key found for this signature in database
GPG key ID: CED392DE0C483D00
10 changed files with 210 additions and 127 deletions

View file

@ -26,7 +26,7 @@ use crate::{
},
ids::LocationCtx,
name,
path::{PathKind, PathSegment},
path::PathKind,
resolve::{ScopeDef, TypeNs, ValueNs},
ty::method_resolution::implements_trait,
AsName, AstId, Const, Crate, DefWithBody, Either, Enum, Function, HasBody, HirFileId, MacroDef,
@ -433,14 +433,10 @@ impl SourceAnalyzer {
/// 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: Ty) -> bool {
let std_future_path = Path {
kind: PathKind::Abs,
segments: vec![
PathSegment { name: name::STD, args_and_bindings: None },
PathSegment { name: name::FUTURE_MOD, args_and_bindings: None },
PathSegment { name: name::FUTURE_TYPE, args_and_bindings: None },
],
};
let std_future_path = Path::from_simple_segments(
PathKind::Abs,
vec![name::STD, name::FUTURE_MOD, name::FUTURE_TYPE],
);
let std_future_trait = match self.resolver.resolve_known_trait(db, &std_future_path) {
Some(it) => it,