Skip to content

literal_string_with_formatting_args false positive on test #13885

Closed
@tamird

Description

@tamird

Summary

See reproducer below. I can't reproduce this in playground because it doesn't run clippy with --all-targets.

Lint Name

literal_string_with_formatting_args

Reproducer

I tried this code:

pub fn parse(_: &str) -> Result<Vec<String>, String> {
    unimplemented!()
}

#[test]
fn test_parse() {
    assert!(parse(
        #[allow(clippy::literal_string_with_formatting_args)]
        "foo {:}"
    )
    .is_err());
}

I saw this happen:

$ cargo +nightly clippy --all-targets
warning: this looks like a formatting argument but it is not part of a formatting macro
 --> src/lib.rs:5:6
  |
5 |     #[test]
  |      ^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#literal_string_with_formatting_args
  = note: `#[warn(clippy::literal_string_with_formatting_args)]` on by default

I expected to see this happen:
No warnings.

Version

rustc 1.85.0-nightly (917bfa784 2024-12-26)
binary: rustc
commit-hash: 917bfa78478cbcc77406e5ea37b24c3eedefacf4
commit-date: 2024-12-26
host: aarch64-apple-darwin
release: 1.85.0-nightly
LLVM version: 19.1.6

Additional Labels

No response

Metadata

Metadata

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