@@ -104,7 +104,7 @@ impl InferenceContext<'_> {
104
104
Expr :: RecordLit { path : _, fields, spread, ellipsis : _, is_assignee_expr : _ } => {
105
105
self . infer_mut_not_expr_iter ( fields. iter ( ) . map ( |it| it. expr ) . chain ( * spread) )
106
106
}
107
- & Expr :: Index { base, index, is_assignee_expr : _ } => {
107
+ & Expr :: Index { base, index, is_assignee_expr } => {
108
108
if mutability == Mutability :: Mut {
109
109
if let Some ( ( f, _) ) = self . result . method_resolutions . get_mut ( & tgt_expr) {
110
110
if let Some ( index_trait) = self
@@ -129,12 +129,16 @@ impl InferenceContext<'_> {
129
129
target,
130
130
} ) = base_adjustments
131
131
{
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
+ }
135
137
}
138
+ * mutability = Mutability :: Mut ;
136
139
}
137
140
141
+ // Apply `IndexMut` obligation for non-assignee expr
138
142
if let Some ( base_ty) = base_ty {
139
143
let index_ty =
140
144
if let Some ( ty) = self . result . type_of_expr . get ( index) {
0 commit comments