-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Borrow checking with loops, safe uninitailized variables, and conditional breaks. #19433
Comments
I suspect this is a dupe of #12147 and hence of #6393 transitively. cc @nikomatsakis |
Since I reported this, I have been allowed to open source the code: https://github.com/RustOS-Fork-Holding-Ground/rust-net/blob/master/transport/tcp/src/connection/packet_buf/vec_queue.rs#L191-L219 |
I might be wrong but I think my current problem (more minimal example) falls under the same class:
It should pass the borrow checker because the loop will be terminated after the assignment. Same issue occurs on early returns in the loop. I don’t think that it is a dupe of #10520 but indeed a dupe of #12147. |
Triage: it seems that this issue boils down to non-lexiacal lifetimes, so I'm going to give it a close in favor of that. Thanks all! |
Heh, I got about 1/3 through getting my net stack to compile this summer. I'll make a definitive report on this someday! |
I have some code that compiles like this:
I would like to change the method so it is instead
But the borrow checker rejects this. Not that if
if cond
is commented, it is accepted.I understand that the borrow checker is already doing a lot of magic regarding loops, conditional breaks, and uninitialized variables, but thought I'd report this in case I am hitting an unintended restriction.
head
,tail
,is_clockwise
, are invariant with respect to lifetimes. Everything else is I believe from the standard library or countravariant.The text was updated successfully, but these errors were encountered: