Skip to content

FP: needless_raw_string_hashes on inner empty raw string #11737

Description

@pms1969

Summary

I have a situation where I'm including a raw string in a raw string... for testing, but I could also do this outside of a test.

Precisely, I have this:

        let input = r##"task test(image: rust:latest, execute: "") {r#""#}"##;
        check(input);

I have Pedantic lints enabled, and the empty raw string triggers the lint. If I add a space to the inner raw string; or any other character; the lint does not fire. i.e.

        let input = r##"task test(image: rust:latest, execute: "") {r#"_"#}"##;
        check(input);

Lint Name

needless_raw_string_hashes

Reproducer

I tried this code:

        let input = r##"task test(image: rust:latest, execute: "") {r#""#}"##;
        check(input);

I saw this happen:

   |
73 |         let input = r##"task test(image: rust, execute: "") {r#""#}"##;
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `r#"task test(image: rust, execute: "") {r#""#}"#`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_raw_string_hashes
   = note: `-D clippy::needless-raw-string-hashes` implied by `-D warnings`

I expected to see this happen:
I do not expect the lint to trigger in this situation.

Version

rustc 1.73.0 (cc66ad468 2023-10-03)
binary: rustc
commit-hash: cc66ad468955717ab92600c770da8c1601a4ff33
commit-date: 2023-10-03
host: aarch64-apple-darwin
release: 1.73.0
LLVM version: 17.0.2

Additional Labels

No response

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions