From 0358f5fdebb7f462e72aaf77eea8c842709127fc Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 14 Jan 2020 11:13:07 +0100 Subject: [PATCH] Use lang-items to resolve future trait --- crates/ra_hir/src/source_analyzer.rs | 19 +++++++++---------- crates/ra_ide/src/completion/complete_dot.rs | 1 + 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs index f0511c742c4..bd5ef146634 100644 --- a/crates/ra_hir/src/source_analyzer.rs +++ b/crates/ra_hir/src/source_analyzer.rs @@ -15,7 +15,6 @@ }, expr::{ExprId, PatId}, nameres::ModuleSource, - path::path, resolver::{self, resolver_for_scope, HasResolver, Resolver, TypeNs, ValueNs}, AssocItemId, DefWithBodyId, }; @@ -399,20 +398,20 @@ pub fn iterate_path_candidates( /// 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 { - let std_future_path = path![std::future::Future]; - - let std_future_trait = match self.resolver.resolve_known_trait(db, &std_future_path) { - Some(it) => it.into(), - _ => return false, - }; - let krate = match self.resolver.krate() { Some(krate) => krate, - _ => return false, + None => return false, + }; + + let std_future_trait = + db.lang_item(krate, "future_trait".into()).and_then(|it| it.as_trait()); + let std_future_trait = match std_future_trait { + Some(it) => it, + None => return false, }; let canonical_ty = Canonical { value: ty.ty.value, num_vars: 0 }; - implements_trait(&canonical_ty, db, &self.resolver, krate.into(), std_future_trait) + implements_trait(&canonical_ty, db, &self.resolver, krate, std_future_trait) } pub fn expand( diff --git a/crates/ra_ide/src/completion/complete_dot.rs b/crates/ra_ide/src/completion/complete_dot.rs index 210a685e408..fe02e36b354 100644 --- a/crates/ra_ide/src/completion/complete_dot.rs +++ b/crates/ra_ide/src/completion/complete_dot.rs @@ -525,6 +525,7 @@ fn foo(a: A) { //- /std/lib.rs pub mod future { + #[lang = "future_trait"] pub trait Future {} } "###, CompletionKind::Keyword),