@@ -17,7 +17,7 @@ use hir_def::{
17
17
resolver:: resolver_for_expr,
18
18
ConstParamId , FieldId , ItemContainerId , Lookup ,
19
19
} ;
20
- use hir_expand:: name:: Name ;
20
+ use hir_expand:: name:: { name , Name } ;
21
21
use stdx:: always;
22
22
use syntax:: ast:: RangeOp ;
23
23
@@ -741,7 +741,6 @@ impl<'a> InferenceContext<'a> {
741
741
}
742
742
}
743
743
Expr :: Index { base, index } => {
744
- // FIXME: note down method resolution for the `index`/`index_mut` function
745
744
let base_ty = self . infer_expr_inner ( * base, & Expectation :: none ( ) ) ;
746
745
let index_ty = self . infer_expr ( * index, & Expectation :: none ( ) ) ;
747
746
@@ -758,6 +757,15 @@ impl<'a> InferenceContext<'a> {
758
757
adj. apply ( & mut self . table , base_ty)
759
758
} ) ;
760
759
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
+ }
761
769
self . resolve_associated_type_with_params (
762
770
self_ty,
763
771
self . resolve_ops_index_output ( ) ,
0 commit comments