Skip to content

Commit c025917

Browse files
committed
Fixed more compile errors
Moved to rustc::hir::Ty
1 parent 7921531 commit c025917

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

clippy_lints/src/trait_bounds.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TraitBounds {
2828
let mut map = FxHashMap::default();
2929
for bound in &gen.where_clause.predicates {
3030
if let WherePredicate::BoundPredicate(ref p) = bound {
31-
let h = hash(&p.bounded_ty.node);
31+
let h = hash(&p.bounded_ty);
3232
if let Some(ref v) = map.insert(h, p.bounds) {
3333
let mut hint_string = format!("consider combining the bounds: `{:?}: ", p.bounded_ty);
34-
for &b in v.iter() {
34+
for b in v.iter() {
3535
hint_string.push_str(&format!("{:?}, ", b));
3636
}
37-
for &b in p.bounds.iter() {
37+
for b in p.bounds.iter() {
3838
hint_string.push_str(&format!("{:?}, ", b));
3939
}
4040
hint_string.truncate(hint_string.len() - 2);

clippy_lints/src/utils/hir_utils.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::utils::differing_macro_contexts;
33
use rustc::hir::ptr::P;
44
use rustc::hir::*;
55
use rustc::lint::LateContext;
6-
use rustc::ty::{self, Ty, TypeckTables};
6+
use rustc::ty::{self, TypeckTables};
77
use std::collections::hash_map::DefaultHasher;
88
use std::hash::{Hash, Hasher};
99
use syntax::ast::Name;
@@ -45,7 +45,7 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> {
4545
match (&left.node, &right.node) {
4646
(&StmtKind::Local(ref l), &StmtKind::Local(ref r)) => {
4747
self.eq_pat(&l.pat, &r.pat)
48-
&& both(&l.ty, &r.ty, |l, r| self.eq_ty(*l, *r))
48+
&& both(&l.ty, &r.ty, |l, r| self.eq_ty(l, r))
4949
&& both(&l.init, &r.init, |l, r| self.eq_expr(l, r))
5050
},
5151
(&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> {
257257
}
258258
}
259259

260-
pub fn eq_ty(&mut self, left: &Ty<'tcx>, right: &Ty<'tcx>) -> bool {
261-
self.eq_ty_kind(&left.sty, &right.sty)
260+
pub fn eq_ty(&mut self, left: &Ty, right: &Ty) -> bool {
261+
self.eq_ty_kind(&left.node, &right.node)
262262
}
263263

264264
#[allow(clippy::similar_names)]
@@ -604,8 +604,12 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
604604
}
605605
}
606606

607-
pub fn hash_ty(&mut self, ty: &TyKind) {
608-
std::mem::discriminant(&ty.node).hash(&mut self.s);
607+
pub fn hash_ty(&mut self, ty: &Ty) {
608+
self.hash_tykind(&ty.node);
609+
}
610+
611+
pub fn hash_tykind(&mut self, ty: &TyKind) {
612+
std::mem::discriminant(&ty).hash(&mut self.s);
609613
match ty {
610614
TyKind::Slice(ty) => {
611615
self.hash_ty(ty);
@@ -665,7 +669,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
665669
for arg in arg_list {
666670
match arg {
667671
GenericArg::Lifetime(ref l) => self.hash_lifetime(l),
668-
GenericArg::Type(ref ty) => self.hash_ty(ty),
672+
GenericArg::Type(ref ty) => self.hash_ty(&ty),
669673
GenericArg::Const(ref ca) => {
670674
self.hash_expr(&self.cx.tcx.hir().body(ca.value.body).value);
671675
},

0 commit comments

Comments
 (0)