Auto merge of #23963 - alexcrichton:rollup, r=alexcrichton

This commit is contained in:
bors 2015-04-02 07:19:33 +00:00
commit cf00fc4da9
264 changed files with 967 additions and 736 deletions

View File

@ -1,3 +1,102 @@
Version 1.0.0-beta (April 2015)
-------------------------------------
* ~1100 changes, numerous bugfixes
* Highlights
* The big news is that the vast majority of the standard library
is now `#[stable]` -- 75% of the non-deprecated API surface at
last count. Numerous crates are now running on stable
Rust. Starting with this release, it is not possible to use
unstable features on a stable build.
* Arithmetic on basic integer types now
[checks for overflow in debug builds][overflow].
* Language
* [`Send` no longer implies `'static`][send-rfc], which made
possible the [`thread::scoped` API][scoped]. Scoped threads can
borrow data from their parent's stack frame -- safely!
* [UFCS now supports trait-less associated paths][moar-ufcs] like
`MyType::default()`.
* Primitive types [now have inherent methods][prim-inherent],
obviating the need for extension traits like `SliceExt`.
* Methods with `Self: Sized` in their `where` clause are
[considered object-safe][self-sized], allowing many extension
traits like `IteratorExt` to be merged into the traits they
extended.
* You can now [refer to associated types][assoc-where] whose
corresponding trait bounds appear only in a `where` clause.
* The final bits of [OIBIT landed][oibit-final], meaning that
traits like `Send` and `Sync` are now library-defined.
* A [Reflect trait][reflect] was introduced, which means that
downcasting via the `Any` trait is effectively limited to
concrete types. This helps retain the potentially-important
"parametricity" property: generic code cannot behave differently
for different type arguments except in minor ways.
* The `unsafe_destructor` feature is now deprecated in favor of
the [new `dropck`][dropck]. This change is a major reduction in
unsafe code.
* Trait coherence was [revised again][fundamental], this time with
an eye toward API evolution over time.
* Libraries
* The new path and IO modules are complete and `#[stable]`. This
was the major library focus for this cycle.
* The path API was [revised][path-normalize] to normalize `.`,
adjusting the tradeoffs in favor of the most common usage.
* A large number of remaining APIs in `std` were also stabilized
during this cycle; about 75% of the non-deprecated API surface
is now stable.
* The new [string pattern API][string-pattern] landed, which makes
the string slice API much more internally consistent and flexible.
* A shiny [framework for Debug implementations][debug-builder] landed.
This makes it possible to opt in to "pretty-printed" debugging output.
* A new set of [generic conversion traits][conversion] replaced
many existing ad hoc traits.
* Generic numeric traits were
[completely removed][num-traits]. This was made possible thanks
to inherent methods for primitive types, and the removal gives
maximal flexibility for designing a numeric hierarchy in the future.
* The `Fn` traits are now related via [inheritance][fn-inherit]
and provide ergonomic [blanket implementations][fn-blanket].
* The `Index` and `IndexMut` traits were changed to
[take the index by value][index-value], enabling code like
`hash_map["string"]` to work.
* `Copy` now [inherits][copy-clone] from `Clone`, meaning that all
`Copy` data is known to be `Clone` as well.
* Infrastructure
* Metadata was tuned, shrinking binaries [by 27%][metadata-shrink].
* Much headway was made on ecosystem-wide CI, making it possible
to [compare builds for breakage][ci-compare].
[send-rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0458-send-improvements.md
[scoped]: http://static.rust-lang.org/doc/master/std/thread/fn.scoped.html
[moar-ufcs]: https://github.com/rust-lang/rust/pull/22172
[prim-inherent]: https://github.com/rust-lang/rust/pull/23104
[overflow]: https://github.com/rust-lang/rfcs/blob/master/text/0560-integer-overflow.md
[metadata-shrink]: https://github.com/rust-lang/rust/pull/22971
[self-sized]: https://github.com/rust-lang/rust/pull/22301
[assoc-where]: https://github.com/rust-lang/rust/pull/22512
[string-pattern]: https://github.com/rust-lang/rust/pull/22466
[oibit-final]: https://github.com/rust-lang/rust/pull/21689
[reflect]: https://github.com/rust-lang/rust/pull/23712
[debug-builder]: https://github.com/rust-lang/rfcs/blob/master/text/0640-debug-improvements.md
[conversion]: https://github.com/rust-lang/rfcs/pull/529
[num-traits]: https://github.com/rust-lang/rust/pull/23549
[index-value]: https://github.com/rust-lang/rust/pull/23601
[dropck]: https://github.com/rust-lang/rfcs/pull/769
[fundamental]: https://github.com/rust-lang/rfcs/pull/1023
[ci-compare]: https://gist.github.com/brson/a30a77836fbec057cbee
[fn-inherit]: https://github.com/rust-lang/rust/pull/23282
[fn-blanket]: https://github.com/rust-lang/rust/pull/23895
[copy-clone]: https://github.com/rust-lang/rust/pull/23860
[path-normalize]: https://github.com/rust-lang/rust/pull/23229
Version 1.0.0-alpha.2 (February 2015)
-------------------------------------

View File

@ -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 {

View File

@ -321,7 +321,7 @@ impl<T> Deref for Arc<T> {
}
}
impl<T: Send + Sync + Clone> Arc<T> {
impl<T: Clone> Arc<T> {
/// Make a mutable reference from the given `Arc<T>`.
///
/// This is also referred to as a copy-on-write operation because the inner
@ -465,7 +465,7 @@ impl<T> Weak<T> {
#[unstable(feature = "alloc",
reason = "Weak pointers may not belong in this module.")]
impl<T: Sync + Send> Clone for Weak<T> {
impl<T> Clone for Weak<T> {
/// Makes a clone of the `Weak<T>`.
///
/// This increases the weak reference count.

View File

@ -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,

View File

@ -526,7 +526,7 @@ impl<K: Clone, V: Clone> Clone for Node<K, V> {
/// println!("Uninitialized memory: {:?}", handle.into_kv());
/// }
/// ```
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct Handle<NodeRef, Type, NodeType> {
node: NodeRef,
index: usize,

View File

@ -21,7 +21,7 @@ use core::ops::{Sub, BitOr, BitAnd, BitXor};
// FIXME(contentions): implement union family of methods? (general design may be wrong here)
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
/// A specialized set implementation to use enum types.
///
/// It is a logic error for an item to be modified in such a way that the transformation of the
@ -37,6 +37,10 @@ pub struct EnumSet<E> {
impl<E> Copy for EnumSet<E> {}
impl<E> Clone for EnumSet<E> {
fn clone(&self) -> EnumSet<E> { *self }
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<E:CLike + fmt::Debug> fmt::Debug for EnumSet<E> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {

View File

@ -1135,7 +1135,7 @@ impl Iterator for ElementSwaps {
// #[inline]
fn next(&mut self) -> Option<(usize, usize)> {
fn new_pos_wrapping(i: usize, s: Direction) -> usize {
i.wrapping_add(match s { Pos => 1, Neg => -1 })
i.wrapping_add(match s { Pos => 1, Neg => !0 /* aka -1 */ })
}
fn new_pos(i: usize, s: Direction) -> usize {

View File

@ -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,

View File

@ -1089,7 +1089,7 @@ fn test_bytes_set_memory() {
#[should_panic]
fn test_overflow_does_not_cause_segfault() {
let mut v = vec![];
v.reserve_exact(-1);
v.reserve_exact(!0);
v.push(1);
v.push(2);
}
@ -1098,7 +1098,7 @@ fn test_overflow_does_not_cause_segfault() {
#[should_panic]
fn test_overflow_does_not_cause_segfault_managed() {
let mut v = vec![Rc::new(1)];
v.reserve_exact(-1);
v.reserve_exact(!0);
v.push(Rc::new(2));
}

View File

@ -122,7 +122,7 @@ unsafe impl<T> Sync for AtomicPtr<T> {}
/// Rust's memory orderings are [the same as
/// C++'s](http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync).
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum Ordering {
/// No ordering constraints, only atomic operations.
#[stable(feature = "rust1", since = "1.0.0")]
@ -161,7 +161,7 @@ pub const ATOMIC_USIZE_INIT: AtomicUsize =
AtomicUsize { v: UnsafeCell { value: 0, } };
// NB: Needs to be -1 (0b11111111...) to make fetch_nand work correctly
const UINT_TRUE: usize = -1;
const UINT_TRUE: usize = !0;
impl AtomicBool {
/// Creates a new `AtomicBool`.

View File

@ -287,7 +287,7 @@ pub enum BorrowState {
// (will not outgrow its range since `usize` is the size of the address space)
type BorrowFlag = usize;
const UNUSED: BorrowFlag = 0;
const WRITING: BorrowFlag = -1;
const WRITING: BorrowFlag = !0;
impl<T> RefCell<T> {
/// Creates a new `RefCell` containing `value`.

View File

@ -14,6 +14,7 @@
use cell::{Cell, RefCell, Ref, RefMut, BorrowState};
use char::CharExt;
use clone::Clone;
use iter::Iterator;
use marker::{Copy, PhantomData, Sized};
use mem;
@ -53,7 +54,7 @@ pub type Result = result::Result<(), Error>;
/// occurred. Any extra information must be arranged to be transmitted through
/// some other means.
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Copy, Debug)]
#[derive(Copy, Clone, Debug)]
pub struct Error;
/// A collection of methods that are required to format a message into a stream.
@ -140,6 +141,12 @@ pub struct ArgumentV1<'a> {
formatter: fn(&Void, &mut Formatter) -> Result,
}
impl<'a> Clone for ArgumentV1<'a> {
fn clone(&self) -> ArgumentV1<'a> {
*self
}
}
impl<'a> ArgumentV1<'a> {
#[inline(never)]
fn show_usize(x: &usize, f: &mut Formatter) -> Result {
@ -174,7 +181,7 @@ impl<'a> ArgumentV1<'a> {
}
// flags available in the v1 format of format_args
#[derive(Copy)]
#[derive(Copy, Clone)]
#[allow(dead_code)] // SignMinus isn't currently used
enum FlagV1 { SignPlus, SignMinus, Alternate, SignAwareZeroPad, }
@ -221,7 +228,7 @@ impl<'a> Arguments<'a> {
/// macro validates the format string at compile-time so usage of the `write`
/// and `format` functions can be safely performed.
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct Arguments<'a> {
// Format string pieces to print.
pieces: &'a [&'a str],

View File

@ -139,7 +139,7 @@ impl GenericRadix for Radix {
/// A helper type for formatting radixes.
#[unstable(feature = "core",
reason = "may be renamed or move to a different module")]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct RadixFmt<T, R>(T, R);
/// Constructs a radix formatter in the range of `2..36`.

View File

@ -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")]

View File

@ -76,7 +76,7 @@ pub trait Sized : MarkerTrait {
///
/// ```
/// // we can just derive a `Copy` implementation
/// #[derive(Debug, Copy)]
/// #[derive(Debug, Copy, Clone)]
/// struct Foo;
///
/// let x = Foo;
@ -125,7 +125,7 @@ pub trait Sized : MarkerTrait {
/// There are two ways to implement `Copy` on your type:
///
/// ```
/// #[derive(Copy)]
/// #[derive(Copy, Clone)]
/// struct MyStruct;
/// ```
///
@ -134,6 +134,7 @@ pub trait Sized : MarkerTrait {
/// ```
/// struct MyStruct;
/// impl Copy for MyStruct {}
/// impl Clone for MyStruct { fn clone(&self) -> MyStruct { *self } }
/// ```
///
/// There is a small difference between the two: the `derive` strategy will also place a `Copy`
@ -155,7 +156,7 @@ pub trait Sized : MarkerTrait {
/// change: that second example would fail to compile if we made `Foo` non-`Copy`.
#[stable(feature = "rust1", since = "1.0.0")]
#[lang="copy"]
pub trait Copy : MarkerTrait {
pub trait Copy : Clone {
// Empty.
}

View File

@ -516,7 +516,7 @@ macro_rules! uint_impl {
fn min_value() -> $T { 0 }
#[inline]
fn max_value() -> $T { -1 }
fn max_value() -> $T { !0 }
#[inline]
fn count_ones(self) -> u32 {
@ -1347,7 +1347,7 @@ macro_rules! uint_impl {
/// Returns the largest value that can be represented by this integer type.
#[stable(feature = "rust1", since = "1.0.0")]
pub fn max_value() -> $T { -1 }
pub fn max_value() -> $T { !0 }
/// Convert a string slice in a given base to an integer.
///
@ -2444,7 +2444,7 @@ impl_num_cast! { f32, to_f32 }
impl_num_cast! { f64, to_f64 }
/// Used for representing the classification of floating point numbers
#[derive(Copy, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
#[stable(feature = "rust1", since = "1.0.0")]
pub enum FpCategory {
/// "Not a Number", often obtained by dividing by zero

View File

@ -30,7 +30,7 @@ use intrinsics::{i16_mul_with_overflow, u16_mul_with_overflow};
use intrinsics::{i32_mul_with_overflow, u32_mul_with_overflow};
use intrinsics::{i64_mul_with_overflow, u64_mul_with_overflow};
use ::{i8,i16,i32,i64,u8,u16,u32,u64};
use ::{i8,i16,i32,i64};
#[unstable(feature = "core", reason = "may be removed, renamed, or relocated")]
#[deprecated(since = "1.0.0", reason = "moved to inherent methods")]
@ -206,7 +206,7 @@ mod shift_max {
pub const u64: u32 = i64;
}
macro_rules! overflowing_impl {
macro_rules! signed_overflowing_impl {
($($t:ident)*) => ($(
impl OverflowingOps for $t {
#[inline(always)]
@ -259,7 +259,53 @@ macro_rules! overflowing_impl {
)*)
}
overflowing_impl! { u8 u16 u32 u64 i8 i16 i32 i64 }
macro_rules! unsigned_overflowing_impl {
($($t:ident)*) => ($(
impl OverflowingOps for $t {
#[inline(always)]
fn overflowing_add(self, rhs: $t) -> ($t, bool) {
unsafe {
concat_idents!($t, _add_with_overflow)(self, rhs)
}
}
#[inline(always)]
fn overflowing_sub(self, rhs: $t) -> ($t, bool) {
unsafe {
concat_idents!($t, _sub_with_overflow)(self, rhs)
}
}
#[inline(always)]
fn overflowing_mul(self, rhs: $t) -> ($t, bool) {
unsafe {
concat_idents!($t, _mul_with_overflow)(self, rhs)
}
}
#[inline(always)]
fn overflowing_div(self, rhs: $t) -> ($t, bool) {
(self/rhs, false)
}
#[inline(always)]
fn overflowing_rem(self, rhs: $t) -> ($t, bool) {
(self % rhs, false)
}
#[inline(always)]
fn overflowing_shl(self, rhs: u32) -> ($t, bool) {
(self << (rhs & self::shift_max::$t),
(rhs > self::shift_max::$t))
}
#[inline(always)]
fn overflowing_shr(self, rhs: u32) -> ($t, bool) {
(self >> (rhs & self::shift_max::$t),
(rhs > self::shift_max::$t))
}
}
)*)
}
signed_overflowing_impl! { i8 i16 i32 i64 }
unsigned_overflowing_impl! { u8 u16 u32 u64 }
#[cfg(target_pointer_width = "64")]
impl OverflowingOps for usize {

View File

@ -165,7 +165,7 @@ macro_rules! forward_ref_binop {
/// ```
/// use std::ops::Add;
///
/// #[derive(Copy)]
/// #[derive(Copy, Clone)]
/// struct Foo;
///
/// impl Add for Foo {
@ -219,7 +219,7 @@ add_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
/// ```
/// use std::ops::Sub;
///
/// #[derive(Copy)]
/// #[derive(Copy, Clone)]
/// struct Foo;
///
/// impl Sub for Foo {
@ -273,7 +273,7 @@ sub_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
/// ```
/// use std::ops::Mul;
///
/// #[derive(Copy)]
/// #[derive(Copy, Clone)]
/// struct Foo;
///
/// impl Mul for Foo {
@ -327,7 +327,7 @@ mul_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
/// ```
/// use std::ops::Div;
///
/// #[derive(Copy)]
/// #[derive(Copy, Clone)]
/// struct Foo;
///
/// impl Div for Foo {
@ -381,7 +381,7 @@ div_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
/// ```
/// use std::ops::Rem;
///
/// #[derive(Copy)]
/// #[derive(Copy, Clone)]
/// struct Foo;
///
/// impl Rem for Foo {
@ -454,7 +454,7 @@ rem_float_impl! { f64, fmod }
/// ```
/// use std::ops::Neg;
///
/// #[derive(Copy)]
/// #[derive(Copy, Clone)]
/// struct Foo;
///
/// impl Neg for Foo {
@ -482,8 +482,10 @@ pub trait Neg {
fn neg(self) -> Self::Output;
}
macro_rules! neg_impl {
($($t:ty)*) => ($(
macro_rules! neg_impl_core {
($id:ident => $body:expr, $($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(unsigned_negation)]
impl Neg for $t {
@ -492,14 +494,28 @@ macro_rules! neg_impl {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn neg(self) -> $t { -self }
fn neg(self) -> $t { let $id = self; $body }
}
forward_ref_unop! { impl Neg, neg for $t }
)*)
}
neg_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
macro_rules! neg_impl_numeric {
($($t:ty)*) => { neg_impl_core!{ x => -x, $($t)*} }
}
macro_rules! neg_impl_unsigned {
($($t:ty)*) => {
neg_impl_core!{ x => {
#[cfg(stage0)]
use ::num::wrapping::WrappingOps;
!x.wrapping_add(1)
}, $($t)*} }
}
// neg_impl_unsigned! { usize u8 u16 u32 u64 }
neg_impl_numeric! { isize i8 i16 i32 i64 f32 f64 }
/// The `Not` trait is used to specify the functionality of unary `!`.
///
@ -511,7 +527,7 @@ neg_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
/// ```
/// use std::ops::Not;
///
/// #[derive(Copy)]
/// #[derive(Copy, Clone)]
/// struct Foo;
///
/// impl Not for Foo {
@ -565,7 +581,7 @@ not_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 }
/// ```
/// use std::ops::BitAnd;
///
/// #[derive(Copy)]
/// #[derive(Copy, Clone)]
/// struct Foo;
///
/// impl BitAnd for Foo {
@ -619,7 +635,7 @@ bitand_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 }
/// ```
/// use std::ops::BitOr;
///
/// #[derive(Copy)]
/// #[derive(Copy, Clone)]
/// struct Foo;
///
/// impl BitOr for Foo {
@ -673,7 +689,7 @@ bitor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 }
/// ```
/// use std::ops::BitXor;
///
/// #[derive(Copy)]
/// #[derive(Copy, Clone)]
/// struct Foo;
///
/// impl BitXor for Foo {
@ -727,7 +743,7 @@ bitxor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 }
/// ```
/// use std::ops::Shl;
///
/// #[derive(Copy)]
/// #[derive(Copy, Clone)]
/// struct Foo;
///
/// impl Shl<Foo> for Foo {
@ -799,7 +815,7 @@ shl_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize }
/// ```
/// use std::ops::Shr;
///
/// #[derive(Copy)]
/// #[derive(Copy, Clone)]
/// struct Foo;
///
/// impl Shr<Foo> for Foo {
@ -871,7 +887,7 @@ shr_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize }
/// ```
/// use std::ops::Index;
///
/// #[derive(Copy)]
/// #[derive(Copy, Clone)]
/// struct Foo;
/// struct Bar;
///
@ -912,7 +928,7 @@ pub trait Index<Idx: ?Sized> {
/// ```
/// use std::ops::{Index, IndexMut};
///
/// #[derive(Copy)]
/// #[derive(Copy, Clone)]
/// struct Foo;
/// struct Bar;
///

View File

@ -18,6 +18,7 @@
//!
//! Their definition should always match the ABI defined in `rustc::back::abi`.
use clone::Clone;
use marker::Copy;
use mem;
@ -63,6 +64,9 @@ pub struct Slice<T> {
}
impl<T> Copy for Slice<T> {}
impl<T> Clone for Slice<T> {
fn clone(&self) -> Slice<T> { *self }
}
/// The representation of a trait object like `&SomeTrait`.
///
@ -136,7 +140,7 @@ impl<T> Copy for Slice<T> {}
/// assert_eq!(synthesized.bar(), 457);
/// ```
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct TraitObject {
pub data: *mut (),
pub vtable: *mut (),

View File

@ -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);

View File

@ -855,7 +855,7 @@ impl TwoWaySearcher {
#[allow(dead_code)]
#[allow(deprecated)]
fn maximal_suffix(arr: &[u8], reversed: bool) -> (usize, usize) {
let mut left: usize = -1; // Corresponds to i in the paper
let mut left: usize = !0; // Corresponds to i in the paper
let mut right = 0; // Corresponds to j in the paper
let mut offset = 1; // Corresponds to k in the paper
let mut period = 1; // Corresponds to p in the paper
@ -1105,7 +1105,7 @@ static UTF8_CHAR_WIDTH: [u8; 256] = [
/// Struct that contains a `char` and the index of the first byte of
/// the next `char` in a string. This can be used as a data structure
/// for iterating over the UTF-8 bytes of a string.
#[derive(Copy)]
#[derive(Copy, Clone)]
#[unstable(feature = "str_char",
reason = "existence of this struct is uncertain as it is frequently \
able to be replaced with char.len_utf8() and/or \

View File

@ -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]

View File

@ -40,7 +40,7 @@ use std::string;
/// A piece is a portion of the format string which represents the next part
/// to emit. These are emitted as a stream by the `Parser` class.
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
pub enum Piece<'a> {
/// A literal string which should directly be emitted
String(&'a str),
@ -50,7 +50,7 @@ pub enum Piece<'a> {
}
/// Representation of an argument specification.
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
pub struct Argument<'a> {
/// Where to find this argument
pub position: Position<'a>,
@ -59,7 +59,7 @@ pub struct Argument<'a> {
}
/// Specification for the formatting of an argument in the format string.
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
pub struct FormatSpec<'a> {
/// Optionally specified character to fill alignment with
pub fill: Option<char>,
@ -78,7 +78,7 @@ pub struct FormatSpec<'a> {
}
/// Enum describing where an argument for a format can be located.
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
pub enum Position<'a> {
/// The argument will be in the next position. This is the default.
ArgumentNext,
@ -89,7 +89,7 @@ pub enum Position<'a> {
}
/// Enum of alignments which are supported.
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
pub enum Alignment {
/// The value will be aligned to the left.
AlignLeft,
@ -103,7 +103,7 @@ pub enum Alignment {
/// Various flags which can be applied to format strings. The meaning of these
/// flags is defined by the formatters themselves.
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
pub enum Flag {
/// A `+` will be used to denote positive numbers.
FlagSignPlus,
@ -119,7 +119,7 @@ pub enum Flag {
/// A count is used for the precision and width parameters of an integer, and
/// can reference either an argument or a literal integer.
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
pub enum Count<'a> {
/// The count is specified explicitly.
CountIs(usize),

View File

@ -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

View File

@ -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,

File diff suppressed because it is too large Load Diff

View File

@ -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,

View File

@ -29,7 +29,7 @@ use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample};
/// Generate Normal Random
/// Samples*](http://www.doornik.com/research/ziggurat.pdf). Nuffield
/// College, Oxford
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct Exp1(pub f64);
// This could be done via `-rng.gen::<f64>().ln()` but that is slower.
@ -68,7 +68,7 @@ impl Rand for Exp1 {
/// let v = exp.ind_sample(&mut rand::thread_rng());
/// println!("{} is from a Exp(2) distribution", v);
/// ```
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct Exp {
/// `lambda` stored as `1/lambda`, since this is what we scale by.
lambda_inverse: f64

View File

@ -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 },

View File

@ -28,7 +28,7 @@ use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample};
/// Generate Normal Random
/// Samples*](http://www.doornik.com/research/ziggurat.pdf). Nuffield
/// College, Oxford
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct StandardNormal(pub f64);
impl Rand for StandardNormal {
@ -85,7 +85,7 @@ impl Rand for StandardNormal {
/// let v = normal.ind_sample(&mut rand::thread_rng());
/// println!("{} is from a N(2, 9) distribution", v)
/// ```
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct Normal {
mean: f64,
std_dev: f64,
@ -134,7 +134,7 @@ impl IndependentSample<f64> for Normal {
/// let v = log_normal.ind_sample(&mut rand::thread_rng());
/// println!("{} is from an ln N(2, 9) distribution", v)
/// ```
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct LogNormal {
norm: Normal
}

View File

@ -134,7 +134,7 @@ pub trait Reseeder<R> {
/// Reseed an RNG using a `Default` instance. This reseeds by
/// replacing the RNG with the result of a `Default::default` call.
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct ReseedWithDefault;
impl<R: Rng + Default> Reseeder<R> for ReseedWithDefault {

View File

@ -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

View File

@ -113,7 +113,7 @@ declare_lint! {
}
/// Does nothing as a lint pass, but registers some `Lint`s
/// which are used by other parts of the compiler.
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct HardwiredLints;
impl LintPass for HardwiredLints {

View File

@ -41,7 +41,7 @@ pub use lint::context::{Context, LintStore, raw_emit_lint, check_crate, gather_a
GatherNodeLevels};
/// Specification of a single lint.
#[derive(Copy, Debug)]
#[derive(Copy, Clone, Debug)]
pub struct Lint {
/// A string identifier for the lint.
///

View File

@ -116,7 +116,7 @@ pub const tag_items_data_item_reexport_def_id: usize = 0x47;
pub const tag_items_data_item_reexport_name: usize = 0x48;
// used to encode crate_ctxt side tables
#[derive(Copy, PartialEq, FromPrimitive)]
#[derive(Copy, Clone, PartialEq, FromPrimitive)]
#[repr(usize)]
pub enum astencode_tag { // Reserves 0x50 -- 0x6f
tag_ast = 0x50,

View File

@ -29,7 +29,7 @@ use syntax::parse::token;
use std::collections::hash_map::HashMap;
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct MethodInfo {
pub name: ast::Name,
pub def_id: ast::DefId,

View File

@ -21,7 +21,7 @@ use std::path::{Path, PathBuf};
use util::fs as myfs;
use session::search_paths::{SearchPaths, PathKind};
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum FileMatch {
FileMatches,
FileDoesntMatch,

View File

@ -43,7 +43,7 @@ use syntax::parse::token;
// def-id will depend on where it originated from. Therefore, the conversion
// function is given an indicator of the source of the def-id. See
// astencode.rs for more information.
#[derive(Copy, Debug)]
#[derive(Copy, Clone, Debug)]
pub enum DefIdSource {
// Identifies a struct, trait, enum, etc.
NominalType,

View File

@ -25,7 +25,7 @@ struct CFGBuilder<'a, 'tcx: 'a> {
loop_scopes: Vec<LoopScope>,
}
#[derive(Copy)]
#[derive(Copy, Clone)]
struct LoopScope {
loop_id: ast::NodeId, // id of loop/while node
continue_index: CFGIndex, // where to go on a `loop`

View File

@ -24,7 +24,7 @@ pub struct CFG {
pub exit: CFGIndex,
}
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
pub enum CFGNodeData {
AST(ast::NodeId),
Entry,

View File

@ -76,7 +76,7 @@ bitflags! {
}
}
#[derive(Copy, Eq, PartialEq)]
#[derive(Copy, Clone, Eq, PartialEq)]
enum Mode {
Const,
Static,

View File

@ -21,7 +21,7 @@ enum Context {
Normal, Loop, Closure
}
#[derive(Copy)]
#[derive(Copy, Clone)]
struct CheckLoopVisitor<'a> {
sess: &'a Session,
cx: Context

View File

@ -128,7 +128,7 @@ enum Usefulness {
NotUseful
}
#[derive(Copy)]
#[derive(Copy, Clone)]
enum WitnessPreference {
ConstructWitness,
LeaveOutWitness

View File

@ -23,6 +23,7 @@ use middle::astconv_util::ast_ty_to_prim_ty;
use syntax::ast::{self, Expr};
use syntax::codemap::Span;
use syntax::feature_gate;
use syntax::parse::token::InternedString;
use syntax::ptr::P;
use syntax::{ast_map, ast_util, codemap};
@ -395,7 +396,7 @@ pub fn const_int_checked_neg<'a>(
pub fn const_uint_checked_neg<'a>(
a: u64, _e: &'a Expr, _opt_ety: Option<UintTy>) -> EvalResult {
// This always succeeds, and by definition, returns `(!a)+1`.
Ok(const_uint(-a))
Ok(const_uint((!a).wrapping_add(1)))
}
macro_rules! overflow_checking_body {
@ -594,7 +595,16 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
match try!(eval_const_expr_partial(tcx, &**inner, ety)) {
const_float(f) => const_float(-f),
const_int(n) => try!(const_int_checked_neg(n, e, expr_int_type)),
const_uint(n) => try!(const_uint_checked_neg(n, e, expr_uint_type)),
const_uint(i) => {
if !tcx.sess.features.borrow().negate_unsigned {
feature_gate::emit_feature_err(
&tcx.sess.parse_sess.span_diagnostic,
"negate_unsigned",
e.span,
"unary negation of unsigned integers may be removed in the future");
}
try!(const_uint_checked_neg(i, e, expr_uint_type))
}
const_str(_) => signal!(e, NegateOnString),
const_bool(_) => signal!(e, NegateOnBoolean),
const_binary(_) => signal!(e, NegateOnBinary),

View File

@ -28,7 +28,7 @@ use syntax::visit;
use syntax::print::{pp, pprust};
use util::nodemap::NodeMap;
#[derive(Copy, Debug)]
#[derive(Copy, Clone, Debug)]
pub enum EntryOrExit {
Entry,
Exit,

View File

@ -104,7 +104,7 @@ pub type DefMap = RefCell<NodeMap<PathResolution>>;
// within.
pub type ExportMap = NodeMap<Vec<Export>>;
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct Export {
pub name: ast::Name, // The name of the target.
pub def_id: ast::DefId, // The definition of the target.

View File

@ -22,7 +22,7 @@ use syntax::codemap::Span;
use syntax::visit;
use syntax::visit::Visitor;
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
enum UnsafeContext {
SafeContext,
UnsafeFn,

View File

@ -94,7 +94,7 @@ pub trait Delegate<'tcx> {
mode: MutateMode);
}
#[derive(Copy, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum LoanCause {
ClosureCapture(Span),
AddrOf,
@ -106,20 +106,20 @@ pub enum LoanCause {
MatchDiscriminant
}
#[derive(Copy, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum ConsumeMode {
Copy, // reference to x where x has a type that copies
Move(MoveReason), // reference to x where x has a type that moves
}
#[derive(Copy, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum MoveReason {
DirectRefMove,
PatBindingMove,
CaptureMove,
}
#[derive(Copy, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum MatchMode {
NonBindingMatch,
BorrowingMatch,
@ -127,7 +127,7 @@ pub enum MatchMode {
MovingMatch,
}
#[derive(Copy, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
enum TrackMatchMode {
Unknown,
Definite(MatchMode),
@ -194,14 +194,14 @@ impl TrackMatchMode {
}
}
#[derive(Copy, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum MutateMode {
Init,
JustWrite, // x = y
WriteAndRead, // x += y
}
#[derive(Copy)]
#[derive(Copy, Clone)]
enum OverloadedCallType {
FnOverloadedCall,
FnMutOverloadedCall,

View File

@ -66,13 +66,13 @@ pub struct NodeIndex(pub usize);
#[allow(non_upper_case_globals)]
pub const InvalidNodeIndex: NodeIndex = NodeIndex(usize::MAX);
#[derive(Copy, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct EdgeIndex(pub usize);
#[allow(non_upper_case_globals)]
pub const InvalidEdgeIndex: EdgeIndex = EdgeIndex(usize::MAX);
// Use a private field here to guarantee no more instances are created:
#[derive(Copy, Debug)]
#[derive(Copy, Clone, Debug)]
pub struct Direction { repr: usize }
#[allow(non_upper_case_globals)]
pub const Outgoing: Direction = Direction { repr: 0 };

View File

@ -290,7 +290,7 @@ pub enum RegionVariableOrigin {
BoundRegionInCoherence(ast::Name),
}
#[derive(Copy, Debug)]
#[derive(Copy, Clone, Debug)]
pub enum fixup_err {
unresolved_int_ty(IntVid),
unresolved_float_ty(FloatVid),

View File

@ -74,13 +74,13 @@ pub enum GenericKind<'tcx> {
Projection(ty::ProjectionTy<'tcx>),
}
#[derive(Copy, PartialEq, Eq, Hash)]
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub struct TwoRegions {
a: Region,
b: Region,
}
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
pub enum UndoLogEntry {
OpenSnapshot,
CommitedSnapshot,
@ -91,7 +91,7 @@ pub enum UndoLogEntry {
AddCombination(CombineMapType, TwoRegions)
}
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
pub enum CombineMapType {
Lub, Glb
}
@ -951,10 +951,10 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
// ______________________________________________________________________
#[derive(Copy, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
enum Classification { Expanding, Contracting }
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum VarValue { NoValue, Value(Region), ErrorValue }
struct VarData {

View File

@ -47,7 +47,7 @@ struct Delegate<'tcx>(PhantomData<&'tcx ()>);
type Relation = (RelationDir, ty::TyVid);
#[derive(Copy, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum RelationDir {
SubtypeOf, SupertypeOf, EqTo, BiTo
}

View File

@ -84,7 +84,7 @@ pub struct Node<K:UnifyKey> {
pub rank: usize,
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct Delegate<K>(PhantomData<K>);
// We can't use V:LatticeValue, much as I would like to,

View File

@ -46,7 +46,7 @@ macro_rules! lets_do_this {
$( $variant:ident, $name:expr, $method:ident; )*
) => {
#[derive(Copy, FromPrimitive, PartialEq, Eq, Hash)]
#[derive(Copy, Clone, FromPrimitive, PartialEq, Eq, Hash)]
pub enum LangItem {
$($variant),*
}

View File

@ -139,7 +139,7 @@ enum LoopKind<'a> {
WhileLoop(&'a Expr),
}
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
struct Variable(usize);
#[derive(Copy, PartialEq)]
@ -159,7 +159,7 @@ impl Clone for LiveNode {
}
}
#[derive(Copy, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
enum LiveNodeKind {
FreeVarNode(Span),
ExprNode(Span),
@ -245,13 +245,13 @@ struct CaptureInfo {
var_nid: NodeId
}
#[derive(Copy, Debug)]
#[derive(Copy, Clone, Debug)]
struct LocalInfo {
id: NodeId,
ident: ast::Ident
}
#[derive(Copy, Debug)]
#[derive(Copy, Clone, Debug)]
enum VarKind {
Arg(NodeId, ast::Ident),
Local(LocalInfo),
@ -534,7 +534,7 @@ fn invalid_users() -> Users {
}
}
#[derive(Copy)]
#[derive(Copy, Clone)]
struct Specials {
exit_ln: LiveNode,
fallthrough_ln: LiveNode,

View File

@ -199,7 +199,7 @@ pub type cmt<'tcx> = Rc<cmt_<'tcx>>;
// We pun on *T to mean both actual deref of a ptr as well
// as accessing of components:
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum deref_kind {
deref_ptr(PointerKind),
deref_interior(InteriorKind),
@ -263,6 +263,9 @@ pub struct MemCategorizationContext<'t,TYPER:'t> {
}
impl<'t,TYPER:'t> Copy for MemCategorizationContext<'t,TYPER> {}
impl<'t,TYPER:'t> Clone for MemCategorizationContext<'t,TYPER> {
fn clone(&self) -> MemCategorizationContext<'t,TYPER> { *self }
}
pub type McResult<T> = Result<T, ()>;

View File

@ -271,7 +271,7 @@ pub struct RegionMaps {
/// Carries the node id for the innermost block or match expression,
/// for building up the `var_map` which maps ids to the blocks in
/// which they were declared.
#[derive(PartialEq, Eq, Debug, Copy)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
enum InnermostDeclaringBlock {
None,
Block(ast::NodeId),
@ -296,7 +296,7 @@ impl InnermostDeclaringBlock {
/// Contextual information for declarations introduced by a statement
/// (i.e. `let`). It carries node-id's for statement and enclosing
/// block both, as well as the statement's index within the block.
#[derive(PartialEq, Eq, Debug, Copy)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
struct DeclaringStatementContext {
stmt_id: ast::NodeId,
block_id: ast::NodeId,
@ -312,7 +312,7 @@ impl DeclaringStatementContext {
}
}
#[derive(PartialEq, Eq, Debug, Copy)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
enum InnermostEnclosingExpr {
None,
Some(ast::NodeId),
@ -334,7 +334,7 @@ impl InnermostEnclosingExpr {
}
}
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct Context {
/// the root of the current region tree. This is typically the id
/// of the innermost fn body. Each fn forms its own disjoint tree

View File

@ -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.

View File

@ -99,7 +99,7 @@ pub enum MethodMatchResult {
MethodDidNotMatch,
}
#[derive(Copy, Debug)]
#[derive(Copy, Clone, Debug)]
pub enum MethodMatchedData {
// In the case of a precise match, we don't really need to store
// how the match was found. So don't.

View File

@ -262,7 +262,7 @@ pub struct field_ty {
// Contains information needed to resolve types and (in the future) look up
// the types of AST nodes.
#[derive(Copy, PartialEq, Eq, Hash)]
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub struct creader_cache_key {
pub cnum: CrateNum,
pub pos: usize,
@ -596,7 +596,7 @@ pub type ObjectCastMap<'tcx> = RefCell<NodeMap<ty::PolyTraitRef<'tcx>>>;
/// will push one or more such restriction into the
/// `transmute_restrictions` vector during `intrinsicck`. They are
/// then checked during `trans` by the fn `check_intrinsics`.
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct TransmuteRestriction<'tcx> {
/// The span whence the restriction comes.
pub span: Span,
@ -886,7 +886,7 @@ macro_rules! sty_debug_print {
// variable names.
mod inner {
use middle::ty;
#[derive(Copy)]
#[derive(Copy, Clone)]
struct DebugStat {
total: usize,
region_infer: usize,
@ -4003,7 +4003,7 @@ pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool {
///
/// The ordering of the cases is significant. They are sorted so that cmp::max
/// will keep the "more erroneous" of two values.
#[derive(Copy, PartialOrd, Ord, Eq, PartialEq, Debug)]
#[derive(Copy, Clone, PartialOrd, Ord, Eq, PartialEq, Debug)]
pub enum Representability {
Representable,
ContainsRecursive,
@ -4734,7 +4734,7 @@ pub fn expr_is_lval(tcx: &ctxt, e: &ast::Expr) -> bool {
/// two kinds of rvalues is an artifact of trans which reflects how we will
/// generate code for that kind of expression. See trans/expr.rs for more
/// information.
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum ExprKind {
LvalueExpr,
RvalueDpsExpr,
@ -5430,7 +5430,7 @@ pub fn item_path_str(cx: &ctxt, id: ast::DefId) -> String {
with_path(cx, id, |path| ast_map::path_to_string(path)).to_string()
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum DtorKind {
NoDtor,
TraitDtor(DefId, bool)
@ -7154,7 +7154,7 @@ pub fn make_substs_for_receiver_types<'tcx>(tcx: &ty::ctxt<'tcx>,
trait_ref.substs.clone().with_method(meth_tps, meth_regions)
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum CopyImplementationError {
FieldDoesNotImplementCopy(ast::Name),
VariantDoesNotImplementCopy(ast::Name),

View File

@ -247,7 +247,7 @@ pub fn basic_options() -> Options {
// users can have their own entry
// functions that don't start a
// scheduler
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
pub enum EntryFnType {
EntryMain,
EntryStart,

View File

@ -15,7 +15,7 @@ use target::TargetOptions;
use self::Arch::*;
#[allow(non_camel_case_types)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum Arch {
Armv7,
Armv7s,

View File

@ -334,7 +334,7 @@ impl ToInteriorKind for mc::InteriorKind {
}
}
#[derive(Copy, PartialEq, Eq, Hash, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub enum LoanPathElem {
LpDeref(mc::PointerKind), // `*LV` in README.md
LpInterior(InteriorKind), // `LV.f` in README.md
@ -500,13 +500,13 @@ pub struct BckError<'tcx> {
code: bckerr_code
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum AliasableViolationKind {
MutabilityViolation,
BorrowViolation(euv::LoanCause)
}
#[derive(Copy, Debug)]
#[derive(Copy, Clone, Debug)]
pub enum MovedValueUseKind {
MovedInUse,
MovedInCapture,

View File

@ -94,7 +94,7 @@ impl Clone for MovePathIndex {
const InvalidMovePathIndex: MovePathIndex = MovePathIndex(usize::MAX);
/// Index into `MoveData.moves`, used like a pointer
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
pub struct MoveIndex(usize);
impl MoveIndex {
@ -125,7 +125,7 @@ pub struct MovePath<'tcx> {
pub next_sibling: MovePathIndex,
}
#[derive(Copy, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum MoveKind {
Declared, // When declared, variables start out "moved".
MoveExpr, // Expression or binding that moves a variable
@ -133,7 +133,7 @@ pub enum MoveKind {
Captured // Closure creation that moves a value
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct Move {
/// Path being moved.
pub path: MovePathIndex,
@ -148,7 +148,7 @@ pub struct Move {
pub next_move: MoveIndex
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct Assignment {
/// Path being assigned.
pub path: MovePathIndex,
@ -160,7 +160,7 @@ pub struct Assignment {
pub span: Span,
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct VariantMatch {
/// downcast to the variant.
pub path: MovePathIndex,

View File

@ -26,7 +26,7 @@ use rustc::middle::dataflow;
use std::rc::Rc;
use std::borrow::IntoCow;
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub enum Variant {
Loans,
Moves,

View File

@ -182,7 +182,7 @@ fn make_input(free_matches: &[String]) -> Option<(Input, Option<PathBuf>)> {
}
// Whether to stop or continue compilation.
#[derive(Copy, Debug, Eq, PartialEq)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Compilation {
Stop,
Continue,
@ -265,7 +265,7 @@ pub trait CompilerCalls<'a> {
}
// CompilerCalls instance for a regular rustc build.
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct RustcDefaultCalls;
impl<'a> CompilerCalls<'a> for RustcDefaultCalls {

View File

@ -44,7 +44,7 @@ use std::option;
use std::path::PathBuf;
use std::str::FromStr;
#[derive(Copy, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum PpSourceMode {
PpmNormal,
PpmEveryBodyLoops,
@ -56,7 +56,7 @@ pub enum PpSourceMode {
}
#[derive(Copy, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum PpFlowGraphMode {
Default,
/// Drops the labels from the edges in the flowgraph output. This
@ -65,7 +65,7 @@ pub enum PpFlowGraphMode {
/// have become a pain to maintain.
UnlabelledEdges,
}
#[derive(Copy, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum PpMode {
PpmSource(PpSourceMode),
PpmFlowGraph(PpFlowGraphMode),

View File

@ -63,7 +63,7 @@ declare_lint! {
"suggest using `loop { }` instead of `while true { }`"
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct WhileTrue;
impl LintPass for WhileTrue {
@ -107,7 +107,7 @@ declare_lint! {
"shift exceeds the type's number of bits"
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct TypeLimits {
/// Id of the last visited negated expression
negated_expr_id: ast::NodeId,
@ -116,7 +116,7 @@ pub struct TypeLimits {
impl TypeLimits {
pub fn new() -> TypeLimits {
TypeLimits {
negated_expr_id: -1,
negated_expr_id: !0,
}
}
}
@ -431,7 +431,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ImproperCTypesVisitor<'a, 'tcx> {
}
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct ImproperCTypes;
impl LintPass for ImproperCTypes {
@ -474,7 +474,7 @@ declare_lint! {
"use of owned (Box type) heap memory"
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct BoxPointers;
impl BoxPointers {
@ -621,7 +621,7 @@ declare_lint! {
"detects attributes that were not used by the compiler"
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct UnusedAttributes;
impl LintPass for UnusedAttributes {
@ -662,7 +662,7 @@ declare_lint! {
"path statements with no effect"
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct PathStatements;
impl LintPass for PathStatements {
@ -696,7 +696,7 @@ declare_lint! {
"unused result of an expression in a statement"
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct UnusedResults;
impl LintPass for UnusedResults {
@ -764,7 +764,7 @@ declare_lint! {
"types, variants, traits and type parameters should have camel case names"
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct NonCamelCaseTypes;
impl NonCamelCaseTypes {
@ -874,7 +874,7 @@ declare_lint! {
"methods, functions, lifetime parameters and modules should have snake case names"
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct NonSnakeCase;
impl NonSnakeCase {
@ -1014,7 +1014,7 @@ declare_lint! {
"static constants should have uppercase identifiers"
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct NonUpperCaseGlobals;
impl NonUpperCaseGlobals {
@ -1072,7 +1072,7 @@ declare_lint! {
"`if`, `match`, `while` and `return` do not need parentheses"
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct UnusedParens;
impl UnusedParens {
@ -1166,7 +1166,7 @@ declare_lint! {
"unnecessary braces around an imported item"
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct UnusedImportBraces;
impl LintPass for UnusedImportBraces {
@ -1196,7 +1196,7 @@ declare_lint! {
"using `Struct { x: x }` instead of `Struct { x }`"
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct NonShorthandFieldPatterns;
impl LintPass for NonShorthandFieldPatterns {
@ -1233,7 +1233,7 @@ declare_lint! {
"unnecessary use of an `unsafe` block"
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct UnusedUnsafe;
impl LintPass for UnusedUnsafe {
@ -1258,7 +1258,7 @@ declare_lint! {
"usage of `unsafe` code"
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct UnsafeCode;
impl LintPass for UnsafeCode {
@ -1319,7 +1319,7 @@ declare_lint! {
"detect mut variables which don't need to be mutable"
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct UnusedMut;
impl UnusedMut {
@ -1388,7 +1388,7 @@ declare_lint! {
"detects unnecessary allocations that can be eliminated"
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct UnusedAllocation;
impl LintPass for UnusedAllocation {
@ -1625,7 +1625,7 @@ declare_lint! {
"detects potentially-forgotten implementations of `Copy`"
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct MissingCopyImplementations;
impl LintPass for MissingCopyImplementations {
@ -1740,7 +1740,7 @@ declare_lint! {
}
/// Checks for use of items with `#[deprecated]` attributes
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct Stability;
impl Stability {
@ -1800,7 +1800,7 @@ declare_lint! {
"functions that cannot return without calling themselves"
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct UnconditionalRecursion;
@ -1991,7 +1991,7 @@ declare_lint! {
"compiler plugin used as ordinary library in non-plugin crate"
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct PluginAsLibrary;
impl LintPass for PluginAsLibrary {
@ -2045,7 +2045,7 @@ declare_lint! {
"const items will not have their symbols exported"
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct InvalidNoMangleItems;
impl LintPass for InvalidNoMangleItems {
@ -2088,7 +2088,7 @@ impl LintPass for InvalidNoMangleItems {
}
/// Forbids using the `#[feature(...)]` attribute
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct UnstableFeatures;
declare_lint! {

View File

@ -18,7 +18,7 @@ use std::ptr;
use {ValueRef, TwineRef, DebugLocRef, DiagnosticInfoRef};
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum OptimizationDiagnosticKind {
OptimizationRemark,
OptimizationMissed,
@ -38,7 +38,7 @@ impl OptimizationDiagnosticKind {
}
#[allow(raw_pointer_derive)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct OptimizationDiagnostic {
pub kind: OptimizationDiagnosticKind,
pub pass_name: *const c_char,
@ -69,14 +69,13 @@ impl OptimizationDiagnostic {
}
}
#[derive(Copy, Clone)]
pub struct InlineAsmDiagnostic {
pub cookie: c_uint,
pub message: TwineRef,
pub instruction: ValueRef,
}
impl Copy for InlineAsmDiagnostic {}
impl InlineAsmDiagnostic {
unsafe fn unpack(di: DiagnosticInfoRef)
-> InlineAsmDiagnostic {
@ -96,7 +95,7 @@ impl InlineAsmDiagnostic {
}
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum Diagnostic {
Optimization(OptimizationDiagnostic),
InlineAsm(InlineAsmDiagnostic),

View File

@ -76,7 +76,7 @@ pub const False: Bool = 0 as Bool;
// Consts for the LLVM CallConv type, pre-cast to usize.
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
pub enum CallConv {
CCallConv = 0,
FastCallConv = 8,
@ -86,7 +86,7 @@ pub enum CallConv {
X86_64_Win64 = 79,
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum Visibility {
LLVMDefaultVisibility = 0,
HiddenVisibility = 1,
@ -97,7 +97,7 @@ pub enum Visibility {
// DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
// LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
// they've been removed in upstream LLVM commit r203866.
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum Linkage {
ExternalLinkage = 0,
AvailableExternallyLinkage = 1,
@ -113,7 +113,7 @@ pub enum Linkage {
}
#[repr(C)]
#[derive(Copy, Debug)]
#[derive(Copy, Clone, Debug)]
pub enum DiagnosticSeverity {
Error,
Warning,
@ -154,7 +154,7 @@ bitflags! {
#[repr(u64)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum OtherAttribute {
// The following are not really exposed in
// the LLVM c api so instead to add these
@ -175,13 +175,13 @@ pub enum OtherAttribute {
NonNullAttribute = 1 << 44,
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum SpecialAttribute {
DereferenceableAttribute(u64)
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum AttributeSet {
ReturnIndex = 0,
FunctionIndex = !0
@ -273,7 +273,7 @@ impl AttrBuilder {
}
// enum for the LLVM IntPredicate type
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum IntPredicate {
IntEQ = 32,
IntNE = 33,
@ -288,7 +288,7 @@ pub enum IntPredicate {
}
// enum for the LLVM RealPredicate type
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum RealPredicate {
RealPredicateFalse = 0,
RealOEQ = 1,
@ -310,7 +310,7 @@ pub enum RealPredicate {
// The LLVM TypeKind type - must stay in sync with the def of
// LLVMTypeKind in llvm/include/llvm-c/Core.h
#[derive(Copy, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
#[repr(C)]
pub enum TypeKind {
Void = 0,
@ -332,7 +332,7 @@ pub enum TypeKind {
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum AtomicBinOp {
AtomicXchg = 0,
AtomicAdd = 1,
@ -348,7 +348,7 @@ pub enum AtomicBinOp {
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum AtomicOrdering {
NotAtomic = 0,
Unordered = 1,
@ -362,13 +362,13 @@ pub enum AtomicOrdering {
// Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum FileType {
AssemblyFileType = 0,
ObjectFileType = 1
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum MetadataType {
MD_dbg = 0,
MD_tbaa = 1,
@ -385,13 +385,13 @@ pub enum MetadataType {
}
// Inline Asm Dialect
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum AsmDialect {
AD_ATT = 0,
AD_Intel = 1
}
#[derive(Copy, PartialEq, Clone)]
#[derive(Copy, Clone, PartialEq)]
#[repr(C)]
pub enum CodeGenOptLevel {
CodeGenLevelNone = 0,
@ -400,7 +400,7 @@ pub enum CodeGenOptLevel {
CodeGenLevelAggressive = 3,
}
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
#[repr(C)]
pub enum RelocMode {
RelocDefault = 0,
@ -410,7 +410,7 @@ pub enum RelocMode {
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum CodeGenModel {
CodeModelDefault = 0,
CodeModelJITDefault = 1,
@ -421,7 +421,7 @@ pub enum CodeGenModel {
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum DiagnosticKind {
DK_InlineAsm = 0,
DK_StackSize,
@ -533,7 +533,7 @@ pub mod debuginfo {
pub type DIEnumerator = DIDescriptor;
pub type DITemplateTypeParameter = DIDescriptor;
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum DIDescriptorFlags {
FlagPrivate = 1 << 0,
FlagProtected = 1 << 1,

View File

@ -61,7 +61,7 @@ use std::rc::Rc;
// Specifies how duplicates should be handled when adding a child item if
// another item exists with the same name in some namespace.
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
enum DuplicateCheckingMode {
ForbidDuplicateModules,
ForbidDuplicateTypesAndModules,
@ -70,7 +70,7 @@ enum DuplicateCheckingMode {
OverwriteDuplicates
}
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
enum NamespaceError {
NoError,
ModuleError,

View File

@ -107,7 +107,7 @@ mod record_exports;
mod build_reduced_graph;
mod resolve_imports;
#[derive(Copy)]
#[derive(Copy, Clone)]
struct BindingInfo {
span: Span,
binding_mode: BindingMode,
@ -116,14 +116,14 @@ struct BindingInfo {
// Map from the name in a pattern to its binding mode.
type BindingMap = HashMap<Name, BindingInfo>;
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
enum PatternBindingMode {
RefutableMode,
LocalIrrefutableMode,
ArgumentIrrefutableMode,
}
#[derive(Copy, PartialEq, Eq, Hash, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
enum Namespace {
TypeNS,
ValueNS
@ -280,7 +280,7 @@ enum FallbackSuggestion {
TraitMethod(String),
}
#[derive(Copy)]
#[derive(Copy, Clone)]
enum TypeParameters<'a> {
NoTypeParameters,
HasTypeParameters(
@ -297,7 +297,7 @@ enum TypeParameters<'a> {
// The rib kind controls the translation of local
// definitions (`DefLocal`) to upvars (`DefUpvar`).
#[derive(Copy, Debug)]
#[derive(Copy, Clone, Debug)]
enum RibKind {
// No translation needs to be applied.
NormalRibKind,
@ -319,7 +319,7 @@ enum RibKind {
ConstantItemRibKind
}
#[derive(Copy)]
#[derive(Copy, Clone)]
enum UseLexicalScopeFlag {
DontUseLexicalScope,
UseLexicalScope
@ -330,7 +330,7 @@ enum ModulePrefixResult {
PrefixFound(Rc<Module>, usize)
}
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
enum NameSearchType {
/// We're doing a name search in order to resolve a `use` directive.
ImportSearch,
@ -340,7 +340,7 @@ enum NameSearchType {
PathSearch,
}
#[derive(Copy)]
#[derive(Copy, Clone)]
enum BareIdentifierPatternResolution {
FoundStructOrEnumVariant(Def, LastPrivate),
FoundConst(Def, LastPrivate),
@ -372,7 +372,7 @@ enum ParentLink {
}
/// The type of module this is.
#[derive(Copy, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
enum ModuleKind {
NormalModuleKind,
TraitModuleKind,
@ -3527,7 +3527,7 @@ pub struct CrateMap {
pub glob_map: Option<GlobMap>
}
#[derive(PartialEq,Copy)]
#[derive(PartialEq,Copy, Clone)]
pub enum MakeGlobMap {
Yes,
No

View File

@ -37,7 +37,7 @@ use std::rc::Rc;
/// Contains data for specific types of import directives.
#[derive(Copy,Debug)]
#[derive(Copy, Clone,Debug)]
pub enum ImportDirectiveSubclass {
SingleImport(Name /* target */, Name /* source */),
GlobImport

View File

@ -62,7 +62,7 @@ macro_rules! svec {
})
}
#[derive(Copy, Debug, Eq, PartialEq)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Row {
Variable,
Enum,

View File

@ -228,7 +228,7 @@ use syntax::codemap::Span;
use syntax::fold::Folder;
use syntax::ptr::P;
#[derive(Copy, Debug)]
#[derive(Copy, Clone, Debug)]
struct ConstantExpr<'a>(&'a ast::Expr);
impl<'a> ConstantExpr<'a> {
@ -311,7 +311,7 @@ impl<'a, 'tcx> Opt<'a, 'tcx> {
}
}
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
pub enum BranchKind {
NoBranch,
Single,

View File

@ -830,7 +830,7 @@ fn load_discr(bcx: Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr)
let bits = machine::llbitsize_of_real(bcx.ccx(), llty);
assert!(bits <= 64);
let bits = bits as usize;
let mask = (-1u64 >> (64 - bits)) as Disr;
let mask = (!0u64 >> (64 - bits)) as Disr;
// For a (max) discr of -1, max will be `-1 as usize`, which overflows.
// However, that is fine here (it would still represent the full range),
if (max.wrapping_add(1)) & mask == min & mask {

View File

@ -868,7 +868,7 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>(
_ => unreachable!(),
};
let minus_one = ICmp(bcx, llvm::IntEQ, rhs,
C_integral(llty, -1, false), debug_loc);
C_integral(llty, !0, false), debug_loc);
with_cond(bcx, minus_one, |bcx| {
let is_min = ICmp(bcx, llvm::IntEQ, lhs,
C_integral(llty, min, true), debug_loc);
@ -1388,7 +1388,7 @@ pub fn new_fn_ctxt<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
common::validate_substs(param_substs);
debug!("new_fn_ctxt(path={}, id={}, param_substs={})",
if id == -1 {
if id == !0 {
"".to_string()
} else {
ccx.tcx().map.path_to_string(id).to_string()
@ -2112,7 +2112,7 @@ pub fn llvm_linkage_by_name(name: &str) -> Option<Linkage> {
/// Enum describing the origin of an LLVM `Value`, for linkage purposes.
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum ValueOrigin {
/// The LLVM `Value` is in this context because the corresponding item was
/// assigned to the current compilation unit.

View File

@ -13,7 +13,7 @@ use llvm::BasicBlockRef;
use trans::value::{Users, Value};
use std::iter::{Filter, Map};
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct BasicBlock(pub BasicBlockRef);
pub type Preds = Map<Filter<Users, fn(&Value) -> bool>, fn(Value) -> BasicBlock>;

View File

@ -60,7 +60,7 @@ use syntax::ast;
use syntax::ast_map;
use syntax::ptr::P;
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct MethodData {
pub llfn: ValueRef,
pub llself: ValueRef,
@ -1110,7 +1110,7 @@ pub fn trans_args<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
bcx
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum AutorefArg {
DontAutorefArg,
DoAutorefArg(ast::NodeId)

View File

@ -153,7 +153,7 @@ pub struct CleanupScope<'blk, 'tcx: 'blk> {
cached_landing_pad: Option<BasicBlockRef>,
}
#[derive(Copy, Debug)]
#[derive(Copy, Clone, Debug)]
pub struct CustomScopeIndex {
index: usize
}
@ -184,14 +184,14 @@ impl<'blk, 'tcx: 'blk> fmt::Debug for CleanupScopeKind<'blk, 'tcx> {
}
}
#[derive(Copy, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum EarlyExitLabel {
UnwindExit,
ReturnExit,
LoopExit(ast::NodeId, usize)
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct CachedEarlyExit {
label: EarlyExitLabel,
cleanup_block: BasicBlockRef,
@ -209,7 +209,7 @@ pub trait Cleanup<'tcx> {
pub type CleanupObj<'tcx> = Box<Cleanup<'tcx>+'tcx>;
#[derive(Copy, Debug)]
#[derive(Copy, Clone, Debug)]
pub enum ScopeId {
AstScope(ast::NodeId),
CustomScope(CustomScopeIndex)
@ -982,7 +982,7 @@ impl EarlyExitLabel {
///////////////////////////////////////////////////////////////////////////
// Cleanup types
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct DropValue<'tcx> {
is_immediate: bool,
must_unwind: bool,
@ -1021,12 +1021,12 @@ impl<'tcx> Cleanup<'tcx> for DropValue<'tcx> {
}
}
#[derive(Copy, Debug)]
#[derive(Copy, Clone, Debug)]
pub enum Heap {
HeapExchange
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct FreeValue<'tcx> {
ptr: ValueRef,
heap: Heap,
@ -1061,7 +1061,7 @@ impl<'tcx> Cleanup<'tcx> for FreeValue<'tcx> {
}
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct FreeSlice {
ptr: ValueRef,
size: ValueRef,
@ -1098,7 +1098,7 @@ impl<'tcx> Cleanup<'tcx> for FreeSlice {
}
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct LifetimeEnd {
ptr: ValueRef,
}

View File

@ -343,7 +343,7 @@ pub fn gensym_name(name: &str) -> PathElem {
*
*/
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct NodeIdAndSpan {
pub id: ast::NodeId,
pub span: Span,
@ -1225,7 +1225,7 @@ pub fn drain_fulfillment_cx<'a,'tcx,T>(infcx: &infer::InferCtxt<'a,'tcx>,
}
// Key used to lookup values supplied for type parameters in an expr.
#[derive(Copy, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum ExprOrMethodCall {
// Type parameters for a path like `None::<int>`
ExprId(ast::NodeId),

View File

@ -459,7 +459,7 @@ impl<'tcx> LocalCrateContext<'tcx> {
CrateContext {
shared: shared,
local: self,
index: -1 as usize,
index: !0 as usize,
}
}
}

View File

@ -172,7 +172,7 @@ impl Drop for Rvalue {
fn drop(&mut self) { }
}
#[derive(Copy, PartialEq, Eq, Hash, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub enum RvalueMode {
/// `val` is a pointer to the actual value (and thus has type *T)
ByRef,

View File

@ -2382,7 +2382,7 @@ impl<'tcx> VariantMemberDescriptionFactory<'tcx> {
}
}
#[derive(Copy)]
#[derive(Copy, Clone)]
enum EnumDiscriminantInfo {
RegularDiscriminant(DIType),
OptimizedDiscriminant,
@ -3106,7 +3106,7 @@ impl MetadataCreationResult {
}
}
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
enum InternalDebugLocation {
KnownLocation { scope: DIScope, line: usize, col: usize },
UnknownLocation

View File

@ -94,7 +94,7 @@ use std::rc::Rc;
// These are passed around by the code generating functions to track the
// destination of a computation's value.
#[derive(Copy, PartialEq)]
#[derive(Copy, Clone, PartialEq)]
pub enum Dest {
SaveIn(ValueRef),
Ignore,
@ -2038,7 +2038,7 @@ fn float_cast(bcx: Block,
} else { llsrc };
}
#[derive(Copy, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum cast_kind {
cast_pointer,
cast_integral,

View File

@ -57,7 +57,7 @@ mod basic_block;
mod llrepr;
mod cleanup;
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct ModuleTranslation {
pub llcx: ContextRef,
pub llmod: ModuleRef,

View File

@ -33,7 +33,7 @@ use util::ppaux::ty_to_string;
use syntax::ast;
use syntax::parse::token::InternedString;
#[derive(Copy)]
#[derive(Copy, Clone)]
struct VecTypes<'tcx> {
unit_ty: Ty<'tcx>,
llunit_ty: Type

View File

@ -14,7 +14,7 @@ use trans::basic_block::BasicBlock;
use trans::common::Block;
use libc::c_uint;
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct Value(pub ValueRef);
macro_rules! opt_val { ($e:expr) => (
@ -125,7 +125,7 @@ impl Value {
}
/// Wrapper for LLVM UseRef
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct Use(UseRef);
impl Use {

View File

@ -52,7 +52,7 @@ pub enum MethodError {
// A pared down enum describing just the places from which a method
// candidate can arise. Used for error reporting only.
#[derive(Copy, PartialOrd, Ord, PartialEq, Eq)]
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq)]
pub enum CandidateSource {
ImplSource(ast::DefId),
TraitSource(/* trait id */ ast::DefId),

View File

@ -109,7 +109,7 @@ pub enum PickAdjustment {
AutoRef(ast::Mutability, Box<PickAdjustment>),
}
#[derive(PartialEq, Eq, Copy)]
#[derive(PartialEq, Eq, Copy, Clone)]
pub enum Mode {
// An expression of the form `receiver.method_name(...)`.
// Autoderefs are performed on `receiver`, lookup is done based on the

View File

@ -266,7 +266,7 @@ fn type_derefs_to_local<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
}).2.is_some()
}
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct TraitInfo {
pub def_id: ast::DefId,
}

View File

@ -120,6 +120,7 @@ use syntax::attr::AttrMetaMethods;
use syntax::ast::{self, DefId, Visibility};
use syntax::ast_util::{self, local_def};
use syntax::codemap::{self, Span};
use syntax::feature_gate;
use syntax::owned_slice::OwnedSlice;
use syntax::parse::token;
use syntax::print::pprust;
@ -204,7 +205,7 @@ struct CastCheck<'tcx> {
/// When type-checking an expression, we propagate downward
/// whatever type hint we are able in the form of an `Expectation`.
#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum Expectation<'tcx> {
/// We know nothing about what type this expression should have.
NoExpectation,
@ -1951,14 +1952,14 @@ impl<'a, 'tcx> RegionScope for FnCtxt<'a, 'tcx> {
}
}
#[derive(Copy, Debug, PartialEq, Eq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum LvaluePreference {
PreferMutLvalue,
NoPreference
}
/// Whether `autoderef` requires types to resolve.
#[derive(Copy, Debug, PartialEq, Eq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum UnresolvedTypeAction {
/// Produce an error and return `ty_err` whenever a type cannot
/// be resolved (i.e. it is `ty_infer`).
@ -3258,6 +3259,15 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
tcx.lang_items.neg_trait(),
expr, &**oprnd, oprnd_t, unop);
}
if let ty::ty_uint(_) = oprnd_t.sty {
if !tcx.sess.features.borrow().negate_unsigned {
feature_gate::emit_feature_err(
&tcx.sess.parse_sess.span_diagnostic,
"negate_unsigned",
expr.span,
"unary negation of unsigned integers may be removed in the future");
}
}
}
}
}

View File

@ -249,11 +249,6 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
&fcx.inh.param_env.free_substs,
&trait_ref);
if fcx.tcx().lang_items.copy_trait() == Some(trait_ref.def_id) {
// This is checked in coherence.
return
}
// We are stricter on the trait-ref in an impl than the
// self-type. In particular, we enforce region
// relationships. The reason for this is that (at least

View File

@ -350,7 +350,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
///////////////////////////////////////////////////////////////////////////
// Resolution reason.
#[derive(Copy)]
#[derive(Copy, Clone)]
enum ResolveReason {
ResolvingExpr(Span),
ResolvingLocal(Span),

View File

@ -135,7 +135,7 @@ struct ItemCtxt<'a,'tcx:'a> {
param_bounds: &'a (GetTypeParameterBounds<'tcx>+'a),
}
#[derive(Copy, PartialEq, Eq)]
#[derive(Copy, Clone, PartialEq, Eq)]
enum AstConvRequest {
GetItemTypeScheme(ast::DefId),
GetTraitDef(ast::DefId),

View File

@ -40,7 +40,7 @@ pub trait RegionScope {
// A scope in which all regions must be explicitly named. This is used
// for types that appear in structs and so on.
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct ExplicitRscope;
impl RegionScope for ExplicitRscope {

View File

@ -295,10 +295,10 @@ pub fn infer_variance(tcx: &ty::ctxt) {
type VarianceTermPtr<'a> = &'a VarianceTerm<'a>;
#[derive(Copy, Debug)]
#[derive(Copy, Clone, Debug)]
struct InferredIndex(usize);
#[derive(Copy)]
#[derive(Copy, Clone)]
enum VarianceTerm<'a> {
ConstantTerm(ty::Variance),
TransformTerm(VarianceTermPtr<'a>, VarianceTermPtr<'a>),
@ -336,7 +336,7 @@ struct TermsContext<'a, 'tcx: 'a> {
inferred_infos: Vec<InferredInfo<'a>> ,
}
#[derive(Copy, Debug, PartialEq)]
#[derive(Copy, Clone, Debug, PartialEq)]
enum ParamKind {
TypeParam,
RegionParam,
@ -560,7 +560,7 @@ struct ConstraintContext<'a, 'tcx: 'a> {
/// Declares that the variable `decl_id` appears in a location with
/// variance `variance`.
#[derive(Copy)]
#[derive(Copy, Clone)]
struct Constraint<'a> {
inferred: InferredIndex,
variance: &'a VarianceTerm<'a>,

View File

@ -30,19 +30,19 @@ use html::render::{cache, CURRENT_LOCATION_KEY};
/// Helper to render an optional visibility with a space after it (if the
/// visibility is preset)
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct VisSpace(pub Option<ast::Visibility>);
/// Similarly to VisSpace, this structure is used to render a function style with a
/// space after it.
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct UnsafetySpace(pub ast::Unsafety);
/// Wrapper struct for properly emitting a method declaration.
pub struct Method<'a>(pub &'a clean::SelfTy, pub &'a clean::FnDecl);
/// Similar to VisSpace, but used for mutability
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct MutableSpace(pub clean::Mutability);
/// Similar to VisSpace, but used for mutability
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct RawMutableSpace(pub clean::Mutability);
/// Wrapper struct for properly emitting the stability level.
pub struct Stability<'a>(pub &'a Option<clean::Stability>);

View File

@ -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,

View File

@ -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,

Some files were not shown because too many files have changed in this diff Show More