@@ -38,7 +38,7 @@ declare_clippy_lint! {
38
38
declare_clippy_lint ! {
39
39
pub PRINT_WITH_NEWLINE ,
40
40
style,
41
- "using `print!()` with a format string that ends in a newline"
41
+ "using `print!()` with a format string that ends in a single newline"
42
42
}
43
43
44
44
/// **What it does:** Checks for printing on *stdout*. The purpose of this lint
@@ -127,7 +127,7 @@ declare_clippy_lint! {
127
127
declare_clippy_lint ! {
128
128
pub WRITE_WITH_NEWLINE ,
129
129
style,
130
- "using `write!()` with a format string that ends in a newline"
130
+ "using `write!()` with a format string that ends in a single newline"
131
131
}
132
132
133
133
/// **What it does:** This lint warns about the use of literals as `write!`/`writeln!` args.
@@ -186,18 +186,18 @@ impl EarlyLintPass for Pass {
186
186
} else if mac. node . path == "print" {
187
187
span_lint ( cx, PRINT_STDOUT , mac. span , "use of `print!`" ) ;
188
188
if let Some ( fmtstr) = check_tts ( cx, & mac. node . tts , false ) {
189
- if fmtstr. ends_with ( "\\ n" ) {
189
+ if fmtstr. ends_with ( "\\ n" ) && !fmtstr . ends_with ( " \\ n \\ n" ) {
190
190
span_lint ( cx, PRINT_WITH_NEWLINE , mac. span ,
191
191
"using `print!()` with a format string that ends in a \
192
- newline, consider using `println!()` instead") ;
192
+ single newline, consider using `println!()` instead") ;
193
193
}
194
194
}
195
195
} else if mac. node . path == "write" {
196
196
if let Some ( fmtstr) = check_tts ( cx, & mac. node . tts , true ) {
197
- if fmtstr. ends_with ( "\\ n" ) {
197
+ if fmtstr. ends_with ( "\\ n" ) && !fmtstr . ends_with ( " \\ n \\ n" ) {
198
198
span_lint ( cx, WRITE_WITH_NEWLINE , mac. span ,
199
199
"using `write!()` with a format string that ends in a \
200
- newline, consider using `writeln!()` instead") ;
200
+ single newline, consider using `writeln!()` instead") ;
201
201
}
202
202
}
203
203
} else if mac. node . path == "writeln" {
0 commit comments