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} ;
2
2
use rustc:: hir:: * ;
3
3
use rustc:: lint:: { LateContext , LateLintPass , LintArray , LintPass } ;
4
4
use rustc:: { declare_lint_pass, declare_tool_lint} ;
@@ -92,15 +92,14 @@ fn escape<T: Iterator<Item = char>>(s: T) -> String {
92
92
fn check_str ( cx : & LateContext < ' _ , ' _ > , span : Span , id : HirId ) {
93
93
let string = snippet ( cx, span, "" ) ;
94
94
if string. contains ( '\u{200B}' ) {
95
- span_help_and_lint (
95
+ span_lint_and_sugg (
96
96
cx,
97
97
ZERO_WIDTH_SPACE ,
98
98
span,
99
99
"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 ,
104
103
) ;
105
104
}
106
105
if string. chars ( ) . any ( |c| c as u32 > 0x7F ) {
@@ -109,35 +108,24 @@ fn check_str(cx: &LateContext<'_, '_>, span: Span, id: HirId) {
109
108
NON_ASCII_LITERAL ,
110
109
span,
111
110
"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
+ } ,
128
117
Applicability :: MachineApplicable ,
129
118
) ;
130
119
}
131
120
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 (
133
122
cx,
134
123
UNICODE_NOT_NFC ,
135
124
span,
136
125
"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 ,
141
129
) ;
142
130
}
143
131
}
0 commit comments