]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/utils/hir_utils.rs
Merge pull request #3303 from shssoichiro/3069-unnecessary-fold-pattern-guard
[rust.git] / clippy_lints / src / utils / hir_utils.rs
index 939b4f595e4d09a9d32440aba3e0aae44ff3ce6f..7a0b28d15d875f47b53d78caed01d7bb1f5f47f0 100644 (file)
@@ -1,11 +1,21 @@
+// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
 use crate::consts::{constant_simple, constant_context};
-use rustc::lint::LateContext;
-use rustc::hir::*;
-use rustc::ty::{TypeckTables};
+use crate::rustc::lint::LateContext;
+use crate::rustc::hir::*;
+use crate::rustc::ty::{TypeckTables};
 use std::hash::{Hash, Hasher};
 use std::collections::hash_map::DefaultHasher;
-use syntax::ast::Name;
-use syntax::ptr::P;
+use crate::syntax::ast::Name;
+use crate::syntax::ptr::P;
 use crate::utils::differing_macro_contexts;
 
 /// Type used to check whether two ast are the same. This is different from the
@@ -63,6 +73,7 @@ pub fn eq_block(&mut self, left: &Block, right: &Block) -> bool {
             && both(&left.expr, &right.expr, |l, r| self.eq_expr(l, r))
     }
 
+    #[allow(clippy::similar_names)]
     pub fn eq_expr(&mut self, left: &Expr, right: &Expr) -> bool {
         if self.ignore_fn && differing_macro_contexts(left.span, right.span) {
             return false;
@@ -198,6 +209,7 @@ pub fn eq_pat(&mut self, left: &Pat, right: &Pat) -> bool {
         }
     }
 
+    #[allow(clippy::similar_names)]
     fn eq_qpath(&mut self, left: &QPath, right: &QPath) -> bool {
         match (left, right) {
             (&QPath::Resolved(ref lty, ref lpath), &QPath::Resolved(ref rty, ref rpath)) => {
@@ -252,6 +264,7 @@ pub fn eq_ty(&mut self, left: &Ty, right: &Ty) -> bool {
         self.eq_ty_kind(&left.node, &right.node)
     }
 
+    #[allow(clippy::similar_names)]
     pub fn eq_ty_kind(&mut self, left: &TyKind, right: &TyKind) -> bool {
         match (left, right) {
             (&TyKind::Slice(ref l_vec), &TyKind::Slice(ref r_vec)) => self.eq_ty(l_vec, r_vec),
@@ -454,8 +467,7 @@ pub fn hash_expr(&mut self, e: &Expr) {
                     CaptureClause::CaptureByValue => 0,
                     CaptureClause::CaptureByRef => 1,
                 }.hash(&mut self.s);
-                let value = &self.cx.tcx.hir.body(eid).value;
-                self.hash_expr(value);
+                self.hash_expr(&self.cx.tcx.hir.body(eid).value);
             },
             ExprKind::Field(ref e, ref f) => {
                 let c: fn(_, _) -> _ = ExprKind::Field;
@@ -522,8 +534,7 @@ pub fn hash_expr(&mut self, e: &Expr) {
                 self.hash_expr(e);
                 let full_table = self.tables;
                 self.tables = self.cx.tcx.body_tables(l_id.body);
-                let value = &self.cx.tcx.hir.body(l_id.body).value;
-                self.hash_expr(value);
+                self.hash_expr(&self.cx.tcx.hir.body(l_id.body).value);
                 self.tables = full_table;
             },
             ExprKind::Ret(ref e) => {