mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-22 18:15:07 +03:00
aaa5bd244e
Detect format macros where an argument
is passed with an explicit `&` even though the formatter already takes
references, e.g. `println!("{}", &s)` when `s: &str`.
Some original micro-benchmarks showed ~6% performance improvement when redundant refs are removed.
- Lint runs for both Display (`{}`) and Debug (`{:?}`) placeholders when
the inner type is Sized and implements the corresponding trait.
- Applies to the main value argument and to width/precision arguments
(e.g. `format!("{0:1$.2$}", &v1, &v2, &v3)`).
- Suggests removing the redundant `&` with MachineApplicable fix.
- Skip when the argument comes from expansion or a proc macro.