diff --git a/clippy_lints/src/map_clone.rs b/clippy_lints/src/map_clone.rs index c2bfcf182..b2c08e6ae 100644 --- a/clippy_lints/src/map_clone.rs +++ b/clippy_lints/src/map_clone.rs @@ -79,7 +79,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { lint(cx, e.span, args[0].span, name, closure_expr); }, hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, name, None) => match closure_expr.node { - hir::ExprKind::Unary(hir::UnOp::UnDeref, ref inner) => lint(cx, e.span, args[0].span, name, inner), + hir::ExprKind::Unary(hir::UnOp::UnDeref, ref inner) if !cx.tables.expr_ty(inner).is_box() => lint(cx, e.span, args[0].span, name, inner), hir::ExprKind::MethodCall(ref method, _, ref obj) => if method.ident.as_str() == "clone" && match_trait_method(cx, closure_expr, &paths::CLONE_TRAIT) { lint(cx, e.span, args[0].span, name, &obj[0]); } diff --git a/tests/ui/map_clone.rs b/tests/ui/map_clone.rs index 8a410737f..90611023f 100644 --- a/tests/ui/map_clone.rs +++ b/tests/ui/map_clone.rs @@ -16,4 +16,5 @@ fn main() { let _: Vec = vec![5_i8; 6].iter().map(|x| *x).collect(); let _: Vec = vec![String::new()].iter().map(|x| x.clone()).collect(); let _: Vec = vec![42, 43].iter().map(|&x| x).collect(); + let _: Option = Some(Box::new(16)).map(|b| *b); }