aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorEvgenii P <[email protected]>2019-08-02 19:16:20 +0100
committerEvgenii P <[email protected]>2019-08-02 19:16:20 +0100
commit30bc3b93bec06256350b66869f2885ee71c3bedd (patch)
tree87422290ad2ea1a85f1805a2e9431b2983f0974c /crates
parentc417b98f02004a10819111903882482b39e50d17 (diff)
rustfmt
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/src/source_binder.rs23
-rw-r--r--crates/ra_hir/src/ty/method_resolution.rs12
-rw-r--r--crates/ra_ide_api/src/completion/complete_dot.rs12
3 files changed, 28 insertions, 19 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index 8496b143a..67cb19615 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -23,8 +23,8 @@ use crate::{
23 scope::{ExprScopes, ScopeId}, 23 scope::{ExprScopes, ScopeId},
24 BodySourceMap, 24 BodySourceMap,
25 }, 25 },
26 ty::method_resolution::implements_trait,
27 ids::LocationCtx, 26 ids::LocationCtx,
27 ty::method_resolution::implements_trait,
28 AsName, AstId, Const, Crate, DefWithBody, Either, Enum, Function, HirDatabase, HirFileId, 28 AsName, AstId, Const, Crate, DefWithBody, Either, Enum, Function, HirDatabase, HirFileId,
29 MacroDef, Module, Name, Path, PerNs, Resolver, Static, Struct, Trait, Ty, 29 MacroDef, Module, Name, Path, PerNs, Resolver, Static, Struct, Trait, Ty,
30}; 30};
@@ -414,22 +414,25 @@ impl SourceAnalyzer {
414 /// This function is used in `.await` syntax completion. 414 /// This function is used in `.await` syntax completion.
415 pub fn impls_future(&self, db: &impl HirDatabase, ty: Ty) -> bool { 415 pub fn impls_future(&self, db: &impl HirDatabase, ty: Ty) -> bool {
416 // Search for std::future::Future trait in scope 416 // Search for std::future::Future trait in scope
417 let future_trait = self.resolver.traits_in_scope(db) 417 let future_trait = self
418 .resolver
419 .traits_in_scope(db)
418 .into_iter() 420 .into_iter()
419 .filter(|t| { 421 .filter(|t| {
420 let std = t.module(db).parent(db) 422 let std = t
421 .and_then(|m| m 423 .module(db)
422 .name(db) 424 .parent(db)
423 .and_then(|n| Some(n.to_string() == "std"))) 425 .and_then(|m| m.name(db).and_then(|n| Some(n.to_string() == "std")))
424 .unwrap_or(false); 426 .unwrap_or(false);
425 427
426 let future = t.module(db).name(db) 428 let future = t
429 .module(db)
430 .name(db)
427 .and_then(|n| Some(n.to_string() == "future")) 431 .and_then(|n| Some(n.to_string() == "future"))
428 .unwrap_or(false); 432 .unwrap_or(false);
429 433
430 let future_trait = t.name(db) 434 let future_trait =
431 .and_then(|n| Some(n.to_string() == "Future")) 435 t.name(db).and_then(|n| Some(n.to_string() == "Future")).unwrap_or(false);
432 .unwrap_or(false);
433 436
434 std && future && future_trait 437 std && future && future_trait
435 }) 438 })
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs
index 2e2f88138..8731d6ba4 100644
--- a/crates/ra_hir/src/ty/method_resolution.rs
+++ b/crates/ra_hir/src/ty/method_resolution.rs
@@ -15,7 +15,7 @@ use crate::{
15 resolve::Resolver, 15 resolve::Resolver,
16 traits::TraitItem, 16 traits::TraitItem,
17 ty::primitive::{FloatBitness, UncertainFloatTy, UncertainIntTy}, 17 ty::primitive::{FloatBitness, UncertainFloatTy, UncertainIntTy},
18 ty::{Ty, TypeCtor, traits::Solution}, 18 ty::{traits::Solution, Ty, TypeCtor},
19 Crate, Function, HirDatabase, Module, Name, Trait, 19 Crate, Function, HirDatabase, Module, Name, Trait,
20}; 20};
21 21
@@ -255,14 +255,20 @@ fn iterate_inherent_methods<T>(
255 None 255 None
256} 256}
257 257
258pub(crate) fn implements_trait(ty: &Canonical<Ty>, db: &impl HirDatabase, resolver: &Resolver, krate: Crate, trait_: Trait) -> bool { 258pub(crate) fn implements_trait(
259 ty: &Canonical<Ty>,
260 db: &impl HirDatabase,
261 resolver: &Resolver,
262 krate: Crate,
263 trait_: Trait,
264) -> bool {
259 let env = lower::trait_env(db, resolver); 265 let env = lower::trait_env(db, resolver);
260 let goal = generic_implements_goal(db, env.clone(), trait_, ty.clone()); 266 let goal = generic_implements_goal(db, env.clone(), trait_, ty.clone());
261 let solution = db.trait_solve(krate, goal); 267 let solution = db.trait_solve(krate, goal);
262 268
263 if let Some(solution) = solution { 269 if let Some(solution) = solution {
264 if let Solution::Unique(_) = solution { 270 if let Solution::Unique(_) = solution {
265 return true 271 return true;
266 } 272 }
267 } 273 }
268 274
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs
index b6579be63..1dbbdb1bc 100644
--- a/crates/ra_ide_api/src/completion/complete_dot.rs
+++ b/crates/ra_ide_api/src/completion/complete_dot.rs
@@ -1,14 +1,14 @@
1use hir::{AdtDef, Ty, TypeCtor}; 1use hir::{AdtDef, Ty, TypeCtor};
2 2
3use crate::{completion::{ 3use crate::completion::completion_item::{Builder, CompletionKind};
4 completion_context::CompletionContext, 4use crate::{
5 completion_item::Completions, 5 completion::{completion_context::CompletionContext, completion_item::Completions},
6}, CompletionItem}; 6 CompletionItem,
7};
7use ra_syntax::ast::AstNode; 8use ra_syntax::ast::AstNode;
9use ra_syntax::TextRange;
8use ra_text_edit::TextEditBuilder; 10use ra_text_edit::TextEditBuilder;
9use rustc_hash::FxHashSet; 11use rustc_hash::FxHashSet;
10use crate::completion::completion_item::{Builder, CompletionKind};
11use ra_syntax::TextRange;
12 12
13/// Applies postfix edition but with CompletionKind::Reference 13/// Applies postfix edition but with CompletionKind::Reference
14fn postfix_reference(ctx: &CompletionContext, label: &str, detail: &str, snippet: &str) -> Builder { 14fn postfix_reference(ctx: &CompletionContext, label: &str, detail: &str, snippet: &str) -> Builder {