bors
dbc02854fc
Auto merge of #5727 - rail-rain:manual_memcpy_with_counter, r=flip1995
...
Expands `manual_memcpy` to lint ones with loop counters
Closes #1670
This PR expands `manual_memcpy` to lint ones with loop counters as described in https://github.com/rust-lang/rust-clippy/issues/1670#issuecomment-293280204
Although the current code is working, I have a couple of questions and concerns.
~~Firstly, I manually implemented `Clone` for `Sugg` because `AssocOp` lacks `Clone`. As `AssocOp` only holds an enum, which is `Copy`, as a value, it seems `AssocOp` can be `Clone`; but, I was not sure where to ask it. Should I make a PR to `rustc`?~~ The [PR]( https://github.com/rust-lang/rust/pull/73629 ) was made.
Secondly, manual copying with loop counters are likely to trigger `needless_range_loop` and `explicit_counter_loop` along with `manual_memcpy`; in fact, I explicitly allowed them in the tests. Is there any way to disable these two lints when a code triggers `manual_memcpy`?
And, another thing I'd like to note is that `Sugg` adds unnecessary parentheses when expressions with parentheses passed to its `hir` function, as seen here:
```
error: it looks like you're manually copying between slices
--> $DIR/manual_memcpy.rs:145:14
|
LL | for i in 3..(3 + src.len()) {
| ^^^^^^^^^^^^^^^^^^ help: try replacing the loop by: `dst[3..((3 + src.len()))].clone_from_slice(&src[..((3 + src.len()) - 3)])
```
However, using the `hir` function is needed to prevent the suggestion causing errors when users use bitwise operations; and also this have already existed, for example: `verbose_bit_mask`. Thus, I think this is fine.
changelog: Expands `manual_memcpy` to lint ones with loop counters
2020-10-10 06:32:32 +00:00
..
2020-09-28 19:17:22 +02:00
2020-10-09 22:21:47 +02:00
2020-10-02 23:21:24 +13: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-10-07 00:02:28 +02:00
2020-10-07 00:02:28 +02:00
2020-10-07 00:02:28 +02:00
2020-10-07 00:02:28 +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-10-08 18:50:52 -03:00
2020-09-23 08:15:44 +12:00
2020-09-24 14:49:22 +02:00
2020-10-09 21:37:50 +02:00
2020-10-09 21:37:50 +02:00
2020-08-28 18:43:25 +02:00
2020-08-28 18:43:25 +02:00
2020-10-09 20:23:03 +02:00
2020-10-09 20:23:03 +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-10-07 11:48:06 +02:00
2020-10-07 11:48:06 +02:00
2020-10-07 11:48:06 +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-10-08 01:07:00 +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