rust-lang / rust-lang/rust-clippy
needless_pass_by_value for `Option<&_>` types?
Open
Nobody has claimed this yet.
I-false-positive
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
I was surprised to get a needless_pass_by_value warning here:
warning: this argument is passed by value, but not consumed in the function body
--> src/state/init.rs:189:42
|
189 | _merge_world_entity_restore_map: Option<&mut HashMap<Entity, Entity>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&Option<&mut HashMap<Entity, Entity>>`
|
note: the lint level is defined here
--> src/lib.rs:47:9
|
47 | #![warn(clippy::pedantic)]
| ^^^^^^^^^^^^^^^^
= note: `#[warn(clippy::needless_pass_by_value)]` implied by `#[warn(clippy::pedantic)]`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value
Wouldn't it make sense for Option<&_> to be allowed everywhere by this lint?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the needless_pass_by_value lint and the example at src/state/init.rs:189, then review the lint-level configuration in src/lib.rs:47. Determine whether Option<&mut HashMap<Entity, Entity>> should be exempt from this warning, and verify the decision against the reported diagnostic behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100