Auto merge of #11078 - Centri3:11068, r=llogiq

[`needless_raw_string_hashes`]: Only reset hashes needed if not following quote

Fixes #11068

changelog: none
This commit is contained in:
bors 2023-07-03 17:01:27 +00:00
commit ba3bd8f0f1
3 changed files with 9 additions and 1 deletions

View file

@ -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

View file

@ -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"##;
}

View file

@ -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"##;
}