From 4926bed42680d329f906be93450bec6b2ba0e99b Mon Sep 17 00:00:00 2001 From: uHOOCCOOHu Date: Thu, 12 Sep 2019 02:01:07 +0800 Subject: Support path starting with a type --- crates/ra_hir/src/source_binder.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'crates/ra_hir/src/source_binder.rs') diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index cff55b640..59053cda3 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs @@ -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, -- cgit v1.2.3 From 7ed3be32916facf3b709d5277381408cd3ec134a Mon Sep 17 00:00:00 2001 From: uHOOCCOOHu Date: Sun, 15 Sep 2019 20:14:33 +0800 Subject: Define known paths and group names --- crates/ra_hir/src/source_binder.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'crates/ra_hir/src/source_binder.rs') diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 59053cda3..2a907c9f1 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs @@ -25,8 +25,7 @@ use crate::{ BodySourceMap, }, ids::LocationCtx, - name, - path::PathKind, + path::known, resolve::{ScopeDef, TypeNs, ValueNs}, ty::method_resolution::implements_trait, AsName, AstId, Const, Crate, DefWithBody, Either, Enum, Function, HasBody, HirFileId, MacroDef, @@ -433,10 +432,7 @@ 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::from_simple_segments( - PathKind::Abs, - vec![name::STD, name::FUTURE_MOD, name::FUTURE_TYPE], - ); + let std_future_path = known::std_future_future(); let std_future_trait = match self.resolver.resolve_known_trait(db, &std_future_path) { Some(it) => it, -- cgit v1.2.3