Use UnordMap instead of FxHashMap in define_id_collections!().

This commit is contained in:
Michael Woerister 2023-01-17 12:05:01 +01:00
parent 31a053059e
commit 465ed5bd46
4 changed files with 29 additions and 29 deletions

@ -52,21 +52,19 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
// List of spans to lint. (lint_span, first_span) // List of spans to lint. (lint_span, first_span)
let mut lint_spans = Vec::new(); let mut lint_spans = Vec::new();
for (_, impl_ids) in cx let inherent_impls = cx
.tcx .tcx
.crate_inherent_impls(()) .with_stable_hashing_context(|hcx| cx.tcx.crate_inherent_impls(()).inherent_impls.to_sorted(&hcx));
.inherent_impls
.iter() for (_, impl_ids) in inherent_impls.into_iter().filter(|(&id, impls)| {
.filter(|(&id, impls)| { impls.len() > 1
impls.len() > 1 // Check for `#[allow]` on the type definition
// Check for `#[allow]` on the type definition && !is_lint_allowed(
&& !is_lint_allowed( cx,
cx, MULTIPLE_INHERENT_IMPL,
MULTIPLE_INHERENT_IMPL, cx.tcx.hir().local_def_id_to_hir_id(id),
cx.tcx.hir().local_def_id_to_hir_id(id), )
) }) {
})
{
for impl_id in impl_ids.iter().map(|id| id.expect_local()) { for impl_id in impl_ids.iter().map(|id| id.expect_local()) {
match type_map.entry(cx.tcx.type_of(impl_id)) { match type_map.entry(cx.tcx.type_of(impl_id)) {
Entry::Vacant(e) => { Entry::Vacant(e) => {

@ -35,7 +35,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, cond: &'tcx Expr<'_>, expr: &'
} else { } else {
return; return;
}; };
let mutable_static_in_cond = var_visitor.def_ids.iter().any(|(_, v)| *v); let mutable_static_in_cond = var_visitor.def_ids.items().any(|(_, v)| *v);
let mut has_break_or_return_visitor = HasBreakOrReturnVisitor { let mut has_break_or_return_visitor = HasBreakOrReturnVisitor {
has_break_or_return: false, has_break_or_return: false,

@ -80,19 +80,21 @@ impl<'tcx> LateLintPass<'tcx> for MissingTraitMethods {
} }
} }
for assoc in provided.values() { cx.tcx.with_stable_hashing_context(|hcx| {
let source_map = cx.tcx.sess.source_map(); for assoc in provided.values_sorted(&hcx) {
let definition_span = source_map.guess_head_span(cx.tcx.def_span(assoc.def_id)); let source_map = cx.tcx.sess.source_map();
let definition_span = source_map.guess_head_span(cx.tcx.def_span(assoc.def_id));
span_lint_and_help( span_lint_and_help(
cx, cx,
MISSING_TRAIT_METHODS, MISSING_TRAIT_METHODS,
source_map.guess_head_span(item.span), source_map.guess_head_span(item.span),
&format!("missing trait method provided by default: `{}`", assoc.name), &format!("missing trait method provided by default: `{}`", assoc.name),
Some(definition_span), Some(definition_span),
"implement the method", "implement the method",
); );
} }
})
} }
} }
} }

@ -190,10 +190,10 @@ impl<'tcx> PassByRefOrValue {
// Don't lint if an unsafe pointer is created. // Don't lint if an unsafe pointer is created.
// TODO: Limit the check only to unsafe pointers to the argument (or part of the argument) // TODO: Limit the check only to unsafe pointers to the argument (or part of the argument)
// which escape the current function. // which escape the current function.
if typeck.node_types().iter().any(|(_, &ty)| ty.is_unsafe_ptr()) if typeck.node_types().items().any(|(_, &ty)| ty.is_unsafe_ptr())
|| typeck || typeck
.adjustments() .adjustments()
.iter() .items()
.flat_map(|(_, a)| a) .flat_map(|(_, a)| a)
.any(|a| matches!(a.kind, Adjust::Pointer(PointerCast::UnsafeFnPointer))) .any(|a| matches!(a.kind, Adjust::Pointer(PointerCast::UnsafeFnPointer)))
{ {