aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-27 18:27:45 +0000
committerGitHub <[email protected]>2019-11-27 18:27:45 +0000
commit4946169a96f3d442f463724af481fdb760381ccb (patch)
treeb68c3da4bb47e0a285968319bfb33b44cbfd5546 /crates/ra_ide_api/src
parent2798beeeb05ab0e71773a2ed51b7b0c90bf6b06a (diff)
parent47ec2ceb12df756b3482ddd2b1947e4b38f23706 (diff)
Merge #2429
2429: Move type inference to a separate crate r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r--crates/ra_ide_api/src/impls.rs17
1 files changed, 2 insertions, 15 deletions
diff --git a/crates/ra_ide_api/src/impls.rs b/crates/ra_ide_api/src/impls.rs
index b3ebd9145..aa480e399 100644
--- a/crates/ra_ide_api/src/impls.rs
+++ b/crates/ra_ide_api/src/impls.rs
@@ -1,6 +1,6 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use hir::{ApplicationTy, FromSource, ImplBlock, Ty, TypeCtor}; 3use hir::{FromSource, ImplBlock};
4use ra_db::SourceDatabase; 4use ra_db::SourceDatabase;
5use ra_syntax::{algo::find_node_at_offset, ast, AstNode}; 5use ra_syntax::{algo::find_node_at_offset, ast, AstNode};
6 6
@@ -61,7 +61,7 @@ fn impls_for_def(
61 Some( 61 Some(
62 impls 62 impls
63 .into_iter() 63 .into_iter()
64 .filter(|impl_block| is_equal_for_find_impls(&ty, &impl_block.target_ty(db))) 64 .filter(|impl_block| ty.is_equal_for_find_impls(&impl_block.target_ty(db)))
65 .map(|imp| imp.to_nav(db)) 65 .map(|imp| imp.to_nav(db))
66 .collect(), 66 .collect(),
67 ) 67 )
@@ -82,19 +82,6 @@ fn impls_for_trait(
82 Some(impls.into_iter().map(|imp| imp.to_nav(db)).collect()) 82 Some(impls.into_iter().map(|imp| imp.to_nav(db)).collect())
83} 83}
84 84
85fn is_equal_for_find_impls(original_ty: &Ty, impl_ty: &Ty) -> bool {
86 match (original_ty, impl_ty) {
87 (Ty::Apply(a_original_ty), Ty::Apply(ApplicationTy { ctor, parameters })) => match ctor {
88 TypeCtor::Ref(..) => match parameters.as_single() {
89 Ty::Apply(a_ty) => a_original_ty.ctor == a_ty.ctor,
90 _ => false,
91 },
92 _ => a_original_ty.ctor == *ctor,
93 },
94 _ => false,
95 }
96}
97
98#[cfg(test)] 85#[cfg(test)]
99mod tests { 86mod tests {
100 use crate::mock_analysis::analysis_and_position; 87 use crate::mock_analysis::analysis_and_position;