Skip to content

Commit cac69ec

Browse files
committed
Respond to comments and improve printout
Now get the trait names for the diagnostic message and removed more `let c: fn(_) -> _ = T; hashes from hir_utils
1 parent 7853dac commit cac69ec

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

clippy_lints/src/trait_bounds.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TraitBounds {
3232
if let Some(ref v) = map.insert(h, p.bounds.iter().collect::<Vec<_>>()) {
3333
let mut hint_string = format!("consider combining the bounds: `{:?}: ", p.bounded_ty);
3434
for b in v.iter() {
35-
hint_string.push_str(&format!("{:?}, ", b));
35+
if let GenericBound::Trait(ref poly_trait_ref, _) = b {
36+
let path = &poly_trait_ref.trait_ref.path;
37+
hint_string.push_str(&format!("{}, ", path));
38+
}
3639
}
3740
for b in p.bounds.iter() {
38-
hint_string.push_str(&format!("{:?}, ", b));
41+
if let GenericBound::Trait(ref poly_trait_ref, _) = b {
42+
let path = &poly_trait_ref.trait_ref.path;
43+
hint_string.push_str(&format!("{}, ", path));
44+
}
3945
}
4046
hint_string.truncate(hint_string.len() - 2);
4147
hint_string.push('`');

clippy_lints/src/utils/hir_utils.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -513,18 +513,12 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
513513
}
514514
},
515515
ExprKind::Tup(ref tup) => {
516-
let c: fn(_) -> _ = ExprKind::Tup;
517-
c.hash(&mut self.s);
518516
self.hash_exprs(tup);
519517
},
520518
ExprKind::Array(ref v) => {
521-
let c: fn(_) -> _ = ExprKind::Array;
522-
c.hash(&mut self.s);
523519
self.hash_exprs(v);
524520
},
525521
ExprKind::Type(ref e, ref ty) => {
526-
let c: fn(_, _) -> _ = ExprKind::Type;
527-
c.hash(&mut self.s);
528522
self.hash_expr(e);
529523
self.hash_ty(ty);
530524
},

0 commit comments

Comments
 (0)