mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
cleanup: s/impl Copy/#[derive(Copy)]/g
This commit is contained in:
parent
102ab57d80
commit
bff462302b
@ -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<Mode> {
|
||||
match s {
|
||||
|
@ -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; }
|
||||
|
@ -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, _)| {
|
||||
|
@ -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;
|
||||
///
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -82,4 +82,5 @@ mod std {
|
||||
pub use core::clone;
|
||||
pub use core::cmp;
|
||||
pub use core::fmt;
|
||||
pub use core::marker;
|
||||
}
|
||||
|
@ -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, _)| {
|
||||
|
@ -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).
|
||||
|
@ -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 {
|
||||
|
@ -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 {}
|
||||
|
||||
|
@ -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; }
|
||||
|
@ -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; }
|
||||
|
@ -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 {}
|
||||
|
||||
|
@ -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) }
|
||||
|
@ -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<Color>) -> String {
|
||||
let mut out = String::new();
|
||||
for col in set.iter() {
|
||||
|
@ -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];
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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<Foo> { panic!() }
|
||||
|
||||
fn borrow_same_field_twice_mut_mut() {
|
||||
|
@ -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() {
|
||||
|
@ -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<isize> }
|
||||
|
||||
fn var_copy_after_var_borrow() {
|
||||
|
@ -14,10 +14,9 @@
|
||||
use std::ops::Index;
|
||||
use std::fmt::Debug;
|
||||
|
||||
#[derive(Copy)]
|
||||
struct S;
|
||||
|
||||
impl Copy for S {}
|
||||
|
||||
impl Index<usize> for S {
|
||||
type Output = str;
|
||||
|
||||
@ -26,10 +25,9 @@ impl Index<usize> for S {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy)]
|
||||
struct T;
|
||||
|
||||
impl Copy for T {}
|
||||
|
||||
impl Index<usize> for T {
|
||||
type Output = Debug + 'static;
|
||||
|
||||
|
@ -17,13 +17,12 @@ fn assert_copy<T:Copy>() { }
|
||||
|
||||
trait Dummy { }
|
||||
|
||||
#[derive(Copy)]
|
||||
struct MyStruct {
|
||||
x: isize,
|
||||
y: isize,
|
||||
}
|
||||
|
||||
impl Copy for MyStruct {}
|
||||
|
||||
struct MyNoncopyStruct {
|
||||
x: Box<char>,
|
||||
}
|
||||
|
@ -115,6 +115,7 @@
|
||||
#![feature(box_syntax)]
|
||||
#![omit_gdb_pretty_printer_section]
|
||||
|
||||
#[derive(Copy)]
|
||||
struct Struct<T> {
|
||||
x: T
|
||||
}
|
||||
@ -150,5 +151,3 @@ fn main() {
|
||||
|
||||
fn zzz() {()}
|
||||
|
||||
impl<T:Copy> Copy for Struct<T> {}
|
||||
|
||||
|
@ -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 {}
|
||||
|
||||
|
@ -116,6 +116,7 @@
|
||||
#![feature(box_syntax)]
|
||||
#![omit_gdb_pretty_printer_section]
|
||||
|
||||
#[derive(Copy)]
|
||||
struct Struct<T> {
|
||||
x: T
|
||||
}
|
||||
@ -151,5 +152,3 @@ fn main() {
|
||||
|
||||
fn zzz() {()}
|
||||
|
||||
impl<T:Copy> Copy for Struct<T> {}
|
||||
|
||||
|
@ -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 {}
|
||||
|
||||
|
@ -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 {}
|
||||
|
||||
|
@ -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 {}
|
||||
|
||||
|
@ -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 {}
|
||||
|
||||
|
@ -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 {}
|
||||
|
||||
|
@ -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 => { } _ => { } }
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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>(T);
|
||||
|
||||
impl<T:Copy> Copy for X<T> {}
|
||||
|
||||
impl<T:Sync> RequiresShare for X<T> { }
|
||||
|
||||
impl<T:Sync+Send> RequiresRequiresShareAndSend for X<T> { }
|
||||
|
@ -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();
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -23,13 +23,11 @@ impl<T> 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() }
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -30,11 +30,9 @@ fn foo2<T:ToBar>(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;
|
||||
}
|
||||
|
@ -49,11 +49,9 @@ fn foo3(x: &Fat<Fat<[int]>>) {
|
||||
}
|
||||
|
||||
|
||||
#[derive(PartialEq,Eq)]
|
||||
#[derive(Copy, PartialEq, Eq)]
|
||||
struct Bar;
|
||||
|
||||
impl Copy for Bar {}
|
||||
|
||||
trait ToBar {
|
||||
fn to_bar(&self) -> Bar;
|
||||
}
|
||||
|
@ -17,18 +17,14 @@ struct Fat<T: ?Sized> {
|
||||
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;
|
||||
|
@ -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)
|
||||
|
@ -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::<E>(), size_of::<$t>());
|
||||
assert_eq!(E::V as $t, $v as $t);
|
||||
|
@ -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<K,V> {
|
||||
HashMap_(LM)
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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<Point>) {
|
||||
assert!((p.get().z == 12));
|
||||
p.set(Point {x: 10, y: 11, z: 13});
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -12,10 +12,9 @@
|
||||
|
||||
fn id<T>(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;
|
||||
|
@ -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<uint>) }
|
||||
|
||||
impl Copy for Q {}
|
||||
|
||||
fn xyzzy(q: Q) -> uint {
|
||||
match q {
|
||||
Q::R(S) if S.is_some() => { 0 }
|
||||
|
@ -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 } };
|
||||
|
@ -29,10 +29,9 @@ enum TyS<'tcx> {
|
||||
Boop(marker::InvariantLifetime<'tcx>)
|
||||
}
|
||||
|
||||
#[derive(Copy)]
|
||||
enum Bar<'tcx> {
|
||||
Baz(Foo<Ty<'tcx>>)
|
||||
}
|
||||
|
||||
impl<'tcx> Copy for Bar<'tcx> { }
|
||||
|
||||
fn main() { }
|
||||
|
@ -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();
|
||||
|
@ -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 {
|
||||
|
@ -15,12 +15,11 @@ trait clam<A> {
|
||||
fn chowder(&self, y: A);
|
||||
}
|
||||
|
||||
#[derive(Copy)]
|
||||
struct foo<A> {
|
||||
x: A,
|
||||
}
|
||||
|
||||
impl<A:Copy> Copy for foo<A> {}
|
||||
|
||||
impl<A> clam<A> for foo<A> {
|
||||
fn chowder(&self, _y: A) {
|
||||
}
|
||||
|
@ -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)();
|
||||
|
@ -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<meal>, cond: bool) {
|
||||
match *m {
|
||||
meal::to_go(_) => { }
|
||||
|
@ -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,
|
||||
|
@ -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)]
|
||||
|
@ -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 {
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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; }
|
||||
|
@ -18,26 +18,21 @@
|
||||
* and apply the wrong instance of the method `unwrap`.
|
||||
*/
|
||||
|
||||
#[derive(Copy)]
|
||||
struct S<T> { i:u8, t:T }
|
||||
|
||||
impl<T:Copy> Copy for S<T> {}
|
||||
|
||||
impl<T> S<T> {
|
||||
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<A> = S { i: 0, t: A((13, 104)) };
|
||||
static Cb: S<B> = S { i: 0, t: B(31337) };
|
||||
|
@ -14,12 +14,11 @@ trait MyTrait<T> {
|
||||
fn get(&self) -> T;
|
||||
}
|
||||
|
||||
#[derive(Copy)]
|
||||
struct MyType {
|
||||
dummy: uint
|
||||
}
|
||||
|
||||
impl Copy for MyType {}
|
||||
|
||||
impl MyTrait<uint> for MyType {
|
||||
fn get(&self) -> uint { self.dummy }
|
||||
}
|
||||
|
@ -23,12 +23,11 @@ impl<T> MyTrait<T> for T
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy)]
|
||||
struct MyType {
|
||||
dummy: uint
|
||||
}
|
||||
|
||||
impl Copy for MyType {}
|
||||
|
||||
impl MyTrait<uint> for MyType {
|
||||
fn get(&self) -> uint { self.dummy }
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -11,13 +11,12 @@
|
||||
use std::rc::Rc;
|
||||
use std::ops::Deref;
|
||||
|
||||
#[derive(Copy)]
|
||||
struct DerefWrapper<X, Y> {
|
||||
x: X,
|
||||
y: Y
|
||||
}
|
||||
|
||||
impl<X:Copy,Y:Copy> Copy for DerefWrapper<X,Y> {}
|
||||
|
||||
impl<X, Y> DerefWrapper<X, Y> {
|
||||
fn get_x(self) -> X {
|
||||
self.x
|
||||
@ -35,13 +34,12 @@ impl<X, Y> Deref for DerefWrapper<X, Y> {
|
||||
mod priv_test {
|
||||
use std::ops::Deref;
|
||||
|
||||
#[derive(Copy)]
|
||||
pub struct DerefWrapperHideX<X, Y> {
|
||||
x: X,
|
||||
pub y: Y
|
||||
}
|
||||
|
||||
impl<X:Copy,Y:Copy> Copy for DerefWrapperHideX<X,Y> {}
|
||||
|
||||
impl<X, Y> DerefWrapperHideX<X, Y> {
|
||||
pub fn new(x: X, y: Y) -> DerefWrapperHideX<X, Y> {
|
||||
DerefWrapperHideX {
|
||||
|
@ -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];
|
||||
|
||||
|
@ -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; }
|
||||
|
@ -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);
|
||||
|
@ -27,12 +27,11 @@ struct B {
|
||||
v6: Option<C>
|
||||
}
|
||||
|
||||
#[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
|
||||
|
@ -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
|
||||
|
@ -15,12 +15,11 @@ trait Get<T> {
|
||||
fn get(&self) -> T;
|
||||
}
|
||||
|
||||
#[derive(Copy)]
|
||||
struct Box<T> {
|
||||
t: T
|
||||
}
|
||||
|
||||
impl<T:Copy> Copy for Box<T> {}
|
||||
|
||||
impl<T:Clone> Get<T> for Box<T> {
|
||||
fn get(&self) -> T {
|
||||
self.t.clone()
|
||||
|
@ -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>
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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<T: ops::Add<Output=T>>(lhs: T, rhs: T) -> T {
|
||||
lhs + rhs
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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};
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -15,13 +15,12 @@ trait Trait<T> {
|
||||
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);
|
||||
|
@ -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!");
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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<T> {
|
||||
f: T,
|
||||
}
|
||||
|
||||
impl<T:Copy> Copy for Bar<T> {}
|
||||
|
||||
impl<T> Bar<T> {
|
||||
fn foo(self: Bar<T>, x: int) -> int {
|
||||
x
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user