- span_lint_and_sugg(
- cx,
- MAP_CLONE,
- replace,
- "You are using an explicit closure for cloning elements",
- "Consider calling the dedicated `cloned` method",
- format!(
- "{}.cloned()",
- snippet_with_applicability(cx, root, "..", &mut applicability)
- ),
- applicability,
- )
+ if copied {
+ span_lint_and_sugg(
+ cx,
+ MAP_CLONE,
+ replace,
+ "You are using an explicit closure for copying elements",
+ "Consider calling the dedicated `copied` method",
+ format!(
+ "{}.copied()",
+ snippet_with_applicability(cx, root, "..", &mut applicability)
+ ),
+ applicability,
+ )
+ } else {
+ span_lint_and_sugg(
+ cx,
+ MAP_CLONE,
+ replace,
+ "You are using an explicit closure for cloning elements",
+ "Consider calling the dedicated `cloned` method",
+ format!(
+ "{}.cloned()",
+ snippet_with_applicability(cx, root, "..", &mut applicability)
+ ),
+ applicability,
+ )
+ }