@@ -42,7 +42,7 @@ declare_clippy_lint! {
42
42
declare_clippy_lint ! {
43
43
pub PRINT_WITH_NEWLINE ,
44
44
style,
45
- "using `print!()` with a format string that ends in a newline"
45
+ "using `print!()` with a format string that ends in a single newline"
46
46
}
47
47
48
48
/// **What it does:** Checks for printing on *stdout*. The purpose of this lint
@@ -135,7 +135,7 @@ declare_clippy_lint! {
135
135
declare_clippy_lint ! {
136
136
pub WRITE_WITH_NEWLINE ,
137
137
style,
138
- "using `write!()` with a format string that ends in a newline"
138
+ "using `write!()` with a format string that ends in a single newline"
139
139
}
140
140
141
141
/// **What it does:** This lint warns about the use of literals as `write!`/`writeln!` args.
@@ -194,18 +194,18 @@ impl EarlyLintPass for Pass {
194
194
} else if mac. node . path == "print" {
195
195
span_lint ( cx, PRINT_STDOUT , mac. span , "use of `print!`" ) ;
196
196
if let Some ( fmtstr) = check_tts ( cx, & mac. node . tts , false ) {
197
- if fmtstr. ends_with ( "\\ n" ) {
197
+ if fmtstr. ends_with ( "\\ n" ) && !fmtstr . ends_with ( " \\ n \\ n" ) {
198
198
span_lint ( cx, PRINT_WITH_NEWLINE , mac. span ,
199
199
"using `print!()` with a format string that ends in a \
200
- newline, consider using `println!()` instead") ;
200
+ single newline, consider using `println!()` instead") ;
201
201
}
202
202
}
203
203
} else if mac. node . path == "write" {
204
204
if let Some ( fmtstr) = check_tts ( cx, & mac. node . tts , true ) {
205
- if fmtstr. ends_with ( "\\ n" ) {
205
+ if fmtstr. ends_with ( "\\ n" ) && !fmtstr . ends_with ( " \\ n \\ n" ) {
206
206
span_lint ( cx, WRITE_WITH_NEWLINE , mac. span ,
207
207
"using `write!()` with a format string that ends in a \
208
- newline, consider using `writeln!()` instead") ;
208
+ single newline, consider using `writeln!()` instead") ;
209
209
}
210
210
}
211
211
} else if mac. node . path == "writeln" {
0 commit comments