From cae969e2a755bd7e8ec22758a8a02146ddb599a4 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Fri, 13 Feb 2015 15:15:05 +1100 Subject: Remove the implicit `'static` bound on `Send`. Previously Send was defined as `trait Send: 'static {}`. As detailed in https://github.com/rust-lang/rfcs/pull/458, the `'static` bound is not actually necessary for safety, we can use lifetimes to enforce that more flexibly. `unsafe` code that was previously relying on `Send` to insert a `'static` bound now may allow incorrect patterns, and so should be audited (a quick way to ensure safety immediately and postpone the audit is to add an explicit `'static` bound to any uses of the `Send` type). cc #22251. --- src/libcore/marker.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/libcore') diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index da93d4f6ca4..f5b42b3c858 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -32,9 +32,19 @@ use clone::Clone; reason = "will be overhauled with new lifetime rules; see RFC 458")] #[lang="send"] #[rustc_on_unimplemented = "`{Self}` cannot be sent between threads safely"] +#[cfg(stage0)] // SNAP ac134f7 remove after stage0 pub unsafe trait Send: 'static { // empty. } +/// Types able to be transferred across thread boundaries. +#[unstable(feature = "core", + reason = "will be overhauled with new lifetime rules; see RFC 458")] +#[lang="send"] +#[rustc_on_unimplemented = "`{Self}` cannot be sent between threads safely"] +#[cfg(not(stage0))] +pub unsafe trait Send { + // empty. +} /// Types with a constant size known at compile-time. #[stable(feature = "rust1", since = "1.0.0")] -- cgit 1.4.1-3-g733a5 From 35ca50bd5676db31a8074a216d1aadad7d434de8 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Sat, 14 Feb 2015 00:07:48 +1100 Subject: Add Send implementations for `&` and `&mut`. Per RFC 458. Closes #22251. --- src/libcore/marker.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/libcore') diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index f5b42b3c858..7e8472b91dc 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -434,3 +434,11 @@ pub struct NoCopy; #[lang="managed_bound"] #[derive(Clone, PartialEq, Eq, PartialOrd, Ord)] pub struct Managed; + +#[cfg(not(stage0))] // SNAP ac134f7 remove this attribute after the next snapshot +mod impls { + use super::{Send, Sync, Sized}; + + unsafe impl<'a, T: Sync + ?Sized> Send for &'a T {} + unsafe impl<'a, T: Send + ?Sized> Send for &'a mut T {} +} -- cgit 1.4.1-3-g733a5