Skip to content

literal_string_with_formatting_args is trigger by Actix Web's wildcard route definitions #13928

Open
@Thomasdezeeuw

Description

@Thomasdezeeuw

Summary

Actix Web (https://crates.io/crates/actix-web) supports wildcard in their HTTP route definition macro. It looks something like #[post("/path/{variable:.*}")]. This triggers literal_string_with_formatting_args incorrectly.

As a work around we're adding #![allow(clippy::literal_string_with_formatting_args)] to all our files.

Lint Name

literal_string_with_formatting_args

Reproducer

I tried this code:

use actix_web::{post, HttpRequest, HttpResponse};

#[post("/path/{variable:.*}")]
pub async fn my_route(req: HttpRequest) -> HttpResponse {
    Ok(HttpResponse::Ok())
}

Creates (roughly) the following error:

error: this looks like a formatting argument but it is not part of a formatting macro
  --> path.rs:1
   |
1 | #[post("/path/{variable:.*}")]
   |              ^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#literal_string_with_formatting_args
   = note: `-D clippy::literal-string-with-formatting-args` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::literal_string_with_formatting_args)]`

Version

rustc 1.85.0-nightly (45d11e51b 2025-01-01)
binary: rustc
commit-hash: 45d11e51bb66c2deb63a006fe3953c4b6fbc50c2
commit-date: 2025-01-01
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.6

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    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