add needless_raw_string_hashes lint
add semicolon in doctest
This commit is contained in:
parent
ecdea8cdd3
commit
1bf74fc303
18 changed files with 216 additions and 22 deletions
|
|
@ -7,6 +7,7 @@
|
|||
clippy::to_string_in_format_args,
|
||||
clippy::needless_borrow,
|
||||
clippy::uninlined_format_args,
|
||||
clippy::needless_raw_string_hashes,
|
||||
clippy::useless_vec
|
||||
)]
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
clippy::to_string_in_format_args,
|
||||
clippy::needless_borrow,
|
||||
clippy::uninlined_format_args,
|
||||
clippy::needless_raw_string_hashes,
|
||||
clippy::useless_vec
|
||||
)]
|
||||
|
||||
|
|
|
|||
19
tests/ui/needless_raw_string_hashes.fixed
Normal file
19
tests/ui/needless_raw_string_hashes.fixed
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
//@run-rustfix
|
||||
#![allow(clippy::no_effect, unused)]
|
||||
#![warn(clippy::needless_raw_string_hashes)]
|
||||
#![feature(c_str_literals)]
|
||||
|
||||
fn main() {
|
||||
r"aaa";
|
||||
r#"Hello "world"!"#;
|
||||
r####" "### "## "# "####;
|
||||
r###" "aa" "# "## "###;
|
||||
br"aaa";
|
||||
br#"Hello "world"!"#;
|
||||
br####" "### "## "# "####;
|
||||
br###" "aa" "# "## "###;
|
||||
cr"aaa";
|
||||
cr#"Hello "world"!"#;
|
||||
cr####" "### "## "# "####;
|
||||
cr###" "aa" "# "## "###;
|
||||
}
|
||||
19
tests/ui/needless_raw_string_hashes.rs
Normal file
19
tests/ui/needless_raw_string_hashes.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
//@run-rustfix
|
||||
#![allow(clippy::no_effect, unused)]
|
||||
#![warn(clippy::needless_raw_string_hashes)]
|
||||
#![feature(c_str_literals)]
|
||||
|
||||
fn main() {
|
||||
r#"aaa"#;
|
||||
r##"Hello "world"!"##;
|
||||
r######" "### "## "# "######;
|
||||
r######" "aa" "# "## "######;
|
||||
br#"aaa"#;
|
||||
br##"Hello "world"!"##;
|
||||
br######" "### "## "# "######;
|
||||
br######" "aa" "# "## "######;
|
||||
cr#"aaa"#;
|
||||
cr##"Hello "world"!"##;
|
||||
cr######" "### "## "# "######;
|
||||
cr######" "aa" "# "## "######;
|
||||
}
|
||||
76
tests/ui/needless_raw_string_hashes.stderr
Normal file
76
tests/ui/needless_raw_string_hashes.stderr
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
error: unnecessary hashes around raw string literal
|
||||
--> $DIR/needless_raw_string_hashes.rs:7:5
|
||||
|
|
||||
LL | r#"aaa"#;
|
||||
| ^^^^^^^^ help: try: `r"aaa"`
|
||||
|
|
||||
= note: `-D clippy::needless-raw-string-hashes` implied by `-D warnings`
|
||||
|
||||
error: unnecessary hashes around raw string literal
|
||||
--> $DIR/needless_raw_string_hashes.rs:8:5
|
||||
|
|
||||
LL | r##"Hello "world"!"##;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `r#"Hello "world"!"#`
|
||||
|
||||
error: unnecessary hashes around raw string literal
|
||||
--> $DIR/needless_raw_string_hashes.rs:9:5
|
||||
|
|
||||
LL | r######" "### "## "# "######;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `r####" "### "## "# "####`
|
||||
|
||||
error: unnecessary hashes around raw string literal
|
||||
--> $DIR/needless_raw_string_hashes.rs:10:5
|
||||
|
|
||||
LL | r######" "aa" "# "## "######;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `r###" "aa" "# "## "###`
|
||||
|
||||
error: unnecessary hashes around raw string literal
|
||||
--> $DIR/needless_raw_string_hashes.rs:11:5
|
||||
|
|
||||
LL | br#"aaa"#;
|
||||
| ^^^^^^^^^ help: try: `br"aaa"`
|
||||
|
||||
error: unnecessary hashes around raw string literal
|
||||
--> $DIR/needless_raw_string_hashes.rs:12:5
|
||||
|
|
||||
LL | br##"Hello "world"!"##;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `br#"Hello "world"!"#`
|
||||
|
||||
error: unnecessary hashes around raw string literal
|
||||
--> $DIR/needless_raw_string_hashes.rs:13:5
|
||||
|
|
||||
LL | br######" "### "## "# "######;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `br####" "### "## "# "####`
|
||||
|
||||
error: unnecessary hashes around raw string literal
|
||||
--> $DIR/needless_raw_string_hashes.rs:14:5
|
||||
|
|
||||
LL | br######" "aa" "# "## "######;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `br###" "aa" "# "## "###`
|
||||
|
||||
error: unnecessary hashes around raw string literal
|
||||
--> $DIR/needless_raw_string_hashes.rs:15:5
|
||||
|
|
||||
LL | cr#"aaa"#;
|
||||
| ^^^^^^^^^ help: try: `cr"aaa"`
|
||||
|
||||
error: unnecessary hashes around raw string literal
|
||||
--> $DIR/needless_raw_string_hashes.rs:16:5
|
||||
|
|
||||
LL | cr##"Hello "world"!"##;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `cr#"Hello "world"!"#`
|
||||
|
||||
error: unnecessary hashes around raw string literal
|
||||
--> $DIR/needless_raw_string_hashes.rs:17:5
|
||||
|
|
||||
LL | cr######" "### "## "# "######;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cr####" "### "## "# "####`
|
||||
|
||||
error: unnecessary hashes around raw string literal
|
||||
--> $DIR/needless_raw_string_hashes.rs:18:5
|
||||
|
|
||||
LL | cr######" "aa" "# "## "######;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cr###" "aa" "# "## "###`
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#![allow(unused, clippy::needless_borrow)]
|
||||
#![allow(unused, clippy::needless_raw_string_hashes, clippy::needless_borrow)]
|
||||
#![warn(clippy::invalid_regex, clippy::trivial_regex)]
|
||||
|
||||
extern crate regex;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
//@run-rustfix
|
||||
#![warn(clippy::single_char_add_str)]
|
||||
#![allow(clippy::needless_raw_string_hashes)]
|
||||
|
||||
macro_rules! get_string {
|
||||
() => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
//@run-rustfix
|
||||
#![warn(clippy::single_char_add_str)]
|
||||
#![allow(clippy::needless_raw_string_hashes)]
|
||||
|
||||
macro_rules! get_string {
|
||||
() => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: calling `push_str()` using a single-character string literal
|
||||
--> $DIR/single_char_add_str.rs:14:5
|
||||
--> $DIR/single_char_add_str.rs:15:5
|
||||
|
|
||||
LL | string.push_str("R");
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('R')`
|
||||
|
|
@ -7,85 +7,85 @@ LL | string.push_str("R");
|
|||
= note: `-D clippy::single-char-add-str` implied by `-D warnings`
|
||||
|
||||
error: calling `push_str()` using a single-character string literal
|
||||
--> $DIR/single_char_add_str.rs:15:5
|
||||
--> $DIR/single_char_add_str.rs:16: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_add_str.rs:20:5
|
||||
--> $DIR/single_char_add_str.rs:21: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_add_str.rs:21:5
|
||||
--> $DIR/single_char_add_str.rs:22: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_add_str.rs:22:5
|
||||
--> $DIR/single_char_add_str.rs:23:5
|
||||
|
|
||||
LL | string.push_str(r##"a"##);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('a')`
|
||||
|
||||
error: calling `push_str()` using a single-character string literal
|
||||
--> $DIR/single_char_add_str.rs:24:5
|
||||
--> $DIR/single_char_add_str.rs:25:5
|
||||
|
|
||||
LL | get_string!().push_str("ö");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `get_string!().push('ö')`
|
||||
|
||||
error: calling `insert_str()` using a single-character string literal
|
||||
--> $DIR/single_char_add_str.rs:29:5
|
||||
--> $DIR/single_char_add_str.rs:30:5
|
||||
|
|
||||
LL | string.insert_str(0, "R");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(0, 'R')`
|
||||
|
||||
error: calling `insert_str()` using a single-character string literal
|
||||
--> $DIR/single_char_add_str.rs:30:5
|
||||
--> $DIR/single_char_add_str.rs:31:5
|
||||
|
|
||||
LL | string.insert_str(1, "'");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(1, '/'')`
|
||||
|
||||
error: calling `insert_str()` using a single-character string literal
|
||||
--> $DIR/single_char_add_str.rs:35:5
|
||||
--> $DIR/single_char_add_str.rs:36:5
|
||||
|
|
||||
LL | string.insert_str(0, "/x52");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(0, '/x52')`
|
||||
|
||||
error: calling `insert_str()` using a single-character string literal
|
||||
--> $DIR/single_char_add_str.rs:36:5
|
||||
--> $DIR/single_char_add_str.rs:37:5
|
||||
|
|
||||
LL | string.insert_str(0, "/u{0052}");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(0, '/u{0052}')`
|
||||
|
||||
error: calling `insert_str()` using a single-character string literal
|
||||
--> $DIR/single_char_add_str.rs:38:5
|
||||
--> $DIR/single_char_add_str.rs:39:5
|
||||
|
|
||||
LL | string.insert_str(x, r##"a"##);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(x, 'a')`
|
||||
|
||||
error: calling `insert_str()` using a single-character string literal
|
||||
--> $DIR/single_char_add_str.rs:40:5
|
||||
--> $DIR/single_char_add_str.rs:41:5
|
||||
|
|
||||
LL | string.insert_str(Y, r##"a"##);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(Y, 'a')`
|
||||
|
||||
error: calling `insert_str()` using a single-character string literal
|
||||
--> $DIR/single_char_add_str.rs:41:5
|
||||
--> $DIR/single_char_add_str.rs:42:5
|
||||
|
|
||||
LL | string.insert_str(Y, r##"""##);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(Y, '"')`
|
||||
|
||||
error: calling `insert_str()` using a single-character string literal
|
||||
--> $DIR/single_char_add_str.rs:42:5
|
||||
--> $DIR/single_char_add_str.rs:43:5
|
||||
|
|
||||
LL | string.insert_str(Y, r##"'"##);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(Y, '/'')`
|
||||
|
||||
error: calling `insert_str()` using a single-character string literal
|
||||
--> $DIR/single_char_add_str.rs:44:5
|
||||
--> $DIR/single_char_add_str.rs:45:5
|
||||
|
|
||||
LL | get_string!().insert_str(1, "?");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `get_string!().insert(1, '?')`
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//@run-rustfix
|
||||
|
||||
#![allow(unused_must_use)]
|
||||
#![allow(clippy::needless_raw_string_hashes, unused_must_use)]
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//@run-rustfix
|
||||
|
||||
#![allow(unused_must_use)]
|
||||
#![allow(clippy::needless_raw_string_hashes, unused_must_use)]
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//@run-rustfix
|
||||
//@aux-build:macro_rules.rs
|
||||
|
||||
#![allow(dead_code, unused_variables)]
|
||||
#![allow(clippy::needless_raw_string_hashes, dead_code, unused_variables)]
|
||||
#![warn(clippy::string_lit_as_bytes)]
|
||||
|
||||
#[macro_use]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//@run-rustfix
|
||||
//@aux-build:macro_rules.rs
|
||||
|
||||
#![allow(dead_code, unused_variables)]
|
||||
#![allow(clippy::needless_raw_string_hashes, dead_code, unused_variables)]
|
||||
#![warn(clippy::string_lit_as_bytes)]
|
||||
|
||||
#[macro_use]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue