Skip to content

allow-one-hash-in-raw-strings in clippy.toml not respected for needless_raw_string_hashes #11481

Closed
@gwy15

Description

@gwy15

Summary

in https://doc.rust-lang.org/clippy/lint_configuration.html#allow-one-hash-in-raw-strings, there's a configuration which, as the name suggests, should allow using one hash for raw strings. But it is not currently respected for lint needless_raw_string_hashes.

Reproducer

I tried this code:

./clippy.toml:

allow-one-hash-in-raw-strings = true

./src/main.rs:

const S: &str = r#"
\d+
"#;

fn main() {
    println!("s = {S}");
}

I expected to see this happen: No lint.

Instead, this happened:

warning: unnecessary hashes around raw string literal
 --> src/main.rs:1:17
  |
1 |   const S: &str = r#"
  |  _________________^
2 | | \d+
3 | | "#;
  | |__^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_raw_string_hashes
  = note: `#[warn(clippy::needless_raw_string_hashes)]` on by default
help: try
  |
1 ~ const S: &str = r"
2 + \d+
3 ~ ";
  |

Version

rustc 1.72.0 (5680fa18f 2023-08-23)
binary: rustc
commit-hash: 5680fa18feaa87f3ff04063800aec256c3d4b4be
commit-date: 2023-08-23
host: aarch64-apple-darwin
release: 1.72.0
LLVM version: 16.0.5

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions