diff options
| author | bors <bors@rust-lang.org> | 2015-04-02 07:19:33 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-04-02 07:19:33 +0000 |
| commit | cf00fc4da984481a75229ce1e40f339f292d2166 (patch) | |
| tree | 460e4d59504435411421cf261c5735a726f16942 | |
| parent | 2e3b0c051dca9880bf66b5366dccd2e0bb424b99 (diff) | |
| parent | e3b7e6caa25bffcffe6b04f550f551e1ae086f6b (diff) | |
| download | rust-cf00fc4da984481a75229ce1e40f339f292d2166.tar.gz rust-cf00fc4da984481a75229ce1e40f339f292d2166.zip | |
Auto merge of #23963 - alexcrichton:rollup, r=alexcrichton
264 files changed, 967 insertions, 736 deletions
diff --git a/RELEASES.md b/RELEASES.md index 69b804cf24c..7da73afb411 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,102 @@ +Version 1.0.0-beta (April 2015) +------------------------------------- + +* ~1100 changes, numerous bugfixes + +* Highlights + + * The big news is that the vast majority of the standard library + is now `#[stable]` -- 75% of the non-deprecated API surface at + last count. Numerous crates are now running on stable + Rust. Starting with this release, it is not possible to use + unstable features on a stable build. + * Arithmetic on basic integer types now + [checks for overflow in debug builds][overflow]. + +* Language + + * [`Send` no longer implies `'static`][send-rfc], which made + possible the [`thread::scoped` API][scoped]. Scoped threads can + borrow data from their parent's stack frame -- safely! + * [UFCS now supports trait-less associated paths][moar-ufcs] like + `MyType::default()`. + * Primitive types [now have inherent methods][prim-inherent], + obviating the need for extension traits like `SliceExt`. + * Methods with `Self: Sized` in their `where` clause are + [considered object-safe][self-sized], allowing many extension + traits like `IteratorExt` to be merged into the traits they + extended. + * You can now [refer to associated types][assoc-where] whose + corresponding trait bounds appear only in a `where` clause. + * The final bits of [OIBIT landed][oibit-final], meaning that + traits like `Send` and `Sync` are now library-defined. + * A [Reflect trait][reflect] was introduced, which means that + downcasting via the `Any` trait is effectively limited to + concrete types. This helps retain the potentially-important + "parametricity" property: generic code cannot behave differently + for different type arguments except in minor ways. + * The `unsafe_destructor` feature is now deprecated in favor of + the [new `dropck`][dropck]. This change is a major reduction in + unsafe code. + * Trait coherence was [revised again][fundamental], this time with + an eye toward API evolution over time. + +* Libraries + + * The new path and IO modules are complete and `#[stable]`. This + was the major library focus for this cycle. + * The path API was [revised][path-normalize] to normalize `.`, + adjusting the tradeoffs in favor of the most common usage. + * A large number of remaining APIs in `std` were also stabilized + during this cycle; about 75% of the non-deprecated API surface + is now stable. + * The new [string pattern API][string-pattern] landed, which makes + the string slice API much more internally consistent and flexible. + * A shiny [framework for Debug implementations][debug-builder] landed. + This makes it possible to opt in to "pretty-printed" debugging output. + * A new set of [generic conversion traits][conversion] replaced + many existing ad hoc traits. + * Generic numeric traits were + [completely removed][num-traits]. This was made possible thanks + to inherent methods for primitive types, and the removal gives + maximal flexibility for designing a numeric hierarchy in the future. + * The `Fn` traits are now related via [inheritance][fn-inherit] + and provide ergonomic [blanket implementations][fn-blanket]. + * The `Index` and `IndexMut` traits were changed to + [take the index by value][index-value], enabling code like + `hash_map["string"]` to work. + * `Copy` now [inherits][copy-clone] from `Clone`, meaning that all + `Copy` data is known to be `Clone` as well. + +* Infrastructure + + * Metadata was tuned, shrinking binaries [by 27%][metadata-shrink]. + * Much headway was made on ecosystem-wide CI, making it possible + to [compare builds for breakage][ci-compare]. + +[send-rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0458-send-improvements.md +[scoped]: http://static.rust-lang.org/doc/master/std/thread/fn.scoped.html +[moar-ufcs]: https://github.com/rust-lang/rust/pull/22172 +[prim-inherent]: https://github.com/rust-lang/rust/pull/23104 +[overflow]: https://github.com/rust-lang/rfcs/blob/master/text/0560-integer-overflow.md +[metadata-shrink]: https://github.com/rust-lang/rust/pull/22971 +[self-sized]: https://github.com/rust-lang/rust/pull/22301 +[assoc-where]: https://github.com/rust-lang/rust/pull/22512 +[string-pattern]: https://github.com/rust-lang/rust/pull/22466 +[oibit-final]: https://github.com/rust-lang/rust/pull/21689 +[reflect]: https://github.com/rust-lang/rust/pull/23712 +[debug-builder]: https://github.com/rust-lang/rfcs/blob/master/text/0640-debug-improvements.md +[conversion]: https://github.com/rust-lang/rfcs/pull/529 +[num-traits]: https://github.com/rust-lang/rust/pull/23549 +[index-value]: https://github.com/rust-lang/rust/pull/23601 +[dropck]: https://github.com/rust-lang/rfcs/pull/769 +[fundamental]: https://github.com/rust-lang/rfcs/pull/1023 +[ci-compare]: https://gist.github.com/brson/a30a77836fbec057cbee +[fn-inherit]: https://github.com/rust-lang/rust/pull/23282 +[fn-blanket]: https://github.com/rust-lang/rust/pull/23895 +[copy-clone]: https://github.com/rust-lang/rust/pull/23860 +[path-normalize]: https://github.com/rust-lang/rust/pull/23229 + Version 1.0.0-alpha.2 (February 2015) ------------------------------------- diff --git a/src/doc/reference.md b/src/doc/reference.md index b3d5ad3b55d..cc90a69fd2a 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -1648,7 +1648,7 @@ specific type. Implementations are defined with the keyword `impl`. ``` -# #[derive(Copy)] +# #[derive(Copy, Clone)] # struct Point {x: f64, y: f64}; # type Surface = i32; # struct BoundingBox {x: f64, y: f64, width: f64, height: f64}; @@ -1661,6 +1661,10 @@ struct Circle { impl Copy for Circle {} +impl Clone for Circle { + fn clone(&self) -> Circle { *self } +} + impl Shape for Circle { fn draw(&self, s: Surface) { do_draw_circle(s, *self); } fn bounding_box(&self) -> BoundingBox { diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index f87c450eda5..8b884c56505 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -321,7 +321,7 @@ impl<T> Deref for Arc<T> { } } -impl<T: Send + Sync + Clone> Arc<T> { +impl<T: Clone> Arc<T> { /// Make a mutable reference from the given `Arc<T>`. /// /// This is also referred to as a copy-on-write operation because the inner @@ -465,7 +465,7 @@ impl<T> Weak<T> { #[unstable(feature = "alloc", reason = "Weak pointers may not belong in this module.")] -impl<T: Sync + Send> Clone for Weak<T> { +impl<T> Clone for Weak<T> { /// Makes a clone of the `Weak<T>`. /// /// This increases the weak reference count. diff --git a/src/libcollections/binary_heap.rs b/src/libcollections/binary_heap.rs index e4bc6a393c4..3804874a650 100644 --- a/src/libcollections/binary_heap.rs +++ b/src/libcollections/binary_heap.rs @@ -30,7 +30,7 @@ //! use std::collections::BinaryHeap; //! use std::usize; //! -//! #[derive(Copy, Eq, PartialEq)] +//! #[derive(Copy, Clone, Eq, PartialEq)] //! struct State { //! cost: usize, //! position: usize, diff --git a/src/libcollections/btree/node.rs b/src/libcollections/btree/node.rs index 847ee7c19ce..26c57256049 100644 --- a/src/libcollections/btree/node.rs +++ b/src/libcollections/btree/node.rs @@ -526,7 +526,7 @@ impl<K: Clone, V: Clone> Clone for Node<K, V> { /// println!("Uninitialized memory: {:?}", handle.into_kv()); /// } /// ``` -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Handle<NodeRef, Type, NodeType> { node: NodeRef, index: usize, diff --git a/src/libcollections/enum_set.rs b/src/libcollections/enum_set.rs index 474b4de8123..0b206d381dd 100644 --- a/src/libcollections/enum_set.rs +++ b/src/libcollections/enum_set.rs @@ -21,7 +21,7 @@ use core::ops::{Sub, BitOr, BitAnd, BitXor}; // FIXME(contentions): implement union family of methods? (general design may be wrong here) -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)] /// A specialized set implementation to use enum types. /// /// It is a logic error for an item to be modified in such a way that the transformation of the @@ -37,6 +37,10 @@ pub struct EnumSet<E> { impl<E> Copy for EnumSet<E> {} +impl<E> Clone for EnumSet<E> { + fn clone(&self) -> EnumSet<E> { *self } +} + #[stable(feature = "rust1", since = "1.0.0")] impl<E:CLike + fmt::Debug> fmt::Debug for EnumSet<E> { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index d35173cbebf..ff923fb1906 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -1135,7 +1135,7 @@ impl Iterator for ElementSwaps { // #[inline] fn next(&mut self) -> Option<(usize, usize)> { fn new_pos_wrapping(i: usize, s: Direction) -> usize { - i.wrapping_add(match s { Pos => 1, Neg => -1 }) + i.wrapping_add(match s { Pos => 1, Neg => !0 /* aka -1 */ }) } fn new_pos(i: usize, s: Direction) -> usize { diff --git a/src/libcollectionstest/enum_set.rs b/src/libcollectionstest/enum_set.rs index a748541fca5..0a1eb0bcfa8 100644 --- a/src/libcollectionstest/enum_set.rs +++ b/src/libcollectionstest/enum_set.rs @@ -14,7 +14,7 @@ use collections::enum_set::{CLike, EnumSet}; use self::Foo::*; -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] #[repr(usize)] enum Foo { A, B, C @@ -218,7 +218,7 @@ fn test_operators() { #[should_panic] fn test_overflow() { #[allow(dead_code)] - #[derive(Copy)] + #[derive(Copy, Clone)] #[repr(usize)] enum Bar { V00, V01, V02, V03, V04, V05, V06, V07, V08, V09, diff --git a/src/libcollectionstest/slice.rs b/src/libcollectionstest/slice.rs index 9dc12aa5bd9..5b0aceb76d1 100644 --- a/src/libcollectionstest/slice.rs +++ b/src/libcollectionstest/slice.rs @@ -1089,7 +1089,7 @@ fn test_bytes_set_memory() { #[should_panic] fn test_overflow_does_not_cause_segfault() { let mut v = vec![]; - v.reserve_exact(-1); + v.reserve_exact(!0); v.push(1); v.push(2); } @@ -1098,7 +1098,7 @@ fn test_overflow_does_not_cause_segfault() { #[should_panic] fn test_overflow_does_not_cause_segfault_managed() { let mut v = vec![Rc::new(1)]; - v.reserve_exact(-1); + v.reserve_exact(!0); v.push(Rc::new(2)); } diff --git a/src/libcore/atomic.rs b/src/libcore/atomic.rs index 8c396a4e7fb..ed35e095492 100644 --- a/src/libcore/atomic.rs +++ b/src/libcore/atomic.rs @@ -122,7 +122,7 @@ unsafe impl<T> Sync for AtomicPtr<T> {} /// Rust's memory orderings are [the same as /// C++'s](http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync). #[stable(feature = "rust1", since = "1.0.0")] -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum Ordering { /// No ordering constraints, only atomic operations. #[stable(feature = "rust1", since = "1.0.0")] @@ -161,7 +161,7 @@ pub const ATOMIC_USIZE_INIT: AtomicUsize = AtomicUsize { v: UnsafeCell { value: 0, } }; // NB: Needs to be -1 (0b11111111...) to make fetch_nand work correctly -const UINT_TRUE: usize = -1; +const UINT_TRUE: usize = !0; impl AtomicBool { /// Creates a new `AtomicBool`. diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 906c87f3ffd..76e09eedbdf 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -287,7 +287,7 @@ pub enum BorrowState { // (will not outgrow its range since `usize` is the size of the address space) type BorrowFlag = usize; const UNUSED: BorrowFlag = 0; -const WRITING: BorrowFlag = -1; +const WRITING: BorrowFlag = !0; impl<T> RefCell<T> { /// Creates a new `RefCell` containing `value`. diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 3f8bbeb1feb..be804327663 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -14,6 +14,7 @@ use cell::{Cell, RefCell, Ref, RefMut, BorrowState}; use char::CharExt; +use clone::Clone; use iter::Iterator; use marker::{Copy, PhantomData, Sized}; use mem; @@ -53,7 +54,7 @@ pub type Result = result::Result<(), Error>; /// occurred. Any extra information must be arranged to be transmitted through /// some other means. #[stable(feature = "rust1", since = "1.0.0")] -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub struct Error; /// A collection of methods that are required to format a message into a stream. @@ -140,6 +141,12 @@ pub struct ArgumentV1<'a> { formatter: fn(&Void, &mut Formatter) -> Result, } +impl<'a> Clone for ArgumentV1<'a> { + fn clone(&self) -> ArgumentV1<'a> { + *self + } +} + impl<'a> ArgumentV1<'a> { #[inline(never)] fn show_usize(x: &usize, f: &mut Formatter) -> Result { @@ -174,7 +181,7 @@ impl<'a> ArgumentV1<'a> { } // flags available in the v1 format of format_args -#[derive(Copy)] +#[derive(Copy, Clone)] #[allow(dead_code)] // SignMinus isn't currently used enum FlagV1 { SignPlus, SignMinus, Alternate, SignAwareZeroPad, } @@ -221,7 +228,7 @@ impl<'a> Arguments<'a> { /// macro validates the format string at compile-time so usage of the `write` /// and `format` functions can be safely performed. #[stable(feature = "rust1", since = "1.0.0")] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Arguments<'a> { // Format string pieces to print. pieces: &'a [&'a str], diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index f3f5a0b70cb..76c975902aa 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -139,7 +139,7 @@ impl GenericRadix for Radix { /// A helper type for formatting radixes. #[unstable(feature = "core", reason = "may be renamed or move to a different module")] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct RadixFmt<T, R>(T, R); /// Constructs a radix formatter in the range of `2..36`. diff --git a/src/libcore/fmt/rt/v1.rs b/src/libcore/fmt/rt/v1.rs index 7f6dea905da..d56ec6a74d4 100644 --- a/src/libcore/fmt/rt/v1.rs +++ b/src/libcore/fmt/rt/v1.rs @@ -16,7 +16,7 @@ #![stable(feature = "rust1", since = "1.0.0")] -#[derive(Copy)] +#[derive(Copy, Clone)] #[stable(feature = "rust1", since = "1.0.0")] pub struct Argument { #[stable(feature = "rust1", since = "1.0.0")] @@ -25,7 +25,7 @@ pub struct Argument { pub format: FormatSpec, } -#[derive(Copy)] +#[derive(Copy, Clone)] #[stable(feature = "rust1", since = "1.0.0")] pub struct FormatSpec { #[stable(feature = "rust1", since = "1.0.0")] @@ -41,7 +41,7 @@ pub struct FormatSpec { } /// Possible alignments that can be requested as part of a formatting directive. -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] #[stable(feature = "rust1", since = "1.0.0")] pub enum Alignment { /// Indication that contents should be left-aligned. @@ -58,7 +58,7 @@ pub enum Alignment { Unknown, } -#[derive(Copy)] +#[derive(Copy, Clone)] #[stable(feature = "rust1", since = "1.0.0")] pub enum Count { #[stable(feature = "rust1", since = "1.0.0")] @@ -71,7 +71,7 @@ pub enum Count { Implied, } -#[derive(Copy)] +#[derive(Copy, Clone)] #[stable(feature = "rust1", since = "1.0.0")] pub enum Position { #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index d1d9c389942..619f983aee0 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -76,7 +76,7 @@ pub trait Sized : MarkerTrait { /// /// ``` /// // we can just derive a `Copy` implementation -/// #[derive(Debug, Copy)] +/// #[derive(Debug, Copy, Clone)] /// struct Foo; /// /// let x = Foo; @@ -125,7 +125,7 @@ pub trait Sized : MarkerTrait { /// There are two ways to implement `Copy` on your type: /// /// ``` -/// #[derive(Copy)] +/// #[derive(Copy, Clone)] /// struct MyStruct; /// ``` /// @@ -134,6 +134,7 @@ pub trait Sized : MarkerTrait { /// ``` /// struct MyStruct; /// impl Copy for MyStruct {} +/// impl Clone for MyStruct { fn clone(&self) -> MyStruct { *self } } /// ``` /// /// There is a small difference between the two: the `derive` strategy will also place a `Copy` @@ -155,7 +156,7 @@ pub trait Sized : MarkerTrait { /// change: that second example would fail to compile if we made `Foo` non-`Copy`. #[stable(feature = "rust1", since = "1.0.0")] #[lang="copy"] -pub trait Copy : MarkerTrait { +pub trait Copy : Clone { // Empty. } diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 4e458e993a0..28e0bcf13dd 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -516,7 +516,7 @@ macro_rules! uint_impl { fn min_value() -> $T { 0 } #[inline] - fn max_value() -> $T { -1 } + fn max_value() -> $T { !0 } #[inline] fn count_ones(self) -> u32 { @@ -1347,7 +1347,7 @@ macro_rules! uint_impl { /// Returns the largest value that can be represented by this integer type. #[stable(feature = "rust1", since = "1.0.0")] - pub fn max_value() -> $T { -1 } + pub fn max_value() -> $T { !0 } /// Convert a string slice in a given base to an integer. /// @@ -2444,7 +2444,7 @@ impl_num_cast! { f32, to_f32 } impl_num_cast! { f64, to_f64 } /// Used for representing the classification of floating point numbers -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] #[stable(feature = "rust1", since = "1.0.0")] pub enum FpCategory { /// "Not a Number", often obtained by dividing by zero diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs index a78eed8ae5f..28276d0bf01 100644 --- a/src/libcore/num/wrapping.rs +++ b/src/libcore/num/wrapping.rs @@ -30,7 +30,7 @@ use intrinsics::{i16_mul_with_overflow, u16_mul_with_overflow}; use intrinsics::{i32_mul_with_overflow, u32_mul_with_overflow}; use intrinsics::{i64_mul_with_overflow, u64_mul_with_overflow}; -use ::{i8,i16,i32,i64,u8,u16,u32,u64}; +use ::{i8,i16,i32,i64}; #[unstable(feature = "core", reason = "may be removed, renamed, or relocated")] #[deprecated(since = "1.0.0", reason = "moved to inherent methods")] @@ -206,7 +206,7 @@ mod shift_max { pub const u64: u32 = i64; } -macro_rules! overflowing_impl { +macro_rules! signed_overflowing_impl { ($($t:ident)*) => ($( impl OverflowingOps for $t { #[inline(always)] @@ -259,7 +259,53 @@ macro_rules! overflowing_impl { )*) } -overflowing_impl! { u8 u16 u32 u64 i8 i16 i32 i64 } +macro_rules! unsigned_overflowing_impl { + ($($t:ident)*) => ($( + impl OverflowingOps for $t { + #[inline(always)] + fn overflowing_add(self, rhs: $t) -> ($t, bool) { + unsafe { + concat_idents!($t, _add_with_overflow)(self, rhs) + } + } + #[inline(always)] + fn overflowing_sub(self, rhs: $t) -> ($t, bool) { + unsafe { + concat_idents!($t, _sub_with_overflow)(self, rhs) + } + } + #[inline(always)] + fn overflowing_mul(self, rhs: $t) -> ($t, bool) { + unsafe { + concat_idents!($t, _mul_with_overflow)(self, rhs) + } + } + + #[inline(always)] + fn overflowing_div(self, rhs: $t) -> ($t, bool) { + (self/rhs, false) + } + #[inline(always)] + fn overflowing_rem(self, rhs: $t) -> ($t, bool) { + (self % rhs, false) + } + + #[inline(always)] + fn overflowing_shl(self, rhs: u32) -> ($t, bool) { + (self << (rhs & self::shift_max::$t), + (rhs > self::shift_max::$t)) + } + #[inline(always)] + fn overflowing_shr(self, rhs: u32) -> ($t, bool) { + (self >> (rhs & self::shift_max::$t), + (rhs > self::shift_max::$t)) + } + } + )*) +} + +signed_overflowing_impl! { i8 i16 i32 i64 } +unsigned_overflowing_impl! { u8 u16 u32 u64 } #[cfg(target_pointer_width = "64")] impl OverflowingOps for usize { diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 21af342b1bf..faf305c6a13 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -165,7 +165,7 @@ macro_rules! forward_ref_binop { /// ``` /// use std::ops::Add; /// -/// #[derive(Copy)] +/// #[derive(Copy, Clone)] /// struct Foo; /// /// impl Add for Foo { @@ -219,7 +219,7 @@ add_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// ``` /// use std::ops::Sub; /// -/// #[derive(Copy)] +/// #[derive(Copy, Clone)] /// struct Foo; /// /// impl Sub for Foo { @@ -273,7 +273,7 @@ sub_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// ``` /// use std::ops::Mul; /// -/// #[derive(Copy)] +/// #[derive(Copy, Clone)] /// struct Foo; /// /// impl Mul for Foo { @@ -327,7 +327,7 @@ mul_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// ``` /// use std::ops::Div; /// -/// #[derive(Copy)] +/// #[derive(Copy, Clone)] /// struct Foo; /// /// impl Div for Foo { @@ -381,7 +381,7 @@ div_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// ``` /// use std::ops::Rem; /// -/// #[derive(Copy)] +/// #[derive(Copy, Clone)] /// struct Foo; /// /// impl Rem for Foo { @@ -454,7 +454,7 @@ rem_float_impl! { f64, fmod } /// ``` /// use std::ops::Neg; /// -/// #[derive(Copy)] +/// #[derive(Copy, Clone)] /// struct Foo; /// /// impl Neg for Foo { @@ -482,8 +482,10 @@ pub trait Neg { fn neg(self) -> Self::Output; } -macro_rules! neg_impl { - ($($t:ty)*) => ($( + + +macro_rules! neg_impl_core { + ($id:ident => $body:expr, $($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] #[allow(unsigned_negation)] impl Neg for $t { @@ -492,14 +494,28 @@ macro_rules! neg_impl { #[inline] #[stable(feature = "rust1", since = "1.0.0")] - fn neg(self) -> $t { -self } + fn neg(self) -> $t { let $id = self; $body } } forward_ref_unop! { impl Neg, neg for $t } )*) } -neg_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } +macro_rules! neg_impl_numeric { + ($($t:ty)*) => { neg_impl_core!{ x => -x, $($t)*} } +} + +macro_rules! neg_impl_unsigned { + ($($t:ty)*) => { + neg_impl_core!{ x => { + #[cfg(stage0)] + use ::num::wrapping::WrappingOps; + !x.wrapping_add(1) + }, $($t)*} } +} + +// neg_impl_unsigned! { usize u8 u16 u32 u64 } +neg_impl_numeric! { isize i8 i16 i32 i64 f32 f64 } /// The `Not` trait is used to specify the functionality of unary `!`. /// @@ -511,7 +527,7 @@ neg_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// ``` /// use std::ops::Not; /// -/// #[derive(Copy)] +/// #[derive(Copy, Clone)] /// struct Foo; /// /// impl Not for Foo { @@ -565,7 +581,7 @@ not_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } /// ``` /// use std::ops::BitAnd; /// -/// #[derive(Copy)] +/// #[derive(Copy, Clone)] /// struct Foo; /// /// impl BitAnd for Foo { @@ -619,7 +635,7 @@ bitand_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } /// ``` /// use std::ops::BitOr; /// -/// #[derive(Copy)] +/// #[derive(Copy, Clone)] /// struct Foo; /// /// impl BitOr for Foo { @@ -673,7 +689,7 @@ bitor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } /// ``` /// use std::ops::BitXor; /// -/// #[derive(Copy)] +/// #[derive(Copy, Clone)] /// struct Foo; /// /// impl BitXor for Foo { @@ -727,7 +743,7 @@ bitxor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } /// ``` /// use std::ops::Shl; /// -/// #[derive(Copy)] +/// #[derive(Copy, Clone)] /// struct Foo; /// /// impl Shl<Foo> for Foo { @@ -799,7 +815,7 @@ shl_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } /// ``` /// use std::ops::Shr; /// -/// #[derive(Copy)] +/// #[derive(Copy, Clone)] /// struct Foo; /// /// impl Shr<Foo> for Foo { @@ -871,7 +887,7 @@ shr_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } /// ``` /// use std::ops::Index; /// -/// #[derive(Copy)] +/// #[derive(Copy, Clone)] /// struct Foo; /// struct Bar; /// @@ -912,7 +928,7 @@ pub trait Index<Idx: ?Sized> { /// ``` /// use std::ops::{Index, IndexMut}; /// -/// #[derive(Copy)] +/// #[derive(Copy, Clone)] /// struct Foo; /// struct Bar; /// diff --git a/src/libcore/raw.rs b/src/libcore/raw.rs index 47d1f3a1a3c..ded52ff0778 100644 --- a/src/libcore/raw.rs +++ b/src/libcore/raw.rs @@ -18,6 +18,7 @@ //! //! Their definition should always match the ABI defined in `rustc::back::abi`. +use clone::Clone; use marker::Copy; use mem; @@ -63,6 +64,9 @@ pub struct Slice<T> { } impl<T> Copy for Slice<T> {} +impl<T> Clone for Slice<T> { + fn clone(&self) -> Slice<T> { *self } +} /// The representation of a trait object like `&SomeTrait`. /// @@ -136,7 +140,7 @@ impl<T> Copy for Slice<T> {} /// assert_eq!(synthesized.bar(), 457); /// ``` #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct TraitObject { pub data: *mut (), pub vtable: *mut (), diff --git a/src/libcore/simd.rs b/src/libcore/simd.rs index 21cff3021ab..7b55ba49a07 100644 --- a/src/libcore/simd.rs +++ b/src/libcore/simd.rs @@ -38,7 +38,7 @@ #[unstable(feature = "core")] #[simd] -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] #[repr(C)] pub struct i8x16(pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, @@ -47,26 +47,26 @@ pub struct i8x16(pub i8, pub i8, pub i8, pub i8, #[unstable(feature = "core")] #[simd] -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] #[repr(C)] pub struct i16x8(pub i16, pub i16, pub i16, pub i16, pub i16, pub i16, pub i16, pub i16); #[unstable(feature = "core")] #[simd] -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] #[repr(C)] pub struct i32x4(pub i32, pub i32, pub i32, pub i32); #[unstable(feature = "core")] #[simd] -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] #[repr(C)] pub struct i64x2(pub i64, pub i64); #[unstable(feature = "core")] #[simd] -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] #[repr(C)] pub struct u8x16(pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, @@ -75,31 +75,31 @@ pub struct u8x16(pub u8, pub u8, pub u8, pub u8, #[unstable(feature = "core")] #[simd] -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] #[repr(C)] pub struct u16x8(pub u16, pub u16, pub u16, pub u16, pub u16, pub u16, pub u16, pub u16); #[unstable(feature = "core")] #[simd] -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] #[repr(C)] pub struct u32x4(pub u32, pub u32, pub u32, pub u32); #[unstable(feature = "core")] #[simd] -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] #[repr(C)] pub struct u64x2(pub u64, pub u64); #[unstable(feature = "core")] #[simd] -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] #[repr(C)] pub struct f32x4(pub f32, pub f32, pub f32, pub f32); #[unstable(feature = "core")] #[simd] -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] #[repr(C)] pub struct f64x2(pub f64, pub f64); diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index f07c988c2b4..dbb365c4e23 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -855,7 +855,7 @@ impl TwoWaySearcher { #[allow(dead_code)] #[allow(deprecated)] fn maximal_suffix(arr: &[u8], reversed: bool) -> (usize, usize) { - let mut left: usize = -1; // Corresponds to i in the paper + let mut left: usize = !0; // Corresponds to i in the paper let mut right = 0; // Corresponds to j in the paper let mut offset = 1; // Corresponds to k in the paper let mut period = 1; // Corresponds to p in the paper @@ -1105,7 +1105,7 @@ static UTF8_CHAR_WIDTH: [u8; 256] = [ /// Struct that contains a `char` and the index of the first byte of /// the next `char` in a string. This can be used as a data structure /// for iterating over the UTF-8 bytes of a string. -#[derive(Copy)] +#[derive(Copy, Clone)] #[unstable(feature = "str_char", reason = "existence of this struct is uncertain as it is frequently \ able to be replaced with char.len_utf8() and/or \ diff --git a/src/libcoretest/fmt/num.rs b/src/libcoretest/fmt/num.rs index 7db8db444ff..ba12ff306e9 100644 --- a/src/libcoretest/fmt/num.rs +++ b/src/libcoretest/fmt/num.rs @@ -125,14 +125,14 @@ fn test_format_int_flags() { assert!(format!("{:>8x}", 10) == " a"); assert!(format!("{:#08x}", 10) == "0x00000a"); assert!(format!("{:08}", -10) == "-0000010"); - assert!(format!("{:x}", -1u8) == "ff"); - assert!(format!("{:X}", -1u8) == "FF"); - assert!(format!("{:b}", -1u8) == "11111111"); - assert!(format!("{:o}", -1u8) == "377"); - assert!(format!("{:#x}", -1u8) == "0xff"); - assert!(format!("{:#X}", -1u8) == "0xFF"); - assert!(format!("{:#b}", -1u8) == "0b11111111"); - assert!(format!("{:#o}", -1u8) == "0o377"); + assert!(format!("{:x}", !0u8) == "ff"); + assert!(format!("{:X}", !0u8) == "FF"); + assert!(format!("{:b}", !0u8) == "11111111"); + assert!(format!("{:o}", !0u8) == "377"); + assert!(format!("{:#x}", !0u8) == "0xff"); + assert!(format!("{:#X}", !0u8) == "0xFF"); + assert!(format!("{:#b}", !0u8) == "0b11111111"); + assert!(format!("{:#o}", !0u8) == "0o377"); } #[test] diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index a7be6a7fcf0..4cf93ab2645 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -40,7 +40,7 @@ use std::string; /// A piece is a portion of the format string which represents the next part /// to emit. These are emitted as a stream by the `Parser` class. -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub enum Piece<'a> { /// A literal string which should directly be emitted String(&'a str), @@ -50,7 +50,7 @@ pub enum Piece<'a> { } /// Representation of an argument specification. -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub struct Argument<'a> { /// Where to find this argument pub position: Position<'a>, @@ -59,7 +59,7 @@ pub struct Argument<'a> { } /// Specification for the formatting of an argument in the format string. -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub struct FormatSpec<'a> { /// Optionally specified character to fill alignment with pub fill: Option<char>, @@ -78,7 +78,7 @@ pub struct FormatSpec<'a> { } /// Enum describing where an argument for a format can be located. -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub enum Position<'a> { /// The argument will be in the next position. This is the default. ArgumentNext, @@ -89,7 +89,7 @@ pub enum Position<'a> { } /// Enum of alignments which are supported. -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub enum Alignment { /// The value will be aligned to the left. AlignLeft, @@ -103,7 +103,7 @@ pub enum Alignment { /// Various flags which can be applied to format strings. The meaning of these /// flags is defined by the formatters themselves. -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub enum Flag { /// A `+` will be used to denote positive numbers. FlagSignPlus, @@ -119,7 +119,7 @@ pub enum Flag { /// A count is used for the precision and width parameters of an integer, and /// can reference either an argument or a literal integer. -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub enum Count<'a> { /// The count is specified explicitly. CountIs(usize), diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index 9a5dde8e45e..5c10641e851 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -213,7 +213,7 @@ pub enum Fail { } /// The type of failure that occurred. -#[derive(Copy, PartialEq, Eq, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Debug)] #[allow(missing_docs)] pub enum FailType { ArgumentMissing_, @@ -843,18 +843,18 @@ pub fn short_usage(program_name: &str, opts: &[OptGroup]) -> String { line } -#[derive(Copy)] +#[derive(Copy, Clone)] enum SplitWithinState { A, // leading whitespace, initial state B, // words C, // internal and trailing whitespace } -#[derive(Copy)] +#[derive(Copy, Clone)] enum Whitespace { Ws, // current char is whitespace Cr // current char is not whitespace } -#[derive(Copy)] +#[derive(Copy, Clone)] enum LengthLimit { UnderLim, // current char makes current substring still fit in limit OverLim // current char makes current substring no longer fit in limit diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index 74be96235d2..95b78e1cbfd 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -524,7 +524,7 @@ pub trait GraphWalk<'a, N, E> { fn target(&'a self, edge: &E) -> N; } -#[derive(Copy, PartialEq, Eq, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Debug)] pub enum RenderOption { NoEdgeLabels, NoNodeLabels, diff --git a/src/liblibc/lib.rs b/src/liblibc/lib.rs index b7162c4a177..44d689059d1 100644 --- a/src/liblibc/lib.rs +++ b/src/liblibc/lib.rs @@ -227,7 +227,7 @@ pub mod types { pub type rlim_t = u64; #[repr(C)] - #[derive(Copy)] pub struct glob_t { + #[derive(Copy, Clone)] pub struct glob_t { pub gl_pathc: size_t, pub gl_pathv: *mut *mut c_char, pub gl_offs: size_t, @@ -240,23 +240,23 @@ pub mod types { } #[repr(C)] - #[derive(Copy)] pub struct timeval { + #[derive(Copy, Clone)] pub struct timeval { pub tv_sec: time_t, pub tv_usec: suseconds_t, } #[repr(C)] - #[derive(Copy)] pub struct timespec { + #[derive(Copy, Clone)] pub struct timespec { pub tv_sec: time_t, pub tv_nsec: c_long, } - #[derive(Copy)] pub enum timezone {} + pub enum timezone {} pub type sighandler_t = size_t; #[repr(C)] - #[derive(Copy)] + #[derive(Copy, Clone)] pub struct rlimit { pub rlim_cur: rlim_t, pub rlim_max: rlim_t, @@ -269,7 +269,7 @@ pub mod types { // This is also specified in POSIX 2001, but only has two fields. All implementors // implement BSD 4.3 version. #[repr(C)] - #[derive(Copy)] + #[derive(Copy, Clone)] pub struct rusage { pub ru_utime: timeval, pub ru_stime: timeval, @@ -299,7 +299,7 @@ pub mod types { pub type in_port_t = u16; pub type in_addr_t = u32; #[repr(C)] - #[derive(Copy)] pub struct sockaddr { + #[derive(Copy, Clone)] pub struct sockaddr { pub sa_family: sa_family_t, pub sa_data: [u8; 14], } @@ -312,19 +312,22 @@ pub mod types { #[cfg(target_pointer_width = "64")] pub __ss_pad2: [u8; 128 - 2 * 8], } + impl ::core::clone::Clone for sockaddr_storage { + fn clone(&self) -> sockaddr_storage { *self } + } #[repr(C)] - #[derive(Copy)] pub struct sockaddr_in { + #[derive(Copy, Clone)] pub struct sockaddr_in { pub sin_family: sa_family_t, pub sin_port: in_port_t, pub sin_addr: in_addr, pub sin_zero: [u8; 8], } #[repr(C)] - #[derive(Copy)] pub struct in_addr { + #[derive(Copy, Clone)] pub struct in_addr { pub s_addr: in_addr_t, } #[repr(C)] - #[derive(Copy)] pub struct sockaddr_in6 { + #[derive(Copy, Clone)] pub struct sockaddr_in6 { pub sin6_family: sa_family_t, pub sin6_port: in_port_t, pub sin6_flowinfo: u32, @@ -332,21 +335,21 @@ pub mod types { pub sin6_scope_id: u32, } #[repr(C)] - #[derive(Copy)] pub struct in6_addr { + #[derive(Copy, Clone)] pub struct in6_addr { pub s6_addr: [u16; 8] } #[repr(C)] - #[derive(Copy)] pub struct ip_mreq { + #[derive(Copy, Clone)] pub struct ip_mreq { pub imr_multiaddr: in_addr, pub imr_interface: in_addr, } #[repr(C)] - #[derive(Copy)] pub struct ip6_mreq { + #[derive(Copy, Clone)] pub struct ip6_mreq { pub ipv6mr_multiaddr: in6_addr, pub ipv6mr_interface: c_uint, } #[repr(C)] - #[derive(Copy)] pub struct addrinfo { + #[derive(Copy, Clone)] pub struct addrinfo { pub ai_flags: c_int, pub ai_family: c_int, pub ai_socktype: c_int, @@ -372,9 +375,12 @@ pub mod types { pub sun_family: sa_family_t, pub sun_path: [c_char; 108] } + impl ::core::clone::Clone for sockaddr_un { + fn clone(&self) -> sockaddr_un { *self } + } #[repr(C)] - #[derive(Copy)] pub struct ifaddrs { + #[derive(Copy, Clone)] pub struct ifaddrs { pub ifa_next: *mut ifaddrs, pub ifa_name: *mut c_char, pub ifa_flags: c_uint, @@ -465,7 +471,7 @@ pub mod types { pub type blkcnt_t = i32; #[repr(C)] - #[derive(Copy)] pub struct stat { + #[derive(Copy, Clone)] pub struct stat { pub st_dev: dev_t, pub __pad1: c_short, pub st_ino: ino_t, @@ -489,13 +495,13 @@ pub mod types { } #[repr(C)] - #[derive(Copy)] pub struct utimbuf { + #[derive(Copy, Clone)] pub struct utimbuf { pub actime: time_t, pub modtime: time_t, } #[repr(C)] - #[derive(Copy)] pub struct pthread_attr_t { + #[derive(Copy, Clone)] pub struct pthread_attr_t { pub __size: [u32; 9] } } @@ -510,7 +516,7 @@ pub mod types { pub type blkcnt_t = u32; #[repr(C)] - #[derive(Copy)] pub struct stat { + #[derive(Copy, Clone)] pub struct stat { pub st_dev: c_ulonglong, pub __pad0: [c_uchar; 4], pub __st_ino: ino_t, @@ -533,13 +539,13 @@ pub mod types { } #[repr(C)] - #[derive(Copy)] pub struct utimbuf { + #[derive(Copy, Clone)] pub struct utimbuf { pub actime: time_t, pub modtime: time_t, } #[repr(C)] - #[derive(Copy)] pub struct pthread_attr_t { + #[derive(Copy, Clone)] pub struct pthread_attr_t { pub __size: [u32; 9] } } @@ -556,7 +562,7 @@ pub mod types { pub type blkcnt_t = i32; #[repr(C)] - #[derive(Copy)] pub struct stat { + #[derive(Copy, Clone)] pub struct stat { pub st_dev: c_ulong, pub st_pad1: [c_long; 3], pub st_ino: ino_t, @@ -580,13 +586,13 @@ pub mod types { } #[repr(C)] - #[derive(Copy)] pub struct utimbuf { + #[derive(Copy, Clone)] pub struct utimbuf { pub actime: time_t, pub modtime: time_t, } #[repr(C)] - #[derive(Copy)] pub struct pthread_attr_t { + #[derive(Copy, Clone)] pub struct pthread_attr_t { pub __size: [u32; 9] } } @@ -595,7 +601,7 @@ pub mod types { pub mod extra { use types::os::arch::c95::{c_ushort, c_int, c_uchar}; #[repr(C)] - #[derive(Copy)] pub struct sockaddr_ll { + #[derive(Copy, Clone)] pub struct sockaddr_ll { pub sll_family: c_ushort, pub sll_protocol: c_ushort, pub sll_ifindex: c_int, @@ -667,7 +673,7 @@ pub mod types { pub type blkcnt_t = i64; #[repr(C)] - #[derive(Copy)] pub struct stat { + #[derive(Copy, Clone)] pub struct stat { pub st_dev: dev_t, pub st_ino: ino_t, pub st_nlink: nlink_t, @@ -689,13 +695,13 @@ pub mod types { } #[repr(C)] - #[derive(Copy)] pub struct utimbuf { + #[derive(Copy, Clone)] pub struct utimbuf { pub actime: time_t, pub modtime: time_t, } #[repr(C)] - #[derive(Copy)] pub struct pthread_attr_t { + #[derive(Copy, Clone)] pub struct pthread_attr_t { pub __size: [u64; 7] } } @@ -711,7 +717,7 @@ pub mod types { pub type blkcnt_t = i64; #[repr(C)] - #[derive(Copy)] pub struct stat { + #[derive(Copy, Clone)] pub struct stat { pub st_dev: dev_t, pub st_ino: ino_t, pub st_mode: mode_t, @@ -734,13 +740,13 @@ pub mod types { } #[repr(C)] - #[derive(Copy)] pub struct utimbuf { + #[derive(Copy, Clone)] pub struct utimbuf { pub actime: time_t, pub modtime: time_t, } #[repr(C)] - #[derive(Copy)] pub struct pthread_attr_t { + #[derive(Copy, Clone)] pub struct pthread_attr_t { pub __size: [u64; 8] } } @@ -750,7 +756,7 @@ pub mod types { } pub mod extra { use types::os::arch::c95::{c_ushort, c_int, c_uchar}; - #[derive(Copy)] pub struct sockaddr_ll { + #[derive(Copy, Clone)] pub struct sockaddr_ll { pub sll_family: c_ushort, pub sll_protocol: c_ushort, pub sll_ifindex: c_int, @@ -777,7 +783,7 @@ pub mod types { pub type rlim_t = i64; #[repr(C)] - #[derive(Copy)] pub struct glob_t { + #[derive(Copy, Clone)] pub struct glob_t { pub gl_pathc: size_t, pub __unused1: size_t, pub gl_offs: size_t, @@ -794,23 +800,23 @@ pub mod types { } #[repr(C)] - #[derive(Copy)] pub struct timeval { + #[derive(Copy, Clone)] pub struct timeval { pub tv_sec: time_t, pub tv_usec: suseconds_t, } #[repr(C)] - #[derive(Copy)] pub struct timespec { + #[derive(Copy, Clone)] pub struct timespec { pub tv_sec: time_t, pub tv_nsec: c_long, } - #[derive(Copy)] pub enum timezone {} + pub enum timezone {} pub type sighandler_t = size_t; #[repr(C)] - #[derive(Copy)] + #[derive(Copy, Clone)] pub struct rlimit { pub rlim_cur: rlim_t, pub rlim_max: rlim_t, @@ -821,7 +827,7 @@ pub mod types { use types::os::common::posix01::timeval; use types::os::arch::c95::c_long; #[repr(C)] - #[derive(Copy)] + #[derive(Copy, Clone)] pub struct rusage { pub ru_utime: timeval, pub ru_stime: timeval, @@ -851,13 +857,13 @@ pub mod types { pub type in_port_t = u16; pub type in_addr_t = u32; #[repr(C)] - #[derive(Copy)] pub struct sockaddr { + #[derive(Copy, Clone)] pub struct sockaddr { pub sa_len: u8, pub sa_family: sa_family_t, pub sa_data: [u8; 14], } #[repr(C)] - #[derive(Copy)] pub struct sockaddr_storage { + #[derive(Copy, Clone)] pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: sa_family_t, pub __ss_pad1: [u8; 6], @@ -865,7 +871,7 @@ pub mod types { pub __ss_pad2: [u8; 112], } #[repr(C)] - #[derive(Copy)] pub struct sockaddr_in { + #[derive(Copy, Clone)] pub struct sockaddr_in { pub sin_len: u8, pub sin_family: sa_family_t, pub sin_port: in_port_t, @@ -873,11 +879,11 @@ pub mod types { pub sin_zero: [u8; 8], } #[repr(C)] - #[derive(Copy)] pub struct in_addr { + #[derive(Copy, Clone)] pub struct in_addr { pub s_addr: in_addr_t, } #[repr(C)] - #[derive(Copy)] pub struct sockaddr_in6 { + #[derive(Copy, Clone)] pub struct sockaddr_in6 { pub sin6_len: u8, pub sin6_family: sa_family_t, pub sin6_port: in_port_t, @@ -886,21 +892,21 @@ pub mod types { pub sin6_scope_id: u32, } #[repr(C)] - #[derive(Copy)] pub struct in6_addr { + #[derive(Copy, Clone)] pub struct in6_addr { pub s6_addr: [u16; 8] } #[repr(C)] - #[derive(Copy)] pub struct ip_mreq { + #[derive(Copy, Clone)] pub struct ip_mreq { pub imr_multiaddr: in_addr, pub imr_interface: in_addr, } #[repr(C)] - #[derive(Copy)] pub struct ip6_mreq { + #[derive(Copy, Clone)] pub struct ip6_mreq { pub ipv6mr_multiaddr: in6_addr, pub ipv6mr_interface: c_uint, } #[repr(C)] - #[derive(Copy)] pub struct addrinfo { + #[derive(Copy, Clone)] pub struct addrinfo { pub ai_flags: c_int, pub ai_family: c_int, pub ai_socktype: c_int, @@ -911,13 +917,13 @@ pub mod types { pub ai_next: *mut addrinfo, } #[repr(C)] - #[derive(Copy)] pub struct sockaddr_un { + #[derive(Copy, Clone)] pub struct sockaddr_un { pub sun_len: u8, pub sun_family: sa_family_t, pub sun_path: [c_char; 104] } #[repr(C)] - #[derive(Copy)] pub struct ifaddrs { + #[derive(Copy, Clone)] pub struct ifaddrs { pub ifa_next: *mut ifaddrs, pub ifa_name: *mut c_char, pub ifa_flags: c_uint, @@ -984,7 +990,7 @@ pub mod types { pub type blkcnt_t = i64; pub type fflags_t = u32; #[repr(C)] - #[derive(Copy)] pub struct stat { + #[derive(Copy, Clone)] pub struct stat { pub st_dev: dev_t, pub st_ino: ino_t, pub st_mode: mode_t, @@ -1010,7 +1016,7 @@ pub mod types { } #[repr(C)] - #[derive(Copy)] pub struct utimbuf { + #[derive(Copy, Clone)] pub struct utimbuf { pub actime: time_t, pub modtime: time_t, } @@ -1039,7 +1045,7 @@ pub mod types { pub type rlim_t = i64; #[repr(C)] - #[derive(Copy)] pub struct glob_t { + #[derive(Copy, Clone)] pub struct glob_t { pub gl_pathc: size_t, pub __unused1: size_t, pub gl_offs: size_t, @@ -1056,23 +1062,23 @@ pub mod types { } #[repr(C)] - #[derive(Copy)] pub struct timeval { + #[derive(Copy, Clone)] pub struct timeval { pub tv_sec: time_t, pub tv_usec: suseconds_t, } #[repr(C)] - #[derive(Copy)] pub struct timespec { + #[derive(Copy, Clone)] pub struct timespec { pub tv_sec: time_t, pub tv_nsec: c_long, } - #[derive(Copy)] pub enum timezone {} + pub enum timezone {} pub type sighandler_t = size_t; #[repr(C)] - #[derive(Copy)] + #[derive(Copy, Clone)] pub struct rlimit { pub rlim_cur: rlim_t, pub rlim_max: rlim_t, @@ -1083,7 +1089,7 @@ pub mod types { use types::os::common::posix01::timeval; use types::os::arch::c95::c_long; #[repr(C)] - #[derive(Copy)] + #[derive(Copy, Clone)] pub struct rusage { pub ru_utime: timeval, pub ru_stime: timeval, @@ -1113,13 +1119,13 @@ pub mod types { pub type in_port_t = u16; pub type in_addr_t = u32; #[repr(C)] - #[derive(Copy)] pub struct sockaddr { + #[derive(Copy, Clone)] pub struct sockaddr { pub sa_len: u8, pub sa_family: sa_family_t, pub sa_data: [u8; 14], } #[repr(C)] - #[derive(Copy)] pub struct sockaddr_storage { + #[derive(Copy, Clone)] pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: sa_family_t, pub __ss_pad1: [u8; 6], @@ -1127,7 +1133,7 @@ pub mod types { pub __ss_pad2: [u8; 112], } #[repr(C)] - #[derive(Copy)] pub struct sockaddr_in { + #[derive(Copy, Clone)] pub struct sockaddr_in { pub sin_len: u8, pub sin_family: sa_family_t, pub sin_port: in_port_t, @@ -1135,11 +1141,11 @@ pub mod types { pub sin_zero: [u8; 8], } #[repr(C)] - #[derive(Copy)] pub struct in_addr { + #[derive(Copy, Clone)] pub struct in_addr { pub s_addr: in_addr_t, } #[repr(C)] - #[derive(Copy)] pub struct sockaddr_in6 { + #[derive(Copy, Clone)] pub struct sockaddr_in6 { pub sin6_len: u8, pub sin6_family: sa_family_t, pub sin6_port: in_port_t, @@ -1148,21 +1154,21 @@ pub mod types { pub sin6_scope_id: u32, } #[repr(C)] - #[derive(Copy)] pub struct in6_addr { + #[derive(Copy, Clone)] pub struct in6_addr { pub s6_addr: [u16; 8] } #[repr(C)] - #[derive(Copy)] pub struct ip_mreq { + #[derive(Copy, Clone)] pub struct ip_mreq { pub imr_multiaddr: in_addr, pub imr_interface: in_addr, } #[repr(C)] - #[derive(Copy)] pub struct ip6_mreq { + #[derive(Copy, Clone)] pub struct ip6_mreq { pub ipv6mr_multiaddr: in6_addr, pub ipv6mr_interface: c_uint, } #[repr(C)] - #[derive(Copy)] pub struct addrinfo { + #[derive(Copy, Clone)] pub struct addrinfo { pub ai_flags: c_int, pub ai_family: c_int, pub ai_socktype: c_int, @@ -1173,13 +1179,13 @@ pub mod types { pub ai_next: *mut addrinfo, } #[repr(C)] - #[derive(Copy)] pub struct sockaddr_un { + #[derive(Copy, Clone)] pub struct sockaddr_un { pub sun_len: u8, pub sun_family: sa_family_t, pub sun_path: [c_char; 104] } #[repr(C)] - #[derive(Copy)] pub struct ifaddrs { + #[derive(Copy, Clone)] pub struct ifaddrs { pub ifa_next: *mut ifaddrs, pub ifa_name: *mut c_char, pub ifa_flags: c_uint, @@ -1246,7 +1252,7 @@ pub mod types { pub type fflags_t = u32; #[repr(C)] - #[derive(Copy)] pub struct stat { + #[derive(Copy, Clone)] pub struct stat { pub st_ino: ino_t, pub st_nlink: nlink_t, pub st_dev: dev_t, @@ -1271,7 +1277,7 @@ pub mod types { pub st_qspare2: int64_t, } #[repr(C)] - #[derive(Copy)] pub struct utimbuf { + #[derive(Copy, Clone)] pub struct utimbuf { pub actime: time_t, pub modtime: time_t, } @@ -1301,7 +1307,7 @@ pub mod types { #[cfg(target_os = "bitrig")] #[repr(C)] - #[derive(Copy)] pub struct glob_t { + #[derive(Copy, Clone)] pub struct glob_t { pub gl_pathc: c_int, pub gl_matchc: c_int, pub gl_offs: c_int, @@ -1318,7 +1324,7 @@ pub mod types { #[cfg(target_os = "openbsd")] #[repr(C)] - #[derive(Copy)] pub struct glob_t { + #[derive(Copy, Clone)] pub struct glob_t { pub gl_pathc: c_int, pub __unused1: c_int, pub gl_offs: c_int, @@ -1336,23 +1342,23 @@ pub mod types { } #[repr(C)] - #[derive(Copy)] pub struct timeval { + #[derive(Copy, Clone)] pub struct timeval { pub tv_sec: time_t, pub tv_usec: suseconds_t, } #[repr(C)] - #[derive(Copy)] pub struct timespec { + #[derive(Copy, Clone)] pub struct timespec { pub tv_sec: time_t, pub tv_nsec: c_long, } - #[derive(Copy)] pub enum timezone {} + pub enum timezone {} pub type sighandler_t = size_t; #[repr(C)] - #[derive(Copy)] + #[derive(Copy, Clone)] pub struct rlimit { pub rlim_cur: rlim_t, pub rlim_max: rlim_t, @@ -1363,7 +1369,7 @@ pub mod types { use types::os::common::posix01::timeval; use types::os::arch::c95::c_long; #[repr(C)] - #[derive(Copy)] + #[derive(Copy, Clone)] pub struct rusage { pub ru_utime: timeval, pub ru_stime: timeval, @@ -1393,13 +1399,13 @@ pub mod types { pub type in_port_t = u16; pub type in_addr_t = u32; #[repr(C)] - #[derive(Copy)] pub struct sockaddr { + #[derive(Copy, Clone)] pub struct sockaddr { pub sa_len: u8, pub sa_family: sa_family_t, pub sa_data: [u8; 14], } #[repr(C)] - #[derive(Copy)] pub struct sockaddr_storage { + #[derive(Copy, Clone)] pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: sa_family_t, pub __ss_pad1: [u8; 6], @@ -1407,7 +1413,7 @@ pub mod types { pub __ss_pad3: [u8; 240], } #[repr(C)] - #[derive(Copy)] pub struct sockaddr_in { + #[derive(Copy, Clone)] pub struct sockaddr_in { pub sin_len: u8, pub sin_family: sa_family_t, pub sin_port: in_port_t, @@ -1415,11 +1421,11 @@ pub mod types { pub sin_zero: [u8; 8], } #[repr(C)] - #[derive(Copy)] pub struct in_addr { + #[derive(Copy, Clone)] pub struct in_addr { pub s_addr: in_addr_t, } #[repr(C)] - #[derive(Copy)] pub struct sockaddr_in6 { + #[derive(Copy, Clone)] pub struct sockaddr_in6 { pub sin6_len: u8, pub sin6_family: sa_family_t, pub sin6_port: in_port_t, @@ -1428,21 +1434,21 @@ pub mod types { pub sin6_scope_id: u32, } #[repr(C)] - #[derive(Copy)] pub struct in6_addr { + #[derive(Copy, Clone)] pub struct in6_addr { pub s6_addr: [u16; 8] } #[repr(C)] - #[derive(Copy)] pub struct ip_mreq { + #[derive(Copy, Clone)] pub struct ip_mreq { pub imr_multiaddr: in_addr, pub imr_interface: in_addr, } #[repr(C)] - #[derive(Copy)] pub struct ip6_mreq { + #[derive(Copy, Clone)] pub struct ip6_mreq { pub ipv6mr_multiaddr: in6_addr, pub ipv6mr_interface: c_uint, } #[repr(C)] - #[derive(Copy)] pub struct addrinfo { + #[derive(Copy, Clone)] pub struct addrinfo { pub ai_flags: c_int, pub ai_family: c_int, pub ai_socktype: c_int, @@ -1453,13 +1459,13 @@ pub mod types { pub ai_next: *mut addrinfo, } #[repr(C)] - #[derive(Copy)] pub struct sockaddr_un { + #[derive(Copy, Clone)] pub struct sockaddr_un { pub sun_len: u8, pub sun_family: sa_family_t, pub sun_path: [c_char; 104] } #[repr(C)] - #[derive(Copy)] pub struct ifaddrs { + #[derive(Copy, Clone)] pub struct ifaddrs { pub ifa_next: *mut ifaddrs, pub ifa_name: *mut c_char, pub ifa_flags: c_uint, @@ -1526,7 +1532,7 @@ pub mod types { pub type fflags_t = u32; // type not declared, but struct stat have u_int32_t #[repr(C)] - #[derive(Copy)] pub struct stat { + #[derive(Copy, Clone)] pub struct stat { pub st_mode: mode_t, pub st_dev: dev_t, pub st_ino: ino_t, @@ -1549,7 +1555,7 @@ pub mod types { pub st_birthtime_nsec: c_long, } #[repr(C)] - #[derive(Copy)] pub struct utimbuf { + #[derive(Copy, Clone)] pub struct utimbuf { pub actime: time_t, pub modtime: time_t, } @@ -1576,7 +1582,7 @@ pub mod types { // pub Note: this is the struct called stat64 in Windows. Not stat, // nor stati64. #[repr(C)] - #[derive(Copy)] pub struct stat { + #[derive(Copy, Clone)] pub struct stat { pub st_dev: dev_t, pub st_ino: ino_t, pub st_mode: u16, @@ -1592,24 +1598,24 @@ pub mod types { // note that this is called utimbuf64 in Windows #[repr(C)] - #[derive(Copy)] pub struct utimbuf { + #[derive(Copy, Clone)] pub struct utimbuf { pub actime: time64_t, pub modtime: time64_t, } #[repr(C)] - #[derive(Copy)] pub struct timeval { + #[derive(Copy, Clone)] pub struct timeval { pub tv_sec: c_long, pub tv_usec: c_long, } #[repr(C)] - #[derive(Copy)] pub struct timespec { + #[derive(Copy, Clone)] pub struct timespec { pub tv_sec: time_t, pub tv_nsec: c_long, } - #[derive(Copy)] pub enum timezone {} + pub enum timezone {} } pub mod bsd44 { @@ -1622,7 +1628,7 @@ pub mod types { pub type in_port_t = u16; pub type in_addr_t = u32; #[repr(C)] - #[derive(Copy)] pub struct sockaddr { + #[derive(Copy, Clone)] pub struct sockaddr { pub sa_family: sa_family_t, pub sa_data: [u8; 14], } @@ -1633,19 +1639,22 @@ pub mod types { pub __ss_align: i64, pub __ss_pad2: [u8; 112], } + impl ::core::clone::Clone for sockaddr_storage { + fn clone(&self) -> sockaddr_storage { *self } + } #[repr(C)] - #[derive(Copy)] pub struct sockaddr_in { + #[derive(Copy, Clone)] pub struct sockaddr_in { pub sin_family: sa_family_t, pub sin_port: in_port_t, pub sin_addr: in_addr, pub sin_zero: [u8; 8], } #[repr(C)] - #[derive(Copy)] pub struct in_addr { + #[derive(Copy, Clone)] pub struct in_addr { pub s_addr: in_addr_t, } #[repr(C)] - #[derive(Copy)] pub struct sockaddr_in6 { + #[derive(Copy, Clone)] pub struct sockaddr_in6 { pub sin6_family: sa_family_t, pub sin6_port: in_port_t, pub sin6_flowinfo: u32, @@ -1653,21 +1662,21 @@ pub mod types { pub sin6_scope_id: u32, } #[repr(C)] - #[derive(Copy)] pub struct in6_addr { + #[derive(Copy, Clone)] pub struct in6_addr { pub s6_addr: [u16; 8] } #[repr(C)] - #[derive(Copy)] pub struct ip_mreq { + #[derive(Copy, Clone)] pub struct ip_mreq { pub imr_multiaddr: in_addr, pub imr_interface: in_addr, } #[repr(C)] - #[derive(Copy)] pub struct ip6_mreq { + #[derive(Copy, Clone)] pub struct ip6_mreq { pub ipv6mr_multiaddr: in6_addr, pub ipv6mr_interface: c_uint, } #[repr(C)] - #[derive(Copy)] pub struct addrinfo { + #[derive(Copy, Clone)] pub struct addrinfo { pub ai_flags: c_int, pub ai_family: c_int, pub ai_socktype: c_int, @@ -1682,6 +1691,9 @@ pub mod types { pub sun_family: sa_family_t, pub sun_path: [c_char; 108] } + impl ::core::clone::Clone for sockaddr_un { + fn clone(&self) -> sockaddr_un { *self } + } } } @@ -1807,7 +1819,7 @@ pub mod types { pub type LPCH = *mut CHAR; #[repr(C)] - #[derive(Copy)] pub struct SECURITY_ATTRIBUTES { + #[derive(Copy, Clone)] pub struct SECURITY_ATTRIBUTES { pub nLength: DWORD, pub lpSecurityDescriptor: LPVOID, pub bInheritHandle: BOOL, @@ -1831,7 +1843,7 @@ pub mod types { pub type int64 = i64; #[repr(C)] - #[derive(Copy)] pub struct STARTUPINFO { + #[derive(Copy, Clone)] pub struct STARTUPINFO { pub cb: DWORD, pub lpReserved: LPWSTR, pub lpDesktop: LPWSTR, @@ -1854,7 +1866,7 @@ pub mod types { pub type LPSTARTUPINFO = *mut STARTUPINFO; #[repr(C)] - #[derive(Copy)] pub struct PROCESS_INFORMATION { + #[derive(Copy, Clone)] pub struct PROCESS_INFORMATION { pub hProcess: HANDLE, pub hThread: HANDLE, pub dwProcessId: DWORD, @@ -1863,7 +1875,7 @@ pub mod types { pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION; #[repr(C)] - #[derive(Copy)] pub struct SYSTEM_INFO { + #[derive(Copy, Clone)] pub struct SYSTEM_INFO { pub wProcessorArchitecture: WORD, pub wReserved: WORD, pub dwPageSize: DWORD, @@ -1879,7 +1891,7 @@ pub mod types { pub type LPSYSTEM_INFO = *mut SYSTEM_INFO; #[repr(C)] - #[derive(Copy)] pub struct MEMORY_BASIC_INFORMATION { + #[derive(Copy, Clone)] pub struct MEMORY_BASIC_INFORMATION { pub BaseAddress: LPVOID, pub AllocationBase: LPVOID, pub AllocationProtect: DWORD, @@ -1891,7 +1903,7 @@ pub mod types { pub type LPMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION; #[repr(C)] - #[derive(Copy)] pub struct OVERLAPPED { + #[derive(Copy, Clone)] pub struct OVERLAPPED { pub Internal: *mut c_ulong, pub InternalHigh: *mut c_ulong, pub Offset: DWORD, @@ -1902,7 +1914,7 @@ pub mod types { pub type LPOVERLAPPED = *mut OVERLAPPED; #[repr(C)] - #[derive(Copy)] pub struct FILETIME { + #[derive(Copy, Clone)] pub struct FILETIME { pub dwLowDateTime: DWORD, pub dwHighDateTime: DWORD, } @@ -1910,7 +1922,7 @@ pub mod types { pub type LPFILETIME = *mut FILETIME; #[repr(C)] - #[derive(Copy)] pub struct GUID { + #[derive(Copy, Clone)] pub struct GUID { pub Data1: DWORD, pub Data2: WORD, pub Data3: WORD, @@ -1918,7 +1930,7 @@ pub mod types { } #[repr(C)] - #[derive(Copy)] pub struct WSAPROTOCOLCHAIN { + #[derive(Copy, Clone)] pub struct WSAPROTOCOLCHAIN { pub ChainLen: c_int, pub ChainEntries: [DWORD; MAX_PROTOCOL_CHAIN as usize], } @@ -1948,6 +1960,9 @@ pub mod types { pub dwProviderReserved: DWORD, pub szProtocol: [u8; WSAPROTOCOL_LEN as usize + 1], } + impl ::core::clone::Clone for WSAPROTOCOL_INFO { + fn clone(&self) -> WSAPROTOCOL_INFO { *self } + } pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO; @@ -1966,6 +1981,9 @@ pub mod types { pub cFileName: [wchar_t; 260], // #define MAX_PATH 260 pub cAlternateFileName: [wchar_t; 14], } + impl ::core::clone::Clone for WIN32_FIND_DATAW { + fn clone(&self) -> WIN32_FIND_DATAW { *self } + } pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW; } @@ -1985,7 +2003,7 @@ pub mod types { pub type rlim_t = u64; #[repr(C)] - #[derive(Copy)] pub struct glob_t { + #[derive(Copy, Clone)] pub struct glob_t { pub gl_pathc: size_t, pub __unused1: c_int, pub gl_offs: size_t, @@ -2002,23 +2020,23 @@ pub mod types { } #[repr(C)] - #[derive(Copy)] pub struct timeval { + #[derive(Copy, Clone)] pub struct timeval { pub tv_sec: time_t, pub tv_usec: suseconds_t, } #[repr(C)] - #[derive(Copy)] pub struct timespec { + #[derive(Copy, Clone)] pub struct timespec { pub tv_sec: time_t, pub tv_nsec: c_long, } - #[derive(Copy)] pub enum timezone {} + pub enum timezone {} pub type sighandler_t = size_t; #[repr(C)] - #[derive(Copy)] + #[derive(Copy, Clone)] pub struct rlimit { pub rlim_cur: rlim_t, pub rlim_max: rlim_t, @@ -2029,7 +2047,7 @@ pub mod types { use types::os::common::posix01::timeval; use types::os::arch::c95::c_long; #[repr(C)] - #[derive(Copy)] + #[derive(Copy, Clone)] pub struct rusage { pub ru_utime: timeval, pub ru_stime: timeval, @@ -2059,7 +2077,7 @@ pub mod types { pub type in_port_t = u16; pub type in_addr_t = u32; #[repr(C)] - #[derive(Copy)] pub struct sockaddr { + #[derive(Copy, Clone)] pub struct sockaddr { pub sa_len: u8, pub sa_family: sa_family_t, pub sa_data: [u8; 14], @@ -2073,9 +2091,12 @@ pub mod types { pub __ss_align: i64, pub __ss_pad2: [u8; 112], } + impl ::core::clone::Clone for sockaddr_storage { + fn clone(&self) -> sockaddr_storage { *self } + } #[repr(C)] - #[derive(Copy)] pub struct sockaddr_in { + #[derive(Copy, Clone)] pub struct sockaddr_in { pub sin_len: u8, pub sin_family: sa_family_t, pub sin_port: in_port_t, @@ -2084,12 +2105,12 @@ pub mod types { } #[repr(C)] - #[derive(Copy)] pub struct in_addr { + #[derive(Copy, Clone)] pub struct in_addr { pub s_addr: in_addr_t, } #[repr(C)] - #[derive(Copy)] pub struct sockaddr_in6 { + #[derive(Copy, Clone)] pub struct sockaddr_in6 { pub sin6_len: u8, pub sin6_family: sa_family_t, pub sin6_port: in_port_t, @@ -2099,24 +2120,24 @@ pub mod types { } #[repr(C)] - #[derive(Copy)] pub struct in6_addr { + #[derive(Copy, Clone)] pub struct in6_addr { pub s6_addr: [u16; 8] } #[repr(C)] - #[derive(Copy)] pub struct ip_mreq { + #[derive(Copy, Clone)] pub struct ip_mreq { pub imr_multiaddr: in_addr, pub imr_interface: in_addr, } #[repr(C)] - #[derive(Copy)] pub struct ip6_mreq { + #[derive(Copy, Clone)] pub struct ip6_mreq { pub ipv6mr_multiaddr: in6_addr, pub ipv6mr_interface: c_uint, } #[repr(C)] - #[derive(Copy)] pub struct addrinfo { + #[derive(Copy, Clone)] pub struct addrinfo { pub ai_flags: c_int, pub ai_family: c_int, pub ai_socktype: c_int, @@ -2133,9 +2154,12 @@ pub mod types { pub sun_family: sa_family_t, pub sun_path: [c_char; 104] } + impl ::core::clone::Clone for sockaddr_un { + fn clone(&self) -> sockaddr_un { *self } + } #[repr(C)] - #[derive(Copy)] pub struct ifaddrs { + #[derive(Copy, Clone)] pub struct ifaddrs { pub ifa_next: *mut ifaddrs, pub ifa_name: *mut c_char, pub ifa_flags: c_uint, @@ -2200,7 +2224,7 @@ pub mod types { pub type blkcnt_t = i64; #[repr(C)] - #[derive(Copy)] pub struct stat { + #[derive(Copy, Clone)] pub struct stat { pub st_dev: dev_t, pub st_mode: mode_t, pub st_nlink: nlink_t, @@ -2226,7 +2250,7 @@ pub mod types { } #[repr(C)] - #[derive(Copy)] pub struct utimbuf { + #[derive(Copy, Clone)] pub struct utimbuf { pub actime: time_t, pub modtime: time_t, } @@ -2236,6 +2260,9 @@ pub mod types { pub __sig: c_long, pub __opaque: [c_char; 36] } + impl ::core::clone::Clone for pthread_attr_t { + fn clone(&self) -> pthread_attr_t { *self } + } } pub mod posix08 { } @@ -2243,7 +2270,7 @@ pub mod types { } pub mod extra { #[repr(C)] - #[derive(Copy)] pub struct mach_timebase_info { + #[derive(Copy, Clone)] pub struct mach_timebase_info { pub numer: u32, pub denom: u32, } @@ -2306,7 +2333,7 @@ pub mod types { pub type blkcnt_t = i64; #[repr(C)] - #[derive(Copy)] pub struct stat { + #[derive(Copy, Clone)] pub struct stat { pub st_dev: dev_t, pub st_mode: mode_t, pub st_nlink: nlink_t, @@ -2332,7 +2359,7 @@ pub mod types { } #[repr(C)] - #[derive(Copy)] pub struct utimbuf { + #[derive(Copy, Clone)] pub struct utimbuf { pub actime: time_t, pub modtime: time_t, } @@ -2342,6 +2369,9 @@ pub mod types { pub __sig: c_long, pub __opaque: [c_char; 56] } + impl ::core::clone::Clone for pthread_attr_t { + fn clone(&self) -> pthread_attr_t { *self } + } } pub mod posix08 { } @@ -2349,7 +2379,7 @@ pub mod types { } pub mod extra { #[repr(C)] - #[derive(Copy)] pub struct mach_timebase_info { + #[derive(Copy, Clone)] pub struct mach_timebase_info { pub numer: u32, pub denom: u32, } @@ -2564,7 +2594,7 @@ pub mod consts { pub const ERROR_IO_PENDING: c_int = 997; pub const ERROR_FILE_INVALID : c_int = 1006; pub const ERROR_NOT_FOUND: c_int = 1168; - pub const INVALID_HANDLE_VALUE: HANDLE = -1 as HANDLE; + pub const INVALID_HANDLE_VALUE: HANDLE = !0 as HANDLE; pub const DELETE : DWORD = 0x00010000; pub const READ_CONTROL : DWORD = 0x00020000; @@ -2602,12 +2632,12 @@ pub mod consts { pub const WAIT_ABANDONED : DWORD = 0x00000080; pub const WAIT_OBJECT_0 : DWORD = 0x00000000; pub const WAIT_TIMEOUT : DWORD = 0x00000102; - pub const WAIT_FAILED : DWORD = -1; + pub const WAIT_FAILED : DWORD = !0; pub const DUPLICATE_CLOSE_SOURCE : DWORD = 0x00000001; pub const DUPLICATE_SAME_ACCESS : DWORD = 0x00000002; - pub const INFINITE : DWORD = -1; + pub const INFINITE : DWORD = !0; pub const STILL_ACTIVE : DWORD = 259; pub const MEM_COMMIT : DWORD = 0x00001000; @@ -2865,7 +2895,7 @@ pub mod consts { pub const MAP_FIXED : c_int = 0x0010; pub const MAP_ANON : c_int = 0x0020; - pub const MAP_FAILED : *mut c_void = -1 as *mut c_void; + pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; pub const MCL_CURRENT : c_int = 0x0001; pub const MCL_FUTURE : c_int = 0x0002; @@ -4696,7 +4726,7 @@ pub mod consts { pub const MAP_FIXED : c_int = 0x0010; pub const MAP_ANON : c_int = 0x1000; - pub const MAP_FAILED : *mut c_void = -1 as *mut c_void; + pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; pub const MCL_CURRENT : c_int = 0x0001; pub const MCL_FUTURE : c_int = 0x0002; diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 1cfac4d8668..453d087196b 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -239,7 +239,7 @@ pub trait Logger { struct DefaultLogger { handle: Stderr } /// Wraps the log level with fmt implementations. -#[derive(Copy, PartialEq, PartialOrd, Debug)] +#[derive(Copy, Clone, PartialEq, PartialOrd, Debug)] pub struct LogLevel(pub u32); impl fmt::Display for LogLevel { @@ -355,7 +355,7 @@ pub struct LogRecord<'a> { } #[doc(hidden)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct LogLocation { pub module_path: &'static str, pub file: &'static str, diff --git a/src/librand/distributions/exponential.rs b/src/librand/distributions/exponential.rs index 0c5f5cb0d44..2ba3164e1b0 100644 --- a/src/librand/distributions/exponential.rs +++ b/src/librand/distributions/exponential.rs @@ -29,7 +29,7 @@ use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample}; /// Generate Normal Random /// Samples*](http://www.doornik.com/research/ziggurat.pdf). Nuffield /// College, Oxford -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Exp1(pub f64); // This could be done via `-rng.gen::<f64>().ln()` but that is slower. @@ -68,7 +68,7 @@ impl Rand for Exp1 { /// let v = exp.ind_sample(&mut rand::thread_rng()); /// println!("{} is from a Exp(2) distribution", v); /// ``` -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Exp { /// `lambda` stored as `1/lambda`, since this is what we scale by. lambda_inverse: f64 diff --git a/src/librand/distributions/mod.rs b/src/librand/distributions/mod.rs index 62189e721e5..432081063c5 100644 --- a/src/librand/distributions/mod.rs +++ b/src/librand/distributions/mod.rs @@ -361,7 +361,7 @@ mod tests { } #[test] #[should_panic] fn test_weighted_choice_weight_overflows() { - let x = (-1) as usize / 2; // x + x + 2 is the overflow + let x = (!0) as usize / 2; // x + x + 2 is the overflow WeightedChoice::new(&mut [Weighted { weight: x, item: 0 }, Weighted { weight: 1, item: 1 }, Weighted { weight: x, item: 2 }, diff --git a/src/librand/distributions/normal.rs b/src/librand/distributions/normal.rs index 7cecc6ac611..fa41c3edfe5 100644 --- a/src/librand/distributions/normal.rs +++ b/src/librand/distributions/normal.rs @@ -28,7 +28,7 @@ use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample}; /// Generate Normal Random /// Samples*](http://www.doornik.com/research/ziggurat.pdf). Nuffield /// College, Oxford -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct StandardNormal(pub f64); impl Rand for StandardNormal { @@ -85,7 +85,7 @@ impl Rand for StandardNormal { /// let v = normal.ind_sample(&mut rand::thread_rng()); /// println!("{} is from a N(2, 9) distribution", v) /// ``` -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Normal { mean: f64, std_dev: f64, @@ -134,7 +134,7 @@ impl IndependentSample<f64> for Normal { /// let v = log_normal.ind_sample(&mut rand::thread_rng()); /// println!("{} is from an ln N(2, 9) distribution", v) /// ``` -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct LogNormal { norm: Normal } diff --git a/src/librand/reseeding.rs b/src/librand/reseeding.rs index ab4939f57d4..98d1bbf5af9 100644 --- a/src/librand/reseeding.rs +++ b/src/librand/reseeding.rs @@ -134,7 +134,7 @@ pub trait Reseeder<R> { /// Reseed an RNG using a `Default` instance. This reseeds by /// replacing the RNG with the result of a `Default::default` call. -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct ReseedWithDefault; impl<R: Rng + Default> Reseeder<R> for ReseedWithDefault { diff --git a/src/librbml/lib.rs b/src/librbml/lib.rs index 3e91b988770..e2875ac8ca5 100644 --- a/src/librbml/lib.rs +++ b/src/librbml/lib.rs @@ -175,7 +175,7 @@ pub struct TaggedDoc<'a> { pub doc: Doc<'a>, } -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub enum EbmlEncoderTag { // tags 00..1f are reserved for auto-serialization. // first NUM_IMPLICIT_TAGS tags are implicitly sized and lengths are not encoded. @@ -265,7 +265,7 @@ pub mod reader { ) } - #[derive(Copy)] + #[derive(Copy, Clone)] pub struct Res { pub val: usize, pub next: usize diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 9093cd00ca0..495044f9459 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -113,7 +113,7 @@ declare_lint! { } /// Does nothing as a lint pass, but registers some `Lint`s /// which are used by other parts of the compiler. -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct HardwiredLints; impl LintPass for HardwiredLints { diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 23f9cbc3a4b..498b2ce518c 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -41,7 +41,7 @@ pub use lint::context::{Context, LintStore, raw_emit_lint, check_crate, gather_a GatherNodeLevels}; /// Specification of a single lint. -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub struct Lint { /// A string identifier for the lint. /// diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs index e4c0eda0448..cda00847686 100644 --- a/src/librustc/metadata/common.rs +++ b/src/librustc/metadata/common.rs @@ -116,7 +116,7 @@ pub const tag_items_data_item_reexport_def_id: usize = 0x47; pub const tag_items_data_item_reexport_name: usize = 0x48; // used to encode crate_ctxt side tables -#[derive(Copy, PartialEq, FromPrimitive)] +#[derive(Copy, Clone, PartialEq, FromPrimitive)] #[repr(usize)] pub enum astencode_tag { // Reserves 0x50 -- 0x6f tag_ast = 0x50, diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index ebc3a6fd52c..d528e38d341 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -29,7 +29,7 @@ use syntax::parse::token; use std::collections::hash_map::HashMap; -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct MethodInfo { pub name: ast::Name, pub def_id: ast::DefId, diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index 284e76b328a..1567f4b9947 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -21,7 +21,7 @@ use std::path::{Path, PathBuf}; use util::fs as myfs; use session::search_paths::{SearchPaths, PathKind}; -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum FileMatch { FileMatches, FileDoesntMatch, diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index e2eebbfdc72..3fb128b1881 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -43,7 +43,7 @@ use syntax::parse::token; // def-id will depend on where it originated from. Therefore, the conversion // function is given an indicator of the source of the def-id. See // astencode.rs for more information. -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub enum DefIdSource { // Identifies a struct, trait, enum, etc. NominalType, diff --git a/src/librustc/middle/cfg/construct.rs b/src/librustc/middle/cfg/construct.rs index 24c54b53590..cbc2ef1535e 100644 --- a/src/librustc/middle/cfg/construct.rs +++ b/src/librustc/middle/cfg/construct.rs @@ -25,7 +25,7 @@ struct CFGBuilder<'a, 'tcx: 'a> { loop_scopes: Vec<LoopScope>, } -#[derive(Copy)] +#[derive(Copy, Clone)] struct LoopScope { loop_id: ast::NodeId, // id of loop/while node continue_index: CFGIndex, // where to go on a `loop` diff --git a/src/librustc/middle/cfg/mod.rs b/src/librustc/middle/cfg/mod.rs index e8a99f59b1e..ad4fdcd7b83 100644 --- a/src/librustc/middle/cfg/mod.rs +++ b/src/librustc/middle/cfg/mod.rs @@ -24,7 +24,7 @@ pub struct CFG { pub exit: CFGIndex, } -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub enum CFGNodeData { AST(ast::NodeId), Entry, diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index 497022ac6ac..ce011f2561b 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -76,7 +76,7 @@ bitflags! { } } -#[derive(Copy, Eq, PartialEq)] +#[derive(Copy, Clone, Eq, PartialEq)] enum Mode { Const, Static, diff --git a/src/librustc/middle/check_loop.rs b/src/librustc/middle/check_loop.rs index ea584407944..bf6829d9676 100644 --- a/src/librustc/middle/check_loop.rs +++ b/src/librustc/middle/check_loop.rs @@ -21,7 +21,7 @@ enum Context { Normal, Loop, Closure } -#[derive(Copy)] +#[derive(Copy, Clone)] struct CheckLoopVisitor<'a> { sess: &'a Session, cx: Context diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 01692158c17..79f4d62b45e 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -128,7 +128,7 @@ enum Usefulness { NotUseful } -#[derive(Copy)] +#[derive(Copy, Clone)] enum WitnessPreference { ConstructWitness, LeaveOutWitness diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index e3e5efc53c7..367bcbbe1d8 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -23,6 +23,7 @@ use middle::astconv_util::ast_ty_to_prim_ty; use syntax::ast::{self, Expr}; use syntax::codemap::Span; +use syntax::feature_gate; use syntax::parse::token::InternedString; use syntax::ptr::P; use syntax::{ast_map, ast_util, codemap}; @@ -395,7 +396,7 @@ pub fn const_int_checked_neg<'a>( pub fn const_uint_checked_neg<'a>( a: u64, _e: &'a Expr, _opt_ety: Option<UintTy>) -> EvalResult { // This always succeeds, and by definition, returns `(!a)+1`. - Ok(const_uint(-a)) + Ok(const_uint((!a).wrapping_add(1))) } macro_rules! overflow_checking_body { @@ -594,7 +595,16 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, match try!(eval_const_expr_partial(tcx, &**inner, ety)) { const_float(f) => const_float(-f), const_int(n) => try!(const_int_checked_neg(n, e, expr_int_type)), - const_uint(n) => try!(const_uint_checked_neg(n, e, expr_uint_type)), + const_uint(i) => { + if !tcx.sess.features.borrow().negate_unsigned { + feature_gate::emit_feature_err( + &tcx.sess.parse_sess.span_diagnostic, + "negate_unsigned", + e.span, + "unary negation of unsigned integers may be removed in the future"); + } + try!(const_uint_checked_neg(i, e, expr_uint_type)) + } const_str(_) => signal!(e, NegateOnString), const_bool(_) => signal!(e, NegateOnBoolean), const_binary(_) => signal!(e, NegateOnBinary), diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index 7e436d95192..f69ac030520 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -28,7 +28,7 @@ use syntax::visit; use syntax::print::{pp, pprust}; use util::nodemap::NodeMap; -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub enum EntryOrExit { Entry, Exit, diff --git a/src/librustc/middle/def.rs b/src/librustc/middle/def.rs index c60bb229be1..6707a4d3fd7 100644 --- a/src/librustc/middle/def.rs +++ b/src/librustc/middle/def.rs @@ -104,7 +104,7 @@ pub type DefMap = RefCell<NodeMap<PathResolution>>; // within. pub type ExportMap = NodeMap<Vec<Export>>; -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Export { pub name: ast::Name, // The name of the target. pub def_id: ast::DefId, // The definition of the target. diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index 5d970c59f63..814492cbef1 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -22,7 +22,7 @@ use syntax::codemap::Span; use syntax::visit; use syntax::visit::Visitor; -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] enum UnsafeContext { SafeContext, UnsafeFn, diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index e98b438d370..2fa9c7c8fbe 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -94,7 +94,7 @@ pub trait Delegate<'tcx> { mode: MutateMode); } -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub enum LoanCause { ClosureCapture(Span), AddrOf, @@ -106,20 +106,20 @@ pub enum LoanCause { MatchDiscriminant } -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub enum ConsumeMode { Copy, // reference to x where x has a type that copies Move(MoveReason), // reference to x where x has a type that moves } -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub enum MoveReason { DirectRefMove, PatBindingMove, CaptureMove, } -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub enum MatchMode { NonBindingMatch, BorrowingMatch, @@ -127,7 +127,7 @@ pub enum MatchMode { MovingMatch, } -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] enum TrackMatchMode { Unknown, Definite(MatchMode), @@ -194,14 +194,14 @@ impl TrackMatchMode { } } -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub enum MutateMode { Init, JustWrite, // x = y WriteAndRead, // x += y } -#[derive(Copy)] +#[derive(Copy, Clone)] enum OverloadedCallType { FnOverloadedCall, FnMutOverloadedCall, diff --git a/src/librustc/middle/graph.rs b/src/librustc/middle/graph.rs index 8673273f9b3..a9ac61b49ec 100644 --- a/src/librustc/middle/graph.rs +++ b/src/librustc/middle/graph.rs @@ -66,13 +66,13 @@ pub struct NodeIndex(pub usize); #[allow(non_upper_case_globals)] pub const InvalidNodeIndex: NodeIndex = NodeIndex(usize::MAX); -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub struct EdgeIndex(pub usize); #[allow(non_upper_case_globals)] pub const InvalidEdgeIndex: EdgeIndex = EdgeIndex(usize::MAX); // Use a private field here to guarantee no more instances are created: -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub struct Direction { repr: usize } #[allow(non_upper_case_globals)] pub const Outgoing: Direction = Direction { repr: 0 }; diff --git a/src/librustc/middle/infer/mod.rs b/src/librustc/middle/infer/mod.rs index da811c35457..b11e25c059d 100644 --- a/src/librustc/middle/infer/mod.rs +++ b/src/librustc/middle/infer/mod.rs @@ -290,7 +290,7 @@ pub enum RegionVariableOrigin { BoundRegionInCoherence(ast::Name), } -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub enum fixup_err { unresolved_int_ty(IntVid), unresolved_float_ty(FloatVid), diff --git a/src/librustc/middle/infer/region_inference/mod.rs b/src/librustc/middle/infer/region_inference/mod.rs index 98347e97e09..d41fdc5f09a 100644 --- a/src/librustc/middle/infer/region_inference/mod.rs +++ b/src/librustc/middle/infer/region_inference/mod.rs @@ -74,13 +74,13 @@ pub enum GenericKind<'tcx> { Projection(ty::ProjectionTy<'tcx>), } -#[derive(Copy, PartialEq, Eq, Hash)] +#[derive(Copy, Clone, PartialEq, Eq, Hash)] pub struct TwoRegions { a: Region, b: Region, } -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub enum UndoLogEntry { OpenSnapshot, CommitedSnapshot, @@ -91,7 +91,7 @@ pub enum UndoLogEntry { AddCombination(CombineMapType, TwoRegions) } -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub enum CombineMapType { Lub, Glb } @@ -951,10 +951,10 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { // ______________________________________________________________________ -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] enum Classification { Expanding, Contracting } -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum VarValue { NoValue, Value(Region), ErrorValue } struct VarData { diff --git a/src/librustc/middle/infer/type_variable.rs b/src/librustc/middle/infer/type_variable.rs index 553ef9afc28..03612a6c1ae 100644 --- a/src/librustc/middle/infer/type_variable.rs +++ b/src/librustc/middle/infer/type_variable.rs @@ -47,7 +47,7 @@ struct Delegate<'tcx>(PhantomData<&'tcx ()>); type Relation = (RelationDir, ty::TyVid); -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub enum RelationDir { SubtypeOf, SupertypeOf, EqTo, BiTo } diff --git a/src/librustc/middle/infer/unify.rs b/src/librustc/middle/infer/unify.rs index 39271d4cdc5..4bbced1d75c 100644 --- a/src/librustc/middle/infer/unify.rs +++ b/src/librustc/middle/infer/unify.rs @@ -84,7 +84,7 @@ pub struct Node<K:UnifyKey> { pub rank: usize, } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Delegate<K>(PhantomData<K>); // We can't use V:LatticeValue, much as I would like to, diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index b9a82669f65..a08de58f909 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -46,7 +46,7 @@ macro_rules! lets_do_this { $( $variant:ident, $name:expr, $method:ident; )* ) => { -#[derive(Copy, FromPrimitive, PartialEq, Eq, Hash)] +#[derive(Copy, Clone, FromPrimitive, PartialEq, Eq, Hash)] pub enum LangItem { $($variant),* } diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 705f20559af..d7161607b61 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -139,7 +139,7 @@ enum LoopKind<'a> { WhileLoop(&'a Expr), } -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] struct Variable(usize); #[derive(Copy, PartialEq)] @@ -159,7 +159,7 @@ impl Clone for LiveNode { } } -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] enum LiveNodeKind { FreeVarNode(Span), ExprNode(Span), @@ -245,13 +245,13 @@ struct CaptureInfo { var_nid: NodeId } -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] struct LocalInfo { id: NodeId, ident: ast::Ident } -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] enum VarKind { Arg(NodeId, ast::Ident), Local(LocalInfo), @@ -534,7 +534,7 @@ fn invalid_users() -> Users { } } -#[derive(Copy)] +#[derive(Copy, Clone)] struct Specials { exit_ln: LiveNode, fallthrough_ln: LiveNode, diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 3738e38f687..85255d04df4 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -199,7 +199,7 @@ pub type cmt<'tcx> = Rc<cmt_<'tcx>>; // We pun on *T to mean both actual deref of a ptr as well // as accessing of components: -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum deref_kind { deref_ptr(PointerKind), deref_interior(InteriorKind), @@ -263,6 +263,9 @@ pub struct MemCategorizationContext<'t,TYPER:'t> { } impl<'t,TYPER:'t> Copy for MemCategorizationContext<'t,TYPER> {} +impl<'t,TYPER:'t> Clone for MemCategorizationContext<'t,TYPER> { + fn clone(&self) -> MemCategorizationContext<'t,TYPER> { *self } +} pub type McResult<T> = Result<T, ()>; diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index b68f8fa9b98..652f6613252 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -271,7 +271,7 @@ pub struct RegionMaps { /// Carries the node id for the innermost block or match expression, /// for building up the `var_map` which maps ids to the blocks in /// which they were declared. -#[derive(PartialEq, Eq, Debug, Copy)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] enum InnermostDeclaringBlock { None, Block(ast::NodeId), @@ -296,7 +296,7 @@ impl InnermostDeclaringBlock { /// Contextual information for declarations introduced by a statement /// (i.e. `let`). It carries node-id's for statement and enclosing /// block both, as well as the statement's index within the block. -#[derive(PartialEq, Eq, Debug, Copy)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] struct DeclaringStatementContext { stmt_id: ast::NodeId, block_id: ast::NodeId, @@ -312,7 +312,7 @@ impl DeclaringStatementContext { } } -#[derive(PartialEq, Eq, Debug, Copy)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] enum InnermostEnclosingExpr { None, Some(ast::NodeId), @@ -334,7 +334,7 @@ impl InnermostEnclosingExpr { } } -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct Context { /// the root of the current region tree. This is typically the id /// of the innermost fn body. Each fn forms its own disjoint tree diff --git a/src/librustc/middle/traits/coherence.rs b/src/librustc/middle/traits/coherence.rs index 411be28b896..2f2db8f38bd 100644 --- a/src/librustc/middle/traits/coherence.rs +++ b/src/librustc/middle/traits/coherence.rs @@ -25,7 +25,7 @@ use syntax::ast; use syntax::codemap::{DUMMY_SP, Span}; use util::ppaux::Repr; -#[derive(Copy)] +#[derive(Copy, Clone)] struct ParamIsLocal(bool); /// True if there exist types that satisfy both of the two given impls. diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index bb2d37c944c..f7e7d071f8c 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -99,7 +99,7 @@ pub enum MethodMatchResult { MethodDidNotMatch, } -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub enum MethodMatchedData { // In the case of a precise match, we don't really need to store // how the match was found. So don't. diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 0814ec2c84e..1123c923631 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -262,7 +262,7 @@ pub struct field_ty { // Contains information needed to resolve types and (in the future) look up // the types of AST nodes. -#[derive(Copy, PartialEq, Eq, Hash)] +#[derive(Copy, Clone, PartialEq, Eq, Hash)] pub struct creader_cache_key { pub cnum: CrateNum, pub pos: usize, @@ -596,7 +596,7 @@ pub type ObjectCastMap<'tcx> = RefCell<NodeMap<ty::PolyTraitRef<'tcx>>>; /// will push one or more such restriction into the /// `transmute_restrictions` vector during `intrinsicck`. They are /// then checked during `trans` by the fn `check_intrinsics`. -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct TransmuteRestriction<'tcx> { /// The span whence the restriction comes. pub span: Span, @@ -886,7 +886,7 @@ macro_rules! sty_debug_print { // variable names. mod inner { use middle::ty; - #[derive(Copy)] + #[derive(Copy, Clone)] struct DebugStat { total: usize, region_infer: usize, @@ -4003,7 +4003,7 @@ pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool { /// /// The ordering of the cases is significant. They are sorted so that cmp::max /// will keep the "more erroneous" of two values. -#[derive(Copy, PartialOrd, Ord, Eq, PartialEq, Debug)] +#[derive(Copy, Clone, PartialOrd, Ord, Eq, PartialEq, Debug)] pub enum Representability { Representable, ContainsRecursive, @@ -4734,7 +4734,7 @@ pub fn expr_is_lval(tcx: &ctxt, e: &ast::Expr) -> bool { /// two kinds of rvalues is an artifact of trans which reflects how we will /// generate code for that kind of expression. See trans/expr.rs for more /// information. -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum ExprKind { LvalueExpr, RvalueDpsExpr, @@ -5430,7 +5430,7 @@ pub fn item_path_str(cx: &ctxt, id: ast::DefId) -> String { with_path(cx, id, |path| ast_map::path_to_string(path)).to_string() } -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum DtorKind { NoDtor, TraitDtor(DefId, bool) @@ -7154,7 +7154,7 @@ pub fn make_substs_for_receiver_types<'tcx>(tcx: &ty::ctxt<'tcx>, trait_ref.substs.clone().with_method(meth_tps, meth_regions) } -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum CopyImplementationError { FieldDoesNotImplementCopy(ast::Name), VariantDoesNotImplementCopy(ast::Name), diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 5a598921195..a7d608d2c87 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -247,7 +247,7 @@ pub fn basic_options() -> Options { // users can have their own entry // functions that don't start a // scheduler -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub enum EntryFnType { EntryMain, EntryStart, diff --git a/src/librustc_back/target/apple_ios_base.rs b/src/librustc_back/target/apple_ios_base.rs index 42cbdd7577d..7dcd6ba6cd1 100644 --- a/src/librustc_back/target/apple_ios_base.rs +++ b/src/librustc_back/target/apple_ios_base.rs @@ -15,7 +15,7 @@ use target::TargetOptions; use self::Arch::*; #[allow(non_camel_case_types)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum Arch { Armv7, Armv7s, diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 268e469b7f9..f8da075e4bd 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -334,7 +334,7 @@ impl ToInteriorKind for mc::InteriorKind { } } -#[derive(Copy, PartialEq, Eq, Hash, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] pub enum LoanPathElem { LpDeref(mc::PointerKind), // `*LV` in README.md LpInterior(InteriorKind), // `LV.f` in README.md @@ -500,13 +500,13 @@ pub struct BckError<'tcx> { code: bckerr_code } -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum AliasableViolationKind { MutabilityViolation, BorrowViolation(euv::LoanCause) } -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub enum MovedValueUseKind { MovedInUse, MovedInCapture, diff --git a/src/librustc_borrowck/borrowck/move_data.rs b/src/librustc_borrowck/borrowck/move_data.rs index a4470acbe4d..2d1b57243d1 100644 --- a/src/librustc_borrowck/borrowck/move_data.rs +++ b/src/librustc_borrowck/borrowck/move_data.rs @@ -94,7 +94,7 @@ impl Clone for MovePathIndex { const InvalidMovePathIndex: MovePathIndex = MovePathIndex(usize::MAX); /// Index into `MoveData.moves`, used like a pointer -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub struct MoveIndex(usize); impl MoveIndex { @@ -125,7 +125,7 @@ pub struct MovePath<'tcx> { pub next_sibling: MovePathIndex, } -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub enum MoveKind { Declared, // When declared, variables start out "moved". MoveExpr, // Expression or binding that moves a variable @@ -133,7 +133,7 @@ pub enum MoveKind { Captured // Closure creation that moves a value } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Move { /// Path being moved. pub path: MovePathIndex, @@ -148,7 +148,7 @@ pub struct Move { pub next_move: MoveIndex } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Assignment { /// Path being assigned. pub path: MovePathIndex, @@ -160,7 +160,7 @@ pub struct Assignment { pub span: Span, } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct VariantMatch { /// downcast to the variant. pub path: MovePathIndex, diff --git a/src/librustc_borrowck/graphviz.rs b/src/librustc_borrowck/graphviz.rs index fb8afa83d86..ade52bfde35 100644 --- a/src/librustc_borrowck/graphviz.rs +++ b/src/librustc_borrowck/graphviz.rs @@ -26,7 +26,7 @@ use rustc::middle::dataflow; use std::rc::Rc; use std::borrow::IntoCow; -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub enum Variant { Loans, Moves, diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index be416327dad..b32c6829a22 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -182,7 +182,7 @@ fn make_input(free_matches: &[String]) -> Option<(Input, Option<PathBuf>)> { } // Whether to stop or continue compilation. -#[derive(Copy, Debug, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum Compilation { Stop, Continue, @@ -265,7 +265,7 @@ pub trait CompilerCalls<'a> { } // CompilerCalls instance for a regular rustc build. -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct RustcDefaultCalls; impl<'a> CompilerCalls<'a> for RustcDefaultCalls { diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index e5847400496..410f31e0900 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -44,7 +44,7 @@ use std::option; use std::path::PathBuf; use std::str::FromStr; -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub enum PpSourceMode { PpmNormal, PpmEveryBodyLoops, @@ -56,7 +56,7 @@ pub enum PpSourceMode { } -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub enum PpFlowGraphMode { Default, /// Drops the labels from the edges in the flowgraph output. This @@ -65,7 +65,7 @@ pub enum PpFlowGraphMode { /// have become a pain to maintain. UnlabelledEdges, } -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub enum PpMode { PpmSource(PpSourceMode), PpmFlowGraph(PpFlowGraphMode), diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index e7443af3013..3bb737ddc12 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -63,7 +63,7 @@ declare_lint! { "suggest using `loop { }` instead of `while true { }`" } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct WhileTrue; impl LintPass for WhileTrue { @@ -107,7 +107,7 @@ declare_lint! { "shift exceeds the type's number of bits" } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct TypeLimits { /// Id of the last visited negated expression negated_expr_id: ast::NodeId, @@ -116,7 +116,7 @@ pub struct TypeLimits { impl TypeLimits { pub fn new() -> TypeLimits { TypeLimits { - negated_expr_id: -1, + negated_expr_id: !0, } } } @@ -431,7 +431,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ImproperCTypesVisitor<'a, 'tcx> { } } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct ImproperCTypes; impl LintPass for ImproperCTypes { @@ -474,7 +474,7 @@ declare_lint! { "use of owned (Box type) heap memory" } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct BoxPointers; impl BoxPointers { @@ -621,7 +621,7 @@ declare_lint! { "detects attributes that were not used by the compiler" } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct UnusedAttributes; impl LintPass for UnusedAttributes { @@ -662,7 +662,7 @@ declare_lint! { "path statements with no effect" } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct PathStatements; impl LintPass for PathStatements { @@ -696,7 +696,7 @@ declare_lint! { "unused result of an expression in a statement" } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct UnusedResults; impl LintPass for UnusedResults { @@ -764,7 +764,7 @@ declare_lint! { "types, variants, traits and type parameters should have camel case names" } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct NonCamelCaseTypes; impl NonCamelCaseTypes { @@ -874,7 +874,7 @@ declare_lint! { "methods, functions, lifetime parameters and modules should have snake case names" } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct NonSnakeCase; impl NonSnakeCase { @@ -1014,7 +1014,7 @@ declare_lint! { "static constants should have uppercase identifiers" } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct NonUpperCaseGlobals; impl NonUpperCaseGlobals { @@ -1072,7 +1072,7 @@ declare_lint! { "`if`, `match`, `while` and `return` do not need parentheses" } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct UnusedParens; impl UnusedParens { @@ -1166,7 +1166,7 @@ declare_lint! { "unnecessary braces around an imported item" } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct UnusedImportBraces; impl LintPass for UnusedImportBraces { @@ -1196,7 +1196,7 @@ declare_lint! { "using `Struct { x: x }` instead of `Struct { x }`" } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct NonShorthandFieldPatterns; impl LintPass for NonShorthandFieldPatterns { @@ -1233,7 +1233,7 @@ declare_lint! { "unnecessary use of an `unsafe` block" } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct UnusedUnsafe; impl LintPass for UnusedUnsafe { @@ -1258,7 +1258,7 @@ declare_lint! { "usage of `unsafe` code" } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct UnsafeCode; impl LintPass for UnsafeCode { @@ -1319,7 +1319,7 @@ declare_lint! { "detect mut variables which don't need to be mutable" } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct UnusedMut; impl UnusedMut { @@ -1388,7 +1388,7 @@ declare_lint! { "detects unnecessary allocations that can be eliminated" } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct UnusedAllocation; impl LintPass for UnusedAllocation { @@ -1625,7 +1625,7 @@ declare_lint! { "detects potentially-forgotten implementations of `Copy`" } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct MissingCopyImplementations; impl LintPass for MissingCopyImplementations { @@ -1740,7 +1740,7 @@ declare_lint! { } /// Checks for use of items with `#[deprecated]` attributes -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Stability; impl Stability { @@ -1800,7 +1800,7 @@ declare_lint! { "functions that cannot return without calling themselves" } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct UnconditionalRecursion; @@ -1991,7 +1991,7 @@ declare_lint! { "compiler plugin used as ordinary library in non-plugin crate" } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct PluginAsLibrary; impl LintPass for PluginAsLibrary { @@ -2045,7 +2045,7 @@ declare_lint! { "const items will not have their symbols exported" } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct InvalidNoMangleItems; impl LintPass for InvalidNoMangleItems { @@ -2088,7 +2088,7 @@ impl LintPass for InvalidNoMangleItems { } /// Forbids using the `#[feature(...)]` attribute -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct UnstableFeatures; declare_lint! { diff --git a/src/librustc_llvm/diagnostic.rs b/src/librustc_llvm/diagnostic.rs index aca4d265bc9..e6350ae44d4 100644 --- a/src/librustc_llvm/diagnostic.rs +++ b/src/librustc_llvm/diagnostic.rs @@ -18,7 +18,7 @@ use std::ptr; use {ValueRef, TwineRef, DebugLocRef, DiagnosticInfoRef}; -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum OptimizationDiagnosticKind { OptimizationRemark, OptimizationMissed, @@ -38,7 +38,7 @@ impl OptimizationDiagnosticKind { } #[allow(raw_pointer_derive)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct OptimizationDiagnostic { pub kind: OptimizationDiagnosticKind, pub pass_name: *const c_char, @@ -69,14 +69,13 @@ impl OptimizationDiagnostic { } } +#[derive(Copy, Clone)] pub struct InlineAsmDiagnostic { pub cookie: c_uint, pub message: TwineRef, pub instruction: ValueRef, } -impl Copy for InlineAsmDiagnostic {} - impl InlineAsmDiagnostic { unsafe fn unpack(di: DiagnosticInfoRef) -> InlineAsmDiagnostic { @@ -96,7 +95,7 @@ impl InlineAsmDiagnostic { } } -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum Diagnostic { Optimization(OptimizationDiagnostic), InlineAsm(InlineAsmDiagnostic), diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index cdafa4a16d0..9b0ae2e9ef8 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -76,7 +76,7 @@ pub const False: Bool = 0 as Bool; // Consts for the LLVM CallConv type, pre-cast to usize. -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub enum CallConv { CCallConv = 0, FastCallConv = 8, @@ -86,7 +86,7 @@ pub enum CallConv { X86_64_Win64 = 79, } -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum Visibility { LLVMDefaultVisibility = 0, HiddenVisibility = 1, @@ -97,7 +97,7 @@ pub enum Visibility { // DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage. // LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either; // they've been removed in upstream LLVM commit r203866. -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum Linkage { ExternalLinkage = 0, AvailableExternallyLinkage = 1, @@ -113,7 +113,7 @@ pub enum Linkage { } #[repr(C)] -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub enum DiagnosticSeverity { Error, Warning, @@ -154,7 +154,7 @@ bitflags! { #[repr(u64)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum OtherAttribute { // The following are not really exposed in // the LLVM c api so instead to add these @@ -175,13 +175,13 @@ pub enum OtherAttribute { NonNullAttribute = 1 << 44, } -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum SpecialAttribute { DereferenceableAttribute(u64) } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum AttributeSet { ReturnIndex = 0, FunctionIndex = !0 @@ -273,7 +273,7 @@ impl AttrBuilder { } // enum for the LLVM IntPredicate type -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum IntPredicate { IntEQ = 32, IntNE = 33, @@ -288,7 +288,7 @@ pub enum IntPredicate { } // enum for the LLVM RealPredicate type -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum RealPredicate { RealPredicateFalse = 0, RealOEQ = 1, @@ -310,7 +310,7 @@ pub enum RealPredicate { // The LLVM TypeKind type - must stay in sync with the def of // LLVMTypeKind in llvm/include/llvm-c/Core.h -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] #[repr(C)] pub enum TypeKind { Void = 0, @@ -332,7 +332,7 @@ pub enum TypeKind { } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum AtomicBinOp { AtomicXchg = 0, AtomicAdd = 1, @@ -348,7 +348,7 @@ pub enum AtomicBinOp { } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum AtomicOrdering { NotAtomic = 0, Unordered = 1, @@ -362,13 +362,13 @@ pub enum AtomicOrdering { // Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h) #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum FileType { AssemblyFileType = 0, ObjectFileType = 1 } -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum MetadataType { MD_dbg = 0, MD_tbaa = 1, @@ -385,13 +385,13 @@ pub enum MetadataType { } // Inline Asm Dialect -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum AsmDialect { AD_ATT = 0, AD_Intel = 1 } -#[derive(Copy, PartialEq, Clone)] +#[derive(Copy, Clone, PartialEq)] #[repr(C)] pub enum CodeGenOptLevel { CodeGenLevelNone = 0, @@ -400,7 +400,7 @@ pub enum CodeGenOptLevel { CodeGenLevelAggressive = 3, } -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] #[repr(C)] pub enum RelocMode { RelocDefault = 0, @@ -410,7 +410,7 @@ pub enum RelocMode { } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum CodeGenModel { CodeModelDefault = 0, CodeModelJITDefault = 1, @@ -421,7 +421,7 @@ pub enum CodeGenModel { } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum DiagnosticKind { DK_InlineAsm = 0, DK_StackSize, @@ -533,7 +533,7 @@ pub mod debuginfo { pub type DIEnumerator = DIDescriptor; pub type DITemplateTypeParameter = DIDescriptor; - #[derive(Copy)] + #[derive(Copy, Clone)] pub enum DIDescriptorFlags { FlagPrivate = 1 << 0, FlagProtected = 1 << 1, diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 5bff5479e2e..52db6013f4d 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -61,7 +61,7 @@ use std::rc::Rc; // Specifies how duplicates should be handled when adding a child item if // another item exists with the same name in some namespace. -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] enum DuplicateCheckingMode { ForbidDuplicateModules, ForbidDuplicateTypesAndModules, @@ -70,7 +70,7 @@ enum DuplicateCheckingMode { OverwriteDuplicates } -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] enum NamespaceError { NoError, ModuleError, diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index ece83b578d2..045320e4fa4 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -107,7 +107,7 @@ mod record_exports; mod build_reduced_graph; mod resolve_imports; -#[derive(Copy)] +#[derive(Copy, Clone)] struct BindingInfo { span: Span, binding_mode: BindingMode, @@ -116,14 +116,14 @@ struct BindingInfo { // Map from the name in a pattern to its binding mode. type BindingMap = HashMap<Name, BindingInfo>; -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] enum PatternBindingMode { RefutableMode, LocalIrrefutableMode, ArgumentIrrefutableMode, } -#[derive(Copy, PartialEq, Eq, Hash, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] enum Namespace { TypeNS, ValueNS @@ -280,7 +280,7 @@ enum FallbackSuggestion { TraitMethod(String), } -#[derive(Copy)] +#[derive(Copy, Clone)] enum TypeParameters<'a> { NoTypeParameters, HasTypeParameters( @@ -297,7 +297,7 @@ enum TypeParameters<'a> { // The rib kind controls the translation of local // definitions (`DefLocal`) to upvars (`DefUpvar`). -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] enum RibKind { // No translation needs to be applied. NormalRibKind, @@ -319,7 +319,7 @@ enum RibKind { ConstantItemRibKind } -#[derive(Copy)] +#[derive(Copy, Clone)] enum UseLexicalScopeFlag { DontUseLexicalScope, UseLexicalScope @@ -330,7 +330,7 @@ enum ModulePrefixResult { PrefixFound(Rc<Module>, usize) } -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] enum NameSearchType { /// We're doing a name search in order to resolve a `use` directive. ImportSearch, @@ -340,7 +340,7 @@ enum NameSearchType { PathSearch, } -#[derive(Copy)] +#[derive(Copy, Clone)] enum BareIdentifierPatternResolution { FoundStructOrEnumVariant(Def, LastPrivate), FoundConst(Def, LastPrivate), @@ -372,7 +372,7 @@ enum ParentLink { } /// The type of module this is. -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] enum ModuleKind { NormalModuleKind, TraitModuleKind, @@ -3527,7 +3527,7 @@ pub struct CrateMap { pub glob_map: Option<GlobMap> } -#[derive(PartialEq,Copy)] +#[derive(PartialEq,Copy, Clone)] pub enum MakeGlobMap { Yes, No diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 44c803c7765..f1a8507b178 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -37,7 +37,7 @@ use std::rc::Rc; /// Contains data for specific types of import directives. -#[derive(Copy,Debug)] +#[derive(Copy, Clone,Debug)] pub enum ImportDirectiveSubclass { SingleImport(Name /* target */, Name /* source */), GlobImport diff --git a/src/librustc_trans/save/recorder.rs b/src/librustc_trans/save/recorder.rs index f7c0d6a983f..db724b0ef6b 100644 --- a/src/librustc_trans/save/recorder.rs +++ b/src/librustc_trans/save/recorder.rs @@ -62,7 +62,7 @@ macro_rules! svec { }) } -#[derive(Copy, Debug, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum Row { Variable, Enum, diff --git a/src/librustc_trans/trans/_match.rs b/src/librustc_trans/trans/_match.rs index ea8197d0c40..ef599a01e7c 100644 --- a/src/librustc_trans/trans/_match.rs +++ b/src/librustc_trans/trans/_match.rs @@ -228,7 +228,7 @@ use syntax::codemap::Span; use syntax::fold::Folder; use syntax::ptr::P; -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] struct ConstantExpr<'a>(&'a ast::Expr); impl<'a> ConstantExpr<'a> { @@ -311,7 +311,7 @@ impl<'a, 'tcx> Opt<'a, 'tcx> { } } -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub enum BranchKind { NoBranch, Single, diff --git a/src/librustc_trans/trans/adt.rs b/src/librustc_trans/trans/adt.rs index e32d8e2b9cf..fd1fff308df 100644 --- a/src/librustc_trans/trans/adt.rs +++ b/src/librustc_trans/trans/adt.rs @@ -830,7 +830,7 @@ fn load_discr(bcx: Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr) let bits = machine::llbitsize_of_real(bcx.ccx(), llty); assert!(bits <= 64); let bits = bits as usize; - let mask = (-1u64 >> (64 - bits)) as Disr; + let mask = (!0u64 >> (64 - bits)) as Disr; // For a (max) discr of -1, max will be `-1 as usize`, which overflows. // However, that is fine here (it would still represent the full range), if (max.wrapping_add(1)) & mask == min & mask { diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 20677ab93fc..05c366a645e 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -868,7 +868,7 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>( _ => unreachable!(), }; let minus_one = ICmp(bcx, llvm::IntEQ, rhs, - C_integral(llty, -1, false), debug_loc); + C_integral(llty, !0, false), debug_loc); with_cond(bcx, minus_one, |bcx| { let is_min = ICmp(bcx, llvm::IntEQ, lhs, C_integral(llty, min, true), debug_loc); @@ -1388,7 +1388,7 @@ pub fn new_fn_ctxt<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>, common::validate_substs(param_substs); debug!("new_fn_ctxt(path={}, id={}, param_substs={})", - if id == -1 { + if id == !0 { "".to_string() } else { ccx.tcx().map.path_to_string(id).to_string() @@ -2112,7 +2112,7 @@ pub fn llvm_linkage_by_name(name: &str) -> Option<Linkage> { /// Enum describing the origin of an LLVM `Value`, for linkage purposes. -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum ValueOrigin { /// The LLVM `Value` is in this context because the corresponding item was /// assigned to the current compilation unit. diff --git a/src/librustc_trans/trans/basic_block.rs b/src/librustc_trans/trans/basic_block.rs index a0aca17538f..d3d055cda12 100644 --- a/src/librustc_trans/trans/basic_block.rs +++ b/src/librustc_trans/trans/basic_block.rs @@ -13,7 +13,7 @@ use llvm::BasicBlockRef; use trans::value::{Users, Value}; use std::iter::{Filter, Map}; -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct BasicBlock(pub BasicBlockRef); pub type Preds = Map<Filter<Users, fn(&Value) -> bool>, fn(Value) -> BasicBlock>; diff --git a/src/librustc_trans/trans/callee.rs b/src/librustc_trans/trans/callee.rs index e33ec29017c..9eb46d3ff54 100644 --- a/src/librustc_trans/trans/callee.rs +++ b/src/librustc_trans/trans/callee.rs @@ -60,7 +60,7 @@ use syntax::ast; use syntax::ast_map; use syntax::ptr::P; -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct MethodData { pub llfn: ValueRef, pub llself: ValueRef, @@ -1110,7 +1110,7 @@ pub fn trans_args<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>, bcx } -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum AutorefArg { DontAutorefArg, DoAutorefArg(ast::NodeId) diff --git a/src/librustc_trans/trans/cleanup.rs b/src/librustc_trans/trans/cleanup.rs index 4897ae286d3..19891e93072 100644 --- a/src/librustc_trans/trans/cleanup.rs +++ b/src/librustc_trans/trans/cleanup.rs @@ -153,7 +153,7 @@ pub struct CleanupScope<'blk, 'tcx: 'blk> { cached_landing_pad: Option<BasicBlockRef>, } -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub struct CustomScopeIndex { index: usize } @@ -184,14 +184,14 @@ impl<'blk, 'tcx: 'blk> fmt::Debug for CleanupScopeKind<'blk, 'tcx> { } } -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub enum EarlyExitLabel { UnwindExit, ReturnExit, LoopExit(ast::NodeId, usize) } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct CachedEarlyExit { label: EarlyExitLabel, cleanup_block: BasicBlockRef, @@ -209,7 +209,7 @@ pub trait Cleanup<'tcx> { pub type CleanupObj<'tcx> = Box<Cleanup<'tcx>+'tcx>; -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub enum ScopeId { AstScope(ast::NodeId), CustomScope(CustomScopeIndex) @@ -982,7 +982,7 @@ impl EarlyExitLabel { /////////////////////////////////////////////////////////////////////////// // Cleanup types -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct DropValue<'tcx> { is_immediate: bool, must_unwind: bool, @@ -1021,12 +1021,12 @@ impl<'tcx> Cleanup<'tcx> for DropValue<'tcx> { } } -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub enum Heap { HeapExchange } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct FreeValue<'tcx> { ptr: ValueRef, heap: Heap, @@ -1061,7 +1061,7 @@ impl<'tcx> Cleanup<'tcx> for FreeValue<'tcx> { } } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct FreeSlice { ptr: ValueRef, size: ValueRef, @@ -1098,7 +1098,7 @@ impl<'tcx> Cleanup<'tcx> for FreeSlice { } } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct LifetimeEnd { ptr: ValueRef, } diff --git a/src/librustc_trans/trans/common.rs b/src/librustc_trans/trans/common.rs index 995f3caf588..c5985e930e9 100644 --- a/src/librustc_trans/trans/common.rs +++ b/src/librustc_trans/trans/common.rs @@ -343,7 +343,7 @@ pub fn gensym_name(name: &str) -> PathElem { * */ -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct NodeIdAndSpan { pub id: ast::NodeId, pub span: Span, @@ -1225,7 +1225,7 @@ pub fn drain_fulfillment_cx<'a,'tcx,T>(infcx: &infer::InferCtxt<'a,'tcx>, } // Key used to lookup values supplied for type parameters in an expr. -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub enum ExprOrMethodCall { // Type parameters for a path like `None::<int>` ExprId(ast::NodeId), diff --git a/src/librustc_trans/trans/context.rs b/src/librustc_trans/trans/context.rs index 3542bcd081f..8919a386a45 100644 --- a/src/librustc_trans/trans/context.rs +++ b/src/librustc_trans/trans/context.rs @@ -459,7 +459,7 @@ impl<'tcx> LocalCrateContext<'tcx> { CrateContext { shared: shared, local: self, - index: -1 as usize, + index: !0 as usize, } } } diff --git a/src/librustc_trans/trans/datum.rs b/src/librustc_trans/trans/datum.rs index 7b983ca4ac6..a736a9fe88a 100644 --- a/src/librustc_trans/trans/datum.rs +++ b/src/librustc_trans/trans/datum.rs @@ -172,7 +172,7 @@ impl Drop for Rvalue { fn drop(&mut self) { } } -#[derive(Copy, PartialEq, Eq, Hash, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] pub enum RvalueMode { /// `val` is a pointer to the actual value (and thus has type *T) ByRef, diff --git a/src/librustc_trans/trans/debuginfo.rs b/src/librustc_trans/trans/debuginfo.rs index 8e9ae2eba0b..2747288b607 100644 --- a/src/librustc_trans/trans/debuginfo.rs +++ b/src/librustc_trans/trans/debuginfo.rs @@ -2382,7 +2382,7 @@ impl<'tcx> VariantMemberDescriptionFactory<'tcx> { } } -#[derive(Copy)] +#[derive(Copy, Clone)] enum EnumDiscriminantInfo { RegularDiscriminant(DIType), OptimizedDiscriminant, @@ -3106,7 +3106,7 @@ impl MetadataCreationResult { } } -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] enum InternalDebugLocation { KnownLocation { scope: DIScope, line: usize, col: usize }, UnknownLocation diff --git a/src/librustc_trans/trans/expr.rs b/src/librustc_trans/trans/expr.rs index 46cbd193600..5a79aa35bfa 100644 --- a/src/librustc_trans/trans/expr.rs +++ b/src/librustc_trans/trans/expr.rs @@ -94,7 +94,7 @@ use std::rc::Rc; // These are passed around by the code generating functions to track the // destination of a computation's value. -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub enum Dest { SaveIn(ValueRef), Ignore, @@ -2038,7 +2038,7 @@ fn float_cast(bcx: Block, } else { llsrc }; } -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub enum cast_kind { cast_pointer, cast_integral, diff --git a/src/librustc_trans/trans/mod.rs b/src/librustc_trans/trans/mod.rs index f7433e6a774..c7857d6a775 100644 --- a/src/librustc_trans/trans/mod.rs +++ b/src/librustc_trans/trans/mod.rs @@ -57,7 +57,7 @@ mod basic_block; mod llrepr; mod cleanup; -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct ModuleTranslation { pub llcx: ContextRef, pub llmod: ModuleRef, diff --git a/src/librustc_trans/trans/tvec.rs b/src/librustc_trans/trans/tvec.rs index 34dfb0eebcf..791b58d88a9 100644 --- a/src/librustc_trans/trans/tvec.rs +++ b/src/librustc_trans/trans/tvec.rs @@ -33,7 +33,7 @@ use util::ppaux::ty_to_string; use syntax::ast; use syntax::parse::token::InternedString; -#[derive(Copy)] +#[derive(Copy, Clone)] struct VecTypes<'tcx> { unit_ty: Ty<'tcx>, llunit_ty: Type diff --git a/src/librustc_trans/trans/value.rs b/src/librustc_trans/trans/value.rs index c2d91e4e160..bc71278c157 100644 --- a/src/librustc_trans/trans/value.rs +++ b/src/librustc_trans/trans/value.rs @@ -14,7 +14,7 @@ use trans::basic_block::BasicBlock; use trans::common::Block; use libc::c_uint; -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Value(pub ValueRef); macro_rules! opt_val { ($e:expr) => ( @@ -125,7 +125,7 @@ impl Value { } /// Wrapper for LLVM UseRef -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Use(UseRef); impl Use { diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index af33cdb3932..677ab568524 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -52,7 +52,7 @@ pub enum MethodError { // A pared down enum describing just the places from which a method // candidate can arise. Used for error reporting only. -#[derive(Copy, PartialOrd, Ord, PartialEq, Eq)] +#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq)] pub enum CandidateSource { ImplSource(ast::DefId), TraitSource(/* trait id */ ast::DefId), diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index e203019bd06..41eae881589 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -109,7 +109,7 @@ pub enum PickAdjustment { AutoRef(ast::Mutability, Box<PickAdjustment>), } -#[derive(PartialEq, Eq, Copy)] +#[derive(PartialEq, Eq, Copy, Clone)] pub enum Mode { // An expression of the form `receiver.method_name(...)`. // Autoderefs are performed on `receiver`, lookup is done based on the diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 9832fe1cb6e..c5ff8a14bc1 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -266,7 +266,7 @@ fn type_derefs_to_local<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, }).2.is_some() } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct TraitInfo { pub def_id: ast::DefId, } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index b9a0070f205..156fbfede9c 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -120,6 +120,7 @@ use syntax::attr::AttrMetaMethods; use syntax::ast::{self, DefId, Visibility}; use syntax::ast_util::{self, local_def}; use syntax::codemap::{self, Span}; +use syntax::feature_gate; use syntax::owned_slice::OwnedSlice; use syntax::parse::token; use syntax::print::pprust; @@ -204,7 +205,7 @@ struct CastCheck<'tcx> { /// When type-checking an expression, we propagate downward /// whatever type hint we are able in the form of an `Expectation`. -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum Expectation<'tcx> { /// We know nothing about what type this expression should have. NoExpectation, @@ -1951,14 +1952,14 @@ impl<'a, 'tcx> RegionScope for FnCtxt<'a, 'tcx> { } } -#[derive(Copy, Debug, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum LvaluePreference { PreferMutLvalue, NoPreference } /// Whether `autoderef` requires types to resolve. -#[derive(Copy, Debug, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum UnresolvedTypeAction { /// Produce an error and return `ty_err` whenever a type cannot /// be resolved (i.e. it is `ty_infer`). @@ -3258,6 +3259,15 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, tcx.lang_items.neg_trait(), expr, &**oprnd, oprnd_t, unop); } + if let ty::ty_uint(_) = oprnd_t.sty { + if !tcx.sess.features.borrow().negate_unsigned { + feature_gate::emit_feature_err( + &tcx.sess.parse_sess.span_diagnostic, + "negate_unsigned", + expr.span, + "unary negation of unsigned integers may be removed in the future"); + } + } } } } diff --git a/src/librustc_typeck/check/wf.rs b/src/librustc_typeck/check/wf.rs index 23e31df5395..a86e2b17c93 100644 --- a/src/librustc_typeck/check/wf.rs +++ b/src/librustc_typeck/check/wf.rs @@ -249,11 +249,6 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> { &fcx.inh.param_env.free_substs, &trait_ref); - if fcx.tcx().lang_items.copy_trait() == Some(trait_ref.def_id) { - // This is checked in coherence. - return - } - // We are stricter on the trait-ref in an impl than the // self-type. In particular, we enforce region // relationships. The reason for this is that (at least diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 4d7a046fc60..37f43252483 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -350,7 +350,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { /////////////////////////////////////////////////////////////////////////// // Resolution reason. -#[derive(Copy)] +#[derive(Copy, Clone)] enum ResolveReason { ResolvingExpr(Span), ResolvingLocal(Span), diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index dd306c4da86..8f1b8bf1092 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -135,7 +135,7 @@ struct ItemCtxt<'a,'tcx:'a> { param_bounds: &'a (GetTypeParameterBounds<'tcx>+'a), } -#[derive(Copy, PartialEq, Eq)] +#[derive(Copy, Clone, PartialEq, Eq)] enum AstConvRequest { GetItemTypeScheme(ast::DefId), GetTraitDef(ast::DefId), diff --git a/src/librustc_typeck/rscope.rs b/src/librustc_typeck/rscope.rs index f1050a936e2..c908e21626e 100644 --- a/src/librustc_typeck/rscope.rs +++ b/src/librustc_typeck/rscope.rs @@ -40,7 +40,7 @@ pub trait RegionScope { // A scope in which all regions must be explicitly named. This is used // for types that appear in structs and so on. -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct ExplicitRscope; impl RegionScope for ExplicitRscope { diff --git a/src/librustc_typeck/variance.rs b/src/librustc_typeck/variance.rs index b014238b6f2..b83d8fc6af7 100644 --- a/src/librustc_typeck/variance.rs +++ b/src/librustc_typeck/variance.rs @@ -295,10 +295,10 @@ pub fn infer_variance(tcx: &ty::ctxt) { type VarianceTermPtr<'a> = &'a VarianceTerm<'a>; -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] struct InferredIndex(usize); -#[derive(Copy)] +#[derive(Copy, Clone)] enum VarianceTerm<'a> { ConstantTerm(ty::Variance), TransformTerm(VarianceTermPtr<'a>, VarianceTermPtr<'a>), @@ -336,7 +336,7 @@ struct TermsContext<'a, 'tcx: 'a> { inferred_infos: Vec<InferredInfo<'a>> , } -#[derive(Copy, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq)] enum ParamKind { TypeParam, RegionParam, @@ -560,7 +560,7 @@ struct ConstraintContext<'a, 'tcx: 'a> { /// Declares that the variable `decl_id` appears in a location with /// variance `variance`. -#[derive(Copy)] +#[derive(Copy, Clone)] struct Constraint<'a> { inferred: InferredIndex, variance: &'a VarianceTerm<'a>, diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index df6beab0f58..ed37b973f78 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -30,19 +30,19 @@ use html::render::{cache, CURRENT_LOCATION_KEY}; /// Helper to render an optional visibility with a space after it (if the /// visibility is preset) -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct VisSpace(pub Option<ast::Visibility>); /// Similarly to VisSpace, this structure is used to render a function style with a /// space after it. -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct UnsafetySpace(pub ast::Unsafety); /// Wrapper struct for properly emitting a method declaration. pub struct Method<'a>(pub &'a clean::SelfTy, pub &'a clean::FnDecl); /// Similar to VisSpace, but used for mutability -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct MutableSpace(pub clean::Mutability); /// Similar to VisSpace, but used for mutability -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct RawMutableSpace(pub clean::Mutability); /// Wrapper struct for properly emitting the stability level. pub struct Stability<'a>(pub &'a Option<clean::Stability>); diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 179418174d9..ac097d051b2 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -225,7 +225,7 @@ struct Source<'a>(&'a str); // Helper structs for rendering items/sidebars and carrying along contextual // information -#[derive(Copy)] +#[derive(Copy, Clone)] struct Item<'a> { cx: &'a Context, item: &'a clean::Item, diff --git a/src/librustdoc/stability_summary.rs b/src/librustdoc/stability_summary.rs index f75fced3bc2..3e4f6896ee6 100644 --- a/src/librustdoc/stability_summary.rs +++ b/src/librustdoc/stability_summary.rs @@ -27,7 +27,7 @@ use html::render::cache; #[derive(RustcEncodable, RustcDecodable, PartialEq, Eq)] /// The counts for each stability level. -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Counts { pub deprecated: u64, pub unstable: u64, diff --git a/src/libserialize/hex.rs b/src/libserialize/hex.rs index dc44536d60c..0676edf8169 100644 --- a/src/libserialize/hex.rs +++ b/src/libserialize/hex.rs @@ -62,7 +62,7 @@ pub trait FromHex { } /// Errors that can occur when decoding a hex encoded string -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub enum FromHexError { /// The input contained a character not part of the hex format InvalidHexCharacter(char, usize), diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index cdfe212bf23..5890bdec8c1 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -278,7 +278,7 @@ pub enum DecoderError { ApplicationError(string::String) } -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub enum EncoderError { FmtError(fmt::Error), BadHashmapKey, diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs index 053ceceb496..dec6d1e2209 100644 --- a/src/libstd/collections/hash/table.rs +++ b/src/libstd/collections/hash/table.rs @@ -87,6 +87,9 @@ struct RawBucket<K, V> { } impl<K,V> Copy for RawBucket<K,V> {} +impl<K,V> Clone for RawBucket<K,V> { + fn clone(&self) -> RawBucket<K, V> { *self } +} pub struct Bucket<K, V, M> { raw: RawBucket<K, V>, @@ -95,6 +98,9 @@ pub struct Bucket<K, V, M> { } impl<K,V,M:Copy> Copy for Bucket<K,V,M> {} +impl<K,V,M:Copy> Clone for Bucket<K,V,M> { + fn clone(&self) -> Bucket<K,V,M> { *self } +} pub struct EmptyBucket<K, V, M> { raw: RawBucket<K, V>, @@ -129,7 +135,7 @@ struct GapThenFull<K, V, M> { /// A hash that is not zero, since we use a hash of zero to represent empty /// buckets. -#[derive(PartialEq, Copy)] +#[derive(PartialEq, Copy, Clone)] pub struct SafeHash { hash: u64, } diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 4f97ae8f69b..eabc51beb12 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -946,7 +946,7 @@ mod tests { let mut read_stream = check!(File::open(filename)); let mut read_buf = [0; 1028]; let read_str = match check!(read_stream.read(&mut read_buf)) { - -1|0 => panic!("shouldn't happen"), + 0 => panic!("shouldn't happen"), n => str::from_utf8(&read_buf[..n]).unwrap().to_string() }; assert_eq!(read_str, message); diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index fe55f40390e..ea869ebae10 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -25,7 +25,7 @@ use string::String; use vec::Vec; /// A flag that specifies whether to use exponential (scientific) notation. -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum ExponentFormat { /// Do not use exponential notation. ExpNone, @@ -40,7 +40,7 @@ pub enum ExponentFormat { /// The number of digits used for emitting the fractional part of a number, if /// any. -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum SignificantDigits { /// All calculable digits will be printed. /// @@ -57,7 +57,7 @@ pub enum SignificantDigits { } /// How to emit the sign of a number. -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum SignFormat { /// No sign will be printed. The exponent sign will also be emitted. SignNone, diff --git a/src/libstd/old_io/fs.rs b/src/libstd/old_io/fs.rs index bef6ea53e50..509daa46ef3 100644 --- a/src/libstd/old_io/fs.rs +++ b/src/libstd/old_io/fs.rs @@ -970,7 +970,7 @@ mod test { let mut read_stream = File::open_mode(filename, Open, Read); let mut read_buf = [0; 1028]; let read_str = match check!(read_stream.read(&mut read_buf)) { - -1|0 => panic!("shouldn't happen"), + 0 => panic!("shouldn't happen"), n => str::from_utf8(&read_buf[..n]).unwrap().to_string() }; assert_eq!(read_str, message); diff --git a/src/libstd/old_io/mod.rs b/src/libstd/old_io/mod.rs index 9d7e1082d33..98ff6e82c6f 100644 --- a/src/libstd/old_io/mod.rs +++ b/src/libstd/old_io/mod.rs @@ -391,7 +391,7 @@ impl Error for IoError { } /// A list specifying general categories of I/O error. -#[derive(Copy, PartialEq, Eq, Clone, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Debug)] pub enum IoErrorKind { /// Any I/O error not part of this list. OtherIoError, @@ -1553,7 +1553,7 @@ impl<T: Buffer> BufferPrelude for T { /// When seeking, the resulting cursor is offset from a base by the offset given /// to the `seek` function. The base used is specified by this enumeration. -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum SeekStyle { /// Seek from the beginning of the stream SeekSet, @@ -1744,7 +1744,7 @@ pub enum FileType { /// /// println!("byte size: {}", info.size); /// ``` -#[derive(Copy, Hash)] +#[derive(Copy, Clone, Hash)] pub struct FileStat { /// The size of the file, in bytes pub size: u64, @@ -1783,7 +1783,7 @@ pub struct FileStat { /// structure. This information is not necessarily platform independent, and may /// have different meanings or no meaning at all on some platforms. #[unstable(feature = "io")] -#[derive(Copy, Hash)] +#[derive(Copy, Clone, Hash)] pub struct UnstableFileStat { /// The ID of the device containing the file. pub device: u64, diff --git a/src/libstd/old_io/net/addrinfo.rs b/src/libstd/old_io/net/addrinfo.rs index 739439ebd15..c5fa775ab4e 100644 --- a/src/libstd/old_io/net/addrinfo.rs +++ b/src/libstd/old_io/net/addrinfo.rs @@ -29,7 +29,7 @@ use sys; use vec::Vec; /// Hints to the types of sockets that are desired when looking up hosts -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub enum SocketType { Stream, Datagram, Raw } @@ -38,7 +38,7 @@ pub enum SocketType { /// to manipulate how a query is performed. /// /// The meaning of each of these flags can be found with `man -s 3 getaddrinfo` -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub enum Flag { AddrConfig, All, @@ -51,7 +51,7 @@ pub enum Flag { /// A transport protocol associated with either a hint or a return value of /// `lookup` -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub enum Protocol { TCP, UDP } @@ -61,7 +61,7 @@ pub enum Protocol { /// /// For details on these fields, see their corresponding definitions via /// `man -s 3 getaddrinfo` -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub struct Hint { pub family: usize, pub socktype: Option<SocketType>, @@ -69,7 +69,7 @@ pub struct Hint { pub flags: usize, } -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub struct Info { pub address: SocketAddr, pub family: usize, diff --git a/src/libstd/old_io/util.rs b/src/libstd/old_io/util.rs index a5ecb98334a..818c8e76d60 100644 --- a/src/libstd/old_io/util.rs +++ b/src/libstd/old_io/util.rs @@ -90,7 +90,7 @@ impl<R: Buffer> Buffer for LimitReader<R> { } /// A `Writer` which ignores bytes written to it, like /dev/null. -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] #[deprecated(since = "1.0.0", reason = "use std::io::sink() instead")] #[unstable(feature = "old_io")] pub struct NullWriter; @@ -103,7 +103,7 @@ impl Writer for NullWriter { } /// A `Reader` which returns an infinite stream of 0 bytes, like /dev/zero. -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] #[deprecated(since = "1.0.0", reason = "use std::io::repeat(0) instead")] #[unstable(feature = "old_io")] pub struct ZeroReader; @@ -130,7 +130,7 @@ impl Buffer for ZeroReader { } /// A `Reader` which is always at EOF, like /dev/null. -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] #[deprecated(since = "1.0.0", reason = "use std::io::empty() instead")] #[unstable(feature = "old_io")] pub struct NullReader; diff --git a/src/libstd/rt/libunwind.rs b/src/libstd/rt/libunwind.rs index b7769910564..4b754bd5f58 100644 --- a/src/libstd/rt/libunwind.rs +++ b/src/libstd/rt/libunwind.rs @@ -25,7 +25,7 @@ use libc; #[cfg(any(not(target_arch = "arm"), target_os = "ios"))] #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum _Unwind_Action { _UA_SEARCH_PHASE = 1, _UA_CLEANUP_PHASE = 2, diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index 632d9647212..0d26206f26b 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -116,7 +116,7 @@ fn lang_start(main: *const u8, argc: isize, argv: *const *const u8) -> isize { use libc; use libc::funcs::posix01::signal::signal; unsafe { - assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != -1); + assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != !0); } } ignore_sigpipe(); diff --git a/src/libstd/rt/unwind.rs b/src/libstd/rt/unwind.rs index e4927bbd3d2..f71811b1ead 100644 --- a/src/libstd/rt/unwind.rs +++ b/src/libstd/rt/unwind.rs @@ -398,7 +398,7 @@ pub mod eabi { pub struct DISPATCHER_CONTEXT; #[repr(C)] - #[derive(Copy)] + #[derive(Copy, Clone)] pub enum EXCEPTION_DISPOSITION { ExceptionContinueExecution, ExceptionContinueSearch, diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index e14f32865fa..c80182ec07d 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -342,7 +342,7 @@ mod spsc_queue; /// The receiving-half of Rust's channel type. This half can only be owned by /// one task #[stable(feature = "rust1", since = "1.0.0")] -pub struct Receiver<T:Send> { +pub struct Receiver<T> { inner: UnsafeCell<Flavor<T>>, } @@ -354,14 +354,14 @@ unsafe impl<T: Send> Send for Receiver<T> { } /// whenever `next` is called, waiting for a new message, and `None` will be /// returned when the corresponding channel has hung up. #[stable(feature = "rust1", since = "1.0.0")] -pub struct Iter<'a, T:Send+'a> { +pub struct Iter<'a, T: 'a> { rx: &'a Receiver<T> } /// The sending-half of Rust's asynchronous channel type. This half can only be /// owned by one task, but it can be cloned to send to other tasks. #[stable(feature = "rust1", since = "1.0.0")] -pub struct Sender<T:Send> { +pub struct Sender<T> { inner: UnsafeCell<Flavor<T>>, } @@ -372,7 +372,7 @@ unsafe impl<T: Send> Send for Sender<T> { } /// The sending-half of Rust's synchronous channel type. This half can only be /// owned by one task, but it can be cloned to send to other tasks. #[stable(feature = "rust1", since = "1.0.0")] -pub struct SyncSender<T: Send> { +pub struct SyncSender<T> { inner: Arc<UnsafeCell<sync::Packet<T>>>, } @@ -433,7 +433,7 @@ pub enum TrySendError<T> { Disconnected(T), } -enum Flavor<T:Send> { +enum Flavor<T> { Oneshot(Arc<UnsafeCell<oneshot::Packet<T>>>), Stream(Arc<UnsafeCell<stream::Packet<T>>>), Shared(Arc<UnsafeCell<shared::Packet<T>>>), @@ -441,7 +441,7 @@ enum Flavor<T:Send> { } #[doc(hidden)] -trait UnsafeFlavor<T:Send> { +trait UnsafeFlavor<T> { fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>>; unsafe fn inner_mut<'a>(&'a self) -> &'a mut Flavor<T> { &mut *self.inner_unsafe().get() @@ -450,12 +450,12 @@ trait UnsafeFlavor<T:Send> { &*self.inner_unsafe().get() } } -impl<T:Send> UnsafeFlavor<T> for Sender<T> { +impl<T> UnsafeFlavor<T> for Sender<T> { fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>> { &self.inner } } -impl<T:Send> UnsafeFlavor<T> for Receiver<T> { +impl<T> UnsafeFlavor<T> for Receiver<T> { fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>> { &self.inner } @@ -488,7 +488,7 @@ impl<T:Send> UnsafeFlavor<T> for Receiver<T> { /// println!("{:?}", rx.recv().unwrap()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] -pub fn channel<T: Send>() -> (Sender<T>, Receiver<T>) { +pub fn channel<T>() -> (Sender<T>, Receiver<T>) { let a = Arc::new(UnsafeCell::new(oneshot::Packet::new())); (Sender::new(Flavor::Oneshot(a.clone())), Receiver::new(Flavor::Oneshot(a))) } @@ -528,7 +528,7 @@ pub fn channel<T: Send>() -> (Sender<T>, Receiver<T>) { /// assert_eq!(rx.recv().unwrap(), 2); /// ``` #[stable(feature = "rust1", since = "1.0.0")] -pub fn sync_channel<T: Send>(bound: usize) -> (SyncSender<T>, Receiver<T>) { +pub fn sync_channel<T>(bound: usize) -> (SyncSender<T>, Receiver<T>) { let a = Arc::new(UnsafeCell::new(sync::Packet::new(bound))); (SyncSender::new(a.clone()), Receiver::new(Flavor::Sync(a))) } @@ -537,7 +537,7 @@ pub fn sync_channel<T: Send>(bound: usize) -> (SyncSender<T>, Receiver<T>) { // Sender //////////////////////////////////////////////////////////////////////////////// -impl<T: Send> Sender<T> { +impl<T> Sender<T> { fn new(inner: Flavor<T>) -> Sender<T> { Sender { inner: UnsafeCell::new(inner), @@ -619,7 +619,7 @@ impl<T: Send> Sender<T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<T: Send> Clone for Sender<T> { +impl<T> Clone for Sender<T> { fn clone(&self) -> Sender<T> { let (packet, sleeper, guard) = match *unsafe { self.inner() } { Flavor::Oneshot(ref p) => { @@ -665,7 +665,7 @@ impl<T: Send> Clone for Sender<T> { #[unsafe_destructor] #[stable(feature = "rust1", since = "1.0.0")] -impl<T: Send> Drop for Sender<T> { +impl<T> Drop for Sender<T> { fn drop(&mut self) { match *unsafe { self.inner_mut() } { Flavor::Oneshot(ref mut p) => unsafe { (*p.get()).drop_chan(); }, @@ -680,7 +680,7 @@ impl<T: Send> Drop for Sender<T> { // SyncSender //////////////////////////////////////////////////////////////////////////////// -impl<T: Send> SyncSender<T> { +impl<T> SyncSender<T> { fn new(inner: Arc<UnsafeCell<sync::Packet<T>>>) -> SyncSender<T> { SyncSender { inner: inner } } @@ -720,7 +720,7 @@ impl<T: Send> SyncSender<T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<T: Send> Clone for SyncSender<T> { +impl<T> Clone for SyncSender<T> { fn clone(&self) -> SyncSender<T> { unsafe { (*self.inner.get()).clone_chan(); } return SyncSender::new(self.inner.clone()); @@ -729,7 +729,7 @@ impl<T: Send> Clone for SyncSender<T> { #[unsafe_destructor] #[stable(feature = "rust1", since = "1.0.0")] -impl<T: Send> Drop for SyncSender<T> { +impl<T> Drop for SyncSender<T> { fn drop(&mut self) { unsafe { (*self.inner.get()).drop_chan(); } } @@ -739,7 +739,7 @@ impl<T: Send> Drop for SyncSender<T> { // Receiver //////////////////////////////////////////////////////////////////////////////// -impl<T: Send> Receiver<T> { +impl<T> Receiver<T> { fn new(inner: Flavor<T>) -> Receiver<T> { Receiver { inner: UnsafeCell::new(inner) } } @@ -858,7 +858,7 @@ impl<T: Send> Receiver<T> { } } -impl<T: Send> select::Packet for Receiver<T> { +impl<T> select::Packet for Receiver<T> { fn can_recv(&self) -> bool { loop { let new_port = match *unsafe { self.inner() } { @@ -945,7 +945,7 @@ impl<T: Send> select::Packet for Receiver<T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: Send> Iterator for Iter<'a, T> { +impl<'a, T> Iterator for Iter<'a, T> { type Item = T; fn next(&mut self) -> Option<T> { self.rx.recv().ok() } @@ -953,7 +953,7 @@ impl<'a, T: Send> Iterator for Iter<'a, T> { #[unsafe_destructor] #[stable(feature = "rust1", since = "1.0.0")] -impl<T: Send> Drop for Receiver<T> { +impl<T> Drop for Receiver<T> { fn drop(&mut self) { match *unsafe { self.inner_mut() } { Flavor::Oneshot(ref mut p) => unsafe { (*p.get()).drop_port(); }, diff --git a/src/libstd/sync/mpsc/mpsc_queue.rs b/src/libstd/sync/mpsc/mpsc_queue.rs index 1be8b0dd862..9b6c8f4dd97 100644 --- a/src/libstd/sync/mpsc/mpsc_queue.rs +++ b/src/libstd/sync/mpsc/mpsc_queue.rs @@ -72,12 +72,12 @@ struct Node<T> { /// The multi-producer single-consumer structure. This is not cloneable, but it /// may be safely shared so long as it is guaranteed that there is only one /// popper at a time (many pushers are allowed). -pub struct Queue<T: Send> { +pub struct Queue<T> { head: AtomicPtr<Node<T>>, tail: UnsafeCell<*mut Node<T>>, } -unsafe impl<T:Send> Send for Queue<T> { } +unsafe impl<T: Send> Send for Queue<T> { } unsafe impl<T: Send> Sync for Queue<T> { } impl<T> Node<T> { @@ -89,7 +89,7 @@ impl<T> Node<T> { } } -impl<T: Send> Queue<T> { +impl<T> Queue<T> { /// Creates a new queue that is safe to share among multiple producers and /// one consumer. pub fn new() -> Queue<T> { @@ -140,7 +140,7 @@ impl<T: Send> Queue<T> { #[unsafe_destructor] #[stable(feature = "rust1", since = "1.0.0")] -impl<T: Send> Drop for Queue<T> { +impl<T> Drop for Queue<T> { fn drop(&mut self) { unsafe { let mut cur = *self.tail.get(); diff --git a/src/libstd/sync/mpsc/oneshot.rs b/src/libstd/sync/mpsc/oneshot.rs index 13578ce0517..c6e8d87a22e 100644 --- a/src/libstd/sync/mpsc/oneshot.rs +++ b/src/libstd/sync/mpsc/oneshot.rs @@ -54,7 +54,7 @@ const DISCONNECTED: usize = 2; // channel is disconnected OR upgraded // moves *from* a pointer, ownership of the token is transferred to // whoever changed the state. -pub struct Packet<T:Send> { +pub struct Packet<T> { // Internal state of the chan/port pair (stores the blocked task as well) state: AtomicUsize, // One-shot data slot location @@ -64,7 +64,7 @@ pub struct Packet<T:Send> { upgrade: MyUpgrade<T>, } -pub enum Failure<T:Send> { +pub enum Failure<T> { Empty, Disconnected, Upgraded(Receiver<T>), @@ -76,19 +76,19 @@ pub enum UpgradeResult { UpWoke(SignalToken), } -pub enum SelectionResult<T:Send> { +pub enum SelectionResult<T> { SelCanceled, SelUpgraded(SignalToken, Receiver<T>), SelSuccess, } -enum MyUpgrade<T:Send> { +enum MyUpgrade<T> { NothingSent, SendUsed, GoUp(Receiver<T>), } -impl<T: Send> Packet<T> { +impl<T> Packet<T> { pub fn new() -> Packet<T> { Packet { data: None, @@ -368,7 +368,7 @@ impl<T: Send> Packet<T> { } #[unsafe_destructor] -impl<T: Send> Drop for Packet<T> { +impl<T> Drop for Packet<T> { fn drop(&mut self) { assert_eq!(self.state.load(Ordering::SeqCst), DISCONNECTED); } diff --git a/src/libstd/sync/mpsc/shared.rs b/src/libstd/sync/mpsc/shared.rs index 80cbd076163..5c1610bdc31 100644 --- a/src/libstd/sync/mpsc/shared.rs +++ b/src/libstd/sync/mpsc/shared.rs @@ -40,7 +40,7 @@ const MAX_STEALS: isize = 5; #[cfg(not(test))] const MAX_STEALS: isize = 1 << 20; -pub struct Packet<T: Send> { +pub struct Packet<T> { queue: mpsc::Queue<T>, cnt: AtomicIsize, // How many items are on this channel steals: isize, // How many times has a port received without blocking? @@ -64,7 +64,7 @@ pub enum Failure { Disconnected, } -impl<T: Send> Packet<T> { +impl<T> Packet<T> { // Creation of a packet *must* be followed by a call to postinit_lock // and later by inherit_blocker pub fn new() -> Packet<T> { @@ -474,7 +474,7 @@ impl<T: Send> Packet<T> { } #[unsafe_destructor] -impl<T: Send> Drop for Packet<T> { +impl<T> Drop for Packet<T> { fn drop(&mut self) { // Note that this load is not only an assert for correctness about // disconnection, but also a proper fence before the read of diff --git a/src/libstd/sync/mpsc/spsc_queue.rs b/src/libstd/sync/mpsc/spsc_queue.rs index cd6d1ee05c7..c75ac130808 100644 --- a/src/libstd/sync/mpsc/spsc_queue.rs +++ b/src/libstd/sync/mpsc/spsc_queue.rs @@ -57,7 +57,7 @@ struct Node<T> { /// but it can be safely shared in an Arc if it is guaranteed that there /// is only one popper and one pusher touching the queue at any one point in /// time. -pub struct Queue<T: Send> { +pub struct Queue<T> { // consumer fields tail: UnsafeCell<*mut Node<T>>, // where to pop from tail_prev: AtomicPtr<Node<T>>, // where to pop from @@ -78,7 +78,7 @@ unsafe impl<T: Send> Send for Queue<T> { } unsafe impl<T: Send> Sync for Queue<T> { } -impl<T: Send> Node<T> { +impl<T> Node<T> { fn new() -> *mut Node<T> { unsafe { boxed::into_raw(box Node { @@ -89,7 +89,7 @@ impl<T: Send> Node<T> { } } -impl<T: Send> Queue<T> { +impl<T> Queue<T> { /// Creates a new queue. /// /// This is unsafe as the type system doesn't enforce a single @@ -227,7 +227,7 @@ impl<T: Send> Queue<T> { } #[unsafe_destructor] -impl<T: Send> Drop for Queue<T> { +impl<T> Drop for Queue<T> { fn drop(&mut self) { unsafe { let mut cur = *self.first.get(); diff --git a/src/libstd/sync/mpsc/stream.rs b/src/libstd/sync/mpsc/stream.rs index a5a73314a6d..f0363fae84f 100644 --- a/src/libstd/sync/mpsc/stream.rs +++ b/src/libstd/sync/mpsc/stream.rs @@ -39,7 +39,7 @@ const MAX_STEALS: isize = 5; #[cfg(not(test))] const MAX_STEALS: isize = 1 << 20; -pub struct Packet<T:Send> { +pub struct Packet<T> { queue: spsc::Queue<Message<T>>, // internal queue for all message cnt: AtomicIsize, // How many items are on this channel @@ -49,7 +49,7 @@ pub struct Packet<T:Send> { port_dropped: AtomicBool, // flag if the channel has been destroyed. } -pub enum Failure<T:Send> { +pub enum Failure<T> { Empty, Disconnected, Upgraded(Receiver<T>), @@ -61,7 +61,7 @@ pub enum UpgradeResult { UpWoke(SignalToken), } -pub enum SelectionResult<T:Send> { +pub enum SelectionResult<T> { SelSuccess, SelCanceled, SelUpgraded(SignalToken, Receiver<T>), @@ -69,12 +69,12 @@ pub enum SelectionResult<T:Send> { // Any message could contain an "upgrade request" to a new shared port, so the // internal queue it's a queue of T, but rather Message<T> -enum Message<T:Send> { +enum Message<T> { Data(T), GoUp(Receiver<T>), } -impl<T: Send> Packet<T> { +impl<T> Packet<T> { pub fn new() -> Packet<T> { Packet { queue: unsafe { spsc::Queue::new(128) }, @@ -472,7 +472,7 @@ impl<T: Send> Packet<T> { } #[unsafe_destructor] -impl<T: Send> Drop for Packet<T> { +impl<T> Drop for Packet<T> { fn drop(&mut self) { // Note that this load is not only an assert for correctness about // disconnection, but also a proper fence before the read of diff --git a/src/libstd/sync/mpsc/sync.rs b/src/libstd/sync/mpsc/sync.rs index 71236269487..6221ca59b54 100644 --- a/src/libstd/sync/mpsc/sync.rs +++ b/src/libstd/sync/mpsc/sync.rs @@ -47,7 +47,7 @@ use sync::mpsc::blocking::{self, WaitToken, SignalToken}; use sync::mpsc::select::StartResult::{self, Installed, Abort}; use sync::{Mutex, MutexGuard}; -pub struct Packet<T: Send> { +pub struct Packet<T> { /// Only field outside of the mutex. Just done for kicks, but mainly because /// the other shared channel already had the code implemented channels: AtomicUsize, @@ -113,10 +113,10 @@ pub enum Failure { /// Atomically blocks the current thread, placing it into `slot`, unlocking `lock` /// in the meantime. This re-locks the mutex upon returning. -fn wait<'a, 'b, T: Send>(lock: &'a Mutex<State<T>>, - mut guard: MutexGuard<'b, State<T>>, - f: fn(SignalToken) -> Blocker) - -> MutexGuard<'a, State<T>> +fn wait<'a, 'b, T>(lock: &'a Mutex<State<T>>, + mut guard: MutexGuard<'b, State<T>>, + f: fn(SignalToken) -> Blocker) + -> MutexGuard<'a, State<T>> { let (wait_token, signal_token) = blocking::tokens(); match mem::replace(&mut guard.blocker, f(signal_token)) { @@ -136,7 +136,7 @@ fn wakeup<T>(token: SignalToken, guard: MutexGuard<State<T>>) { token.signal(); } -impl<T: Send> Packet<T> { +impl<T> Packet<T> { pub fn new(cap: usize) -> Packet<T> { Packet { channels: AtomicUsize::new(1), @@ -412,7 +412,7 @@ impl<T: Send> Packet<T> { } #[unsafe_destructor] -impl<T: Send> Drop for Packet<T> { +impl<T> Drop for Packet<T> { fn drop(&mut self) { assert_eq!(self.channels.load(Ordering::SeqCst), 0); let mut guard = self.lock.lock().unwrap(); diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index b24cfbb6899..16e7f265412 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -112,7 +112,7 @@ use fmt; /// *guard += 1; /// ``` #[stable(feature = "rust1", since = "1.0.0")] -pub struct Mutex<T: Send> { +pub struct Mutex<T> { // Note that this static mutex is in a *box*, not inlined into the struct // itself. Once a native mutex has been used once, its address can never // change (it can't be moved). This mutex type can be safely moved at any @@ -122,6 +122,8 @@ pub struct Mutex<T: Send> { data: UnsafeCell<T>, } +// these are the only places where `T: Send` matters; all other +// functionality works fine on a single thread. unsafe impl<T: Send> Send for Mutex<T> { } unsafe impl<T: Send> Sync for Mutex<T> { } @@ -181,7 +183,7 @@ pub const MUTEX_INIT: StaticMutex = StaticMutex { poison: poison::FLAG_INIT, }; -impl<T: Send> Mutex<T> { +impl<T> Mutex<T> { /// Creates a new mutex in an unlocked state ready for use. #[stable(feature = "rust1", since = "1.0.0")] pub fn new(t: T) -> Mutex<T> { @@ -244,7 +246,7 @@ impl<T: Send> Mutex<T> { #[unsafe_destructor] #[stable(feature = "rust1", since = "1.0.0")] -impl<T: Send> Drop for Mutex<T> { +impl<T> Drop for Mutex<T> { fn drop(&mut self) { // This is actually safe b/c we know that there is no further usage of // this mutex (it's up to the user to arrange for a mutex to get @@ -254,7 +256,7 @@ impl<T: Send> Drop for Mutex<T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<T: fmt::Debug + Send + 'static> fmt::Debug for Mutex<T> { +impl<T: fmt::Debug + 'static> fmt::Debug for Mutex<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.try_lock() { Ok(guard) => write!(f, "Mutex {{ data: {:?} }}", *guard), diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index a79ffaa0860..d70350bc7d6 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -130,7 +130,7 @@ pub struct RwLockWriteGuard<'a, T: 'a> { impl<'a, T> !marker::Send for RwLockWriteGuard<'a, T> {} -impl<T: Send + Sync> RwLock<T> { +impl<T> RwLock<T> { /// Creates a new instance of an `RwLock<T>` which is unlocked. /// /// # Examples @@ -258,7 +258,7 @@ impl<T> Drop for RwLock<T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<T: fmt::Debug + Send + Sync> fmt::Debug for RwLock<T> { +impl<T: fmt::Debug> fmt::Debug for RwLock<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.try_read() { Ok(guard) => write!(f, "RwLock {{ data: {:?} }}", *guard), diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs index 1a0ee17904a..fc21effb45a 100644 --- a/src/libstd/sys/common/net.rs +++ b/src/libstd/sys/common/net.rs @@ -115,9 +115,9 @@ pub fn socket(addr: SocketAddr, ty: libc::c_int) -> IoResult<sock_t> { Ipv4Addr(..) => libc::AF_INET, Ipv6Addr(..) => libc::AF_INET6, }; - match libc::socket(fam, ty, 0) { + match libc::socket(fam, ty, 0) as i32 { -1 => Err(last_net_error()), - fd => Ok(fd), + fd => Ok(fd as sock_t), } } } diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index e74de595f97..4804f650441 100644 --- a/src/libstd/sys/windows/c.rs +++ b/src/libstd/sys/windows/c.rs @@ -49,9 +49,9 @@ pub const ERROR_NO_MORE_FILES: libc::DWORD = 18; pub const TOKEN_READ: libc::DWORD = 0x20008; // Note that these are not actually HANDLEs, just values to pass to GetStdHandle -pub const STD_INPUT_HANDLE: libc::DWORD = -10; -pub const STD_OUTPUT_HANDLE: libc::DWORD = -11; -pub const STD_ERROR_HANDLE: libc::DWORD = -12; +pub const STD_INPUT_HANDLE: libc::DWORD = -10i32 as libc::DWORD; +pub const STD_OUTPUT_HANDLE: libc::DWORD = -11i32 as libc::DWORD; +pub const STD_ERROR_HANDLE: libc::DWORD = -12i32 as libc::DWORD; #[repr(C)] #[cfg(target_arch = "x86")] @@ -89,7 +89,6 @@ pub type LPWSANETWORKEVENTS = *mut WSANETWORKEVENTS; pub type WSAEVENT = libc::HANDLE; #[repr(C)] -#[derive(Copy)] pub struct WSAPROTOCOL_INFO { pub dwServiceFlags1: libc::DWORD, pub dwServiceFlags2: libc::DWORD, diff --git a/src/libstd/sys/windows/tcp.rs b/src/libstd/sys/windows/tcp.rs index 2ac8ac10aa9..41e97dc8475 100644 --- a/src/libstd/sys/windows/tcp.rs +++ b/src/libstd/sys/windows/tcp.rs @@ -15,6 +15,7 @@ use prelude::v1::*; use old_io::net::ip; use old_io::IoResult; use libc; +use libc::consts::os::extra::INVALID_SOCKET; use mem; use ptr; use super::{last_error, last_net_error, sock_t}; @@ -183,8 +184,8 @@ impl TcpAcceptor { match unsafe { libc::accept(self.socket(), ptr::null_mut(), ptr::null_mut()) } { - -1 if wouldblock() => {} - -1 => return Err(last_net_error()), + INVALID_SOCKET if wouldblock() => {} + INVALID_SOCKET => return Err(last_net_error()), // Accepted sockets inherit the same properties as the caller, // so we need to deregister our event and switch the socket back diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index b9cbd01bed1..acd6970f113 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -197,7 +197,7 @@ macro_rules! __thread_local_inner { /// Indicator of the state of a thread local storage key. #[unstable(feature = "std_misc", reason = "state querying was recently added")] -#[derive(Eq, PartialEq, Copy)] +#[derive(Eq, PartialEq, Copy, Clone)] pub enum LocalKeyState { /// All keys are in this state whenever a thread starts. Keys will /// transition to the `Valid` state once the first call to `with` happens diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index 896e638deb4..27e331893e5 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.rs @@ -15,7 +15,7 @@ pub use self::AbiArchitecture::*; use std::fmt; -#[derive(Copy, PartialEq, Eq, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Debug)] pub enum Os { OsWindows, OsMacos, @@ -49,7 +49,7 @@ pub enum Abi { } #[allow(non_camel_case_types)] -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub enum Architecture { X86, X86_64, @@ -58,7 +58,7 @@ pub enum Architecture { Mipsel } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct AbiData { abi: Abi, @@ -66,7 +66,7 @@ pub struct AbiData { name: &'static str, } -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum AbiArchitecture { /// Not a real ABI (e.g., intrinsic) RustArch, diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index ce1539c62f8..40390765dde 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -388,7 +388,7 @@ pub const CRATE_NODE_ID: NodeId = 0; /// When parsing and doing expansions, we initially give all AST nodes this AST /// node value. Then later, in the renumber pass, we renumber them to have /// small, positive ids. -pub const DUMMY_NODE_ID: NodeId = -1; +pub const DUMMY_NODE_ID: NodeId = !0; /// The AST represents all type param bounds as types. /// typeck::collect::compute_bounds matches these against diff --git a/src/libsyntax/ast_map/blocks.rs b/src/libsyntax/ast_map/blocks.rs index 1994ca70bbb..475970ac30a 100644 --- a/src/libsyntax/ast_map/blocks.rs +++ b/src/libsyntax/ast_map/blocks.rs @@ -40,7 +40,7 @@ use visit; /// - The default implementation for a trait method. /// /// To construct one, use the `Code::from_node` function. -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct FnLikeNode<'a> { node: ast_map::Node<'a> } /// MaybeFnLike wraps a method that indicates if an object @@ -80,7 +80,7 @@ impl MaybeFnLike for ast::Expr { /// Carries either an FnLikeNode or a Block, as these are the two /// constructs that correspond to "code" (as in, something from which /// we can construct a control-flow graph). -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum Code<'a> { FnLikeCode(FnLikeNode<'a>), BlockCode(&'a Block), diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs index 2b5cb7076f4..2a9a609ecd1 100644 --- a/src/libsyntax/ast_map/mod.rs +++ b/src/libsyntax/ast_map/mod.rs @@ -101,7 +101,7 @@ pub fn path_to_string<PI: Iterator<Item=PathElem>>(path: PI) -> String { }) } -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub enum Node<'ast> { NodeItem(&'ast Item), NodeForeignItem(&'ast ForeignItem), diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index b83b42c73e7..c4c2249d029 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -291,7 +291,7 @@ pub fn empty_generics() -> Generics { // ______________________________________________________________________ // Enumerating the IDs which appear in an AST -#[derive(RustcEncodable, RustcDecodable, Debug, Copy)] +#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug)] pub struct IdRange { pub min: NodeId, pub max: NodeId, diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 2d8484e95bb..06e447bb12a 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -282,7 +282,7 @@ pub fn find_crate_name(attrs: &[Attribute]) -> Option<InternedString> { first_attr_value_str_by_name(attrs, "crate_name") } -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub enum InlineAttr { None, Hint, @@ -571,7 +571,7 @@ fn int_type_of_word(s: &str) -> Option<IntType> { } } -#[derive(PartialEq, Debug, RustcEncodable, RustcDecodable, Copy)] +#[derive(PartialEq, Debug, RustcEncodable, RustcDecodable, Copy, Clone)] pub enum ReprAttr { ReprAny, ReprInt(Span, IntType), @@ -590,7 +590,7 @@ impl ReprAttr { } } -#[derive(Eq, Hash, PartialEq, Debug, RustcEncodable, RustcDecodable, Copy)] +#[derive(Eq, Hash, PartialEq, Debug, RustcEncodable, RustcDecodable, Copy, Clone)] pub enum IntType { SignedInt(ast::IntTy), UnsignedInt(ast::UintTy) diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 6a00fff1860..b563a5e7d6e 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -47,7 +47,7 @@ pub struct BytePos(pub u32); /// A character offset. Because of multibyte utf8 characters, a byte offset /// is not equivalent to a character offset. The CodeMap will convert BytePos /// values to CharPos values as necessary. -#[derive(Copy, PartialEq, Hash, PartialOrd, Debug)] +#[derive(Copy, Clone, PartialEq, Hash, PartialOrd, Debug)] pub struct CharPos(pub usize); // FIXME: Lots of boilerplate in these impls, but so far my attempts to fix @@ -278,9 +278,9 @@ pub struct ExpnInfo { #[derive(PartialEq, Eq, Clone, Debug, Hash, RustcEncodable, RustcDecodable, Copy)] pub struct ExpnId(u32); -pub const NO_EXPANSION: ExpnId = ExpnId(-1); +pub const NO_EXPANSION: ExpnId = ExpnId(!0); // For code appearing from the command line -pub const COMMAND_LINE_EXPN: ExpnId = ExpnId(-2); +pub const COMMAND_LINE_EXPN: ExpnId = ExpnId(!1); impl ExpnId { pub fn from_llvm_cookie(cookie: c_uint) -> ExpnId { @@ -305,7 +305,7 @@ pub struct FileLines { } /// Identifies an offset of a multi-byte character in a FileMap -#[derive(Copy, RustcEncodable, RustcDecodable, Eq, PartialEq)] +#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Eq, PartialEq)] pub struct MultiByteChar { /// The absolute offset of the character in the CodeMap pub pos: BytePos, diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 32857769acf..f35cc8c8d23 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -71,12 +71,12 @@ pub trait Emitter { /// This structure is used to signify that a task has panicked with a fatal error /// from the diagnostics. You can use this with the `Any` trait to figure out /// how a rustc task died (if so desired). -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct FatalError; /// Signifies that the compiler died with an explicit call to `.bug` /// or `.span_bug` rather than a failed assertion, etc. -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct ExplicitBug; /// A span-handler is like a handler but also @@ -371,7 +371,7 @@ fn stderr_isatty() -> bool { } #[cfg(windows)] fn stderr_isatty() -> bool { - const STD_ERROR_HANDLE: libc::DWORD = -12; + const STD_ERROR_HANDLE: libc::DWORD = -12i32 as libc::DWORD; extern "system" { fn GetStdHandle(which: libc::DWORD) -> libc::HANDLE; fn GetConsoleMode(hConsoleHandle: libc::HANDLE, diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index b679456b353..71fba789ff8 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -318,7 +318,7 @@ impl MacResult for MacEager { /// Fill-in macro expansion result, to allow compilation to continue /// after hitting errors. -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct DummyResult { expr_only: bool, span: Span diff --git a/src/libsyntax/ext/deriving/cmp/ord.rs b/src/libsyntax/ext/deriving/cmp/ord.rs index b2b26548018..8ecd172b2f0 100644 --- a/src/libsyntax/ext/deriving/cmp/ord.rs +++ b/src/libsyntax/ext/deriving/cmp/ord.rs @@ -84,7 +84,7 @@ pub fn expand_deriving_ord<F>(cx: &mut ExtCtxt, trait_def.expand(cx, mitem, item, push) } -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum OrderingOp { PartialCmpOp, LtOp, LeOp, GtOp, GeOp, } diff --git a/src/libsyntax/ext/mtwt.rs b/src/libsyntax/ext/mtwt.rs index a2023d6832e..f514f72d565 100644 --- a/src/libsyntax/ext/mtwt.rs +++ b/src/libsyntax/ext/mtwt.rs @@ -38,7 +38,7 @@ pub struct SCTable { rename_memo: RefCell<HashMap<(SyntaxContext,Ident,Name),SyntaxContext>>, } -#[derive(PartialEq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] +#[derive(PartialEq, RustcEncodable, RustcDecodable, Hash, Debug, Copy, Clone)] pub enum SyntaxContext_ { EmptyCtxt, Mark (Mrk,SyntaxContext), diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 4c01cecc67c..dbddd9dd44d 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -152,6 +152,9 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[ // #23121. Array patterns have some hazards yet. ("slice_patterns", "1.0.0", Active), + + // Allows use of unary negate on unsigned integers, e.g. -e for e: u8 + ("negate_unsigned", "1.0.0", Active), ]; // (changing above list without updating src/doc/reference.md makes @cmr sad) @@ -292,7 +295,7 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType)] = &[ ("recursion_limit", CrateLevel), ]; -#[derive(PartialEq, Copy, Debug)] +#[derive(PartialEq, Copy, Clone, Debug)] pub enum AttributeType { /// Normal, builtin attribute that is consumed /// by the compiler before the unused_attribute check @@ -325,6 +328,7 @@ pub struct Features { pub allow_custom_derive: bool, pub simd_ffi: bool, pub unmarked_api: bool, + pub negate_unsigned: bool, /// spans of #![feature] attrs for stable language features. for error reporting pub declared_stable_lang_features: Vec<Span>, /// #![feature] attrs for non-language (library) features @@ -346,6 +350,7 @@ impl Features { allow_custom_derive: false, simd_ffi: false, unmarked_api: false, + negate_unsigned: false, declared_stable_lang_features: Vec::new(), declared_lib_features: Vec::new() } @@ -724,6 +729,7 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler, allow_custom_derive: cx.has_feature("custom_derive"), simd_ffi: cx.has_feature("simd_ffi"), unmarked_api: cx.has_feature("unmarked_api"), + negate_unsigned: cx.has_feature("negate_unsigned"), declared_stable_lang_features: accepted_features, declared_lib_features: unknown_features } diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index bb9b586bb3f..f120dde8e1c 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -20,7 +20,7 @@ use parse::token; use ptr::P; /// The specific types of unsupported syntax -#[derive(Copy, PartialEq, Eq, Hash)] +#[derive(Copy, Clone, PartialEq, Eq, Hash)] pub enum ObsoleteSyntax { ClosureKind, ExternCrateString, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6f1f73aa2a9..c7216243239 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -96,7 +96,7 @@ type ItemInfo = (Ident, Item_, Option<Vec<Attribute> >); /// How to parse a path. There are four different kinds of paths, all of which /// are parsed somewhat differently. -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub enum PathParsingMode { /// A path with no type parameters; e.g. `foo::bar::Baz` NoTypesAllowed, @@ -109,7 +109,7 @@ pub enum PathParsingMode { } /// How to parse a bound, whether to allow bound modifiers such as `?`. -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub enum BoundParsingMode { Bare, Modified, diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 640b7d1c91d..ebfd970f3db 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -147,13 +147,13 @@ pub fn buf_str(toks: &[Token], s } -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum PrintStackBreak { Fits, Broken(Breaks), } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct PrintStackElem { offset: isize, pbreak: PrintStackBreak diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index c2f323f98af..46d196d13fa 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -47,12 +47,12 @@ pub trait PpAnn { fn post(&self, _state: &mut State, _node: AnnNode) -> io::Result<()> { Ok(()) } } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct NoAnn; impl PpAnn for NoAnn {} -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct CurrentCommentAndLiteral { cur_cmnt: usize, cur_lit: usize, @@ -3053,7 +3053,7 @@ mod test { #[test] fn test_signed_int_to_string() { let pos_int = ast::LitInt(42, ast::SignedIntLit(ast::TyI32, ast::Plus)); - let neg_int = ast::LitInt((-42) as u64, ast::SignedIntLit(ast::TyI32, ast::Minus)); + let neg_int = ast::LitInt((!42 + 1) as u64, ast::SignedIntLit(ast::TyI32, ast::Minus)); assert_eq!(format!("-{}", lit_to_string(&codemap::dummy_spanned(pos_int))), lit_to_string(&codemap::dummy_spanned(neg_int))); } diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 638ddd3ea2e..5c345c75642 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -32,7 +32,7 @@ use codemap::Span; use ptr::P; use owned_slice::OwnedSlice; -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum FnKind<'a> { /// fn foo() or extern "Abi" fn foo() FkItemFn(Ident, &'a Generics, Unsafety, Abi), diff --git a/src/libterm/lib.rs b/src/libterm/lib.rs index 38d58f042b9..74ec3406f73 100644 --- a/src/libterm/lib.rs +++ b/src/libterm/lib.rs @@ -184,7 +184,7 @@ pub mod attr { /// Most attributes can only be turned on and must be turned off with term.reset(). /// The ones that can be turned off explicitly take a boolean value. /// Color is also represented as an attribute for convenience. - #[derive(Copy)] + #[derive(Copy, Clone)] pub enum Attr { /// Bold (or possibly bright) mode Bold, diff --git a/src/libterm/terminfo/parm.rs b/src/libterm/terminfo/parm.rs index d6a4659c45a..01586b8f36e 100644 --- a/src/libterm/terminfo/parm.rs +++ b/src/libterm/terminfo/parm.rs @@ -18,7 +18,7 @@ use std::ascii::OwnedAsciiExt; use std::mem::replace; use std::iter::repeat; -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] enum States { Nothing, Percent, @@ -35,7 +35,7 @@ enum States { SeekIfEndPercent(isize) } -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] enum FormatState { FormatStateFlags, FormatStateWidth, @@ -444,7 +444,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) Ok(output) } -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] struct Flags { width: usize, precision: usize, @@ -461,7 +461,7 @@ impl Flags { } } -#[derive(Copy)] +#[derive(Copy, Clone)] enum FormatOp { FormatDigit, FormatOctal, diff --git a/src/libterm/win.rs b/src/libterm/win.rs index 001313db676..66ef5e86617 100644 --- a/src/libterm/win.rs +++ b/src/libterm/win.rs @@ -104,7 +104,7 @@ impl<T: Write+Send+'static> WinConsole<T> { // terminal! Admittedly, this is fragile, since stderr could be // redirected to a different console. This is good enough for // rustc though. See #13400. - let out = GetStdHandle(-11); + let out = GetStdHandle(-11i32 as libc::DWORD); SetConsoleTextAttribute(out, accum); } } @@ -116,7 +116,8 @@ impl<T: Write+Send+'static> WinConsole<T> { let bg; unsafe { let mut buffer_info = ::std::mem::uninitialized(); - if GetConsoleScreenBufferInfo(GetStdHandle(-11), &mut buffer_info) != 0 { + if GetConsoleScreenBufferInfo(GetStdHandle(-11i32 as libc::DWORD), + &mut buffer_info) != 0 { fg = bits_to_color(buffer_info.wAttributes); bg = bits_to_color(buffer_info.wAttributes >> 4); } else { diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 00117775eee..c84703b93ed 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -194,7 +194,7 @@ impl fmt::Debug for TestFn { /// This is fed into functions marked with `#[bench]` to allow for /// set-up & tear-down before running a piece of code repeatedly via a /// call to `iter`. -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Bencher { iterations: u64, dur: Duration, @@ -281,7 +281,7 @@ pub fn test_main_static(args: env::Args, tests: &[TestDescAndFn]) { test_main(&args, owned_tests) } -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum ColorConfig { AutoColor, AlwaysColor, @@ -757,7 +757,7 @@ fn stdout_isatty() -> bool { } #[cfg(windows)] fn stdout_isatty() -> bool { - const STD_OUTPUT_HANDLE: libc::DWORD = -11; + const STD_OUTPUT_HANDLE: libc::DWORD = -11i32 as libc::DWORD; extern "system" { fn GetStdHandle(which: libc::DWORD) -> libc::HANDLE; fn GetConsoleMode(hConsoleHandle: libc::HANDLE, diff --git a/src/snapshots.txt b/src/snapshots.txt index 74d8b222c54..5d265478b64 100644 --- a/src/snapshots.txt +++ b/src/snapshots.txt @@ -1,5 +1,5 @@ S 2015-03-27 5520801 - bitrig-x86_64 41de2c7a69a1ac648d3fa3b65e96a29bdc122163 + bitrig-x86_64 55a69b0ae5481ccda54c2fcfc54025a0945c4f57 freebsd-x86_64 0910bbad35e213f679d0433884fd51398eb3bc8d linux-i386 1ef82402ed16f5a6d2f87a9a62eaa83170e249ec linux-x86_64 ef2154372e97a3cb687897d027fd51c8f2c5f349 @@ -9,7 +9,7 @@ S 2015-03-27 5520801 winnt-x86_64 903a99a58f57a9bd9848cc68a2445dda881f1ee8 S 2015-03-25 a923278 - bitrig-x86_64 41de2c7a69a1ac648d3fa3b65e96a29bdc122163 + bitrig-x86_64 e56c400a04bca7b52ab54e0780484bb68fa449c2 freebsd-x86_64 cd02c86a9218da73b2a45aff293787010d33bf3e linux-i386 da50141558eed6dabab97b79b2c6a7de4f2d2c5e linux-x86_64 bca03458d28d07506bad4b80e5770b2117286244 diff --git a/src/test/auxiliary/issue-14422.rs b/src/test/auxiliary/issue-14422.rs index 3e23698397b..32af6d9255e 100644 --- a/src/test/auxiliary/issue-14422.rs +++ b/src/test/auxiliary/issue-14422.rs @@ -23,7 +23,7 @@ mod src { pub mod hidden_core { use super::aliases::B; - #[derive(Copy)] + #[derive(Copy, Clone)] pub struct A; pub fn make() -> B { A } diff --git a/src/test/auxiliary/issue13213aux.rs b/src/test/auxiliary/issue13213aux.rs index c2acc514346..d0566a1e091 100644 --- a/src/test/auxiliary/issue13213aux.rs +++ b/src/test/auxiliary/issue13213aux.rs @@ -13,13 +13,13 @@ pub use private::P; -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct S { p: P, } mod private { - #[derive(Copy)] + #[derive(Copy, Clone)] pub struct P { p: i32, } diff --git a/src/test/auxiliary/method_self_arg1.rs b/src/test/auxiliary/method_self_arg1.rs index 643442363a4..348b71faf0c 100644 --- a/src/test/auxiliary/method_self_arg1.rs +++ b/src/test/auxiliary/method_self_arg1.rs @@ -17,7 +17,7 @@ static mut COUNT: u64 = 1; pub fn get_count() -> u64 { unsafe { COUNT } } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Foo; impl Foo { diff --git a/src/test/auxiliary/method_self_arg2.rs b/src/test/auxiliary/method_self_arg2.rs index fd99da87e6b..b67ec1b9bfc 100644 --- a/src/test/auxiliary/method_self_arg2.rs +++ b/src/test/auxiliary/method_self_arg2.rs @@ -17,7 +17,7 @@ static mut COUNT: u64 = 1; pub fn get_count() -> u64 { unsafe { COUNT } } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Foo; impl Foo { diff --git a/src/test/auxiliary/struct_variant_xc_aux.rs b/src/test/auxiliary/struct_variant_xc_aux.rs index 8670cd96fc6..201f028b6b6 100644 --- a/src/test/auxiliary/struct_variant_xc_aux.rs +++ b/src/test/auxiliary/struct_variant_xc_aux.rs @@ -11,7 +11,7 @@ #![crate_name="struct_variant_xc_aux"] #![crate_type = "lib"] -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum Enum { Variant(u8), StructVariant { arg: u8 } diff --git a/src/test/auxiliary/xcrate_unit_struct.rs b/src/test/auxiliary/xcrate_unit_struct.rs index 6799cbc6f33..7a69be2b06c 100644 --- a/src/test/auxiliary/xcrate_unit_struct.rs +++ b/src/test/auxiliary/xcrate_unit_struct.rs @@ -12,26 +12,26 @@ // used by the rpass test -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Struct; -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum Unit { UnitVariant, Argument(Struct) } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct TupleStruct(pub usize, pub &'static str); // used by the cfail test -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct StructWithFields { foo: isize, } -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum EnumWithVariants { EnumVariant, EnumVariantArg(isize) diff --git a/src/test/bench/noise.rs b/src/test/bench/noise.rs index d6577036b8e..83c39b3f3fa 100644 --- a/src/test/bench/noise.rs +++ b/src/test/bench/noise.rs @@ -18,7 +18,7 @@ use std::f32::consts::PI; use std::num::Float; use std::rand::{Rng, StdRng}; -#[derive(Copy)] +#[derive(Copy, Clone)] struct Vec2 { x: f32, y: f32, diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index 891d8143dd8..72f3464cdb7 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -54,7 +54,7 @@ fn print_complements() { } } -#[derive(Copy)] +#[derive(Copy, Clone)] enum Color { Red, Yellow, @@ -72,7 +72,7 @@ impl fmt::Debug for Color { } } -#[derive(Copy)] +#[derive(Copy, Clone)] struct CreatureInfo { name: usize, color: Color diff --git a/src/test/bench/shootout-fannkuch-redux.rs b/src/test/bench/shootout-fannkuch-redux.rs index af9ef80e609..4489a124abe 100644 --- a/src/test/bench/shootout-fannkuch-redux.rs +++ b/src/test/bench/shootout-fannkuch-redux.rs @@ -63,12 +63,12 @@ fn next_permutation(perm: &mut [i32], count: &mut [i32]) { } } -#[derive(Copy)] +#[derive(Copy, Clone)] struct P { p: [i32; 16], } -#[derive(Copy)] +#[derive(Copy, Clone)] struct Perm { cnt: [i32; 16], fact: [u32; 16], diff --git a/src/test/bench/shootout-fasta-redux.rs b/src/test/bench/shootout-fasta-redux.rs index 7c4cc0eaab7..effdd67027a 100644 --- a/src/test/bench/shootout-fasta-redux.rs +++ b/src/test/bench/shootout-fasta-redux.rs @@ -105,7 +105,7 @@ fn sum_and_scale(a: &'static [AminoAcid]) -> Vec<AminoAcid> { result } -#[derive(Copy)] +#[derive(Copy, Clone)] struct AminoAcid { c: u8, p: f32, diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index ba4f2c9b1c5..db131bcfdc3 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -64,7 +64,7 @@ static OCCURRENCES: [&'static str;5] = [ // Code implementation -#[derive(Copy, PartialEq, PartialOrd, Ord, Eq)] +#[derive(Copy, Clone, PartialEq, PartialOrd, Ord, Eq)] struct Code(u64); impl Code { diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index 13154e025d2..669a0e86f1e 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -96,7 +96,7 @@ static BODIES: [Planet;N_BODIES] = [ }, ]; -#[derive(Copy)] +#[derive(Copy, Clone)] struct Planet { x: f64, y: f64, z: f64, vx: f64, vy: f64, vz: f64, diff --git a/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs b/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs index 99618c6bf56..e5091a92581 100644 --- a/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs +++ b/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs @@ -9,13 +9,13 @@ // except according to those terms. -#[derive(Copy)] +#[derive(Copy, Clone)] struct Foo { bar1: Bar, bar2: Bar } -#[derive(Copy)] +#[derive(Copy, Clone)] struct Bar { int1: isize, int2: isize, diff --git a/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs b/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs index 849c98e122e..440be93dfdc 100644 --- a/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs +++ b/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs @@ -8,13 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[derive(Copy)] +#[derive(Copy, Clone)] struct Foo { bar1: Bar, bar2: Bar } -#[derive(Copy)] +#[derive(Copy, Clone)] struct Bar { int1: isize, int2: isize, diff --git a/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs b/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs index b1eb06d16b1..cce55b6c941 100644 --- a/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs +++ b/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs @@ -10,7 +10,7 @@ use std::ops::Add; -#[derive(Copy)] +#[derive(Copy, Clone)] struct Point { x: isize, y: isize, diff --git a/src/test/compile-fail/borrowck-use-mut-borrow.rs b/src/test/compile-fail/borrowck-use-mut-borrow.rs index e14df7329ea..c11e58651aa 100644 --- a/src/test/compile-fail/borrowck-use-mut-borrow.rs +++ b/src/test/compile-fail/borrowck-use-mut-borrow.rs @@ -10,7 +10,7 @@ #![feature(box_syntax)] -#[derive(Copy)] +#[derive(Copy, Clone)] struct A { a: isize, b: isize } struct B { a: isize, b: Box<isize> } diff --git a/src/test/compile-fail/coherence-impls-copy.rs b/src/test/compile-fail/coherence-impls-copy.rs index b99b2e1205b..1be606c3546 100644 --- a/src/test/compile-fail/coherence-impls-copy.rs +++ b/src/test/compile-fail/coherence-impls-copy.rs @@ -22,10 +22,15 @@ struct NotSync; impl !Sync for NotSync {} impl Copy for TestE {} +impl Clone for TestE { fn clone(&self) -> Self { *self } } + impl Copy for MyType {} impl Copy for &'static mut MyType {} //~^ ERROR E0206 +//~| ERROR E0277 +//~| ERROR E0277 +impl Clone for MyType { fn clone(&self) -> Self { *self } } impl Copy for (MyType, MyType) {} //~^ ERROR E0206 @@ -37,6 +42,8 @@ impl Copy for &'static NotSync {} impl Copy for [MyType] {} //~^ ERROR E0206 //~| ERROR E0117 +//~| ERROR E0277 +//~| ERROR E0277 impl Copy for &'static [NotSync] {} //~^ ERROR E0206 diff --git a/src/test/compile-fail/const-eval-overflow.rs b/src/test/compile-fail/const-eval-overflow.rs index f647c43e137..19b5f9b094c 100644 --- a/src/test/compile-fail/const-eval-overflow.rs +++ b/src/test/compile-fail/const-eval-overflow.rs @@ -8,7 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(negate_unsigned)] + #![allow(unused_imports)] +#![feature(negate_unsigned)] // Note: the relevant lint pass here runs before some of the constant // evaluation below (e.g. that performed by trans and llvm), so if you diff --git a/src/test/compile-fail/dst-index.rs b/src/test/compile-fail/dst-index.rs index 021ef7343cb..c52458934bd 100644 --- a/src/test/compile-fail/dst-index.rs +++ b/src/test/compile-fail/dst-index.rs @@ -14,7 +14,7 @@ use std::ops::Index; use std::fmt::Debug; -#[derive(Copy)] +#[derive(Copy, Clone)] struct S; impl Index<usize> for S { @@ -25,7 +25,7 @@ impl Index<usize> for S { } } -#[derive(Copy)] +#[derive(Copy, Clone)] struct T; impl Index<usize> for T { diff --git a/src/test/compile-fail/enum-discrim-too-small.rs b/src/test/compile-fail/enum-discrim-too-small.rs index 1d7794336a0..cdf7d026d5e 100644 --- a/src/test/compile-fail/enum-discrim-too-small.rs +++ b/src/test/compile-fail/enum-discrim-too-small.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(negate_unsigned)] + #[repr(u8)] //~ NOTE discriminant type specified here enum Eu8 { Au8 = 23, diff --git a/src/test/compile-fail/exclusive-drop-and-copy.rs b/src/test/compile-fail/exclusive-drop-and-copy.rs index f47f14d5879..460c396750f 100644 --- a/src/test/compile-fail/exclusive-drop-and-copy.rs +++ b/src/test/compile-fail/exclusive-drop-and-copy.rs @@ -12,14 +12,14 @@ // issue #20126 -#[derive(Copy)] //~ ERROR the trait `Copy` may not be implemented +#[derive(Copy, Clone)] //~ ERROR the trait `Copy` may not be implemented struct Foo; impl Drop for Foo { fn drop(&mut self) {} } -#[derive(Copy)] //~ ERROR the trait `Copy` may not be implemented +#[derive(Copy, Clone)] //~ ERROR the trait `Copy` may not be implemented struct Bar<T>(::std::marker::PhantomData<T>); #[unsafe_destructor] diff --git a/src/test/compile-fail/feature-gate-simd-ffi.rs b/src/test/compile-fail/feature-gate-simd-ffi.rs index 9ee3fcee023..dcd7a0ded81 100644 --- a/src/test/compile-fail/feature-gate-simd-ffi.rs +++ b/src/test/compile-fail/feature-gate-simd-ffi.rs @@ -13,7 +13,7 @@ use std::simd::f32x4; -#[simd] #[derive(Copy)] #[repr(C)] struct LocalSimd(u8, u8); +#[simd] #[derive(Copy, Clone)] #[repr(C)] struct LocalSimd(u8, u8); extern { fn foo() -> f32x4; //~ ERROR use of SIMD type diff --git a/src/test/compile-fail/gated-simd-ffi.rs b/src/test/compile-fail/gated-simd-ffi.rs index c0a251e77a3..883e1be04b2 100644 --- a/src/test/compile-fail/gated-simd-ffi.rs +++ b/src/test/compile-fail/gated-simd-ffi.rs @@ -13,7 +13,7 @@ #![feature(simd)] #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] #[simd] pub struct f32x4(f32, f32, f32, f32); diff --git a/src/test/compile-fail/kindck-copy.rs b/src/test/compile-fail/kindck-copy.rs index d5bfe3d1692..1925caf6870 100644 --- a/src/test/compile-fail/kindck-copy.rs +++ b/src/test/compile-fail/kindck-copy.rs @@ -17,7 +17,7 @@ fn assert_copy<T:Copy>() { } trait Dummy : MarkerTrait { } -#[derive(Copy)] +#[derive(Copy, Clone)] struct MyStruct { x: isize, y: isize, diff --git a/src/test/compile-fail/kindck-inherited-copy-bound.rs b/src/test/compile-fail/kindck-inherited-copy-bound.rs index 52ca24d0f54..066590252a5 100644 --- a/src/test/compile-fail/kindck-inherited-copy-bound.rs +++ b/src/test/compile-fail/kindck-inherited-copy-bound.rs @@ -25,13 +25,13 @@ fn take_param<T:Foo>(foo: &T) { } fn a() { let x: Box<_> = box 3; - take_param(&x); //~ ERROR `core::marker::Copy` is not implemented + take_param(&x); //~ ERROR E0277 } fn b() { let x: Box<_> = box 3; let y = &x; - let z = &x as &Foo; //~ ERROR `core::marker::Copy` is not implemented + let z = &x as &Foo; //~ ERROR E0038 } fn main() { } diff --git a/src/test/compile-fail/lint-exceeding-bitshifts.rs b/src/test/compile-fail/lint-exceeding-bitshifts.rs index 171dedd5b2e..1f70828e411 100644 --- a/src/test/compile-fail/lint-exceeding-bitshifts.rs +++ b/src/test/compile-fail/lint-exceeding-bitshifts.rs @@ -8,10 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(negate_unsigned)] #![deny(exceeding_bitshifts)] #![allow(unused_variables)] #![allow(dead_code)] -#![feature(core)] +#![feature(core, negate_unsigned)] fn main() { let n = 1u8 << 7; diff --git a/src/test/compile-fail/lint-type-limits.rs b/src/test/compile-fail/lint-type-limits.rs index f36c726c875..798dc112b0a 100644 --- a/src/test/compile-fail/lint-type-limits.rs +++ b/src/test/compile-fail/lint-type-limits.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(negate_unsigned)] #![allow(dead_code)] +#![feature(negate_unsigned)] // compile-flags: -D unused-comparisons fn main() { } diff --git a/src/test/compile-fail/opt-in-copy.rs b/src/test/compile-fail/opt-in-copy.rs index bc18b52a0c1..be321b62903 100644 --- a/src/test/compile-fail/opt-in-copy.rs +++ b/src/test/compile-fail/opt-in-copy.rs @@ -16,6 +16,7 @@ struct IWantToCopyThis { impl Copy for IWantToCopyThis {} //~^ ERROR the trait `Copy` may not be implemented for this type +//~| ERROR E0277 enum CantCopyThisEither { A, @@ -28,5 +29,6 @@ enum IWantToCopyThisToo { impl Copy for IWantToCopyThisToo {} //~^ ERROR the trait `Copy` may not be implemented for this type +//~| ERROR E0277 fn main() {} diff --git a/src/test/compile-fail/pub-method-macro.rs b/src/test/compile-fail/pub-method-macro.rs index aa890550f1c..198fa5b9aca 100644 --- a/src/test/compile-fail/pub-method-macro.rs +++ b/src/test/compile-fail/pub-method-macro.rs @@ -20,7 +20,7 @@ mod bleh { ) } - #[derive(Copy)] + #[derive(Copy, Clone)] pub struct S; impl S { diff --git a/src/test/compile-fail/unsendable-class.rs b/src/test/compile-fail/unsendable-class.rs deleted file mode 100644 index f51eee37934..00000000000 --- a/src/test/compile-fail/unsendable-class.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2012 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. - -use std::sync::mpsc::channel; - -// Test that a class with an unsendable field can't be -// sent - -use std::rc::Rc; - -struct foo { - i: isize, - j: Rc<String>, -} - -fn foo(i:isize, j: Rc<String>) -> foo { - foo { - i: i, - j: j - } -} - -fn main() { - let cat = "kitty".to_string(); - let (tx, _) = channel(); - //~^ ERROR `core::marker::Send` is not implemented - tx.send(foo(42, Rc::new(cat))); -} diff --git a/src/test/debuginfo/c-style-enum.rs b/src/test/debuginfo/c-style-enum.rs index 7a285d90b9d..3024ca0fe69 100644 --- a/src/test/debuginfo/c-style-enum.rs +++ b/src/test/debuginfo/c-style-enum.rs @@ -105,21 +105,21 @@ use self::AutoDiscriminant::{One, Two, Three}; use self::ManualDiscriminant::{OneHundred, OneThousand, OneMillion}; use self::SingleVariant::TheOnlyVariant; -#[derive(Copy)] +#[derive(Copy, Clone)] enum AutoDiscriminant { One, Two, Three } -#[derive(Copy)] +#[derive(Copy, Clone)] enum ManualDiscriminant { OneHundred = 100, OneThousand = 1000, OneMillion = 1000000 } -#[derive(Copy)] +#[derive(Copy, Clone)] enum SingleVariant { TheOnlyVariant } diff --git a/src/test/debuginfo/generic-method-on-generic-struct.rs b/src/test/debuginfo/generic-method-on-generic-struct.rs index 06053965ca7..fc9ef8e3a98 100644 --- a/src/test/debuginfo/generic-method-on-generic-struct.rs +++ b/src/test/debuginfo/generic-method-on-generic-struct.rs @@ -114,7 +114,7 @@ #![feature(box_syntax)] #![omit_gdb_pretty_printer_section] -#[derive(Copy)] +#[derive(Copy, Clone)] struct Struct<T> { x: T } diff --git a/src/test/debuginfo/method-on-enum.rs b/src/test/debuginfo/method-on-enum.rs index 314ec472b69..6468a36f8c6 100644 --- a/src/test/debuginfo/method-on-enum.rs +++ b/src/test/debuginfo/method-on-enum.rs @@ -115,7 +115,7 @@ #![feature(box_syntax)] #![omit_gdb_pretty_printer_section] -#[derive(Copy)] +#[derive(Copy, Clone)] enum Enum { Variant1 { x: u16, y: u16 }, Variant2 (u32) diff --git a/src/test/debuginfo/method-on-generic-struct.rs b/src/test/debuginfo/method-on-generic-struct.rs index 564c2d26493..975668baa12 100644 --- a/src/test/debuginfo/method-on-generic-struct.rs +++ b/src/test/debuginfo/method-on-generic-struct.rs @@ -115,7 +115,7 @@ #![feature(box_syntax)] #![omit_gdb_pretty_printer_section] -#[derive(Copy)] +#[derive(Copy, Clone)] struct Struct<T> { x: T } diff --git a/src/test/debuginfo/method-on-struct.rs b/src/test/debuginfo/method-on-struct.rs index eba4370e698..28885d0ad9b 100644 --- a/src/test/debuginfo/method-on-struct.rs +++ b/src/test/debuginfo/method-on-struct.rs @@ -115,7 +115,7 @@ #![feature(box_syntax)] #![omit_gdb_pretty_printer_section] -#[derive(Copy)] +#[derive(Copy, Clone)] struct Struct { x: isize } diff --git a/src/test/debuginfo/method-on-trait.rs b/src/test/debuginfo/method-on-trait.rs index 6df7cdfd47f..b69a3856736 100644 --- a/src/test/debuginfo/method-on-trait.rs +++ b/src/test/debuginfo/method-on-trait.rs @@ -115,7 +115,7 @@ #![feature(box_syntax)] #![omit_gdb_pretty_printer_section] -#[derive(Copy)] +#[derive(Copy, Clone)] struct Struct { x: isize } diff --git a/src/test/debuginfo/method-on-tuple-struct.rs b/src/test/debuginfo/method-on-tuple-struct.rs index b638e210dd3..97d4496cce1 100644 --- a/src/test/debuginfo/method-on-tuple-struct.rs +++ b/src/test/debuginfo/method-on-tuple-struct.rs @@ -115,7 +115,7 @@ #![feature(box_syntax)] #![omit_gdb_pretty_printer_section] -#[derive(Copy)] +#[derive(Copy, Clone)] struct TupleStruct(isize, f64); impl TupleStruct { diff --git a/src/test/debuginfo/self-in-default-method.rs b/src/test/debuginfo/self-in-default-method.rs index f61b78d5449..f16f236a0cb 100644 --- a/src/test/debuginfo/self-in-default-method.rs +++ b/src/test/debuginfo/self-in-default-method.rs @@ -114,7 +114,7 @@ #![feature(box_syntax)] #![omit_gdb_pretty_printer_section] -#[derive(Copy)] +#[derive(Copy, Clone)] struct Struct { x: isize } diff --git a/src/test/debuginfo/self-in-generic-default-method.rs b/src/test/debuginfo/self-in-generic-default-method.rs index 4ac436c9325..56de877016d 100644 --- a/src/test/debuginfo/self-in-generic-default-method.rs +++ b/src/test/debuginfo/self-in-generic-default-method.rs @@ -114,7 +114,7 @@ #![feature(box_syntax)] #![omit_gdb_pretty_printer_section] -#[derive(Copy)] +#[derive(Copy, Clone)] struct Struct { x: isize } diff --git a/src/test/pretty/block-disambig.rs b/src/test/pretty/block-disambig.rs index 6e75e085138..3d5e6e78dea 100644 --- a/src/test/pretty/block-disambig.rs +++ b/src/test/pretty/block-disambig.rs @@ -19,7 +19,7 @@ fn test1() { let val = &0; { } *val; } fn test2() -> isize { let val = &0; { } *val } -#[derive(Copy)] +#[derive(Copy, Clone)] struct S { eax: isize } fn test3() { diff --git a/src/test/run-make/allow-non-lint-warnings-cmdline/foo.rs b/src/test/run-make/allow-non-lint-warnings-cmdline/foo.rs index 19ce5d0a7ca..a9e18f5a8f1 100644 --- a/src/test/run-make/allow-non-lint-warnings-cmdline/foo.rs +++ b/src/test/run-make/allow-non-lint-warnings-cmdline/foo.rs @@ -9,7 +9,7 @@ // except according to those terms. #[derive()] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Foo; pub fn main() { } diff --git a/src/test/run-make/extern-fn-with-packed-struct/test.rs b/src/test/run-make/extern-fn-with-packed-struct/test.rs index 838ef338846..c0f55893a3a 100644 --- a/src/test/run-make/extern-fn-with-packed-struct/test.rs +++ b/src/test/run-make/extern-fn-with-packed-struct/test.rs @@ -9,7 +9,7 @@ // except according to those terms. #[repr(packed)] -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] struct Foo { a: i8, b: i16, diff --git a/src/test/run-make/save-analysis/foo.rs b/src/test/run-make/save-analysis/foo.rs index 5310ed25d3b..9d1ab00359d 100644 --- a/src/test/run-make/save-analysis/foo.rs +++ b/src/test/run-make/save-analysis/foo.rs @@ -179,7 +179,7 @@ enum SomeEnum<'a> { MyTypes(MyType, MyType) } -#[derive(Copy)] +#[derive(Copy, Clone)] enum SomeOtherEnum { SomeConst1, SomeConst2, diff --git a/src/test/run-pass/associated-types-normalize-unifield-struct.rs b/src/test/run-pass/associated-types-normalize-unifield-struct.rs index 82adac8cf86..3dffae99292 100644 --- a/src/test/run-pass/associated-types-normalize-unifield-struct.rs +++ b/src/test/run-pass/associated-types-normalize-unifield-struct.rs @@ -20,10 +20,10 @@ pub trait Offset { fn dummy(&self) { } } -#[derive(Copy)] pub struct X; +#[derive(Copy, Clone)] pub struct X; impl Offset for X { type State = Y; } -#[derive(Copy)] pub struct Y; +#[derive(Copy, Clone)] pub struct Y; impl OffsetState for Y {} pub fn now() -> DateTime<X> { from_utc(Y) } diff --git a/src/test/run-pass/big-literals.rs b/src/test/run-pass/big-literals.rs index b73eac0c714..ab9d892ce2b 100644 --- a/src/test/run-pass/big-literals.rs +++ b/src/test/run-pass/big-literals.rs @@ -16,10 +16,10 @@ #![deny(overflowing_literals)] pub fn main() { - assert_eq!(0xffffffff, (-1 as u32)); - assert_eq!(4294967295, (-1 as u32)); - assert_eq!(0xffffffffffffffff, (-1 as u64)); - assert_eq!(18446744073709551615, (-1 as u64)); + assert_eq!(0xffffffff, (!0 as u32)); + assert_eq!(4294967295, (!0 as u32)); + assert_eq!(0xffffffffffffffff, (!0 as u64)); + assert_eq!(18446744073709551615, (!0 as u64)); assert_eq!((-2147483648i32).wrapping_sub(1), 2147483647); } diff --git a/src/test/run-pass/binops-issue-22743.rs b/src/test/run-pass/binops-issue-22743.rs index 01c85023eda..da7a3ae684c 100644 --- a/src/test/run-pass/binops-issue-22743.rs +++ b/src/test/run-pass/binops-issue-22743.rs @@ -10,7 +10,7 @@ use std::ops::Mul; -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Foo { x: f64, } diff --git a/src/test/run-pass/bitwise.rs b/src/test/run-pass/bitwise.rs index d6117a04e35..a9f19c12b02 100644 --- a/src/test/run-pass/bitwise.rs +++ b/src/test/run-pass/bitwise.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(negate_unsigned)] #[cfg(any(target_arch = "x86", target_arch = "arm"))] fn target() { diff --git a/src/test/run-pass/borrowck-univariant-enum.rs b/src/test/run-pass/borrowck-univariant-enum.rs index 84efe190367..a5c68c5ecf9 100644 --- a/src/test/run-pass/borrowck-univariant-enum.rs +++ b/src/test/run-pass/borrowck-univariant-enum.rs @@ -13,7 +13,7 @@ use std::cell::Cell; -#[derive(Copy)] +#[derive(Copy, Clone)] enum newtype { newvar(isize) } diff --git a/src/test/run-pass/builtin-superkinds-in-metadata.rs b/src/test/run-pass/builtin-superkinds-in-metadata.rs index 717348652ed..c026ffc6d31 100644 --- a/src/test/run-pass/builtin-superkinds-in-metadata.rs +++ b/src/test/run-pass/builtin-superkinds-in-metadata.rs @@ -20,7 +20,7 @@ use trait_superkinds_in_metadata::{RequiresRequiresShareAndSend, RequiresShare}; use trait_superkinds_in_metadata::RequiresCopy; use std::marker; -#[derive(Copy)] +#[derive(Copy, Clone)] struct X<T>(T); impl<T:Sync> RequiresShare for X<T> { } diff --git a/src/test/run-pass/class-impl-very-parameterized-trait.rs b/src/test/run-pass/class-impl-very-parameterized-trait.rs index 57c1fd80bd5..4c494293b51 100644 --- a/src/test/run-pass/class-impl-very-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-very-parameterized-trait.rs @@ -11,7 +11,7 @@ use std::cmp; -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] enum cat_type { tuxedo, tabby, tortoiseshell } impl cmp::PartialEq for cat_type { diff --git a/src/test/run-pass/coherence-impl-in-fn.rs b/src/test/run-pass/coherence-impl-in-fn.rs index 134549d747a..b0630b51640 100644 --- a/src/test/run-pass/coherence-impl-in-fn.rs +++ b/src/test/run-pass/coherence-impl-in-fn.rs @@ -11,7 +11,7 @@ // pretty-expanded FIXME #23616 pub fn main() { - #[derive(Copy)] + #[derive(Copy, Clone)] enum x { foo } impl ::std::cmp::PartialEq for x { fn eq(&self, other: &x) -> bool { diff --git a/src/test/run-pass/const-nullary-univariant-enum.rs b/src/test/run-pass/const-nullary-univariant-enum.rs index d0e9e5d6106..51926ececc2 100644 --- a/src/test/run-pass/const-nullary-univariant-enum.rs +++ b/src/test/run-pass/const-nullary-univariant-enum.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#[derive(Copy)] +#[derive(Copy, Clone)] enum Foo { Bar = 0xDEADBEE } diff --git a/src/test/run-pass/copy-out-of-array-1.rs b/src/test/run-pass/copy-out-of-array-1.rs index 6dfcc3b2a16..5c5765454d4 100644 --- a/src/test/run-pass/copy-out-of-array-1.rs +++ b/src/test/run-pass/copy-out-of-array-1.rs @@ -14,10 +14,9 @@ // pretty-expanded FIXME #23616 +#[derive(Copy, Clone)] struct C { _x: u8 } -impl Copy for C { } - fn main() { fn d() -> C { C { _x: 0 } } diff --git a/src/test/run-pass/deriving-bounds.rs b/src/test/run-pass/deriving-bounds.rs index e0bbd0b2b04..4204d9b5c3e 100644 --- a/src/test/run-pass/deriving-bounds.rs +++ b/src/test/run-pass/deriving-bounds.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#[derive(Copy)] +#[derive(Copy, Clone)] struct Test; pub fn main() {} diff --git a/src/test/run-pass/dst-struct-sole.rs b/src/test/run-pass/dst-struct-sole.rs index fd19d02e688..9bf286c4342 100644 --- a/src/test/run-pass/dst-struct-sole.rs +++ b/src/test/run-pass/dst-struct-sole.rs @@ -32,7 +32,7 @@ fn foo2<T:ToBar>(x: &Fat<[T]>) { assert!(x.ptr[1].to_bar() == bar); } -#[derive(Copy, PartialEq, Eq)] +#[derive(Copy, Clone, PartialEq, Eq)] struct Bar; trait ToBar { diff --git a/src/test/run-pass/dst-struct.rs b/src/test/run-pass/dst-struct.rs index 055b61b25fb..5198dd43d6d 100644 --- a/src/test/run-pass/dst-struct.rs +++ b/src/test/run-pass/dst-struct.rs @@ -51,7 +51,7 @@ fn foo3(x: &Fat<Fat<[isize]>>) { } -#[derive(Copy, PartialEq, Eq)] +#[derive(Copy, Clone, PartialEq, Eq)] struct Bar; trait ToBar { diff --git a/src/test/run-pass/dst-trait.rs b/src/test/run-pass/dst-trait.rs index ede4b8c442e..370bc288227 100644 --- a/src/test/run-pass/dst-trait.rs +++ b/src/test/run-pass/dst-trait.rs @@ -19,10 +19,10 @@ struct Fat<T: ?Sized> { ptr: T } -#[derive(Copy, PartialEq, Eq)] +#[derive(Copy, Clone, PartialEq, Eq)] struct Bar; -#[derive(Copy, PartialEq, Eq)] +#[derive(Copy, Clone, PartialEq, Eq)] struct Bar1 { f: isize } diff --git a/src/test/run-pass/empty-tag.rs b/src/test/run-pass/empty-tag.rs index ff2a70467ea..e60cd02ce99 100644 --- a/src/test/run-pass/empty-tag.rs +++ b/src/test/run-pass/empty-tag.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] enum chan { chan_t, } impl PartialEq for chan { diff --git a/src/test/run-pass/enum-discrim-width-stuff.rs b/src/test/run-pass/enum-discrim-width-stuff.rs index 0242e53aa8c..46238c45720 100644 --- a/src/test/run-pass/enum-discrim-width-stuff.rs +++ b/src/test/run-pass/enum-discrim-width-stuff.rs @@ -12,7 +12,7 @@ macro_rules! check { ($m:ident, $t:ty, $v:expr) => {{ mod $m { use std::mem::size_of; - #[derive(Copy, Debug)] + #[derive(Copy, Clone, Debug)] enum E { V = $v, A = 0 diff --git a/src/test/run-pass/explicit-self-generic.rs b/src/test/run-pass/explicit-self-generic.rs index 25f09ee94b0..ee50d3bdf0e 100644 --- a/src/test/run-pass/explicit-self-generic.rs +++ b/src/test/run-pass/explicit-self-generic.rs @@ -13,7 +13,7 @@ #![allow(unknown_features)] #![feature(box_syntax)] -#[derive(Copy)] +#[derive(Copy, Clone)] struct LM { resize_at: usize, size: usize } enum HashMap<K,V> { diff --git a/src/test/run-pass/expr-copy.rs b/src/test/run-pass/expr-copy.rs index 80729fb2164..ca394f991f2 100644 --- a/src/test/run-pass/expr-copy.rs +++ b/src/test/run-pass/expr-copy.rs @@ -15,7 +15,7 @@ fn f(arg: &mut A) { arg.a = 100; } -#[derive(Copy)] +#[derive(Copy, Clone)] struct A { a: isize } pub fn main() { diff --git a/src/test/run-pass/expr-if-struct.rs b/src/test/run-pass/expr-if-struct.rs index ad397830638..e79daed4c33 100644 --- a/src/test/run-pass/expr-if-struct.rs +++ b/src/test/run-pass/expr-if-struct.rs @@ -14,7 +14,7 @@ // Tests for if as expressions returning nominal types -#[derive(Copy)] +#[derive(Copy, Clone)] struct I { i: isize } fn test_rec() { @@ -22,7 +22,7 @@ fn test_rec() { assert_eq!(rs.i, 100); } -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] enum mood { happy, sad, } impl PartialEq for mood { diff --git a/src/test/run-pass/expr-match-struct.rs b/src/test/run-pass/expr-match-struct.rs index 91ad142c386..2dcb0f833e4 100644 --- a/src/test/run-pass/expr-match-struct.rs +++ b/src/test/run-pass/expr-match-struct.rs @@ -13,7 +13,7 @@ // Tests for match as expressions resulting in struct types -#[derive(Copy)] +#[derive(Copy, Clone)] struct R { i: isize } fn test_rec() { @@ -21,7 +21,7 @@ fn test_rec() { assert_eq!(rs.i, 100); } -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] enum mood { happy, sad, } impl PartialEq for mood { diff --git a/src/test/run-pass/exterior.rs b/src/test/run-pass/exterior.rs index 25a990383e4..9a039e8bc35 100644 --- a/src/test/run-pass/exterior.rs +++ b/src/test/run-pass/exterior.rs @@ -13,7 +13,7 @@ use std::cell::Cell; -#[derive(Copy)] +#[derive(Copy, Clone)] struct Point {x: isize, y: isize, z: isize} fn f(p: &Cell<Point>) { diff --git a/src/test/run-pass/extern-pass-TwoU16s.rs b/src/test/run-pass/extern-pass-TwoU16s.rs index 1f48dc3bcf1..9d304ea9e10 100644 --- a/src/test/run-pass/extern-pass-TwoU16s.rs +++ b/src/test/run-pass/extern-pass-TwoU16s.rs @@ -11,7 +11,7 @@ // Test a foreign function that accepts and returns a struct // by value. -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub struct TwoU16s { one: u16, two: u16 } diff --git a/src/test/run-pass/extern-pass-TwoU32s.rs b/src/test/run-pass/extern-pass-TwoU32s.rs index 171e2a647cc..8dae0473fd5 100644 --- a/src/test/run-pass/extern-pass-TwoU32s.rs +++ b/src/test/run-pass/extern-pass-TwoU32s.rs @@ -11,7 +11,7 @@ // Test a foreign function that accepts and returns a struct // by value. -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub struct TwoU32s { one: u32, two: u32 } diff --git a/src/test/run-pass/extern-pass-TwoU64s.rs b/src/test/run-pass/extern-pass-TwoU64s.rs index 83555f6bb1d..14aeea34657 100644 --- a/src/test/run-pass/extern-pass-TwoU64s.rs +++ b/src/test/run-pass/extern-pass-TwoU64s.rs @@ -11,7 +11,7 @@ // Test a foreign function that accepts and returns a struct // by value. -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub struct TwoU64s { one: u64, two: u64 } diff --git a/src/test/run-pass/extern-pass-TwoU8s.rs b/src/test/run-pass/extern-pass-TwoU8s.rs index d2b13445e6a..75a109e4429 100644 --- a/src/test/run-pass/extern-pass-TwoU8s.rs +++ b/src/test/run-pass/extern-pass-TwoU8s.rs @@ -11,7 +11,7 @@ // Test a foreign function that accepts and returns a struct // by value. -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub struct TwoU8s { one: u8, two: u8 } diff --git a/src/test/run-pass/foreign-fn-with-byval.rs b/src/test/run-pass/foreign-fn-with-byval.rs index 4c0633d49c6..7883c22f909 100644 --- a/src/test/run-pass/foreign-fn-with-byval.rs +++ b/src/test/run-pass/foreign-fn-with-byval.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct S { x: u64, y: u64, diff --git a/src/test/run-pass/generic-fn.rs b/src/test/run-pass/generic-fn.rs index 82b03abf057..0ba0ed4bf7f 100644 --- a/src/test/run-pass/generic-fn.rs +++ b/src/test/run-pass/generic-fn.rs @@ -12,7 +12,7 @@ fn id<T>(x: T) -> T { return x; } -#[derive(Copy)] +#[derive(Copy, Clone)] struct Triple {x: isize, y: isize, z: isize} pub fn main() { diff --git a/src/test/run-pass/guards-not-exhaustive.rs b/src/test/run-pass/guards-not-exhaustive.rs index 59ec14e097e..f5f80914937 100644 --- a/src/test/run-pass/guards-not-exhaustive.rs +++ b/src/test/run-pass/guards-not-exhaustive.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#[derive(Copy)] +#[derive(Copy, Clone)] enum Q { R(Option<usize>) } fn xyzzy(q: Q) -> usize { diff --git a/src/test/run-pass/guards.rs b/src/test/run-pass/guards.rs index 598172ac18e..11c67b8af81 100644 --- a/src/test/run-pass/guards.rs +++ b/src/test/run-pass/guards.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#[derive(Copy)] +#[derive(Copy, Clone)] struct Pair { x: isize, y: isize } pub fn main() { diff --git a/src/test/run-pass/hrtb-opt-in-copy.rs b/src/test/run-pass/hrtb-opt-in-copy.rs index 8ececb3875a..b40f4d27a9c 100644 --- a/src/test/run-pass/hrtb-opt-in-copy.rs +++ b/src/test/run-pass/hrtb-opt-in-copy.rs @@ -22,7 +22,7 @@ use std::marker::PhantomData; -#[derive(Copy)] +#[derive(Copy, Clone)] struct Foo<T> { x: T } type Ty<'tcx> = &'tcx TyS<'tcx>; @@ -31,7 +31,7 @@ enum TyS<'tcx> { Boop(PhantomData<*mut &'tcx ()>) } -#[derive(Copy)] +#[derive(Copy, Clone)] enum Bar<'tcx> { Baz(Foo<Ty<'tcx>>) } diff --git a/src/test/run-pass/intrinsics-integer.rs b/src/test/run-pass/intrinsics-integer.rs index a4661410ad6..15dbe796ef5 100644 --- a/src/test/run-pass/intrinsics-integer.rs +++ b/src/test/run-pass/intrinsics-integer.rs @@ -10,6 +10,7 @@ // pretty-expanded FIXME #23616 +#![feature(negate_unsigned)] #![feature(intrinsics)] mod rusti { diff --git a/src/test/run-pass/issue-12860.rs b/src/test/run-pass/issue-12860.rs index ad03c7fddb4..dddfb9bacf9 100644 --- a/src/test/run-pass/issue-12860.rs +++ b/src/test/run-pass/issue-12860.rs @@ -16,7 +16,7 @@ extern crate collections; use std::collections::HashSet; -#[derive(Copy, PartialEq, Eq, Hash)] +#[derive(Copy, Clone, PartialEq, Eq, Hash)] struct XYZ { x: isize, y: isize, diff --git a/src/test/run-pass/issue-13264.rs b/src/test/run-pass/issue-13264.rs index e82a7602ef5..7acabf31c85 100644 --- a/src/test/run-pass/issue-13264.rs +++ b/src/test/run-pass/issue-13264.rs @@ -24,7 +24,7 @@ impl Deref for Root { } } -#[derive(Copy)] +#[derive(Copy, Clone)] struct JSRef { node: *const Node } diff --git a/src/test/run-pass/issue-17074.rs b/src/test/run-pass/issue-17074.rs index 31f6a4209de..08c313ab0a4 100644 --- a/src/test/run-pass/issue-17074.rs +++ b/src/test/run-pass/issue-17074.rs @@ -10,10 +10,10 @@ // pretty-expanded FIXME #23616 -static X2: u64 = -1 as u16 as u64; -static Y2: u64 = -1 as u32 as u64; -const X: u64 = -1 as u16 as u64; -const Y: u64 = -1 as u32 as u64; +static X2: u64 = !0 as u16 as u64; +static Y2: u64 = !0 as u32 as u64; +const X: u64 = !0 as u16 as u64; +const Y: u64 = !0 as u32 as u64; fn main() { assert_eq!(match 1 { diff --git a/src/test/run-pass/issue-19100.rs b/src/test/run-pass/issue-19100.rs index 26eacd682ef..0fd4b4394dc 100644 --- a/src/test/run-pass/issue-19100.rs +++ b/src/test/run-pass/issue-19100.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[derive(Copy)] +#[derive(Copy, Clone)] enum Foo { Bar, Baz diff --git a/src/test/run-pass/issue-20797.rs b/src/test/run-pass/issue-20797.rs index 45d31d4a7f1..8b5e6f837d8 100644 --- a/src/test/run-pass/issue-20797.rs +++ b/src/test/run-pass/issue-20797.rs @@ -34,7 +34,7 @@ pub trait Strategy { } /// The basic fully-recursive strategy. Nothing is pruned. -#[derive(Copy, Default)] +#[derive(Copy, Clone, Default)] pub struct Recursive; impl Strategy for Recursive { diff --git a/src/test/run-pass/issue-21296.rs b/src/test/run-pass/issue-21296.rs index 2ce36b0dd44..5e2ac61caa2 100644 --- a/src/test/run-pass/issue-21296.rs +++ b/src/test/run-pass/issue-21296.rs @@ -14,4 +14,8 @@ #[derive(Copy)] struct Test(*const i32); +impl Clone for Test { + fn clone(&self) -> Test { *self } +} + fn main() {} diff --git a/src/test/run-pass/issue-22536-copy-mustnt-zero.rs b/src/test/run-pass/issue-22536-copy-mustnt-zero.rs index 8b2e1c3e149..8a0f04a2cf0 100644 --- a/src/test/run-pass/issue-22536-copy-mustnt-zero.rs +++ b/src/test/run-pass/issue-22536-copy-mustnt-zero.rs @@ -22,12 +22,14 @@ struct BufferHandle<R: Resources> { raw: <R as Resources>::Buffer, } impl<R: Resources> Copy for BufferHandle<R> {} +impl<R: Resources> Clone for BufferHandle<R> { + fn clone(&self) -> BufferHandle<R> { *self } +} enum Res {} impl Resources for Res { type Buffer = u32; } -impl Copy for Res { } fn main() { let b: BufferHandle<Res> = BufferHandle { raw: 1 }; diff --git a/src/test/run-pass/issue-2288.rs b/src/test/run-pass/issue-2288.rs index 3364fae0d6f..d16655a6855 100644 --- a/src/test/run-pass/issue-2288.rs +++ b/src/test/run-pass/issue-2288.rs @@ -17,7 +17,7 @@ trait clam<A> { fn chowder(&self, y: A); } -#[derive(Copy)] +#[derive(Copy, Clone)] struct foo<A> { x: A, } diff --git a/src/test/run-pass/issue-23550.rs b/src/test/run-pass/issue-23550.rs index 97357c1dba4..9b5ca23565e 100644 --- a/src/test/run-pass/issue-23550.rs +++ b/src/test/run-pass/issue-23550.rs @@ -13,7 +13,7 @@ use std::intrinsics; -#[derive(Copy)] +#[derive(Copy, Clone)] struct Wrap(i64); // These volatile and atomic intrinsics used to cause an ICE diff --git a/src/test/run-pass/issue-2633.rs b/src/test/run-pass/issue-2633.rs index de99141c803..5841a9ec176 100644 --- a/src/test/run-pass/issue-2633.rs +++ b/src/test/run-pass/issue-2633.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[derive(Copy)] +#[derive(Copy, Clone)] struct cat { meow: extern "Rust" fn(), } @@ -23,7 +23,7 @@ fn cat() -> cat { } } -#[derive(Copy)] +#[derive(Copy, Clone)] struct KittyInfo {kitty: cat} // Code compiles and runs successfully if we add a + before the first arg diff --git a/src/test/run-pass/issue-3121.rs b/src/test/run-pass/issue-3121.rs index 5a1fedbdccc..777e5bf7a6d 100644 --- a/src/test/run-pass/issue-3121.rs +++ b/src/test/run-pass/issue-3121.rs @@ -13,11 +13,11 @@ #![allow(unknown_features)] #![feature(box_syntax)] -#[derive(Copy)] +#[derive(Copy, Clone)] enum side { mayo, catsup, vinegar } -#[derive(Copy)] +#[derive(Copy, Clone)] enum order { hamburger, fries(side), shake } -#[derive(Copy)] +#[derive(Copy, Clone)] enum meal { to_go(order), for_here(order) } fn foo(m: Box<meal>, cond: bool) { diff --git a/src/test/run-pass/issue-3563-3.rs b/src/test/run-pass/issue-3563-3.rs index 07837625117..cfdc54a3622 100644 --- a/src/test/run-pass/issue-3563-3.rs +++ b/src/test/run-pass/issue-3563-3.rs @@ -29,7 +29,7 @@ use std::iter::repeat; use std::slice; // Represents a position on a canvas. -#[derive(Copy)] +#[derive(Copy, Clone)] struct Point { x: isize, y: isize, @@ -37,13 +37,13 @@ struct Point { // Represents an offset on a canvas. (This has the same structure as a Point. // but different semantics). -#[derive(Copy)] +#[derive(Copy, Clone)] struct Size { width: isize, height: isize, } -#[derive(Copy)] +#[derive(Copy, Clone)] struct Rect { top_left: Point, size: Size, diff --git a/src/test/run-pass/issue-3743.rs b/src/test/run-pass/issue-3743.rs index 7f66b6b25b8..cd62c04a325 100644 --- a/src/test/run-pass/issue-3743.rs +++ b/src/test/run-pass/issue-3743.rs @@ -13,7 +13,7 @@ use std::ops::Mul; -#[derive(Copy)] +#[derive(Copy, Clone)] struct Vec2 { x: f64, y: f64 diff --git a/src/test/run-pass/issue-3753.rs b/src/test/run-pass/issue-3753.rs index bbfeb94cd9d..e81025d8464 100644 --- a/src/test/run-pass/issue-3753.rs +++ b/src/test/run-pass/issue-3753.rs @@ -16,13 +16,13 @@ use std::f64; -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Point { x: f64, y: f64 } -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum Shape { Circle(Point, f64), Rectangle(Point, Point) diff --git a/src/test/run-pass/issue-5688.rs b/src/test/run-pass/issue-5688.rs index 3c25c6dc8ed..88ff103723c 100644 --- a/src/test/run-pass/issue-5688.rs +++ b/src/test/run-pass/issue-5688.rs @@ -17,7 +17,7 @@ with the representation of [isize; n] and [isize] somehow, or at least failed to typecheck correctly. */ -#[derive(Copy)] +#[derive(Copy, Clone)] struct X { vec: &'static [isize] } static V: &'static [X] = &[X { vec: &[1, 2, 3] }]; diff --git a/src/test/run-pass/match-arm-statics.rs b/src/test/run-pass/match-arm-statics.rs index e21f89aee43..1b4dfb869d4 100644 --- a/src/test/run-pass/match-arm-statics.rs +++ b/src/test/run-pass/match-arm-statics.rs @@ -38,7 +38,7 @@ const VARIANT2_NORTH: EnumWithStructVariants = EnumWithStructVariants::Variant2 dir: Direction::North }; pub mod glfw { - #[derive(Copy)] + #[derive(Copy, Clone)] pub struct InputState(usize); pub const RELEASE : InputState = InputState(0); diff --git a/src/test/run-pass/method-self-arg-trait.rs b/src/test/run-pass/method-self-arg-trait.rs index 8687014bfbb..f0ca0a70acc 100644 --- a/src/test/run-pass/method-self-arg-trait.rs +++ b/src/test/run-pass/method-self-arg-trait.rs @@ -17,7 +17,7 @@ static mut COUNT: u64 = 1; -#[derive(Copy)] +#[derive(Copy, Clone)] struct Foo; trait Bar : Sized { diff --git a/src/test/run-pass/method-self-arg.rs b/src/test/run-pass/method-self-arg.rs index 98ab67b05af..dfc12119222 100644 --- a/src/test/run-pass/method-self-arg.rs +++ b/src/test/run-pass/method-self-arg.rs @@ -17,7 +17,7 @@ static mut COUNT: usize = 1; -#[derive(Copy)] +#[derive(Copy, Clone)] struct Foo; impl Foo { diff --git a/src/test/run-pass/monomorphize-abi-alignment.rs b/src/test/run-pass/monomorphize-abi-alignment.rs index 726f205f5c4..00e97ebc24e 100644 --- a/src/test/run-pass/monomorphize-abi-alignment.rs +++ b/src/test/run-pass/monomorphize-abi-alignment.rs @@ -18,7 +18,7 @@ * and apply the wrong instance of the method `unwrap`. */ -#[derive(Copy)] +#[derive(Copy, Clone)] struct S<T> { i:u8, t:T } impl<T> S<T> { @@ -27,10 +27,10 @@ impl<T> S<T> { } } -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] struct A((u32, u32)); -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] struct B(u64); pub fn main() { diff --git a/src/test/run-pass/multidispatch1.rs b/src/test/run-pass/multidispatch1.rs index 0233a7ff485..fdf9f95b274 100644 --- a/src/test/run-pass/multidispatch1.rs +++ b/src/test/run-pass/multidispatch1.rs @@ -16,7 +16,7 @@ trait MyTrait<T> { fn get(&self) -> T; } -#[derive(Copy)] +#[derive(Copy, Clone)] struct MyType { dummy: usize } diff --git a/src/test/run-pass/multidispatch2.rs b/src/test/run-pass/multidispatch2.rs index 161913f6f5d..75c6c5ac7d1 100644 --- a/src/test/run-pass/multidispatch2.rs +++ b/src/test/run-pass/multidispatch2.rs @@ -25,7 +25,7 @@ impl<T> MyTrait<T> for T } } -#[derive(Copy)] +#[derive(Copy, Clone)] struct MyType { dummy: usize } diff --git a/src/test/run-pass/newtype.rs b/src/test/run-pass/newtype.rs index fb43f041e04..818ea4c9f23 100644 --- a/src/test/run-pass/newtype.rs +++ b/src/test/run-pass/newtype.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[derive(Copy)] +#[derive(Copy, Clone)] struct mytype(Mytype); -#[derive(Copy)] +#[derive(Copy, Clone)] struct Mytype { compute: fn(mytype) -> isize, val: isize, diff --git a/src/test/run-pass/operator-overloading.rs b/src/test/run-pass/operator-overloading.rs index fc089839683..045af79189a 100644 --- a/src/test/run-pass/operator-overloading.rs +++ b/src/test/run-pass/operator-overloading.rs @@ -13,7 +13,7 @@ use std::cmp; use std::ops; -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] struct Point { x: isize, y: isize diff --git a/src/test/run-pass/out-pointer-aliasing.rs b/src/test/run-pass/out-pointer-aliasing.rs index eb0a6c95134..0a58411041e 100644 --- a/src/test/run-pass/out-pointer-aliasing.rs +++ b/src/test/run-pass/out-pointer-aliasing.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Foo { f1: isize, _f2: isize, diff --git a/src/test/run-pass/overloaded-autoderef-order.rs b/src/test/run-pass/overloaded-autoderef-order.rs index fdd7a5000b2..6880032e69f 100644 --- a/src/test/run-pass/overloaded-autoderef-order.rs +++ b/src/test/run-pass/overloaded-autoderef-order.rs @@ -13,7 +13,7 @@ use std::rc::Rc; use std::ops::Deref; -#[derive(Copy)] +#[derive(Copy, Clone)] struct DerefWrapper<X, Y> { x: X, y: Y @@ -36,7 +36,7 @@ impl<X, Y> Deref for DerefWrapper<X, Y> { mod priv_test { use std::ops::Deref; - #[derive(Copy)] + #[derive(Copy, Clone)] pub struct DerefWrapperHideX<X, Y> { x: X, pub y: Y diff --git a/src/test/run-pass/packed-struct-vec.rs b/src/test/run-pass/packed-struct-vec.rs index 92f57f04b10..9a327eb5672 100644 --- a/src/test/run-pass/packed-struct-vec.rs +++ b/src/test/run-pass/packed-struct-vec.rs @@ -13,7 +13,7 @@ use std::mem; #[repr(packed)] -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] struct Foo { bar: u8, baz: u64 diff --git a/src/test/run-pass/rec-tup.rs b/src/test/run-pass/rec-tup.rs index c61c387c781..1644a169426 100644 --- a/src/test/run-pass/rec-tup.rs +++ b/src/test/run-pass/rec-tup.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#[derive(Copy)] +#[derive(Copy, Clone)] struct Point {x: isize, y: isize} type rect = (Point, Point); diff --git a/src/test/run-pass/rec.rs b/src/test/run-pass/rec.rs index 96b6b50237d..a422aaba84b 100644 --- a/src/test/run-pass/rec.rs +++ b/src/test/run-pass/rec.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#[derive(Copy)] +#[derive(Copy, Clone)] struct Rect {x: isize, y: isize, w: isize, h: isize} fn f(r: Rect, x: isize, y: isize, w: isize, h: isize) { diff --git a/src/test/run-pass/regions-dependent-addr-of.rs b/src/test/run-pass/regions-dependent-addr-of.rs index 0cb70735dba..123806a4d9d 100644 --- a/src/test/run-pass/regions-dependent-addr-of.rs +++ b/src/test/run-pass/regions-dependent-addr-of.rs @@ -30,7 +30,7 @@ struct B { v6: Option<C> } -#[derive(Copy)] +#[derive(Copy, Clone)] struct C { f: isize } diff --git a/src/test/run-pass/regions-early-bound-used-in-bound-method.rs b/src/test/run-pass/regions-early-bound-used-in-bound-method.rs index b1f9ff4de0f..6ad89951238 100644 --- a/src/test/run-pass/regions-early-bound-used-in-bound-method.rs +++ b/src/test/run-pass/regions-early-bound-used-in-bound-method.rs @@ -17,7 +17,7 @@ trait GetRef<'a> { fn get(&self) -> &'a isize; } -#[derive(Copy)] +#[derive(Copy, Clone)] struct Box<'a> { t: &'a isize } diff --git a/src/test/run-pass/regions-early-bound-used-in-bound.rs b/src/test/run-pass/regions-early-bound-used-in-bound.rs index 9c2d2726a73..6ab95d6e497 100644 --- a/src/test/run-pass/regions-early-bound-used-in-bound.rs +++ b/src/test/run-pass/regions-early-bound-used-in-bound.rs @@ -17,12 +17,11 @@ trait GetRef<'a, T> { fn get(&self) -> &'a T; } +#[derive(Copy, Clone)] struct Box<'a, T:'a> { t: &'a T } -impl<'a,T:'a> Copy for Box<'a,T> {} - impl<'a,T:Clone> GetRef<'a,T> for Box<'a,T> { fn get(&self) -> &'a T { self.t diff --git a/src/test/run-pass/regions-early-bound-used-in-type-param.rs b/src/test/run-pass/regions-early-bound-used-in-type-param.rs index 830fb7127b9..dc991e9493f 100644 --- a/src/test/run-pass/regions-early-bound-used-in-type-param.rs +++ b/src/test/run-pass/regions-early-bound-used-in-type-param.rs @@ -17,7 +17,7 @@ trait Get<T> { fn get(&self) -> T; } -#[derive(Copy)] +#[derive(Copy, Clone)] struct Box<T> { t: T } diff --git a/src/test/run-pass/regions-mock-tcx.rs b/src/test/run-pass/regions-mock-tcx.rs index c6bacac63e0..ed3cec465ef 100644 --- a/src/test/run-pass/regions-mock-tcx.rs +++ b/src/test/run-pass/regions-mock-tcx.rs @@ -29,7 +29,7 @@ use std::mem; type Type<'tcx> = &'tcx TypeStructure<'tcx>; -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] enum TypeStructure<'tcx> { TypeInt, TypeFunction(Type<'tcx>, Type<'tcx>), @@ -94,20 +94,20 @@ impl<'tcx,'ast> TypeContext<'tcx, 'ast> { } } -#[derive(Copy, PartialEq, Eq, Hash)] +#[derive(Copy, Clone, PartialEq, Eq, Hash)] struct NodeId { id: usize } type Ast<'ast> = &'ast AstStructure<'ast>; -#[derive(Copy)] +#[derive(Copy, Clone)] struct AstStructure<'ast> { id: NodeId, kind: AstKind<'ast> } -#[derive(Copy)] +#[derive(Copy, Clone)] enum AstKind<'ast> { ExprInt, ExprVar(usize), diff --git a/src/test/run-pass/self-in-mut-slot-immediate-value.rs b/src/test/run-pass/self-in-mut-slot-immediate-value.rs index fa7b21a26c5..fa9ad9f6517 100644 --- a/src/test/run-pass/self-in-mut-slot-immediate-value.rs +++ b/src/test/run-pass/self-in-mut-slot-immediate-value.rs @@ -13,7 +13,7 @@ // pretty-expanded FIXME #23616 -#[derive(Copy)] +#[derive(Copy, Clone)] struct Value { n: isize } diff --git a/src/test/run-pass/simd-generics.rs b/src/test/run-pass/simd-generics.rs index 201da8dbc94..867f028a3fb 100644 --- a/src/test/run-pass/simd-generics.rs +++ b/src/test/run-pass/simd-generics.rs @@ -16,7 +16,7 @@ use std::ops; #[simd] -#[derive(Copy)] +#[derive(Copy, Clone)] struct f32x4(f32, f32, f32, f32); fn add<T: ops::Add<Output=T>>(lhs: T, rhs: T) -> T { diff --git a/src/test/run-pass/small-enum-range-edge.rs b/src/test/run-pass/small-enum-range-edge.rs index a87a3072c8a..9515da6fcbc 100644 --- a/src/test/run-pass/small-enum-range-edge.rs +++ b/src/test/run-pass/small-enum-range-edge.rs @@ -18,14 +18,14 @@ */ #[repr(u8)] -#[derive(Copy)] +#[derive(Copy, Clone)] enum Eu { Lu = 0, Hu = 255 } static CLu: Eu = Eu::Lu; static CHu: Eu = Eu::Hu; #[repr(i8)] -#[derive(Copy)] +#[derive(Copy, Clone)] enum Es { Ls = -128, Hs = 127 } static CLs: Es = Es::Ls; diff --git a/src/test/run-pass/struct-return.rs b/src/test/run-pass/struct-return.rs index 9e372913e05..1ff13d4eaea 100644 --- a/src/test/run-pass/struct-return.rs +++ b/src/test/run-pass/struct-return.rs @@ -10,10 +10,10 @@ // // ignore-lexer-test FIXME #15883 -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Quad { a: u64, b: u64, c: u64, d: u64 } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Floats { a: f64, b: u8, c: f64 } mod rustrt { diff --git a/src/test/run-pass/structured-compare.rs b/src/test/run-pass/structured-compare.rs index 4df802849e2..7974366c395 100644 --- a/src/test/run-pass/structured-compare.rs +++ b/src/test/run-pass/structured-compare.rs @@ -10,7 +10,7 @@ -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] enum foo { large, small, } impl PartialEq for foo { diff --git a/src/test/run-pass/sync-send-iterators-in-libcollections.rs b/src/test/run-pass/sync-send-iterators-in-libcollections.rs index 7103fa7c33e..447b4de450b 100644 --- a/src/test/run-pass/sync-send-iterators-in-libcollections.rs +++ b/src/test/run-pass/sync-send-iterators-in-libcollections.rs @@ -77,7 +77,7 @@ fn main() { all_sync_send!(LinkedList::<usize>::new(), iter, iter_mut, into_iter); - #[derive(Copy)] + #[derive(Copy, Clone)] #[repr(usize)] #[allow(dead_code)] enum Foo { A, B, C } diff --git a/src/test/run-pass/tag-variant-disr-val.rs b/src/test/run-pass/tag-variant-disr-val.rs index affabff9164..a063801032e 100644 --- a/src/test/run-pass/tag-variant-disr-val.rs +++ b/src/test/run-pass/tag-variant-disr-val.rs @@ -11,7 +11,7 @@ use color::{red, green, blue, black, white, imaginary, purple, orange}; -#[derive(Copy)] +#[derive(Copy, Clone)] enum color { red = 0xff0000, green = 0x00ff00, diff --git a/src/test/run-pass/trait-coercion-generic.rs b/src/test/run-pass/trait-coercion-generic.rs index 2f33621e36c..f9a22d5ccec 100644 --- a/src/test/run-pass/trait-coercion-generic.rs +++ b/src/test/run-pass/trait-coercion-generic.rs @@ -12,7 +12,7 @@ trait Trait<T> { fn f(&self, x: T); } -#[derive(Copy)] +#[derive(Copy, Clone)] struct Struct { x: isize, y: isize, diff --git a/src/test/run-pass/trait-coercion.rs b/src/test/run-pass/trait-coercion.rs index de0a2e9e4d4..fa31d9891aa 100644 --- a/src/test/run-pass/trait-coercion.rs +++ b/src/test/run-pass/trait-coercion.rs @@ -17,7 +17,7 @@ trait Trait { fn f(&self); } -#[derive(Copy)] +#[derive(Copy, Clone)] struct Struct { x: isize, y: isize, diff --git a/src/test/run-pass/ufcs-explicit-self.rs b/src/test/run-pass/ufcs-explicit-self.rs index 3a1394447f6..bd09a311b70 100644 --- a/src/test/run-pass/ufcs-explicit-self.rs +++ b/src/test/run-pass/ufcs-explicit-self.rs @@ -11,7 +11,7 @@ #![allow(unknown_features)] #![feature(box_syntax)] -#[derive(Copy)] +#[derive(Copy, Clone)] struct Foo { f: isize, } @@ -28,7 +28,7 @@ impl Foo { } } -#[derive(Copy)] +#[derive(Copy, Clone)] struct Bar<T> { f: T, } |
