mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-04 18:40:18 +00:00
ef72b2cac0
Both regular strings and raw strings can contain literal newlines. This commit extends the lint to also warn about terminating strings with these. Behaviour handling for raw strings is also moved into `check_newlines` by passing in the `is_raw` boolean from `check_tts` as [suggested](https://github.com/rust-lang/rust-clippy/pull/3781#pullrequestreview-204663732)
54 lines
1.8 KiB
Text
54 lines
1.8 KiB
Text
error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead
|
|
--> $DIR/write_with_newline.rs:10:5
|
|
|
|
|
LL | write!(&mut v, "Hello/n");
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= note: `-D clippy::write-with-newline` implied by `-D warnings`
|
|
|
|
error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead
|
|
--> $DIR/write_with_newline.rs:11:5
|
|
|
|
|
LL | write!(&mut v, "Hello {}/n", "world");
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead
|
|
--> $DIR/write_with_newline.rs:12:5
|
|
|
|
|
LL | write!(&mut v, "Hello {} {}/n", "world", "#2");
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead
|
|
--> $DIR/write_with_newline.rs:13:5
|
|
|
|
|
LL | write!(&mut v, "{}/n", 1265);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead
|
|
--> $DIR/write_with_newline.rs:32:5
|
|
|
|
|
LL | write!(&mut v, "//n"); // should fail
|
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead
|
|
--> $DIR/write_with_newline.rs:39:5
|
|
|
|
|
LL | / write!(
|
|
LL | | &mut v,
|
|
LL | | "
|
|
LL | | "
|
|
LL | | );
|
|
| |_____^
|
|
|
|
error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead
|
|
--> $DIR/write_with_newline.rs:44:5
|
|
|
|
|
LL | / write!(
|
|
LL | | &mut v,
|
|
LL | | r"
|
|
LL | | "
|
|
LL | | );
|
|
| |_____^
|
|
|
|
error: aborting due to 7 previous errors
|
|
|