]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/identity_conversion.rs
Auto merge of #4551 - mikerite:fix-ice-reporting, r=llogiq
[rust.git] / clippy_lints / src / identity_conversion.rs
index 0941ed513fc4506766eda11f8185c1442833b883..2441dd914affeeff8081c5919820d6f213473ca5 100644 (file)
@@ -1,4 +1,6 @@
-use crate::utils::{in_macro, match_trait_method, same_tys, snippet, snippet_with_macro_callsite, span_lint_and_then};
+use crate::utils::{
+    match_def_path, match_trait_method, same_tys, snippet, snippet_with_macro_callsite, span_lint_and_then,
+};
 use crate::utils::{paths, resolve_node};
 use rustc::hir::*;
 use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
@@ -31,7 +33,7 @@ pub struct IdentityConversion {
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
     fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
-        if in_macro(e.span) {
+        if e.span.from_expansion() {
             return;
         }
 
@@ -47,13 +49,11 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
                 };
                 if let ExprKind::Call(_, ref args) = e.node {
                     self.try_desugar_arm.push(args[0].hir_id);
-                } else {
-                    return;
                 }
             },
 
             ExprKind::MethodCall(ref name, .., ref args) => {
-                if match_trait_method(cx, e, &paths::INTO[..]) && &*name.ident.as_str() == "into" {
+                if match_trait_method(cx, e, &paths::INTO) && &*name.ident.as_str() == "into" {
                     let a = cx.tables.expr_ty(e);
                     let b = cx.tables.expr_ty(&args[0]);
                     if same_tys(cx, a, b) {
@@ -89,7 +89,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
             ExprKind::Call(ref path, ref args) => {
                 if let ExprKind::Path(ref qpath) = path.node {
                     if let Some(def_id) = resolve_node(cx, qpath, path.hir_id).opt_def_id() {
-                        if cx.match_def_path(def_id, &paths::FROM_FROM[..]) {
+                        if match_def_path(cx, def_id, &paths::FROM_FROM) {
                             let a = cx.tables.expr_ty(e);
                             let b = cx.tables.expr_ty(&args[0]);
                             if same_tys(cx, a, b) {