about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlavio Percoco <flaper87@gmail.com>2015-01-26 23:10:24 +0100
committerFlavio Percoco <flaper87@gmail.com>2015-02-22 02:14:24 +0100
commit7ae8889286535446f9a7c0d4c3e214b55d7063e6 (patch)
treed99b40d0061a6cfebac8b032a2382ad45a7ca05d
parentbd511f73be526640ae98012d302201a019f9b458 (diff)
downloadrust-7ae8889286535446f9a7c0d4c3e214b55d7063e6.tar.gz
rust-7ae8889286535446f9a7c0d4c3e214b55d7063e6.zip
Add negative impls for Sync
-rw-r--r--src/libcore/cell.rs4
-rw-r--r--src/libcore/marker.rs2
-rw-r--r--src/librustc/middle/traits/select.rs20
3 files changed, 9 insertions, 17 deletions
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs
index eb138e6142b..b8a22c30f9e 100644
--- a/src/libcore/cell.rs
+++ b/src/libcore/cell.rs
@@ -144,7 +144,7 @@
 use clone::Clone;
 use cmp::PartialEq;
 use default::Default;
-use marker::{Copy, Send};
+use marker::{Copy, Send, Sync};
 use ops::{Deref, DerefMut, Drop};
 use option::Option;
 use option::Option::{None, Some};
@@ -660,6 +660,8 @@ pub struct UnsafeCell<T> {
     pub value: T,
 }
 
+impl<T> !Sync for UnsafeCell<T> {}
+
 impl<T> UnsafeCell<T> {
     /// Construct a new instance of `UnsafeCell` which will wrap the specified
     /// value.
diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs
index eefb6ef7703..b5d533f104c 100644
--- a/src/libcore/marker.rs
+++ b/src/libcore/marker.rs
@@ -51,6 +51,7 @@ pub unsafe trait Send : MarkerTrait {
 
 impl<T> !Send for *const T { }
 impl<T> !Send for *mut T { }
+impl !Send for Managed { }
 
 /// Types with a constant size known at compile-time.
 #[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 *mut T { }
+impl !Sync for Managed { }
 
 /// A type which is considered "not POD", meaning that it is not
 /// implicitly copyable. This is typically embedded in other types to
diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs
index 53fdab1cd07..9fade728b36 100644
--- a/src/librustc/middle/traits/select.rs
+++ b/src/librustc/middle/traits/select.rs
@@ -826,6 +826,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
             }
             Some(bound @ ty::BoundSend) |
             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));
 
                 // 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>>
         {
             // First check for markers and other nonsense.
-            let tcx = this.tcx();
             match bound {
-                ty::BoundSend => {
-                    if Some(def_id) == tcx.lang_items.managed_bound() {
-                        return Err(Unimplemented)
-                    }
-                }
-
                 ty::BoundCopy => {
                     return Ok(ParameterBuiltin)
                 }
 
-                ty::BoundSync => {
-                    if
-                        Some(def_id) == tcx.lang_items.managed_bound() ||
-                        Some(def_id) == tcx.lang_items.unsafe_cell_type()
-                    {
-                        return Err(Unimplemented)
-                    }
-                }
-
+                ty::BoundSend |
+                ty::BoundSync |
                 ty::BoundSized => { }
             }