fix iter_kv_map dont suggest into_keys and into_values if msrv is to low
This commit is contained in:
parent
d487579efd
commit
5f651da2de
6 changed files with 154 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#![allow(unused_imports)]
|
||||
|
||||
use super::ITER_KV_MAP;
|
||||
use clippy_config::msrvs::{self, Msrv};
|
||||
use clippy_utils::diagnostics::{multispan_sugg, span_lint_and_sugg, span_lint_and_then};
|
||||
use clippy_utils::source::{snippet, snippet_with_applicability};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
|
|
@ -21,7 +22,11 @@ pub(super) fn check<'tcx>(
|
|||
expr: &'tcx Expr<'tcx>, // .iter().map(|(_, v_| v))
|
||||
recv: &'tcx Expr<'tcx>, // hashmap
|
||||
m_arg: &'tcx Expr<'tcx>, // |(_, v)| v
|
||||
msrv: &Msrv,
|
||||
) {
|
||||
if map_type == "into_iter" && !msrv.meets(msrvs::INTO_KEYS) {
|
||||
return;
|
||||
}
|
||||
if !expr.span.from_expansion()
|
||||
&& let ExprKind::Closure(c) = m_arg.kind
|
||||
&& let Body {
|
||||
|
|
|
|||
|
|
@ -4255,7 +4255,7 @@ impl Methods {
|
|||
map_clone::check(cx, expr, recv, m_arg, &self.msrv);
|
||||
match method_call(recv) {
|
||||
Some((map_name @ ("iter" | "into_iter"), recv2, _, _, _)) => {
|
||||
iter_kv_map::check(cx, map_name, expr, recv2, m_arg);
|
||||
iter_kv_map::check(cx, map_name, expr, recv2, m_arg, &self.msrv);
|
||||
},
|
||||
Some(("cloned", recv2, [], _, _)) => iter_overeager_cloned::check(
|
||||
cx,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue