]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/identity_conversion.rs
Auto merge of #4938 - flip1995:rustup, r=flip1995
[rust.git] / clippy_lints / src / identity_conversion.rs
index 50ba2b90ee59962ffc314ef6491e7e354601a73c..c37bb02708f0b55c851e3741d0fcad7db6f78448 100644 (file)
@@ -1,12 +1,11 @@
 use crate::utils::{
-    in_macro_or_desugar, match_def_path, match_trait_method, same_tys, snippet, snippet_with_macro_callsite,
-    span_lint_and_then,
+    match_def_path, match_trait_method, paths, same_tys, snippet, snippet_with_macro_callsite, span_lint_and_then,
 };
-use crate::utils::{paths, resolve_node};
 use rustc::hir::*;
+use rustc::impl_lint_pass;
 use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
-use rustc::{declare_tool_lint, impl_lint_pass};
 use rustc_errors::Applicability;
+use rustc_session::declare_tool_lint;
 
 declare_clippy_lint! {
     /// **What it does:** Checks for always-identical `Into`/`From`/`IntoIter` conversions.
@@ -34,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_or_desugar(e.span) {
+        if e.span.from_expansion() {
             return;
         }
 
@@ -42,16 +41,14 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
             return;
         }
 
-        match e.node {
+        match e.kind {
             ExprKind::Match(_, ref arms, MatchSource::TryDesugar) => {
-                let e = match arms[0].body.node {
+                let e = match arms[0].body.kind {
                     ExprKind::Ret(Some(ref e)) | ExprKind::Break(_, Some(ref e)) => e,
                     _ => return,
                 };
-                if let ExprKind::Call(_, ref args) = e.node {
+                if let ExprKind::Call(_, ref args) = e.kind {
                     self.try_desugar_arm.push(args[0].hir_id);
-                } else {
-                    return;
                 }
             },
 
@@ -90,8 +87,8 @@ 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 let ExprKind::Path(ref qpath) = path.kind {
+                    if let Some(def_id) = cx.tables.qpath_res(qpath, path.hir_id).opt_def_id() {
                         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]);