@@ -43,16 +43,15 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMapOnConstructor {
43
43
return ;
44
44
} ;
45
45
46
- let ( constructor_path, constructor_item) = if_chain ! {
47
- if let hir:: ExprKind :: Call ( constructor, constructor_args) = recv. kind;
48
- if let hir:: ExprKind :: Path ( constructor_path) = constructor. kind;
49
- if let Some ( arg) = constructor_args. get( 0 ) ;
50
- then {
46
+ let ( constructor_path, constructor_item) =
47
+ if let hir:: ExprKind :: Call ( constructor, constructor_args) = recv. kind
48
+ && let hir:: ExprKind :: Path ( constructor_path) = constructor. kind
49
+ && let Some ( arg) = constructor_args. get ( 0 )
50
+ {
51
51
( constructor_path, arg)
52
52
} else {
53
53
return ;
54
- }
55
- } ;
54
+ } ;
56
55
let constructor_symbol = match constructor_path {
57
56
hir:: QPath :: Resolved ( _, path) => {
58
57
if let Some ( path_segment) = path. segments . last ( ) {
@@ -70,25 +69,23 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMapOnConstructor {
70
69
_ => return ,
71
70
}
72
71
73
- if_chain ! {
74
- if let Some ( arg) = args. get( 0 ) ;
75
- if let hir:: ExprKind :: Path ( fun) = arg. kind;
76
- then {
77
- let mut applicability = Applicability :: MachineApplicable ;
78
- let constructor_snippet =
79
- snippet_with_applicability( cx, constructor_path. span( ) , "_" , & mut applicability) ;
80
- let constructor_arg_snippet =
81
- snippet_with_applicability( cx, constructor_item. span, "_" , & mut applicability) ;
82
- span_lint_and_sugg(
83
- cx,
84
- UNNECESSARY_MAP_ON_CONSTRUCTOR ,
85
- expr. span,
86
- & format!( "unnecessary {} on contstuctor {constructor_snippet}(_)" , path. ident. name) ,
87
- "try" ,
88
- format!( "{constructor_snippet}({}({constructor_arg_snippet}))" , path. ident. name) ,
89
- applicability,
90
- ) ;
91
- }
72
+ if let Some ( arg) = args. get ( 0 )
73
+ && let hir:: ExprKind :: Path ( fun) = arg. kind
74
+ {
75
+ let mut applicability = Applicability :: MachineApplicable ;
76
+ let constructor_snippet =
77
+ snippet_with_applicability ( cx, constructor_path. span ( ) , "_" , & mut applicability) ;
78
+ let constructor_arg_snippet =
79
+ snippet_with_applicability ( cx, constructor_item. span , "_" , & mut applicability) ;
80
+ span_lint_and_sugg (
81
+ cx,
82
+ UNNECESSARY_MAP_ON_CONSTRUCTOR ,
83
+ expr. span ,
84
+ & format ! ( "unnecessary {} on contstuctor {constructor_snippet}(_)" , path. ident. name) ,
85
+ "try" ,
86
+ format ! ( "{constructor_snippet}({}({constructor_arg_snippet}))" , path. ident. name) ,
87
+ applicability,
88
+ ) ;
92
89
}
93
90
}
94
91
}
0 commit comments