-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #5881 - wiomoc:feature/single-char-push_str, r=ebroto,f…
…lip1995 Lint `push_str` with a single-character string literal Fixes #5875 changelog: `* [single_char_push_str]`
- Loading branch information
Showing
8 changed files
with
151 additions
and
14 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
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
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
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
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
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,15 @@ | ||
// run-rustfix | ||
#![warn(clippy::single_char_push_str)] | ||
|
||
fn main() { | ||
let mut string = String::new(); | ||
string.push('R'); | ||
string.push('\''); | ||
|
||
string.push('u'); | ||
string.push_str("st"); | ||
string.push_str(""); | ||
string.push('\x52'); | ||
string.push('\u{0052}'); | ||
string.push('a'); | ||
} |
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,15 @@ | ||
// run-rustfix | ||
#![warn(clippy::single_char_push_str)] | ||
|
||
fn main() { | ||
let mut string = String::new(); | ||
string.push_str("R"); | ||
string.push_str("'"); | ||
|
||
string.push('u'); | ||
string.push_str("st"); | ||
string.push_str(""); | ||
string.push_str("\x52"); | ||
string.push_str("\u{0052}"); | ||
string.push_str(r##"a"##); | ||
} |
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,34 @@ | ||
error: calling `push_str()` using a single-character string literal | ||
--> $DIR/single_char_push_str.rs:6:5 | ||
| | ||
LL | string.push_str("R"); | ||
| ^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('R')` | ||
| | ||
= note: `-D clippy::single-char-push-str` implied by `-D warnings` | ||
|
||
error: calling `push_str()` using a single-character string literal | ||
--> $DIR/single_char_push_str.rs:7:5 | ||
| | ||
LL | string.push_str("'"); | ||
| ^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('/'')` | ||
|
||
error: calling `push_str()` using a single-character string literal | ||
--> $DIR/single_char_push_str.rs:12:5 | ||
| | ||
LL | string.push_str("/x52"); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('/x52')` | ||
|
||
error: calling `push_str()` using a single-character string literal | ||
--> $DIR/single_char_push_str.rs:13:5 | ||
| | ||
LL | string.push_str("/u{0052}"); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('/u{0052}')` | ||
|
||
error: calling `push_str()` using a single-character string literal | ||
--> $DIR/single_char_push_str.rs:14:5 | ||
| | ||
LL | string.push_str(r##"a"##); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('a')` | ||
|
||
error: aborting due to 5 previous errors | ||
|