]> git.lizzy.rs Git - rust.git/blobdiff - clippy_utils/src/eager_or_lazy.rs
Auto merge of #7726 - dswij:unseparated-literal-suffix, r=flip1995
[rust.git] / clippy_utils / src / eager_or_lazy.rs
index 8013c4e4fcbe417b369ea1de6be89036ad69e620..1ea7ccfb75212bb5e9a12b3c04fe514dde7343db 100644 (file)
@@ -9,7 +9,8 @@
 //!  - or-fun-call
 //!  - option-if-let-else
 
-use crate::{is_ctor_or_promotable_const_function, is_type_diagnostic_item};
+use crate::is_ctor_or_promotable_const_function;
+use crate::ty::is_type_diagnostic_item;
 use rustc_hir::def::{DefKind, Res};
 
 use rustc_hir::intravisit;
@@ -26,10 +27,9 @@ fn identify_some_pure_patterns(expr: &Expr<'_>) -> bool {
     match expr.kind {
         ExprKind::Lit(..) | ExprKind::ConstBlock(..) | ExprKind::Path(..) | ExprKind::Field(..) => true,
         ExprKind::AddrOf(_, _, addr_of_expr) => identify_some_pure_patterns(addr_of_expr),
-        ExprKind::Tup(tup_exprs) => tup_exprs.iter().all(|expr| identify_some_pure_patterns(expr)),
+        ExprKind::Tup(tup_exprs) => tup_exprs.iter().all(identify_some_pure_patterns),
         ExprKind::Struct(_, fields, expr) => {
-            fields.iter().all(|f| identify_some_pure_patterns(f.expr))
-                && expr.map_or(true, |e| identify_some_pure_patterns(e))
+            fields.iter().all(|f| identify_some_pure_patterns(f.expr)) && expr.map_or(true, identify_some_pure_patterns)
         },
         ExprKind::Call(
             &Expr {
@@ -44,7 +44,7 @@ fn identify_some_pure_patterns(expr: &Expr<'_>) -> bool {
                 ..
             },
             args,
-        ) => args.iter().all(|expr| identify_some_pure_patterns(expr)),
+        ) => args.iter().all(identify_some_pure_patterns),
         ExprKind::Block(
             &Block {
                 stmts,
@@ -59,6 +59,7 @@ fn identify_some_pure_patterns(expr: &Expr<'_>) -> bool {
         | ExprKind::MethodCall(..)
         | ExprKind::Binary(..)
         | ExprKind::Unary(..)
+        | ExprKind::Let(..)
         | ExprKind::Cast(..)
         | ExprKind::Type(..)
         | ExprKind::DropTemps(..)
@@ -100,7 +101,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) {
                 ExprKind::Call(..) => !is_ctor_or_promotable_const_function(self.cx, expr),
                 ExprKind::Index(obj, _) => {
                     let ty = self.cx.typeck_results().expr_ty(obj);
-                    is_type_diagnostic_item(self.cx, ty, sym::hashmap_type)
+                    is_type_diagnostic_item(self.cx, ty, sym::HashMap)
                         || is_type_diagnostic_item(self.cx, ty, sym::BTreeMap)
                 },
                 ExprKind::MethodCall(..) => true,