Skip to content

Make Copy a subtrait of Clone #23860

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 7 commits into from
Apr 2, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fallout in tests
  • Loading branch information
nikomatsakis committed Apr 1, 2015
commit 890ed5c46847fa544278c18fd46c1bdfe2809c09
2 changes: 1 addition & 1 deletion src/test/auxiliary/issue-14422.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mod src {
pub mod hidden_core {
use super::aliases::B;

#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct A;

pub fn make() -> B { A }
Expand Down
4 changes: 2 additions & 2 deletions src/test/auxiliary/issue13213aux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

pub use private::P;

#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct S {
p: P,
}

mod private {
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct P {
p: i32,
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/auxiliary/method_self_arg1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static mut COUNT: u64 = 1;

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

#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct Foo;

impl Foo {
Expand Down
2 changes: 1 addition & 1 deletion src/test/auxiliary/method_self_arg2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static mut COUNT: u64 = 1;

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

#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct Foo;

impl Foo {
Expand Down
2 changes: 1 addition & 1 deletion src/test/auxiliary/struct_variant_xc_aux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#![crate_name="struct_variant_xc_aux"]
#![crate_type = "lib"]

#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum Enum {
Variant(u8),
StructVariant { arg: u8 }
Expand Down
10 changes: 5 additions & 5 deletions src/test/auxiliary/xcrate_unit_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@

// used by the rpass test

#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct Struct;

#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum Unit {
UnitVariant,
Argument(Struct)
}

#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct TupleStruct(pub usize, pub &'static str);

// used by the cfail test

#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct StructWithFields {
foo: isize,
}

#[derive(Copy)]
#[derive(Copy, Clone)]
pub enum EnumWithVariants {
EnumVariant,
EnumVariantArg(isize)
Expand Down
2 changes: 1 addition & 1 deletion src/test/bench/noise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::f32::consts::PI;
use std::num::Float;
use std::rand::{Rng, StdRng};

#[derive(Copy)]
#[derive(Copy, Clone)]
struct Vec2 {
x: f32,
y: f32,
Expand Down
4 changes: 2 additions & 2 deletions src/test/bench/shootout-chameneos-redux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn print_complements() {
}
}

#[derive(Copy)]
#[derive(Copy, Clone)]
enum Color {
Red,
Yellow,
Expand All @@ -72,7 +72,7 @@ impl fmt::Debug for Color {
}
}

#[derive(Copy)]
#[derive(Copy, Clone)]
struct CreatureInfo {
name: usize,
color: Color
Expand Down
4 changes: 2 additions & 2 deletions src/test/bench/shootout-fannkuch-redux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ fn next_permutation(perm: &mut [i32], count: &mut [i32]) {
}
}

#[derive(Copy)]
#[derive(Copy, Clone)]
struct P {
p: [i32; 16],
}

#[derive(Copy)]
#[derive(Copy, Clone)]
struct Perm {
cnt: [i32; 16],
fact: [u32; 16],
Expand Down
2 changes: 1 addition & 1 deletion src/test/bench/shootout-fasta-redux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fn sum_and_scale(a: &'static [AminoAcid]) -> Vec<AminoAcid> {
result
}

#[derive(Copy)]
#[derive(Copy, Clone)]
struct AminoAcid {
c: u8,
p: f32,
Expand Down
2 changes: 1 addition & 1 deletion src/test/bench/shootout-k-nucleotide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static OCCURRENCES: [&'static str;5] = [

// Code implementation

#[derive(Copy, PartialEq, PartialOrd, Ord, Eq)]
#[derive(Copy, Clone, PartialEq, PartialOrd, Ord, Eq)]
struct Code(u64);

impl Code {
Expand Down
2 changes: 1 addition & 1 deletion src/test/bench/shootout-nbody.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static BODIES: [Planet;N_BODIES] = [
},
];

#[derive(Copy)]
#[derive(Copy, Clone)]
struct Planet {
x: f64, y: f64, z: f64,
vx: f64, vy: f64, vz: f64,
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
// except according to those terms.


#[derive(Copy)]
#[derive(Copy, Clone)]
struct Foo {
bar1: Bar,
bar2: Bar
}

#[derive(Copy)]
#[derive(Copy, Clone)]
struct Bar {
int1: isize,
int2: isize,
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/borrowck-borrow-from-stack-variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[derive(Copy)]
#[derive(Copy, Clone)]
struct Foo {
bar1: Bar,
bar2: Bar
}

#[derive(Copy)]
#[derive(Copy, Clone)]
struct Bar {
int1: isize,
int2: isize,
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use std::ops::Add;

#[derive(Copy)]
#[derive(Copy, Clone)]
struct Point {
x: isize,
y: isize,
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/borrowck-use-mut-borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#![feature(box_syntax)]

#[derive(Copy)]
#[derive(Copy, Clone)]
struct A { a: isize, b: isize }

struct B { a: isize, b: Box<isize> }
Expand Down
6 changes: 6 additions & 0 deletions src/test/compile-fail/coherence-impls-copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ struct NotSync;
impl !Sync for NotSync {}

impl Copy for TestE {}
impl Clone for TestE { fn clone(&self) -> Self { *self } }

impl Copy for MyType {}
impl Clone for MyType { fn clone(&self) -> Self { *self } }

impl Copy for (MyType, MyType) {}
//~^ ERROR E0206

Expand All @@ -31,6 +35,8 @@ impl Copy for &'static NotSync {}

impl Copy for [MyType] {}
//~^ ERROR E0206
//~| ERROR E0277
//~| ERROR E0277

impl Copy for &'static [NotSync] {}
//~^ ERROR E0206
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/dst-index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use std::ops::Index;
use std::fmt::Debug;

#[derive(Copy)]
#[derive(Copy, Clone)]
struct S;

impl Index<usize> for S {
Expand All @@ -25,7 +25,7 @@ impl Index<usize> for S {
}
}

#[derive(Copy)]
#[derive(Copy, Clone)]
struct T;

impl Index<usize> for T {
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/exclusive-drop-and-copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

// issue #20126

#[derive(Copy)] //~ ERROR the trait `Copy` may not be implemented
#[derive(Copy, Clone)] //~ ERROR the trait `Copy` may not be implemented
struct Foo;

impl Drop for Foo {
fn drop(&mut self) {}
}

#[derive(Copy)] //~ ERROR the trait `Copy` may not be implemented
#[derive(Copy, Clone)] //~ ERROR the trait `Copy` may not be implemented
struct Bar<T>(::std::marker::PhantomData<T>);

#[unsafe_destructor]
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/feature-gate-simd-ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use std::simd::f32x4;

#[simd] #[derive(Copy)] #[repr(C)] struct LocalSimd(u8, u8);
#[simd] #[derive(Copy, Clone)] #[repr(C)] struct LocalSimd(u8, u8);

extern {
fn foo() -> f32x4; //~ ERROR use of SIMD type
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/gated-simd-ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#![feature(simd)]

#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
#[simd]
pub struct f32x4(f32, f32, f32, f32);

Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/kindck-copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn assert_copy<T:Copy>() { }

trait Dummy : MarkerTrait { }

#[derive(Copy)]
#[derive(Copy, Clone)]
struct MyStruct {
x: isize,
y: isize,
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/kindck-inherited-copy-bound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ fn take_param<T:Foo>(foo: &T) { }

fn a() {
let x: Box<_> = box 3;
take_param(&x); //~ ERROR `core::marker::Copy` is not implemented
take_param(&x); //~ ERROR E0277
}

fn b() {
let x: Box<_> = box 3;
let y = &x;
let z = &x as &Foo; //~ ERROR `core::marker::Copy` is not implemented
let z = &x as &Foo; //~ ERROR E0038
}

fn main() { }
2 changes: 2 additions & 0 deletions src/test/compile-fail/opt-in-copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct IWantToCopyThis {

impl Copy for IWantToCopyThis {}
//~^ ERROR the trait `Copy` may not be implemented for this type
//~| ERROR E0277

enum CantCopyThisEither {
A,
Expand All @@ -28,5 +29,6 @@ enum IWantToCopyThisToo {

impl Copy for IWantToCopyThisToo {}
//~^ ERROR the trait `Copy` may not be implemented for this type
//~| ERROR E0277

fn main() {}
2 changes: 1 addition & 1 deletion src/test/compile-fail/pub-method-macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mod bleh {
)
}

#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct S;

impl S {
Expand Down
6 changes: 3 additions & 3 deletions src/test/debuginfo/c-style-enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,21 @@ use self::AutoDiscriminant::{One, Two, Three};
use self::ManualDiscriminant::{OneHundred, OneThousand, OneMillion};
use self::SingleVariant::TheOnlyVariant;

#[derive(Copy)]
#[derive(Copy, Clone)]
enum AutoDiscriminant {
One,
Two,
Three
}

#[derive(Copy)]
#[derive(Copy, Clone)]
enum ManualDiscriminant {
OneHundred = 100,
OneThousand = 1000,
OneMillion = 1000000
}

#[derive(Copy)]
#[derive(Copy, Clone)]
enum SingleVariant {
TheOnlyVariant
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/debuginfo/generic-method-on-generic-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
#![feature(box_syntax)]
#![omit_gdb_pretty_printer_section]

#[derive(Copy)]
#[derive(Copy, Clone)]
struct Struct<T> {
x: T
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/debuginfo/method-on-enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
#![feature(box_syntax)]
#![omit_gdb_pretty_printer_section]

#[derive(Copy)]
#[derive(Copy, Clone)]
enum Enum {
Variant1 { x: u16, y: u16 },
Variant2 (u32)
Expand Down
2 changes: 1 addition & 1 deletion src/test/debuginfo/method-on-generic-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
#![feature(box_syntax)]
#![omit_gdb_pretty_printer_section]

#[derive(Copy)]
#[derive(Copy, Clone)]
struct Struct<T> {
x: T
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/debuginfo/method-on-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
#![feature(box_syntax)]
#![omit_gdb_pretty_printer_section]

#[derive(Copy)]
#[derive(Copy, Clone)]
struct Struct {
x: isize
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/debuginfo/method-on-trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
#![feature(box_syntax)]
#![omit_gdb_pretty_printer_section]

#[derive(Copy)]
#[derive(Copy, Clone)]
struct Struct {
x: isize
}
Expand Down
Loading