Add negative impls for Sync

This commit is contained in:
Flavio Percoco
2015-01-26 23:10:24 +01:00
parent bd511f73be
commit 7ae8889286
3 changed files with 9 additions and 17 deletions

View File

@@ -144,7 +144,7 @@
use clone::Clone; use clone::Clone;
use cmp::PartialEq; use cmp::PartialEq;
use default::Default; use default::Default;
use marker::{Copy, Send}; use marker::{Copy, Send, Sync};
use ops::{Deref, DerefMut, Drop}; use ops::{Deref, DerefMut, Drop};
use option::Option; use option::Option;
use option::Option::{None, Some}; use option::Option::{None, Some};
@@ -660,6 +660,8 @@ pub struct UnsafeCell<T> {
pub value: T, pub value: T,
} }
impl<T> !Sync for UnsafeCell<T> {}
impl<T> UnsafeCell<T> { impl<T> UnsafeCell<T> {
/// Construct a new instance of `UnsafeCell` which will wrap the specified /// Construct a new instance of `UnsafeCell` which will wrap the specified
/// value. /// value.

View File

@@ -51,6 +51,7 @@ pub unsafe trait Send : MarkerTrait {
impl<T> !Send for *const T { } impl<T> !Send for *const T { }
impl<T> !Send for *mut T { } impl<T> !Send for *mut T { }
impl !Send for Managed { }
/// Types with a constant size known at compile-time. /// Types with a constant size known at compile-time.
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
@@ -219,6 +220,7 @@ pub unsafe trait Sync : MarkerTrait {
impl<T> !Sync for *const T { } impl<T> !Sync for *const T { }
impl<T> !Sync for *mut T { } impl<T> !Sync for *mut T { }
impl !Sync for Managed { }
/// A type which is considered "not POD", meaning that it is not /// A type which is considered "not POD", meaning that it is not
/// implicitly copyable. This is typically embedded in other types to /// implicitly copyable. This is typically embedded in other types to

View File

@@ -826,6 +826,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
} }
Some(bound @ ty::BoundSend) | Some(bound @ ty::BoundSend) |
Some(bound @ ty::BoundSync) => { Some(bound @ ty::BoundSync) => {
// Ideally, we shouldn't sepcial case Send/Sync. This will be unified
// as soon as default trait implementations for these traits land.
try!(self.assemble_candidates_from_impls(obligation, &mut candidates)); try!(self.assemble_candidates_from_impls(obligation, &mut candidates));
// No explicit impls were declared for this type, consider the fallback rules. // No explicit impls were declared for this type, consider the fallback rules.
@@ -1599,27 +1601,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
-> Result<BuiltinBoundConditions<'tcx>,SelectionError<'tcx>> -> Result<BuiltinBoundConditions<'tcx>,SelectionError<'tcx>>
{ {
// First check for markers and other nonsense. // First check for markers and other nonsense.
let tcx = this.tcx();
match bound { match bound {
ty::BoundSend => {
if Some(def_id) == tcx.lang_items.managed_bound() {
return Err(Unimplemented)
}
}
ty::BoundCopy => { ty::BoundCopy => {
return Ok(ParameterBuiltin) return Ok(ParameterBuiltin)
} }
ty::BoundSync => { ty::BoundSend |
if ty::BoundSync |
Some(def_id) == tcx.lang_items.managed_bound() ||
Some(def_id) == tcx.lang_items.unsafe_cell_type()
{
return Err(Unimplemented)
}
}
ty::BoundSized => { } ty::BoundSized => { }
} }