]> git.lizzy.rs Git - rust.git/commitdiff
Fix cargo crash
authorPhilipp Hansch <dev@phansch.net>
Sun, 26 Apr 2020 11:45:47 +0000 (13:45 +0200)
committerPhilipp Hansch <dev@phansch.net>
Sun, 26 Apr 2020 12:11:58 +0000 (14:11 +0200)
clippy_lints/src/types.rs

index d8d6dcc3777ef91296d0aa19f5fe993820c7d304..6d49f50d550e858d0a0f87bb92fa3e275f093e95 100644 (file)
@@ -2460,14 +2460,13 @@ fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
         if_chain! {
             if let ExprKind::Call(ref fun, ref args) = e.kind;
             if let ExprKind::Path(QPath::TypeRelative(ref ty, ref method)) = fun.kind;
+            if let TyKind::Path(QPath::Resolved(None, ty_path)) = ty.kind;
             then {
                 if !same_tys(self.cx, self.target.ty(), self.body.expr_ty(e)) {
                     return;
                 }
 
-                let ty = hir_ty_to_ty(self.cx.tcx, ty);
-
-                if is_type_diagnostic_item(self.cx, ty, sym!(hashmap_type)) {
+                if match_path(ty_path, &paths::HASHMAP) {
                     if method.ident.name == sym!(new) {
                         self.suggestions
                             .insert(e.span, "HashMap::default()".to_string());
@@ -2480,7 +2479,7 @@ fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
                             ),
                         );
                     }
-                } else if is_type_diagnostic_item(self.cx, ty, sym!(hashset_type)) {
+                } else if match_path(ty_path, &paths::HASHSET) {
                     if method.ident.name == sym!(new) {
                         self.suggestions
                             .insert(e.span, "HashSet::default()".to_string());