11use crate :: { EarlyContext , EarlyLintPass , LintContext } ;
2+ use ast:: util:: unicode:: { contains_text_flow_control_chars, TEXT_FLOW_CONTROL_CHARS } ;
23use rustc_ast as ast;
34use rustc_errors:: { Applicability , SuggestionStyle } ;
45use rustc_span:: { BytePos , Span , Symbol } ;
@@ -37,11 +38,6 @@ declare_lint! {
3738
3839declare_lint_pass ! ( HiddenUnicodeCodepoints => [ TEXT_DIRECTION_CODEPOINT_IN_LITERAL ] ) ;
3940
40- crate const UNICODE_TEXT_FLOW_CHARS : & [ char ] = & [
41- '\u{202A}' , '\u{202B}' , '\u{202D}' , '\u{202E}' , '\u{2066}' , '\u{2067}' , '\u{2068}' , '\u{202C}' ,
42- '\u{2069}' ,
43- ] ;
44-
4541impl HiddenUnicodeCodepoints {
4642 fn lint_text_direction_codepoint (
4743 & self ,
@@ -57,7 +53,7 @@ impl HiddenUnicodeCodepoints {
5753 . as_str ( )
5854 . char_indices ( )
5955 . filter_map ( |( i, c) | {
60- UNICODE_TEXT_FLOW_CHARS . contains ( & c) . then ( || {
56+ TEXT_FLOW_CONTROL_CHARS . contains ( & c) . then ( || {
6157 let lo = span. lo ( ) + BytePos ( i as u32 + padding) ;
6258 ( c, span. with_lo ( lo) . with_hi ( lo + BytePos ( c. len_utf8 ( ) as u32 ) ) )
6359 } )
@@ -131,7 +127,7 @@ impl HiddenUnicodeCodepoints {
131127impl EarlyLintPass for HiddenUnicodeCodepoints {
132128 fn check_attribute ( & mut self , cx : & EarlyContext < ' _ > , attr : & ast:: Attribute ) {
133129 if let ast:: AttrKind :: DocComment ( _, comment) = attr. kind {
134- if comment. as_str ( ) . contains ( UNICODE_TEXT_FLOW_CHARS ) {
130+ if contains_text_flow_control_chars ( & comment. as_str ( ) ) {
135131 self . lint_text_direction_codepoint ( cx, comment, attr. span , 0 , false , "doc comment" ) ;
136132 }
137133 }
@@ -142,7 +138,7 @@ impl EarlyLintPass for HiddenUnicodeCodepoints {
142138 let ( text, span, padding) = match & expr. kind {
143139 ast:: ExprKind :: Lit ( ast:: Lit { token, kind, span } ) => {
144140 let text = token. symbol ;
145- if !text. as_str ( ) . contains ( UNICODE_TEXT_FLOW_CHARS ) {
141+ if !contains_text_flow_control_chars ( & text. as_str ( ) ) {
146142 return ;
147143 }
148144 let padding = match kind {
0 commit comments