1- use crate :: utils:: { is_allowed, snippet, span_help_and_lint , span_lint_and_sugg} ;
1+ use crate :: utils:: { is_allowed, snippet, span_lint_and_sugg} ;
22use rustc:: hir:: * ;
33use rustc:: lint:: { LateContext , LateLintPass , LintArray , LintPass } ;
44use rustc:: { declare_lint_pass, declare_tool_lint} ;
@@ -92,15 +92,14 @@ fn escape<T: Iterator<Item = char>>(s: T) -> String {
9292fn check_str ( cx : & LateContext < ' _ , ' _ > , span : Span , id : HirId ) {
9393 let string = snippet ( cx, span, "" ) ;
9494 if string. contains ( '\u{200B}' ) {
95- span_help_and_lint (
95+ span_lint_and_sugg (
9696 cx,
9797 ZERO_WIDTH_SPACE ,
9898 span,
9999 "zero-width space detected" ,
100- & format ! (
101- "Consider replacing the string with:\n \" {}\" " ,
102- string. replace( "\u{200B} " , "\\ u{200B}" )
103- ) ,
100+ "consider replacing the string with" ,
101+ string. replace ( "\u{200B} " , "\\ u{200B}" ) ,
102+ Applicability :: MachineApplicable ,
104103 ) ;
105104 }
106105 if string. chars ( ) . any ( |c| c as u32 > 0x7F ) {
@@ -109,35 +108,24 @@ fn check_str(cx: &LateContext<'_, '_>, span: Span, id: HirId) {
109108 NON_ASCII_LITERAL ,
110109 span,
111110 "literal non-ASCII character detected" ,
112- & format ! (
113- "Consider replacing the string with:\n \" {}\" " ,
114- if is_allowed( cx, UNICODE_NOT_NFC , id) {
115- escape( string. chars( ) )
116- } else {
117- escape( string. nfc( ) )
118- }
119- ) ,
120- format ! (
121- "{}" ,
122- if is_allowed( cx, UNICODE_NOT_NFC , id) {
123- escape( string. chars( ) )
124- } else {
125- escape( string. nfc( ) )
126- }
127- ) ,
111+ "consider replacing the string with" ,
112+ if is_allowed ( cx, UNICODE_NOT_NFC , id) {
113+ escape ( string. chars ( ) )
114+ } else {
115+ escape ( string. nfc ( ) )
116+ } ,
128117 Applicability :: MachineApplicable ,
129118 ) ;
130119 }
131120 if is_allowed ( cx, NON_ASCII_LITERAL , id) && string. chars ( ) . zip ( string. nfc ( ) ) . any ( |( a, b) | a != b) {
132- span_help_and_lint (
121+ span_lint_and_sugg (
133122 cx,
134123 UNICODE_NOT_NFC ,
135124 span,
136125 "non-nfc unicode sequence detected" ,
137- & format ! (
138- "Consider replacing the string with:\n \" {}\" " ,
139- string. nfc( ) . collect:: <String >( )
140- ) ,
126+ "consider replacing the string with" ,
127+ string. nfc ( ) . collect :: < String > ( ) ,
128+ Applicability :: MachineApplicable ,
141129 ) ;
142130 }
143131}
0 commit comments