From 25d070f228a101a806165a434b150a59a54f08ba Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Sun, 8 Mar 2015 22:01:01 +1100 Subject: Remove unneeded `Send`/`Sync` bounds from `Mutex`/`RwLock`. The requirements `T: Send` and `T: Send + Sync` for `Mutex` and `RwLock` respectively only matter if those types are shared/sent across thread boundaries, and that is adequately controlled by the impls of `Send`/`Sync` for them. If `T` doesn't satisfy the bounds, then the types cannot cross thread boundaries and so everything is still safe (the two types just act like an expensive `RefCell`). --- src/libstd/sync/mutex.rs | 8 +++++--- src/libstd/sync/rwlock.rs | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 6f0febd61e8..7b5076acbca 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -121,6 +121,8 @@ pub struct Mutex { data: UnsafeCell, } +// these are the only places where `T: Send` matters; all other +// functionality works fine on a single thread. unsafe impl Send for Mutex { } unsafe impl Sync for Mutex { } @@ -179,7 +181,7 @@ pub const MUTEX_INIT: StaticMutex = StaticMutex { poison: poison::FLAG_INIT, }; -impl Mutex { +impl Mutex { /// Creates a new mutex in an unlocked state ready for use. #[stable(feature = "rust1", since = "1.0.0")] pub fn new(t: T) -> Mutex { @@ -242,7 +244,7 @@ impl Mutex { #[unsafe_destructor] #[stable(feature = "rust1", since = "1.0.0")] -impl Drop for Mutex { +impl Drop for Mutex { 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 @@ -252,7 +254,7 @@ impl Drop for Mutex { } #[stable(feature = "rust1", since = "1.0.0")] -impl fmt::Debug for Mutex { +impl fmt::Debug for Mutex { 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 e9ff6c0bf9d..d32eae15a1b 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -129,7 +129,7 @@ pub struct RwLockWriteGuard<'a, T: 'a> { impl<'a, T> !marker::Send for RwLockWriteGuard<'a, T> {} -impl RwLock { +impl RwLock { /// Creates a new instance of an `RwLock` which is unlocked. /// /// # Examples @@ -257,7 +257,7 @@ impl Drop for RwLock { } #[stable(feature = "rust1", since = "1.0.0")] -impl fmt::Debug for RwLock { +impl fmt::Debug for RwLock { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.try_read() { Ok(guard) => write!(f, "RwLock {{ data: {:?} }}", *guard), -- cgit 1.4.1-3-g733a5 From 0f6b43aa8f288d3d12adc8747fb5060956d7f0e5 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Sun, 8 Mar 2015 22:02:21 +1100 Subject: Remove unneeded `Send` bounds from `std::sync::mpsc`. The requirements `T: Send` only matter if the channel crosses thread boundaries i.e. the `Sender` or `Reciever` are sent across thread boundaries, and which is adequately controlled by the impls of `Send` for them. If `T` doesn't satisfy the bounds, then the types cannot cross thread boundaries and so everything is still safe (the pair of types collectively behave like a `Rc>`, or something of that nature). --- src/libstd/sync/mpsc/mod.rs | 24 ++++++++++++------------ src/libstd/sync/mpsc/mpsc_queue.rs | 4 ++-- src/libstd/sync/mpsc/oneshot.rs | 4 ++-- src/libstd/sync/mpsc/shared.rs | 4 ++-- src/libstd/sync/mpsc/spsc_queue.rs | 6 +++--- src/libstd/sync/mpsc/stream.rs | 4 ++-- src/libstd/sync/mpsc/sync.rs | 12 ++++++------ 7 files changed, 29 insertions(+), 29 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 1a1e9e69e71..6ce94592c95 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -485,7 +485,7 @@ impl UnsafeFlavor for Receiver { /// println!("{:?}", rx.recv().unwrap()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] -pub fn channel() -> (Sender, Receiver) { +pub fn channel() -> (Sender, Receiver) { let a = Arc::new(UnsafeCell::new(oneshot::Packet::new())); (Sender::new(Flavor::Oneshot(a.clone())), Receiver::new(Flavor::Oneshot(a))) } @@ -525,7 +525,7 @@ pub fn channel() -> (Sender, Receiver) { /// assert_eq!(rx.recv().unwrap(), 2); /// ``` #[stable(feature = "rust1", since = "1.0.0")] -pub fn sync_channel(bound: usize) -> (SyncSender, Receiver) { +pub fn sync_channel(bound: usize) -> (SyncSender, Receiver) { let a = Arc::new(UnsafeCell::new(sync::Packet::new(bound))); (SyncSender::new(a.clone()), Receiver::new(Flavor::Sync(a))) } @@ -534,7 +534,7 @@ pub fn sync_channel(bound: usize) -> (SyncSender, Receiver) { // Sender //////////////////////////////////////////////////////////////////////////////// -impl Sender { +impl Sender { fn new(inner: Flavor) -> Sender { Sender { inner: UnsafeCell::new(inner), @@ -616,7 +616,7 @@ impl Sender { } #[stable(feature = "rust1", since = "1.0.0")] -impl Clone for Sender { +impl Clone for Sender { fn clone(&self) -> Sender { let (packet, sleeper, guard) = match *unsafe { self.inner() } { Flavor::Oneshot(ref p) => { @@ -662,7 +662,7 @@ impl Clone for Sender { #[unsafe_destructor] #[stable(feature = "rust1", since = "1.0.0")] -impl Drop for Sender { +impl Drop for Sender { fn drop(&mut self) { match *unsafe { self.inner_mut() } { Flavor::Oneshot(ref mut p) => unsafe { (*p.get()).drop_chan(); }, @@ -677,7 +677,7 @@ impl Drop for Sender { // SyncSender //////////////////////////////////////////////////////////////////////////////// -impl SyncSender { +impl SyncSender { fn new(inner: Arc>>) -> SyncSender { SyncSender { inner: inner } } @@ -717,7 +717,7 @@ impl SyncSender { } #[stable(feature = "rust1", since = "1.0.0")] -impl Clone for SyncSender { +impl Clone for SyncSender { fn clone(&self) -> SyncSender { unsafe { (*self.inner.get()).clone_chan(); } return SyncSender::new(self.inner.clone()); @@ -726,7 +726,7 @@ impl Clone for SyncSender { #[unsafe_destructor] #[stable(feature = "rust1", since = "1.0.0")] -impl Drop for SyncSender { +impl Drop for SyncSender { fn drop(&mut self) { unsafe { (*self.inner.get()).drop_chan(); } } @@ -736,7 +736,7 @@ impl Drop for SyncSender { // Receiver //////////////////////////////////////////////////////////////////////////////// -impl Receiver { +impl Receiver { fn new(inner: Flavor) -> Receiver { Receiver { inner: UnsafeCell::new(inner) } } @@ -855,7 +855,7 @@ impl Receiver { } } -impl select::Packet for Receiver { +impl select::Packet for Receiver { fn can_recv(&self) -> bool { loop { let new_port = match *unsafe { self.inner() } { @@ -942,7 +942,7 @@ impl select::Packet for Receiver { } #[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 { self.rx.recv().ok() } @@ -950,7 +950,7 @@ impl<'a, T: Send> Iterator for Iter<'a, T> { #[unsafe_destructor] #[stable(feature = "rust1", since = "1.0.0")] -impl Drop for Receiver { +impl Drop for Receiver { 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 14ed253d8e2..8b6672e0c27 100644 --- a/src/libstd/sync/mpsc/mpsc_queue.rs +++ b/src/libstd/sync/mpsc/mpsc_queue.rs @@ -89,7 +89,7 @@ impl Node { } } -impl Queue { +impl Queue { /// Creates a new queue that is safe to share among multiple producers and /// one consumer. pub fn new() -> Queue { @@ -140,7 +140,7 @@ impl Queue { #[unsafe_destructor] #[stable(feature = "rust1", since = "1.0.0")] -impl Drop for Queue { +impl Drop for Queue { 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 f287712d9d4..c6e8d87a22e 100644 --- a/src/libstd/sync/mpsc/oneshot.rs +++ b/src/libstd/sync/mpsc/oneshot.rs @@ -88,7 +88,7 @@ enum MyUpgrade { GoUp(Receiver), } -impl Packet { +impl Packet { pub fn new() -> Packet { Packet { data: None, @@ -368,7 +368,7 @@ impl Packet { } #[unsafe_destructor] -impl Drop for Packet { +impl Drop for Packet { 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 8d14824d37f..b611ad3c35d 100644 --- a/src/libstd/sync/mpsc/shared.rs +++ b/src/libstd/sync/mpsc/shared.rs @@ -64,7 +64,7 @@ pub enum Failure { Disconnected, } -impl Packet { +impl Packet { // Creation of a packet *must* be followed by a call to postinit_lock // and later by inherit_blocker pub fn new() -> Packet { @@ -474,7 +474,7 @@ impl Packet { } #[unsafe_destructor] -impl Drop for Packet { +impl Drop for Packet { 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 3fb13739aa7..c75ac130808 100644 --- a/src/libstd/sync/mpsc/spsc_queue.rs +++ b/src/libstd/sync/mpsc/spsc_queue.rs @@ -78,7 +78,7 @@ unsafe impl Send for Queue { } unsafe impl Sync for Queue { } -impl Node { +impl Node { fn new() -> *mut Node { unsafe { boxed::into_raw(box Node { @@ -89,7 +89,7 @@ impl Node { } } -impl Queue { +impl Queue { /// Creates a new queue. /// /// This is unsafe as the type system doesn't enforce a single @@ -227,7 +227,7 @@ impl Queue { } #[unsafe_destructor] -impl Drop for Queue { +impl Drop for Queue { 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 5a1e05f9c15..f0363fae84f 100644 --- a/src/libstd/sync/mpsc/stream.rs +++ b/src/libstd/sync/mpsc/stream.rs @@ -74,7 +74,7 @@ enum Message { GoUp(Receiver), } -impl Packet { +impl Packet { pub fn new() -> Packet { Packet { queue: unsafe { spsc::Queue::new(128) }, @@ -472,7 +472,7 @@ impl Packet { } #[unsafe_destructor] -impl Drop for Packet { +impl Drop for Packet { 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 33c1614e1b2..6221ca59b54 100644 --- a/src/libstd/sync/mpsc/sync.rs +++ b/src/libstd/sync/mpsc/sync.rs @@ -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>, - mut guard: MutexGuard<'b, State>, - f: fn(SignalToken) -> Blocker) - -> MutexGuard<'a, State> +fn wait<'a, 'b, T>(lock: &'a Mutex>, + mut guard: MutexGuard<'b, State>, + f: fn(SignalToken) -> Blocker) + -> MutexGuard<'a, State> { let (wait_token, signal_token) = blocking::tokens(); match mem::replace(&mut guard.blocker, f(signal_token)) { @@ -136,7 +136,7 @@ fn wakeup(token: SignalToken, guard: MutexGuard>) { token.signal(); } -impl Packet { +impl Packet { pub fn new(cap: usize) -> Packet { Packet { channels: AtomicUsize::new(1), @@ -412,7 +412,7 @@ impl Packet { } #[unsafe_destructor] -impl Drop for Packet { +impl Drop for Packet { fn drop(&mut self) { assert_eq!(self.channels.load(Ordering::SeqCst), 0); let mut guard = self.lock.lock().unwrap(); -- cgit 1.4.1-3-g733a5 From c35c46821a69af14e6b38e0238f70e22433a3e8e Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 30 Mar 2015 09:40:52 -0400 Subject: Fallout in public-facing and semi-public-facing libs --- src/doc/reference.md | 6 +- src/libcollections/binary_heap.rs | 2 +- src/libcollections/btree/node.rs | 2 +- src/libcollections/enum_set.rs | 6 +- src/libcollectionstest/enum_set.rs | 4 +- src/libcore/atomic.rs | 2 +- src/libcore/fmt/mod.rs | 13 +- src/libcore/fmt/num.rs | 2 +- src/libcore/fmt/rt/v1.rs | 10 +- src/libcore/marker.rs | 5 +- src/libcore/num/mod.rs | 2 +- src/libcore/ops.rs | 28 +-- src/libcore/raw.rs | 6 +- src/libcore/simd.rs | 20 +-- src/libcore/str/mod.rs | 2 +- src/libfmt_macros/lib.rs | 14 +- src/libgetopts/lib.rs | 8 +- src/libgraphviz/lib.rs | 2 +- src/liblibc/lib.rs | 289 ++++++++++++++++--------------- src/liblog/lib.rs | 4 +- src/librand/distributions/exponential.rs | 4 +- src/librand/distributions/normal.rs | 6 +- src/librand/reseeding.rs | 2 +- src/librbml/lib.rs | 4 +- src/librustdoc/html/format.rs | 8 +- src/librustdoc/html/render.rs | 2 +- src/librustdoc/stability_summary.rs | 2 +- src/libserialize/hex.rs | 2 +- src/libserialize/json.rs | 2 +- src/libstd/collections/hash/table.rs | 8 +- src/libstd/num/strconv.rs | 6 +- src/libstd/old_io/mod.rs | 8 +- src/libstd/old_io/net/addrinfo.rs | 10 +- src/libstd/old_io/util.rs | 6 +- src/libstd/rt/libunwind.rs | 2 +- src/libstd/thread/local.rs | 2 +- src/libterm/lib.rs | 2 +- src/libterm/terminfo/parm.rs | 8 +- src/libtest/lib.rs | 4 +- 39 files changed, 273 insertions(+), 242 deletions(-) (limited to 'src/libstd') 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/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 Clone for Node { /// println!("Uninitialized memory: {:?}", handle.into_kv()); /// } /// ``` -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Handle { 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 { impl Copy for EnumSet {} +impl Clone for EnumSet { + fn clone(&self) -> EnumSet { *self } +} + #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for EnumSet { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { 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/libcore/atomic.rs b/src/libcore/atomic.rs index 8c396a4e7fb..da93ae6dd2a 100644 --- a/src/libcore/atomic.rs +++ b/src/libcore/atomic.rs @@ -122,7 +122,7 @@ unsafe impl Sync for AtomicPtr {} /// 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")] diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index ffb358cdac8..22e622d3208 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -15,6 +15,7 @@ use any; use cell::{Cell, RefCell, Ref, RefMut, BorrowState}; use char::CharExt; +use clone::Clone; use iter::Iterator; use marker::{Copy, PhantomData, Sized}; use mem; @@ -54,7 +55,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. @@ -141,6 +142,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 { @@ -175,7 +182,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, } @@ -222,7 +229,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); /// 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 9503e439a8e..a89dbcdf2ce 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -75,7 +75,7 @@ pub trait Sized : MarkerTrait { /// /// ``` /// // we can just derive a `Copy` implementation -/// #[derive(Debug, Copy)] +/// #[derive(Debug, Copy, Clone)] /// struct Foo; /// /// let x = Foo; @@ -124,7 +124,7 @@ pub trait Sized : MarkerTrait { /// There are two ways to implement `Copy` on your type: /// /// ``` -/// #[derive(Copy)] +/// #[derive(Copy, Clone)] /// struct MyStruct; /// ``` /// @@ -133,6 +133,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` diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index a4829ed96b3..26f5c7c58c6 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -2425,7 +2425,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/ops.rs b/src/libcore/ops.rs index 862eb16d0bf..956df7ee786 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 { @@ -511,7 +511,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 +565,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 +619,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 +673,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 +727,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 for Foo { @@ -799,7 +799,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 for Foo { @@ -871,7 +871,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 +912,7 @@ pub trait Index { /// ``` /// 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..b072b0a9646 100644 --- a/src/libcore/raw.rs +++ b/src/libcore/raw.rs @@ -18,7 +18,6 @@ //! //! Their definition should always match the ABI defined in `rustc::back::abi`. -use marker::Copy; use mem; /// The representation of a slice like `&[T]`. @@ -63,6 +62,9 @@ pub struct Slice { } impl Copy for Slice {} +impl Clone for Slice { + fn clone(&self) -> Slice { *self } +} /// The representation of a trait object like `&SomeTrait`. /// @@ -136,7 +138,7 @@ impl Copy for Slice {} /// 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 934c4515614..625673d6d90 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1123,7 +1123,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/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, @@ -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..d2ddbd088a9 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, @@ -291,6 +291,7 @@ pub mod types { } pub mod bsd44 { + use core::clone::Clone; use types::common::c95::{c_void}; use types::os::arch::c95::{c_char, c_int, c_uint}; @@ -299,7 +300,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 +313,22 @@ pub mod types { #[cfg(target_pointer_width = "64")] pub __ss_pad2: [u8; 128 - 2 * 8], } + impl 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 +336,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 +376,12 @@ pub mod types { pub sun_family: sa_family_t, pub sun_path: [c_char; 108] } + impl 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 +472,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 +496,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 +517,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 +540,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 +563,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 +587,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 +602,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 +674,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 +696,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 +718,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 +741,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 +757,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 +784,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 +801,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 {} + #[derive(Copy, Clone)] 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 +828,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 +858,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 +872,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 +880,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 +893,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 +918,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 +991,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 +1017,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 +1046,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 +1063,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 {} + #[derive(Copy, Clone)] 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 +1090,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 +1120,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 +1134,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 +1142,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 +1155,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 +1180,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 +1253,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 +1278,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 +1308,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 +1325,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 +1343,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 {} + #[derive(Copy, Clone)] 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 +1370,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 +1400,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 +1414,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 +1422,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 +1435,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 +1460,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 +1533,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 +1556,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 +1583,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 +1599,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 {} + #[derive(Copy, Clone)] pub enum timezone {} } pub mod bsd44 { @@ -1622,30 +1629,30 @@ 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], } #[repr(C)] - #[derive(Copy)] pub struct sockaddr_storage { + #[derive(Copy, Clone)] pub struct sockaddr_storage { pub ss_family: sa_family_t, pub __ss_pad1: [u8; 6], pub __ss_align: i64, pub __ss_pad2: [u8; 112], } #[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 +1660,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, @@ -1678,7 +1685,7 @@ 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_family: sa_family_t, pub sun_path: [c_char; 108] } @@ -1807,7 +1814,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 +1838,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 +1861,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 +1870,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 +1886,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 +1898,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 +1909,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 +1917,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 +1925,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], } @@ -1926,7 +1933,7 @@ pub mod types { pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN; #[repr(C)] - #[derive(Copy)] pub struct WSAPROTOCOL_INFO { + #[derive(Copy, Clone)] pub struct WSAPROTOCOL_INFO { pub dwServiceFlags1: DWORD, pub dwServiceFlags2: DWORD, pub dwServiceFlags3: DWORD, @@ -1954,7 +1961,7 @@ pub mod types { pub type GROUP = c_uint; #[repr(C)] - #[derive(Copy)] pub struct WIN32_FIND_DATAW { + #[derive(Copy, Clone)] pub struct WIN32_FIND_DATAW { pub dwFileAttributes: DWORD, pub ftCreationTime: FILETIME, pub ftLastAccessTime: FILETIME, @@ -1985,7 +1992,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 +2009,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 {} + #[derive(Copy, Clone)] 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 +2036,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,14 +2066,14 @@ 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], @@ -2075,7 +2082,7 @@ pub mod types { } #[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 +2091,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 +2106,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, @@ -2128,14 +2135,14 @@ pub mod types { } #[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, @@ -2200,7 +2207,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,13 +2233,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 __sig: c_long, pub __opaque: [c_char; 36] } @@ -2243,7 +2250,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 +2313,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,13 +2339,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 __sig: c_long, pub __opaque: [c_char; 56] } @@ -2349,7 +2356,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, } 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::().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/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 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 { /// 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 Reseeder 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/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); /// 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); 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 { } impl Copy for RawBucket {} +impl Clone for RawBucket { + fn clone(&self) -> RawBucket { *self } +} pub struct Bucket { raw: RawBucket, @@ -95,6 +98,9 @@ pub struct Bucket { } impl Copy for Bucket {} +impl Clone for Bucket { + fn clone(&self) -> Bucket { *self } +} pub struct EmptyBucket { raw: RawBucket, @@ -129,7 +135,7 @@ struct GapThenFull { /// 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/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/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 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, @@ -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 Buffer for LimitReader { } /// 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/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/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/libtest/lib.rs b/src/libtest/lib.rs index f7e5c9f1dee..521961215dd 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -193,7 +193,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, @@ -280,7 +280,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, -- cgit 1.4.1-3-g733a5 From 3225b04c7d335b8f6e224c7d90ab95717ed84cc3 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Wed, 1 Apr 2015 12:36:37 +0200 Subject: fallout from feature-gating unary negation on unsigned integers. --- src/libcollections/slice.rs | 2 +- src/libcore/atomic.rs | 2 +- src/libcore/cell.rs | 2 +- src/libcore/num/mod.rs | 2 +- src/libcore/ops.rs | 24 ++++++++++++++++++++---- src/libcore/str/mod.rs | 2 +- src/liblibc/lib.rs | 2 +- src/libstd/rt/mod.rs | 2 +- 8 files changed, 27 insertions(+), 11 deletions(-) (limited to 'src/libstd') diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 4599aff000d..29301bfd6fe 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -1123,7 +1123,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/libcore/atomic.rs b/src/libcore/atomic.rs index 8c396a4e7fb..d738ff947c4 100644 --- a/src/libcore/atomic.rs +++ b/src/libcore/atomic.rs @@ -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 RefCell { /// Creates a new `RefCell` containing `value`. diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index a4829ed96b3..13f168b3fdb 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -517,7 +517,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 { diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 862eb16d0bf..e1a9efd69ad 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -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 `!`. /// diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 934c4515614..c78fa803361 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -873,7 +873,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 diff --git a/src/liblibc/lib.rs b/src/liblibc/lib.rs index b7162c4a177..77e18be298b 100644 --- a/src/liblibc/lib.rs +++ b/src/liblibc/lib.rs @@ -4696,7 +4696,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/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index 696c7960c3e..7ea77a79619 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -117,7 +117,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(); -- cgit 1.4.1-3-g733a5 From f86318d63c86568b312f39da20bea67e328c1fc5 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 1 Apr 2015 16:34:15 -0700 Subject: Test fixes and rebase conflicts, round 2 Conflicts: src/libcore/num/mod.rs --- src/libcollectionstest/slice.rs | 4 ++-- src/libcoretest/fmt/num.rs | 16 ++++++++-------- src/liblibc/lib.rs | 2 +- src/librand/distributions/mod.rs | 2 +- src/librustc/middle/const_eval.rs | 2 +- src/libstd/fs.rs | 2 +- src/libstd/old_io/fs.rs | 2 +- src/libsyntax/print/pprust.rs | 2 +- src/test/compile-fail/const-eval-overflow.rs | 1 + src/test/compile-fail/lint-exceeding-bitshifts.rs | 2 +- src/test/compile-fail/lint-type-limits.rs | 1 + 11 files changed, 19 insertions(+), 17 deletions(-) (limited to 'src/libstd') diff --git a/src/libcollectionstest/slice.rs b/src/libcollectionstest/slice.rs index 041d9fba57c..dab5da10db4 100644 --- a/src/libcollectionstest/slice.rs +++ b/src/libcollectionstest/slice.rs @@ -1088,7 +1088,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); } @@ -1097,7 +1097,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/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/liblibc/lib.rs b/src/liblibc/lib.rs index 77e18be298b..bfc657f8784 100644 --- a/src/liblibc/lib.rs +++ b/src/liblibc/lib.rs @@ -2865,7 +2865,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; 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/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index fb742b6737f..367bcbbe1d8 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -396,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) -> 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 { 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/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/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index da1b7a7bdde..3a41b74fb79 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -3048,7 +3048,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/test/compile-fail/const-eval-overflow.rs b/src/test/compile-fail/const-eval-overflow.rs index fb8726f900d..19b5f9b094c 100644 --- a/src/test/compile-fail/const-eval-overflow.rs +++ b/src/test/compile-fail/const-eval-overflow.rs @@ -11,6 +11,7 @@ #![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/lint-exceeding-bitshifts.rs b/src/test/compile-fail/lint-exceeding-bitshifts.rs index 1894064fd84..1f70828e411 100644 --- a/src/test/compile-fail/lint-exceeding-bitshifts.rs +++ b/src/test/compile-fail/lint-exceeding-bitshifts.rs @@ -12,7 +12,7 @@ #![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 2ccfb5cd520..798dc112b0a 100644 --- a/src/test/compile-fail/lint-type-limits.rs +++ b/src/test/compile-fail/lint-type-limits.rs @@ -10,6 +10,7 @@ #![feature(negate_unsigned)] #![allow(dead_code)] +#![feature(negate_unsigned)] // compile-flags: -D unused-comparisons fn main() { } -- cgit 1.4.1-3-g733a5 From 57f5ac948aeb296b99785a82ffc49fafc291aad9 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 1 Apr 2015 16:34:15 -0700 Subject: Test fixes and rebase conflicts, round 2 --- src/libcore/num/mod.rs | 2 +- src/liblibc/lib.rs | 6 +++--- src/libstd/sync/mpsc/mod.rs | 16 +++++++------- src/libstd/sync/mpsc/mpsc_queue.rs | 4 ++-- src/libstd/sync/mpsc/oneshot.rs | 8 +++---- src/libstd/sync/mpsc/shared.rs | 2 +- src/libstd/sync/mpsc/spsc_queue.rs | 2 +- src/libstd/sync/mpsc/stream.rs | 8 +++---- src/libstd/sync/mpsc/sync.rs | 2 +- src/libstd/sync/mutex.rs | 2 +- src/libstd/sys/windows/c.rs | 6 +++--- src/test/compile-fail/unsendable-class.rs | 35 ------------------------------- 12 files changed, 29 insertions(+), 64 deletions(-) delete mode 100644 src/test/compile-fail/unsendable-class.rs (limited to 'src/libstd') diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index e4565c51fa8..28e0bcf13dd 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -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. /// diff --git a/src/liblibc/lib.rs b/src/liblibc/lib.rs index 9265a3e1c16..a3a7edac230 100644 --- a/src/liblibc/lib.rs +++ b/src/liblibc/lib.rs @@ -2571,7 +2571,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; @@ -2609,12 +2609,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; diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index b436e49feab..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 { +pub struct Receiver { inner: UnsafeCell>, } @@ -354,14 +354,14 @@ unsafe impl Send for Receiver { } /// 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 } /// 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 { +pub struct Sender { inner: UnsafeCell>, } @@ -372,7 +372,7 @@ unsafe impl Send for Sender { } /// 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 { +pub struct SyncSender { inner: Arc>>, } @@ -433,7 +433,7 @@ pub enum TrySendError { Disconnected(T), } -enum Flavor { +enum Flavor { Oneshot(Arc>>), Stream(Arc>>), Shared(Arc>>), @@ -441,7 +441,7 @@ enum Flavor { } #[doc(hidden)] -trait UnsafeFlavor { +trait UnsafeFlavor { fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell>; unsafe fn inner_mut<'a>(&'a self) -> &'a mut Flavor { &mut *self.inner_unsafe().get() @@ -450,12 +450,12 @@ trait UnsafeFlavor { &*self.inner_unsafe().get() } } -impl UnsafeFlavor for Sender { +impl UnsafeFlavor for Sender { fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell> { &self.inner } } -impl UnsafeFlavor for Receiver { +impl UnsafeFlavor for Receiver { fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell> { &self.inner } diff --git a/src/libstd/sync/mpsc/mpsc_queue.rs b/src/libstd/sync/mpsc/mpsc_queue.rs index 7866a85dc8f..9b6c8f4dd97 100644 --- a/src/libstd/sync/mpsc/mpsc_queue.rs +++ b/src/libstd/sync/mpsc/mpsc_queue.rs @@ -72,12 +72,12 @@ struct Node { /// 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 { +pub struct Queue { head: AtomicPtr>, tail: UnsafeCell<*mut Node>, } -unsafe impl Send for Queue { } +unsafe impl Send for Queue { } unsafe impl Sync for Queue { } impl Node { diff --git a/src/libstd/sync/mpsc/oneshot.rs b/src/libstd/sync/mpsc/oneshot.rs index 21f690f0ee4..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 { +pub struct Packet { // 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 { upgrade: MyUpgrade, } -pub enum Failure { +pub enum Failure { Empty, Disconnected, Upgraded(Receiver), @@ -76,13 +76,13 @@ pub enum UpgradeResult { UpWoke(SignalToken), } -pub enum SelectionResult { +pub enum SelectionResult { SelCanceled, SelUpgraded(SignalToken, Receiver), SelSuccess, } -enum MyUpgrade { +enum MyUpgrade { NothingSent, SendUsed, GoUp(Receiver), diff --git a/src/libstd/sync/mpsc/shared.rs b/src/libstd/sync/mpsc/shared.rs index be973028577..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 { +pub struct Packet { queue: mpsc::Queue, cnt: AtomicIsize, // How many items are on this channel steals: isize, // How many times has a port received without blocking? diff --git a/src/libstd/sync/mpsc/spsc_queue.rs b/src/libstd/sync/mpsc/spsc_queue.rs index 278ac03cf03..c75ac130808 100644 --- a/src/libstd/sync/mpsc/spsc_queue.rs +++ b/src/libstd/sync/mpsc/spsc_queue.rs @@ -57,7 +57,7 @@ struct Node { /// 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 { +pub struct Queue { // consumer fields tail: UnsafeCell<*mut Node>, // where to pop from tail_prev: AtomicPtr>, // where to pop from diff --git a/src/libstd/sync/mpsc/stream.rs b/src/libstd/sync/mpsc/stream.rs index 25b5f6f27ba..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 { +pub struct Packet { queue: spsc::Queue>, // internal queue for all message cnt: AtomicIsize, // How many items are on this channel @@ -49,7 +49,7 @@ pub struct Packet { port_dropped: AtomicBool, // flag if the channel has been destroyed. } -pub enum Failure { +pub enum Failure { Empty, Disconnected, Upgraded(Receiver), @@ -61,7 +61,7 @@ pub enum UpgradeResult { UpWoke(SignalToken), } -pub enum SelectionResult { +pub enum SelectionResult { SelSuccess, SelCanceled, SelUpgraded(SignalToken, Receiver), @@ -69,7 +69,7 @@ pub enum SelectionResult { // 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 -enum Message { +enum Message { Data(T), GoUp(Receiver), } diff --git a/src/libstd/sync/mpsc/sync.rs b/src/libstd/sync/mpsc/sync.rs index 8e49edc44b6..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 { +pub struct Packet { /// Only field outside of the mutex. Just done for kicks, but mainly because /// the other shared channel already had the code implemented channels: AtomicUsize, diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 6a721aff89e..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 { +pub struct Mutex { // 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 diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index e74de595f97..99abe10c8a4 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")] 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 or the MIT license -// , 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, -} - -fn foo(i:isize, j: Rc) -> 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))); -} -- cgit 1.4.1-3-g733a5 From e3b7e6caa25bffcffe6b04f550f551e1ae086f6b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 1 Apr 2015 18:44:53 -0700 Subject: Tweak relese notes + rebase fixes --- RELEASES.md | 4 +-- src/liblibc/lib.rs | 45 ++++++++++++++++++++------- src/librustc/middle/traits/coherence.rs | 2 +- src/libstd/rt/unwind.rs | 2 +- src/libstd/sys/common/net.rs | 4 +-- src/libstd/sys/windows/c.rs | 1 - src/libstd/sys/windows/tcp.rs | 5 +-- src/libsyntax/diagnostic.rs | 2 +- src/libterm/win.rs | 5 +-- src/libtest/lib.rs | 2 +- src/test/compile-fail/coherence-impls-copy.rs | 2 ++ 11 files changed, 50 insertions(+), 24 deletions(-) (limited to 'src/libstd') diff --git a/RELEASES.md b/RELEASES.md index 4068d2ef9f2..7da73afb411 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -34,7 +34,7 @@ Version 1.0.0-beta (April 2015) 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. + 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. @@ -78,7 +78,7 @@ Version 1.0.0-beta (April 2015) [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/rust/pull/22532 +[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 diff --git a/src/liblibc/lib.rs b/src/liblibc/lib.rs index a3a7edac230..44d689059d1 100644 --- a/src/liblibc/lib.rs +++ b/src/liblibc/lib.rs @@ -291,7 +291,6 @@ pub mod types { } pub mod bsd44 { - use core::clone::Clone; use types::common::c95::{c_void}; use types::os::arch::c95::{c_char, c_int, c_uint}; @@ -313,7 +312,7 @@ pub mod types { #[cfg(target_pointer_width = "64")] pub __ss_pad2: [u8; 128 - 2 * 8], } - impl Clone for sockaddr_storage { + impl ::core::clone::Clone for sockaddr_storage { fn clone(&self) -> sockaddr_storage { *self } } #[repr(C)] @@ -376,7 +375,7 @@ pub mod types { pub sun_family: sa_family_t, pub sun_path: [c_char; 108] } - impl Clone for sockaddr_un { + impl ::core::clone::Clone for sockaddr_un { fn clone(&self) -> sockaddr_un { *self } } @@ -1634,12 +1633,15 @@ pub mod types { pub sa_data: [u8; 14], } #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_storage { + #[derive(Copy)] pub struct sockaddr_storage { pub ss_family: sa_family_t, pub __ss_pad1: [u8; 6], 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, Clone)] pub struct sockaddr_in { pub sin_family: sa_family_t, @@ -1685,10 +1687,13 @@ pub mod types { pub ai_next: *mut addrinfo, } #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_un { + #[derive(Copy)] pub struct sockaddr_un { 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 } + } } } @@ -1933,7 +1938,7 @@ pub mod types { pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN; #[repr(C)] - #[derive(Copy, Clone)] pub struct WSAPROTOCOL_INFO { + #[derive(Copy)] pub struct WSAPROTOCOL_INFO { pub dwServiceFlags1: DWORD, pub dwServiceFlags2: DWORD, pub dwServiceFlags3: DWORD, @@ -1955,13 +1960,16 @@ 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; pub type GROUP = c_uint; #[repr(C)] - #[derive(Copy, Clone)] pub struct WIN32_FIND_DATAW { + #[derive(Copy)] pub struct WIN32_FIND_DATAW { pub dwFileAttributes: DWORD, pub ftCreationTime: FILETIME, pub ftLastAccessTime: FILETIME, @@ -1973,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; } @@ -2073,13 +2084,16 @@ pub mod types { } #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_storage { + #[derive(Copy)] pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: sa_family_t, pub __ss_pad1: [u8; 6], 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, Clone)] pub struct sockaddr_in { @@ -2135,11 +2149,14 @@ pub mod types { } #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_un { + #[derive(Copy)] pub struct sockaddr_un { pub sun_len: u8, 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, Clone)] pub struct ifaddrs { @@ -2239,10 +2256,13 @@ pub mod types { } #[repr(C)] - #[derive(Copy, Clone)] pub struct pthread_attr_t { + #[derive(Copy)] pub struct pthread_attr_t { 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 { } @@ -2345,10 +2365,13 @@ pub mod types { } #[repr(C)] - #[derive(Copy, Clone)] pub struct pthread_attr_t { + #[derive(Copy)] pub struct pthread_attr_t { 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 { } 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/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/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 { 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 99abe10c8a4..4804f650441 100644 --- a/src/libstd/sys/windows/c.rs +++ b/src/libstd/sys/windows/c.rs @@ -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/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index c4690b9716c..f35cc8c8d23 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -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/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 WinConsole { // 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 WinConsole { 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 8d329367972..c84703b93ed 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -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/test/compile-fail/coherence-impls-copy.rs b/src/test/compile-fail/coherence-impls-copy.rs index f1a04a8ea57..1be606c3546 100644 --- a/src/test/compile-fail/coherence-impls-copy.rs +++ b/src/test/compile-fail/coherence-impls-copy.rs @@ -28,6 +28,8 @@ 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) {} -- cgit 1.4.1-3-g733a5