]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/methods.rs
Merge pull request #2991 from mikerite/issue2979
[rust.git] / clippy_lints / src / methods.rs
index 9a6d3df3088f8b4f84e066f4a5de46e18c6b6704..c8f3e0db3240895644170399d9f26ed69c1ab2a9 100644 (file)
@@ -1047,10 +1047,21 @@ fn check_general_case(
             return;
         }
 
-        // don't lint for constant values
-        let owner_def = cx.tcx.hir.get_parent_did(arg.id);
-        let promotable = cx.tcx.rvalue_promotable_map(owner_def).contains(&arg.hir_id.local_id);
-        if promotable {
+        fn is_call(node: &hir::ExprKind) -> bool {
+            match node {
+                hir::ExprKind::AddrOf(_, expr) => {
+                    is_call(&expr.node)
+                },
+                hir::ExprKind::Call(..)
+                | hir::ExprKind::MethodCall(..)
+                // These variants are debatable or require further examination
+                | hir::ExprKind::If(..)
+                | hir::ExprKind::Match(..) => true,
+                _ => false,
+            }
+        }
+
+        if !is_call(&arg.node) {
             return;
         }