Avoid emitting `assigning_clones` when cloned data borrows from the place to clone into
Fixes #12444 Fixes #12460 Fixes #12749 Fixes #12757
I think the documentation for the function should describe what- and how this is fixing the issues well.
It avoids emitting a warning when the data being cloned borrows from the place to clone into, which is information that we can get from PossibleBorrowerMap. Unfortunately, it is a tiny bit tedious to match on the MIR like that and I'm not sure if this is possibly relying a bit too much on the exact MIR lowering for assignments.
Things left to do:
- [x] Handle place projections (or verify that they work as expected)
- [x] Handle non-
Droptypes
changelog: [assigning_clones]: avoid warning when the suggestion would lead to a borrow-check error
r? @Alexendoo
rustbot has assigned @Alexendoo. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.
Use r? to explicitly pick a reviewer
:umbrella: The latest upstream changes (presumably #12783) made this pull request unmergeable. Please resolve the merge conflicts.
It would be great to merge this. Even if it's not perfect, it's much better than what has shipped in stable and causing numerous annoyances.
@bors r+
It seems reasonable to me, it is relying on the MIR layout a bit but it seems like it would be fairly straightforward to adapt if that ever changes
:pushpin: Commit 60508f546a07fa51169736766b7e16676724c496 has been approved by Alexendoo
It is now in the queue for this repository.
:hourglass: Testing commit 60508f546a07fa51169736766b7e16676724c496 with merge 0dc265ff82fe861f673f20003e4370df52f50ff3...
:sunny: Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test Approved by: Alexendoo Pushing 0dc265ff82fe861f673f20003e4370df52f50ff3 to master...