@@ -12,6 +12,7 @@ use itertools::Itertools;
1212use pulldown_cmark;
1313use rustc:: lint:: { EarlyContext , EarlyLintPass , LintArray , LintPass } ;
1414use rustc:: { declare_tool_lint, lint_array} ;
15+ use rustc_data_structures:: fx:: FxHashSet ;
1516use syntax:: ast;
1617use syntax:: source_map:: { BytePos , Span } ;
1718use syntax_pos:: Pos ;
@@ -43,11 +44,11 @@ declare_clippy_lint! {
4344
4445#[ derive( Clone ) ]
4546pub struct Doc {
46- valid_idents : Vec < String > ,
47+ valid_idents : FxHashSet < String > ,
4748}
4849
4950impl Doc {
50- pub fn new ( valid_idents : Vec < String > ) -> Self {
51+ pub fn new ( valid_idents : FxHashSet < String > ) -> Self {
5152 Self { valid_idents }
5253 }
5354}
@@ -144,7 +145,7 @@ pub fn strip_doc_comment_decoration(comment: &str, span: Span) -> (String, Vec<(
144145 panic ! ( "not a doc-comment: {}" , comment) ;
145146}
146147
147- pub fn check_attrs < ' a > ( cx : & EarlyContext < ' _ > , valid_idents : & [ String ] , attrs : & ' a [ ast:: Attribute ] ) {
148+ pub fn check_attrs < ' a > ( cx : & EarlyContext < ' _ > , valid_idents : & FxHashSet < String > , attrs : & ' a [ ast:: Attribute ] ) {
148149 let mut doc = String :: new ( ) ;
149150 let mut spans = vec ! [ ] ;
150151
@@ -192,7 +193,7 @@ pub fn check_attrs<'a>(cx: &EarlyContext<'_>, valid_idents: &[String], attrs: &'
192193
193194fn check_doc < ' a , Events : Iterator < Item = ( usize , pulldown_cmark:: Event < ' a > ) > > (
194195 cx : & EarlyContext < ' _ > ,
195- valid_idents : & [ String ] ,
196+ valid_idents : & FxHashSet < String > ,
196197 docs : Events ,
197198 spans : & [ ( usize , Span ) ] ,
198199) {
@@ -237,14 +238,14 @@ fn check_doc<'a, Events: Iterator<Item = (usize, pulldown_cmark::Event<'a>)>>(
237238 }
238239}
239240
240- fn check_text ( cx : & EarlyContext < ' _ > , valid_idents : & [ String ] , text : & str , span : Span ) {
241+ fn check_text ( cx : & EarlyContext < ' _ > , valid_idents : & FxHashSet < String > , text : & str , span : Span ) {
241242 for word in text. split ( |c : char | c. is_whitespace ( ) || c == '\'' ) {
242243 // Trim punctuation as in `some comment (see foo::bar).`
243244 // ^^
244245 // Or even as in `_foo bar_` which is emphasized.
245246 let word = word. trim_matches ( |c : char | !c. is_alphanumeric ( ) ) ;
246247
247- if valid_idents. iter ( ) . any ( |i| i == word) {
248+ if valid_idents. contains ( word) {
248249 continue ;
249250 }
250251
0 commit comments