Skip to content

Commit a4f45e8

Browse files
committed
Use cx.access_levels.exported() instead of visibility
1 parent 31f16b8 commit a4f45e8

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

clippy_lints/src/types.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,15 +1453,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidUpcastComparisons {
14531453
}
14541454
}
14551455

1456-
/// **What it does:** Checks for `impl` or `fn` missing generalization over
1456+
/// **What it does:** Checks for public `impl` or `fn` missing generalization over
14571457
/// different hashers and implicitly defaulting to the default hashing
1458-
/// algorithm (SipHash). This lint ignores private free-functions.
1458+
/// algorithm (SipHash).
14591459
///
14601460
/// **Why is this bad?** `HashMap` or `HashSet` with custom hashers cannot be
14611461
/// used with them.
14621462
///
1463-
/// **Known problems:** Suggestions for replacing constructors contains
1464-
/// false-positives. Also applying suggestion can require modification of other
1463+
/// **Known problems:** Suggestions for replacing constructors can contain
1464+
/// false-positives. Also applying suggestions can require modification of other
14651465
/// pieces of code, possibly including external crates.
14661466
///
14671467
/// **Example:**
@@ -1530,9 +1530,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImplicitHasher {
15301530
if !vis.suggestions.is_empty() {
15311531
multispan_sugg(db, "...and use generic constructor".into(), vis.suggestions);
15321532
}
1533-
// for (span, sugg) in vis.suggestions {
1534-
// db.span_suggestion(span, "...and use generic constructor here", sugg);
1535-
// }
1533+
}
1534+
1535+
if !cx.access_levels.is_exported(item.id) {
1536+
return;
15361537
}
15371538

15381539
match item.node {
@@ -1565,10 +1566,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImplicitHasher {
15651566
}
15661567
},
15671568
ItemFn(ref decl, .., ref generics, body_id) => {
1568-
if item.vis != Public {
1569-
return;
1570-
}
1571-
15721569
let body = cx.tcx.hir.body(body_id);
15731570

15741571
for ty in &decl.inputs {

tests/ui/implicit_hasher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::collections::{HashMap, HashSet};
44
use std::cmp::Eq;
55
use std::hash::{Hash, BuildHasher};
66

7-
trait Foo<T>: Sized {
7+
pub trait Foo<T>: Sized {
88
fn make() -> (Self, Self);
99
}
1010

0 commit comments

Comments
 (0)