Summary
Sorry, this is weird and I don't know the reason for it.
cargo clippy and cargo +beta clippy produce different warnings than cargo +nightly clippy on this code:
#![allow(clippy::all)]
#![warn(clippy::uninlined_format_args)]
fn main() {
let path = "x";
let _ = format!("Failed to open `{}`", path);
let _ = || format!("Failed to open `{}`", path);
}
The difference does't seem to be a commit: if you checkout tag rust-1.72.0 and run it on the above code, you see the nightly behavior.
The only things I've found that make a difference are: being stable/beta or being a uitest.
Re the latter, if you create a uitest and put both of the expected warnings in the stderr file, the test passes.
I've performed the above experiment on two different OSes (Linux and Mac)---same results.
I've also tried debug vs. release. Again, no difference.
I am really at a loss.
What about being stable/beta or being a uitest could make a difference?
Lint Name
uninlined_format_args
Reproducer
I tried this code with cargo +nightly clippy:
#![allow(clippy::all)]
#![warn(clippy::uninlined_format_args)]
fn main() {
let path = "x";
let _ = format!("Failed to open `{}`", path);
let _ = || format!("Failed to open `{}`", path);
}
I expected to see this happen (the same warnings produced by cargo clippy):
warning: variables can be used directly in the `format!` string
--> src/main.rs:7:13
|
7 | let _ = format!("Failed to open `{}`", path);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
note: the lint level is defined here
--> src/main.rs:2:9
|
2 | #![warn(clippy::uninlined_format_args)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: change this to
|
7 - let _ = format!("Failed to open `{}`", path);
7 + let _ = format!("Failed to open `{path}`");
|
warning: variables can be used directly in the `format!` string
--> src/main.rs:9:16
|
9 | let _ = || format!("Failed to open `{}`", path);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
help: change this to
|
9 - let _ = || format!("Failed to open `{}`", path);
9 + let _ = || format!("Failed to open `{path}`");
|
warning: `a` (bin "a") generated 2 warnings (run `cargo clippy --fix --bin "a"` to apply 2 suggestions)
Finished dev [unoptimized + debuginfo] target(s) in 0.08s
Instead, this happened (no warning for the format inside the closure)):
warning: variables can be used directly in the `format!` string
--> src/main.rs:7:13
|
7 | let _ = format!("Failed to open `{}`", path);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
note: the lint level is defined here
--> src/main.rs:2:9
|
2 | #![warn(clippy::uninlined_format_args)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: change this to
|
7 - let _ = format!("Failed to open `{}`", path);
7 + let _ = format!("Failed to open `{path}`");
|
warning: `a` (bin "a") generated 1 warning (run `cargo clippy --fix --bin "a"` to apply 1 suggestion)
Finished dev [unoptimized + debuginfo] target(s) in 0.09s
Version
rustc 1.74.0-nightly (e3abbd499 2023-09-06)
binary: rustc
commit-hash: e3abbd4994f72888f9e5e44dc89a4102e48c2a54
commit-date: 2023-09-06
host: x86_64-apple-darwin
release: 1.74.0-nightly
LLVM version: 17.0.0
Summary
Sorry, this is weird and I don't know the reason for it.
cargo clippyandcargo +beta clippyproduce different warnings thancargo +nightly clippyon this code:The difference does't seem to be a commit: if you checkout tag
rust-1.72.0and run it on the above code, you see the nightly behavior.The only things I've found that make a difference are: being stable/beta or being a uitest.
Re the latter, if you create a uitest and put both of the expected warnings in the stderr file, the test passes.
I've performed the above experiment on two different OSes (Linux and Mac)---same results.
I've also tried debug vs. release. Again, no difference.
I am really at a loss.
What about being stable/beta or being a uitest could make a difference?
Lint Name
uninlined_format_args
Reproducer
I tried this code with
cargo +nightly clippy:I expected to see this happen (the same warnings produced by
cargo clippy):Instead, this happened (no warning for the
formatinside the closure)):Version