diff --git a/clippy_lints/src/trait_bounds.rs b/clippy_lints/src/trait_bounds.rs index e41437bf1..02514377d 100644 --- a/clippy_lints/src/trait_bounds.rs +++ b/clippy_lints/src/trait_bounds.rs @@ -28,13 +28,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TraitBounds { 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); diff --git a/clippy_lints/src/utils/hir_utils.rs b/clippy_lints/src/utils/hir_utils.rs index 5304a9226..4330b5587 100644 --- a/clippy_lints/src/utils/hir_utils.rs +++ b/clippy_lints/src/utils/hir_utils.rs @@ -3,7 +3,7 @@ use crate::utils::differing_macro_contexts; 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 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> { 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 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> { } } - 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 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { } } - 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 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { 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); },