rust-clippy icon indicating copy to clipboard operation
rust-clippy copied to clipboard

fix: `manual_memcpy` wrong indexing for multi dimensional arrays

Open granddaifuku opened this issue 2 years ago • 4 comments

fixes: #9334

This PR fixes an invalid suggestion for multi-dimensional arrays.

For example,

let src = vec![vec![0; 5]; 5];
let mut dst = vec![0; 5];

for i in 0..5 {
    dst[i] = src[i][i];
}

For the above code, Clippy suggests dst.copy_from_slice(&src[i]);, but it is not compilable because i is only used to loop the array. I adjusted it so that Clippy manual_memcpy works properly for multi-dimensional arrays.

changelog: [manual_memcpy]: Fixes invalid indexing suggestions for multi-dimensional arrays

granddaifuku avatar Dec 25 '23 11:12 granddaifuku

r? @Alexendoo

(rustbot has picked a reviewer for you, use r? to override)

rustbot avatar Dec 25 '23 11:12 rustbot

:umbrella: The latest upstream changes (presumably #12198) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Feb 17 '24 00:02 bors

Hi @Alexendoo , this is just a friendly reminder about this PR. It would be appreciated if you could review it when you have time? Thak you!

granddaifuku avatar Feb 17 '24 17:02 granddaifuku

:umbrella: The latest upstream changes (presumably #12306) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Feb 19 '24 09:02 bors

Thank you!

@bors r+

Alexendoo avatar Mar 01 '24 12:03 Alexendoo

:pushpin: Commit dfedadc179dc3c388e0b0098a910658bc6e820ef has been approved by Alexendoo

It is now in the queue for this repository.

bors avatar Mar 01 '24 12:03 bors

:hourglass: Testing commit dfedadc179dc3c388e0b0098a910658bc6e820ef with merge e865dca4d76a204e002c223cba1dc804ee9b7c56...

bors avatar Mar 01 '24 12:03 bors

:sunny: Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test Approved by: Alexendoo Pushing e865dca4d76a204e002c223cba1dc804ee9b7c56 to master...

bors avatar Mar 01 '24 12:03 bors