Skip to content

cleanup: s/impl Copy/#[derive(Copy)]/g #21602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/compiletest/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -38,9 +38,6 @@ pub enum Mode {
Codegen
}


impl Copy for Mode {}

impl FromStr for Mode {
fn from_str(s: &str) -> Option<Mode> {
match s {
Expand Down
2 changes: 1 addition & 1 deletion src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
4 changes: 1 addition & 3 deletions src/etc/unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, _)| {
Expand Down
6 changes: 2 additions & 4 deletions src/libcore/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
///
Expand Down Expand Up @@ -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;
///
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_llvm/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ impl OptimizationDiagnosticKind {
}
}

#[allow(raw_pointer_derive)]
#[derive(Copy)]
pub struct OptimizationDiagnostic {
pub kind: OptimizationDiagnosticKind,
pub pass_name: *const c_char,
Expand All @@ -45,8 +47,6 @@ pub struct OptimizationDiagnostic {
pub message: TwineRef,
}

impl Copy for OptimizationDiagnostic {}

impl OptimizationDiagnostic {
unsafe fn unpack(kind: OptimizationDiagnosticKind, di: DiagnosticInfoRef)
-> OptimizationDiagnostic {
Expand Down
8 changes: 4 additions & 4 deletions src/libstd/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/libunicode/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ mod std {
pub use core::clone;
pub use core::cmp;
pub use core::fmt;
pub use core::marker;
}
5 changes: 1 addition & 4 deletions src/libunicode/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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, _)| {
Expand Down
4 changes: 1 addition & 3 deletions src/libunicode/u_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,16 +410,14 @@ 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),
/// An invalid surrogate without its pair.
LoneSurrogate(u16)
}

impl Copy for Utf16Item {}

impl Utf16Item {
/// Convert `self` to a `char`, taking `LoneSurrogate`s to the
/// replacement character (U+FFFD).
Expand Down
3 changes: 1 addition & 2 deletions src/test/auxiliary/issue-14422.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions src/test/auxiliary/issue13213aux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

3 changes: 1 addition & 2 deletions src/test/auxiliary/method_self_arg1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
3 changes: 1 addition & 2 deletions src/test/auxiliary/method_self_arg2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
15 changes: 5 additions & 10 deletions src/test/auxiliary/xcrate_unit_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

3 changes: 1 addition & 2 deletions src/test/bench/noise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
6 changes: 2 additions & 4 deletions src/test/bench/shootout-chameneos-redux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<Color>) -> String {
let mut out = String::new();
for col in set.iter() {
Expand Down
6 changes: 2 additions & 4 deletions src/test/bench/shootout-fannkuch-redux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -75,8 +75,6 @@ struct Perm {
perm: P,
}

impl Copy for Perm {}

impl Perm {
fn new(n: u32) -> Perm {
let mut fact = [1; 16];
Expand Down
3 changes: 1 addition & 2 deletions src/test/bench/shootout-fasta-redux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,12 @@ fn sum_and_scale(a: &'static [AminoAcid]) -> Vec<AminoAcid> {
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
Expand Down
4 changes: 1 addition & 3 deletions src/test/bench/shootout-k-nucleotide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/test/bench/shootout-nbody.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading