Handle clippy
cases of rustc::potential_query_instability
lint
This commit is contained in:
parent
743623d4f7
commit
0b632ec812
@ -5,7 +5,7 @@
|
|||||||
use clippy_utils::higher::IfLet;
|
use clippy_utils::higher::IfLet;
|
||||||
use clippy_utils::ty::is_copy;
|
use clippy_utils::ty::is_copy;
|
||||||
use clippy_utils::{is_expn_of, is_lint_allowed, path_to_local};
|
use clippy_utils::{is_expn_of, is_lint_allowed, path_to_local};
|
||||||
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
|
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::HirId;
|
use rustc_hir::HirId;
|
||||||
@ -133,7 +133,7 @@ fn lint_slice(cx: &LateContext<'_>, slice: &SliceLintInformation) {
|
|||||||
.index_use
|
.index_use
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(index, _)| *index)
|
.map(|(index, _)| *index)
|
||||||
.collect::<FxHashSet<_>>();
|
.collect::<FxIndexSet<_>>();
|
||||||
|
|
||||||
let value_name = |index| format!("{}_{index}", slice.ident.name);
|
let value_name = |index| format!("{}_{index}", slice.ident.name);
|
||||||
|
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
unused_qualifications,
|
unused_qualifications,
|
||||||
rustc::internal
|
rustc::internal
|
||||||
)]
|
)]
|
||||||
// Disable this rustc lint for now, as it was also done in rustc
|
|
||||||
#![allow(rustc::potential_query_instability)]
|
|
||||||
|
|
||||||
// FIXME: switch to something more ergonomic here, once available.
|
// FIXME: switch to something more ergonomic here, once available.
|
||||||
// (Currently there is no way to opt into sysroot crates without `extern crate`.)
|
// (Currently there is no way to opt into sysroot crates without `extern crate`.)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use clippy_utils::diagnostics::{span_lint, span_lint_and_then};
|
use clippy_utils::diagnostics::{span_lint, span_lint_and_then};
|
||||||
use clippy_utils::trait_ref_of_method;
|
use clippy_utils::trait_ref_of_method;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::FnRetTy::Return;
|
use rustc_hir::FnRetTy::Return;
|
||||||
use rustc_hir::intravisit::nested_filter::{self as hir_nested_filter, NestedFilter};
|
use rustc_hir::intravisit::nested_filter::{self as hir_nested_filter, NestedFilter};
|
||||||
@ -311,7 +311,7 @@ fn could_use_elision<'tcx>(
|
|||||||
Some((elidable_lts, usages))
|
Some((elidable_lts, usages))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn allowed_lts_from(named_generics: &[GenericParam<'_>]) -> FxHashSet<LocalDefId> {
|
fn allowed_lts_from(named_generics: &[GenericParam<'_>]) -> FxIndexSet<LocalDefId> {
|
||||||
named_generics
|
named_generics
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|par| {
|
.filter_map(|par| {
|
||||||
@ -499,7 +499,7 @@ struct Usage {
|
|||||||
|
|
||||||
struct LifetimeChecker<'cx, 'tcx, F> {
|
struct LifetimeChecker<'cx, 'tcx, F> {
|
||||||
cx: &'cx LateContext<'tcx>,
|
cx: &'cx LateContext<'tcx>,
|
||||||
map: FxHashMap<LocalDefId, Vec<Usage>>,
|
map: FxIndexMap<LocalDefId, Vec<Usage>>,
|
||||||
where_predicate_depth: usize,
|
where_predicate_depth: usize,
|
||||||
generic_args_depth: usize,
|
generic_args_depth: usize,
|
||||||
phantom: std::marker::PhantomData<F>,
|
phantom: std::marker::PhantomData<F>,
|
||||||
@ -621,7 +621,7 @@ fn report_extra_impl_lifetimes<'tcx>(cx: &LateContext<'tcx>, impl_: &'tcx Impl<'
|
|||||||
fn report_elidable_impl_lifetimes<'tcx>(
|
fn report_elidable_impl_lifetimes<'tcx>(
|
||||||
cx: &LateContext<'tcx>,
|
cx: &LateContext<'tcx>,
|
||||||
impl_: &'tcx Impl<'_>,
|
impl_: &'tcx Impl<'_>,
|
||||||
map: &FxHashMap<LocalDefId, Vec<Usage>>,
|
map: &FxIndexMap<LocalDefId, Vec<Usage>>,
|
||||||
) {
|
) {
|
||||||
let single_usages = map
|
let single_usages = map
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
use clippy_utils::visitors::is_local_used;
|
use clippy_utils::visitors::is_local_used;
|
||||||
use clippy_utils::{SpanlessEq, contains_name, higher, is_integer_const, sugg};
|
use clippy_utils::{SpanlessEq, contains_name, higher, is_integer_const, sugg};
|
||||||
use rustc_ast::ast;
|
use rustc_ast::ast;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::def::{DefKind, Res};
|
use rustc_hir::def::{DefKind, Res};
|
||||||
use rustc_hir::intravisit::{Visitor, walk_expr};
|
use rustc_hir::intravisit::{Visitor, walk_expr};
|
||||||
@ -39,7 +39,7 @@ pub(super) fn check<'tcx>(
|
|||||||
var: canonical_id,
|
var: canonical_id,
|
||||||
indexed_mut: FxHashSet::default(),
|
indexed_mut: FxHashSet::default(),
|
||||||
indexed_indirectly: FxHashMap::default(),
|
indexed_indirectly: FxHashMap::default(),
|
||||||
indexed_directly: FxHashMap::default(),
|
indexed_directly: FxIndexMap::default(),
|
||||||
referenced: FxHashSet::default(),
|
referenced: FxHashSet::default(),
|
||||||
nonindex: false,
|
nonindex: false,
|
||||||
prefer_mutable: false,
|
prefer_mutable: false,
|
||||||
@ -229,7 +229,7 @@ struct VarVisitor<'a, 'tcx> {
|
|||||||
indexed_indirectly: FxHashMap<Symbol, Option<region::Scope>>,
|
indexed_indirectly: FxHashMap<Symbol, Option<region::Scope>>,
|
||||||
/// subset of `indexed` of vars that are indexed directly: `v[i]`
|
/// subset of `indexed` of vars that are indexed directly: `v[i]`
|
||||||
/// this will not contain cases like `v[calc_index(i)]` or `v[(i + 4) % N]`
|
/// this will not contain cases like `v[calc_index(i)]` or `v[(i + 4) % N]`
|
||||||
indexed_directly: FxHashMap<Symbol, (Option<region::Scope>, Ty<'tcx>)>,
|
indexed_directly: FxIndexMap<Symbol, (Option<region::Scope>, Ty<'tcx>)>,
|
||||||
/// Any names that are used outside an index operation.
|
/// Any names that are used outside an index operation.
|
||||||
/// Used to detect things like `&mut vec` used together with `vec[i]`
|
/// Used to detect things like `&mut vec` used together with `vec[i]`
|
||||||
referenced: FxHashSet<Symbol>,
|
referenced: FxHashSet<Symbol>,
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
use clippy_utils::{get_attr, is_lint_allowed};
|
use clippy_utils::{get_attr, is_lint_allowed};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use rustc_ast::Mutability;
|
use rustc_ast::Mutability;
|
||||||
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
use rustc_errors::{Applicability, Diag};
|
use rustc_errors::{Applicability, Diag};
|
||||||
use rustc_hir::intravisit::{Visitor, walk_expr};
|
use rustc_hir::intravisit::{Visitor, walk_expr};
|
||||||
use rustc_hir::{Arm, Expr, ExprKind, MatchSource};
|
use rustc_hir::{Arm, Expr, ExprKind, MatchSource};
|
||||||
@ -475,19 +476,19 @@ fn visit_expr(&mut self, ex: &'tcx Expr<'_>) {
|
|||||||
|
|
||||||
struct ArmSigDropHelper<'a, 'tcx> {
|
struct ArmSigDropHelper<'a, 'tcx> {
|
||||||
sig_drop_checker: SigDropChecker<'a, 'tcx>,
|
sig_drop_checker: SigDropChecker<'a, 'tcx>,
|
||||||
found_sig_drop_spans: FxHashSet<Span>,
|
found_sig_drop_spans: FxIndexSet<Span>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> ArmSigDropHelper<'a, 'tcx> {
|
impl<'a, 'tcx> ArmSigDropHelper<'a, 'tcx> {
|
||||||
fn new(cx: &'a LateContext<'tcx>) -> ArmSigDropHelper<'a, 'tcx> {
|
fn new(cx: &'a LateContext<'tcx>) -> ArmSigDropHelper<'a, 'tcx> {
|
||||||
ArmSigDropHelper {
|
ArmSigDropHelper {
|
||||||
sig_drop_checker: SigDropChecker::new(cx),
|
sig_drop_checker: SigDropChecker::new(cx),
|
||||||
found_sig_drop_spans: FxHashSet::<Span>::default(),
|
found_sig_drop_spans: FxIndexSet::<Span>::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_significant_drop_in_arms<'tcx>(cx: &LateContext<'tcx>, arms: &[&'tcx Expr<'_>]) -> FxHashSet<Span> {
|
fn has_significant_drop_in_arms<'tcx>(cx: &LateContext<'tcx>, arms: &[&'tcx Expr<'_>]) -> FxIndexSet<Span> {
|
||||||
let mut helper = ArmSigDropHelper::new(cx);
|
let mut helper = ArmSigDropHelper::new(cx);
|
||||||
for arm in arms {
|
for arm in arms {
|
||||||
helper.visit_expr(arm);
|
helper.visit_expr(arm);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
use clippy_utils::{eq_expr_value, hash_expr, higher};
|
use clippy_utils::{eq_expr_value, hash_expr, higher};
|
||||||
use rustc_ast::{LitKind, RangeLimits};
|
use rustc_ast::{LitKind, RangeLimits};
|
||||||
use rustc_data_structures::packed::Pu128;
|
use rustc_data_structures::packed::Pu128;
|
||||||
use rustc_data_structures::unhash::UnhashMap;
|
use rustc_data_structures::unhash::UnindexMap;
|
||||||
use rustc_errors::{Applicability, Diag};
|
use rustc_errors::{Applicability, Diag};
|
||||||
use rustc_hir::{BinOp, Block, Body, Expr, ExprKind, UnOp};
|
use rustc_hir::{BinOp, Block, Body, Expr, ExprKind, UnOp};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
@ -226,7 +226,7 @@ fn upper_index_expr(expr: &Expr<'_>) -> Option<usize> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if the expression is an index into a slice and adds it to `indexes`
|
/// Checks if the expression is an index into a slice and adds it to `indexes`
|
||||||
fn check_index<'hir>(cx: &LateContext<'_>, expr: &'hir Expr<'hir>, map: &mut UnhashMap<u64, Vec<IndexEntry<'hir>>>) {
|
fn check_index<'hir>(cx: &LateContext<'_>, expr: &'hir Expr<'hir>, map: &mut UnindexMap<u64, Vec<IndexEntry<'hir>>>) {
|
||||||
if let ExprKind::Index(slice, index_lit, _) = expr.kind
|
if let ExprKind::Index(slice, index_lit, _) = expr.kind
|
||||||
&& cx.typeck_results().expr_ty_adjusted(slice).peel_refs().is_slice()
|
&& cx.typeck_results().expr_ty_adjusted(slice).peel_refs().is_slice()
|
||||||
&& let Some(index) = upper_index_expr(index_lit)
|
&& let Some(index) = upper_index_expr(index_lit)
|
||||||
@ -274,7 +274,7 @@ fn check_index<'hir>(cx: &LateContext<'_>, expr: &'hir Expr<'hir>, map: &mut Unh
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if the expression is an `assert!` expression and adds it to `asserts`
|
/// Checks if the expression is an `assert!` expression and adds it to `asserts`
|
||||||
fn check_assert<'hir>(cx: &LateContext<'_>, expr: &'hir Expr<'hir>, map: &mut UnhashMap<u64, Vec<IndexEntry<'hir>>>) {
|
fn check_assert<'hir>(cx: &LateContext<'_>, expr: &'hir Expr<'hir>, map: &mut UnindexMap<u64, Vec<IndexEntry<'hir>>>) {
|
||||||
if let Some((comparison, asserted_len, slice)) = assert_len_expr(cx, expr) {
|
if let Some((comparison, asserted_len, slice)) = assert_len_expr(cx, expr) {
|
||||||
let hash = hash_expr(cx, slice);
|
let hash = hash_expr(cx, slice);
|
||||||
let indexes = map.entry(hash).or_default();
|
let indexes = map.entry(hash).or_default();
|
||||||
@ -311,7 +311,7 @@ fn check_assert<'hir>(cx: &LateContext<'_>, expr: &'hir Expr<'hir>, map: &mut Un
|
|||||||
/// Inspects indexes and reports lints.
|
/// Inspects indexes and reports lints.
|
||||||
///
|
///
|
||||||
/// Called at the end of this lint after all indexing and `assert!` expressions have been collected.
|
/// Called at the end of this lint after all indexing and `assert!` expressions have been collected.
|
||||||
fn report_indexes(cx: &LateContext<'_>, map: &UnhashMap<u64, Vec<IndexEntry<'_>>>) {
|
fn report_indexes(cx: &LateContext<'_>, map: &UnindexMap<u64, Vec<IndexEntry<'_>>>) {
|
||||||
for bucket in map.values() {
|
for bucket in map.values() {
|
||||||
for entry in bucket {
|
for entry in bucket {
|
||||||
let Some(full_span) = entry
|
let Some(full_span) = entry
|
||||||
@ -403,7 +403,7 @@ fn report_indexes(cx: &LateContext<'_>, map: &UnhashMap<u64, Vec<IndexEntry<'_>>
|
|||||||
|
|
||||||
impl LateLintPass<'_> for MissingAssertsForIndexing {
|
impl LateLintPass<'_> for MissingAssertsForIndexing {
|
||||||
fn check_body(&mut self, cx: &LateContext<'_>, body: &Body<'_>) {
|
fn check_body(&mut self, cx: &LateContext<'_>, body: &Body<'_>) {
|
||||||
let mut map = UnhashMap::default();
|
let mut map = UnindexMap::default();
|
||||||
|
|
||||||
for_each_expr_without_closures(body.value, |expr| {
|
for_each_expr_without_closures(body.value, |expr| {
|
||||||
check_index(cx, expr, &mut map);
|
check_index(cx, expr, &mut map);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
use rustc_ast::ast;
|
use rustc_ast::ast;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
|
||||||
use rustc_lint::{EarlyContext, EarlyLintPass, Level, LintContext};
|
use rustc_lint::{EarlyContext, EarlyLintPass, Level, LintContext};
|
||||||
use rustc_session::impl_lint_pass;
|
use rustc_session::impl_lint_pass;
|
||||||
use rustc_span::def_id::LOCAL_CRATE;
|
use rustc_span::def_id::LOCAL_CRATE;
|
||||||
@ -87,7 +87,7 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
|
|||||||
|
|
||||||
// `folder_segments` is all unique folder path segments `path/to/foo.rs` gives
|
// `folder_segments` is all unique folder path segments `path/to/foo.rs` gives
|
||||||
// `[path, to]` but not foo
|
// `[path, to]` but not foo
|
||||||
let mut folder_segments = FxHashSet::default();
|
let mut folder_segments = FxIndexSet::default();
|
||||||
// `mod_folders` is all the unique folder names that contain a mod.rs file
|
// `mod_folders` is all the unique folder names that contain a mod.rs file
|
||||||
let mut mod_folders = FxHashSet::default();
|
let mut mod_folders = FxHashSet::default();
|
||||||
// `file_map` maps file names to the full path including the file name
|
// `file_map` maps file names to the full path including the file name
|
||||||
@ -144,7 +144,7 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
|
|||||||
/// is `mod.rs` we add it's parent folder to `mod_folders`.
|
/// is `mod.rs` we add it's parent folder to `mod_folders`.
|
||||||
fn process_paths_for_mod_files<'a>(
|
fn process_paths_for_mod_files<'a>(
|
||||||
path: &'a Path,
|
path: &'a Path,
|
||||||
folder_segments: &mut FxHashSet<&'a OsStr>,
|
folder_segments: &mut FxIndexSet<&'a OsStr>,
|
||||||
mod_folders: &mut FxHashSet<&'a OsStr>,
|
mod_folders: &mut FxHashSet<&'a OsStr>,
|
||||||
) {
|
) {
|
||||||
let mut comp = path.components().rev().peekable();
|
let mut comp = path.components().rev().peekable();
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
use clippy_utils::visitors::for_each_expr;
|
use clippy_utils::visitors::for_each_expr;
|
||||||
use clippy_utils::{inherits_cfg, is_from_proc_macro, is_self};
|
use clippy_utils::{inherits_cfg, is_from_proc_macro, is_self};
|
||||||
use core::ops::ControlFlow;
|
use core::ops::ControlFlow;
|
||||||
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
|
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::intravisit::FnKind;
|
use rustc_hir::intravisit::FnKind;
|
||||||
use rustc_hir::{
|
use rustc_hir::{
|
||||||
@ -101,7 +101,7 @@ fn check_closures<'tcx>(
|
|||||||
ctx: &mut MutablyUsedVariablesCtxt<'tcx>,
|
ctx: &mut MutablyUsedVariablesCtxt<'tcx>,
|
||||||
cx: &LateContext<'tcx>,
|
cx: &LateContext<'tcx>,
|
||||||
checked_closures: &mut FxHashSet<LocalDefId>,
|
checked_closures: &mut FxHashSet<LocalDefId>,
|
||||||
closures: FxHashSet<LocalDefId>,
|
closures: FxIndexSet<LocalDefId>,
|
||||||
) {
|
) {
|
||||||
let hir = cx.tcx.hir();
|
let hir = cx.tcx.hir();
|
||||||
for closure in closures {
|
for closure in closures {
|
||||||
@ -196,7 +196,7 @@ fn check_fn(
|
|||||||
prev_bind: None,
|
prev_bind: None,
|
||||||
prev_move_to_closure: HirIdSet::default(),
|
prev_move_to_closure: HirIdSet::default(),
|
||||||
aliases: HirIdMap::default(),
|
aliases: HirIdMap::default(),
|
||||||
async_closures: FxHashSet::default(),
|
async_closures: FxIndexSet::default(),
|
||||||
tcx: cx.tcx,
|
tcx: cx.tcx,
|
||||||
};
|
};
|
||||||
euv::ExprUseVisitor::for_clippy(cx, fn_def_id, &mut ctx)
|
euv::ExprUseVisitor::for_clippy(cx, fn_def_id, &mut ctx)
|
||||||
@ -207,7 +207,7 @@ fn check_fn(
|
|||||||
|
|
||||||
// We retrieve all the closures declared in the function because they will not be found
|
// We retrieve all the closures declared in the function because they will not be found
|
||||||
// by `euv::Delegate`.
|
// by `euv::Delegate`.
|
||||||
let mut closures: FxHashSet<LocalDefId> = FxHashSet::default();
|
let mut closures: FxIndexSet<LocalDefId> = FxIndexSet::default();
|
||||||
for_each_expr(cx, body, |expr| {
|
for_each_expr(cx, body, |expr| {
|
||||||
if let ExprKind::Closure(closure) = expr.kind {
|
if let ExprKind::Closure(closure) = expr.kind {
|
||||||
closures.insert(closure.def_id);
|
closures.insert(closure.def_id);
|
||||||
@ -307,7 +307,7 @@ struct MutablyUsedVariablesCtxt<'tcx> {
|
|||||||
/// use of a variable.
|
/// use of a variable.
|
||||||
prev_move_to_closure: HirIdSet,
|
prev_move_to_closure: HirIdSet,
|
||||||
aliases: HirIdMap<HirId>,
|
aliases: HirIdMap<HirId>,
|
||||||
async_closures: FxHashSet<LocalDefId>,
|
async_closures: FxIndexSet<LocalDefId>,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
use clippy_utils::{can_mut_borrow_both, eq_expr_value, is_in_const_context, std_or_core};
|
use clippy_utils::{can_mut_borrow_both, eq_expr_value, is_in_const_context, std_or_core};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
||||||
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
use rustc_hir::intravisit::{Visitor, walk_expr};
|
use rustc_hir::intravisit::{Visitor, walk_expr};
|
||||||
|
|
||||||
use crate::FxHashSet;
|
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{BinOpKind, Block, Expr, ExprKind, LetStmt, PatKind, QPath, Stmt, StmtKind};
|
use rustc_hir::{BinOpKind, Block, Expr, ExprKind, LetStmt, PatKind, QPath, Stmt, StmtKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||||
@ -334,7 +334,7 @@ struct IndexBinding<'a, 'tcx> {
|
|||||||
|
|
||||||
impl<'tcx> IndexBinding<'_, 'tcx> {
|
impl<'tcx> IndexBinding<'_, 'tcx> {
|
||||||
fn snippet_index_bindings(&mut self, exprs: &[&'tcx Expr<'tcx>]) -> String {
|
fn snippet_index_bindings(&mut self, exprs: &[&'tcx Expr<'tcx>]) -> String {
|
||||||
let mut bindings = FxHashSet::default();
|
let mut bindings = FxIndexSet::default();
|
||||||
for expr in exprs {
|
for expr in exprs {
|
||||||
bindings.insert(self.snippet_index_binding(expr));
|
bindings.insert(self.snippet_index_binding(expr));
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
use clippy_utils::{SpanlessEq, SpanlessHash, is_from_proc_macro};
|
use clippy_utils::{SpanlessEq, SpanlessHash, is_from_proc_macro};
|
||||||
use core::hash::{Hash, Hasher};
|
use core::hash::{Hash, Hasher};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, IndexEntry};
|
||||||
use rustc_data_structures::unhash::UnhashMap;
|
use rustc_data_structures::unhash::UnhashMap;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::def::Res;
|
use rustc_hir::def::Res;
|
||||||
@ -16,7 +16,6 @@
|
|||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_session::impl_lint_pass;
|
use rustc_session::impl_lint_pass;
|
||||||
use rustc_span::{BytePos, Span};
|
use rustc_span::{BytePos, Span};
|
||||||
use std::collections::hash_map::Entry;
|
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
@ -427,7 +426,7 @@ fn rollup_traits(
|
|||||||
bounds: &[GenericBound<'_>],
|
bounds: &[GenericBound<'_>],
|
||||||
msg: &'static str,
|
msg: &'static str,
|
||||||
) -> Vec<(ComparableTraitRef, Span)> {
|
) -> Vec<(ComparableTraitRef, Span)> {
|
||||||
let mut map = FxHashMap::default();
|
let mut map = FxIndexMap::default();
|
||||||
let mut repeated_res = false;
|
let mut repeated_res = false;
|
||||||
|
|
||||||
let only_comparable_trait_refs = |bound: &GenericBound<'_>| {
|
let only_comparable_trait_refs = |bound: &GenericBound<'_>| {
|
||||||
@ -442,8 +441,8 @@ fn rollup_traits(
|
|||||||
for bound in bounds.iter().filter_map(only_comparable_trait_refs) {
|
for bound in bounds.iter().filter_map(only_comparable_trait_refs) {
|
||||||
let (comparable_bound, span_direct) = bound;
|
let (comparable_bound, span_direct) = bound;
|
||||||
match map.entry(comparable_bound) {
|
match map.entry(comparable_bound) {
|
||||||
Entry::Occupied(_) => repeated_res = true,
|
IndexEntry::Occupied(_) => repeated_res = true,
|
||||||
Entry::Vacant(e) => {
|
IndexEntry::Vacant(e) => {
|
||||||
e.insert((span_direct, i));
|
e.insert((span_direct, i));
|
||||||
i += 1;
|
i += 1;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user