aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/infer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty/infer.rs')
-rw-r--r--crates/ra_hir/src/ty/infer.rs54
1 files changed, 26 insertions, 28 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index 2275ac151..c7772a7f6 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -462,7 +462,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
462 let remaining_index = remaining_index.unwrap_or(path.segments.len()); 462 let remaining_index = remaining_index.unwrap_or(path.segments.len());
463 let mut actual_def_ty: Option<Ty> = None; 463 let mut actual_def_ty: Option<Ty> = None;
464 464
465 let krate = resolver.module().map(|t| t.0.krate()); 465 let krate = resolver.krate()?;
466 // resolve intermediate segments 466 // resolve intermediate segments
467 for (i, segment) in path.segments[remaining_index..].iter().enumerate() { 467 for (i, segment) in path.segments[remaining_index..].iter().enumerate() {
468 let ty = match resolved { 468 let ty = match resolved {
@@ -504,38 +504,36 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
504 504
505 actual_def_ty = Some(ty.clone()); 505 actual_def_ty = Some(ty.clone());
506 506
507 let item: crate::ModuleDef = krate.and_then(|k| { 507 let item: crate::ModuleDef = ty.iterate_impl_items(self.db, krate, |item| {
508 ty.iterate_impl_items(self.db, k, |item| { 508 let matching_def: Option<crate::ModuleDef> = match item {
509 let matching_def: Option<crate::ModuleDef> = match item { 509 crate::ImplItem::Method(func) => {
510 crate::ImplItem::Method(func) => { 510 let sig = func.signature(self.db);
511 let sig = func.signature(self.db); 511 if segment.name == *sig.name() {
512 if segment.name == *sig.name() { 512 Some(func.into())
513 Some(func.into()) 513 } else {
514 } else { 514 None
515 None
516 }
517 } 515 }
516 }
518 517
519 crate::ImplItem::Const(konst) => { 518 crate::ImplItem::Const(konst) => {
520 let sig = konst.signature(self.db); 519 let sig = konst.signature(self.db);
521 if segment.name == *sig.name() { 520 if segment.name == *sig.name() {
522 Some(konst.into()) 521 Some(konst.into())
523 } else { 522 } else {
524 None 523 None
525 }
526 } 524 }
525 }
527 526
528 // FIXME: Resolve associated types 527 // FIXME: Resolve associated types
529 crate::ImplItem::TypeAlias(_) => None, 528 crate::ImplItem::TypeAlias(_) => None,
530 }; 529 };
531 match matching_def { 530 match matching_def {
532 Some(_) => { 531 Some(_) => {
533 self.write_assoc_resolution(id, item); 532 self.write_assoc_resolution(id, item);
534 return matching_def; 533 return matching_def;
535 }
536 None => None,
537 } 534 }
538 }) 535 None => None,
536 }
539 })?; 537 })?;
540 538
541 resolved = Resolution::Def(item.into()); 539 resolved = Resolution::Def(item.into());