Commit graph

32 commits

Author SHA1 Message Date
Cameron Steffen
8c0e4d5ccf Rewrite shadow lint 2021-09-30 14:07:58 -05:00
bors
c4fc076e11 Auto merge of #6269 - camsteffen:map-clone-deref, r=ebroto
Fix map_clone with deref and clone

changelog: Fix map_clone false positive with deref coercion

Fixes #6239
2020-11-11 00:48:33 +00:00
Cameron Steffen
769094410a Fix map_clone with deref and clone 2020-11-10 18:37:17 -06:00
Samuel E. Moelius III
06e81bb493 Update references 2020-11-08 18:32:12 -05:00
Aleksei Latyshev
5f57608604
do not trigger map_clone in the case of &mut 2020-11-06 14:38:46 +03:00
Eduardo Broto
806d973adc map_clone: avoid suggesting copied() for &mut 2020-04-25 22:52:19 +02:00
Michael Wright
b15b977d76 Fix map_clone false positive
Don't lint when the item type is not a reference. `copied` only applies
to references.
2019-12-22 11:26:51 +02:00
Shotaro Yamada
555f5a49a2 Test fixes 2019-10-03 08:10:29 +09:00
flip1995
08d2a0d6b2
Also rename the lint in test files 2019-05-16 20:18:07 +02:00
Michael Wright
4fcaab3d62 Split redundant_closure lint
Move the method checking into a new lint called
`redundant_closures_for_method_calls` and put it in the pedantic group.

This aspect of the lint seems more controversial than the rest.

cc #3942
2019-05-16 08:25:39 +02:00
Manish Goregaokar
e9cde416ba Only suggest .copied() for Option right now 2019-04-15 15:44:09 -07:00
Manish Goregaokar
ad2c65bd1b Also suggest .copied() when .clone() is called on a Copy type 2019-04-15 14:39:41 -07:00
Manish Goregaokar
d2f7ae70ae Suggest .copied() instead of .cloned() in map_clone when dealing with references 2019-04-15 14:32:39 -07:00
Grzegorz
16881390e1 removing redundant closures in the whole project 2019-02-10 13:35:44 +01:00
Michael Wright
89de4c9766 Really fix issue number in map_clone test 2019-01-15 08:36:56 +02:00
Michael Wright
67a9f20c91 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
2019-01-15 08:09:47 +02:00
Wilco Kusee
9ff821a7e8 Add run-rustfix to map_clone test 2019-01-13 13:10:25 +01:00
Philipp Hansch
38d4ac7cea
Remove all copyright license headers
Discussion previously happened in https://github.com/rust-lang/rust/pull/43498
2019-01-08 21:46:39 +01:00
Matthias Krüger
435299be30 rustfmt tests 2018-12-09 23:26:16 +01:00
Oliver Scherer
b8654eaa6c Stabilize tool lints 2018-10-11 12:16:22 +02:00
Ryan Cumming
9bd4e5469e Don't suggest cloned() for map Box deref
Boxes are a bit magic in that they need to use `*` to get an owned value
out of the box. They implement `Deref` but that only returns a
reference. This means an easy way to convert an `Option<Box<T>>` to an
`<Option<T>` is:

```
box_option.map(|b| *b)
```

However, since b36bb0a6 the `map_clone` lint is detecting this as an
attempt to copy the box. Fix by excluding boxes completely from the
deref part of this lint.

Fixes #3274
2018-10-08 06:20:32 +11:00
Manish Goregaokar
e9c025ea70 Add license header to Rust files 2018-10-06 09:43:08 -07:00
Oliver Schneider
b36bb0a68d Reimplement the map_clone lint from scratch 2018-10-02 15:13:43 +02:00
Manish Goregaokar
057243f16b relicensing: Remove map_clone
This removes the code added in https://github.com/rust-lang-nursery/rust-clippy/pull/427
2018-10-02 12:51:38 +02:00
flip1995
1b6f6051a8 Adapt ui-tests to the tool_lints 2018-08-29 11:08:29 -07:00
Oliver Schneider
50ffaca4c9
Reduce the hackiness of cargo-clippy 2017-10-03 12:07:24 +02:00
Oliver Schneider
74c776585c Move all our tests back to ui tests 2017-08-01 17:54:21 +02:00
Oliver Schneider
4465bc3e3f Make most tests an example so we can run them one by one 2017-05-17 14:19:44 +02:00
Oliver Schneider
fb6895836f Address PR comments 2017-05-11 15:36:27 +02:00
Oliver Schneider
2cd3366817 Fixes #443 2017-05-10 13:42:19 +02:00
Oliver Schneider
1f2c97a291 remove all //~ from tests 2017-02-08 14:58:07 +01:00
Oliver Schneider
fd1351f6e3 rustup and compile-fail -> ui test move 2017-02-07 21:05:30 +01:00
Renamed from tests/compile-fail/map_clone.rs (Browse further)