Skip to content

Add defaulted impls for Send and Sync #23211

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

Merged
merged 4 commits into from
Mar 24, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add default impls for Send/Sync
  • Loading branch information
flaper87 committed Mar 20, 2015
commit 9ae144f05526ce8963af265d3b33f6c565c85e43
4 changes: 4 additions & 0 deletions src/libcore/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ pub unsafe trait Send : MarkerTrait {
// empty.
}

impl Send for .. { }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this should be unsafe


impl<T> !Send for *const T { }
impl<T> !Send for *mut T { }
impl !Send for Managed { }
Expand Down Expand Up @@ -203,6 +205,8 @@ pub unsafe trait Sync : MarkerTrait {
// Empty
}

impl Sync for .. { }

impl<T> !Sync for *const T { }
impl<T> !Sync for *mut T { }
impl !Sync for Managed { }
Expand Down
5 changes: 1 addition & 4 deletions src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5980,10 +5980,7 @@ pub fn item_variances(tcx: &ctxt, item_id: ast::DefId) -> Rc<ItemVariances> {

pub fn trait_has_default_impl(tcx: &ctxt, trait_def_id: DefId) -> bool {
populate_implementations_for_trait_if_necessary(tcx, trait_def_id);
match tcx.lang_items.to_builtin_kind(trait_def_id) {
Some(BoundSend) | Some(BoundSync) => true,
_ => tcx.traits_with_default_impls.borrow().contains_key(&trait_def_id),
}
tcx.traits_with_default_impls.borrow().contains_key(&trait_def_id)
}

/// Records a trait-to-implementation mapping.
Expand Down