From b3b9f31a869326bcd623c84fd230777f397847f3 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Sun, 28 Jan 2024 20:53:28 +0000 Subject: [PATCH] Bump `indexmap` `swap` has been deprecated in favour of `swap_remove` - the behaviour is the same though. --- clippy_lints/src/copies.rs | 3 ++- clippy_lints/src/escape.rs | 6 ++++-- clippy_lints/src/index_refutable_slice.rs | 6 ++++-- clippy_lints/src/matches/match_same_arms.rs | 3 ++- clippy_lints/src/needless_pass_by_ref_mut.rs | 3 ++- clippy_lints/src/no_effect.rs | 6 ++++-- clippy_lints/src/only_used_in_recursion.rs | 3 ++- 7 files changed, 20 insertions(+), 10 deletions(-) diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index bd07c19a2d8..247048bbc49 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -511,7 +511,8 @@ fn scan_block_for_eq<'tcx>( for stmt in &stmts[stmts.len() - init..=stmts.len() - offset] { if let StmtKind::Local(l) = stmt.kind { l.pat.each_binding_or_first(&mut |_, id, _, _| { - eq.locals.remove(&id); + // FIXME(rust/#120456) - is `swap_remove` correct? + eq.locals.swap_remove(&id); }); } } diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index 064bac2e7dc..8857cb8e382 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -138,7 +138,8 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> { fn consume(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId) { if cmt.place.projections.is_empty() { if let PlaceBase::Local(lid) = cmt.place.base { - self.set.remove(&lid); + // FIXME(rust/#120456) - is `swap_remove` correct? + self.set.swap_remove(&lid); } } } @@ -146,7 +147,8 @@ fn consume(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId) { fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind) { if cmt.place.projections.is_empty() { if let PlaceBase::Local(lid) = cmt.place.base { - self.set.remove(&lid); + // FIXME(rust/#120456) - is `swap_remove` correct? + self.set.swap_remove(&lid); } } } diff --git a/clippy_lints/src/index_refutable_slice.rs b/clippy_lints/src/index_refutable_slice.rs index 51b4f26b6d1..41e9d5b1c2e 100644 --- a/clippy_lints/src/index_refutable_slice.rs +++ b/clippy_lints/src/index_refutable_slice.rs @@ -106,7 +106,8 @@ fn find_slice_values(cx: &LateContext<'_>, pat: &hir::Pat<'_>) -> FxIndexMap) { } // The slice was used for something other than indexing - self.slice_lint_info.remove(&local_id); + // FIXME(rust/#120456) - is `swap_remove` correct? + self.slice_lint_info.swap_remove(&local_id); } intravisit::walk_expr(self, expr); } diff --git a/clippy_lints/src/matches/match_same_arms.rs b/clippy_lints/src/matches/match_same_arms.rs index d645e6c6c05..6595658b769 100644 --- a/clippy_lints/src/matches/match_same_arms.rs +++ b/clippy_lints/src/matches/match_same_arms.rs @@ -415,6 +415,7 @@ fn pat_contains_local(pat: &Pat<'_>, id: HirId) -> bool { /// Returns true if all the bindings in the `Pat` are in `ids` and vice versa fn bindings_eq(pat: &Pat<'_>, mut ids: HirIdSet) -> bool { let mut result = true; - pat.each_binding_or_first(&mut |_, id, _, _| result &= ids.remove(&id)); + // FIXME(rust/#120456) - is `swap_remove` correct? + pat.each_binding_or_first(&mut |_, id, _, _| result &= ids.swap_remove(&id)); result && ids.is_empty() } diff --git a/clippy_lints/src/needless_pass_by_ref_mut.rs b/clippy_lints/src/needless_pass_by_ref_mut.rs index 149d440ecac..710ecd745f8 100644 --- a/clippy_lints/src/needless_pass_by_ref_mut.rs +++ b/clippy_lints/src/needless_pass_by_ref_mut.rs @@ -382,7 +382,8 @@ fn consume(&mut self, cmt: &euv::PlaceWithHirId<'tcx>, id: HirId) { self.add_mutably_used_var(*vid); } self.prev_bind = None; - self.prev_move_to_closure.remove(vid); + // FIXME(rust/#120456) - is `swap_remove` correct? + self.prev_move_to_closure.swap_remove(vid); } } diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs index 580160efeb7..6a5555ca383 100644 --- a/clippy_lints/src/no_effect.rs +++ b/clippy_lints/src/no_effect.rs @@ -98,7 +98,8 @@ fn check_block(&mut self, _: &LateContext<'tcx>, _: &'tcx rustc_hir::Block<'tcx> fn check_block_post(&mut self, cx: &LateContext<'tcx>, _: &'tcx rustc_hir::Block<'tcx>) { for hir_id in self.local_bindings.pop().unwrap() { - if let Some(span) = self.underscore_bindings.remove(&hir_id) { + // FIXME(rust/#120456) - is `swap_remove` correct? + if let Some(span) = self.underscore_bindings.swap_remove(&hir_id) { span_lint_hir( cx, NO_EFFECT_UNDERSCORE_BINDING, @@ -112,7 +113,8 @@ fn check_block_post(&mut self, cx: &LateContext<'tcx>, _: &'tcx rustc_hir::Block fn check_expr(&mut self, _: &LateContext<'tcx>, expr: &'tcx rustc_hir::Expr<'tcx>) { if let Some(def_id) = path_to_local(expr) { - self.underscore_bindings.remove(&def_id); + // FIXME(rust/#120456) - is `swap_remove` correct? + self.underscore_bindings.swap_remove(&def_id); } } } diff --git a/clippy_lints/src/only_used_in_recursion.rs b/clippy_lints/src/only_used_in_recursion.rs index ae14016f482..a568392ecc4 100644 --- a/clippy_lints/src/only_used_in_recursion.rs +++ b/clippy_lints/src/only_used_in_recursion.rs @@ -153,7 +153,8 @@ fn remove_by_id(&mut self, id: HirId) { param.uses = Vec::new(); let key = (param.fn_id, param.idx); self.by_fn.remove(&key); - self.by_id.remove(&id); + // FIXME(rust/#120456) - is `swap_remove` correct? + self.by_id.swap_remove(&id); } }