Skip to content

Commit 7921531

Browse files
committed
Fix some of the compile errors
1 parent f3e4467 commit 7921531

File tree

2 files changed

+22
-32
lines changed

2 files changed

+22
-32
lines changed

clippy_lints/src/trait_bounds.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,19 @@
11
use crate::utils::{in_macro, span_help_and_lint, SpanlessHash};
22
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
3-
use rustc::{declare_tool_lint, lint_array};
3+
use rustc::{declare_tool_lint, lint_array, impl_lint_pass};
44
use rustc_data_structures::fx::FxHashMap;
55
use rustc::hir::*;
66

7+
#[derive(Copy, Clone)]
8+
pub struct TraitBounds;
9+
710
declare_clippy_lint! {
811
pub TYPE_REPETITION_IN_BOUNDS,
912
complexity,
1013
"Types are repeated unnecessary in trait bounds use `+` instead of using `T: _, T: _`"
1114
}
1215

13-
#[derive(Copy, Clone)]
14-
pub struct TraitBounds;
15-
16-
impl LintPass for TraitBounds {
17-
fn get_lints(&self) -> LintArray {
18-
lint_array!(TYPE_REPETITION_IN_BOUNDS)
19-
}
20-
21-
fn name(&self) -> &'static str {
22-
"TypeRepetitionInBounds"
23-
}
24-
}
25-
26-
16+
impl_lint_pass!(TraitBounds => [TYPE_REPETITION_IN_BOUNDS]);
2717

2818
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TraitBounds {
2919
fn check_generics(&mut self, cx: &LateContext<'a, 'tcx>, gen: &'tcx Generics) {
@@ -38,7 +28,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TraitBounds {
3828
let mut map = FxHashMap::default();
3929
for bound in &gen.where_clause.predicates {
4030
if let WherePredicate::BoundPredicate(ref p) = bound {
41-
let h = hash(&p.bounded_ty);
31+
let h = hash(&p.bounded_ty.node);
4232
if let Some(ref v) = map.insert(h, p.bounds) {
4333
let mut hint_string = format!("consider combining the bounds: `{:?}: ", p.bounded_ty);
4434
for &b in v.iter() {

clippy_lints/src/utils/hir_utils.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> {
258258
}
259259

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

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

607-
pub fn hash_ty(&mut self, ty: &Ty<'tcx>) {
607+
pub fn hash_ty(&mut self, ty: &TyKind) {
608608
std::mem::discriminant(&ty.node).hash(&mut self.s);
609-
match ty.sty {
610-
ty::Slice(ty) => {
609+
match ty {
610+
TyKind::Slice(ty) => {
611611
self.hash_ty(ty);
612612
},
613-
ty::Array(ty, anon_const) => {
613+
TyKind::Array(ty, anon_const) => {
614614
self.hash_ty(ty);
615615
self.hash_expr(&self.cx.tcx.hir().body(anon_const.body).value);
616616
},
617-
ty::Ptr(mut_ty) => {
617+
TyKind::Ptr(mut_ty) => {
618618
self.hash_ty(&mut_ty.ty);
619619
mut_ty.mutbl.hash(&mut self.s);
620620
},
621-
ty::Rptr(lifetime, mut_ty) => {
621+
TyKind::Rptr(lifetime, mut_ty) => {
622622
self.hash_lifetime(lifetime);
623623
self.hash_ty(&mut_ty.ty);
624624
mut_ty.mutbl.hash(&mut self.s);
625625
},
626-
ty::BareFn(bfn) => {
626+
TyKind::BareFn(bfn) => {
627627
bfn.unsafety.hash(&mut self.s);
628628
bfn.abi.hash(&mut self.s);
629629
for arg in &bfn.decl.inputs {
@@ -639,13 +639,13 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
639639
}
640640
bfn.decl.c_variadic.hash(&mut self.s);
641641
},
642-
ty::Tup(ty_list) => {
642+
TyKind::Tup(ty_list) => {
643643
for ty in ty_list {
644644
self.hash_ty(ty);
645645
}
646646

647647
},
648-
ty::Path(qpath) => {
648+
TyKind::Path(qpath) => {
649649
match qpath {
650650
QPath::Resolved(ref maybe_ty, ref path) => {
651651
if let Some(ref ty) = maybe_ty {
@@ -661,7 +661,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
661661
},
662662
}
663663
},
664-
ty::Def(_, arg_list) => {
664+
TyKind::Def(_, arg_list) => {
665665
for arg in arg_list {
666666
match arg {
667667
GenericArg::Lifetime(ref l) => self.hash_lifetime(l),
@@ -672,17 +672,17 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
672672
}
673673
}
674674
},
675-
ty::TraitObject(_, lifetime) => {
675+
TyKind::TraitObject(_, lifetime) => {
676676
self.hash_lifetime(lifetime);
677677

678678
},
679-
ty::Typeof(anon_const) => {
679+
TyKind::Typeof(anon_const) => {
680680
self.hash_expr(&self.cx.tcx.hir().body(anon_const.body).value);
681681
},
682-
ty::CVarArgs(lifetime) => {
683-
self.hash_lifetime(lifetime);
682+
TyKind::CVarArgs(lifetime) => {
683+
self.hash_lifetime(lifetime)
684684
},
685-
ty::Err | ty::Infer | ty::Never => {},
685+
TyKind::Err | TyKind::Infer | TyKind::Never => {},
686686
}
687687
}
688688
}

0 commit comments

Comments
 (0)