Skip to content

Commit bff4623

Browse files
author
Jorge Aparicio
committed
cleanup: s/impl Copy/#[derive(Copy)]/g
1 parent 102ab57 commit bff4623

File tree

99 files changed

+136
-289
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+136
-289
lines changed

src/compiletest/common.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::fmt;
1313
use std::str::FromStr;
1414

1515
#[cfg(stage0)] // NOTE: remove impl after snapshot
16-
#[derive(Clone, PartialEq, Show)]
16+
#[derive(Clone, Copy, PartialEq, Show)]
1717
pub enum Mode {
1818
CompileFail,
1919
RunFail,
@@ -26,7 +26,7 @@ pub enum Mode {
2626
}
2727

2828
#[cfg(not(stage0))] // NOTE: remove cfg after snapshot
29-
#[derive(Clone, PartialEq, Debug)]
29+
#[derive(Clone, Copy, PartialEq, Debug)]
3030
pub enum Mode {
3131
CompileFail,
3232
RunFail,
@@ -38,9 +38,6 @@ pub enum Mode {
3838
Codegen
3939
}
4040

41-
42-
impl Copy for Mode {}
43-
4441
impl FromStr for Mode {
4542
fn from_str(s: &str) -> Option<Mode> {
4643
match s {

src/doc/reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1680,8 +1680,8 @@ specific type.
16801680
Implementations are defined with the keyword `impl`.
16811681

16821682
```
1683+
# #[derive(Copy)]
16831684
# struct Point {x: f64, y: f64};
1684-
# impl Copy for Point {}
16851685
# type Surface = i32;
16861686
# struct BoundingBox {x: f64, y: f64, width: f64, height: f64};
16871687
# trait Shape { fn draw(&self, Surface); fn bounding_box(&self) -> BoundingBox; }

src/etc/unicode.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,15 +392,13 @@ def emit_grapheme_module(f, grapheme_table, grapheme_cats):
392392
use core::slice;
393393
394394
#[allow(non_camel_case_types)]
395-
#[derive(Clone)]
395+
#[derive(Clone, Copy)]
396396
pub enum GraphemeCat {
397397
""")
398398
for cat in grapheme_cats + ["Any"]:
399399
f.write(" GC_" + cat + ",\n")
400400
f.write(""" }
401401
402-
impl Copy for GraphemeCat {}
403-
404402
fn bsearch_range_value_table(c: char, r: &'static [(char, char, GraphemeCat)]) -> GraphemeCat {
405403
use core::cmp::Ordering::{Equal, Less, Greater};
406404
match r.binary_search(|&(lo, hi, _)| {

src/libcore/ops.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,9 @@ rem_float_impl! { f64, fmod }
445445
/// ```
446446
/// use std::ops::Neg;
447447
///
448+
/// #[derive(Copy)]
448449
/// struct Foo;
449450
///
450-
/// impl Copy for Foo {}
451-
///
452451
/// impl Neg for Foo {
453452
/// type Output = Foo;
454453
///
@@ -522,10 +521,9 @@ neg_uint_impl! { u64, i64 }
522521
/// ```
523522
/// use std::ops::Not;
524523
///
524+
/// #[derive(Copy)]
525525
/// struct Foo;
526526
///
527-
/// impl Copy for Foo {}
528-
///
529527
/// impl Not for Foo {
530528
/// type Output = Foo;
531529
///

src/librustc_llvm/diagnostic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ impl OptimizationDiagnosticKind {
3737
}
3838
}
3939

40+
#[allow(raw_pointer_derive)]
41+
#[derive(Copy)]
4042
pub struct OptimizationDiagnostic {
4143
pub kind: OptimizationDiagnosticKind,
4244
pub pass_name: *const c_char,
@@ -45,8 +47,6 @@ pub struct OptimizationDiagnostic {
4547
pub message: TwineRef,
4648
}
4749

48-
impl Copy for OptimizationDiagnostic {}
49-
5050
impl OptimizationDiagnostic {
5151
unsafe fn unpack(kind: OptimizationDiagnosticKind, di: DiagnosticInfoRef)
5252
-> OptimizationDiagnostic {

src/libstd/os.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,8 @@ pub struct MemoryMap {
813813
}
814814

815815
/// Type of memory map
816+
#[allow(raw_pointer_derive)]
817+
#[derive(Copy)]
816818
pub enum MemoryMapKind {
817819
/// Virtual memory map. Usually used to change the permissions of a given
818820
/// chunk of memory. Corresponds to `VirtualAlloc` on Windows.
@@ -823,9 +825,9 @@ pub enum MemoryMapKind {
823825
MapVirtual
824826
}
825827

826-
impl Copy for MemoryMapKind {}
827-
828828
/// Options the memory map is created with
829+
#[allow(raw_pointer_derive)]
830+
#[derive(Copy)]
829831
pub enum MapOption {
830832
/// The memory should be readable
831833
MapReadable,
@@ -852,8 +854,6 @@ pub enum MapOption {
852854
MapNonStandardFlags(c_int),
853855
}
854856

855-
impl Copy for MapOption {}
856-
857857
/// Possible errors when creating a map.
858858
#[derive(Copy, Show)]
859859
pub enum MapError {

src/libunicode/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,5 @@ mod std {
8282
pub use core::clone;
8383
pub use core::cmp;
8484
pub use core::fmt;
85+
pub use core::marker;
8586
}

src/libunicode/tables.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7801,13 +7801,12 @@ pub mod charwidth {
78017801
}
78027802

78037803
pub mod grapheme {
7804-
use core::marker::Copy;
78057804
use core::slice::SliceExt;
78067805
pub use self::GraphemeCat::*;
78077806
use core::result::Result::{Ok, Err};
78087807

78097808
#[allow(non_camel_case_types)]
7810-
#[derive(Clone)]
7809+
#[derive(Clone, Copy)]
78117810
pub enum GraphemeCat {
78127811
GC_LV,
78137812
GC_LVT,
@@ -7821,8 +7820,6 @@ pub mod grapheme {
78217820
GC_Any,
78227821
}
78237822

7824-
impl Copy for GraphemeCat {}
7825-
78267823
fn bsearch_range_value_table(c: char, r: &'static [(char, char, GraphemeCat)]) -> GraphemeCat {
78277824
use core::cmp::Ordering::{Equal, Less, Greater};
78287825
match r.binary_search_by(|&(lo, hi, _)| {

src/libunicode/u_str.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,16 +410,14 @@ pub struct Utf16Items<'a> {
410410
iter: slice::Iter<'a, u16>
411411
}
412412
/// The possibilities for values decoded from a `u16` stream.
413-
#[derive(PartialEq, Eq, Clone, Show)]
413+
#[derive(Copy, PartialEq, Eq, Clone, Show)]
414414
pub enum Utf16Item {
415415
/// A valid codepoint.
416416
ScalarValue(char),
417417
/// An invalid surrogate without its pair.
418418
LoneSurrogate(u16)
419419
}
420420

421-
impl Copy for Utf16Item {}
422-
423421
impl Utf16Item {
424422
/// Convert `self` to a `char`, taking `LoneSurrogate`s to the
425423
/// replacement character (U+FFFD).

src/test/auxiliary/issue-14422.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ mod src {
2323
pub mod hidden_core {
2424
use super::aliases::B;
2525

26+
#[derive(Copy)]
2627
pub struct A;
2728

28-
impl Copy for A {}
29-
3029
pub fn make() -> B { A }
3130

3231
impl A {

src/test/auxiliary/issue13213aux.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,18 @@
1313

1414
pub use private::P;
1515

16+
#[derive(Copy)]
1617
pub struct S {
1718
p: P,
1819
}
1920

2021
mod private {
22+
#[derive(Copy)]
2123
pub struct P {
2224
p: i32,
2325
}
2426
pub const THREE: P = P { p: 3 };
25-
impl Copy for P {}
2627
}
2728

2829
pub static A: S = S { p: private::THREE };
2930

30-
impl Copy for S {}
31-

src/test/auxiliary/method_self_arg1.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ static mut COUNT: u64 = 1;
1717

1818
pub fn get_count() -> u64 { unsafe { COUNT } }
1919

20+
#[derive(Copy)]
2021
pub struct Foo;
2122

22-
impl Copy for Foo {}
23-
2423
impl Foo {
2524
pub fn foo(self, x: &Foo) {
2625
unsafe { COUNT *= 2; }

src/test/auxiliary/method_self_arg2.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ static mut COUNT: u64 = 1;
1717

1818
pub fn get_count() -> u64 { unsafe { COUNT } }
1919

20+
#[derive(Copy)]
2021
pub struct Foo;
2122

22-
impl Copy for Foo {}
23-
2423
impl Foo {
2524
pub fn run_trait(self) {
2625
unsafe { COUNT *= 17; }

src/test/auxiliary/xcrate_unit_struct.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,28 @@
1212

1313
// used by the rpass test
1414

15+
#[derive(Copy)]
1516
pub struct Struct;
1617

17-
impl Copy for Struct {}
18-
18+
#[derive(Copy)]
1919
pub enum Unit {
2020
UnitVariant,
2121
Argument(Struct)
2222
}
2323

24-
impl Copy for Unit {}
25-
24+
#[derive(Copy)]
2625
pub struct TupleStruct(pub uint, pub &'static str);
2726

28-
impl Copy for TupleStruct {}
29-
3027
// used by the cfail test
3128

29+
#[derive(Copy)]
3230
pub struct StructWithFields {
3331
foo: int,
3432
}
3533

36-
impl Copy for StructWithFields {}
37-
34+
#[derive(Copy)]
3835
pub enum EnumWithVariants {
3936
EnumVariant,
4037
EnumVariantArg(int)
4138
}
4239

43-
impl Copy for EnumWithVariants {}
44-

src/test/bench/noise.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ use std::f32::consts::PI;
1616
use std::num::Float;
1717
use std::rand::{Rng, StdRng};
1818

19+
#[derive(Copy)]
1920
struct Vec2 {
2021
x: f32,
2122
y: f32,
2223
}
2324

24-
impl Copy for Vec2 {}
25-
2625
fn lerp(a: f32, b: f32, v: f32) -> f32 { a * (1.0 - v) + b * v }
2726

2827
fn smooth(v: f32) -> f32 { v * v * (3.0 - 2.0 * v) }

src/test/bench/shootout-chameneos-redux.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,13 @@ fn print_complements() {
5454
}
5555
}
5656

57+
#[derive(Copy)]
5758
enum Color {
5859
Red,
5960
Yellow,
6061
Blue,
6162
}
6263

63-
impl Copy for Color {}
64-
6564
impl fmt::Show for Color {
6665
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6766
let str = match *self {
@@ -73,13 +72,12 @@ impl fmt::Show for Color {
7372
}
7473
}
7574

75+
#[derive(Copy)]
7676
struct CreatureInfo {
7777
name: uint,
7878
color: Color
7979
}
8080

81-
impl Copy for CreatureInfo {}
82-
8381
fn show_color_list(set: Vec<Color>) -> String {
8482
let mut out = String::new();
8583
for col in set.iter() {

src/test/bench/shootout-fannkuch-redux.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ fn next_permutation(perm: &mut [i32], count: &mut [i32]) {
6161
}
6262
}
6363

64+
#[derive(Copy)]
6465
struct P {
6566
p: [i32; 16],
6667
}
6768

68-
impl Copy for P {}
69-
69+
#[derive(Copy)]
7070
struct Perm {
7171
cnt: [i32; 16],
7272
fact: [u32; 16],
@@ -75,8 +75,6 @@ struct Perm {
7575
perm: P,
7676
}
7777

78-
impl Copy for Perm {}
79-
8078
impl Perm {
8179
fn new(n: u32) -> Perm {
8280
let mut fact = [1; 16];

src/test/bench/shootout-fasta-redux.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,12 @@ fn sum_and_scale(a: &'static [AminoAcid]) -> Vec<AminoAcid> {
103103
result
104104
}
105105

106+
#[derive(Copy)]
106107
struct AminoAcid {
107108
c: u8,
108109
p: f32,
109110
}
110111

111-
impl Copy for AminoAcid {}
112-
113112
struct RepeatFasta<'a, W:'a> {
114113
alu: &'static str,
115114
out: &'a mut W

src/test/bench/shootout-k-nucleotide.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,9 @@ static OCCURRENCES: [&'static str;5] = [
6060

6161
// Code implementation
6262

63-
#[derive(PartialEq, PartialOrd, Ord, Eq)]
63+
#[derive(Copy, PartialEq, PartialOrd, Ord, Eq)]
6464
struct Code(u64);
6565

66-
impl Copy for Code {}
67-
6866
impl Code {
6967
fn hash(&self) -> u64 {
7068
let Code(ret) = *self;

src/test/bench/shootout-nbody.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,13 @@ static BODIES: [Planet;N_BODIES] = [
9494
},
9595
];
9696

97+
#[derive(Copy)]
9798
struct Planet {
9899
x: f64, y: f64, z: f64,
99100
vx: f64, vy: f64, vz: f64,
100101
mass: f64,
101102
}
102103

103-
impl Copy for Planet {}
104-
105104
fn advance(bodies: &mut [Planet;N_BODIES], dt: f64, steps: int) {
106105
for _ in range(0, steps) {
107106
let mut b_slice = bodies.as_mut_slice();

0 commit comments

Comments
 (0)