Skip to content

Commit bd511f7

Browse files
committed
Add negative impls for *const T and *mut T
1 parent ad3e748 commit bd511f7

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/libcore/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
#![feature(staged_api)]
6969
#![feature(unboxed_closures)]
7070
#![feature(rustc_attrs)]
71+
#![feature(optin_builtin_traits)]
7172

7273
#[macro_use]
7374
mod macros;

src/libcore/marker.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ pub unsafe trait Send : MarkerTrait {
4949
// empty.
5050
}
5151

52+
impl<T> !Send for *const T { }
53+
impl<T> !Send for *mut T { }
54+
5255
/// Types with a constant size known at compile-time.
5356
#[stable(feature = "rust1", since = "1.0.0")]
5457
#[lang="sized"]
@@ -214,6 +217,9 @@ pub unsafe trait Sync : MarkerTrait {
214217
// Empty
215218
}
216219

220+
impl<T> !Sync for *const T { }
221+
impl<T> !Sync for *mut T { }
222+
217223
/// A type which is considered "not POD", meaning that it is not
218224
/// implicitly copyable. This is typically embedded in other types to
219225
/// ensure that they are never copied, even if they lack a destructor.

src/librustc/middle/traits/select.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,8 +1377,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
13771377

13781378
ty::BoundSync |
13791379
ty::BoundSend => {
1380-
// sync and send are not implemented for *const, *mut
1381-
Err(Unimplemented)
1380+
self.tcx().sess.bug(
1381+
&format!(
1382+
"raw pointers should have a negative \
1383+
impl for `Send` and `Sync`")[]);
13821384
}
13831385
}
13841386
}

0 commit comments

Comments
 (0)