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

Explicitly opt out of Sync for cell and mpsc types #31982

Merged
merged 1 commit into from
Mar 2, 2016
Merged

Explicitly opt out of Sync for cell and mpsc types #31982

merged 1 commit into from
Mar 2, 2016

Conversation

apasel422
Copy link
Contributor

These types were already !Sync, but this improves error messages when they are used in contexts that require Sync, aligning them with conventions used with Rc, among others.

r? @alexcrichton

@alexcrichton
Copy link
Member

Thanks @apasel422! I wonder if it might also be a good idea to add compile-fail tests for these error messages as well? That way we can at least try to ensure the message remains high-quality over time.

@@ -307,6 +310,9 @@ pub struct Iter<'a, T: 'a> {
rx: &'a Receiver<T>
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> !Sync for Iter<'a, T> { }
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this and the IntoIter can be left off? They seem less "fundamentally not-Sync" than the other types.

These types were already `!Sync`, but this improves error messages when
they are used in contexts that require `Sync`, aligning them with
conventions used with `Rc`, among others.
@apasel422
Copy link
Contributor Author

@alexcrichton Updated.

@alexcrichton
Copy link
Member

@bors: r+ f522d88

Thanks!

@reem
Copy link
Contributor

reem commented Mar 2, 2016

This is a great change! The previous error message was pretty bad and a common source of new user confusion.

Manishearth added a commit to Manishearth/rust that referenced this pull request Mar 2, 2016
These types were already `!Sync`, but this improves error messages when they are used in contexts that require `Sync`, aligning them with conventions used with `Rc`, among others.

r? @alexcrichton
bors added a commit that referenced this pull request Mar 2, 2016
@bors bors merged commit f522d88 into rust-lang:master Mar 2, 2016
@apasel422 apasel422 deleted the sync branch March 2, 2016 04:56
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.

4 participants