-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
redundant-clone: doesn't see redundant clone when involving aliasing #17637
Copy link
Copy link
Open
Labels
C-an-interesting-projectCategory: Interesting projects, that usually are more involved design/code wise.Category: Interesting projects, that usually are more involved design/code wise.C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-hardCall for participation: This a hard problem and requires more experience or effort to work onCall for participation: This a hard problem and requires more experience or effort to work onI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn'tL-nurseryLint: Currently in the nursery groupLint: Currently in the nursery group
Description
Activity
Metadata
Metadata
Assignees
Labels
C-an-interesting-projectCategory: Interesting projects, that usually are more involved design/code wise.Category: Interesting projects, that usually are more involved design/code wise.C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-hardCall for participation: This a hard problem and requires more experience or effort to work onCall for participation: This a hard problem and requires more experience or effort to work onI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn'tL-nurseryLint: Currently in the nursery groupLint: Currently in the nursery group
Summary
Our
redundant-cloneimplementation currently does not track aliasing and therefore is blind to any cloning that is redundant.@rustbot label +L-nursery +C-an-interesting-project +E-hard
(there are a bunch of issues regarding regarding this, but still I don't think anyone has identified the aliasing path)
Lint Name
redundant-clone
Reproducer
There are a bunch of more or less hidden cases that were discussed in either of these PRS:
visit_local_usageanalyse loop bodies instead of giving up on them #17495redundant_cloneto an analysis pass take 2 #14599The loop-cases which I AM missing (=not linting) are all closely related to aliasing
The interesting/hard part is that the aliasing rewrites can get a bit more tricky.
For example
causes
but if we rewrite it like this (Since we know what ``drop
does), it is fine.. As soon as you useblack_box` instead that's no longer true.Version