aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/impls.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/impls.rs')
-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;