Skip to content

poor suggestion on needless_pass_by_value on Option #13744

Closed
@oriongonza

Description

@oriongonza

Summary

It suggest &Option<T> instead of Option<&T> or Option<&T::Deref>

Reproducer

I tried this code:

#[allow(unused)]
#[deny(clippy::needless_pass_by_value)]
fn no_consume(x: Option<String>) {}

I expected to see this happen:

help: consider taking a reference instead: `Option<&String>` (or even better, `Option<&str>`)

Instead, this happened:

help: consider taking a reference instead: `&Option<String>`
```1

### Version

```text
rustc 1.84.0-nightly (3fee0f12e 2024-11-20)
binary: rustc
commit-hash: 3fee0f12e4f595948f8f54f57c8b7a7a58127124
commit-date: 2024-11-20
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.3

Additional Labels

No response

Metadata

Metadata

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