Skip to content
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

Made vec_deque::Drain, hash_map::Drain, and hash_set::Drain covariant #35354

Merged
merged 1 commit into from
Aug 16, 2016

Conversation

tomgarcia
Copy link
Contributor

#30642

Fixed the rest of the Drain iterators.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@brson
Copy link
Contributor

brson commented Aug 9, 2016

I don't understand the issues here enough to review. There's a bunch of new unsafe code though, which is suspicious...

cc @rust-lang/libs

@brson brson added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Aug 9, 2016
@brson
Copy link
Contributor

brson commented Aug 9, 2016

r? @sfackler maybe?

@rust-highfive rust-highfive assigned sfackler and unassigned brson Aug 9, 2016
@alexcrichton
Copy link
Member

cc @apasel422

@@ -897,8 +898,9 @@ unsafe impl<K: Send, V: Send> Send for IntoIter<K, V> {}

/// Iterator over the entries in a table, clearing the table.
pub struct Drain<'a, K: 'a, V: 'a> {
table: &'a mut RawTable<K, V>,
table: Shared<RawTable<K, V>>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems curious because today it's implemented in seeming "safe" code, but that didn't get us the right variance by default?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&mut T is invariant in T. But we're reading (K, V) out of the table, not writing to it, so covariance should be safe. This isn't conveyed by &mut RawTable<K, V> alone, because the compiler has to assume that such a reference could be written to.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah makes sense to me!

@alexcrichton
Copy link
Member

@bors: r+

Discussed during triage yesterday, decision was to merge!

@bors
Copy link
Contributor

bors commented Aug 16, 2016

📌 Commit bf592ce has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Aug 16, 2016

⌛ Testing commit bf592ce with merge 514d4ce...

bors added a commit that referenced this pull request Aug 16, 2016
Made vec_deque::Drain, hash_map::Drain, and hash_set::Drain covariant

Fixed the rest of the Drain iterators.
@bors bors merged commit bf592ce into rust-lang:master Aug 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants