-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Can't use swap
or replace
as suggested by manual_swap
#981
Labels
C-bug
Category: Clippy is not doing the correct thing
I-suggestion-causes-error
Issue: The suggestions provided by this Lint cause an ICE/error when applied
L-suggestion
Lint: Improving, adding or fixing lint suggestions
Comments
let std::mem::swap(&mut foo[0], &mut foo[1]);
^^^
|
I have the related issue where clippy wants me to use mem::swap instead of my manual swap. It's a field through a slice, so it's the same kind of problem: let id = tris[a].id;
tris[a].id = tris[b].id;
tris[b].id = id; |
flip1995
added
the
I-suggestion-causes-error
Issue: The suggestions provided by this Lint cause an ICE/error when applied
label
Aug 15, 2019
phansch
added
the
L-suggestion
Lint: Improving, adding or fixing lint suggestions
label
Aug 24, 2019
bors
added a commit
that referenced
this issue
Sep 11, 2019
Fix incorrect swap suggestion Clippy suggests using swap on fields belonging to the same owner causing two mutable borrows of the owner. Disclosure: This is my first time working with clippy and rusts HIR. I'm very grateful for assistance and suggestions to improve the PR. fixes #981 changelog: none
bors
added a commit
that referenced
this issue
Sep 11, 2019
Fix incorrect swap suggestion Clippy suggests using swap on fields belonging to the same owner causing two mutable borrows of the owner. Disclosure: This is my first time working with clippy and rusts HIR. I'm very grateful for assistance and suggestions to improve the PR. fixes #981 changelog: Fix false positive in `manual_swap` lint
bors
added a commit
that referenced
this issue
Sep 11, 2019
Fix incorrect swap suggestion Clippy suggests using swap on fields belonging to the same owner causing two mutable borrows of the owner. Disclosure: This is my first time working with clippy and rusts HIR. I'm very grateful for assistance and suggestions to improve the PR. fixes #981 changelog: Fix false positive in `manual_swap` lint
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C-bug
Category: Clippy is not doing the correct thing
I-suggestion-causes-error
Issue: The suggestions provided by this Lint cause an ICE/error when applied
L-suggestion
Lint: Improving, adding or fixing lint suggestions
On the following:
Clippy suggests
std::mem::swap(&mut foo[0], &mut foo[1]);
, but this would mutably borrowfoo
twice. The correct suggestion for slices would befoo.swap(0, 1)
. For other types, we should check that the suggestion would not mutably borrow something twice somehow.The text was updated successfully, but these errors were encountered: