aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/method_resolution.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty/method_resolution.rs')
-rw-r--r--crates/ra_hir/src/ty/method_resolution.rs38
1 files changed, 16 insertions, 22 deletions
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs
index 34817a5ec..646e58aa9 100644
--- a/crates/ra_hir/src/ty/method_resolution.rs
+++ b/crates/ra_hir/src/ty/method_resolution.rs
@@ -192,23 +192,20 @@ fn iterate_trait_method_candidates<T>(
192 // iteration 192 // iteration
193 let mut known_implemented = false; 193 let mut known_implemented = false;
194 for item in data.items() { 194 for item in data.items() {
195 match item { 195 if let TraitItem::Function(m) = *item {
196 &TraitItem::Function(m) => { 196 let sig = m.signature(db);
197 let sig = m.signature(db); 197 if name.map_or(true, |name| sig.name() == name) && sig.has_self_param() {
198 if name.map_or(true, |name| sig.name() == name) && sig.has_self_param() { 198 if !known_implemented {
199 if !known_implemented { 199 let trait_ref = canonical_trait_ref(db, t, ty.clone());
200 let trait_ref = canonical_trait_ref(db, t, ty.clone()); 200 if db.implements(krate, trait_ref).is_none() {
201 if db.implements(krate, trait_ref).is_none() { 201 continue 'traits;
202 continue 'traits;
203 }
204 }
205 known_implemented = true;
206 if let Some(result) = callback(&ty.value, m) {
207 return Some(result);
208 } 202 }
209 } 203 }
204 known_implemented = true;
205 if let Some(result) = callback(&ty.value, m) {
206 return Some(result);
207 }
210 } 208 }
211 _ => {}
212 } 209 }
213 } 210 }
214 } 211 }
@@ -230,16 +227,13 @@ fn iterate_inherent_methods<T>(
230 227
231 for impl_block in impls.lookup_impl_blocks(&ty.value) { 228 for impl_block in impls.lookup_impl_blocks(&ty.value) {
232 for item in impl_block.items(db) { 229 for item in impl_block.items(db) {
233 match item { 230 if let ImplItem::Method(f) = item {
234 ImplItem::Method(f) => { 231 let sig = f.signature(db);
235 let sig = f.signature(db); 232 if name.map_or(true, |name| sig.name() == name) && sig.has_self_param() {
236 if name.map_or(true, |name| sig.name() == name) && sig.has_self_param() { 233 if let Some(result) = callback(&ty.value, f) {
237 if let Some(result) = callback(&ty.value, f) { 234 return Some(result);
238 return Some(result);
239 }
240 } 235 }
241 } 236 }
242 _ => {}
243 } 237 }
244 } 238 }
245 } 239 }