Skip to content

Commit ba3bd8f

Browse files
committed
Auto merge of rust-lang#11078 - Centri3:11068, r=llogiq
[`needless_raw_string_hashes`]: Only reset hashes needed if not following quote Fixes rust-lang#11068 changelog: none
2 parents 3f17c5c + 9a58107 commit ba3bd8f

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

clippy_lints/src/raw_strings.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl EarlyLintPass for RawStrings {
9595
// `once` so a raw string ending in hashes is still checked
9696
let num = str.as_bytes().iter().chain(once(&0)).try_fold(0u8, |acc, &b| {
9797
match b {
98-
b'"' => (following_quote, req) = (true, 1),
98+
b'"' if !following_quote => (following_quote, req) = (true, 1),
9999
// I'm a bit surprised the compiler didn't optimize this out, there's no
100100
// branch but it still ends up doing an unnecessary comparison, it's:
101101
// - cmp r9b,1h

tests/ui/needless_raw_string_hashes.fixed

+4
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ fn main() {
1616
cr#"Hello "world"!"#;
1717
cr####" "### "## "# "####;
1818
cr###" "aa" "# "## "###;
19+
// Issue #11068, do not lint
20+
r##"a"#"a"##;
21+
br##"a"#"a"##;
22+
cr##"a"#"a"##;
1923
}

tests/ui/needless_raw_string_hashes.rs

+4
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ fn main() {
1616
cr##"Hello "world"!"##;
1717
cr######" "### "## "# "######;
1818
cr######" "aa" "# "## "######;
19+
// Issue #11068, do not lint
20+
r##"a"#"a"##;
21+
br##"a"#"a"##;
22+
cr##"a"#"a"##;
1923
}

0 commit comments

Comments
 (0)