Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ce2da2c

Browse files
authored
Merge pull request rust-lang#3283 from etaoins/dont-suggest-cloned-for-map-box-deref
Don't suggest cloned() for map Box deref
2 parents 41e94dd + 9bd4e54 commit ce2da2c

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

clippy_lints/src/map_clone.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
7979
lint(cx, e.span, args[0].span, name, closure_expr);
8080
},
8181
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, name, None) => match closure_expr.node {
82-
hir::ExprKind::Unary(hir::UnOp::UnDeref, ref inner) => lint(cx, e.span, args[0].span, name, inner),
82+
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),
8383
hir::ExprKind::MethodCall(ref method, _, ref obj) => if method.ident.as_str() == "clone" && match_trait_method(cx, closure_expr, &paths::CLONE_TRAIT) {
8484
lint(cx, e.span, args[0].span, name, &obj[0]);
8585
}

tests/ui/map_clone.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ fn main() {
1616
let _: Vec<i8> = vec![5_i8; 6].iter().map(|x| *x).collect();
1717
let _: Vec<String> = vec![String::new()].iter().map(|x| x.clone()).collect();
1818
let _: Vec<u32> = vec![42, 43].iter().map(|&x| x).collect();
19+
let _: Option<u64> = Some(Box::new(16)).map(|b| *b);
1920
}

0 commit comments

Comments
 (0)