use core::fmt::{self, Show};
use core::cmp::{Eq, Ord, PartialEq, PartialOrd, Ordering};
use core::default::Default;
-use core::markers::{Sync, Send};
+use core::marker::{Sync, Send};
use core::mem::{min_align_of, size_of, drop};
use core::mem;
use core::nonzero::NonZero;
use core::default::Default;
use core::fmt;
use core::hash::{self, Hash};
-use core::markers::Sized;
+use core::marker::Sized;
use core::mem;
use core::option::Option;
use core::ptr::Unique;
use core::default::Default;
use core::fmt;
use core::hash::{self, Hash};
-use core::markers;
+use core::marker;
use core::mem::{transmute, min_align_of, size_of, forget};
use core::nonzero::NonZero;
use core::ops::{Deref, Drop};
// FIXME #12808: strange names to try to avoid interfering with field accesses of the contained
// type via Deref
_ptr: NonZero<*mut RcBox<T>>,
- _nosend: markers::NoSend,
- _noshare: markers::NoSync
+ _nosend: marker::NoSend,
+ _noshare: marker::NoSync
}
impl<T> Rc<T> {
strong: Cell::new(1),
weak: Cell::new(1)
})),
- _nosend: markers::NoSend,
- _noshare: markers::NoSync
+ _nosend: marker::NoSend,
+ _noshare: marker::NoSync
}
}
}
self.inc_weak();
Weak {
_ptr: self._ptr,
- _nosend: markers::NoSend,
- _noshare: markers::NoSync
+ _nosend: marker::NoSend,
+ _noshare: marker::NoSync
}
}
}
#[inline]
fn clone(&self) -> Rc<T> {
self.inc_strong();
- Rc { _ptr: self._ptr, _nosend: markers::NoSend, _noshare: markers::NoSync }
+ Rc { _ptr: self._ptr, _nosend: marker::NoSend, _noshare: marker::NoSync }
}
}
// FIXME #12808: strange names to try to avoid interfering with
// field accesses of the contained type via Deref
_ptr: NonZero<*mut RcBox<T>>,
- _nosend: markers::NoSend,
- _noshare: markers::NoSync
+ _nosend: marker::NoSend,
+ _noshare: marker::NoSync
}
#[experimental = "Weak pointers may not belong in this module."]
None
} else {
self.inc_strong();
- Some(Rc { _ptr: self._ptr, _nosend: markers::NoSend, _noshare: markers::NoSync })
+ Some(Rc { _ptr: self._ptr, _nosend: marker::NoSend, _noshare: marker::NoSync })
}
}
}
#[inline]
fn clone(&self) -> Weak<T> {
self.inc_weak();
- Weak { _ptr: self._ptr, _nosend: markers::NoSend, _noshare: markers::NoSync }
+ Weak { _ptr: self._ptr, _nosend: marker::NoSend, _noshare: marker::NoSync }
}
}
/// boilerplate gets cut out.
mod stack {
use core::prelude::*;
- use core::markers;
+ use core::marker;
use core::mem;
use core::ops::{Deref, DerefMut};
use super::BTreeMap;
/// where `&'static` can be used in any function expecting any lifetime reference.
pub struct IdRef<'id, T: 'id> {
inner: &'id mut T,
- marker: markers::InvariantLifetime<'id>
+ marker: marker::InvariantLifetime<'id>
}
impl<'id, T> Deref for IdRef<'id, T> {
pub struct Pusher<'id, 'a, K:'a, V:'a> {
map: &'a mut BTreeMap<K, V>,
stack: Stack<K, V>,
- marker: markers::InvariantLifetime<'id>
+ marker: marker::InvariantLifetime<'id>
}
impl<'a, K, V> PartialSearchStack<'a, K, V> {
let pusher = Pusher {
map: self.map,
stack: self.stack,
- marker: markers::InvariantLifetime
+ marker: marker::InvariantLifetime
};
let node = IdRef {
inner: unsafe { &mut *self.next },
- marker: markers::InvariantLifetime
+ marker: marker::InvariantLifetime
};
closure(pusher, node)
pub use core::clone; // deriving(Clone)
pub use core::cmp; // deriving(Eq, Ord, etc.)
#[cfg(stage0)]
- pub use core::markers as kinds;
- pub use core::markers; // deriving(Copy)
+ pub use core::marker as kinds;
+ pub use core::marker; // deriving(Copy)
pub use core::hash; // deriving(Hash)
}
pub use core::iter::{FromIterator, Extend, IteratorExt};
pub use core::iter::{Iterator, DoubleEndedIterator, RandomAccessIterator};
pub use core::iter::{ExactSizeIterator};
- pub use core::markers::{Copy, Send, Sized, Sync};
+ pub use core::marker::{Copy, Send, Sized, Sync};
pub use core::mem::drop;
pub use core::ops::{Drop, Fn, FnMut, FnOnce};
pub use core::option::Option;
use core::default::Default;
use core::fmt;
use core::iter::{self, repeat, FromIterator, RandomAccessIterator};
-use core::markers;
+use core::marker;
use core::mem;
use core::num::{Int, UnsignedInt};
use core::ops::{Index, IndexMut};
head: self.head,
cap: self.cap,
ptr: self.ptr,
- marker: markers::ContravariantLifetime::<'a>,
+ marker: marker::ContravariantLifetime::<'a>,
}
}
tail: uint,
head: uint,
cap: uint,
- marker: markers::ContravariantLifetime<'a>,
+ marker: marker::ContravariantLifetime<'a>,
}
#[stable]
use core::cmp::{self, Ord, PartialEq};
use core::iter::{Iterator, IteratorExt};
use core::iter::{range, range_step, MultiplicativeIterator};
-use core::markers::Sized;
+use core::marker::Sized;
use core::mem::size_of;
use core::mem;
use core::ops::{FnMut, SliceMut};
use core::fmt;
use core::hash::{self, Hash};
use core::iter::{repeat, FromIterator};
-use core::markers::{ContravariantLifetime, InvariantType};
+use core::marker::{ContravariantLifetime, InvariantType};
use core::mem;
use core::nonzero::NonZero;
use core::num::{Int, UnsignedInt};
use clone::Clone;
use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
use fmt;
-use markers::Copy;
+use marker::Copy;
use ops::Deref;
use option::Option;
use self::Ordering::*;
-use markers::Sync;
+use marker::Sync;
use intrinsics;
use cell::UnsafeCell;
use clone::Clone;
use cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd};
use fmt;
-use markers::Sized;
+use marker::Sized;
use ops::Deref;
use option::Option;
use self::Cow::*;
use cmp::PartialEq;
use default::Default;
use fmt;
-use markers::{Copy, Send};
+use marker::{Copy, Send};
use ops::{Deref, DerefMut, Drop};
use option::Option;
use option::Option::{None, Some};
///
/// ```rust
/// use std::cell::UnsafeCell;
-/// use std::markers;
+/// use std::marker;
///
/// struct NotThreadSafe<T> {
/// value: UnsafeCell<T>,
-/// marker: markers::NoSync
+/// marker: marker::NoSync
/// }
/// ```
///
#![stable]
-use markers::Sized;
+use marker::Sized;
/// A common trait for cloning an object.
#[stable]
use self::Ordering::*;
-use markers::Sized;
+use marker::Sized;
use option::Option::{self, Some, None};
/// Trait for equality comparisons which are [partial equivalence relations](
mod impls {
use cmp::{PartialOrd, Ord, PartialEq, Eq, Ordering};
use cmp::Ordering::{Less, Greater, Equal};
- use markers::Sized;
+ use marker::Sized;
use option::Option;
use option::Option::{Some, None};
use any;
use cell::{Cell, Ref, RefMut};
use iter::{Iterator, IteratorExt, range};
-use markers::{Copy, Sized};
+use marker::{Copy, Sized};
use mem;
use option::Option;
use option::Option::{Some, None};
use ops::{Add, Deref, FnMut};
use option::Option;
use option::Option::{Some, None};
-use std::markers::Sized;
+use std::marker::Sized;
use uint;
/// An interface for dealing with "external iterators". These types of iterators
/* Core language traits */
-pub mod markers;
+pub mod marker;
pub mod ops;
pub mod cmp;
pub mod clone;
pub use clone;
pub use cmp;
#[cfg(stage0)]
- pub use markers as kinds;
- pub use markers;
+ pub use marker as kinds;
+ pub use marker;
pub use option;
pub use fmt;
pub use hash;
--- /dev/null
+// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! Primitive traits and marker types representing basic 'kinds' of types.
+//!
+//! Rust types can be classified in various useful ways according to
+//! intrinsic properties of the type. These classifications, often called
+//! 'kinds', are represented as traits.
+//!
+//! They cannot be implemented by user code, but are instead implemented
+//! by the compiler automatically for the types to which they apply.
+//!
+//! Marker types are special types that are used with unsafe code to
+//! inform the compiler of special constraints. Marker types should
+//! only be needed when you are creating an abstraction that is
+//! implemented using unsafe code. In that case, you may want to embed
+//! some of the marker types below into your type.
+
+#![stable]
+
+use clone::Clone;
+
+/// Types able to be transferred across task boundaries.
+#[unstable = "will be overhauled with new lifetime rules; see RFC 458"]
+#[lang="send"]
+pub unsafe trait Send: 'static {
+ // empty.
+}
+
+/// Types with a constant size known at compile-time.
+#[stable]
+#[lang="sized"]
+pub trait Sized {
+ // Empty.
+}
+
+/// Types that can be copied by simply copying bits (i.e. `memcpy`).
+#[stable]
+#[lang="copy"]
+pub trait Copy {
+ // Empty.
+}
+
+/// Types that can be safely shared between tasks when aliased.
+///
+/// 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
+/// `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<T>`, `Vec<T>` and most other
+/// 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
+/// `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 `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<T>` can be `.set`, and do not ensure data races are
+/// 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<T>` can clone a new
+/// reference, which modifies the reference counts in a non-atomic
+/// way.
+///
+/// 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 `Sync`.
+///
+/// Users writing their own types with interior mutability (or anything
+/// else that is not thread-safe) should use the `NoSync` marker type
+/// (from `std::marker`) to ensure that the compiler doesn't
+/// 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).
+#[unstable = "will be overhauled with new lifetime rules; see RFC 458"]
+#[lang="sync"]
+pub unsafe trait Sync {
+ // Empty
+}
+
+
+/// 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
+/// into memory and read from, even though that may not be apparent.
+///
+/// For more information about variance, refer to this Wikipedia
+/// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
+///
+/// *Note:* It is very unusual to have to add a covariant constraint.
+/// If you are not sure, you probably want to use `InvariantType`.
+///
+/// # Example
+///
+/// Given a struct `S` that includes a type parameter `T`
+/// but does not actually *reference* that type parameter:
+///
+/// ```ignore
+/// use std::mem;
+///
+/// struct S<T> { x: *() }
+/// fn get<T>(s: &S<T>) -> T {
+/// unsafe {
+/// let x: *T = mem::transmute(s.x);
+/// *x
+/// }
+/// }
+/// ```
+///
+/// The type system would currently infer that the value of
+/// the type parameter `T` is irrelevant, and hence a `S<int>` is
+/// a subtype of `S<Box<int>>` (or, for that matter, `S<U>` for
+/// any `U`). But this is incorrect because `get()` converts the
+/// `*()` into a `*T` and reads from it. Therefore, we should include the
+/// a marker field `CovariantType<T>` to inform the type checker that
+/// `S<T>` is a subtype of `S<U>` if `T` is a subtype of `U`
+/// (for example, `S<&'static int>` is a subtype of `S<&'a int>`
+/// for some lifetime `'a`, but not the other way around).
+#[unstable = "likely to change with new variance strategy"]
+#[lang="covariant_type"]
+#[derive(PartialEq, Eq, PartialOrd, Ord)]
+pub struct CovariantType<T: ?Sized>;
+
+impl<T: ?Sized> Copy for CovariantType<T> {}
+impl<T: ?Sized> Clone for CovariantType<T> {
+ fn clone(&self) -> CovariantType<T> { *self }
+}
+
+/// A marker type whose type parameter `T` is considered to be
+/// contravariant with respect to the type itself. This is (typically)
+/// used to indicate that an instance of the type `T` will be consumed
+/// (but not read from), even though that may not be apparent.
+///
+/// For more information about variance, refer to this Wikipedia
+/// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
+///
+/// *Note:* It is very unusual to have to add a contravariant constraint.
+/// If you are not sure, you probably want to use `InvariantType`.
+///
+/// # Example
+///
+/// Given a struct `S` that includes a type parameter `T`
+/// but does not actually *reference* that type parameter:
+///
+/// ```
+/// use std::mem;
+///
+/// struct S<T> { x: *const () }
+/// fn get<T>(s: &S<T>, v: T) {
+/// unsafe {
+/// let x: fn(T) = mem::transmute(s.x);
+/// x(v)
+/// }
+/// }
+/// ```
+///
+/// The type system would currently infer that the value of
+/// the type parameter `T` is irrelevant, and hence a `S<int>` is
+/// a subtype of `S<Box<int>>` (or, for that matter, `S<U>` for
+/// any `U`). But this is incorrect because `get()` converts the
+/// `*()` into a `fn(T)` and then passes a value of type `T` to it.
+///
+/// Supplying a `ContravariantType` marker would correct the
+/// problem, because it would mark `S` so that `S<T>` is only a
+/// subtype of `S<U>` if `U` is a subtype of `T`; given that the
+/// function requires arguments of type `T`, it must also accept
+/// arguments of type `U`, hence such a conversion is safe.
+#[unstable = "likely to change with new variance strategy"]
+#[lang="contravariant_type"]
+#[derive(PartialEq, Eq, PartialOrd, Ord)]
+pub struct ContravariantType<T: ?Sized>;
+
+impl<T: ?Sized> Copy for ContravariantType<T> {}
+impl<T: ?Sized> Clone for ContravariantType<T> {
+ fn clone(&self) -> ContravariantType<T> { *self }
+}
+
+/// A marker type whose type parameter `T` is considered to be
+/// invariant with respect to the type itself. This is (typically)
+/// used to indicate that instances of the type `T` may be read or
+/// written, even though that may not be apparent.
+///
+/// For more information about variance, refer to this Wikipedia
+/// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
+///
+/// # Example
+///
+/// The Cell type is an example which uses unsafe code to achieve
+/// "interior" mutability:
+///
+/// ```
+/// pub struct Cell<T> { value: T }
+/// # fn main() {}
+/// ```
+///
+/// The type system would infer that `value` is only read here and
+/// never written, but in fact `Cell` uses unsafe code to achieve
+/// interior mutability.
+#[unstable = "likely to change with new variance strategy"]
+#[lang="invariant_type"]
+#[derive(PartialEq, Eq, PartialOrd, Ord)]
+pub struct InvariantType<T: ?Sized>;
+
+#[unstable = "likely to change with new variance strategy"]
+impl<T: ?Sized> Copy for InvariantType<T> {}
+#[unstable = "likely to change with new variance strategy"]
+impl<T: ?Sized> Clone for InvariantType<T> {
+ fn clone(&self) -> InvariantType<T> { *self }
+}
+
+/// As `CovariantType`, but for lifetime parameters. Using
+/// `CovariantLifetime<'a>` indicates that it is ok to substitute
+/// a *longer* lifetime for `'a` than the one you originally
+/// started with (e.g., you could convert any lifetime `'foo` to
+/// `'static`). You almost certainly want `ContravariantLifetime`
+/// instead, or possibly `InvariantLifetime`. The only case where
+/// it would be appropriate is that you have a (type-casted, and
+/// hence hidden from the type system) function pointer with a
+/// signature like `fn(&'a T)` (and no other uses of `'a`). In
+/// this case, it is ok to substitute a larger lifetime for `'a`
+/// (e.g., `fn(&'static T)`), because the function is only
+/// becoming more selective in terms of what it accepts as
+/// argument.
+///
+/// For more information about variance, refer to this Wikipedia
+/// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
+#[unstable = "likely to change with new variance strategy"]
+#[lang="covariant_lifetime"]
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
+pub struct CovariantLifetime<'a>;
+
+/// As `ContravariantType`, but for lifetime parameters. Using
+/// `ContravariantLifetime<'a>` indicates that it is ok to
+/// substitute a *shorter* lifetime for `'a` than the one you
+/// originally started with (e.g., you could convert `'static` to
+/// any lifetime `'foo`). This is appropriate for cases where you
+/// have an unsafe pointer that is actually a pointer into some
+/// memory with lifetime `'a`, and thus you want to limit the
+/// lifetime of your data structure to `'a`. An example of where
+/// this is used is the iterator for vectors.
+///
+/// For more information about variance, refer to this Wikipedia
+/// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
+#[unstable = "likely to change with new variance strategy"]
+#[lang="contravariant_lifetime"]
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
+pub struct ContravariantLifetime<'a>;
+
+/// As `InvariantType`, but for lifetime parameters. Using
+/// `InvariantLifetime<'a>` indicates that it is not ok to
+/// substitute any other lifetime for `'a` besides its original
+/// value. This is appropriate for cases where you have an unsafe
+/// pointer that is actually a pointer into memory with lifetime `'a`,
+/// and this pointer is itself stored in an inherently mutable
+/// location (such as a `Cell`).
+#[unstable = "likely to change with new variance strategy"]
+#[lang="invariant_lifetime"]
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
+pub struct InvariantLifetime<'a>;
+
+/// A type which is considered "not sendable", meaning that it cannot
+/// be safely sent between tasks, even if it is owned. This is
+/// typically embedded in other types, such as `Gc`, to ensure that
+/// their instances remain thread-local.
+#[unstable = "likely to change with new variance strategy"]
+#[lang="no_send_bound"]
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
+pub struct NoSend;
+
+/// A type which is considered "not POD", meaning that it is not
+/// implicitly copyable. This is typically embedded in other types to
+/// ensure that they are never copied, even if they lack a destructor.
+#[unstable = "likely to change with new variance strategy"]
+#[lang="no_copy_bound"]
+#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
+#[allow(missing_copy_implementations)]
+pub struct NoCopy;
+
+/// A type which is considered "not sync", meaning that
+/// its contents are not threadsafe, hence they cannot be
+/// shared between tasks.
+#[unstable = "likely to change with new variance strategy"]
+#[lang="no_sync_bound"]
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
+pub struct NoSync;
+
+/// A type which is considered managed by the GC. This is typically
+/// embedded in other types.
+#[unstable = "likely to change with new variance strategy"]
+#[lang="managed_bound"]
+#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
+#[allow(missing_copy_implementations)]
+pub struct Managed;
+++ /dev/null
-// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Primitive traits and marker types representing basic 'kinds' of types.
-//!
-//! Rust types can be classified in various useful ways according to
-//! intrinsic properties of the type. These classifications, often called
-//! 'kinds', are represented as traits.
-//!
-//! They cannot be implemented by user code, but are instead implemented
-//! by the compiler automatically for the types to which they apply.
-//!
-//! Marker types are special types that are used with unsafe code to
-//! inform the compiler of special constraints. Marker types should
-//! only be needed when you are creating an abstraction that is
-//! implemented using unsafe code. In that case, you may want to embed
-//! some of the marker types below into your type.
-
-#![stable]
-
-use clone::Clone;
-
-/// Types able to be transferred across task boundaries.
-#[unstable = "will be overhauled with new lifetime rules; see RFC 458"]
-#[lang="send"]
-pub unsafe trait Send: 'static {
- // empty.
-}
-
-/// Types with a constant size known at compile-time.
-#[stable]
-#[lang="sized"]
-pub trait Sized {
- // Empty.
-}
-
-/// Types that can be copied by simply copying bits (i.e. `memcpy`).
-#[stable]
-#[lang="copy"]
-pub trait Copy {
- // Empty.
-}
-
-/// Types that can be safely shared between tasks when aliased.
-///
-/// 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
-/// `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<T>`, `Vec<T>` and most other
-/// 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
-/// `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 `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<T>` can be `.set`, and do not ensure data races are
-/// 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<T>` can clone a new
-/// reference, which modifies the reference counts in a non-atomic
-/// way.
-///
-/// 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 `Sync`.
-///
-/// Users writing their own types with interior mutability (or anything
-/// else that is not thread-safe) should use the `NoSync` marker type
-/// (from `std::markers`) to ensure that the compiler doesn't
-/// 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).
-#[unstable = "will be overhauled with new lifetime rules; see RFC 458"]
-#[lang="sync"]
-pub unsafe trait Sync {
- // Empty
-}
-
-
-/// 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
-/// into memory and read from, even though that may not be apparent.
-///
-/// For more information about variance, refer to this Wikipedia
-/// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
-///
-/// *Note:* It is very unusual to have to add a covariant constraint.
-/// If you are not sure, you probably want to use `InvariantType`.
-///
-/// # Example
-///
-/// Given a struct `S` that includes a type parameter `T`
-/// but does not actually *reference* that type parameter:
-///
-/// ```ignore
-/// use std::mem;
-///
-/// struct S<T> { x: *() }
-/// fn get<T>(s: &S<T>) -> T {
-/// unsafe {
-/// let x: *T = mem::transmute(s.x);
-/// *x
-/// }
-/// }
-/// ```
-///
-/// The type system would currently infer that the value of
-/// the type parameter `T` is irrelevant, and hence a `S<int>` is
-/// a subtype of `S<Box<int>>` (or, for that matter, `S<U>` for
-/// any `U`). But this is incorrect because `get()` converts the
-/// `*()` into a `*T` and reads from it. Therefore, we should include the
-/// a marker field `CovariantType<T>` to inform the type checker that
-/// `S<T>` is a subtype of `S<U>` if `T` is a subtype of `U`
-/// (for example, `S<&'static int>` is a subtype of `S<&'a int>`
-/// for some lifetime `'a`, but not the other way around).
-#[unstable = "likely to change with new variance strategy"]
-#[lang="covariant_type"]
-#[derive(PartialEq, Eq, PartialOrd, Ord)]
-pub struct CovariantType<Sized? T>;
-
-impl<Sized? T> Copy for CovariantType<T> {}
-impl<Sized? T> Clone for CovariantType<T> {
- fn clone(&self) -> CovariantType<T> { *self }
-}
-
-/// A marker type whose type parameter `T` is considered to be
-/// contravariant with respect to the type itself. This is (typically)
-/// used to indicate that an instance of the type `T` will be consumed
-/// (but not read from), even though that may not be apparent.
-///
-/// For more information about variance, refer to this Wikipedia
-/// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
-///
-/// *Note:* It is very unusual to have to add a contravariant constraint.
-/// If you are not sure, you probably want to use `InvariantType`.
-///
-/// # Example
-///
-/// Given a struct `S` that includes a type parameter `T`
-/// but does not actually *reference* that type parameter:
-///
-/// ```
-/// use std::mem;
-///
-/// struct S<T> { x: *const () }
-/// fn get<T>(s: &S<T>, v: T) {
-/// unsafe {
-/// let x: fn(T) = mem::transmute(s.x);
-/// x(v)
-/// }
-/// }
-/// ```
-///
-/// The type system would currently infer that the value of
-/// the type parameter `T` is irrelevant, and hence a `S<int>` is
-/// a subtype of `S<Box<int>>` (or, for that matter, `S<U>` for
-/// any `U`). But this is incorrect because `get()` converts the
-/// `*()` into a `fn(T)` and then passes a value of type `T` to it.
-///
-/// Supplying a `ContravariantType` marker would correct the
-/// problem, because it would mark `S` so that `S<T>` is only a
-/// subtype of `S<U>` if `U` is a subtype of `T`; given that the
-/// function requires arguments of type `T`, it must also accept
-/// arguments of type `U`, hence such a conversion is safe.
-#[unstable = "likely to change with new variance strategy"]
-#[lang="contravariant_type"]
-#[derive(PartialEq, Eq, PartialOrd, Ord)]
-pub struct ContravariantType<T: ?Sized>;
-
-impl<T: ?Sized> Copy for ContravariantType<T> {}
-impl<T: ?Sized> Clone for ContravariantType<T> {
- fn clone(&self) -> ContravariantType<T> { *self }
-}
-
-/// A marker type whose type parameter `T` is considered to be
-/// invariant with respect to the type itself. This is (typically)
-/// used to indicate that instances of the type `T` may be read or
-/// written, even though that may not be apparent.
-///
-/// For more information about variance, refer to this Wikipedia
-/// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
-///
-/// # Example
-///
-/// The Cell type is an example which uses unsafe code to achieve
-/// "interior" mutability:
-///
-/// ```
-/// pub struct Cell<T> { value: T }
-/// # fn main() {}
-/// ```
-///
-/// The type system would infer that `value` is only read here and
-/// never written, but in fact `Cell` uses unsafe code to achieve
-/// interior mutability.
-#[unstable = "likely to change with new variance strategy"]
-#[lang="invariant_type"]
-#[derive(PartialEq, Eq, PartialOrd, Ord)]
-pub struct InvariantType<T: ?Sized>;
-
-#[unstable = "likely to change with new variance strategy"]
-impl<T: ?Sized> Copy for InvariantType<T> {}
-#[unstable = "likely to change with new variance strategy"]
-impl<T: ?Sized> Clone for InvariantType<T> {
- fn clone(&self) -> InvariantType<T> { *self }
-}
-
-/// As `CovariantType`, but for lifetime parameters. Using
-/// `CovariantLifetime<'a>` indicates that it is ok to substitute
-/// a *longer* lifetime for `'a` than the one you originally
-/// started with (e.g., you could convert any lifetime `'foo` to
-/// `'static`). You almost certainly want `ContravariantLifetime`
-/// instead, or possibly `InvariantLifetime`. The only case where
-/// it would be appropriate is that you have a (type-casted, and
-/// hence hidden from the type system) function pointer with a
-/// signature like `fn(&'a T)` (and no other uses of `'a`). In
-/// this case, it is ok to substitute a larger lifetime for `'a`
-/// (e.g., `fn(&'static T)`), because the function is only
-/// becoming more selective in terms of what it accepts as
-/// argument.
-///
-/// For more information about variance, refer to this Wikipedia
-/// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
-#[unstable = "likely to change with new variance strategy"]
-#[lang="covariant_lifetime"]
-#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
-pub struct CovariantLifetime<'a>;
-
-/// As `ContravariantType`, but for lifetime parameters. Using
-/// `ContravariantLifetime<'a>` indicates that it is ok to
-/// substitute a *shorter* lifetime for `'a` than the one you
-/// originally started with (e.g., you could convert `'static` to
-/// any lifetime `'foo`). This is appropriate for cases where you
-/// have an unsafe pointer that is actually a pointer into some
-/// memory with lifetime `'a`, and thus you want to limit the
-/// lifetime of your data structure to `'a`. An example of where
-/// this is used is the iterator for vectors.
-///
-/// For more information about variance, refer to this Wikipedia
-/// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
-#[unstable = "likely to change with new variance strategy"]
-#[lang="contravariant_lifetime"]
-#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
-pub struct ContravariantLifetime<'a>;
-
-/// As `InvariantType`, but for lifetime parameters. Using
-/// `InvariantLifetime<'a>` indicates that it is not ok to
-/// substitute any other lifetime for `'a` besides its original
-/// value. This is appropriate for cases where you have an unsafe
-/// pointer that is actually a pointer into memory with lifetime `'a`,
-/// and this pointer is itself stored in an inherently mutable
-/// location (such as a `Cell`).
-#[unstable = "likely to change with new variance strategy"]
-#[lang="invariant_lifetime"]
-#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
-pub struct InvariantLifetime<'a>;
-
-/// A type which is considered "not sendable", meaning that it cannot
-/// be safely sent between tasks, even if it is owned. This is
-/// typically embedded in other types, such as `Gc`, to ensure that
-/// their instances remain thread-local.
-#[unstable = "likely to change with new variance strategy"]
-#[lang="no_send_bound"]
-#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
-pub struct NoSend;
-
-/// A type which is considered "not POD", meaning that it is not
-/// implicitly copyable. This is typically embedded in other types to
-/// ensure that they are never copied, even if they lack a destructor.
-#[unstable = "likely to change with new variance strategy"]
-#[lang="no_copy_bound"]
-#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
-#[allow(missing_copy_implementations)]
-pub struct NoCopy;
-
-/// A type which is considered "not sync", meaning that
-/// its contents are not threadsafe, hence they cannot be
-/// shared between tasks.
-#[unstable = "likely to change with new variance strategy"]
-#[lang="no_sync_bound"]
-#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
-pub struct NoSync;
-
-/// A type which is considered managed by the GC. This is typically
-/// embedded in other types.
-#[unstable = "likely to change with new variance strategy"]
-#[lang="managed_bound"]
-#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
-#[allow(missing_copy_implementations)]
-pub struct Managed;
#![stable]
-use markers::Sized;
+use marker::Sized;
use intrinsics;
use ptr;
use cmp::{PartialOrd, Ord};
use intrinsics;
use iter::IteratorExt;
-use markers::Copy;
+use marker::Copy;
use mem::size_of;
use ops::{Add, Sub, Mul, Div, Rem, Neg};
use ops::{Not, BitAnd, BitOr, BitXor, Shl, Shr};
/// A generic trait for converting a number to a value.
#[experimental = "trait is likely to be removed"]
-pub trait FromPrimitive : ::markers::Sized {
+pub trait FromPrimitive : ::marker::Sized {
/// Convert an `int` to return an optional value of this type. If the
/// value cannot be represented by this value, the `None` is returned.
#[inline]
use clone::Clone;
use iter::{Step, Iterator,DoubleEndedIterator,ExactSizeIterator};
-use markers::Sized;
+use marker::Sized;
use option::Option::{self, Some, None};
/// The `Drop` trait is used to run some code when a value goes out of scope. This
//! ```
// Reexported core operators
-pub use markers::{Copy, Send, Sized, Sync};
+pub use marker::{Copy, Send, Sized, Sync};
pub use ops::{Drop, Fn, FnMut, FnOnce};
// Reexported functions
use clone::Clone;
use intrinsics;
use option::Option::{self, Some, None};
-use markers::{Send, Sized, Sync};
+use marker::{Send, Sized, Sync};
use cmp::{PartialEq, Eq, Ord, PartialOrd};
use cmp::Ordering::{self, Less, Equal, Greater};
//!
//! Their definition should always match the ABI defined in `rustc::back::abi`.
-use markers::Copy;
+use marker::Copy;
use mem;
/// The representation of a Rust slice
use cmp;
use default::Default;
use iter::*;
-use markers::Copy;
+use marker::Copy;
use num::Int;
use ops::{FnMut, self};
use option::Option;
use ptr::PtrExt;
use mem;
use mem::size_of;
-use markers::{Sized, self};
+use marker::{Sized, self};
use raw::Repr;
// Avoid conflicts with *both* the Slice trait (buggy) and the `slice::raw` module.
use raw::Slice as RawSlice;
if mem::size_of::<T>() == 0 {
Iter {ptr: p,
end: (p as uint + self.len()) as *const T,
- marker: markers::ContravariantLifetime::<'a>}
+ marker: marker::ContravariantLifetime::<'a>}
} else {
Iter {ptr: p,
end: p.offset(self.len() as int),
- marker: markers::ContravariantLifetime::<'a>}
+ marker: marker::ContravariantLifetime::<'a>}
}
}
}
if mem::size_of::<T>() == 0 {
IterMut {ptr: p,
end: (p as uint + self.len()) as *mut T,
- marker: markers::ContravariantLifetime::<'a>}
+ marker: marker::ContravariantLifetime::<'a>}
} else {
IterMut {ptr: p,
end: p.offset(self.len() as int),
- marker: markers::ContravariantLifetime::<'a>}
+ marker: marker::ContravariantLifetime::<'a>}
}
}
}
pub struct Iter<'a, T: 'a> {
ptr: *const T,
end: *const T,
- marker: markers::ContravariantLifetime<'a>
+ marker: marker::ContravariantLifetime<'a>
}
#[experimental]
pub struct IterMut<'a, T: 'a> {
ptr: *mut T,
end: *mut T,
- marker: markers::ContravariantLifetime<'a>,
+ marker: marker::ContravariantLifetime<'a>,
}
#[experimental]
use iter::range;
use iter::ExactSizeIterator;
use iter::{Map, Iterator, IteratorExt, DoubleEndedIterator};
-use markers::Sized;
+use marker::Sized;
use mem;
use num::Int;
use ops::{Fn, FnMut};
//! Types dealing with unsafe actions.
-use markers;
+use marker;
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use core::markers::Sized;
+use core::marker::Sized;
use std::mem;
use core::slice::SliceExt;
use core::fmt::Show;
use core::num::{NumCast, cast};
use core::ops::{Add, Sub, Mul, Div, Rem};
-use core::markers::Copy;
+use core::marker::Copy;
#[cfg_attr(stage0, macro_escape)]
#[cfg_attr(not(stage0), macro_use)]
// except according to those terms.
use core::option::*;
-use core::markers;
+use core::marker;
use core::mem;
use core::clone::Clone;
#[test] #[should_fail]
fn test_option_too_much_dance() {
- let mut y = Some(markers::NoCopy);
+ let mut y = Some(marker::NoCopy);
let _y2 = y.take().unwrap();
let _y3 = y.take().unwrap();
}
#[cfg(not(test))]
mod std {
#[cfg(stage0)]
- pub use core::markers as kinds;
- pub use core::markers;
+ pub use core::marker as kinds;
+ pub use core::marker;
}
pub use core::{option, fmt}; // panic!()
pub use core::clone; // derive Clone
#[cfg(stage0)]
- pub use core::markers as kinds;
- pub use core::markers;
+ pub use core::marker as kinds;
+ pub use core::marker;
}
#[cfg(test)]
use middle::ty::{MethodStatic, MethodStaticUnboxedClosure};
use util::ppaux::Repr;
-use std::markers;
+use std::marker;
use syntax::{ast, ast_util};
use syntax::ptr::P;
use syntax::codemap::Span;
Conflicting,
}
-impl<T> markers::Copy for TrackMatchMode<T> {}
+impl<T> marker::Copy for TrackMatchMode<T> {}
impl<T> TrackMatchMode<T> {
// Builds up the whole match mode for a pattern from its constituent
pub use self::VarValue::*;
-use std::markers;
+use std::marker;
use middle::ty::{expected_found, IntVarValue};
use middle::ty::{self, Ty};
/// made during the snapshot may either be *committed* or *rolled back*.
pub struct Snapshot<K> {
// Link snapshot to the key type `K` of the table.
- marker: markers::CovariantType<K>,
+ marker: marker::CovariantType<K>,
snapshot: sv::Snapshot,
}
/// Starts a new snapshot. Each snapshot must be either
/// rolled back or committed in a "LIFO" (stack) order.
pub fn snapshot(&mut self) -> Snapshot<K> {
- Snapshot { marker: markers::CovariantType::<K>,
+ Snapshot { marker: marker::CovariantType::<K>,
snapshot: self.values.start_snapshot() }
}
struct ConstraintContext<'a, 'tcx: 'a> {
terms_cx: TermsContext<'a, 'tcx>,
- // These are the def-id of the std::markers::InvariantType,
- // std::markers::InvariantLifetime, and so on. The arrays
+ // These are the def-id of the std::marker::InvariantType,
+ // std::marker::InvariantLifetime, and so on. The arrays
// are indexed by the `ParamKind` (type, lifetime, self). Note
// that there are no marker types for self, so the entries for
// self are always None.
use fmt::{self, Show};
use hash::{Hash, Hasher, RandomSipHasher};
use iter::{self, Iterator, IteratorExt, FromIterator, Extend, Map};
-use markers::Sized;
+use marker::Sized;
use mem::{self, replace};
use num::{Int, UnsignedInt};
use ops::{Deref, FnMut, Index, IndexMut};
use borrow::BorrowFrom;
use clone::Clone;
use cmp::{Eq, PartialEq};
-use core::markers::Sized;
+use core::marker::Sized;
use default::Default;
use fmt::Show;
use fmt;
use cmp;
use hash::{Hash, Hasher};
use iter::{Iterator, count};
-use markers::{Copy, Sized, self};
+use marker::{Copy, Sized, self};
use mem::{min_align_of, size_of};
use mem;
use num::{Int, UnsignedInt};
hashes: Unique<u64>,
// Because K/V do not appear directly in any of the types in the struct,
// inform rustc that in fact instances of K and V are reachable from here.
- marker: markers::CovariantType<(K,V)>,
+ marker: marker::CovariantType<(K,V)>,
}
struct RawBucket<K, V> {
size: 0,
capacity: 0,
hashes: Unique::null(),
- marker: markers::CovariantType,
+ marker: marker::CovariantType,
};
}
// No need for `checked_mul` before a more restrictive check performed
capacity: capacity,
size: 0,
hashes: Unique(hashes),
- marker: markers::CovariantType,
+ marker: marker::CovariantType,
}
}
hashes_end: unsafe {
self.hashes.0.offset(self.capacity as int)
},
- marker: markers::ContravariantLifetime,
+ marker: marker::ContravariantLifetime,
}
}
iter: RawBuckets {
raw: raw,
hashes_end: hashes_end,
- marker: markers::ContravariantLifetime,
+ marker: marker::ContravariantLifetime,
},
table: self,
}
iter: RawBuckets {
raw: raw,
hashes_end: hashes_end,
- marker: markers::ContravariantLifetime::<'static>,
+ marker: marker::ContravariantLifetime::<'static>,
},
table: self,
}
raw: raw_bucket.offset(self.capacity as int),
hashes_end: raw_bucket.hash,
elems_left: self.size,
- marker: markers::ContravariantLifetime,
+ marker: marker::ContravariantLifetime,
}
}
}
struct RawBuckets<'a, K, V> {
raw: RawBucket<K, V>,
hashes_end: *mut u64,
- marker: markers::ContravariantLifetime<'a>,
+ marker: marker::ContravariantLifetime<'a>,
}
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
RawBuckets {
raw: self.raw,
hashes_end: self.hashes_end,
- marker: markers::ContravariantLifetime,
+ marker: marker::ContravariantLifetime,
}
}
}
raw: RawBucket<K, V>,
hashes_end: *mut u64,
elems_left: uint,
- marker: markers::ContravariantLifetime<'a>,
+ marker: marker::ContravariantLifetime<'a>,
}
impl<'a, K, V> Iterator for RevMoveBuckets<'a, K, V> {
pub use core::hash::{Hash, Hasher, Writer, hash, sip};
-use core::markers::Sized;
+use core::marker::Sized;
use default::Default;
use rand::Rng;
use rand;
use fmt;
use int;
use iter::{Iterator, IteratorExt};
-use markers::Sized;
+use marker::Sized;
use mem::transmute;
use ops::FnOnce;
use option::Option;
use fmt;
use io::{Reader, Writer, IoResult, IoError, OtherIoError, Buffer,
standard_error, EndOfFile, LineBufferedWriter, BufferedReader};
-use markers::{Sync, Send};
+use marker::{Sync, Send};
use libc;
use mem;
use option::Option;
// Make std testable by not duplicating lang items. See #2912
#[cfg(test)] extern crate "std" as realstd;
-#[cfg(test)] pub use realstd::markers;
+#[cfg(test)] pub use realstd::marker;
#[cfg(test)] pub use realstd::ops;
#[cfg(test)] pub use realstd::cmp;
#[cfg(test)] pub use realstd::boxed;
pub use core::finally;
pub use core::intrinsics;
pub use core::iter;
-#[cfg(stage0)] #[cfg(not(test))] pub use core::markers as kinds;
-#[cfg(not(test))] pub use core::markers;
+#[cfg(stage0)] #[cfg(not(test))] pub use core::marker as kinds;
+#[cfg(not(test))] pub use core::marker;
pub use core::mem;
#[cfg(not(test))] pub use core::ops;
pub use core::ptr;
pub use cell; // used for tls!
pub use thread_local; // used for thread_local!
#[cfg(stage0)]
- pub use markers as kinds;
- pub use markers; // used for tls!
+ pub use marker as kinds;
+ pub use marker; // used for tls!
pub use ops; // used for bitflags!
// The test runner calls ::std::os::args() but really wants realstd
#[cfg(test)] use fmt::Show;
use ops::{Add, Sub, Mul, Div, Rem, Neg};
-use markers::Copy;
+use marker::Copy;
use clone::Clone;
use cmp::{PartialOrd, PartialEq};
use fmt;
use io::{IoResult, IoError};
use iter::{Iterator, IteratorExt};
-use markers::Copy;
+use marker::Copy;
use libc::{c_void, c_int, c_char};
use libc;
use boxed::Box;
#![experimental]
-use core::markers::Sized;
+use core::marker::Sized;
use ffi::CString;
use clone::Clone;
use fmt;
use io::Writer;
use iter::{AdditiveIterator, Extend};
use iter::{Iterator, IteratorExt, Map};
-use markers::Sized;
+use marker::Sized;
use option::Option::{self, Some, None};
use slice::{AsSlice, Split, SliceExt, SliceConcatExt};
use str::{self, FromStr, StrExt};
#![stable]
// Reexported core operators
-#[stable] #[doc(no_inline)] pub use markers::{Copy, Send, Sized, Sync};
+#[stable] #[doc(no_inline)] pub use marker::{Copy, Send, Sized, Sync};
#[stable] #[doc(no_inline)] pub use ops::{Drop, Fn, FnMut, FnOnce};
// Reexported functions
extern crate libc;
use io::{IoResult};
- use markers::Sync;
+ use marker::Sync;
use mem;
use os;
use rand::Rng;
#![allow(dead_code)]
-use markers::Send;
+use marker::Send;
use ops::FnOnce;
use sys;
use thunk::Thunk;
use thread::Thread;
use sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
use sync::Arc;
-use markers::{Sync, Send};
-use markers::{NoSend, NoSync};
+use marker::{Sync, Send};
+use marker::{NoSend, NoSync};
use mem;
use clone::Clone;
use sync::Arc;
use fmt;
-use markers;
+use marker;
use mem;
use cell::UnsafeCell;
pub struct SyncSender<T> {
inner: Arc<RacyCell<sync::Packet<T>>>,
// can't share in an arc
- _marker: markers::NoSync,
+ _marker: marker::NoSync,
}
/// An error returned from the `send` function on channels.
impl<T: Send> SyncSender<T> {
fn new(inner: Arc<RacyCell<sync::Packet<T>>>) -> SyncSender<T> {
- SyncSender { inner: inner, _marker: markers::NoSync }
+ SyncSender { inner: inner, _marker: marker::NoSync }
}
/// Sends a value on this synchronous channel.
use core::prelude::*;
use core::cell::Cell;
-use core::markers;
+use core::marker;
use core::mem;
use core::uint;
head: *mut Handle<'static, ()>,
tail: *mut Handle<'static, ()>,
next_id: Cell<uint>,
- marker1: markers::NoSend,
+ marker1: marker::NoSend,
}
/// A handle to a receiver which is currently a member of a `Select` set of
/// rather much easier through the `select!` macro.
pub fn new() -> Select {
Select {
- marker1: markers::NoSend,
+ marker1: marker::NoSend,
head: 0 as *mut Handle<'static, ()>,
tail: 0 as *mut Handle<'static, ()>,
next_id: Cell::new(1),
use prelude::v1::*;
use cell::UnsafeCell;
-use markers;
+use marker;
use ops::{Deref, DerefMut};
use sync::poison::{self, TryLockError, TryLockResult, LockResult};
use sys_common::mutex as sys;
__lock: &'a StaticMutex,
__data: &'a UnsafeCell<T>,
__poison: poison::Guard,
- __marker: markers::NoSend,
+ __marker: marker::NoSend,
}
/// Static initialization of a mutex. This constant can be used to initialize
__lock: lock,
__data: data,
__poison: guard,
- __marker: markers::NoSend,
+ __marker: marker::NoSend,
}
})
}
//! example use case would be for initializing an FFI library.
use int;
-use markers::Sync;
+use marker::Sync;
use mem::drop;
use ops::FnOnce;
use sync::atomic::{AtomicInt, Ordering, ATOMIC_INT_INIT};
use prelude::v1::*;
use cell::UnsafeCell;
-use markers;
+use marker;
use ops::{Deref, DerefMut};
use sync::poison::{self, LockResult, TryLockError, TryLockResult};
use sys_common::rwlock as sys;
pub struct RwLockReadGuard<'a, T: 'a> {
__lock: &'a StaticRwLock,
__data: &'a UnsafeCell<T>,
- __marker: markers::NoSend,
+ __marker: marker::NoSend,
}
/// RAII structure used to release the exclusive write access of a lock when
__lock: &'a StaticRwLock,
__data: &'a UnsafeCell<T>,
__poison: poison::Guard,
- __marker: markers::NoSend,
+ __marker: marker::NoSend,
}
impl<T: Send + Sync> RwLock<T> {
RwLockReadGuard {
__lock: lock,
__data: data,
- __marker: markers::NoSend,
+ __marker: marker::NoSend,
}
})
}
__lock: lock,
__data: data,
__poison: guard,
- __marker: markers::NoSend,
+ __marker: marker::NoSend,
}
})
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use markers::Sync;
+use marker::Sync;
use sys::mutex as imp;
/// An OS-based mutual exclusion lock.
sa_restorer: *mut libc::c_void,
}
- unsafe impl ::markers::Send for sigaction { }
- unsafe impl ::markers::Sync for sigaction { }
+ unsafe impl ::marker::Send for sigaction { }
+ unsafe impl ::marker::Sync for sigaction { }
#[repr(C)]
#[cfg(target_word_size = "32")]
sa_resv: [libc::c_int; 1],
}
- unsafe impl ::markers::Send for sigaction { }
- unsafe impl ::markers::Sync for sigaction { }
+ unsafe impl ::marker::Send for sigaction { }
+ unsafe impl ::marker::Sync for sigaction { }
#[repr(C)]
pub struct sigset_t {
// except according to those terms.
use cell::UnsafeCell;
-use markers::Sync;
+use marker::Sync;
use sys::sync as ffi;
use sys_common::mutex;
use boxed::Box;
use cell::UnsafeCell;
use clone::Clone;
-use markers::{Send, Sync};
+use marker::{Send, Sync};
use ops::{Drop, FnOnce};
use option::Option::{self, Some, None};
use result::Result::{Err, Ok};
pub dtor_running: UnsafeCell<bool>, // should be Cell
}
- unsafe impl<T> ::markers::Sync for Key<T> { }
+ unsafe impl<T> ::marker::Sync for Key<T> { }
#[doc(hidden)]
impl<T> Key<T> {
pub os: OsStaticKey,
}
- unsafe impl<T> ::markers::Sync for Key<T> { }
+ unsafe impl<T> ::marker::Sync for Key<T> { }
struct Value<T: 'static> {
key: &'static Key<T>,
const _INIT: __Key<$t> = __Key {
inner: ::std::thread_local::scoped::__impl::KeyInner {
inner: ::std::thread_local::scoped::__impl::OS_INIT,
- marker: ::std::markers::InvariantType,
+ marker: ::std::marker::InvariantType,
}
};
#[doc(hidden)]
pub struct KeyInner<T> { pub inner: UnsafeCell<*mut T> }
- unsafe impl<T> ::markers::Sync for KeyInner<T> { }
+ unsafe impl<T> ::marker::Sync for KeyInner<T> { }
#[doc(hidden)]
impl<T> KeyInner<T> {
#[cfg(any(windows, target_os = "android", target_os = "ios", target_arch = "aarch64"))]
mod imp {
- use markers;
+ use marker;
use sys_common::thread_local::StaticKey as OsStaticKey;
#[doc(hidden)]
pub struct KeyInner<T> {
pub inner: OsStaticKey,
- pub marker: markers::InvariantType<T>,
+ pub marker: marker::InvariantType<T>,
}
- unsafe impl<T> ::markers::Sync for KeyInner<T> { }
+ unsafe impl<T> ::marker::Sync for KeyInner<T> { }
#[doc(hidden)]
impl<T> KeyInner<T> {
#![allow(missing_docs)]
use alloc::boxed::Box;
-use core::markers::Send;
+use core::marker::Send;
use core::ops::FnOnce;
pub struct Thunk<A=(),R=()> {
let trait_def = TraitDef {
span: span,
attributes: Vec::new(),
- path: Path::new(vec!("std", "markers", name)),
+ path: Path::new(vec!("std", "marker", name)),
additional_bounds: Vec::new(),
generics: LifetimeBounds::empty(),
methods: vec!()
}
pub mod grapheme {
- use core::markers::Copy;
+ use core::marker::Copy;
use core::slice::SliceExt;
pub use self::GraphemeCat::*;
use core::result::Result::{Ok, Err};
}
fn foo<T:Get>(t: T) {
- let x = t.get(); //~ ERROR the trait `core::markers::Sized` is not implemented
+ let x = t.get(); //~ ERROR the trait `core::marker::Sized` is not implemented
}
fn main() {
// except according to those terms.
fn foo<T:'static>() {
- 1u.bar::<T>(); //~ ERROR `core::markers::Send` is not implemented
+ 1u.bar::<T>(); //~ ERROR `core::marker::Send` is not implemented
}
trait bar {
pub fn main() {
let x: Vec<Trait + Sized> = Vec::new();
- //~^ ERROR the trait `core::markers::Sized` is not implemented
- //~^^ ERROR the trait `core::markers::Sized` is not implemented
+ //~^ ERROR the trait `core::marker::Sized` is not implemented
+ //~^^ ERROR the trait `core::marker::Sized` is not implemented
let x: Vec<Box<RefCell<Trait + Sized>>> = Vec::new();
- //~^ ERROR the trait `core::markers::Sized` is not implemented
+ //~^ ERROR the trait `core::marker::Sized` is not implemented
}
// Ensure that moves out of static items is forbidden
-use std::markers;
+use std::marker;
struct Foo {
foo: int,
- nocopy: markers::NoCopy
+ nocopy: marker::NoCopy
}
-static BAR: Foo = Foo{foo: 5, nocopy: markers::NoCopy};
+static BAR: Foo = Foo{foo: 5, nocopy: marker::NoCopy};
fn test(f: Foo) {
// move, when the struct implements Drop.
// NoCopy
-use std::markers::NoCopy as NP;
+use std::marker::NoCopy as NP;
struct S { a: int, np: NP }
trait Foo : Send+Sync { }
-impl <T: Sync+'static> Foo for (T,) { } //~ ERROR the trait `core::markers::Send` is not implemented
+impl <T: Sync+'static> Foo for (T,) { } //~ ERROR the trait `core::marker::Send` is not implemented
-impl <T: Send> Foo for (T,T) { } //~ ERROR the trait `core::markers::Sync` is not implemented
+impl <T: Send> Foo for (T,T) { } //~ ERROR the trait `core::marker::Sync` is not implemented
impl <T: Send+Sync> Foo for (T,T,T) { } // (ok)
impl <T:Sync> RequiresShare for X<T> { }
impl <T:Sync+'static> RequiresRequiresShareAndSend for X<T> { }
-//~^ ERROR the trait `core::markers::Send` is not implemented
+//~^ ERROR the trait `core::marker::Send` is not implemented
fn main() { }
trait Foo : Send { }
-impl <T: Sync+'static> Foo for T { } //~ ERROR the trait `core::markers::Send` is not implemented
+impl <T: Sync+'static> Foo for T { } //~ ERROR the trait `core::marker::Send` is not implemented
fn main() { }
// Verifies all possible restrictions for statics values.
-use std::markers;
+use std::marker;
struct WithDtor;
}
fn foo<F>(blk: F) -> X<F> where F: FnOnce() + 'static {
- //~^ ERROR the trait `core::kinds::Send` is not implemented for the type
+ //~^ ERROR the trait `core::marker::Send` is not implemented for the type
return X { field: blk };
}
fn give_owned<F>(f: F) where F: FnOnce() + Send {
take_any(f);
- take_const_owned(f); //~ ERROR the trait `core::kinds::Sync` is not implemented for the type
+ take_const_owned(f); //~ ERROR the trait `core::marker::Sync` is not implemented for the type
}
fn main() {}
fn test<T: Sync>() {}
fn main() {
- test::<Receiver<int>>(); //~ ERROR: `core::markers::Sync` is not implemented
+ test::<Receiver<int>>(); //~ ERROR: `core::marker::Sync` is not implemented
}
fn test<T: Sync>() {}
fn main() {
- test::<Sender<int>>(); //~ ERROR: `core::markers::Sync` is not implemented
+ test::<Sender<int>>(); //~ ERROR: `core::marker::Sync` is not implemented
}
let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} };
let z: Box<ToBar> = box Bar1 {f: 36};
f5.ptr = *z;
- //~^ ERROR the trait `core::markers::Sized` is not implemented
+ //~^ ERROR the trait `core::marker::Sized` is not implemented
}
let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} };
let z: Box<ToBar> = box Bar1 {f: 36};
f5.ptr = Bar1 {f: 36}; //~ ERROR mismatched types: expected `ToBar`, found `Bar1`
- //~^ ERROR the trait `core::markers::Sized` is not implemented for the type `ToBar`
+ //~^ ERROR the trait `core::marker::Sized` is not implemented for the type `ToBar`
}
let f: Fat<[int; 3]> = Fat { ptr: [5i, 6, 7] };
let g: &Fat<[int]> = &f;
let h: &Fat<Fat<[int]>> = &Fat { ptr: *g };
- //~^ ERROR the trait `core::markers::Sized` is not implemented
+ //~^ ERROR the trait `core::marker::Sized` is not implemented
}
fn test1<T: ?Sized + Foo>(t: &T) {
let u: &Foo = t;
- //~^ ERROR `core::markers::Sized` is not implemented for the type `T`
+ //~^ ERROR `core::marker::Sized` is not implemented for the type `T`
}
fn test2<T: ?Sized + Foo>(t: &T) {
let v: &Foo = t as &Foo;
- //~^ ERROR `core::markers::Sized` is not implemented for the type `T`
+ //~^ ERROR `core::marker::Sized` is not implemented for the type `T`
}
fn test3() {
let _: &[&Foo] = &["hi"];
- //~^ ERROR `core::markers::Sized` is not implemented for the type `str`
+ //~^ ERROR `core::marker::Sized` is not implemented for the type `str`
}
fn test4() {
let _: &Foo = "hi" as &Foo;
- //~^ ERROR `core::markers::Sized` is not implemented for the type `str`
+ //~^ ERROR `core::marker::Sized` is not implemented for the type `str`
}
fn main() { }
trait Foo<T> : Sized { fn take(self, x: &T) { } } // Note: T is sized
impl Foo<[int]> for uint { }
-//~^ ERROR the trait `core::markers::Sized` is not implemented for the type `[int]`
+//~^ ERROR the trait `core::marker::Sized` is not implemented for the type `[int]`
impl Foo<int> for [uint] { }
-//~^ ERROR the trait `core::markers::Sized` is not implemented for the type `[uint]`
+//~^ ERROR the trait `core::marker::Sized` is not implemented for the type `[uint]`
pub fn main() { }
fn check_bound<T:Copy>(_: T) {}
fn main() {
- check_bound("nocopy".to_string()); //~ ERROR the trait `core::markers::Copy` is not implemented
+ check_bound("nocopy".to_string()); //~ ERROR the trait `core::marker::Copy` is not implemented
}
fn main() {
let _x = "test" as &::std::any::Any;
-//~^ ERROR the trait `core::markers::Sized` is not implemented for the type `str`
+//~^ ERROR the trait `core::marker::Sized` is not implemented for the type `str`
}
{
for
&something
-//~^ ERROR the trait `core::markers::Sized` is not implemented for the type `[T]`
+//~^ ERROR the trait `core::marker::Sized` is not implemented for the type `[T]`
in arg2
{
}
static foo: *const Y::X = Y::foo(Y::x as *const Y::X);
//~^ ERROR cannot refer to other statics by value
-//~| ERROR: the trait `core::markers::Sync` is not implemented for the type
+//~| ERROR: the trait `core::marker::Sync` is not implemented for the type
fn main() {}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::markers;
+use std::marker;
-struct Foo { nc: markers::NoCopy }
-const INIT: Foo = Foo { nc: markers::NoCopy };
+struct Foo { nc: marker::NoCopy }
+const INIT: Foo = Foo { nc: marker::NoCopy };
static FOO: Foo = INIT;
fn main() {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::markers;
+use std::marker;
-struct Foo { marker: markers::NoSync }
+struct Foo { marker: marker::NoSync }
static FOO: uint = 3;
-static BAR: Foo = Foo { marker: markers::NoSync };
-//~^ ERROR: the trait `core::markers::Sync` is not implemented
+static BAR: Foo = Foo { marker: marker::NoSync };
+//~^ ERROR: the trait `core::marker::Sync` is not implemented
fn main() {}
fn _create_render(_: &()) ->
AbstractRenderer
-//~^ ERROR: the trait `core::markers::Sized` is not implemented
+//~^ ERROR: the trait `core::marker::Sized` is not implemented
{
match 0u {
_ => unimplemented!()
// This is a typo, the return type should be `<Dst as From<Self>>::Output`
fn to<Dst: From<Self>>(
self
- //~^ error: the trait `core::markers::Sized` is not implemented
+ //~^ error: the trait `core::marker::Sized` is not implemented
) ->
<Dst as From<Self>>::Dst
- //~^ error: the trait `core::markers::Sized` is not implemented
+ //~^ error: the trait `core::marker::Sized` is not implemented
{
From::from(
- //~^ error: the trait `core::markers::Sized` is not implemented
+ //~^ error: the trait `core::marker::Sized` is not implemented
self
)
}
trait To {
fn to<Dst>(
- self //~ error: the trait `core::markers::Sized` is not implemented
+ self //~ error: the trait `core::marker::Sized` is not implemented
) -> <Dst as From<Self>>::Result where Dst: From<Self> {
- From::from( //~ error: the trait `core::markers::Sized` is not implemented
+ From::from( //~ error: the trait `core::marker::Sized` is not implemented
self
)
}
name: int
}
-fn bar(_x: Foo) {} //~ ERROR the trait `core::markers::Sized` is not implemented
+fn bar(_x: Foo) {} //~ ERROR the trait `core::marker::Sized` is not implemented
fn main() {}
trait I {}
type K = I+'static;
-fn foo(_x: K) {} //~ ERROR: the trait `core::markers::Sized` is not implemented
+fn foo(_x: K) {} //~ ERROR: the trait `core::marker::Sized` is not implemented
fn main() {}
fn main() {
let r: Box<Foo> = box 5;
let _m: Box<Foo> = r as Box<Foo>;
- //~^ ERROR `core::markers::Sized` is not implemented for the type `Foo`
+ //~^ ERROR `core::marker::Sized` is not implemented for the type `Foo`
}
}
fn new_struct(r: A+'static)
- -> Struct { //~^ ERROR the trait `core::markers::Sized` is not implemented
- //~^ ERROR the trait `core::markers::Sized` is not implemented
+ -> Struct { //~^ ERROR the trait `core::marker::Sized` is not implemented
+ //~^ ERROR the trait `core::marker::Sized` is not implemented
Struct { r: r }
}
fn main() {
let a = A {v: box B{v: None} as Box<Foo+Send>};
- //~^ ERROR the trait `core::markers::Send` is not implemented
- //~^^ ERROR the trait `core::markers::Send` is not implemented
+ //~^ ERROR the trait `core::marker::Send` is not implemented
+ //~^^ ERROR the trait `core::marker::Send` is not implemented
}
// Regresion test for issue 7364
static boxed: Box<RefCell<int>> = box RefCell::new(0);
//~^ ERROR statics are not allowed to have custom pointers
-//~| ERROR: the trait `core::markers::Sync` is not implemented for the type
-//~| ERROR: the trait `core::markers::Sync` is not implemented for the type
+//~| ERROR: the trait `core::marker::Sync` is not implemented for the type
+//~| ERROR: the trait `core::marker::Sync` is not implemented for the type
fn main() { }
assert_copy::<&'a [int]>();
// ...unless they are mutable
- assert_copy::<&'static mut int>(); //~ ERROR `core::markers::Copy` is not implemented
- assert_copy::<&'a mut int>(); //~ ERROR `core::markers::Copy` is not implemented
+ assert_copy::<&'static mut int>(); //~ ERROR `core::marker::Copy` is not implemented
+ assert_copy::<&'a mut int>(); //~ ERROR `core::marker::Copy` is not implemented
// ~ pointers are not ok
- assert_copy::<Box<int>>(); //~ ERROR `core::markers::Copy` is not implemented
- assert_copy::<String>(); //~ ERROR `core::markers::Copy` is not implemented
- assert_copy::<Vec<int> >(); //~ ERROR `core::markers::Copy` is not implemented
- assert_copy::<Box<&'a mut int>>(); //~ ERROR `core::markers::Copy` is not implemented
+ assert_copy::<Box<int>>(); //~ ERROR `core::marker::Copy` is not implemented
+ assert_copy::<String>(); //~ ERROR `core::marker::Copy` is not implemented
+ assert_copy::<Vec<int> >(); //~ ERROR `core::marker::Copy` is not implemented
+ assert_copy::<Box<&'a mut int>>(); //~ ERROR `core::marker::Copy` is not implemented
// borrowed object types are generally ok
assert_copy::<&'a Dummy>();
assert_copy::<&'static (Dummy+Copy)>();
// owned object types are not ok
- assert_copy::<Box<Dummy>>(); //~ ERROR `core::markers::Copy` is not implemented
- assert_copy::<Box<Dummy+Copy>>(); //~ ERROR `core::markers::Copy` is not implemented
+ assert_copy::<Box<Dummy>>(); //~ ERROR `core::marker::Copy` is not implemented
+ assert_copy::<Box<Dummy+Copy>>(); //~ ERROR `core::marker::Copy` is not implemented
// mutable object types are not ok
- assert_copy::<&'a mut (Dummy+Copy)>(); //~ ERROR `core::markers::Copy` is not implemented
+ assert_copy::<&'a mut (Dummy+Copy)>(); //~ ERROR `core::marker::Copy` is not implemented
// unsafe ptrs are ok
assert_copy::<*const int>();
assert_copy::<MyStruct>();
// structs containing non-POD are not ok
- assert_copy::<MyNoncopyStruct>(); //~ ERROR `core::markers::Copy` is not implemented
+ assert_copy::<MyNoncopyStruct>(); //~ ERROR `core::marker::Copy` is not implemented
// ref counted types are not ok
- assert_copy::<Rc<int>>(); //~ ERROR `core::markers::Copy` is not implemented
+ assert_copy::<Rc<int>>(); //~ ERROR `core::marker::Copy` is not implemented
}
pub fn main() {
fn main() {
let x = box 3i;
take_param(&x);
- //~^ ERROR the trait `core::markers::Copy` is not implemented
+ //~^ ERROR the trait `core::marker::Copy` is not implemented
}
fn f<T>(val: T) {
let t: S<T> = S;
let a = &t as &Gettable<T>;
- //~^ ERROR the trait `core::markers::Send` is not implemented
- //~^^ ERROR the trait `core::markers::Copy` is not implemented
+ //~^ ERROR the trait `core::marker::Send` is not implemented
+ //~^^ ERROR the trait `core::marker::Copy` is not implemented
}
fn g<T>(val: T) {
let t: S<T> = S;
let a: &Gettable<T> = &t;
- //~^ ERROR the trait `core::markers::Send` is not implemented
- //~^^ ERROR the trait `core::markers::Copy` is not implemented
+ //~^ ERROR the trait `core::marker::Send` is not implemented
+ //~^^ ERROR the trait `core::marker::Copy` is not implemented
}
fn foo<'a>() {
fn foo2<'a>() {
let t: Box<S<String>> = box S;
let a = t as Box<Gettable<String>>;
- //~^ ERROR the trait `core::markers::Copy` is not implemented
+ //~^ ERROR the trait `core::marker::Copy` is not implemented
}
fn foo3<'a>() {
let t: Box<S<String>> = box S;
let a: Box<Gettable<String>> = t;
- //~^ ERROR the trait `core::markers::Copy` is not implemented
+ //~^ ERROR the trait `core::marker::Copy` is not implemented
}
fn main() { }
fn a() {
let x = box 3i;
- take_param(&x); //~ ERROR `core::markers::Copy` is not implemented
+ take_param(&x); //~ ERROR `core::marker::Copy` is not implemented
}
fn b() {
let x = box 3i;
let y = &x;
- let z = &x as &Foo; //~ ERROR `core::markers::Copy` is not implemented
+ let z = &x as &Foo; //~ ERROR `core::marker::Copy` is not implemented
}
fn main() { }
fn main() {
let x = Rc::new(3u);
bar(move|| foo(x));
- //~^ ERROR `core::markers::Send` is not implemented
- //~^^ ERROR `core::markers::Send` is not implemented
+ //~^ ERROR `core::marker::Send` is not implemented
+ //~^^ ERROR `core::marker::Send` is not implemented
}
fn object_ref_with_static_bound_not_ok() {
assert_send::<&'static (Dummy+'static)>();
- //~^ ERROR the trait `core::markers::Send` is not implemented
+ //~^ ERROR the trait `core::marker::Send` is not implemented
}
fn box_object_with_no_bound_not_ok<'a>() {
- assert_send::<Box<Dummy>>(); //~ ERROR the trait `core::markers::Send` is not implemented
+ assert_send::<Box<Dummy>>(); //~ ERROR the trait `core::marker::Send` is not implemented
}
fn object_with_send_bound_ok() {
// careful with object types, who knows what they close over...
fn test51<'a>() {
assert_send::<&'a Dummy>();
- //~^ ERROR the trait `core::markers::Send` is not implemented
+ //~^ ERROR the trait `core::marker::Send` is not implemented
}
fn test52<'a>() {
assert_send::<&'a (Dummy+Send)>();
// them not ok
fn test_71<'a>() {
assert_send::<Box<Dummy+'a>>();
- //~^ ERROR the trait `core::markers::Send` is not implemented
+ //~^ ERROR the trait `core::marker::Send` is not implemented
}
fn main() { }
trait Dummy { }
fn test50() {
- assert_send::<&'static Dummy>(); //~ ERROR the trait `core::markers::Send` is not implemented
+ assert_send::<&'static Dummy>(); //~ ERROR the trait `core::marker::Send` is not implemented
}
fn test53() {
- assert_send::<Box<Dummy>>(); //~ ERROR the trait `core::markers::Send` is not implemented
+ assert_send::<Box<Dummy>>(); //~ ERROR the trait `core::marker::Send` is not implemented
}
// ...unless they are properly bounded
fn test71<'a>() {
assert_send::<*mut &'a int>();
- //~^ ERROR the trait `core::markers::Send` is not implemented for the type
+ //~^ ERROR the trait `core::marker::Send` is not implemented for the type
}
fn main() {
struct Foo {
x: uint,
b: bool, //~ ERROR: struct field is never used
- marker: std::markers::NoCopy
+ marker: std::marker::NoCopy
}
fn field_read(f: Foo) -> uint {
}
fn main() {
- field_read(Foo { x: 1, b: false, marker: std::markers::NoCopy });
+ field_read(Foo { x: 1, b: false, marker: std::marker::NoCopy });
field_match_in_patterns(XYZ::Z);
field_match_in_let(Bar { x: 42u, b: true, _guard: () });
let _ = Baz { x: 0 };
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::markers;
+use std::marker;
fn foo<P:Copy>(p: P) { }
fn main()
{
- foo(markers::NoCopy); //~ ERROR the trait `core::markers::Copy` is not implemented
+ foo(marker::NoCopy); //~ ERROR the trait `core::marker::Copy` is not implemented
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::markers;
+use std::marker;
fn foo<P:Send>(p: P) { }
fn main()
{
- foo(markers::NoSend); //~ ERROR the trait `core::markers::Send` is not implemented
+ foo(marker::NoSend); //~ ERROR the trait `core::marker::Send` is not implemented
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::markers;
+use std::marker;
fn foo<P: Sync>(p: P) { }
fn main()
{
- foo(markers::NoSync); //~ ERROR the trait `core::markers::Sync` is not implemented
+ foo(marker::NoSync); //~ ERROR the trait `core::marker::Sync` is not implemented
}
fn main() {
let x = RefCell::new(0i);
f(x);
- //~^ ERROR `core::markers::Sync` is not implemented
- //~^^ ERROR `core::markers::Sync` is not implemented
+ //~^ ERROR `core::marker::Sync` is not implemented
+ //~^^ ERROR `core::marker::Sync` is not implemented
}
// Tests that an `&` pointer to something inherently mutable is itself
// to be considered mutable.
-use std::markers;
+use std::marker;
-enum Foo { A(markers::NoSync) }
+enum Foo { A(marker::NoSync) }
fn bar<T: Sync>(_: T) {}
fn main() {
- let x = Foo::A(markers::NoSync);
- bar(&x); //~ ERROR the trait `core::markers::Sync` is not implemented
+ let x = Foo::A(marker::NoSync);
+ bar(&x); //~ ERROR the trait `core::marker::Sync` is not implemented
}
let x = foo(Port(Rc::new(())));
Thread::spawn(move|| {
- //~^ ERROR `core::markers::Send` is not implemented
- //~^^ ERROR `core::markers::Send` is not implemented
+ //~^ ERROR `core::marker::Send` is not implemented
+ //~^^ ERROR `core::marker::Send` is not implemented
let y = x;
println!("{}", y);
});
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::markers;
+use std::marker;
enum Foo {
- A(markers::NoSend)
+ A(marker::NoSend)
}
fn bar<T: Send>(_: T) {}
fn main() {
- let x = Foo::A(markers::NoSend);
+ let x = Foo::A(marker::NoSend);
bar(x);
- //~^ ERROR `core::markers::Send` is not implemented
+ //~^ ERROR `core::marker::Send` is not implemented
}
fn main() {
let x = Rc::new(5i);
bar(x);
- //~^ ERROR `core::markers::Send` is not implemented
- //~^^ ERROR `core::markers::Send` is not implemented
+ //~^ ERROR `core::marker::Send` is not implemented
+ //~^^ ERROR `core::marker::Send` is not implemented
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::markers;
+use std::marker;
struct Foo {
a: int,
- ns: markers::NoSend
+ ns: marker::NoSend
}
fn bar<T: Send>(_: T) {}
fn main() {
- let x = Foo { a: 5, ns: markers::NoSend };
+ let x = Foo { a: 5, ns: marker::NoSend };
bar(x);
- //~^ ERROR the trait `core::markers::Send` is not implemented
+ //~^ ERROR the trait `core::marker::Send` is not implemented
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::markers;
+use std::marker;
-enum Foo { A(markers::NoSync) }
+enum Foo { A(marker::NoSync) }
fn bar<T: Sync>(_: T) {}
fn main() {
- let x = Foo::A(markers::NoSync);
+ let x = Foo::A(marker::NoSync);
bar(x);
- //~^ ERROR the trait `core::markers::Sync` is not implemented
+ //~^ ERROR the trait `core::marker::Sync` is not implemented
}
fn main() {
let x = Rc::new(RefCell::new(5i));
bar(x);
- //~^ ERROR the trait `core::markers::Sync` is not implemented
- //~^^ ERROR the trait `core::markers::Sync` is not implemented
+ //~^ ERROR the trait `core::marker::Sync` is not implemented
+ //~^^ ERROR the trait `core::marker::Sync` is not implemented
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::markers;
+use std::marker;
-struct Foo { a: int, m: markers::NoSync }
+struct Foo { a: int, m: marker::NoSync }
fn bar<T: Sync>(_: T) {}
fn main() {
- let x = Foo { a: 5, m: markers::NoSync };
+ let x = Foo { a: 5, m: marker::NoSync };
bar(x);
- //~^ ERROR the trait `core::markers::Sync` is not implemented
+ //~^ ERROR the trait `core::marker::Sync` is not implemented
}
enum CantCopyThisEither {
A,
- B(::std::markers::NoCopy),
+ B(::std::marker::NoCopy),
}
enum IWantToCopyThisToo {
// Unsized type.
let arr: &[_] = &[1u, 2, 3];
let range = (*arr)..;
- //~^ ERROR the trait `core::markers::Sized` is not implemented
+ //~^ ERROR the trait `core::marker::Sized` is not implemented
}
// Note: see variance-regions-*.rs for the tests that check that the
// variance inference works in the first place.
-use std::markers;
+use std::marker;
// This is contravariant with respect to 'a, meaning that
// Contravariant<'foo> <: Contravariant<'static> because
// 'foo <= 'static
struct Contravariant<'a> {
- marker: markers::ContravariantLifetime<'a>
+ marker: marker::ContravariantLifetime<'a>
}
fn use_<'short,'long>(c: Contravariant<'short>,
// Note: see variance-regions-*.rs for the tests that check that the
// variance inference works in the first place.
-use std::markers;
+use std::marker;
struct Covariant<'a> {
- marker: markers::CovariantLifetime<'a>
+ marker: marker::CovariantLifetime<'a>
}
fn use_<'short,'long>(c: Covariant<'long>,
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::markers;
+use std::marker;
struct invariant<'a> {
- marker: markers::InvariantLifetime<'a>
+ marker: marker::InvariantLifetime<'a>
}
fn to_same_lifetime<'r>(bi: invariant<'r>) {
fn main() {
let a = Foo { x: 3 };
let _ = [ a; 5 ];
- //~^ ERROR the trait `core::markers::Copy` is not implemented for the type `Foo`
+ //~^ ERROR the trait `core::marker::Copy` is not implemented for the type `Foo`
}
// Verifies that static items can't be moved
-use std::markers;
+use std::marker;
struct Foo {
foo: int,
- nocopy: markers::NoCopy
+ nocopy: marker::NoCopy
}
-static BAR: Foo = Foo{foo: 5, nocopy: markers::NoCopy};
+static BAR: Foo = Foo{foo: 5, nocopy: marker::NoCopy};
fn test(f: Foo) {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::markers::Send;
+use std::marker::Send;
struct TestType;
#![feature(optin_builtin_traits)]
-use std::markers::Send;
+use std::marker::Send;
struct TestType;
pub fn main() {
test_send::<rand::ThreadRng>();
- //~^ ERROR `core::markers::Send` is not implemented
- //~^^ ERROR `core::markers::Send` is not implemented
+ //~^ ERROR `core::marker::Send` is not implemented
+ //~^^ ERROR `core::marker::Send` is not implemented
}
// This should emit the less confusing error, not the more confusing one.
fn foo(_x: Foo + Send) {
- //~^ERROR the trait `core::markers::Sized` is not implemented
+ //~^ERROR the trait `core::marker::Sized` is not implemented
}
fn main() { }
// ignore-tidy-linelength
use std::cell::UnsafeCell;
-use std::markers;
+use std::marker;
struct MySync<T> {
u: UnsafeCell<T>
}
struct NoSync {
- m: markers::NoSync
+ m: marker::NoSync
}
fn test<T: Sync>(s: T){
fn main() {
let us = UnsafeCell::new(MySync{u: UnsafeCell::new(0i)});
test(us);
- //~^ ERROR `core::markers::Sync` is not implemented
+ //~^ ERROR `core::marker::Sync` is not implemented
- let uns = UnsafeCell::new(NoSync{m: markers::NoSync});
+ let uns = UnsafeCell::new(NoSync{m: marker::NoSync});
test(uns);
- //~^ ERROR `core::markers::Sync` is not implemented
+ //~^ ERROR `core::marker::Sync` is not implemented
let ms = MySync{u: uns};
test(ms);
- //~^ ERROR `core::markers::Sync` is not implemented
+ //~^ ERROR `core::marker::Sync` is not implemented
- let ns = NoSync{m: markers::NoSync};
+ let ns = NoSync{m: marker::NoSync};
test(ns);
- //~^ ERROR `core::markers::Sync` is not implemented
+ //~^ ERROR `core::marker::Sync` is not implemented
}
#![feature(unboxed_closures)]
#![allow(dead_code)]
-use std::markers;
+use std::marker;
trait Foo<'a,T,U> {
fn dummy(&'a self) -> &'a (T,U);
fn main() {
let i = box Rc::new(100i);
f(i);
- //~^ ERROR `core::markers::Send` is not implemented
- //~^^ ERROR `core::markers::Send` is not implemented
+ //~^ ERROR `core::marker::Send` is not implemented
+ //~^^ ERROR `core::marker::Send` is not implemented
}
fn main() {
let cat = "kitty".to_string();
let (tx, _) = channel();
- //~^ ERROR `core::markers::Send` is not implemented
- //~^^ ERROR `core::markers::Send` is not implemented
+ //~^ ERROR `core::marker::Send` is not implemented
+ //~^^ ERROR `core::marker::Send` is not implemented
tx.send(foo(42, Rc::new(cat)));
}
// except according to those terms.
fn bar<T: Sized>() { }
-fn foo<T: ?Sized>() { bar::<T>() } //~ ERROR the trait `core::markers::Sized` is not implemented
+fn foo<T: ?Sized>() { bar::<T>() } //~ ERROR the trait `core::marker::Sized` is not implemented
fn main() { }
enum Foo<U> { FooSome(U), FooNone }
fn foo1<T>() { not_sized::<Foo<T>>() } // Hunky dory.
fn foo2<T: ?Sized>() { not_sized::<Foo<T>>() }
-//~^ ERROR the trait `core::markers::Sized` is not implemented
+//~^ ERROR the trait `core::marker::Sized` is not implemented
//
// Not OK: `T` is not sized.
enum Bar<U: ?Sized> { BarSome(U), BarNone }
fn bar1<T: ?Sized>() { not_sized::<Bar<T>>() }
fn bar2<T: ?Sized>() { is_sized::<Bar<T>>() }
-//~^ ERROR the trait `core::markers::Sized` is not implemented
+//~^ ERROR the trait `core::marker::Sized` is not implemented
//
// Not OK: `Bar<T>` is not sized, but it should be.
struct Foo<T> { data: T }
fn foo1<T>() { not_sized::<Foo<T>>() } // Hunky dory.
fn foo2<T: ?Sized>() { not_sized::<Foo<T>>() }
-//~^ ERROR the trait `core::markers::Sized` is not implemented
+//~^ ERROR the trait `core::marker::Sized` is not implemented
//
// Not OK: `T` is not sized.
struct Bar<T: ?Sized> { data: T }
fn bar1<T: ?Sized>() { not_sized::<Bar<T>>() }
fn bar2<T: ?Sized>() { is_sized::<Bar<T>>() }
-//~^ ERROR the trait `core::markers::Sized` is not implemented
+//~^ ERROR the trait `core::marker::Sized` is not implemented
//
// Not OK: `Bar<T>` is not sized, but it should be.
}
struct S4<Y: ?Sized>;
impl<X: ?Sized> T2<X> for S4<X> {
- //~^ ERROR `core::markers::Sized` is not implemented for the type `X`
+ //~^ ERROR `core::marker::Sized` is not implemented for the type `X`
}
fn main() { }
// Unbounded.
fn f1<X: ?Sized>(x: &X) {
f2::<X>(x);
- //~^ ERROR the trait `core::markers::Sized` is not implemented
+ //~^ ERROR the trait `core::marker::Sized` is not implemented
}
fn f2<X>(x: &X) {
}
trait T {}
fn f3<X: ?Sized + T>(x: &X) {
f4::<X>(x);
- //~^ ERROR the trait `core::markers::Sized` is not implemented
+ //~^ ERROR the trait `core::marker::Sized` is not implemented
}
fn f4<X: T>(x: &X) {
}
fn f6<X: ?Sized>(x: &X) {}
fn f7<X: ?Sized>(x1: &E<X>, x2: &E<X>) {
f5(x1);
- //~^ ERROR the trait `core::markers::Sized` is not implemented
+ //~^ ERROR the trait `core::marker::Sized` is not implemented
f6(x2); // ok
}
fn f8<X: ?Sized>(x1: &S<X>, x2: &S<X>) {
f5(x1);
- //~^ ERROR the trait `core::markers::Sized` is not implemented
+ //~^ ERROR the trait `core::marker::Sized` is not implemented
f6(x2); // ok
}
// Test some tuples.
fn f9<X: ?Sized>(x1: Box<S<X>>, x2: Box<E<X>>) {
f5(&(*x1, 34i));
- //~^ ERROR the trait `core::markers::Sized` is not implemented
+ //~^ ERROR the trait `core::marker::Sized` is not implemented
}
fn f10<X: ?Sized>(x1: Box<S<X>>, x2: Box<E<X>>) {
f5(&(32i, *x2));
- //~^ ERROR the trait `core::markers::Sized` is not implemented
+ //~^ ERROR the trait `core::marker::Sized` is not implemented
}
pub fn main() {
// Test `?Sized` types not allowed in fields (except the last one).
struct S1<X: ?Sized> {
- f1: X, //~ ERROR `core::markers::Sized` is not implemented
+ f1: X, //~ ERROR `core::marker::Sized` is not implemented
f2: int,
}
struct S2<X: ?Sized> {
f: int,
- g: X, //~ ERROR `core::markers::Sized` is not implemented
+ g: X, //~ ERROR `core::marker::Sized` is not implemented
h: int,
}
struct S3 {
- f: str, //~ ERROR `core::markers::Sized` is not implemented
+ f: str, //~ ERROR `core::marker::Sized` is not implemented
g: [uint]
}
struct S4 {
- f: str, //~ ERROR `core::markers::Sized` is not implemented
+ f: str, //~ ERROR `core::marker::Sized` is not implemented
g: uint
}
enum E<X: ?Sized> {
- V1(X, int), //~ERROR `core::markers::Sized` is not implemented
+ V1(X, int), //~ERROR `core::marker::Sized` is not implemented
}
enum F<X: ?Sized> {
- V2{f1: X, f: int}, //~ERROR `core::markers::Sized` is not implemented
+ V2{f1: X, f: int}, //~ERROR `core::marker::Sized` is not implemented
}
pub fn main() {
fn f1<X: ?Sized>(x: &X) {
let _: X; // <-- this is OK, no bindings created, no initializer.
let _: (int, (X, int)); // same
- let y: X; //~ERROR the trait `core::markers::Sized` is not implemented
- let y: (int, (X, int)); //~ERROR the trait `core::markers::Sized` is not implemented
+ let y: X; //~ERROR the trait `core::marker::Sized` is not implemented
+ let y: (int, (X, int)); //~ERROR the trait `core::marker::Sized` is not implemented
}
fn f2<X: ?Sized + T>(x: &X) {
- let y: X; //~ERROR the trait `core::markers::Sized` is not implemented
- let y: (int, (X, int)); //~ERROR the trait `core::markers::Sized` is not implemented
+ let y: X; //~ERROR the trait `core::marker::Sized` is not implemented
+ let y: (int, (X, int)); //~ERROR the trait `core::marker::Sized` is not implemented
}
fn f3<X: ?Sized>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
- let y: X = *x1; //~ERROR the trait `core::markers::Sized` is not implemented
- let y = *x2; //~ERROR the trait `core::markers::Sized` is not implemented
- let (y, z) = (*x3, 4i); //~ERROR the trait `core::markers::Sized` is not implemented
+ let y: X = *x1; //~ERROR the trait `core::marker::Sized` is not implemented
+ let y = *x2; //~ERROR the trait `core::marker::Sized` is not implemented
+ let (y, z) = (*x3, 4i); //~ERROR the trait `core::marker::Sized` is not implemented
}
-fn f4<X: ?Sized: T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
- let y: X = *x1; //~ERROR the trait `core::markers::Sized` is not implemented
- let y = *x2; //~ERROR the trait `core::markers::Sized` is not implemented
- let (y, z) = (*x3, 4i); //~ERROR the trait `core::markers::Sized` is not implemented
+fn f4<X: ?Sized + T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
+ let y: X = *x1; //~ERROR the trait `core::marker::Sized` is not implemented
+ let y = *x2; //~ERROR the trait `core::marker::Sized` is not implemented
+ let (y, z) = (*x3, 4i); //~ERROR the trait `core::marker::Sized` is not implemented
}
-fn g1<X: ?Sized>(x: X) {} //~ERROR the trait `core::markers::Sized` is not implemented
-fn g2<X: ?Sized + T>(x: X) {} //~ERROR the trait `core::markers::Sized` is not implemented
+fn g1<X: ?Sized>(x: X) {} //~ERROR the trait `core::marker::Sized` is not implemented
+fn g2<X: ?Sized + T>(x: X) {} //~ERROR the trait `core::marker::Sized` is not implemented
pub fn main() {
}
}
struct S3<Y: ?Sized>;
impl<X: ?Sized + T> T1<X> for S3<X> {
- //~^ ERROR `core::markers::Sized` is not implemented for the type `X`
+ //~^ ERROR `core::marker::Sized` is not implemented for the type `X`
}
fn main() { }
fn fails_copy(self) {
require_copy(self.x);
- //~^ ERROR the trait `core::markers::Copy` is not implemented for the type `T`
+ //~^ ERROR the trait `core::marker::Copy` is not implemented for the type `T`
}
}
fn fails_copy(self) {
require_copy(self.x);
- //~^ ERROR the trait `core::markers::Copy` is not implemented for the type `T`
+ //~^ ERROR the trait `core::marker::Copy` is not implemented for the type `T`
}
}
#![feature(lang_items, unboxed_closures)]
#![no_implicit_prelude]
-use std::markers::Sized;
+use std::marker::Sized;
use std::option::Option::{None, Some, self};
trait Iterator {
#![feature(lang_items, unboxed_closures)]
#![no_implicit_prelude]
-use std::markers::Sized;
+use std::marker::Sized;
use std::option::Option::{None, Some, self};
trait Iterator {
#![allow(dead_code)]
#![allow(unused_unsafe)]
-use std::markers::Sync;
+use std::marker::Sync;
struct Foo {
a: uint,
// Issue 4691: Ensure that functional-struct-updates operates
// correctly and moves rather than copy when appropriate.
-use std::markers::NoCopy as NP;
+use std::marker::NoCopy as NP;
struct ncint { np: NP, v: int }
fn ncint(v: int) -> ncint { ncint { np: NP, v: v } }
#![allow(dead_code)]
-use std::markers;
+use std::marker;
#[derive(Copy)]
struct Foo<T> { x: T }
type Ty<'tcx> = &'tcx TyS<'tcx>;
enum TyS<'tcx> {
- Boop(markers::InvariantLifetime<'tcx>)
+ Boop(marker::InvariantLifetime<'tcx>)
}
enum Bar<'tcx> {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::markers;
+use std::marker;
use std::cell::UnsafeCell;
struct MyUnsafePack<T>(UnsafeCell<T>);
use std::mem::{replace, swap};
use std::mem;
use std::thread::Thread;
- use std::markers::Send;
+ use std::marker::Send;
pub struct Stuff<T> {
state: state,
// know not to stop at the blanket, we have to recursively evaluate
// the `T:Foo` bound.
-use std::markers::Sized;
+use std::marker::Sized;
// Note: this must be generic for the problem to show up
trait Foo<A> {
// Test that a type whose lifetime parameters is never used is
// inferred to be bivariant.
-use std::markers;
+use std::marker;
struct Bivariant<'a>;
#![feature(optin_builtin_traits)]
-use std::markers::Send;
+use std::marker::Send;
struct TestType;