iter_kv_map: recognize references on maps as well

This commit is contained in:
Samuel Tardieu 2025-04-12 00:06:57 +02:00
parent ec105bab2f
commit ebd5962aaa
4 changed files with 38 additions and 2 deletions

View file

@ -37,7 +37,7 @@ pub(super) fn check<'tcx>(
(PatKind::Binding(ann, _, key, _), value) if pat_is_wild(cx, value, m_arg) => ("key", ann, key),
_ => return,
}
&& let ty = cx.typeck_results().expr_ty(recv)
&& let ty = cx.typeck_results().expr_ty_adjusted(recv).peel_refs()
&& (is_type_diagnostic_item(cx, ty, sym::HashMap) || is_type_diagnostic_item(cx, ty, sym::BTreeMap))
{
let mut applicability = rustc_errors::Applicability::MachineApplicable;