Auto merge of #4937 - mikerite:fix-4824, r=phansch

Fix `map_clone` false positive

Don't lint when the item type is not a reference. `copied` only applies to references.

changelog: Fix `map_clone` false positive
This commit is contained in:
bors 2019-12-22 09:55:50 +00:00
commit 8723eb6035
3 changed files with 24 additions and 2 deletions

View file

@ -69,8 +69,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MapClone {
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, .., name, None) => {
match closure_expr.kind {
hir::ExprKind::Unary(hir::UnOp::UnDeref, ref inner) => {
if ident_eq(name, inner) && !cx.tables.expr_ty(inner).is_box() {
lint(cx, e.span, args[0].span, true);
if ident_eq(name, inner) {
if let ty::Ref(..) = cx.tables.expr_ty(inner).kind {
lint(cx, e.span, args[0].span, true);
}
}
},
hir::ExprKind::MethodCall(ref method, _, ref obj) => {