From 1f760d5d1a448c08ff4b66cfa8d35d39a5d667c0 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 5 Aug 2014 16:40:04 -0700 Subject: [PATCH] Rename `Share` to `Sync` This leaves the `Share` trait at `std::kinds` via a `#[deprecated]` `pub use` statement, but the `NoShare` struct is no longer part of `std::kinds::marker` due to #12660 (the build cannot bootstrap otherwise). All code referencing the `Share` trait should now reference the `Sync` trait, and all code referencing the `NoShare` type should now reference the `NoSync` type. The functionality and meaning of this trait have not changed, only the naming. Closes #16281 [breaking-change] --- src/doc/complement-design-faq.md | 10 ++--- src/doc/guide-unsafe.md | 4 +- src/doc/rust.md | 6 +-- src/doc/tutorial.md | 8 ++-- src/etc/vim/syntax/rust.vim | 2 +- src/liballoc/arc.rs | 22 +++++----- src/liballoc/rc.rs | 14 +++---- src/libcore/cell.rs | 10 ++--- src/libcore/kinds.rs | 41 +++++++++++-------- src/libcore/prelude.rs | 2 +- src/libgreen/message_queue.rs | 10 ++--- src/librustc/metadata/tydecode.rs | 2 +- src/librustc/metadata/tyencode.rs | 2 +- src/librustc/middle/lang_items.rs | 10 ++--- src/librustc/middle/trans/debuginfo.rs | 2 +- src/librustc/middle/ty.rs | 22 +++++----- src/librustc/util/ppaux.rs | 4 +- src/librustdoc/clean/mod.rs | 6 +-- src/librustrt/local_data.rs | 2 +- src/libstd/prelude.rs | 2 +- src/libsync/atomic.rs | 2 +- src/libsync/comm/mod.rs | 12 +++--- src/libsync/deque.rs | 10 ++--- src/libsync/lock.rs | 10 ++--- src/libsync/raw.rs | 2 +- src/libsyntax/ast.rs | 2 +- src/libsyntax/ext/deriving/bounds.rs | 2 +- src/libsyntax/ext/deriving/mod.rs | 2 +- src/test/auxiliary/issue-2526.rs | 6 +-- .../auxiliary/trait_superkinds_in_metadata.rs | 2 +- .../builtin-superkinds-double-superkind.rs | 6 +-- .../builtin-superkinds-in-metadata.rs | 4 +- .../builtin-superkinds-self-type.rs | 4 +- .../builtin-superkinds-typaram-not-send.rs | 2 +- .../compile-fail/closure-bounds-subtype.rs | 4 +- src/test/compile-fail/comm-not-freeze.rs | 8 ++-- src/test/compile-fail/deriving-bounds.rs | 2 +- src/test/compile-fail/issue-2611-4.rs | 2 +- src/test/compile-fail/marker-no-share.rs | 4 +- src/test/compile-fail/mut-not-freeze.rs | 4 +- .../compile-fail/mutable-enum-indirect.rs | 6 +-- src/test/compile-fail/no_share-enum.rs | 8 ++-- src/test/compile-fail/no_share-rc.rs | 4 +- src/test/compile-fail/no_share-struct.rs | 8 ++-- src/test/compile-fail/proc-bounds.rs | 2 +- .../compile-fail/trait-bounds-cant-coerce.rs | 2 +- src/test/compile-fail/trait-bounds-sugar.rs | 4 +- .../typeck-unsafe-always-share.rs | 20 ++++----- src/test/pretty/path-type-bounds.rs | 6 +-- .../builtin-superkinds-capabilities-xc.rs | 4 +- .../builtin-superkinds-in-metadata.rs | 4 +- src/test/run-pass/closure-syntax.rs | 18 ++++---- src/test/run-pass/const-bound.rs | 2 +- src/test/run-pass/deriving-bounds.rs | 2 +- src/test/run-pass/issue-2611-3.rs | 2 +- .../parameterized-trait-with-bounds.rs | 2 +- src/test/run-pass/proc-bounds.rs | 8 ++-- src/test/run-pass/trait-bounds-basic.rs | 2 +- src/test/run-pass/trait-bounds-in-arc.rs | 14 +++---- 59 files changed, 199 insertions(+), 190 deletions(-) diff --git a/src/doc/complement-design-faq.md b/src/doc/complement-design-faq.md index 447a3e25808fb..eb060d06cc4ff 100644 --- a/src/doc/complement-design-faq.md +++ b/src/doc/complement-design-faq.md @@ -50,15 +50,15 @@ non-deterministic behavior. Rust provides the tools to make using a GC possible and even pleasant, but it should not be a requirement for implementing the language. -## Non-`Share` `static mut` is unsafe +## Non-`Sync` `static mut` is unsafe -Types which are [`Share`][share] are thread-safe when multiple shared -references to them are used concurrently. Types which are not `Share` are not +Types which are [`Sync`][sync] are thread-safe when multiple shared +references to them are used concurrently. Types which are not `Sync` are not thread-safe, and thus when used in a global require unsafe code to use. -[share]: http://doc.rust-lang.org/core/kinds/trait.Share.html +[sync]: http://doc.rust-lang.org/core/kinds/trait.Sync.html -### If mutable static items that implement `Share` are safe, why is taking &mut SHARABLE unsafe? +### If mutable static items that implement `Sync` are safe, why is taking &mut SHARABLE unsafe? Having multiple aliasing `&mut T`s is never allowed. Due to the nature of globals, the borrow checker cannot possibly ensure that a static obeys the diff --git a/src/doc/guide-unsafe.md b/src/doc/guide-unsafe.md index dd69a5f07feac..8349c8ebcb648 100644 --- a/src/doc/guide-unsafe.md +++ b/src/doc/guide-unsafe.md @@ -699,10 +699,10 @@ Other features provided by lang items include: - stack unwinding and general failure; the `eh_personality`, `fail_` and `fail_bounds_checks` lang items. - the traits in `std::kinds` used to indicate types that satisfy - various kinds; lang items `send`, `share` and `copy`. + various kinds; lang items `send`, `sync` and `copy`. - the marker types and variance indicators found in `std::kinds::markers`; lang items `covariant_type`, - `contravariant_lifetime`, `no_share_bound`, etc. + `contravariant_lifetime`, `no_sync_bound`, etc. Lang items are loaded lazily by the compiler; e.g. if one never uses `Box` then there is no need to define functions for `exchange_malloc` diff --git a/src/doc/rust.md b/src/doc/rust.md index a07b8a42dc004..9061a623c03f0 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -2111,7 +2111,7 @@ A complete list of the built-in language items follows: : Has a size known at compile time. * `copy` : Types that do not move ownership when used by-value. -* `share` +* `sync` : Able to be safely shared between tasks when aliased. * `drop` : Have destructors. @@ -2191,8 +2191,8 @@ These types help drive the compiler's analysis : This type does not implement "send", even if eligible * `no_copy_bound` : This type does not implement "copy", even if eligible -* `no_share_bound` - : This type does not implement "share", even if eligible +* `no_sync_bound` + : This type does not implement "sync", even if eligible * `managed_bound` : This type implements "managed" diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index e4480e26cccd7..a42cdcca82daa 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -2196,7 +2196,7 @@ and may not be overridden: Types are sendable unless they contain references. -* `Share` - Types that are *threadsafe*. +* `Sync` - Types that are *threadsafe*. These are types that are safe to be used across several threads with access to a `&T` pointer. `Mutex` is an example of a *sharable* type with internal mutable data. @@ -2250,7 +2250,7 @@ We say that the `Printable` trait _provides_ a `print` method with the given signature. This means that we can call `print` on an argument of any type that implements the `Printable` trait. -Rust's built-in `Send` and `Share` types are examples of traits that +Rust's built-in `Send` and `Sync` types are examples of traits that don't provide any methods. Traits may be implemented for specific types with [impls]. An impl for @@ -2535,7 +2535,7 @@ select the method to call at runtime. This usage of traits is similar to Java interfaces. -There are some built-in bounds, such as `Send` and `Share`, which are properties +There are some built-in bounds, such as `Send` and `Sync`, which are properties of the components of types. By design, trait objects don't know the exact type of their contents and so the compiler cannot reason about those properties. @@ -2548,7 +2548,7 @@ trait Foo {} trait Bar {} fn sendable_foo(f: Box) { /* ... */ } -fn shareable_bar(b: &Bar + Share) { /* ... */ } +fn sync_bar(b: &Bar + Sync) { /* ... */ } ~~~ When no colon is specified (such as the type `Box`), it is inferred that the diff --git a/src/etc/vim/syntax/rust.vim b/src/etc/vim/syntax/rust.vim index 0204d42a726ff..d8330b84f3119 100644 --- a/src/etc/vim/syntax/rust.vim +++ b/src/etc/vim/syntax/rust.vim @@ -76,7 +76,7 @@ syn keyword rustType f64 i8 i16 i32 i64 str Self " to make it easy to update. " Core operators {{{3 -syn keyword rustTrait Copy Send Sized Share +syn keyword rustTrait Copy Send Sized Sync syn keyword rustTrait Add Sub Mul Div Rem Neg Not syn keyword rustTrait BitAnd BitOr BitXor syn keyword rustTrait Drop Deref DerefMut diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 3b0ed52806008..1d6714430a8ed 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -15,7 +15,7 @@ use core::atomic; use core::clone::Clone; -use core::kinds::{Share, Send}; +use core::kinds::{Sync, Send}; use core::mem::{min_align_of, size_of, drop}; use core::mem; use core::ops::{Drop, Deref}; @@ -76,7 +76,7 @@ struct ArcInner { data: T, } -impl Arc { +impl Arc { /// Create an atomically reference counted wrapper. #[inline] #[stable] @@ -95,8 +95,8 @@ impl Arc { fn inner(&self) -> &ArcInner { // This unsafety is ok because while this arc is alive we're guaranteed // that the inner pointer is valid. Furthermore, we know that the - // `ArcInner` structure itself is `Share` because the inner data is - // `Share` as well, so we're ok loaning out an immutable pointer to + // `ArcInner` structure itself is `Sync` because the inner data is + // `Sync` as well, so we're ok loaning out an immutable pointer to // these contents. unsafe { &*self._ptr } } @@ -115,7 +115,7 @@ impl Arc { } #[unstable = "waiting on stability of Clone"] -impl Clone for Arc { +impl Clone for Arc { /// Duplicate an atomically reference counted wrapper. /// /// The resulting two `Arc` objects will point to the same underlying data @@ -140,14 +140,14 @@ impl Clone for Arc { } #[experimental = "Deref is experimental."] -impl Deref for Arc { +impl Deref for Arc { #[inline] fn deref(&self) -> &T { &self.inner().data } } -impl Arc { +impl Arc { /// Acquires a mutable pointer to the inner contents by guaranteeing that /// the reference count is one (no sharing is possible). /// @@ -175,7 +175,7 @@ impl Arc { #[unsafe_destructor] #[experimental = "waiting on stability of Drop"] -impl Drop for Arc { +impl Drop for Arc { fn drop(&mut self) { // This structure has #[unsafe_no_drop_flag], so this drop glue may run // more than once (but it is guaranteed to be zeroed after the first if @@ -219,7 +219,7 @@ impl Drop for Arc { } #[experimental = "Weak pointers may not belong in this module."] -impl Weak { +impl Weak { /// Attempts to upgrade this weak reference to a strong reference. /// /// This method will fail to upgrade this reference if the strong reference @@ -245,7 +245,7 @@ impl Weak { } #[experimental = "Weak pointers may not belong in this module."] -impl Clone for Weak { +impl Clone for Weak { #[inline] fn clone(&self) -> Weak { // See comments in Arc::clone() for why this is relaxed @@ -256,7 +256,7 @@ impl Clone for Weak { #[unsafe_destructor] #[experimental = "Weak pointers may not belong in this module."] -impl Drop for Weak { +impl Drop for Weak { fn drop(&mut self) { // see comments above for why this check is here if self._ptr.is_null() { return } diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 022928ce74331..060f9875bfcf9 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -179,7 +179,7 @@ pub struct Rc { // field accesses of the contained type via Deref _ptr: *mut RcBox, _nosend: marker::NoSend, - _noshare: marker::NoShare + _noshare: marker::NoSync } #[stable] @@ -199,7 +199,7 @@ impl Rc { weak: Cell::new(1) }), _nosend: marker::NoSend, - _noshare: marker::NoShare + _noshare: marker::NoSync } } } @@ -213,7 +213,7 @@ impl Rc { Weak { _ptr: self._ptr, _nosend: marker::NoSend, - _noshare: marker::NoShare + _noshare: marker::NoSync } } } @@ -348,7 +348,7 @@ impl Clone for Rc { #[inline] fn clone(&self) -> Rc { self.inc_strong(); - Rc { _ptr: self._ptr, _nosend: marker::NoSend, _noshare: marker::NoShare } + Rc { _ptr: self._ptr, _nosend: marker::NoSend, _noshare: marker::NoSync } } } @@ -412,7 +412,7 @@ pub struct Weak { // field accesses of the contained type via Deref _ptr: *mut RcBox, _nosend: marker::NoSend, - _noshare: marker::NoShare + _noshare: marker::NoSync } #[experimental = "Weak pointers may not belong in this module."] @@ -423,7 +423,7 @@ impl Weak { None } else { self.inc_strong(); - Some(Rc { _ptr: self._ptr, _nosend: marker::NoSend, _noshare: marker::NoShare }) + Some(Rc { _ptr: self._ptr, _nosend: marker::NoSend, _noshare: marker::NoSync }) } } } @@ -451,7 +451,7 @@ impl Clone for Weak { #[inline] fn clone(&self) -> Weak { self.inc_weak(); - Weak { _ptr: self._ptr, _nosend: marker::NoSend, _noshare: marker::NoShare } + Weak { _ptr: self._ptr, _nosend: marker::NoSend, _noshare: marker::NoSync } } } diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index becd2d3f9628c..2a7b1630edf68 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -165,7 +165,7 @@ use option::{None, Option, Some}; #[unstable = "likely to be renamed; otherwise stable"] pub struct Cell { value: UnsafeCell, - noshare: marker::NoShare, + noshare: marker::NoSync, } #[stable] @@ -174,7 +174,7 @@ impl Cell { pub fn new(value: T) -> Cell { Cell { value: UnsafeCell::new(value), - noshare: marker::NoShare, + noshare: marker::NoSync, } } @@ -213,7 +213,7 @@ pub struct RefCell { value: UnsafeCell, borrow: Cell, nocopy: marker::NoCopy, - noshare: marker::NoShare, + noshare: marker::NoSync, } // Values [1, MAX-1] represent the number of `Ref` active @@ -230,7 +230,7 @@ impl RefCell { value: UnsafeCell::new(value), borrow: Cell::new(UNUSED), nocopy: marker::NoCopy, - noshare: marker::NoShare, + noshare: marker::NoSync, } } @@ -430,7 +430,7 @@ impl<'b, T> DerefMut for RefMut<'b, T> { /// /// struct NotThreadSafe { /// value: UnsafeCell, -/// marker: marker::NoShare +/// marker: marker::NoSync /// } /// ``` /// diff --git a/src/libcore/kinds.rs b/src/libcore/kinds.rs index f6a88b3419607..c16af871f833e 100644 --- a/src/libcore/kinds.rs +++ b/src/libcore/kinds.rs @@ -20,6 +20,9 @@ by the compiler automatically for the types to which they apply. */ +#[deprecated = "This has been renamed to Sync"] +pub use Share = self::Sync; + /// Types able to be transferred across task boundaries. #[lang="send"] pub trait Send { @@ -40,32 +43,32 @@ pub trait Copy { /// Types that can be safely shared between tasks when aliased. /// -/// The precise definition is: a type `T` is `Share` if `&T` is +/// The precise definition is: a type `T` is `Sync` if `&T` is /// thread-safe. In other words, there is no possibility of data races /// when passing `&T` references between tasks. /// /// As one would expect, primitive types like `u8` and `f64` are all -/// `Share`, and so are simple aggregate types containing them (like -/// tuples, structs and enums). More instances of basic `Share` types +/// `Sync`, and so are simple aggregate types containing them (like +/// tuples, structs and enums). More instances of basic `Sync` types /// include "immutable" types like `&T` and those with simple /// inherited mutability, such as `Box`, `Vec` and most other -/// collection types. (Generic parameters need to be `Share` for their -/// container to be `Share`.) +/// collection types. (Generic parameters need to be `Sync` for their +/// container to be `Sync`.) /// /// A somewhat surprising consequence of the definition is `&mut T` is -/// `Share` (if `T` is `Share`) even though it seems that it might +/// `Sync` (if `T` is `Sync`) even though it seems that it might /// provide unsynchronised mutation. The trick is a mutable reference /// stored in an aliasable reference (that is, `& &mut T`) becomes /// read-only, as if it were a `& &T`, hence there is no risk of a data /// race. /// -/// Types that are not `Share` are those that have "interior +/// Types that are not `Sync` are those that have "interior /// mutability" in a non-thread-safe way, such as `Cell` and `RefCell` /// in `std::cell`. These types allow for mutation of their contents /// even when in an immutable, aliasable slot, e.g. the contents of /// `&Cell` can be `.set`, and do not ensure data races are -/// impossible, hence they cannot be `Share`. A higher level example -/// of a non-`Share` type is the reference counted pointer +/// impossible, hence they cannot be `Sync`. A higher level example +/// of a non-`Sync` type is the reference counted pointer /// `std::rc::Rc`, because any reference `&Rc` can clone a new /// reference, which modifies the reference counts in a non-atomic /// way. @@ -73,18 +76,25 @@ pub trait Copy { /// For cases when one does need thread-safe interior mutability, /// types like the atomics in `std::sync` and `Mutex` & `RWLock` in /// the `sync` crate do ensure that any mutation cannot cause data -/// races. Hence these types are `Share`. +/// races. Hence these types are `Sync`. /// /// Users writing their own types with interior mutability (or anything -/// else that is not thread-safe) should use the `NoShare` marker type +/// else that is not thread-safe) should use the `NoSync` marker type /// (from `std::kinds::marker`) to ensure that the compiler doesn't -/// consider the user-defined type to be `Share`. Any types with +/// consider the user-defined type to be `Sync`. Any types with /// interior mutability must also use the `std::cell::UnsafeCell` wrapper /// around the value(s) which can be mutated when behind a `&` /// reference; not doing this is undefined behaviour (for example, /// `transmute`-ing from `&T` to `&mut T` is illegal). +#[lang="sync"] +#[cfg(not(stage0))] +pub trait Sync { + // Empty +} +/// dox #[lang="share"] -pub trait Share { +#[cfg(stage0)] +pub trait Sync { // Empty } @@ -94,7 +104,6 @@ pub trait Share { /// implemented using unsafe code. In that case, you may want to embed /// some of the marker types below into your type. pub mod marker { - /// A marker type whose type parameter `T` is considered to be /// covariant with respect to the type itself. This is (typically) /// used to indicate that an instance of the type `T` is being stored @@ -266,12 +275,12 @@ pub mod marker { #[deriving(PartialEq,Clone)] pub struct NoCopy; - /// A type which is considered "not shareable", meaning that + /// A type which is considered "not sync", meaning that /// its contents are not threadsafe, hence they cannot be /// shared between tasks. #[lang="no_share_bound"] #[deriving(PartialEq,Clone)] - pub struct NoShare; + pub struct NoSync; /// A type which is considered managed by the GC. This is typically /// embedded in other types. diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index d27689eeaf417..5b7c7c8f31a6f 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -29,7 +29,7 @@ //! ``` // Reexported core operators -pub use kinds::{Copy, Send, Sized, Share}; +pub use kinds::{Copy, Send, Sized, Sync}; pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not}; pub use ops::{BitAnd, BitOr, BitXor}; pub use ops::{Drop, Deref, DerefMut}; diff --git a/src/libgreen/message_queue.rs b/src/libgreen/message_queue.rs index 137c493364520..66040633ff192 100644 --- a/src/libgreen/message_queue.rs +++ b/src/libgreen/message_queue.rs @@ -20,18 +20,18 @@ pub enum PopResult { pub fn queue() -> (Consumer, Producer) { let a = Arc::new(mpsc::Queue::new()); - (Consumer { inner: a.clone(), noshare: marker::NoShare }, - Producer { inner: a, noshare: marker::NoShare }) + (Consumer { inner: a.clone(), noshare: marker::NoSync }, + Producer { inner: a, noshare: marker::NoSync }) } pub struct Producer { inner: Arc>, - noshare: marker::NoShare, + noshare: marker::NoSync, } pub struct Consumer { inner: Arc>, - noshare: marker::NoShare, + noshare: marker::NoSync, } impl Consumer { @@ -60,6 +60,6 @@ impl Producer { impl Clone for Producer { fn clone(&self) -> Producer { - Producer { inner: self.inner.clone(), noshare: marker::NoShare } + Producer { inner: self.inner.clone(), noshare: marker::NoSync } } } diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index ffa0cca753904..fed23185c5d27 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -633,7 +633,7 @@ fn parse_bounds(st: &mut PState, conv: conv_did) -> ty::ParamBounds { param_bounds.builtin_bounds.add(ty::BoundCopy); } 'T' => { - param_bounds.builtin_bounds.add(ty::BoundShare); + param_bounds.builtin_bounds.add(ty::BoundSync); } 'I' => { param_bounds.trait_bounds.push(Rc::new(parse_trait_ref(st, |x,y| conv(x,y)))); diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index f16a46ed72933..ba865c7ab04d0 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -352,7 +352,7 @@ fn enc_bounds(w: &mut SeekableMemWriter, cx: &ctxt, bs: &ty::ParamBounds) { ty::BoundStatic => mywrite!(w, "O"), ty::BoundSized => mywrite!(w, "Z"), ty::BoundCopy => mywrite!(w, "P"), - ty::BoundShare => mywrite!(w, "T"), + ty::BoundSync => mywrite!(w, "T"), } } diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index f59909bd138b2..223e518fecdf7 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -13,7 +13,7 @@ // Language items are items that represent concepts intrinsic to the language // itself. Examples are: // -// * Traits that specify "kinds"; e.g. "Share", "Send". +// * Traits that specify "kinds"; e.g. "Sync", "Send". // // * Traits that represent operators; e.g. "Add", "Sub", "Index". // @@ -92,8 +92,8 @@ impl LanguageItems { Some(ty::BoundSized) } else if Some(id) == self.copy_trait() { Some(ty::BoundCopy) - } else if Some(id) == self.share_trait() { - Some(ty::BoundShare) + } else if Some(id) == self.sync_trait() { + Some(ty::BoundSync) } else { None } @@ -218,7 +218,7 @@ lets_do_this! { SendTraitLangItem, "send", send_trait; SizedTraitLangItem, "sized", sized_trait; CopyTraitLangItem, "copy", copy_trait; - ShareTraitLangItem, "share", share_trait; + SyncTraitLangItem, "sync", sync_trait; DropTraitLangItem, "drop", drop_trait; @@ -296,7 +296,7 @@ lets_do_this! { NoSendItem, "no_send_bound", no_send_bound; NoCopyItem, "no_copy_bound", no_copy_bound; - NoShareItem, "no_share_bound", no_share_bound; + NoSyncItem, "no_share_bound", no_share_bound; ManagedItem, "managed_bound", managed_bound; IteratorItem, "iterator", iterator; diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 6fe3ee5d29b58..f3916f296f126 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -499,7 +499,7 @@ impl TypeMap { ty::BoundSend => unique_type_id.push_str("Send"), ty::BoundSized => unique_type_id.push_str("Sized"), ty::BoundCopy => unique_type_id.push_str("Copy"), - ty::BoundShare => unique_type_id.push_str("Share"), + ty::BoundSync => unique_type_id.push_str("Sync"), }; unique_type_id.push_char('+'); } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index ce8f37514a4cd..0cc5486013aac 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -833,7 +833,7 @@ pub enum BuiltinBound { BoundSend, BoundSized, BoundCopy, - BoundShare, + BoundSync, } pub fn empty_builtin_bounds() -> BuiltinBounds { @@ -845,7 +845,7 @@ pub fn all_builtin_bounds() -> BuiltinBounds { set.add(BoundStatic); set.add(BoundSend); set.add(BoundSized); - set.add(BoundShare); + set.add(BoundSync); set } @@ -1804,7 +1804,7 @@ def_type_content_sets!( ReachesBorrowed = 0b0000_0010__0000_0000__0000, // ReachesManaged /* see [1] below */ = 0b0000_0100__0000_0000__0000, ReachesMutable = 0b0000_1000__0000_0000__0000, - ReachesNoShare = 0b0001_0000__0000_0000__0000, + ReachesNoSync = 0b0001_0000__0000_0000__0000, ReachesAll = 0b0001_1111__0000_0000__0000, // Things that cause values to *move* rather than *copy* @@ -1828,8 +1828,8 @@ def_type_content_sets!( // Things that prevent values from being considered sized Nonsized = 0b0000_0000__0000_0000__0001, - // Things that prevent values from being shared - Nonsharable = 0b0001_0000__0000_0000__0000, + // Things that prevent values from being sync + Nonsync = 0b0001_0000__0000_0000__0000, // Things that make values considered not POD (would be same // as `Moves`, but for the fact that managed data `@` is @@ -1855,7 +1855,7 @@ impl TypeContents { BoundSend => self.is_sendable(cx), BoundSized => self.is_sized(cx), BoundCopy => self.is_copy(cx), - BoundShare => self.is_sharable(cx), + BoundSync => self.is_sync(cx), } } @@ -1875,8 +1875,8 @@ impl TypeContents { !self.intersects(TC::Nonsendable) } - pub fn is_sharable(&self, _: &ctxt) -> bool { - !self.intersects(TC::Nonsharable) + pub fn is_sync(&self, _: &ctxt) -> bool { + !self.intersects(TC::Nonsync) } pub fn owns_managed(&self) -> bool { @@ -2169,11 +2169,11 @@ pub fn type_contents(cx: &ctxt, ty: t) -> TypeContents { } else if Some(did) == cx.lang_items.no_copy_bound() { tc | TC::OwnsAffine } else if Some(did) == cx.lang_items.no_share_bound() { - tc | TC::ReachesNoShare + tc | TC::ReachesNoSync } else if Some(did) == cx.lang_items.unsafe_type() { // FIXME(#13231): This shouldn't be needed after // opt-in built-in bounds are implemented. - (tc | TC::InteriorUnsafe) - TC::Nonsharable + (tc | TC::InteriorUnsafe) - TC::Nonsync } else { tc } @@ -2237,7 +2237,7 @@ pub fn type_contents(cx: &ctxt, ty: t) -> TypeContents { BoundSend => TC::Nonsendable, BoundSized => TC::Nonsized, BoundCopy => TC::Noncopy, - BoundShare => TC::Nonsharable, + BoundSync => TC::Nonsync, }; }); return tc; diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index c3986d01d3da5..4e193f0f1d952 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -646,7 +646,7 @@ impl Repr for ty::ParamBounds { ty::BoundSend => "Send".to_string(), ty::BoundSized => "Sized".to_string(), ty::BoundCopy => "Copy".to_string(), - ty::BoundShare => "Share".to_string(), + ty::BoundSync => "Sync".to_string(), }); } for t in self.trait_bounds.iter() { @@ -931,7 +931,7 @@ impl UserString for ty::BuiltinBound { ty::BoundSend => "Send".to_string(), ty::BoundSized => "Sized".to_string(), ty::BoundCopy => "Copy".to_string(), - ty::BoundShare => "Share".to_string(), + ty::BoundSync => "Sync".to_string(), } } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 7eecae84d1d6f..d714c2c394657 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -535,9 +535,9 @@ impl Clean for ty::BuiltinBound { ty::BoundCopy => (tcx.lang_items.copy_trait().unwrap(), external_path("Copy", &empty)), - ty::BoundShare => - (tcx.lang_items.share_trait().unwrap(), - external_path("Share", &empty)), + ty::BoundSync => + (tcx.lang_items.sync_trait().unwrap(), + external_path("Sync", &empty)), }; let fqn = csearch::get_item_path(tcx, did); let fqn = fqn.move_iter().map(|i| i.to_string()).collect(); diff --git a/src/librustrt/local_data.rs b/src/librustrt/local_data.rs index c290b59b61b7a..27858b025c6cb 100644 --- a/src/librustrt/local_data.rs +++ b/src/librustrt/local_data.rs @@ -112,7 +112,7 @@ struct TLDValueBox { // refcount of 0 means uninitialized value, 1 means initialized, 2+ means // borrowed. // NB: we use UnsafeCell instead of Cell because Ref should be allowed to - // be Share. The only mutation occurs when a Ref is created or destroyed, + // be Sync. The only mutation occurs when a Ref is created or destroyed, // so there's no issue with &Ref being thread-safe. refcount: UnsafeCell } diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs index 96d5c0785f477..aa407ce8e0ccb 100644 --- a/src/libstd/prelude.rs +++ b/src/libstd/prelude.rs @@ -40,7 +40,7 @@ #![experimental] // Reexported core operators -#[doc(no_inline)] pub use kinds::{Copy, Send, Sized, Share}; +#[doc(no_inline)] pub use kinds::{Copy, Send, Sized, Sync}; #[doc(no_inline)] pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not}; #[doc(no_inline)] pub use ops::{BitAnd, BitOr, BitXor}; #[doc(no_inline)] pub use ops::{Drop, Deref, DerefMut}; diff --git a/src/libsync/atomic.rs b/src/libsync/atomic.rs index 101d869451c6d..31b993d8bab46 100644 --- a/src/libsync/atomic.rs +++ b/src/libsync/atomic.rs @@ -25,7 +25,7 @@ //! //! [1]: http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync //! -//! Atomic variables are safe to share between threads (they implement `Share`) +//! Atomic variables are safe to share between threads (they implement `Sync`) //! but they do not themselves provide the mechanism for sharing. The most //! common way to share an atomic variable is to put it into an `Arc` (an //! atomically-reference-counted shared pointer). diff --git a/src/libsync/comm/mod.rs b/src/libsync/comm/mod.rs index eff4cea1c43f0..45016b97566ce 100644 --- a/src/libsync/comm/mod.rs +++ b/src/libsync/comm/mod.rs @@ -375,7 +375,7 @@ pub struct Receiver { inner: UnsafeCell>, receives: Cell, // can't share in an arc - marker: marker::NoShare, + marker: marker::NoSync, } /// An iterator over messages on a receiver, this iterator will block @@ -393,7 +393,7 @@ pub struct Sender { inner: UnsafeCell>, sends: Cell, // can't share in an arc - marker: marker::NoShare, + marker: marker::NoSync, } /// The sending-half of Rust's synchronous channel type. This half can only be @@ -402,7 +402,7 @@ pub struct Sender { pub struct SyncSender { inner: Arc>>, // can't share in an arc - marker: marker::NoShare, + marker: marker::NoSync, } /// This enumeration is the list of the possible reasons that try_recv could not @@ -537,7 +537,7 @@ impl Sender { Sender { inner: UnsafeCell::new(inner), sends: Cell::new(0), - marker: marker::NoShare, + marker: marker::NoSync, } } @@ -713,7 +713,7 @@ impl Drop for Sender { impl SyncSender { fn new(inner: Arc>>) -> SyncSender { - SyncSender { inner: inner, marker: marker::NoShare } + SyncSender { inner: inner, marker: marker::NoSync } } /// Sends a value on this synchronous channel. @@ -801,7 +801,7 @@ impl Drop for SyncSender { impl Receiver { fn new(inner: Flavor) -> Receiver { - Receiver { inner: UnsafeCell::new(inner), receives: Cell::new(0), marker: marker::NoShare } + Receiver { inner: UnsafeCell::new(inner), receives: Cell::new(0), marker: marker::NoSync } } /// Blocks waiting for a value on this receiver diff --git a/src/libsync/deque.rs b/src/libsync/deque.rs index d5a05e7a68175..e70a730dc3a13 100644 --- a/src/libsync/deque.rs +++ b/src/libsync/deque.rs @@ -87,7 +87,7 @@ struct Deque { /// There may only be one worker per deque. pub struct Worker { deque: Arc>, - noshare: marker::NoShare, + noshare: marker::NoSync, } /// The stealing half of the work-stealing deque. Stealers have access to the @@ -95,7 +95,7 @@ pub struct Worker { /// `steal` method. pub struct Stealer { deque: Arc>, - noshare: marker::NoShare, + noshare: marker::NoSync, } /// When stealing some data, this is an enumeration of the possible outcomes. @@ -153,8 +153,8 @@ impl BufferPool { pub fn deque(&self) -> (Worker, Stealer) { let a = Arc::new(Deque::new(self.clone())); let b = a.clone(); - (Worker { deque: a, noshare: marker::NoShare }, - Stealer { deque: b, noshare: marker::NoShare }) + (Worker { deque: a, noshare: marker::NoSync }, + Stealer { deque: b, noshare: marker::NoSync }) } fn alloc(&mut self, bits: uint) -> Box> { @@ -217,7 +217,7 @@ impl Stealer { impl Clone for Stealer { fn clone(&self) -> Stealer { - Stealer { deque: self.deque.clone(), noshare: marker::NoShare } + Stealer { deque: self.deque.clone(), noshare: marker::NoSync } } } diff --git a/src/libsync/lock.rs b/src/libsync/lock.rs index 665cd48a278df..b07d06ca18e54 100644 --- a/src/libsync/lock.rs +++ b/src/libsync/lock.rs @@ -298,7 +298,7 @@ pub struct RWLockReadGuard<'a, T> { _guard: raw::RWLockReadGuard<'a>, } -impl RWLock { +impl RWLock { /// Create a reader/writer lock with the supplied data. pub fn new(user_data: T) -> RWLock { RWLock::new_with_condvars(user_data, 1) @@ -359,7 +359,7 @@ impl RWLock { } } -impl<'a, T: Send + Share> RWLockWriteGuard<'a, T> { +impl<'a, T: Send + Sync> RWLockWriteGuard<'a, T> { /// Consumes this write lock token, returning a new read lock token. /// /// This will allow pending readers to come into the lock. @@ -375,13 +375,13 @@ impl<'a, T: Send + Share> RWLockWriteGuard<'a, T> { } } -impl<'a, T: Send + Share> Deref for RWLockReadGuard<'a, T> { +impl<'a, T: Send + Sync> Deref for RWLockReadGuard<'a, T> { fn deref<'a>(&'a self) -> &'a T { self._data } } -impl<'a, T: Send + Share> Deref for RWLockWriteGuard<'a, T> { +impl<'a, T: Send + Sync> Deref for RWLockWriteGuard<'a, T> { fn deref<'a>(&'a self) -> &'a T { &*self._data } } -impl<'a, T: Send + Share> DerefMut for RWLockWriteGuard<'a, T> { +impl<'a, T: Send + Sync> DerefMut for RWLockWriteGuard<'a, T> { fn deref_mut<'a>(&'a mut self) -> &'a mut T { &mut *self._data } } diff --git a/src/libsync/raw.rs b/src/libsync/raw.rs index 49f60fe6f005f..c42d567fc18ce 100644 --- a/src/libsync/raw.rs +++ b/src/libsync/raw.rs @@ -87,7 +87,7 @@ impl WaitQueue { // The building-block used to make semaphores, mutexes, and rwlocks. struct Sem { lock: mutex::Mutex, - // n.b, we need Sem to be `Share`, but the WaitQueue type is not send/share + // n.b, we need Sem to be `Sync`, but the WaitQueue type is not send/share // (for good reason). We have an internal invariant on this semaphore, // however, that the queue is never accessed outside of a locked // context. diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 19882fecaa900..36a35e51062a3 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -208,7 +208,7 @@ pub static DUMMY_NODE_ID: NodeId = -1; /// The AST represents all type param bounds as types. /// typeck::collect::compute_bounds matches these against /// the "special" built-in traits (see middle::lang_items) and -/// detects Copy, Send and Share. +/// detects Copy, Send and Sync. #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum TyParamBound { TraitTyParamBound(TraitRef), diff --git a/src/libsyntax/ext/deriving/bounds.rs b/src/libsyntax/ext/deriving/bounds.rs index fac9f37c462cc..7cff6e8ff3c01 100644 --- a/src/libsyntax/ext/deriving/bounds.rs +++ b/src/libsyntax/ext/deriving/bounds.rs @@ -27,7 +27,7 @@ pub fn expand_deriving_bound(cx: &mut ExtCtxt, match tname.get() { "Copy" => "Copy", "Send" => "Send", - "Share" => "Share", + "Sync" => "Sync", ref tname => { cx.span_bug(span, format!("expected built-in trait name but \ diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs index edfe54db0c760..a9b5c8a413463 100644 --- a/src/libsyntax/ext/deriving/mod.rs +++ b/src/libsyntax/ext/deriving/mod.rs @@ -94,7 +94,7 @@ pub fn expand_meta_deriving(cx: &mut ExtCtxt, "FromPrimitive" => expand!(primitive::expand_deriving_from_primitive), "Send" => expand!(bounds::expand_deriving_bound), - "Share" => expand!(bounds::expand_deriving_bound), + "Sync" => expand!(bounds::expand_deriving_bound), "Copy" => expand!(bounds::expand_deriving_bound), ref tname => { diff --git a/src/test/auxiliary/issue-2526.rs b/src/test/auxiliary/issue-2526.rs index c6ca0f3ed7bdd..c2e1dd69a900c 100644 --- a/src/test/auxiliary/issue-2526.rs +++ b/src/test/auxiliary/issue-2526.rs @@ -18,17 +18,17 @@ struct arc_destruct { } #[unsafe_destructor] -impl Drop for arc_destruct { +impl Drop for arc_destruct { fn drop(&mut self) {} } -fn arc_destruct(data: int) -> arc_destruct { +fn arc_destruct(data: int) -> arc_destruct { arc_destruct { _data: data } } -fn arc(_data: T) -> arc_destruct { +fn arc(_data: T) -> arc_destruct { arc_destruct(0) } diff --git a/src/test/auxiliary/trait_superkinds_in_metadata.rs b/src/test/auxiliary/trait_superkinds_in_metadata.rs index 2efb8a17239da..0fa2d3459f433 100644 --- a/src/test/auxiliary/trait_superkinds_in_metadata.rs +++ b/src/test/auxiliary/trait_superkinds_in_metadata.rs @@ -13,6 +13,6 @@ #![crate_type="lib"] -pub trait RequiresShare : Share { } +pub trait RequiresShare : Sync { } pub trait RequiresRequiresShareAndSend : RequiresShare + Send { } pub trait RequiresCopy : Copy { } diff --git a/src/test/compile-fail/builtin-superkinds-double-superkind.rs b/src/test/compile-fail/builtin-superkinds-double-superkind.rs index 7de38e6173be1..d5a648e3e2001 100644 --- a/src/test/compile-fail/builtin-superkinds-double-superkind.rs +++ b/src/test/compile-fail/builtin-superkinds-double-superkind.rs @@ -11,12 +11,12 @@ // Test for traits that inherit from multiple builtin kinds at once, // testing that all such kinds must be present on implementing types. -trait Foo : Send+Share { } +trait Foo : Send+Sync { } -impl Foo for (T,) { } //~ ERROR cannot implement this trait +impl Foo for (T,) { } //~ ERROR cannot implement this trait impl Foo for (T,T) { } //~ ERROR cannot implement this trait -impl Foo for (T,T,T) { } // (ok) +impl Foo for (T,T,T) { } // (ok) fn main() { } diff --git a/src/test/compile-fail/builtin-superkinds-in-metadata.rs b/src/test/compile-fail/builtin-superkinds-in-metadata.rs index 66809aa72dc8d..889d82383e74e 100644 --- a/src/test/compile-fail/builtin-superkinds-in-metadata.rs +++ b/src/test/compile-fail/builtin-superkinds-in-metadata.rs @@ -19,8 +19,8 @@ use trait_superkinds_in_metadata::{RequiresRequiresShareAndSend, RequiresShare}; struct X(T); -impl RequiresShare for X { } +impl RequiresShare for X { } -impl RequiresRequiresShareAndSend for X { } //~ ERROR cannot implement this trait +impl RequiresRequiresShareAndSend for X { } //~ ERROR cannot implement this trait fn main() { } diff --git a/src/test/compile-fail/builtin-superkinds-self-type.rs b/src/test/compile-fail/builtin-superkinds-self-type.rs index bea025df6fc85..67222bdafbf94 100644 --- a/src/test/compile-fail/builtin-superkinds-self-type.rs +++ b/src/test/compile-fail/builtin-superkinds-self-type.rs @@ -11,13 +11,13 @@ // Tests (negatively) the ability for the Self type in default methods // to use capabilities granted by builtin kinds as supertraits. -trait Foo : Share { +trait Foo : Sync { fn foo(self, mut chan: Sender) { chan.send(self); //~ ERROR does not fulfill `Send` } } -impl Foo for T { } +impl Foo for T { } fn main() { let (tx, rx) = channel(); diff --git a/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs b/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs index bc0ad6dbb2938..166ca10ee1875 100644 --- a/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs +++ b/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs @@ -12,6 +12,6 @@ trait Foo : Send { } -impl Foo for T { } //~ ERROR cannot implement this trait +impl Foo for T { } //~ ERROR cannot implement this trait fn main() { } diff --git a/src/test/compile-fail/closure-bounds-subtype.rs b/src/test/compile-fail/closure-bounds-subtype.rs index 5ffaebe405e1c..51188e5dce412 100644 --- a/src/test/compile-fail/closure-bounds-subtype.rs +++ b/src/test/compile-fail/closure-bounds-subtype.rs @@ -12,7 +12,7 @@ fn take_any(_: ||:) { } -fn take_const_owned(_: ||:Share+Send) { +fn take_const_owned(_: ||:Sync+Send) { } fn give_any(f: ||:) { @@ -21,7 +21,7 @@ fn give_any(f: ||:) { fn give_owned(f: ||:Send) { take_any(f); - take_const_owned(f); //~ ERROR expected bounds `Send+Share` but found bounds `Send` + take_const_owned(f); //~ ERROR expected bounds `Send+Sync` but found bounds `Send` } fn main() {} diff --git a/src/test/compile-fail/comm-not-freeze.rs b/src/test/compile-fail/comm-not-freeze.rs index 3550922dc1462..5820818167cbd 100644 --- a/src/test/compile-fail/comm-not-freeze.rs +++ b/src/test/compile-fail/comm-not-freeze.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn test() {} +fn test() {} fn main() { - test::>(); //~ ERROR: does not fulfill `Share` - test::>(); //~ ERROR: does not fulfill `Share` - test::>(); //~ ERROR: does not fulfill `Share` + test::>(); //~ ERROR: does not fulfill `Sync` + test::>(); //~ ERROR: does not fulfill `Sync` + test::>(); //~ ERROR: does not fulfill `Sync` } diff --git a/src/test/compile-fail/deriving-bounds.rs b/src/test/compile-fail/deriving-bounds.rs index dc0bd5d028a42..1f9bd881afe2d 100644 --- a/src/test/compile-fail/deriving-bounds.rs +++ b/src/test/compile-fail/deriving-bounds.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[deriving(Share(Bad),Send,Copy)] +#[deriving(Sync(Bad),Send,Copy)] //~^ ERROR unexpected value in deriving, expected a trait struct Test; diff --git a/src/test/compile-fail/issue-2611-4.rs b/src/test/compile-fail/issue-2611-4.rs index b159337765e5f..42b70c28be604 100644 --- a/src/test/compile-fail/issue-2611-4.rs +++ b/src/test/compile-fail/issue-2611-4.rs @@ -20,7 +20,7 @@ struct E { } impl A for E { - fn b(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Share` + fn b(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Sync` } fn main() {} diff --git a/src/test/compile-fail/marker-no-share.rs b/src/test/compile-fail/marker-no-share.rs index 84e856f5ac915..25fe95b80c42c 100644 --- a/src/test/compile-fail/marker-no-share.rs +++ b/src/test/compile-fail/marker-no-share.rs @@ -10,9 +10,9 @@ use std::kinds::marker; -fn foo(p: P) { } +fn foo(p: P) { } fn main() { - foo(marker::NoShare); //~ ERROR does not fulfill `Share` + foo(marker::NoSync); //~ ERROR does not fulfill `Sync` } diff --git a/src/test/compile-fail/mut-not-freeze.rs b/src/test/compile-fail/mut-not-freeze.rs index 985bfec392c7f..a5b6acc447f84 100644 --- a/src/test/compile-fail/mut-not-freeze.rs +++ b/src/test/compile-fail/mut-not-freeze.rs @@ -10,9 +10,9 @@ use std::cell::RefCell; -fn f(_: T) {} +fn f(_: T) {} fn main() { let x = RefCell::new(0i); - f(x); //~ ERROR: which does not fulfill `Share` + f(x); //~ ERROR: which does not fulfill `Sync` } diff --git a/src/test/compile-fail/mutable-enum-indirect.rs b/src/test/compile-fail/mutable-enum-indirect.rs index e480ebfd3781f..9d4c35baea38b 100644 --- a/src/test/compile-fail/mutable-enum-indirect.rs +++ b/src/test/compile-fail/mutable-enum-indirect.rs @@ -13,11 +13,11 @@ use std::kinds::marker; -enum Foo { A(marker::NoShare) } +enum Foo { A(marker::NoSync) } -fn bar(_: T) {} +fn bar(_: T) {} fn main() { - let x = A(marker::NoShare); + let x = A(marker::NoSync); bar(&x); //~ ERROR type parameter with an incompatible type } diff --git a/src/test/compile-fail/no_share-enum.rs b/src/test/compile-fail/no_share-enum.rs index e68274fcb7940..f96d751af7e9d 100644 --- a/src/test/compile-fail/no_share-enum.rs +++ b/src/test/compile-fail/no_share-enum.rs @@ -10,13 +10,13 @@ use std::kinds::marker; -enum Foo { A(marker::NoShare) } +enum Foo { A(marker::NoSync) } -fn bar(_: T) {} +fn bar(_: T) {} fn main() { - let x = A(marker::NoShare); + let x = A(marker::NoSync); bar(x); //~^ ERROR instantiating a type parameter with an incompatible type `Foo`, - // which does not fulfill `Share` + // which does not fulfill `Sync` } diff --git a/src/test/compile-fail/no_share-rc.rs b/src/test/compile-fail/no_share-rc.rs index f49592b173587..7a840674be6f0 100644 --- a/src/test/compile-fail/no_share-rc.rs +++ b/src/test/compile-fail/no_share-rc.rs @@ -11,11 +11,11 @@ use std::rc::Rc; use std::cell::RefCell; -fn bar(_: T) {} +fn bar(_: T) {} fn main() { let x = Rc::new(RefCell::new(5i)); bar(x); //~^ ERROR instantiating a type parameter with an incompatible type - // `std::rc::Rc>`, which does not fulfill `Share` + // `std::rc::Rc>`, which does not fulfill `Sync` } diff --git a/src/test/compile-fail/no_share-struct.rs b/src/test/compile-fail/no_share-struct.rs index 7bb7d86e8d870..6b87a5fa09c98 100644 --- a/src/test/compile-fail/no_share-struct.rs +++ b/src/test/compile-fail/no_share-struct.rs @@ -10,13 +10,13 @@ use std::kinds::marker; -struct Foo { a: int, m: marker::NoShare } +struct Foo { a: int, m: marker::NoSync } -fn bar(_: T) {} +fn bar(_: T) {} fn main() { - let x = Foo { a: 5, m: marker::NoShare }; + let x = Foo { a: 5, m: marker::NoSync }; bar(x); //~^ ERROR instantiating a type parameter with an incompatible type `Foo`, - // which does not fulfill `Share` + // which does not fulfill `Sync` } diff --git a/src/test/compile-fail/proc-bounds.rs b/src/test/compile-fail/proc-bounds.rs index 0875212b7dee3..e8c6a3ba19174 100644 --- a/src/test/compile-fail/proc-bounds.rs +++ b/src/test/compile-fail/proc-bounds.rs @@ -9,7 +9,7 @@ // except according to those terms. fn is_send() {} -fn is_freeze() {} +fn is_freeze() {} fn is_static() {} fn main() { diff --git a/src/test/compile-fail/trait-bounds-cant-coerce.rs b/src/test/compile-fail/trait-bounds-cant-coerce.rs index 0b9f09d9482f1..4f405e2558d23 100644 --- a/src/test/compile-fail/trait-bounds-cant-coerce.rs +++ b/src/test/compile-fail/trait-bounds-cant-coerce.rs @@ -15,7 +15,7 @@ trait Foo { fn a(_x: Box) { } -fn c(x: Box) { +fn c(x: Box) { a(x); } diff --git a/src/test/compile-fail/trait-bounds-sugar.rs b/src/test/compile-fail/trait-bounds-sugar.rs index d548098ebe13e..c3d608b48f3c6 100644 --- a/src/test/compile-fail/trait-bounds-sugar.rs +++ b/src/test/compile-fail/trait-bounds-sugar.rs @@ -19,11 +19,11 @@ fn a(_x: Box) { fn b(_x: &'static Foo) { // should be same as &'static Foo+'static } -fn c(x: Box) { +fn c(x: Box) { a(x); //~ ERROR expected bounds `Send` } -fn d(x: &'static Foo+Share) { +fn d(x: &'static Foo+Sync) { b(x); //~ ERROR expected bounds `'static` } diff --git a/src/test/compile-fail/typeck-unsafe-always-share.rs b/src/test/compile-fail/typeck-unsafe-always-share.rs index a57654b029d16..826fec2792993 100644 --- a/src/test/compile-fail/typeck-unsafe-always-share.rs +++ b/src/test/compile-fail/typeck-unsafe-always-share.rs @@ -8,36 +8,36 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Verify that UnsafeCell is *always* share regardles `T` is share. +// Verify that UnsafeCell is *always* sync regardles `T` is sync. // ignore-tidy-linelength use std::cell::UnsafeCell; use std::kinds::marker; -struct MyShare { +struct MySync { u: UnsafeCell } -struct NoShare { - m: marker::NoShare +struct NoSync { + m: marker::NoSync } -fn test(s: T){ +fn test(s: T){ } fn main() { - let us = UnsafeCell::new(MyShare{u: UnsafeCell::new(0i)}); + let us = UnsafeCell::new(MySync{u: UnsafeCell::new(0i)}); test(us); - let uns = UnsafeCell::new(NoShare{m: marker::NoShare}); + let uns = UnsafeCell::new(NoSync{m: marker::NoSync}); test(uns); - let ms = MyShare{u: uns}; + let ms = MySync{u: uns}; test(ms); - let ns = NoShare{m: marker::NoShare}; + let ns = NoSync{m: marker::NoSync}; test(ns); - //~^ ERROR instantiating a type parameter with an incompatible type `NoShare`, which does not fulfill `Share` + //~^ ERROR instantiating a type parameter with an incompatible type `NoSync`, which does not fulfill `Sync` } diff --git a/src/test/pretty/path-type-bounds.rs b/src/test/pretty/path-type-bounds.rs index 94383d9724cbe..7c05e6d606546 100644 --- a/src/test/pretty/path-type-bounds.rs +++ b/src/test/pretty/path-type-bounds.rs @@ -14,11 +14,11 @@ trait Tr { } impl Tr for int { } -fn foo(x: Box) -> Box { x } +fn foo(x: Box) -> Box { x } fn main() { - let x: Box; + let x: Box; - box() 1i as Box; + box() 1i as Box; } diff --git a/src/test/run-pass/builtin-superkinds-capabilities-xc.rs b/src/test/run-pass/builtin-superkinds-capabilities-xc.rs index 51238b0ee52c9..c2b874c61a77f 100644 --- a/src/test/run-pass/builtin-superkinds-capabilities-xc.rs +++ b/src/test/run-pass/builtin-superkinds-capabilities-xc.rs @@ -20,8 +20,8 @@ use trait_superkinds_in_metadata::{RequiresRequiresShareAndSend, RequiresShare}; #[deriving(PartialEq)] struct X(T); -impl RequiresShare for X { } -impl RequiresRequiresShareAndSend for X { } +impl RequiresShare for X { } +impl RequiresRequiresShareAndSend for X { } fn foo(val: T, chan: Sender) { chan.send(val); diff --git a/src/test/run-pass/builtin-superkinds-in-metadata.rs b/src/test/run-pass/builtin-superkinds-in-metadata.rs index ba57f095e1a99..683e7ece8717d 100644 --- a/src/test/run-pass/builtin-superkinds-in-metadata.rs +++ b/src/test/run-pass/builtin-superkinds-in-metadata.rs @@ -19,9 +19,9 @@ use trait_superkinds_in_metadata::{RequiresCopy}; struct X(T); -impl RequiresShare for X { } +impl RequiresShare for X { } -impl RequiresRequiresShareAndSend for X { } +impl RequiresRequiresShareAndSend for X { } impl RequiresCopy for X { } diff --git a/src/test/run-pass/closure-syntax.rs b/src/test/run-pass/closure-syntax.rs index df7d59e25608b..7b8d1dd7576b9 100644 --- a/src/test/run-pass/closure-syntax.rs +++ b/src/test/run-pass/closure-syntax.rs @@ -28,11 +28,11 @@ struct Foo<'a> { a: ||: 'a, b: ||: 'static, c: <'b>||: 'a, - d: ||: 'a + Share, - e: <'b>|int|: 'a + Share -> &'b f32, + d: ||: 'a + Sync, + e: <'b>|int|: 'a + Sync -> &'b f32, f: proc(), - g: proc(): 'static + Share, - h: proc<'b>(int): Share -> &'b f32, + g: proc(): 'static + Sync, + h: proc<'b>(int): Sync -> &'b f32, } fn f<'a>(a: &'a int, f: <'b>|&'b int| -> &'b int) -> &'a int { @@ -54,14 +54,14 @@ fn bar<'b>() { foo::<|| -> ()>(); foo::<||:>(); foo::<||:'b>(); - foo::<||:'b + Share>(); - foo::<||:Share>(); - foo::< <'a>|int, f32, &'a int|:'b + Share -> &'a int>(); + foo::<||:'b + Sync>(); + foo::<||:Sync>(); + foo::< <'a>|int, f32, &'a int|:'b + Sync -> &'a int>(); foo::(); foo:: ()>(); foo::(); - foo::(); - foo::(int, f32, &'a int):'static + Share -> &'a int>(); + foo::(); + foo::(int, f32, &'a int):'static + Sync -> &'a int>(); foo::<<'a>||>(); diff --git a/src/test/run-pass/const-bound.rs b/src/test/run-pass/const-bound.rs index 08912419b5c9f..e24bc1dbff9d5 100644 --- a/src/test/run-pass/const-bound.rs +++ b/src/test/run-pass/const-bound.rs @@ -12,7 +12,7 @@ // are const. -fn foo(x: T) -> T { x } +fn foo(x: T) -> T { x } struct F { field: int } diff --git a/src/test/run-pass/deriving-bounds.rs b/src/test/run-pass/deriving-bounds.rs index ad7ded215af78..d120b8030c1cf 100644 --- a/src/test/run-pass/deriving-bounds.rs +++ b/src/test/run-pass/deriving-bounds.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[deriving(Share,Send,Copy)] +#[deriving(Sync,Send,Copy)] struct Test; pub fn main() {} diff --git a/src/test/run-pass/issue-2611-3.rs b/src/test/run-pass/issue-2611-3.rs index f48a49a15eb3d..8a9e2d28776a7 100644 --- a/src/test/run-pass/issue-2611-3.rs +++ b/src/test/run-pass/issue-2611-3.rs @@ -12,7 +12,7 @@ // than the traits require. trait A { - fn b(x: C) -> C; + fn b(x: C) -> C; } struct E { diff --git a/src/test/run-pass/parameterized-trait-with-bounds.rs b/src/test/run-pass/parameterized-trait-with-bounds.rs index fbc2829816567..339c9e3c490c7 100644 --- a/src/test/run-pass/parameterized-trait-with-bounds.rs +++ b/src/test/run-pass/parameterized-trait-with-bounds.rs @@ -20,7 +20,7 @@ mod foo { } fn foo1(_: &A + Send) {} -fn foo2(_: Box + Send + Share>) {} +fn foo2(_: Box + Send + Sync>) {} fn foo3(_: Box + 'static>) {} fn foo4<'a, T>(_: Box + 'static + Send>) {} fn foo5<'a, T>(_: Box + 'static + Send>) {} diff --git a/src/test/run-pass/proc-bounds.rs b/src/test/run-pass/proc-bounds.rs index 8968b700540d5..7241b0b88b96b 100644 --- a/src/test/run-pass/proc-bounds.rs +++ b/src/test/run-pass/proc-bounds.rs @@ -12,18 +12,18 @@ fn foo() {} fn bar(_: T) {} fn is_send() {} -fn is_freeze() {} +fn is_freeze() {} fn is_static() {} pub fn main() { foo::(); foo::(); foo::(); - foo::(); - foo::(); + foo::(); + foo::(); is_send::(); - is_freeze::(); + is_freeze::(); is_static::(); diff --git a/src/test/run-pass/trait-bounds-basic.rs b/src/test/run-pass/trait-bounds-basic.rs index 013a8dcf60e7a..d03496403ad2a 100644 --- a/src/test/run-pass/trait-bounds-basic.rs +++ b/src/test/run-pass/trait-bounds-basic.rs @@ -15,7 +15,7 @@ trait Foo { fn b(_x: Box) { } -fn c(x: Box) { +fn c(x: Box) { e(x); } diff --git a/src/test/run-pass/trait-bounds-in-arc.rs b/src/test/run-pass/trait-bounds-in-arc.rs index cfe9a772b2ee8..50d3531b632f4 100644 --- a/src/test/run-pass/trait-bounds-in-arc.rs +++ b/src/test/run-pass/trait-bounds-in-arc.rs @@ -71,10 +71,10 @@ pub fn main() { swim_speed: 998, name: "alec_guinness".to_string(), }; - let arc = Arc::new(vec!(box catte as Box, - box dogge1 as Box, - box fishe as Box, - box dogge2 as Box)); + let arc = Arc::new(vec!(box catte as Box, + box dogge1 as Box, + box fishe as Box, + box dogge2 as Box)); let (tx1, rx1) = channel(); let arc1 = arc.clone(); task::spawn(proc() { check_legs(arc1); tx1.send(()); }); @@ -89,21 +89,21 @@ pub fn main() { rx3.recv(); } -fn check_legs(arc: Arc>>) { +fn check_legs(arc: Arc>>) { let mut legs = 0; for pet in arc.iter() { legs += pet.num_legs(); } assert!(legs == 12); } -fn check_names(arc: Arc>>) { +fn check_names(arc: Arc>>) { for pet in arc.iter() { pet.name(|name| { assert!(name.as_bytes()[0] == 'a' as u8 && name.as_bytes()[1] == 'l' as u8); }) } } -fn check_pedigree(arc: Arc>>) { +fn check_pedigree(arc: Arc>>) { for pet in arc.iter() { assert!(pet.of_good_pedigree()); }