1 use crate::utils::{match_type, paths, span_lint};
3 use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
4 use rustc::ty::subst::UnpackedKind;
6 use rustc::{declare_tool_lint, lint_array};
8 /// **What it does:** Checks for usage of `RandomState`
10 /// **Why is this bad?** Some applications don't need collision prevention
11 /// which lowers the performance.
13 /// **Known problems:** None.
18 /// let mut map = std::collections::HashMap::new();
22 declare_clippy_lint! {
30 impl LintPass for Pass {
31 fn get_lints(&self) -> LintArray {
32 lint_array!(RANDOM_STATE)
36 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
37 fn check_ty(&mut self, cx: &LateContext<'a, 'tcx>, ty: &Ty) {
38 if let Some(tys) = cx.tables.node_id_to_type_opt(ty.hir_id) {
39 if let TyKind::Adt(_, substs) = tys.sty {
41 if let UnpackedKind::Type(build_hasher) = subst.unpack() {
42 if match_type(cx, build_hasher, &paths::RANDOM_STATE) {
43 span_lint(cx, RANDOM_STATE, ty.span, "usage of RandomState");