@@ -11,6 +11,7 @@ use crate::utils::span_lint;
11
11
use rustc:: hir:: * ;
12
12
use rustc:: lint:: { LateContext , LateLintPass , LintArray , LintPass } ;
13
13
use rustc:: { declare_tool_lint, lint_array} ;
14
+ use rustc_data_structures:: fx:: FxHashSet ;
14
15
15
16
/// **What it does:** Checks for usage of blacklisted names for variables, such
16
17
/// as `foo`.
@@ -32,11 +33,11 @@ declare_clippy_lint! {
32
33
33
34
#[ derive( Clone , Debug ) ]
34
35
pub struct BlackListedName {
35
- blacklist : Vec < String > ,
36
+ blacklist : FxHashSet < String > ,
36
37
}
37
38
38
39
impl BlackListedName {
39
- pub fn new ( blacklist : Vec < String > ) -> Self {
40
+ pub fn new ( blacklist : FxHashSet < String > ) -> Self {
40
41
Self { blacklist }
41
42
}
42
43
}
@@ -50,7 +51,7 @@ impl LintPass for BlackListedName {
50
51
impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for BlackListedName {
51
52
fn check_pat ( & mut self , cx : & LateContext < ' a , ' tcx > , pat : & ' tcx Pat ) {
52
53
if let PatKind :: Binding ( _, _, ident, _) = pat. node {
53
- if self . blacklist . iter ( ) . any ( |s| ident. name == * s ) {
54
+ if self . blacklist . contains ( & ident. name . to_string ( ) ) {
54
55
span_lint (
55
56
cx,
56
57
BLACKLISTED_NAME ,
0 commit comments