Open
Description
I tried this code:
pub fn func(i: i32) -> String {
format!("{}", &i)
}
I expected &i
to be inlined and be equivalent to format!("{}", i)
Instead, in my benchmarking tests I see about 6% performance hit, and assembly has a non-inlined function.
Relevant links
- Assembly comparison
- Benchmarking code
- A Clippy lint: A new lint to remove unneeded arg referencing in a format! rust-clippy#10851
- Stackoverflow question
Meta
rustc --version --verbose
:
rustc 1.69.0 (84c898d65 2023-04-16)
binary: rustc
commit-hash: 84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc
commit-date: 2023-04-16
host: x86_64-unknown-linux-gnu
release: 1.69.0
LLVM version: 15.0.7