Fix FP [needless_raw_string_hashes]

This commit is contained in:
Catherine 2023-07-03 06:35:04 -05:00
parent ea4ca225fb
commit 9a581077d4
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"##;
}