bors
c9fdeef643
Auto merge of #6078 - ebroto:unnecessary_sort_by_take_2, r=phansch
...
unnecessary sort by: avoid dereferencing the suggested closure parameter
This change tries to simplify the solution for problematic cases but is less restrictive than #6006 .
* We can't dereference shared references to non-Copy types, so the new suggestion does not do that. Note that this implies that the suggested closure parameter will be a reference.
* We can't take a reference to the closure parameter in the returned key, so we don't lint in those cases. This can happen either because the key borrows from the parameter (e.g. `|a| a.borrows()`), or because we suggest `|a| Reverse(a)`. If we did we would hit this error:
```
error: lifetime may not live long enough
--> /home/ebroto/src/ebroto-clippy/tests/ui/unnecessary_sort_by.fixed:19:25
|
19 | vec.sort_by_key(|b| Reverse(b));
| -- ^^^^^^^^^^ returning this value requires that `'1` must outlive `'2`
| ||
| |return type of closure is Reverse<&'2 isize>
| has type `&'1 isize`
error: aborting due to previous error
```
Note that Clippy does not currently have the (MIR-based) machinery necessary to check that what is borrowed is actually the closure parameter.
changelog: [`unnecessary_sort_by`]: avoid dereferencing the suggested closure parameter
Fixes #6001
2020-10-06 06:59:33 +00:00
..
2020-09-28 19:17:22 +02:00
2020-09-29 23:06:08 +02:00
2020-08-28 18:43:25 +02:00
2020-09-30 23:30:49 +02:00
2020-09-30 09:43:46 +02:00
2020-09-10 17:47:07 +02:00
2020-09-10 17:47:07 +02:00
2020-09-10 17:47:07 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-10 17:47:07 +02:00
2020-09-10 17:47:07 +02:00
2020-09-10 17:47:07 +02:00
2020-09-10 17:47:07 +02:00
2020-09-10 17:47:07 +02:00
2020-09-10 17:47:07 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-10 17:47:07 +02:00
2020-09-10 17:47:07 +02:00
2020-09-10 17:47:07 +02:00
2020-10-02 11:34:14 -07:00
2020-10-02 11:34:14 -07:00
2020-09-10 17:47:07 +02:00
2020-09-10 17:47:07 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-09-23 08:15:44 +12:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-09-10 17:47:07 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-10-02 07:02:58 +02:00
2020-10-02 07:02:58 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-08-28 18:43:25 +02:00
2020-09-24 14:49:22 +02:00
2020-09-02 13:18:19 +02:00
2020-09-03 04:58:14 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-08-28 18:43:25 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-10-05 12:23:01 +02:00
2020-10-05 12:23:01 +02:00
2020-10-05 12:23:01 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-09-28 19:17:22 +02:00
2020-09-28 19:17:22 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-09-30 00:33:46 +02:00
2020-09-30 00:33:46 +02:00
2020-10-02 00:49:05 +09:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-10 17:47:07 +02:00
2020-09-23 00:39:00 +02:00
2020-09-23 00:39:00 +02:00
2020-09-23 00:34:56 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-09-26 23:10:25 +09:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-10 17:47:07 +02:00
2020-09-10 17:47:07 +02:00
2020-09-10 17:47:07 +02:00
2020-09-10 17:47:07 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-09-10 17:47:07 +02:00
2020-09-10 15:23:38 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-09-10 17:47:07 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-10-03 00:07:56 +02:00
2020-10-03 00:07:56 +02:00
2020-09-10 17:47:07 +02:00
2020-09-10 17:47:07 +02:00
2020-09-10 17:47:07 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-09-23 23:33:50 +02:00
2020-09-23 23:33:50 +02:00
2020-09-23 23:33:50 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-09-10 17:47:07 +02:00
2020-09-10 17:47:07 +02:00
2020-09-10 17:47:07 +02:00
2020-09-24 14:49:22 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-09-24 14:49:22 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-09-24 14:49:22 +02:00
2020-09-24 14:49:22 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00