Skip to content

fix Send / Sync (typos) #239

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

Closed
wants to merge 2 commits into from

Conversation

sparecycles
Copy link

I think I found a couple copy-paste errors.

@@ -2024,7 +2024,7 @@ mod tests {

#[test]
fn test_bounds() {
fn check_bounds<T: Sync + Send>() {}
fn check_bounds<T: Send + Sync>() {}
Copy link
Author

Choose a reason for hiding this comment

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

every other usage is in Send + Sync order.

@carllerche
Copy link
Collaborator

How does HashMap in std implement Send and Sync bounds?

@carllerche
Copy link
Collaborator

I actually don’t think that Iter can be Send because it holds a reference to the map. If I recall those bounds were intentional.

@sparecycles
Copy link
Author

Hi @carllerche. I'm not sure if Iter should be Send or not.

But if that's the case, wouldn't Drain, IterMut, and ValueIterMut have the same bounds?

http/src/header/map.rs

Lines 2002 to 2003 in 8d45bd5

unsafe impl<'a, T: Sync> Sync for IterMut<'a, T> {}
unsafe impl<'a, T: Send> Send for IterMut<'a, T> {}

http/src/header/map.rs

Lines 2102 to 2103 in 8d45bd5

unsafe impl<'a, T: Sync> Sync for Drain<'a, T> {}
unsafe impl<'a, T: Send> Send for Drain<'a, T> {}

http/src/header/map.rs

Lines 2531 to 2532 in 8d45bd5

unsafe impl<'a, T: Sync> Sync for ValueIterMut<'a, T> {}
unsafe impl<'a, T: Send> Send for ValueIterMut<'a, T> {}


...

http/src/header/map.rs

Lines 1941 to 1942 in 8d45bd5

unsafe impl<'a, T: Sync> Sync for Iter<'a, T> {}
unsafe impl<'a, T: Sync> Send for Iter<'a, T> {}

@sparecycles
Copy link
Author

@carllerche You're right, the pattern of sync-implies-ref-is-send is deep in the rust type system.

@carllerche
Copy link
Collaborator

Would you mind adding a comment including your findings for the next person?

@sparecycles
Copy link
Author

sparecycles commented Aug 23, 2018

Well, I think I understand why Iter<T: Sync> is Sync + Send, but I don't understand why Iter<T: Send> is not Send, nor why IterMut/Drain etc... don't follow the same pattern.

If a good explanation appears in rust#53625, I'll can reopen this with a nice comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants