fix const_item_mutation lint to use needs_drop instead of has_dtor - #160097
fix const_item_mutation lint to use needs_drop instead of has_dtor#160097Rachit2323 wants to merge 3 commits into
Conversation
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
r? @jackh726 rustbot has assigned @jackh726. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
Nice fix! While testing this branch, I noticed one behaviour change. on the base commit this lint warns for traits associated consts whose type mentions |
|
Thanks for catching this! It was unintended. Fixed it — for types containing type parameters like Self, needs_drop is too conservative so I now skip the suppression and let the lint fire as before. |
This comment has been minimized.
This comment has been minimized.
b47f970 to
4326ae2
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
If you can squash, r=me. |
Description:
The const_item_mutation lint was only checking if the outer type has a direct Drop impl (has_dtor). But if a field inside the type has a Drop impl, that drop logic can also observe the mutation — so the warning should be suppressed in that case too.
This fixes a false positive where the lint would warn on code like:
O.inner.val = 42;even when Inner has a Drop impl that prints the value — meaning the mutation IS observable and the warning is wrong.
Fix: replace has_dtor check with needs_drop, which checks the whole type including all fields inside it.