aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/method_resolution.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src/method_resolution.rs')
-rw-r--r--crates/ra_hir_ty/src/method_resolution.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/ra_hir_ty/src/method_resolution.rs
index 7b0ff8161..74b908c2e 100644
--- a/crates/ra_hir_ty/src/method_resolution.rs
+++ b/crates/ra_hir_ty/src/method_resolution.rs
@@ -447,6 +447,25 @@ fn iterate_inherent_methods<T>(
447 None 447 None
448} 448}
449 449
450/// Returns the self type for the index trait call.
451pub fn resolve_indexing_op(
452 db: &impl HirDatabase,
453 ty: &Canonical<Ty>,
454 env: Arc<TraitEnvironment>,
455 krate: CrateId,
456 index_trait: TraitId,
457) -> Option<Canonical<Ty>> {
458 let ty = InEnvironment { value: ty.clone(), environment: env.clone() };
459 let deref_chain = autoderef_method_receiver(db, krate, ty);
460 for ty in deref_chain {
461 let goal = generic_implements_goal(db, env.clone(), index_trait, ty.clone());
462 if db.trait_solve(krate, goal).is_some() {
463 return Some(ty);
464 }
465 }
466 None
467}
468
450fn is_valid_candidate( 469fn is_valid_candidate(
451 db: &impl HirDatabase, 470 db: &impl HirDatabase,
452 name: Option<&Name>, 471 name: Option<&Name>,