-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Audit iterator specializations for side effects #28810
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
Comments
I've checked Unless, of course, you care about drop order. I haven't tried to reason about that. |
The slice iterators ( |
|
I'd appreciate it if someone else double checked but I think that's all of them. |
This is relevant as well, because implementations of Drop may also (and usually do, in form of memory deallocation) contain side effects. Can we make a
|
I strongly disagree. Drop has side effects but programmers should never rely on drop order except stack drop order because drop order is often unspecified (e.g. within structs). Drop out of order
Audited
|
Ah right, this will be decided by rust-lang/rfcs#744 anyway. |
Awesome, thanks for the work here @Stebalien! |
Updated list of out-of-order drops (didn't notice |
triage: P-medium |
(Need to make sure this behavior is documented/explicitly promised.) |
Is this done? (Everything in the list above is ✅'d) |
I believe this is left open as to-be-documented. Also, I don't see any decision as to whether out of order drop is ok. |
re-tagging as docs |
So I believe that all of these are then documented in Iterator's methods, at least as far as I can tell. Can someone from libs double check me here and help provide any specifics as to what's not documented? |
Doing so is considered weaker writing. Thanks @Charlotteis! Fixes rust-lang#28810
Doing so is considered weaker writing. Thanks @Charlotteis! Fixes rust-lang#28810
Looks good to me, thanks @steveklabnik! |
After some discussion about #28125 the libs subteam decided that iterator adaptors should always preserve the same semantics in terms of the convenience methods and such. This was not audited for when all the initial specializations landed, so we should take a look and make sure that everything adheres to this policy.
Additionally, documentation should be added to the
Iterator
trait methods indicating what form of guarantees you are given (e.g. callinglast
is equivalent to exhausting the iterator).triage: I-nominated
The text was updated successfully, but these errors were encountered: