mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 07:00:55 +00:00
fe35e08e9f
Adds a new `splitting_strings_at_newlines` lint that suggests to use `str.lines` instead of splitting a trimmed string at hard-coded newlines.
65 lines
2.4 KiB
Text
65 lines
2.4 KiB
Text
error: using `str.trim().split()` with hard-coded newlines
|
|
--> $DIR/str_split.rs:59:13
|
|
|
|
|
LL | let _ = s1.trim().split('\n');
|
|
| ^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s1.lines()`
|
|
|
|
|
= note: `-D clippy::str-split-at-newline` implied by `-D warnings`
|
|
= help: to override `-D warnings` add `#[allow(clippy::str_split_at_newline)]`
|
|
|
|
error: using `str.trim().split()` with hard-coded newlines
|
|
--> $DIR/str_split.rs:61:13
|
|
|
|
|
LL | let _ = s1.trim().split("\n");
|
|
| ^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s1.lines()`
|
|
|
|
error: using `str.trim().split()` with hard-coded newlines
|
|
--> $DIR/str_split.rs:62:13
|
|
|
|
|
LL | let _ = s1.trim().split("\r\n");
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s1.lines()`
|
|
|
|
error: using `str.trim().split()` with hard-coded newlines
|
|
--> $DIR/str_split.rs:65:13
|
|
|
|
|
LL | let _ = s2.trim().split('\n');
|
|
| ^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s2.lines()`
|
|
|
|
error: using `str.trim().split()` with hard-coded newlines
|
|
--> $DIR/str_split.rs:67:13
|
|
|
|
|
LL | let _ = s2.trim().split("\n");
|
|
| ^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s2.lines()`
|
|
|
|
error: using `str.trim().split()` with hard-coded newlines
|
|
--> $DIR/str_split.rs:68:13
|
|
|
|
|
LL | let _ = s2.trim().split("\r\n");
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s2.lines()`
|
|
|
|
error: using `str.trim().split()` with hard-coded newlines
|
|
--> $DIR/str_split.rs:72:13
|
|
|
|
|
LL | let _ = s3.trim().split('\n');
|
|
| ^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s3.lines()`
|
|
|
|
error: using `str.trim().split()` with hard-coded newlines
|
|
--> $DIR/str_split.rs:74:13
|
|
|
|
|
LL | let _ = s3.trim().split("\n");
|
|
| ^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s3.lines()`
|
|
|
|
error: using `str.trim().split()` with hard-coded newlines
|
|
--> $DIR/str_split.rs:75:13
|
|
|
|
|
LL | let _ = s3.trim().split("\r\n");
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s3.lines()`
|
|
|
|
error: using `str.trim().split()` with hard-coded newlines
|
|
--> $DIR/str_split.rs:78:13
|
|
|
|
|
LL | let _ = make_str!(s1).trim().split('\n');
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `make_str!(s1).lines()`
|
|
|
|
error: aborting due to 10 previous errors
|
|
|