Skip to content

Commit 2b149c2

Browse files
committed
nits
1 parent f37ed5d commit 2b149c2

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

clippy_lints/src/strings.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,10 +491,10 @@ impl<'tcx> LateLintPass<'tcx> for TrimSplitWhitespace {
491491
span_lint_and_sugg(
492492
cx,
493493
TRIM_SPLIT_WHITESPACE,
494-
split_ws_span.with_lo(trim_span.lo()),
495-
format!("found call to `str::{}` before `str::split_whitespace`", trim_fn_name).as_str(),
496-
format!("remove `{}()`", trim_fn_name).as_str(),
497-
"split_whitespace()".to_string(),
494+
trim_span.with_hi(split_ws_span.lo()),
495+
&format!("found call to `str::{}` before `str::split_whitespace`", trim_fn_name),
496+
&format!("remove `{}()`", trim_fn_name),
497+
String::new(),
498498
Applicability::MachineApplicable,
499499
);
500500
}

tests/ui/trim_split_whitespace.fixed

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![warn(clippy::trim_split_whitespace)]
33
#![allow(clippy::let_unit_value)]
44

5-
struct Custom();
5+
struct Custom;
66
impl Custom {
77
fn trim(self) -> Self {
88
self
@@ -69,7 +69,7 @@ fn main() {
6969
let _ = (" A B C ").to_string().split_whitespace(); // should trigger lint
7070

7171
// Custom
72-
let _ = Custom().trim().split_whitespace(); // should not trigger lint
72+
let _ = Custom.trim().split_whitespace(); // should not trigger lint
7373

7474
// Deref<Target=str>
7575
let s = DerefStr(" A B C ");

tests/ui/trim_split_whitespace.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![warn(clippy::trim_split_whitespace)]
33
#![allow(clippy::let_unit_value)]
44

5-
struct Custom();
5+
struct Custom;
66
impl Custom {
77
fn trim(self) -> Self {
88
self
@@ -69,7 +69,7 @@ fn main() {
6969
let _ = (" A B C ").to_string().trim_end().split_whitespace(); // should trigger lint
7070

7171
// Custom
72-
let _ = Custom().trim().split_whitespace(); // should not trigger lint
72+
let _ = Custom.trim().split_whitespace(); // should not trigger lint
7373

7474
// Deref<Target=str>
7575
let s = DerefStr(" A B C ");

tests/ui/trim_split_whitespace.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,51 @@ error: found call to `str::trim` before `str::split_whitespace`
22
--> $DIR/trim_split_whitespace.rs:62:23
33
|
44
LL | let _ = " A B C ".trim().split_whitespace(); // should trigger lint
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove `trim()`: `split_whitespace()`
5+
| ^^^^^^^ help: remove `trim()`
66
|
77
= note: `-D clippy::trim-split-whitespace` implied by `-D warnings`
88

99
error: found call to `str::trim_start` before `str::split_whitespace`
1010
--> $DIR/trim_split_whitespace.rs:63:23
1111
|
1212
LL | let _ = " A B C ".trim_start().split_whitespace(); // should trigger lint
13-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove `trim_start()`: `split_whitespace()`
13+
| ^^^^^^^^^^^^^ help: remove `trim_start()`
1414

1515
error: found call to `str::trim_end` before `str::split_whitespace`
1616
--> $DIR/trim_split_whitespace.rs:64:23
1717
|
1818
LL | let _ = " A B C ".trim_end().split_whitespace(); // should trigger lint
19-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove `trim_end()`: `split_whitespace()`
19+
| ^^^^^^^^^^^ help: remove `trim_end()`
2020

2121
error: found call to `str::trim` before `str::split_whitespace`
2222
--> $DIR/trim_split_whitespace.rs:67:37
2323
|
2424
LL | let _ = (" A B C ").to_string().trim().split_whitespace(); // should trigger lint
25-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove `trim()`: `split_whitespace()`
25+
| ^^^^^^^ help: remove `trim()`
2626

2727
error: found call to `str::trim_start` before `str::split_whitespace`
2828
--> $DIR/trim_split_whitespace.rs:68:37
2929
|
3030
LL | let _ = (" A B C ").to_string().trim_start().split_whitespace(); // should trigger lint
31-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove `trim_start()`: `split_whitespace()`
31+
| ^^^^^^^^^^^^^ help: remove `trim_start()`
3232

3333
error: found call to `str::trim_end` before `str::split_whitespace`
3434
--> $DIR/trim_split_whitespace.rs:69:37
3535
|
3636
LL | let _ = (" A B C ").to_string().trim_end().split_whitespace(); // should trigger lint
37-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove `trim_end()`: `split_whitespace()`
37+
| ^^^^^^^^^^^ help: remove `trim_end()`
3838

3939
error: found call to `str::trim` before `str::split_whitespace`
4040
--> $DIR/trim_split_whitespace.rs:76:15
4141
|
4242
LL | let _ = s.trim().split_whitespace(); // should trigger lint
43-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove `trim()`: `split_whitespace()`
43+
| ^^^^^^^ help: remove `trim()`
4444

4545
error: found call to `str::trim` before `str::split_whitespace`
4646
--> $DIR/trim_split_whitespace.rs:84:15
4747
|
4848
LL | let _ = s.trim().split_whitespace(); // should trigger lint
49-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove `trim()`: `split_whitespace()`
49+
| ^^^^^^^ help: remove `trim()`
5050

5151
error: aborting due to 8 previous errors
5252

0 commit comments

Comments
 (0)