Skip to content

Commit 64a4cdc

Browse files
committed
review comment: rename method
1 parent abdb64d commit 64a4cdc

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2120,7 +2120,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
21202120
let hir::ExprKind::Index(_, idx1, _) = parent.kind else { return };
21212121
let hir::Node::Expr(parent) = tcx.parent_hir_node(index2.hir_id) else { return };
21222122
let hir::ExprKind::Index(_, idx2, _) = parent.kind else { return };
2123-
if !idx1.equals(idx2) {
2123+
if !idx1.equivalent_for_indexing(idx2) {
21242124
err.help("use `.split_at_mut(position)` to obtain two mutable non-overlapping sub-slices");
21252125
}
21262126
return;
@@ -2146,7 +2146,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
21462146
let Some(index2) = self.find_expr(issued_span) else { return };
21472147
let hir::Node::Expr(parent) = tcx.parent_hir_node(index2.hir_id) else { return };
21482148
let hir::ExprKind::Index(_, idx2, _) = parent.kind else { return };
2149-
if idx1.equals(idx2) {
2149+
if idx1.equivalent_for_indexing(idx2) {
21502150
// `let a = &mut foo[0]` and `let b = &mut foo[0]`? Don't mention `split_at_mut`
21512151
return;
21522152
}

compiler/rustc_hir/src/hir.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1815,7 +1815,7 @@ impl Expr<'_> {
18151815
///
18161816
/// This is only used for diagnostics to see if we have things like `foo[i]` where `foo` is
18171817
/// borrowed multiple times with `i`.
1818-
pub fn equals(&self, other: &Expr<'_>) -> bool {
1818+
pub fn equivalent_for_indexing(&self, other: &Expr<'_>) -> bool {
18191819
match (self.kind, other.kind) {
18201820
(ExprKind::Lit(lit1), ExprKind::Lit(lit2)) => lit1.node == lit2.node,
18211821
(
@@ -1837,11 +1837,14 @@ impl Expr<'_> {
18371837
| (
18381838
ExprKind::Struct(QPath::LangItem(LangItem::RangeFrom, _), [val1], None),
18391839
ExprKind::Struct(QPath::LangItem(LangItem::RangeFrom, _), [val2], None),
1840-
) => val1.expr.equals(val2.expr),
1840+
) => val1.expr.equivalent_for_indexing(val2.expr),
18411841
(
18421842
ExprKind::Struct(QPath::LangItem(LangItem::Range, _), [val1, val3], None),
18431843
ExprKind::Struct(QPath::LangItem(LangItem::Range, _), [val2, val4], None),
1844-
) => val1.expr.equals(val2.expr) && val3.expr.equals(val4.expr),
1844+
) => {
1845+
val1.expr.equivalent_for_indexing(val2.expr)
1846+
&& val3.expr.equivalent_for_indexing(val4.expr)
1847+
}
18451848
_ => false,
18461849
}
18471850
}

0 commit comments

Comments
 (0)