Skip to content

Commit 7ae8889

Browse files
committed
Add negative impls for Sync
1 parent bd511f7 commit 7ae8889

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

src/libcore/cell.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
use clone::Clone;
145145
use cmp::PartialEq;
146146
use default::Default;
147-
use marker::{Copy, Send};
147+
use marker::{Copy, Send, Sync};
148148
use ops::{Deref, DerefMut, Drop};
149149
use option::Option;
150150
use option::Option::{None, Some};
@@ -660,6 +660,8 @@ pub struct UnsafeCell<T> {
660660
pub value: T,
661661
}
662662

663+
impl<T> !Sync for UnsafeCell<T> {}
664+
663665
impl<T> UnsafeCell<T> {
664666
/// Construct a new instance of `UnsafeCell` which will wrap the specified
665667
/// value.

src/libcore/marker.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub unsafe trait Send : MarkerTrait {
5151

5252
impl<T> !Send for *const T { }
5353
impl<T> !Send for *mut T { }
54+
impl !Send for Managed { }
5455

5556
/// Types with a constant size known at compile-time.
5657
#[stable(feature = "rust1", since = "1.0.0")]
@@ -219,6 +220,7 @@ pub unsafe trait Sync : MarkerTrait {
219220

220221
impl<T> !Sync for *const T { }
221222
impl<T> !Sync for *mut T { }
223+
impl !Sync for Managed { }
222224

223225
/// A type which is considered "not POD", meaning that it is not
224226
/// implicitly copyable. This is typically embedded in other types to

src/librustc/middle/traits/select.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
826826
}
827827
Some(bound @ ty::BoundSend) |
828828
Some(bound @ ty::BoundSync) => {
829+
// Ideally, we shouldn't sepcial case Send/Sync. This will be unified
830+
// as soon as default trait implementations for these traits land.
829831
try!(self.assemble_candidates_from_impls(obligation, &mut candidates));
830832

831833
// No explicit impls were declared for this type, consider the fallback rules.
@@ -1599,27 +1601,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
15991601
-> Result<BuiltinBoundConditions<'tcx>,SelectionError<'tcx>>
16001602
{
16011603
// First check for markers and other nonsense.
1602-
let tcx = this.tcx();
16031604
match bound {
1604-
ty::BoundSend => {
1605-
if Some(def_id) == tcx.lang_items.managed_bound() {
1606-
return Err(Unimplemented)
1607-
}
1608-
}
1609-
16101605
ty::BoundCopy => {
16111606
return Ok(ParameterBuiltin)
16121607
}
16131608

1614-
ty::BoundSync => {
1615-
if
1616-
Some(def_id) == tcx.lang_items.managed_bound() ||
1617-
Some(def_id) == tcx.lang_items.unsafe_cell_type()
1618-
{
1619-
return Err(Unimplemented)
1620-
}
1621-
}
1622-
1609+
ty::BoundSend |
1610+
ty::BoundSync |
16231611
ty::BoundSized => { }
16241612
}
16251613

0 commit comments

Comments
 (0)