mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 06:03:58 +00:00
Prevent redundant obigation push for assignee exprs
This commit is contained in:
parent
20e2623234
commit
b5494d7cc3
1 changed files with 8 additions and 4 deletions
|
@ -104,7 +104,7 @@ impl InferenceContext<'_> {
|
||||||
Expr::RecordLit { path: _, fields, spread, ellipsis: _, is_assignee_expr: _ } => {
|
Expr::RecordLit { path: _, fields, spread, ellipsis: _, is_assignee_expr: _ } => {
|
||||||
self.infer_mut_not_expr_iter(fields.iter().map(|it| it.expr).chain(*spread))
|
self.infer_mut_not_expr_iter(fields.iter().map(|it| it.expr).chain(*spread))
|
||||||
}
|
}
|
||||||
&Expr::Index { base, index, is_assignee_expr: _ } => {
|
&Expr::Index { base, index, is_assignee_expr } => {
|
||||||
if mutability == Mutability::Mut {
|
if mutability == Mutability::Mut {
|
||||||
if let Some((f, _)) = self.result.method_resolutions.get_mut(&tgt_expr) {
|
if let Some((f, _)) = self.result.method_resolutions.get_mut(&tgt_expr) {
|
||||||
if let Some(index_trait) = self
|
if let Some(index_trait) = self
|
||||||
|
@ -129,12 +129,16 @@ impl InferenceContext<'_> {
|
||||||
target,
|
target,
|
||||||
}) = base_adjustments
|
}) = base_adjustments
|
||||||
{
|
{
|
||||||
*mutability = Mutability::Mut;
|
// For assignee exprs `IndexMut` obiligations are already applied
|
||||||
if let TyKind::Ref(_, _, ty) = target.kind(Interner) {
|
if !is_assignee_expr {
|
||||||
base_ty = Some(ty.clone());
|
if let TyKind::Ref(_, _, ty) = target.kind(Interner) {
|
||||||
|
base_ty = Some(ty.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
*mutability = Mutability::Mut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply `IndexMut` obligation for non-assignee expr
|
||||||
if let Some(base_ty) = base_ty {
|
if let Some(base_ty) = base_ty {
|
||||||
let index_ty =
|
let index_ty =
|
||||||
if let Some(ty) = self.result.type_of_expr.get(index) {
|
if let Some(ty) = self.result.type_of_expr.get(index) {
|
||||||
|
|
Loading…
Reference in a new issue