-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
string_add, string_add_assign: split tests, make one rustfixable
- Loading branch information
1 parent
898e971
commit 895c661
Showing
7 changed files
with
115 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#[warn(clippy::string_add)] | ||
#[allow(clippy::string_add_assign, unused)] | ||
fn main() { | ||
// ignores assignment distinction | ||
let mut x = "".to_owned(); | ||
|
||
for _ in 1..3 { | ||
x = x + "."; | ||
} | ||
|
||
let y = "".to_owned(); | ||
let z = y + "..."; | ||
|
||
assert_eq!(&x, &z); | ||
|
||
let mut x = 1; | ||
x = x + 1; | ||
assert_eq!(2, x); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
error: manual implementation of an assign operation | ||
--> $DIR/string_add.rs:8:9 | ||
| | ||
LL | x = x + "."; | ||
| ^^^^^^^^^^^ help: replace it with: `x += "."` | ||
| | ||
= note: `-D clippy::assign-op-pattern` implied by `-D warnings` | ||
|
||
error: you added something to a string. Consider using `String::push_str()` instead | ||
--> $DIR/string_add.rs:8:13 | ||
| | ||
LL | x = x + "."; | ||
| ^^^^^^^ | ||
| | ||
= note: `-D clippy::string-add` implied by `-D warnings` | ||
|
||
error: you added something to a string. Consider using `String::push_str()` instead | ||
--> $DIR/string_add.rs:12:13 | ||
| | ||
LL | let z = y + "..."; | ||
| ^^^^^^^^^ | ||
|
||
error: manual implementation of an assign operation | ||
--> $DIR/string_add.rs:17:5 | ||
| | ||
LL | x = x + 1; | ||
| ^^^^^^^^^ help: replace it with: `x += 1` | ||
|
||
error: aborting due to 4 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// run-rustfix | ||
|
||
#[allow(clippy::string_add, unused)] | ||
#[warn(clippy::string_add_assign)] | ||
fn main() { | ||
// ignores assignment distinction | ||
let mut x = "".to_owned(); | ||
|
||
for _ in 1..3 { | ||
x += "."; | ||
} | ||
|
||
let y = "".to_owned(); | ||
let z = y + "..."; | ||
|
||
assert_eq!(&x, &z); | ||
|
||
let mut x = 1; | ||
x += 1; | ||
assert_eq!(2, x); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// run-rustfix | ||
|
||
#[allow(clippy::string_add, unused)] | ||
#[warn(clippy::string_add_assign)] | ||
fn main() { | ||
// ignores assignment distinction | ||
let mut x = "".to_owned(); | ||
|
||
for _ in 1..3 { | ||
x = x + "."; | ||
} | ||
|
||
let y = "".to_owned(); | ||
let z = y + "..."; | ||
|
||
assert_eq!(&x, &z); | ||
|
||
let mut x = 1; | ||
x = x + 1; | ||
assert_eq!(2, x); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
error: you assigned the result of adding something to this string. Consider using `String::push_str()` instead | ||
--> $DIR/string_add_assign.rs:10:9 | ||
| | ||
LL | x = x + "."; | ||
| ^^^^^^^^^^^ | ||
| | ||
= note: `-D clippy::string-add-assign` implied by `-D warnings` | ||
|
||
error: manual implementation of an assign operation | ||
--> $DIR/string_add_assign.rs:10:9 | ||
| | ||
LL | x = x + "."; | ||
| ^^^^^^^^^^^ help: replace it with: `x += "."` | ||
| | ||
= note: `-D clippy::assign-op-pattern` implied by `-D warnings` | ||
|
||
error: manual implementation of an assign operation | ||
--> $DIR/string_add_assign.rs:19:5 | ||
| | ||
LL | x = x + 1; | ||
| ^^^^^^^^^ help: replace it with: `x += 1` | ||
|
||
error: aborting due to 3 previous errors | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.