@@ -62,16 +62,14 @@ Starting with an `expr`, you can check whether it is calling a specific method `
62
62
``` rust
63
63
impl <'tcx > LateLintPass <'tcx > for MyStructLint {
64
64
fn check_expr (& mut self , cx : & LateContext <'tcx >, expr : & 'tcx hir :: Expr <'_ >) {
65
- if_chain! {
66
- // Check our expr is calling a method
67
- if let hir :: ExprKind :: MethodCall (path , _ , [_self_arg , .. ]) = & expr . kind;
65
+ // Check our expr is calling a method
66
+ if let hir :: ExprKind :: MethodCall (path , _ , [_self_arg , .. ]) = & expr . kind
68
67
// Check the name of this method is `some_method`
69
- if path . ident. name == sym! (some_method );
68
+ && path . ident. name == sym! (some_method )
70
69
// Optionally, check the type of the self argument.
71
70
// - See "Checking for a specific type"
72
- then {
71
+ {
73
72
// ...
74
- }
75
73
}
76
74
}
77
75
}
@@ -165,18 +163,16 @@ use clippy_utils::{is_type_diagnostic_item, return_ty};
165
163
166
164
impl <'tcx > LateLintPass <'tcx > for MyTypeImpl {
167
165
fn check_impl_item (& mut self , cx : & LateContext <'tcx >, impl_item : & 'tcx ImplItem <'_ >) {
168
- if_chain! {
169
- // Check if item is a method/function
170
- if let ImplItemKind :: Fn (ref signature , _ ) = impl_item . kind;
166
+ // Check if item is a method/function
167
+ if let ImplItemKind :: Fn (ref signature , _ ) = impl_item . kind
171
168
// Check the method is named `some_method`
172
- if impl_item . ident. name == sym! (some_method );
169
+ && impl_item . ident. name == sym! (some_method )
173
170
// We can also check it has a parameter `self`
174
- if signature . decl. implicit_self. has_implicit_self ();
171
+ && signature . decl. implicit_self. has_implicit_self ()
175
172
// We can go further and even check if its return type is `String`
176
- if is_type_diagnostic_item (cx , return_ty (cx , impl_item . hir_id), sym! (string_type ));
177
- then {
178
- // ...
179
- }
173
+ && is_type_diagnostic_item (cx , return_ty (cx , impl_item . hir_id), sym! (string_type ))
174
+ {
175
+ // ...
180
176
}
181
177
}
182
178
}
0 commit comments