@@ -17,7 +17,7 @@ use hir_def::{
1717 resolver:: resolver_for_expr,
1818 ConstParamId , FieldId , ItemContainerId , Lookup ,
1919} ;
20- use hir_expand:: name:: Name ;
20+ use hir_expand:: name:: { name , Name } ;
2121use stdx:: always;
2222use syntax:: ast:: RangeOp ;
2323
@@ -741,7 +741,6 @@ impl<'a> InferenceContext<'a> {
741741 }
742742 }
743743 Expr :: Index { base, index } => {
744- // FIXME: note down method resolution for the `index`/`index_mut` function
745744 let base_ty = self . infer_expr_inner ( * base, & Expectation :: none ( ) ) ;
746745 let index_ty = self . infer_expr ( * index, & Expectation :: none ( ) ) ;
747746
@@ -758,6 +757,15 @@ impl<'a> InferenceContext<'a> {
758757 adj. apply ( & mut self . table , base_ty)
759758 } ) ;
760759 self . write_expr_adj ( * base, adj) ;
760+ if let Some ( func) =
761+ self . db . trait_data ( index_trait) . method_by_name ( & name ! ( index) )
762+ {
763+ let substs = TyBuilder :: subst_for_def ( self . db , index_trait, None )
764+ . push ( self_ty. clone ( ) )
765+ . push ( index_ty. clone ( ) )
766+ . build ( ) ;
767+ self . write_method_resolution ( tgt_expr, func, substs. clone ( ) ) ;
768+ }
761769 self . resolve_associated_type_with_params (
762770 self_ty,
763771 self . resolve_ops_index_output ( ) ,
0 commit comments