-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
map_clone can lead to compile error, suggest removing the map instead #498
Labels
C-bug
Category: Clippy is not doing the correct thing
Comments
Ah, |
mcarton
referenced
this issue
in mcarton/rust-clippy
Jan 18, 2016
oli-obk
added a commit
that referenced
this issue
Jan 18, 2018
Document map_clone known problems #498
Seems like this was added to the known problems in #2370, then removed again at some point without fixing it. Can still reproduce the problem. I'm trying to fix it, but I'm not really sure how to check the trait item type ( |
bors
added a commit
that referenced
this issue
Dec 22, 2018
Document map_clone known problems #498 (cherry picked from commit ada0d2c) This was lost in relicensing (057243f). However, I [acknowledged](#3099 (comment)) relicensing so this cherry pick should be fine I guess.
ghost
mentioned this issue
Jan 15, 2019
bors
added a commit
that referenced
this issue
Jan 15, 2019
Fix `map_clone` bad suggestion `cloned` requires that the elements of the iterator must be references. This change determines if that is the case by examining the type of the closure argument and suggesting `.cloned` only if it is a reference. When the closure argument is not a reference, it suggests removing the `map` call instead. A minor problem with this change is that the new check sometimes overlaps with the `clone_on_copy` lint. Fixes #498
flip1995
pushed a commit
to flip1995/rust-clippy
that referenced
this issue
May 5, 2020
Fixes clippy tool state Changes: ```` FIXME > TODO rustup rust-lang/rust#56992 Document map_clone known problems rust-lang#498 Remove header link test: panic at map_unit_fn.rs:202 for map() without args rm unused file map_unit_fn.stderr panic at map_unit_fn.rs:202 for map() without args Change contrib.md hierarchy, link to it from readme Workaround rust-lang/rust#43081 Teach `suspicious_else_formatting` about `if .. {..} {..}` Link to `rustc_driver` crate in plugin mutex_atomic: Correct location of AtomicBool and friends Update README local run command to specify syspath Do not mark as_ref as useless if it's followed by a method call Changes lint sugg to bitwise and operator `&` Run update_lints after renaming Rename lint to MODULE_NAME_REPETITIONS Add renaming tests Move renaming to the right place Implements lint for order comparisons against bool fix(module_name_repeat): Try to register renamed lint, not valid yet Fix an endless loop in the tests. Fix `implicit_return` false positives. chore(moduel_name_repeat): Rename stutter lint to module_name_repeat to avoid ableist language Make integration tests fail on 'E0463' base tests: make sure cargo-clippy binary can be called directly Revert "Merge pull request rust-lang#3257 from o01eg/remove-sysroot" ````
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following code
std::env::args().map(|v| v.clone())
will trigger
map_clone
, suggestingstd::env::args().cloned()
But that dosen't compile, the correct suggestion would be to remove the
map(|v| v.clone())
or the.cloned()
call entirely, since the iterator already passes things by value.The text was updated successfully, but these errors were encountered: