@@ -104,7 +104,7 @@ impl InferenceContext<'_> {
104104 Expr :: RecordLit { path : _, fields, spread, ellipsis : _, is_assignee_expr : _ } => {
105105 self . infer_mut_not_expr_iter ( fields. iter ( ) . map ( |it| it. expr ) . chain ( * spread) )
106106 }
107- & Expr :: Index { base, index, is_assignee_expr : _ } => {
107+ & Expr :: Index { base, index, is_assignee_expr } => {
108108 if mutability == Mutability :: Mut {
109109 if let Some ( ( f, _) ) = self . result . method_resolutions . get_mut ( & tgt_expr) {
110110 if let Some ( index_trait) = self
@@ -129,12 +129,16 @@ impl InferenceContext<'_> {
129129 target,
130130 } ) = base_adjustments
131131 {
132- * mutability = Mutability :: Mut ;
133- if let TyKind :: Ref ( _, _, ty) = target. kind ( Interner ) {
134- base_ty = Some ( ty. clone ( ) ) ;
132+ // For assignee exprs `IndexMut` obiligations are already applied
133+ if !is_assignee_expr {
134+ if let TyKind :: Ref ( _, _, ty) = target. kind ( Interner ) {
135+ base_ty = Some ( ty. clone ( ) ) ;
136+ }
135137 }
138+ * mutability = Mutability :: Mut ;
136139 }
137140
141+ // Apply `IndexMut` obligation for non-assignee expr
138142 if let Some ( base_ty) = base_ty {
139143 let index_ty =
140144 if let Some ( ty) = self . result . type_of_expr . get ( index) {
0 commit comments