Skip to content

Conversation

@granddaifuku
Copy link
Contributor

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

@rustbot
Copy link
Collaborator

rustbot commented Dec 25, 2023

r? @Alexendoo

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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 25, 2023
@granddaifuku granddaifuku force-pushed the fix/manual-memcpy-indexing-for-multi-dimension-arrays branch from 0337145 to 7de5fbe Compare December 25, 2023 11:11
@granddaifuku granddaifuku changed the title fix: manual_memcpy wrong indexing for multi diemnsion arrays fix: manual_memcpy wrong indexing for multi dimensional arrays Dec 27, 2023
@bors
Copy link
Contributor

bors commented Feb 17, 2024

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

@granddaifuku granddaifuku force-pushed the fix/manual-memcpy-indexing-for-multi-dimension-arrays branch from 7de5fbe to be3c03a Compare February 17, 2024 16:51
@granddaifuku
Copy link
Contributor Author

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!

@bors
Copy link
Contributor

bors commented Feb 19, 2024

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

@granddaifuku granddaifuku force-pushed the fix/manual-memcpy-indexing-for-multi-dimension-arrays branch from be3c03a to 4c6fe61 Compare February 19, 2024 16:47
@granddaifuku granddaifuku force-pushed the fix/manual-memcpy-indexing-for-multi-dimension-arrays branch from bc5b8a3 to 71e9451 Compare February 27, 2024 13:59
chore: rebase master

chore: replace $DIR

fix: check bases does not contain reference to loop index

fix: grammatical mistake

fix: style
@granddaifuku granddaifuku force-pushed the fix/manual-memcpy-indexing-for-multi-dimension-arrays branch from 0776bc5 to dfedadc Compare February 27, 2024 18:49
@Alexendoo
Copy link
Member

Thank you!

@bors r+

@bors
Copy link
Contributor

bors commented Mar 1, 2024

📌 Commit dfedadc has been approved by Alexendoo

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Mar 1, 2024

⌛ Testing commit dfedadc with merge e865dca...

@bors
Copy link
Contributor

bors commented Mar 1, 2024

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Alexendoo
Pushing e865dca to master...

@bors bors merged commit e865dca into rust-lang:master Mar 1, 2024
@bors bors mentioned this pull request Mar 1, 2024
@granddaifuku granddaifuku deleted the fix/manual-memcpy-indexing-for-multi-dimension-arrays branch March 16, 2024 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

manual_memcpy false positive

4 participants