New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid emitting assigning_clones
when cloned data borrows from the place to clone into
#12756
base: master
Are you sure you want to change the base?
Conversation
r? @Alexendoo rustbot has assigned @Alexendoo. Use |
a413cd1
to
0a93106
Compare
let mut s = (NoDrop, NoDrop); | ||
let s2 = &s.1; | ||
s.0 = s2.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a false negative now but fixing it seems like it'd require large changes to PossibleBorrowerMap
to teach it disjoint borrows, but I suppose this FN might be better than a FP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a sense, a performance lint is about reducing time wasted by the computer, but as human time is more expensive, it's surely more costly to waste human time if no computing performance is likely to be gained in the process.
☔ The latest upstream changes (presumably #12783) made this pull request unmergeable. Please resolve the merge conflicts. |
0a93106
to
60508f5
Compare
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:
Drop
typeschangelog: [
assigning_clones
]: avoid warning when the suggestion would lead to a borrow-check error