@@ -62,16 +62,14 @@ Starting with an `expr`, you can check whether it is calling a specific method `
6262``` rust
6363impl <'tcx > LateLintPass <'tcx > for MyStructLint {
6464 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
6867 // Check the name of this method is `some_method`
69- if path . ident. name == sym! (some_method );
68+ && path . ident. name == sym! (some_method )
7069 // Optionally, check the type of the self argument.
7170 // - See "Checking for a specific type"
72- then {
71+ {
7372 // ...
74- }
7573 }
7674 }
7775}
@@ -165,18 +163,16 @@ use clippy_utils::{is_type_diagnostic_item, return_ty};
165163
166164impl <'tcx > LateLintPass <'tcx > for MyTypeImpl {
167165 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
171168 // Check the method is named `some_method`
172- if impl_item . ident. name == sym! (some_method );
169+ && impl_item . ident. name == sym! (some_method )
173170 // 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 ()
175172 // 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+ // ...
180176 }
181177 }
182178}
0 commit comments