diff options
| author | Catherine <114838443+Centri3@users.noreply.github.com> | 2023-07-03 06:35:04 -0500 |
|---|---|---|
| committer | Catherine <114838443+Centri3@users.noreply.github.com> | 2023-07-03 06:35:04 -0500 |
| commit | 9a581077d41dcc9a751a30cdfeca17464d5a7be2 (patch) | |
| tree | c9593832398062d7a3c9fa6ab0f9d54e59132818 | |
| parent | ea4ca225fb3b22ea8c7dbc0cde87b29f003d85e6 (diff) | |
| download | rust-9a581077d41dcc9a751a30cdfeca17464d5a7be2.tar.gz rust-9a581077d41dcc9a751a30cdfeca17464d5a7be2.zip | |
Fix FP [`needless_raw_string_hashes`]
| -rw-r--r-- | clippy_lints/src/raw_strings.rs | 2 | ||||
| -rw-r--r-- | tests/ui/needless_raw_string_hashes.fixed | 4 | ||||
| -rw-r--r-- | tests/ui/needless_raw_string_hashes.rs | 4 |
3 files changed, 9 insertions, 1 deletions
diff --git a/clippy_lints/src/raw_strings.rs b/clippy_lints/src/raw_strings.rs index f45bb1ef3e1..0e964ec4724 100644 --- a/clippy_lints/src/raw_strings.rs +++ b/clippy_lints/src/raw_strings.rs @@ -95,7 +95,7 @@ impl EarlyLintPass for RawStrings { // `once` so a raw string ending in hashes is still checked let num = str.as_bytes().iter().chain(once(&0)).try_fold(0u8, |acc, &b| { match b { - b'"' => (following_quote, req) = (true, 1), + b'"' if !following_quote => (following_quote, req) = (true, 1), // I'm a bit surprised the compiler didn't optimize this out, there's no // branch but it still ends up doing an unnecessary comparison, it's: // - cmp r9b,1h diff --git a/tests/ui/needless_raw_string_hashes.fixed b/tests/ui/needless_raw_string_hashes.fixed index e4d7d8fb017..a9a6282628e 100644 --- a/tests/ui/needless_raw_string_hashes.fixed +++ b/tests/ui/needless_raw_string_hashes.fixed @@ -16,4 +16,8 @@ fn main() { cr#"Hello "world"!"#; cr####" "### "## "# "####; cr###" "aa" "# "## "###; + // Issue #11068, do not lint + r##"a"#"a"##; + br##"a"#"a"##; + cr##"a"#"a"##; } diff --git a/tests/ui/needless_raw_string_hashes.rs b/tests/ui/needless_raw_string_hashes.rs index e2d85c52e78..baa97d86470 100644 --- a/tests/ui/needless_raw_string_hashes.rs +++ b/tests/ui/needless_raw_string_hashes.rs @@ -16,4 +16,8 @@ fn main() { cr##"Hello "world"!"##; cr######" "### "## "# "######; cr######" "aa" "# "## "######; + // Issue #11068, do not lint + r##"a"#"a"##; + br##"a"#"a"##; + cr##"a"#"a"##; } |
