diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2024-04-24 21:53:33 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2024-04-25 16:55:33 +0000 |
| commit | abdb64d4eaa989ff5ef96099f6e1585472de1622 (patch) | |
| tree | e541fcebf6f57736ea9bf4c0681c2f0c6bb22d4c /compiler | |
| parent | ad6ae612462c77fa6c5d1c98df9f197c570e0e81 (diff) | |
| download | rust-abdb64d4eaa989ff5ef96099f6e1585472de1622.tar.gz rust-abdb64d4eaa989ff5ef96099f6e1585472de1622.zip | |
Check equivalence of indices in more cases
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 84f9ebf18a8..b800e8d45d2 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -2116,7 +2116,13 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { None } }) else { - note_default_suggestion(); + let hir::Node::Expr(parent) = tcx.parent_hir_node(index1.hir_id) else { return }; + let hir::ExprKind::Index(_, idx1, _) = parent.kind else { return }; + let hir::Node::Expr(parent) = tcx.parent_hir_node(index2.hir_id) else { return }; + let hir::ExprKind::Index(_, idx2, _) = parent.kind else { return }; + if !idx1.equals(idx2) { + err.help("use `.split_at_mut(position)` to obtain two mutable non-overlapping sub-slices"); + } return; }; |
