@@ -52,8 +52,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MapClone {
52
52
if args. len( ) == 2 ;
53
53
if method. ident. as_str( ) == "map" ;
54
54
let ty = cx. tables. expr_ty( & args[ 0 ] ) ;
55
- let is_option = match_type( cx, ty, & paths:: OPTION ) ;
56
- if is_option || match_trait_method( cx, e, & paths:: ITERATOR ) ;
55
+ if match_type( cx, ty, & paths:: OPTION ) || match_trait_method( cx, e, & paths:: ITERATOR ) ;
57
56
if let hir:: ExprKind :: Closure ( _, _, body_id, _, _) = args[ 1 ] . node;
58
57
let closure_body = cx. tcx. hir( ) . body( body_id) ;
59
58
let closure_expr = remove_blocks( & closure_body. value) ;
@@ -63,16 +62,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MapClone {
63
62
hir:: BindingAnnotation :: Unannotated , .., name, None
64
63
) = inner. node {
65
64
if ident_eq( name, closure_expr) {
66
- // FIXME When Iterator::copied() stabilizes we can remove is_option
67
- // from here and the other lint() calls
68
- lint( cx, e. span, args[ 0 ] . span, is_option) ;
65
+ lint( cx, e. span, args[ 0 ] . span, true ) ;
69
66
}
70
67
} ,
71
68
hir:: PatKind :: Binding ( hir:: BindingAnnotation :: Unannotated , .., name, None ) => {
72
69
match closure_expr. node {
73
70
hir:: ExprKind :: Unary ( hir:: UnOp :: UnDeref , ref inner) => {
74
71
if ident_eq( name, inner) && !cx. tables. expr_ty( inner) . is_box( ) {
75
- lint( cx, e. span, args[ 0 ] . span, is_option ) ;
72
+ lint( cx, e. span, args[ 0 ] . span, true ) ;
76
73
}
77
74
} ,
78
75
hir:: ExprKind :: MethodCall ( ref method, _, ref obj) => {
@@ -82,7 +79,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MapClone {
82
79
let obj_ty = cx. tables. expr_ty( & obj[ 0 ] ) ;
83
80
if let ty:: Ref ( _, ty, _) = obj_ty. sty {
84
81
let copy = is_copy( cx, ty) ;
85
- lint( cx, e. span, args[ 0 ] . span, is_option && copy) ;
82
+ lint( cx, e. span, args[ 0 ] . span, copy) ;
86
83
} else {
87
84
lint_needless_cloning( cx, e. span, args[ 0 ] . span) ;
88
85
}
0 commit comments