]> git.lizzy.rs Git - rust.git/commitdiff
Fixed more compile errors
authorxd009642 <danielmckenna93@gmail.com>
Wed, 24 Jul 2019 21:59:32 +0000 (22:59 +0100)
committerxd009642 <danielmckenna93@gmail.com>
Wed, 24 Jul 2019 21:59:32 +0000 (22:59 +0100)
Moved to rustc::hir::Ty

clippy_lints/src/trait_bounds.rs
clippy_lints/src/utils/hir_utils.rs

index e41437bf1f825657eb46a01854c631b74cc9bb2f..02514377dfb4e25986d05feba74eee0018a5ada9 100644 (file)
@@ -28,13 +28,13 @@ fn check_generics(&mut self, cx: &LateContext<'a, 'tcx>, gen: &'tcx Generics) {
         let mut map = FxHashMap::default();
         for bound in &gen.where_clause.predicates {
             if let WherePredicate::BoundPredicate(ref p) = bound {
-                let h = hash(&p.bounded_ty.node);
+                let h = hash(&p.bounded_ty);
                 if let Some(ref v) = map.insert(h, p.bounds) {
                     let mut hint_string = format!("consider combining the bounds: `{:?}: ", p.bounded_ty);
-                    for &b in v.iter() {
+                    for b in v.iter() {
                         hint_string.push_str(&format!("{:?}, ", b));
                     }
-                    for &b in p.bounds.iter() {
+                    for b in p.bounds.iter() {
                         hint_string.push_str(&format!("{:?}, ", b));
                     }
                     hint_string.truncate(hint_string.len() - 2);
index 5304a9226ae5d3be3fe83cec12bb710cc8cc460d..4330b55878c3dab8d2f31b9e2032cd647c179d43 100644 (file)
@@ -3,7 +3,7 @@
 use rustc::hir::ptr::P;
 use rustc::hir::*;
 use rustc::lint::LateContext;
-use rustc::ty::{self, Ty, TypeckTables};
+use rustc::ty::{self, TypeckTables};
 use std::collections::hash_map::DefaultHasher;
 use std::hash::{Hash, Hasher};
 use syntax::ast::Name;
@@ -45,7 +45,7 @@ pub fn eq_stmt(&mut self, left: &Stmt, right: &Stmt) -> bool {
         match (&left.node, &right.node) {
             (&StmtKind::Local(ref l), &StmtKind::Local(ref r)) => {
                 self.eq_pat(&l.pat, &r.pat)
-                    && both(&l.ty, &r.ty, |l, r| self.eq_ty(*l, *r))
+                    && both(&l.ty, &r.ty, |l, r| self.eq_ty(l, r))
                     && both(&l.init, &r.init, |l, r| self.eq_expr(l, r))
             },
             (&StmtKind::Expr(ref l), &StmtKind::Expr(ref r)) | (&StmtKind::Semi(ref l), &StmtKind::Semi(ref r)) => {
@@ -257,8 +257,8 @@ pub fn eq_path_segment(&mut self, left: &PathSegment, right: &PathSegment) -> bo
         }
     }
 
-    pub fn eq_ty(&mut self, left: &Ty<'tcx>, right: &Ty<'tcx>) -> bool {
-        self.eq_ty_kind(&left.sty, &right.sty)
+    pub fn eq_ty(&mut self, left: &Ty, right: &Ty) -> bool {
+        self.eq_ty_kind(&left.node, &right.node)
     }
 
     #[allow(clippy::similar_names)]
@@ -604,8 +604,12 @@ pub fn hash_lifetime(&mut self, lifetime: &Lifetime) {
         }
     }
 
-    pub fn hash_ty(&mut self, ty: &TyKind) {
-        std::mem::discriminant(&ty.node).hash(&mut self.s);
+    pub fn hash_ty(&mut self, ty: &Ty) {
+        self.hash_tykind(&ty.node);
+    }
+
+    pub fn hash_tykind(&mut self, ty: &TyKind) {
+        std::mem::discriminant(&ty).hash(&mut self.s);
         match ty {
             TyKind::Slice(ty) => {
                 self.hash_ty(ty);
@@ -665,7 +669,7 @@ pub fn hash_ty(&mut self, ty: &TyKind) {
                 for arg in arg_list {
                     match arg {
                         GenericArg::Lifetime(ref l) => self.hash_lifetime(l),
-                        GenericArg::Type(ref ty) => self.hash_ty(ty),
+                        GenericArg::Type(ref ty) => self.hash_ty(&ty),
                         GenericArg::Const(ref ca) => {
                             self.hash_expr(&self.cx.tcx.hir().body(ca.value.body).value);
                         },