-
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
while_let_loop
fails to account for lifetimes
#362
Comments
This might be related to the extension done for #262. That was easier to justify for a match like |
looking into it, thanks for reporting :) /cc @Manishearth |
@flip1995 with the introduction of NLL, this issue is issue no more. Goes to show you that if you wait long enough all problems solve themselves :) |
The suggestion still misses the |
It does hide it behind an ellipsis now, do you think can we make it machine applicable? |
I am just afraid that for the big loops the suggestion will be long and ugly and as a consequence, a bit confusing |
The current suggestion is
I thought it could be:
Or something like that. |
I have a
loop
with amatch
which is suggested to convert towhile let
. But it's important in this case that the borrows from thematch
don't extend through the whole loop.Here's my function:
(Nevermind whether this is particularly good code -- I'm reconsidering that. But the lint is flawed regardless.)
Clippy's
while_let_loop
suggests replacing the loop with:First of all, it missed the
lt
binding. I can addlet lt = x < y;
or usex < y
directly for that. But now thex
/y
borrows onix
/iy
live for the entire loop body, so they can't be taken mutably fornext()
.Maybe non-lexical lifetimes could someday let this work, but for now it's a bad suggestion.
PS-
while_let_loop
is missing from the wiki.The text was updated successfully, but these errors were encountered: