Skip to content

Clippy does not respect rules to allow uninlined_format_args #14694

Open
@rayokamoto

Description

@rayokamoto

Summary

In Rust 1.88 Nightly, there are issues with cargo clippy where allowing uninlined_format_args does not work:

  • Setting allow-mixed-uninlined-format-args = true in clippy.toml does nothing, in both projects with a single package and Cargo workspaces
  • Setting the linting rule in Cargo.toml (with uninlined_format_args = "allow"), does work for a single crate ([lints.clippy]), but not when it's defined in the workspace Cargo.toml file ([workspace.lints.clippy])

I found #12161 but applying the suggestions here does not have any effect.

Everything I mentioned above works fine in Rust 1.86 (stable). These issues might have been caused as part of #14160.

Reproducer

With single crate

Make sure you are using Rust 1.88 Nightly. Create a new package with cargo init. In the src/main.rs file, add some code that will trigger the uninlined_format_args warning:

fn main() {
    let name = "Bob";
    println!("Hello, {}!", name);
}

Create a clippy.toml file and add the following:

allow-mixed-uninlined-format-args = true

Now try to run cargo clippy. The expectation is to have the Clippy checks pass with no warnings. However, the actual result is this:

warning: variables can be used directly in the `format!` string
 --> src/main.rs:3:5
  |
3 |     println!("Hello, {}!", name);
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
  = note: `#[warn(clippy::uninlined_format_args)]` on by default
help: change this to
  |
3 -     println!("Hello, {}!", name);
3 +     println!("Hello, {name}!");
  |

warning: `rust-clippy` (bin "rust-clippy") generated 1 warning (run `cargo clippy --fix --bin "rust-clippy"` to apply 1 suggestion)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s

If you add the following to Cargo.toml, and then rerun cargo clippy, you will get the expected result.

[lints.clippy]
uninlined_format_args = "allow"

With workspaces

Create a Cargo workspace project (with Rust 1.88 Nightly). The root Cargo.toml should look something like this:

[workspace]
resolver = "2"
members = ["crates/*"]
default-members = ["crates/clippy-test"]

[workspace.package]
version = "0.1.0"
edition = "2024"

[workspace.dependencies]

[workspace.lints.clippy]
uninlined_format_args = "allow"

Then, create a new crate. The folder structure should be like so:

crates
└── clippy-test
    ├── Cargo.toml
    └── src
        └── main.rs

The crates/clippy-test/Cargo.toml file should look something like this:

[package]
name = "clippy-test"
version.workspace = true
edition.workspace = true

[[bin]]
name = "clippy-test"
path = "src/main.rs"

Then, main.rs can be the same as the single crate version:

fn main() {
    let name = "Bob";
    println!("Hello, {}!", name);
}

If you try to create a clippy.toml file with the same allow-mixed-uninlined-format-args = true setting, Clippy will not respect this and still emit the warnings.

Trying to set it in the workspace (root) Cargo.toml file does not work either. This is the config:

[workspace.lints.clippy]
uninlined_format_args = "allow"

However, if you put this in the clippy-test crate that we've created, the config option finally works and Clippy works as intended:

[lints.clippy]
uninlined_format_args = "allow"

Version

rustc 1.88.0-nightly (b4c8b0c3f 2025-04-25)
binary: rustc
commit-hash: b4c8b0c3f0533bb342a4873ff59bdad3883ab8e3
commit-date: 2025-04-25
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2

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