From bff462302b3e0a8f68c14cad2806c7ff5005364e Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sat, 24 Jan 2015 16:36:30 -0500 Subject: [PATCH] cleanup: s/impl Copy/#[derive(Copy)]/g --- src/compiletest/common.rs | 7 ++----- src/doc/reference.md | 2 +- src/etc/unicode.py | 4 +--- src/libcore/ops.rs | 6 ++---- src/librustc_llvm/diagnostic.rs | 4 ++-- src/libstd/os.rs | 8 ++++---- src/libunicode/lib.rs | 1 + src/libunicode/tables.rs | 5 +---- src/libunicode/u_str.rs | 4 +--- src/test/auxiliary/issue-14422.rs | 3 +-- src/test/auxiliary/issue13213aux.rs | 5 ++--- src/test/auxiliary/method_self_arg1.rs | 3 +-- src/test/auxiliary/method_self_arg2.rs | 3 +-- src/test/auxiliary/xcrate_unit_struct.rs | 15 +++++---------- src/test/bench/noise.rs | 3 +-- src/test/bench/shootout-chameneos-redux.rs | 6 ++---- src/test/bench/shootout-fannkuch-redux.rs | 6 ++---- src/test/bench/shootout-fasta-redux.rs | 3 +-- src/test/bench/shootout-k-nucleotide.rs | 4 +--- src/test/bench/shootout-nbody.rs | 3 +-- .../borrowck-borrow-from-owned-ptr.rs | 6 ++---- .../borrowck-borrow-from-stack-variable.rs | 6 ++---- src/test/compile-fail/borrowck-use-mut-borrow.rs | 3 +-- src/test/compile-fail/dst-index.rs | 6 ++---- src/test/compile-fail/kindck-copy.rs | 3 +-- .../debuginfo/generic-method-on-generic-struct.rs | 3 +-- src/test/debuginfo/method-on-enum.rs | 3 +-- src/test/debuginfo/method-on-generic-struct.rs | 3 +-- src/test/debuginfo/method-on-struct.rs | 3 +-- src/test/debuginfo/method-on-trait.rs | 3 +-- src/test/debuginfo/method-on-tuple-struct.rs | 3 +-- src/test/debuginfo/self-in-default-method.rs | 3 +-- .../debuginfo/self-in-generic-default-method.rs | 3 +-- src/test/pretty/block-disambig.rs | 3 +-- .../run-make/extern-fn-with-packed-struct/test.rs | 4 +--- src/test/run-pass/borrowck-univariant-enum.rs | 3 +-- .../run-pass/builtin-superkinds-in-metadata.rs | 3 +-- src/test/run-pass/cell-does-not-clone.rs | 3 +-- .../class-impl-very-parameterized-trait.rs | 4 +--- src/test/run-pass/coherence-impl-in-fn.rs | 2 +- src/test/run-pass/coherence-where-clause.rs | 4 +--- .../run-pass/const-nullary-univariant-enum.rs | 3 +-- src/test/run-pass/dst-struct-sole.rs | 4 +--- src/test/run-pass/dst-struct.rs | 4 +--- src/test/run-pass/dst-trait.rs | 8 ++------ src/test/run-pass/empty-tag.rs | 4 +--- src/test/run-pass/enum-discrim-width-stuff.rs | 3 +-- src/test/run-pass/explicit-self-generic.rs | 3 +-- src/test/run-pass/export-unexported-dep.rs | 3 +-- src/test/run-pass/expr-copy.rs | 3 +-- src/test/run-pass/expr-if-struct.rs | 7 ++----- src/test/run-pass/expr-match-struct.rs | 7 ++----- src/test/run-pass/exterior.rs | 3 +-- src/test/run-pass/extern-pass-TwoU16s.rs | 4 +--- src/test/run-pass/extern-pass-TwoU32s.rs | 4 +--- src/test/run-pass/extern-pass-TwoU64s.rs | 4 +--- src/test/run-pass/extern-pass-TwoU8s.rs | 4 +--- src/test/run-pass/foreign-fn-with-byval.rs | 3 +-- src/test/run-pass/generic-fn.rs | 3 +-- src/test/run-pass/guards-not-exhaustive.rs | 3 +-- src/test/run-pass/guards.rs | 3 +-- src/test/run-pass/hrtb-opt-in-copy.rs | 3 +-- src/test/run-pass/issue-12860.rs | 4 +--- src/test/run-pass/issue-19100.rs | 3 +-- src/test/run-pass/issue-2288.rs | 3 +-- src/test/run-pass/issue-2633.rs | 6 ++---- src/test/run-pass/issue-3121.rs | 7 +++---- src/test/run-pass/issue-3563-3.rs | 9 +++------ src/test/run-pass/issue-3743.rs | 3 +-- src/test/run-pass/issue-3753.rs | 6 ++---- src/test/run-pass/issue-5688.rs | 3 +-- src/test/run-pass/match-arm-statics.rs | 3 +-- src/test/run-pass/method-self-arg-trait.rs | 3 +-- src/test/run-pass/method-self-arg.rs | 3 +-- src/test/run-pass/monomorphize-abi-alignment.rs | 11 +++-------- src/test/run-pass/multidispatch1.rs | 3 +-- src/test/run-pass/multidispatch2.rs | 3 +-- src/test/run-pass/newtype.rs | 6 ++---- src/test/run-pass/out-pointer-aliasing.rs | 3 +-- src/test/run-pass/overloaded-autoderef-order.rs | 6 ++---- src/test/run-pass/packed-struct-vec.rs | 4 +--- src/test/run-pass/rec-tup.rs | 3 +-- src/test/run-pass/rec.rs | 6 +----- src/test/run-pass/regions-dependent-addr-of.rs | 3 +-- .../regions-early-bound-used-in-bound-method.rs | 3 +-- .../regions-early-bound-used-in-type-param.rs | 3 +-- src/test/run-pass/regions-mock-tcx.rs | 14 ++++---------- .../run-pass/self-in-mut-slot-immediate-value.rs | 3 +-- src/test/run-pass/simd-generics.rs | 6 +++--- src/test/run-pass/small-enum-range-edge.rs | 6 ++---- src/test/run-pass/struct-return.rs | 6 ++---- src/test/run-pass/structured-compare.rs | 4 +--- src/test/run-pass/tag-variant-disr-val.rs | 3 +-- src/test/run-pass/trait-coercion-generic.rs | 3 +-- src/test/run-pass/trait-coercion.rs | 3 +-- .../run-pass/typeclasses-eq-example-static.rs | 4 +--- src/test/run-pass/typeclasses-eq-example.rs | 4 +--- src/test/run-pass/ufcs-explicit-self.rs | 6 ++---- .../run-pass/unboxed-closures-monomorphization.rs | 4 +--- 99 files changed, 136 insertions(+), 289 deletions(-) diff --git a/src/compiletest/common.rs b/src/compiletest/common.rs index b2e852a36f7..40e123e5323 100644 --- a/src/compiletest/common.rs +++ b/src/compiletest/common.rs @@ -13,7 +13,7 @@ use std::fmt; use std::str::FromStr; #[cfg(stage0)] // NOTE: remove impl after snapshot -#[derive(Clone, PartialEq, Show)] +#[derive(Clone, Copy, PartialEq, Show)] pub enum Mode { CompileFail, RunFail, @@ -26,7 +26,7 @@ pub enum Mode { } #[cfg(not(stage0))] // NOTE: remove cfg after snapshot -#[derive(Clone, PartialEq, Debug)] +#[derive(Clone, Copy, PartialEq, Debug)] pub enum Mode { CompileFail, RunFail, @@ -38,9 +38,6 @@ pub enum Mode { Codegen } - -impl Copy for Mode {} - impl FromStr for Mode { fn from_str(s: &str) -> Option { match s { diff --git a/src/doc/reference.md b/src/doc/reference.md index 3cbd71a1eb3..61deb4f934a 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -1680,8 +1680,8 @@ specific type. Implementations are defined with the keyword `impl`. ``` +# #[derive(Copy)] # struct Point {x: f64, y: f64}; -# impl Copy for Point {} # type Surface = i32; # struct BoundingBox {x: f64, y: f64, width: f64, height: f64}; # trait Shape { fn draw(&self, Surface); fn bounding_box(&self) -> BoundingBox; } diff --git a/src/etc/unicode.py b/src/etc/unicode.py index 4a0bb992fd9..4952b99ab46 100755 --- a/src/etc/unicode.py +++ b/src/etc/unicode.py @@ -392,15 +392,13 @@ def emit_grapheme_module(f, grapheme_table, grapheme_cats): use core::slice; #[allow(non_camel_case_types)] - #[derive(Clone)] + #[derive(Clone, Copy)] pub enum GraphemeCat { """) for cat in grapheme_cats + ["Any"]: f.write(" GC_" + cat + ",\n") f.write(""" } - impl Copy for GraphemeCat {} - fn bsearch_range_value_table(c: char, r: &'static [(char, char, GraphemeCat)]) -> GraphemeCat { use core::cmp::Ordering::{Equal, Less, Greater}; match r.binary_search(|&(lo, hi, _)| { diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 372596cdd44..49936396b8c 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -445,10 +445,9 @@ rem_float_impl! { f64, fmod } /// ``` /// use std::ops::Neg; /// +/// #[derive(Copy)] /// struct Foo; /// -/// impl Copy for Foo {} -/// /// impl Neg for Foo { /// type Output = Foo; /// @@ -522,10 +521,9 @@ neg_uint_impl! { u64, i64 } /// ``` /// use std::ops::Not; /// +/// #[derive(Copy)] /// struct Foo; /// -/// impl Copy for Foo {} -/// /// impl Not for Foo { /// type Output = Foo; /// diff --git a/src/librustc_llvm/diagnostic.rs b/src/librustc_llvm/diagnostic.rs index db2a569cdef..cd2d2bcef0f 100644 --- a/src/librustc_llvm/diagnostic.rs +++ b/src/librustc_llvm/diagnostic.rs @@ -37,6 +37,8 @@ impl OptimizationDiagnosticKind { } } +#[allow(raw_pointer_derive)] +#[derive(Copy)] pub struct OptimizationDiagnostic { pub kind: OptimizationDiagnosticKind, pub pass_name: *const c_char, @@ -45,8 +47,6 @@ pub struct OptimizationDiagnostic { pub message: TwineRef, } -impl Copy for OptimizationDiagnostic {} - impl OptimizationDiagnostic { unsafe fn unpack(kind: OptimizationDiagnosticKind, di: DiagnosticInfoRef) -> OptimizationDiagnostic { diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 985a8cd32e2..ca3c7e93774 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -813,6 +813,8 @@ pub struct MemoryMap { } /// Type of memory map +#[allow(raw_pointer_derive)] +#[derive(Copy)] pub enum MemoryMapKind { /// Virtual memory map. Usually used to change the permissions of a given /// chunk of memory. Corresponds to `VirtualAlloc` on Windows. @@ -823,9 +825,9 @@ pub enum MemoryMapKind { MapVirtual } -impl Copy for MemoryMapKind {} - /// Options the memory map is created with +#[allow(raw_pointer_derive)] +#[derive(Copy)] pub enum MapOption { /// The memory should be readable MapReadable, @@ -852,8 +854,6 @@ pub enum MapOption { MapNonStandardFlags(c_int), } -impl Copy for MapOption {} - /// Possible errors when creating a map. #[derive(Copy, Show)] pub enum MapError { diff --git a/src/libunicode/lib.rs b/src/libunicode/lib.rs index fbe912ced90..d812d249c5b 100644 --- a/src/libunicode/lib.rs +++ b/src/libunicode/lib.rs @@ -82,4 +82,5 @@ mod std { pub use core::clone; pub use core::cmp; pub use core::fmt; + pub use core::marker; } diff --git a/src/libunicode/tables.rs b/src/libunicode/tables.rs index 3f089d62e4e..a38f911688d 100644 --- a/src/libunicode/tables.rs +++ b/src/libunicode/tables.rs @@ -7801,13 +7801,12 @@ pub mod charwidth { } pub mod grapheme { - use core::marker::Copy; use core::slice::SliceExt; pub use self::GraphemeCat::*; use core::result::Result::{Ok, Err}; #[allow(non_camel_case_types)] - #[derive(Clone)] + #[derive(Clone, Copy)] pub enum GraphemeCat { GC_LV, GC_LVT, @@ -7821,8 +7820,6 @@ pub mod grapheme { GC_Any, } - impl Copy for GraphemeCat {} - fn bsearch_range_value_table(c: char, r: &'static [(char, char, GraphemeCat)]) -> GraphemeCat { use core::cmp::Ordering::{Equal, Less, Greater}; match r.binary_search_by(|&(lo, hi, _)| { diff --git a/src/libunicode/u_str.rs b/src/libunicode/u_str.rs index 66cdf03a51e..cf19e019f03 100644 --- a/src/libunicode/u_str.rs +++ b/src/libunicode/u_str.rs @@ -410,7 +410,7 @@ pub struct Utf16Items<'a> { iter: slice::Iter<'a, u16> } /// The possibilities for values decoded from a `u16` stream. -#[derive(PartialEq, Eq, Clone, Show)] +#[derive(Copy, PartialEq, Eq, Clone, Show)] pub enum Utf16Item { /// A valid codepoint. ScalarValue(char), @@ -418,8 +418,6 @@ pub enum Utf16Item { LoneSurrogate(u16) } -impl Copy for Utf16Item {} - impl Utf16Item { /// Convert `self` to a `char`, taking `LoneSurrogate`s to the /// replacement character (U+FFFD). diff --git a/src/test/auxiliary/issue-14422.rs b/src/test/auxiliary/issue-14422.rs index 9ecb1195de0..3e23698397b 100644 --- a/src/test/auxiliary/issue-14422.rs +++ b/src/test/auxiliary/issue-14422.rs @@ -23,10 +23,9 @@ mod src { pub mod hidden_core { use super::aliases::B; + #[derive(Copy)] pub struct A; - impl Copy for A {} - pub fn make() -> B { A } impl A { diff --git a/src/test/auxiliary/issue13213aux.rs b/src/test/auxiliary/issue13213aux.rs index cf8d0c167a1..227fab73048 100644 --- a/src/test/auxiliary/issue13213aux.rs +++ b/src/test/auxiliary/issue13213aux.rs @@ -13,19 +13,18 @@ pub use private::P; +#[derive(Copy)] pub struct S { p: P, } mod private { + #[derive(Copy)] pub struct P { p: i32, } pub const THREE: P = P { p: 3 }; - impl Copy for P {} } pub static A: S = S { p: private::THREE }; -impl Copy for S {} - diff --git a/src/test/auxiliary/method_self_arg1.rs b/src/test/auxiliary/method_self_arg1.rs index 5865a8f467b..643442363a4 100644 --- a/src/test/auxiliary/method_self_arg1.rs +++ b/src/test/auxiliary/method_self_arg1.rs @@ -17,10 +17,9 @@ static mut COUNT: u64 = 1; pub fn get_count() -> u64 { unsafe { COUNT } } +#[derive(Copy)] pub struct Foo; -impl Copy for Foo {} - impl Foo { pub fn foo(self, x: &Foo) { unsafe { COUNT *= 2; } diff --git a/src/test/auxiliary/method_self_arg2.rs b/src/test/auxiliary/method_self_arg2.rs index a28a877a374..fd99da87e6b 100644 --- a/src/test/auxiliary/method_self_arg2.rs +++ b/src/test/auxiliary/method_self_arg2.rs @@ -17,10 +17,9 @@ static mut COUNT: u64 = 1; pub fn get_count() -> u64 { unsafe { COUNT } } +#[derive(Copy)] pub struct Foo; -impl Copy for Foo {} - impl Foo { pub fn run_trait(self) { unsafe { COUNT *= 17; } diff --git a/src/test/auxiliary/xcrate_unit_struct.rs b/src/test/auxiliary/xcrate_unit_struct.rs index 5a918db1cfa..7ae36554079 100644 --- a/src/test/auxiliary/xcrate_unit_struct.rs +++ b/src/test/auxiliary/xcrate_unit_struct.rs @@ -12,33 +12,28 @@ // used by the rpass test +#[derive(Copy)] pub struct Struct; -impl Copy for Struct {} - +#[derive(Copy)] pub enum Unit { UnitVariant, Argument(Struct) } -impl Copy for Unit {} - +#[derive(Copy)] pub struct TupleStruct(pub uint, pub &'static str); -impl Copy for TupleStruct {} - // used by the cfail test +#[derive(Copy)] pub struct StructWithFields { foo: int, } -impl Copy for StructWithFields {} - +#[derive(Copy)] pub enum EnumWithVariants { EnumVariant, EnumVariantArg(int) } -impl Copy for EnumWithVariants {} - diff --git a/src/test/bench/noise.rs b/src/test/bench/noise.rs index 3c7efb0336a..75edd64fb2e 100644 --- a/src/test/bench/noise.rs +++ b/src/test/bench/noise.rs @@ -16,13 +16,12 @@ use std::f32::consts::PI; use std::num::Float; use std::rand::{Rng, StdRng}; +#[derive(Copy)] struct Vec2 { x: f32, y: f32, } -impl Copy for Vec2 {} - fn lerp(a: f32, b: f32, v: f32) -> f32 { a * (1.0 - v) + b * v } fn smooth(v: f32) -> f32 { v * v * (3.0 - 2.0 * v) } diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index 33995a9be74..12dc224a82f 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -54,14 +54,13 @@ fn print_complements() { } } +#[derive(Copy)] enum Color { Red, Yellow, Blue, } -impl Copy for Color {} - impl fmt::Show for Color { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let str = match *self { @@ -73,13 +72,12 @@ impl fmt::Show for Color { } } +#[derive(Copy)] struct CreatureInfo { name: uint, color: Color } -impl Copy for CreatureInfo {} - fn show_color_list(set: Vec) -> String { let mut out = String::new(); for col in set.iter() { diff --git a/src/test/bench/shootout-fannkuch-redux.rs b/src/test/bench/shootout-fannkuch-redux.rs index daabae88bdf..42b41d955fb 100644 --- a/src/test/bench/shootout-fannkuch-redux.rs +++ b/src/test/bench/shootout-fannkuch-redux.rs @@ -61,12 +61,12 @@ fn next_permutation(perm: &mut [i32], count: &mut [i32]) { } } +#[derive(Copy)] struct P { p: [i32; 16], } -impl Copy for P {} - +#[derive(Copy)] struct Perm { cnt: [i32; 16], fact: [u32; 16], @@ -75,8 +75,6 @@ struct Perm { perm: P, } -impl Copy for Perm {} - impl Perm { fn new(n: u32) -> Perm { let mut fact = [1; 16]; diff --git a/src/test/bench/shootout-fasta-redux.rs b/src/test/bench/shootout-fasta-redux.rs index 9e5618579e4..c09fad533e1 100644 --- a/src/test/bench/shootout-fasta-redux.rs +++ b/src/test/bench/shootout-fasta-redux.rs @@ -103,13 +103,12 @@ fn sum_and_scale(a: &'static [AminoAcid]) -> Vec { result } +#[derive(Copy)] struct AminoAcid { c: u8, p: f32, } -impl Copy for AminoAcid {} - struct RepeatFasta<'a, W:'a> { alu: &'static str, out: &'a mut W diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 5256e607d20..4149726e4bb 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -60,11 +60,9 @@ static OCCURRENCES: [&'static str;5] = [ // Code implementation -#[derive(PartialEq, PartialOrd, Ord, Eq)] +#[derive(Copy, PartialEq, PartialOrd, Ord, Eq)] struct Code(u64); -impl Copy for Code {} - impl Code { fn hash(&self) -> u64 { let Code(ret) = *self; diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index c65f98e545b..1b3d66ca7d2 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -94,14 +94,13 @@ static BODIES: [Planet;N_BODIES] = [ }, ]; +#[derive(Copy)] struct Planet { x: f64, y: f64, z: f64, vx: f64, vy: f64, vz: f64, mass: f64, } -impl Copy for Planet {} - fn advance(bodies: &mut [Planet;N_BODIES], dt: f64, steps: int) { for _ in range(0, steps) { let mut b_slice = bodies.as_mut_slice(); diff --git a/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs b/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs index 397c55a502a..99618c6bf56 100644 --- a/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs +++ b/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs @@ -9,20 +9,18 @@ // except according to those terms. +#[derive(Copy)] struct Foo { bar1: Bar, bar2: Bar } -impl Copy for Foo {} - +#[derive(Copy)] struct Bar { int1: isize, int2: isize, } -impl Copy for Bar {} - fn make_foo() -> Box { panic!() } fn borrow_same_field_twice_mut_mut() { diff --git a/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs b/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs index ae4c09c59d7..849c98e122e 100644 --- a/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs +++ b/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs @@ -8,20 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[derive(Copy)] struct Foo { bar1: Bar, bar2: Bar } -impl Copy for Foo {} - +#[derive(Copy)] struct Bar { int1: isize, int2: isize, } -impl Copy for Bar {} - fn make_foo() -> Foo { panic!() } fn borrow_same_field_twice_mut_mut() { diff --git a/src/test/compile-fail/borrowck-use-mut-borrow.rs b/src/test/compile-fail/borrowck-use-mut-borrow.rs index 42e12622b69..52f89da10b9 100644 --- a/src/test/compile-fail/borrowck-use-mut-borrow.rs +++ b/src/test/compile-fail/borrowck-use-mut-borrow.rs @@ -10,10 +10,9 @@ #![feature(box_syntax)] +#[derive(Copy)] struct A { a: isize, b: isize } -impl Copy for A {} - struct B { a: isize, b: Box } fn var_copy_after_var_borrow() { diff --git a/src/test/compile-fail/dst-index.rs b/src/test/compile-fail/dst-index.rs index 876c98298dc..91f34320482 100644 --- a/src/test/compile-fail/dst-index.rs +++ b/src/test/compile-fail/dst-index.rs @@ -14,10 +14,9 @@ use std::ops::Index; use std::fmt::Debug; +#[derive(Copy)] struct S; -impl Copy for S {} - impl Index for S { type Output = str; @@ -26,10 +25,9 @@ impl Index for S { } } +#[derive(Copy)] struct T; -impl Copy for T {} - impl Index for T { type Output = Debug + 'static; diff --git a/src/test/compile-fail/kindck-copy.rs b/src/test/compile-fail/kindck-copy.rs index 4398be4b212..56f83d93008 100644 --- a/src/test/compile-fail/kindck-copy.rs +++ b/src/test/compile-fail/kindck-copy.rs @@ -17,13 +17,12 @@ fn assert_copy() { } trait Dummy { } +#[derive(Copy)] struct MyStruct { x: isize, y: isize, } -impl Copy for MyStruct {} - struct MyNoncopyStruct { x: Box, } diff --git a/src/test/debuginfo/generic-method-on-generic-struct.rs b/src/test/debuginfo/generic-method-on-generic-struct.rs index 66cd73622ff..d94baa637c2 100644 --- a/src/test/debuginfo/generic-method-on-generic-struct.rs +++ b/src/test/debuginfo/generic-method-on-generic-struct.rs @@ -115,6 +115,7 @@ #![feature(box_syntax)] #![omit_gdb_pretty_printer_section] +#[derive(Copy)] struct Struct { x: T } @@ -150,5 +151,3 @@ fn main() { fn zzz() {()} -impl Copy for Struct {} - diff --git a/src/test/debuginfo/method-on-enum.rs b/src/test/debuginfo/method-on-enum.rs index 732e1d5c500..f8912636971 100644 --- a/src/test/debuginfo/method-on-enum.rs +++ b/src/test/debuginfo/method-on-enum.rs @@ -116,6 +116,7 @@ #![feature(box_syntax)] #![omit_gdb_pretty_printer_section] +#[derive(Copy)] enum Enum { Variant1 { x: u16, y: u16 }, Variant2 (u32) @@ -152,5 +153,3 @@ fn main() { fn zzz() {()} -impl Copy for Enum {} - diff --git a/src/test/debuginfo/method-on-generic-struct.rs b/src/test/debuginfo/method-on-generic-struct.rs index c1785951e23..fa93eaba279 100644 --- a/src/test/debuginfo/method-on-generic-struct.rs +++ b/src/test/debuginfo/method-on-generic-struct.rs @@ -116,6 +116,7 @@ #![feature(box_syntax)] #![omit_gdb_pretty_printer_section] +#[derive(Copy)] struct Struct { x: T } @@ -151,5 +152,3 @@ fn main() { fn zzz() {()} -impl Copy for Struct {} - diff --git a/src/test/debuginfo/method-on-struct.rs b/src/test/debuginfo/method-on-struct.rs index d88a32b8475..56f79da709e 100644 --- a/src/test/debuginfo/method-on-struct.rs +++ b/src/test/debuginfo/method-on-struct.rs @@ -116,6 +116,7 @@ #![feature(box_syntax)] #![omit_gdb_pretty_printer_section] +#[derive(Copy)] struct Struct { x: int } @@ -151,5 +152,3 @@ fn main() { fn zzz() {()} -impl Copy for Struct {} - diff --git a/src/test/debuginfo/method-on-trait.rs b/src/test/debuginfo/method-on-trait.rs index 5622d17225b..4fff301eb5f 100644 --- a/src/test/debuginfo/method-on-trait.rs +++ b/src/test/debuginfo/method-on-trait.rs @@ -116,6 +116,7 @@ #![feature(box_syntax)] #![omit_gdb_pretty_printer_section] +#[derive(Copy)] struct Struct { x: int } @@ -157,5 +158,3 @@ fn main() { fn zzz() {()} -impl Copy for Struct {} - diff --git a/src/test/debuginfo/method-on-tuple-struct.rs b/src/test/debuginfo/method-on-tuple-struct.rs index 02f7808221a..7c4ce211f2f 100644 --- a/src/test/debuginfo/method-on-tuple-struct.rs +++ b/src/test/debuginfo/method-on-tuple-struct.rs @@ -116,6 +116,7 @@ #![feature(box_syntax)] #![omit_gdb_pretty_printer_section] +#[derive(Copy)] struct TupleStruct(int, f64); impl TupleStruct { @@ -149,5 +150,3 @@ fn main() { fn zzz() {()} -impl Copy for TupleStruct {} - diff --git a/src/test/debuginfo/self-in-default-method.rs b/src/test/debuginfo/self-in-default-method.rs index a1074e490f7..e494973b975 100644 --- a/src/test/debuginfo/self-in-default-method.rs +++ b/src/test/debuginfo/self-in-default-method.rs @@ -115,6 +115,7 @@ #![feature(box_syntax)] #![omit_gdb_pretty_printer_section] +#[derive(Copy)] struct Struct { x: int } @@ -151,5 +152,3 @@ fn main() { fn zzz() {()} -impl Copy for Struct {} - diff --git a/src/test/debuginfo/self-in-generic-default-method.rs b/src/test/debuginfo/self-in-generic-default-method.rs index f0da6e26870..0fe74015611 100644 --- a/src/test/debuginfo/self-in-generic-default-method.rs +++ b/src/test/debuginfo/self-in-generic-default-method.rs @@ -115,6 +115,7 @@ #![feature(box_syntax)] #![omit_gdb_pretty_printer_section] +#[derive(Copy)] struct Struct { x: int } @@ -152,5 +153,3 @@ fn main() { fn zzz() {()} -impl Copy for Struct {} - diff --git a/src/test/pretty/block-disambig.rs b/src/test/pretty/block-disambig.rs index db01bc94e32..1e286c236a5 100644 --- a/src/test/pretty/block-disambig.rs +++ b/src/test/pretty/block-disambig.rs @@ -19,10 +19,9 @@ fn test1() { let val = &0i; { } *val; } fn test2() -> int { let val = &0i; { } *val } +#[derive(Copy)] struct S { eax: int } -impl Copy for S {} - fn test3() { let regs = &Cell::new(S {eax: 0}); match true { true => { } _ => { } } diff --git a/src/test/run-make/extern-fn-with-packed-struct/test.rs b/src/test/run-make/extern-fn-with-packed-struct/test.rs index b38db4c9eb2..3e3f4c5948e 100644 --- a/src/test/run-make/extern-fn-with-packed-struct/test.rs +++ b/src/test/run-make/extern-fn-with-packed-struct/test.rs @@ -9,15 +9,13 @@ // except according to those terms. #[repr(packed)] -#[derive(PartialEq, Show)] +#[derive(Copy, PartialEq, Show)] struct Foo { a: i8, b: i16, c: i8 } -impl Copy for Foo {} - #[link(name = "test", kind = "static")] extern { fn foo(f: Foo) -> Foo; diff --git a/src/test/run-pass/borrowck-univariant-enum.rs b/src/test/run-pass/borrowck-univariant-enum.rs index df4106c9844..d95594119b6 100644 --- a/src/test/run-pass/borrowck-univariant-enum.rs +++ b/src/test/run-pass/borrowck-univariant-enum.rs @@ -11,12 +11,11 @@ use std::cell::Cell; +#[derive(Copy)] enum newtype { newvar(int) } -impl Copy for newtype {} - pub fn main() { // Test that borrowck treats enums with a single variant diff --git a/src/test/run-pass/builtin-superkinds-in-metadata.rs b/src/test/run-pass/builtin-superkinds-in-metadata.rs index 382caa83c61..c115415bb9b 100644 --- a/src/test/run-pass/builtin-superkinds-in-metadata.rs +++ b/src/test/run-pass/builtin-superkinds-in-metadata.rs @@ -17,10 +17,9 @@ extern crate trait_superkinds_in_metadata; use trait_superkinds_in_metadata::{RequiresRequiresShareAndSend, RequiresShare}; use trait_superkinds_in_metadata::{RequiresCopy}; +#[derive(Copy)] struct X(T); -impl Copy for X {} - impl RequiresShare for X { } impl RequiresRequiresShareAndSend for X { } diff --git a/src/test/run-pass/cell-does-not-clone.rs b/src/test/run-pass/cell-does-not-clone.rs index 6455f1e4bb2..ea1d0b625fc 100644 --- a/src/test/run-pass/cell-does-not-clone.rs +++ b/src/test/run-pass/cell-does-not-clone.rs @@ -10,6 +10,7 @@ use std::cell::Cell; +#[derive(Copy)] struct Foo { x: int } @@ -24,8 +25,6 @@ impl Clone for Foo { } } -impl Copy for Foo {} - pub fn main() { let x = Cell::new(Foo { x: 22 }); let _y = x.get(); diff --git a/src/test/run-pass/class-impl-very-parameterized-trait.rs b/src/test/run-pass/class-impl-very-parameterized-trait.rs index 629cf7c4ef7..993f27d061d 100644 --- a/src/test/run-pass/class-impl-very-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-very-parameterized-trait.rs @@ -11,11 +11,9 @@ use std::cmp; -#[derive(Show)] +#[derive(Copy, Show)] enum cat_type { tuxedo, tabby, tortoiseshell } -impl Copy for cat_type {} - impl cmp::PartialEq for cat_type { fn eq(&self, other: &cat_type) -> bool { ((*self) as uint) == ((*other) as uint) diff --git a/src/test/run-pass/coherence-impl-in-fn.rs b/src/test/run-pass/coherence-impl-in-fn.rs index df0012e07ec..6edd7390f0f 100644 --- a/src/test/run-pass/coherence-impl-in-fn.rs +++ b/src/test/run-pass/coherence-impl-in-fn.rs @@ -9,8 +9,8 @@ // except according to those terms. pub fn main() { + #[derive(Copy)] enum x { foo } - impl Copy for x {} impl ::std::cmp::PartialEq for x { fn eq(&self, other: &x) -> bool { (*self) as int == (*other) as int diff --git a/src/test/run-pass/coherence-where-clause.rs b/src/test/run-pass/coherence-where-clause.rs index 78b603690fd..d9c292a3e0b 100644 --- a/src/test/run-pass/coherence-where-clause.rs +++ b/src/test/run-pass/coherence-where-clause.rs @@ -23,13 +23,11 @@ impl MyTrait for T } } -#[derive(Clone,Debug,PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq)] struct MyType { dummy: uint } -impl Copy for MyType {} - impl MyTrait for MyType { fn get(&self) -> MyType { (*self).clone() } } diff --git a/src/test/run-pass/const-nullary-univariant-enum.rs b/src/test/run-pass/const-nullary-univariant-enum.rs index 9a1a5de9360..86b194f2eb3 100644 --- a/src/test/run-pass/const-nullary-univariant-enum.rs +++ b/src/test/run-pass/const-nullary-univariant-enum.rs @@ -8,12 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[derive(Copy)] enum Foo { Bar = 0xDEADBEE } -impl Copy for Foo {} - static X: Foo = Foo::Bar; pub fn main() { diff --git a/src/test/run-pass/dst-struct-sole.rs b/src/test/run-pass/dst-struct-sole.rs index c7f37da157f..74f4b9e9233 100644 --- a/src/test/run-pass/dst-struct-sole.rs +++ b/src/test/run-pass/dst-struct-sole.rs @@ -30,11 +30,9 @@ fn foo2(x: &Fat<[T]>) { assert!(x.ptr[1].to_bar() == bar); } -#[derive(PartialEq,Eq)] +#[derive(Copy, PartialEq, Eq)] struct Bar; -impl Copy for Bar {} - trait ToBar { fn to_bar(&self) -> Bar; } diff --git a/src/test/run-pass/dst-struct.rs b/src/test/run-pass/dst-struct.rs index b2092e745a1..fa2af29431c 100644 --- a/src/test/run-pass/dst-struct.rs +++ b/src/test/run-pass/dst-struct.rs @@ -49,11 +49,9 @@ fn foo3(x: &Fat>) { } -#[derive(PartialEq,Eq)] +#[derive(Copy, PartialEq, Eq)] struct Bar; -impl Copy for Bar {} - trait ToBar { fn to_bar(&self) -> Bar; } diff --git a/src/test/run-pass/dst-trait.rs b/src/test/run-pass/dst-trait.rs index 627d197879d..fd1c7247e37 100644 --- a/src/test/run-pass/dst-trait.rs +++ b/src/test/run-pass/dst-trait.rs @@ -17,18 +17,14 @@ struct Fat { ptr: T } -#[derive(PartialEq,Eq)] +#[derive(Copy, PartialEq, Eq)] struct Bar; -impl Copy for Bar {} - -#[derive(PartialEq,Eq)] +#[derive(Copy, PartialEq, Eq)] struct Bar1 { f: int } -impl Copy for Bar1 {} - trait ToBar { fn to_bar(&self) -> Bar; fn to_val(&self) -> int; diff --git a/src/test/run-pass/empty-tag.rs b/src/test/run-pass/empty-tag.rs index d9201746440..35c394cf535 100644 --- a/src/test/run-pass/empty-tag.rs +++ b/src/test/run-pass/empty-tag.rs @@ -8,11 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[derive(Show)] +#[derive(Copy, Show)] enum chan { chan_t, } -impl Copy for chan {} - impl PartialEq for chan { fn eq(&self, other: &chan) -> bool { ((*self) as uint) == ((*other) as uint) diff --git a/src/test/run-pass/enum-discrim-width-stuff.rs b/src/test/run-pass/enum-discrim-width-stuff.rs index 73559af79de..c323bff254d 100644 --- a/src/test/run-pass/enum-discrim-width-stuff.rs +++ b/src/test/run-pass/enum-discrim-width-stuff.rs @@ -12,13 +12,12 @@ macro_rules! check { ($m:ident, $t:ty, $v:expr) => {{ mod $m { use std::mem::size_of; - #[derive(Show)] + #[derive(Copy, Show)] enum E { V = $v, A = 0 } static C: E = E::V; - impl Copy for E {} pub fn check() { assert_eq!(size_of::(), size_of::<$t>()); assert_eq!(E::V as $t, $v as $t); diff --git a/src/test/run-pass/explicit-self-generic.rs b/src/test/run-pass/explicit-self-generic.rs index a2aaaa235e4..066a5f9580a 100644 --- a/src/test/run-pass/explicit-self-generic.rs +++ b/src/test/run-pass/explicit-self-generic.rs @@ -11,10 +11,9 @@ #![allow(unknown_features)] #![feature(box_syntax)] +#[derive(Copy)] struct LM { resize_at: uint, size: uint } -impl Copy for LM {} - enum HashMap { HashMap_(LM) } diff --git a/src/test/run-pass/export-unexported-dep.rs b/src/test/run-pass/export-unexported-dep.rs index 48e9d9dea22..807d28feb6e 100644 --- a/src/test/run-pass/export-unexported-dep.rs +++ b/src/test/run-pass/export-unexported-dep.rs @@ -13,10 +13,9 @@ mod foo { // not exported + #[derive(Copy)] enum t { t1, t2, } - impl Copy for t {} - impl PartialEq for t { fn eq(&self, other: &t) -> bool { ((*self) as uint) == ((*other) as uint) diff --git a/src/test/run-pass/expr-copy.rs b/src/test/run-pass/expr-copy.rs index 6e9ba4f8f41..6c6c5085749 100644 --- a/src/test/run-pass/expr-copy.rs +++ b/src/test/run-pass/expr-copy.rs @@ -13,10 +13,9 @@ fn f(arg: &mut A) { arg.a = 100; } +#[derive(Copy)] struct A { a: int } -impl Copy for A {} - pub fn main() { let mut x = A {a: 10}; f(&mut x); diff --git a/src/test/run-pass/expr-if-struct.rs b/src/test/run-pass/expr-if-struct.rs index 62994068a9e..f1457829d03 100644 --- a/src/test/run-pass/expr-if-struct.rs +++ b/src/test/run-pass/expr-if-struct.rs @@ -14,20 +14,17 @@ // Tests for if as expressions returning nominal types +#[derive(Copy)] struct I { i: int } -impl Copy for I {} - fn test_rec() { let rs = if true { I {i: 100} } else { I {i: 101} }; assert_eq!(rs.i, 100); } -#[derive(Show)] +#[derive(Copy, Show)] enum mood { happy, sad, } -impl Copy for mood {} - impl PartialEq for mood { fn eq(&self, other: &mood) -> bool { ((*self) as uint) == ((*other) as uint) diff --git a/src/test/run-pass/expr-match-struct.rs b/src/test/run-pass/expr-match-struct.rs index 8512cf63cdd..1b5a33dff3d 100644 --- a/src/test/run-pass/expr-match-struct.rs +++ b/src/test/run-pass/expr-match-struct.rs @@ -13,20 +13,17 @@ // Tests for match as expressions resulting in struct types +#[derive(Copy)] struct R { i: int } -impl Copy for R {} - fn test_rec() { let rs = match true { true => R {i: 100}, _ => panic!() }; assert_eq!(rs.i, 100); } -#[derive(Show)] +#[derive(Copy, Show)] enum mood { happy, sad, } -impl Copy for mood {} - impl PartialEq for mood { fn eq(&self, other: &mood) -> bool { ((*self) as uint) == ((*other) as uint) diff --git a/src/test/run-pass/exterior.rs b/src/test/run-pass/exterior.rs index 2ca5f430a2a..bba8cbdb83d 100644 --- a/src/test/run-pass/exterior.rs +++ b/src/test/run-pass/exterior.rs @@ -11,10 +11,9 @@ use std::cell::Cell; +#[derive(Copy)] struct Point {x: int, y: int, z: int} -impl Copy for Point {} - fn f(p: &Cell) { assert!((p.get().z == 12)); p.set(Point {x: 10, y: 11, z: 13}); diff --git a/src/test/run-pass/extern-pass-TwoU16s.rs b/src/test/run-pass/extern-pass-TwoU16s.rs index a38fe6d6d50..f7aef2e59c9 100644 --- a/src/test/run-pass/extern-pass-TwoU16s.rs +++ b/src/test/run-pass/extern-pass-TwoU16s.rs @@ -11,13 +11,11 @@ // Test a foreign function that accepts and returns a struct // by value. -#[derive(PartialEq, Show)] +#[derive(Copy, PartialEq, Show)] pub struct TwoU16s { one: u16, two: u16 } -impl Copy for TwoU16s {} - #[link(name = "rust_test_helpers")] extern { pub fn rust_dbg_extern_identity_TwoU16s(v: TwoU16s) -> TwoU16s; diff --git a/src/test/run-pass/extern-pass-TwoU32s.rs b/src/test/run-pass/extern-pass-TwoU32s.rs index 30b035d56b6..8e13017fdbf 100644 --- a/src/test/run-pass/extern-pass-TwoU32s.rs +++ b/src/test/run-pass/extern-pass-TwoU32s.rs @@ -11,13 +11,11 @@ // Test a foreign function that accepts and returns a struct // by value. -#[derive(PartialEq, Show)] +#[derive(Copy, PartialEq, Show)] pub struct TwoU32s { one: u32, two: u32 } -impl Copy for TwoU32s {} - #[link(name = "rust_test_helpers")] extern { pub fn rust_dbg_extern_identity_TwoU32s(v: TwoU32s) -> TwoU32s; diff --git a/src/test/run-pass/extern-pass-TwoU64s.rs b/src/test/run-pass/extern-pass-TwoU64s.rs index 8ca05f09a9c..b95eb7974b6 100644 --- a/src/test/run-pass/extern-pass-TwoU64s.rs +++ b/src/test/run-pass/extern-pass-TwoU64s.rs @@ -11,13 +11,11 @@ // Test a foreign function that accepts and returns a struct // by value. -#[derive(PartialEq, Show)] +#[derive(Copy, PartialEq, Show)] pub struct TwoU64s { one: u64, two: u64 } -impl Copy for TwoU64s {} - #[link(name = "rust_test_helpers")] extern { pub fn rust_dbg_extern_identity_TwoU64s(v: TwoU64s) -> TwoU64s; diff --git a/src/test/run-pass/extern-pass-TwoU8s.rs b/src/test/run-pass/extern-pass-TwoU8s.rs index 42a1ce78870..d5c727be4bc 100644 --- a/src/test/run-pass/extern-pass-TwoU8s.rs +++ b/src/test/run-pass/extern-pass-TwoU8s.rs @@ -11,13 +11,11 @@ // Test a foreign function that accepts and returns a struct // by value. -#[derive(PartialEq, Show)] +#[derive(Copy, PartialEq, Show)] pub struct TwoU8s { one: u8, two: u8 } -impl Copy for TwoU8s {} - #[link(name = "rust_test_helpers")] extern { pub fn rust_dbg_extern_identity_TwoU8s(v: TwoU8s) -> TwoU8s; diff --git a/src/test/run-pass/foreign-fn-with-byval.rs b/src/test/run-pass/foreign-fn-with-byval.rs index 5d6815fc3c7..09317abce92 100644 --- a/src/test/run-pass/foreign-fn-with-byval.rs +++ b/src/test/run-pass/foreign-fn-with-byval.rs @@ -8,14 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[derive(Copy)] pub struct S { x: u64, y: u64, z: u64, } -impl Copy for S {} - #[link(name = "rust_test_helpers")] extern { pub fn get_x(x: S) -> u64; diff --git a/src/test/run-pass/generic-fn.rs b/src/test/run-pass/generic-fn.rs index a341bfe22eb..8da8c680847 100644 --- a/src/test/run-pass/generic-fn.rs +++ b/src/test/run-pass/generic-fn.rs @@ -12,10 +12,9 @@ fn id(x: T) -> T { return x; } +#[derive(Copy)] struct Triple {x: int, y: int, z: int} -impl Copy for Triple {} - pub fn main() { let mut x = 62; let mut y = 63; diff --git a/src/test/run-pass/guards-not-exhaustive.rs b/src/test/run-pass/guards-not-exhaustive.rs index b1bc40b662d..addd6a63836 100644 --- a/src/test/run-pass/guards-not-exhaustive.rs +++ b/src/test/run-pass/guards-not-exhaustive.rs @@ -8,10 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[derive(Copy)] enum Q { R(Option) } -impl Copy for Q {} - fn xyzzy(q: Q) -> uint { match q { Q::R(S) if S.is_some() => { 0 } diff --git a/src/test/run-pass/guards.rs b/src/test/run-pass/guards.rs index 0157423863c..e7031ae147e 100644 --- a/src/test/run-pass/guards.rs +++ b/src/test/run-pass/guards.rs @@ -8,10 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[derive(Copy)] struct Pair { x: int, y: int } -impl Copy for Pair {} - pub fn main() { let a: int = match 10i { x if x < 7 => { 1i } x if x < 11 => { 2i } 10 => { 3i } _ => { 4i } }; diff --git a/src/test/run-pass/hrtb-opt-in-copy.rs b/src/test/run-pass/hrtb-opt-in-copy.rs index 8eaf8427bfd..9c9f95f61e9 100644 --- a/src/test/run-pass/hrtb-opt-in-copy.rs +++ b/src/test/run-pass/hrtb-opt-in-copy.rs @@ -29,10 +29,9 @@ enum TyS<'tcx> { Boop(marker::InvariantLifetime<'tcx>) } +#[derive(Copy)] enum Bar<'tcx> { Baz(Foo>) } -impl<'tcx> Copy for Bar<'tcx> { } - fn main() { } diff --git a/src/test/run-pass/issue-12860.rs b/src/test/run-pass/issue-12860.rs index 8a95723c735..a05cc9c0f74 100644 --- a/src/test/run-pass/issue-12860.rs +++ b/src/test/run-pass/issue-12860.rs @@ -13,15 +13,13 @@ extern crate collections; use std::collections::HashSet; -#[derive(PartialEq, Eq, Hash)] +#[derive(Copy, PartialEq, Eq, Hash)] struct XYZ { x: int, y: int, z: int } -impl Copy for XYZ {} - fn main() { let mut connected = HashSet::new(); let mut border = HashSet::new(); diff --git a/src/test/run-pass/issue-19100.rs b/src/test/run-pass/issue-19100.rs index 0ebd3ae8d97..26eacd682ef 100644 --- a/src/test/run-pass/issue-19100.rs +++ b/src/test/run-pass/issue-19100.rs @@ -8,13 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[derive(Copy)] enum Foo { Bar, Baz } -impl Copy for Foo {} - impl Foo { fn foo(&self) { match self { diff --git a/src/test/run-pass/issue-2288.rs b/src/test/run-pass/issue-2288.rs index 7baead6929b..18bb6fe5529 100644 --- a/src/test/run-pass/issue-2288.rs +++ b/src/test/run-pass/issue-2288.rs @@ -15,12 +15,11 @@ trait clam { fn chowder(&self, y: A); } +#[derive(Copy)] struct foo { x: A, } -impl Copy for foo {} - impl clam for foo { fn chowder(&self, _y: A) { } diff --git a/src/test/run-pass/issue-2633.rs b/src/test/run-pass/issue-2633.rs index bc014f699c7..de99141c803 100644 --- a/src/test/run-pass/issue-2633.rs +++ b/src/test/run-pass/issue-2633.rs @@ -8,12 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[derive(Copy)] struct cat { meow: extern "Rust" fn(), } -impl Copy for cat {} - fn meow() { println!("meow") } @@ -24,10 +23,9 @@ fn cat() -> cat { } } +#[derive(Copy)] struct KittyInfo {kitty: cat} -impl Copy for KittyInfo {} - // Code compiles and runs successfully if we add a + before the first arg fn nyan(kitty: cat, _kitty_info: KittyInfo) { (kitty.meow)(); diff --git a/src/test/run-pass/issue-3121.rs b/src/test/run-pass/issue-3121.rs index c789921f622..b6ed85e9e4a 100644 --- a/src/test/run-pass/issue-3121.rs +++ b/src/test/run-pass/issue-3121.rs @@ -11,14 +11,13 @@ #![allow(unknown_features)] #![feature(box_syntax)] +#[derive(Copy)] enum side { mayo, catsup, vinegar } +#[derive(Copy)] enum order { hamburger, fries(side), shake } +#[derive(Copy)] enum meal { to_go(order), for_here(order) } -impl Copy for side {} -impl Copy for order {} -impl Copy for meal {} - fn foo(m: Box, cond: bool) { match *m { meal::to_go(_) => { } diff --git a/src/test/run-pass/issue-3563-3.rs b/src/test/run-pass/issue-3563-3.rs index 3fe6e02dcef..004bcf6dcd0 100644 --- a/src/test/run-pass/issue-3563-3.rs +++ b/src/test/run-pass/issue-3563-3.rs @@ -27,29 +27,26 @@ use std::iter::repeat; use std::slice; // Represents a position on a canvas. +#[derive(Copy)] struct Point { x: int, y: int, } -impl Copy for Point {} - // Represents an offset on a canvas. (This has the same structure as a Point. // but different semantics). +#[derive(Copy)] struct Size { width: int, height: int, } -impl Copy for Size {} - +#[derive(Copy)] struct Rect { top_left: Point, size: Size, } -impl Copy for Rect {} - // Contains the information needed to do shape rendering via ASCII art. struct AsciiArt { width: uint, diff --git a/src/test/run-pass/issue-3743.rs b/src/test/run-pass/issue-3743.rs index 382ea0c5758..03699ff8d60 100644 --- a/src/test/run-pass/issue-3743.rs +++ b/src/test/run-pass/issue-3743.rs @@ -14,13 +14,12 @@ use std::ops::Mul; +#[derive(Copy)] struct Vec2 { x: f64, y: f64 } -impl Copy for Vec2 {} - // methods we want to export as methods as well as operators impl Vec2 { #[inline(always)] diff --git a/src/test/run-pass/issue-3753.rs b/src/test/run-pass/issue-3753.rs index 00a8a0893a2..58d7aa276f1 100644 --- a/src/test/run-pass/issue-3753.rs +++ b/src/test/run-pass/issue-3753.rs @@ -14,20 +14,18 @@ use std::f64; +#[derive(Copy)] pub struct Point { x: f64, y: f64 } -impl Copy for Point {} - +#[derive(Copy)] pub enum Shape { Circle(Point, f64), Rectangle(Point, Point) } -impl Copy for Shape {} - impl Shape { pub fn area(&self, sh: Shape) -> f64 { match sh { diff --git a/src/test/run-pass/issue-5688.rs b/src/test/run-pass/issue-5688.rs index cfe9c8f994c..a4f39884846 100644 --- a/src/test/run-pass/issue-5688.rs +++ b/src/test/run-pass/issue-5688.rs @@ -17,10 +17,9 @@ with the representation of [int; n] and [int] somehow, or at least failed to typecheck correctly. */ +#[derive(Copy)] struct X { vec: &'static [int] } -impl Copy for X {} - static V: &'static [X] = &[X { vec: &[1, 2, 3] }]; pub fn main() { diff --git a/src/test/run-pass/match-arm-statics.rs b/src/test/run-pass/match-arm-statics.rs index db512adc011..1964bf4bd7d 100644 --- a/src/test/run-pass/match-arm-statics.rs +++ b/src/test/run-pass/match-arm-statics.rs @@ -36,10 +36,9 @@ const VARIANT2_NORTH: EnumWithStructVariants = EnumWithStructVariants::Variant2 dir: Direction::North }; pub mod glfw { + #[derive(Copy)] pub struct InputState(uint); - impl Copy for InputState {} - pub const RELEASE : InputState = InputState(0); pub const PRESS : InputState = InputState(1); pub const REPEAT : InputState = InputState(2); diff --git a/src/test/run-pass/method-self-arg-trait.rs b/src/test/run-pass/method-self-arg-trait.rs index 39018a87394..c79141d9795 100644 --- a/src/test/run-pass/method-self-arg-trait.rs +++ b/src/test/run-pass/method-self-arg-trait.rs @@ -15,10 +15,9 @@ static mut COUNT: u64 = 1; +#[derive(Copy)] struct Foo; -impl Copy for Foo {} - trait Bar : Sized { fn foo1(&self); fn foo2(self); diff --git a/src/test/run-pass/method-self-arg.rs b/src/test/run-pass/method-self-arg.rs index ae15bc60746..2225ccdc516 100644 --- a/src/test/run-pass/method-self-arg.rs +++ b/src/test/run-pass/method-self-arg.rs @@ -15,10 +15,9 @@ static mut COUNT: uint = 1; +#[derive(Copy)] struct Foo; -impl Copy for Foo {} - impl Foo { fn foo(self, x: &Foo) { unsafe { COUNT *= 2; } diff --git a/src/test/run-pass/monomorphize-abi-alignment.rs b/src/test/run-pass/monomorphize-abi-alignment.rs index 84bffed59a4..8ec16419a22 100644 --- a/src/test/run-pass/monomorphize-abi-alignment.rs +++ b/src/test/run-pass/monomorphize-abi-alignment.rs @@ -18,26 +18,21 @@ * and apply the wrong instance of the method `unwrap`. */ +#[derive(Copy)] struct S { i:u8, t:T } -impl Copy for S {} - impl S { fn unwrap(self) -> T { self.t } } -#[derive(PartialEq, Show)] +#[derive(Copy, PartialEq, Show)] struct A((u32, u32)); -impl Copy for A {} - -#[derive(PartialEq, Show)] +#[derive(Copy, PartialEq, Show)] struct B(u64); -impl Copy for B {} - pub fn main() { static Ca: S = S { i: 0, t: A((13, 104)) }; static Cb: S = S { i: 0, t: B(31337) }; diff --git a/src/test/run-pass/multidispatch1.rs b/src/test/run-pass/multidispatch1.rs index 15df67e1488..b9435afdc7a 100644 --- a/src/test/run-pass/multidispatch1.rs +++ b/src/test/run-pass/multidispatch1.rs @@ -14,12 +14,11 @@ trait MyTrait { fn get(&self) -> T; } +#[derive(Copy)] struct MyType { dummy: uint } -impl Copy for MyType {} - impl MyTrait for MyType { fn get(&self) -> uint { self.dummy } } diff --git a/src/test/run-pass/multidispatch2.rs b/src/test/run-pass/multidispatch2.rs index 0c2652e6a7c..ecacc7f1df9 100644 --- a/src/test/run-pass/multidispatch2.rs +++ b/src/test/run-pass/multidispatch2.rs @@ -23,12 +23,11 @@ impl MyTrait for T } } +#[derive(Copy)] struct MyType { dummy: uint } -impl Copy for MyType {} - impl MyTrait for MyType { fn get(&self) -> uint { self.dummy } } diff --git a/src/test/run-pass/newtype.rs b/src/test/run-pass/newtype.rs index 093fd6c81cc..869ae4a37d2 100644 --- a/src/test/run-pass/newtype.rs +++ b/src/test/run-pass/newtype.rs @@ -8,17 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[derive(Copy)] struct mytype(Mytype); -impl Copy for mytype {} - +#[derive(Copy)] struct Mytype { compute: fn(mytype) -> int, val: int, } -impl Copy for Mytype {} - fn compute(i: mytype) -> int { let mytype(m) = i; return m.val + 20; diff --git a/src/test/run-pass/out-pointer-aliasing.rs b/src/test/run-pass/out-pointer-aliasing.rs index 5f399deb885..eee9838da21 100644 --- a/src/test/run-pass/out-pointer-aliasing.rs +++ b/src/test/run-pass/out-pointer-aliasing.rs @@ -8,13 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[derive(Copy)] pub struct Foo { f1: int, _f2: int, } -impl Copy for Foo {} - #[inline(never)] pub fn foo(f: &mut Foo) -> Foo { let ret = *f; diff --git a/src/test/run-pass/overloaded-autoderef-order.rs b/src/test/run-pass/overloaded-autoderef-order.rs index c34aed42c97..4c48b0ba710 100644 --- a/src/test/run-pass/overloaded-autoderef-order.rs +++ b/src/test/run-pass/overloaded-autoderef-order.rs @@ -11,13 +11,12 @@ use std::rc::Rc; use std::ops::Deref; +#[derive(Copy)] struct DerefWrapper { x: X, y: Y } -impl Copy for DerefWrapper {} - impl DerefWrapper { fn get_x(self) -> X { self.x @@ -35,13 +34,12 @@ impl Deref for DerefWrapper { mod priv_test { use std::ops::Deref; + #[derive(Copy)] pub struct DerefWrapperHideX { x: X, pub y: Y } - impl Copy for DerefWrapperHideX {} - impl DerefWrapperHideX { pub fn new(x: X, y: Y) -> DerefWrapperHideX { DerefWrapperHideX { diff --git a/src/test/run-pass/packed-struct-vec.rs b/src/test/run-pass/packed-struct-vec.rs index 8e5decf5e62..c2e7a56d270 100644 --- a/src/test/run-pass/packed-struct-vec.rs +++ b/src/test/run-pass/packed-struct-vec.rs @@ -13,14 +13,12 @@ use std::mem; #[repr(packed)] -#[derive(PartialEq, Show)] +#[derive(Copy, PartialEq, Show)] struct Foo { bar: u8, baz: u64 } -impl Copy for Foo {} - pub fn main() { let foos = [Foo { bar: 1, baz: 2 }; 10]; diff --git a/src/test/run-pass/rec-tup.rs b/src/test/run-pass/rec-tup.rs index 8adad012ec6..dab7d26cc82 100644 --- a/src/test/run-pass/rec-tup.rs +++ b/src/test/run-pass/rec-tup.rs @@ -8,10 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[derive(Copy)] struct Point {x: int, y: int} -impl Copy for Point {} - type rect = (Point, Point); fn fst(r: rect) -> Point { let (fst, _) = r; return fst; } diff --git a/src/test/run-pass/rec.rs b/src/test/run-pass/rec.rs index 02fcf1ad068..f59538c51a0 100644 --- a/src/test/run-pass/rec.rs +++ b/src/test/run-pass/rec.rs @@ -8,13 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - +#[derive(Copy)] struct Rect {x: int, y: int, w: int, h: int} -impl Copy for Rect {} - fn f(r: Rect, x: int, y: int, w: int, h: int) { assert_eq!(r.x, x); assert_eq!(r.y, y); diff --git a/src/test/run-pass/regions-dependent-addr-of.rs b/src/test/run-pass/regions-dependent-addr-of.rs index e38a472fa4c..85402080f11 100644 --- a/src/test/run-pass/regions-dependent-addr-of.rs +++ b/src/test/run-pass/regions-dependent-addr-of.rs @@ -27,12 +27,11 @@ struct B { v6: Option } +#[derive(Copy)] struct C { f: int } -impl Copy for C {} - fn get_v1(a: &A) -> &int { // Region inferencer must deduce that &v < L2 < L1 let foo = &a.value; // L1 diff --git a/src/test/run-pass/regions-early-bound-used-in-bound-method.rs b/src/test/run-pass/regions-early-bound-used-in-bound-method.rs index 5b4169a4e84..410415e57a0 100644 --- a/src/test/run-pass/regions-early-bound-used-in-bound-method.rs +++ b/src/test/run-pass/regions-early-bound-used-in-bound-method.rs @@ -15,12 +15,11 @@ trait GetRef<'a> { fn get(&self) -> &'a int; } +#[derive(Copy)] struct Box<'a> { t: &'a int } -impl<'a> Copy for Box<'a> {} - impl<'a> GetRef<'a> for Box<'a> { fn get(&self) -> &'a int { self.t diff --git a/src/test/run-pass/regions-early-bound-used-in-type-param.rs b/src/test/run-pass/regions-early-bound-used-in-type-param.rs index 622f820971f..e0d5e0a1c78 100644 --- a/src/test/run-pass/regions-early-bound-used-in-type-param.rs +++ b/src/test/run-pass/regions-early-bound-used-in-type-param.rs @@ -15,12 +15,11 @@ trait Get { fn get(&self) -> T; } +#[derive(Copy)] struct Box { t: T } -impl Copy for Box {} - impl Get for Box { fn get(&self) -> T { self.t.clone() diff --git a/src/test/run-pass/regions-mock-tcx.rs b/src/test/run-pass/regions-mock-tcx.rs index 6e85011b143..eec4ee1be94 100644 --- a/src/test/run-pass/regions-mock-tcx.rs +++ b/src/test/run-pass/regions-mock-tcx.rs @@ -27,14 +27,12 @@ use std::mem; type Type<'tcx> = &'tcx TypeStructure<'tcx>; -#[derive(Show)] +#[derive(Copy, Show)] enum TypeStructure<'tcx> { TypeInt, TypeFunction(Type<'tcx>, Type<'tcx>), } -impl<'tcx> Copy for TypeStructure<'tcx> {} - impl<'tcx> PartialEq for TypeStructure<'tcx> { fn eq(&self, other: &TypeStructure<'tcx>) -> bool { match (*self, *other) { @@ -91,30 +89,26 @@ impl<'tcx,'ast> TypeContext<'tcx, 'ast> { } } -#[derive(PartialEq, Eq, Hash)] +#[derive(Copy, PartialEq, Eq, Hash)] struct NodeId { id: uint } -impl Copy for NodeId {} - type Ast<'ast> = &'ast AstStructure<'ast>; +#[derive(Copy)] struct AstStructure<'ast> { id: NodeId, kind: AstKind<'ast> } -impl<'ast> Copy for AstStructure<'ast> {} - +#[derive(Copy)] enum AstKind<'ast> { ExprInt, ExprVar(uint), ExprLambda(Ast<'ast>), } -impl<'ast> Copy for AstKind<'ast> {} - fn compute_types<'tcx,'ast>(tcx: &mut TypeContext<'tcx,'ast>, ast: Ast<'ast>) -> Type<'tcx> { diff --git a/src/test/run-pass/self-in-mut-slot-immediate-value.rs b/src/test/run-pass/self-in-mut-slot-immediate-value.rs index 1603f7f9763..a4b5ea1d682 100644 --- a/src/test/run-pass/self-in-mut-slot-immediate-value.rs +++ b/src/test/run-pass/self-in-mut-slot-immediate-value.rs @@ -11,12 +11,11 @@ // Assert that `mut self` on an immediate value doesn't // allow mutating the original - issue #10615. +#[derive(Copy)] struct Value { n: int } -impl Copy for Value {} - impl Value { fn squared(mut self) -> Value { self.n *= self.n; diff --git a/src/test/run-pass/simd-generics.rs b/src/test/run-pass/simd-generics.rs index e89d5c9922d..1371c4cc5f4 100644 --- a/src/test/run-pass/simd-generics.rs +++ b/src/test/run-pass/simd-generics.rs @@ -13,9 +13,9 @@ use std::ops; -#[simd] struct f32x4(f32, f32, f32, f32); - -impl Copy for f32x4 {} +#[simd] +#[derive(Copy)] +struct f32x4(f32, f32, f32, f32); fn add>(lhs: T, rhs: T) -> T { lhs + rhs diff --git a/src/test/run-pass/small-enum-range-edge.rs b/src/test/run-pass/small-enum-range-edge.rs index de38a553e12..35283e466c1 100644 --- a/src/test/run-pass/small-enum-range-edge.rs +++ b/src/test/run-pass/small-enum-range-edge.rs @@ -13,18 +13,16 @@ */ #[repr(u8)] +#[derive(Copy)] enum Eu { Lu = 0, Hu = 255 } -impl Copy for Eu {} - static CLu: Eu = Eu::Lu; static CHu: Eu = Eu::Hu; #[repr(i8)] +#[derive(Copy)] enum Es { Ls = -128, Hs = 127 } -impl Copy for Es {} - static CLs: Es = Es::Ls; static CHs: Es = Es::Hs; diff --git a/src/test/run-pass/struct-return.rs b/src/test/run-pass/struct-return.rs index bd945327d10..c8768731e2b 100644 --- a/src/test/run-pass/struct-return.rs +++ b/src/test/run-pass/struct-return.rs @@ -10,14 +10,12 @@ // // ignore-lexer-test FIXME #15883 +#[derive(Copy)] pub struct Quad { a: u64, b: u64, c: u64, d: u64 } -impl Copy for Quad {} - +#[derive(Copy)] pub struct Floats { a: f64, b: u8, c: f64 } -impl Copy for Floats {} - mod rustrt { use super::{Floats, Quad}; diff --git a/src/test/run-pass/structured-compare.rs b/src/test/run-pass/structured-compare.rs index 4f6ed55f425..9278ebebc53 100644 --- a/src/test/run-pass/structured-compare.rs +++ b/src/test/run-pass/structured-compare.rs @@ -10,11 +10,9 @@ -#[derive(Show)] +#[derive(Copy, Show)] enum foo { large, small, } -impl Copy for foo {} - impl PartialEq for foo { fn eq(&self, other: &foo) -> bool { ((*self) as uint) == ((*other) as uint) diff --git a/src/test/run-pass/tag-variant-disr-val.rs b/src/test/run-pass/tag-variant-disr-val.rs index cf53c1a912a..915a0b5b7e3 100644 --- a/src/test/run-pass/tag-variant-disr-val.rs +++ b/src/test/run-pass/tag-variant-disr-val.rs @@ -9,6 +9,7 @@ // except according to those terms. use color::{red, green, blue, black, white, imaginary, purple, orange}; +#[derive(Copy)] enum color { red = 0xff0000, green = 0x00ff00, @@ -20,8 +21,6 @@ enum color { orange = 8 >> 1 } -impl Copy for color {} - impl PartialEq for color { fn eq(&self, other: &color) -> bool { ((*self) as uint) == ((*other) as uint) diff --git a/src/test/run-pass/trait-coercion-generic.rs b/src/test/run-pass/trait-coercion-generic.rs index 22db6c64770..fa02dabb373 100644 --- a/src/test/run-pass/trait-coercion-generic.rs +++ b/src/test/run-pass/trait-coercion-generic.rs @@ -15,13 +15,12 @@ trait Trait { fn f(&self, x: T); } +#[derive(Copy)] struct Struct { x: int, y: int, } -impl Copy for Struct {} - impl Trait<&'static str> for Struct { fn f(&self, x: &'static str) { println!("Hi, {}!", x); diff --git a/src/test/run-pass/trait-coercion.rs b/src/test/run-pass/trait-coercion.rs index 0d4a05bed7f..b3d30e7372f 100644 --- a/src/test/run-pass/trait-coercion.rs +++ b/src/test/run-pass/trait-coercion.rs @@ -17,13 +17,12 @@ trait Trait { fn f(&self); } +#[derive(Copy)] struct Struct { x: int, y: int, } -impl Copy for Struct {} - impl Trait for Struct { fn f(&self) { println!("Hi!"); diff --git a/src/test/run-pass/typeclasses-eq-example-static.rs b/src/test/run-pass/typeclasses-eq-example-static.rs index 20a28c5a9ea..0ea7a1be432 100644 --- a/src/test/run-pass/typeclasses-eq-example-static.rs +++ b/src/test/run-pass/typeclasses-eq-example-static.rs @@ -21,11 +21,9 @@ trait Equal { fn isEq(a: &Self, b: &Self) -> bool; } -#[derive(Clone)] +#[derive(Clone, Copy)] enum Color { cyan, magenta, yellow, black } -impl Copy for Color {} - impl Equal for Color { fn isEq(a: &Color, b: &Color) -> bool { match (*a, *b) { diff --git a/src/test/run-pass/typeclasses-eq-example.rs b/src/test/run-pass/typeclasses-eq-example.rs index aa290edd863..69d22cf34f1 100644 --- a/src/test/run-pass/typeclasses-eq-example.rs +++ b/src/test/run-pass/typeclasses-eq-example.rs @@ -19,11 +19,9 @@ trait Equal { fn isEq(&self, a: &Self) -> bool; } -#[derive(Clone)] +#[derive(Clone, Copy)] enum Color { cyan, magenta, yellow, black } -impl Copy for Color {} - impl Equal for Color { fn isEq(&self, a: &Color) -> bool { match (*self, *a) { diff --git a/src/test/run-pass/ufcs-explicit-self.rs b/src/test/run-pass/ufcs-explicit-self.rs index 968f3511247..2be9f75dae1 100644 --- a/src/test/run-pass/ufcs-explicit-self.rs +++ b/src/test/run-pass/ufcs-explicit-self.rs @@ -11,12 +11,11 @@ #![allow(unknown_features)] #![feature(box_syntax)] +#[derive(Copy)] struct Foo { f: int, } -impl Copy for Foo {} - impl Foo { fn foo(self: Foo, x: int) -> int { self.f + x @@ -29,12 +28,11 @@ impl Foo { } } +#[derive(Copy)] struct Bar { f: T, } -impl Copy for Bar {} - impl Bar { fn foo(self: Bar, x: int) -> int { x diff --git a/src/test/run-pass/unboxed-closures-monomorphization.rs b/src/test/run-pass/unboxed-closures-monomorphization.rs index 6701f879e4f..c1b7166b24e 100644 --- a/src/test/run-pass/unboxed-closures-monomorphization.rs +++ b/src/test/run-pass/unboxed-closures-monomorphization.rs @@ -30,11 +30,9 @@ fn main(){ let mut f = bar(&x); assert_eq!(f.call_mut(()), &x); - #[derive(Clone, Show, PartialEq)] + #[derive(Clone, Copy, Show, PartialEq)] struct Foo(uint, &'static str); - impl Copy for Foo {} - let x = Foo(42, "forty-two"); let mut f = bar(x); assert_eq!(f.call_mut(()), x);