Skip to content

Commit 0d4bb0b

Browse files
committed
Change index_refutable_slice to use FxIndexMap
This will prevent unstable order when HirIds are pertubated.
1 parent a832f5f commit 0d4bb0b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/tools/clippy/clippy_lints/src/index_refutable_slice.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clippy_utils::higher::IfLet;
44
use clippy_utils::ty::is_copy;
55
use clippy_utils::{is_expn_of, is_lint_allowed, meets_msrv, msrvs, path_to_local};
66
use if_chain::if_chain;
7-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
7+
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
88
use rustc_errors::Applicability;
99
use rustc_hir as hir;
1010
use rustc_hir::intravisit::{self, Visitor};
@@ -92,9 +92,9 @@ impl<'tcx> LateLintPass<'tcx> for IndexRefutableSlice {
9292
extract_msrv_attr!(LateContext);
9393
}
9494

95-
fn find_slice_values(cx: &LateContext<'_>, pat: &hir::Pat<'_>) -> FxHashMap<hir::HirId, SliceLintInformation> {
95+
fn find_slice_values(cx: &LateContext<'_>, pat: &hir::Pat<'_>) -> FxIndexMap<hir::HirId, SliceLintInformation> {
9696
let mut removed_pat: FxHashSet<hir::HirId> = FxHashSet::default();
97-
let mut slices: FxHashMap<hir::HirId, SliceLintInformation> = FxHashMap::default();
97+
let mut slices: FxIndexMap<hir::HirId, SliceLintInformation> = FxIndexMap::default();
9898
pat.walk_always(|pat| {
9999
if let hir::PatKind::Binding(binding, value_hir_id, ident, sub_pat) = pat.kind {
100100
// We'll just ignore mut and ref mut for simplicity sake right now
@@ -208,10 +208,10 @@ impl SliceLintInformation {
208208

209209
fn filter_lintable_slices<'a, 'tcx>(
210210
cx: &'a LateContext<'tcx>,
211-
slice_lint_info: FxHashMap<hir::HirId, SliceLintInformation>,
211+
slice_lint_info: FxIndexMap<hir::HirId, SliceLintInformation>,
212212
max_suggested_slice: u64,
213213
scope: &'tcx hir::Expr<'tcx>,
214-
) -> FxHashMap<hir::HirId, SliceLintInformation> {
214+
) -> FxIndexMap<hir::HirId, SliceLintInformation> {
215215
let mut visitor = SliceIndexLintingVisitor {
216216
cx,
217217
slice_lint_info,
@@ -225,7 +225,7 @@ fn filter_lintable_slices<'a, 'tcx>(
225225

226226
struct SliceIndexLintingVisitor<'a, 'tcx> {
227227
cx: &'a LateContext<'tcx>,
228-
slice_lint_info: FxHashMap<hir::HirId, SliceLintInformation>,
228+
slice_lint_info: FxIndexMap<hir::HirId, SliceLintInformation>,
229229
max_suggested_slice: u64,
230230
}
231231

0 commit comments

Comments
 (0)