We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
std::ptr::swap(a, b)
std::mem::swap(&mut *a, &mut *b)
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
This lint would find instances of a user converting two pointers into mutable references and calling swap on them. It would error upon finding them.
swap
By the way, this mistake is an actual thing I once saw on production code: dimforge/nalgebra#919
clippy::correctness
What is the advantage of the recommended code over the original code
If a and b are equal or overlap, the original code is actually UB, while the latter isn't.
a
b
None that I can think of.
The text was updated successfully, but these errors were encountered:
swap_ptr_to_ref
f0bf200
Successfully merging a pull request may close this issue.
What it does
This lint would find instances of a user converting two pointers into mutable references and calling
swap
on them. It would error upon finding them.By the way, this mistake is an actual thing I once saw on production code: dimforge/nalgebra#919
Categories
clippy::correctness
.What is the advantage of the recommended code over the original code
If
a
andb
are equal or overlap, the original code is actually UB, while the latter isn't.Drawbacks
None that I can think of.
The text was updated successfully, but these errors were encountered: