Open
Description
Summary
needless_pass_by_value
is a lint whose validity very much depends on circumstances it can't fully know. (For example, a value consumed in the parameter list might be an allocation handle being passed to a free()
function, which therefore semantically must be moved into the function.) Therefore, it should be possible to suppress it separately for each function parameter — but it is not.
Lint Name
needless_pass_by_value
Reproducer
I tried this code:
#![warn(clippy::needless_pass_by_value)]
fn foo(#[allow(clippy::needless_pass_by_value)] s: String) {
println!("{s}");
}
I saw this happen:
warning: this argument is passed by value, but not consumed in the function body
--> src/lib.rs:3:52
|
3 | fn foo(#[allow(clippy::needless_pass_by_value)] s: String) {
| ^^^^^^ help: consider changing the type to: `&str`
I expected to see this happen: No lint message
Version
rustc 1.77.0 (aedd173a2 2024-03-17)
binary: rustc
commit-hash: aedd173a2c086e558c2b66d3743b344f977621a7
commit-date: 2024-03-17
host: x86_64-apple-darwin
release: 1.77.0
LLVM version: 17.0.6