librustc: Remove all uses of the Copy bound.
This commit is contained in:
parent
99d44d24c7
commit
e20549ff19
94 changed files with 213 additions and 280 deletions
|
|
@ -9,15 +9,15 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn foo<T>() {
|
||||
1u.bar::<T>(); //~ ERROR: does not fulfill `Copy`
|
||||
1u.bar::<T>(); //~ ERROR: does not fulfill `Send`
|
||||
}
|
||||
|
||||
trait bar {
|
||||
fn bar<T:Copy>(&self);
|
||||
fn bar<T:Send>(&self);
|
||||
}
|
||||
|
||||
impl bar for uint {
|
||||
fn bar<T:Copy>(&self) {
|
||||
fn bar<T:Send>(&self) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct X {
|
||||
field: @fn:Copy(),
|
||||
field: @fn:Send(),
|
||||
}
|
||||
|
||||
fn foo(blk: @fn:()) -> X {
|
||||
return X { field: blk }; //~ ERROR expected bounds `Copy` but found no bounds
|
||||
return X { field: blk }; //~ ERROR expected bounds `Send` but found no bounds
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::comm;
|
||||
|
||||
// If this were legal you could use it to copy captured noncopyables.
|
||||
// Issue (#2828)
|
||||
|
||||
fn foo(blk: ~fn:Copy()) {
|
||||
blk();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let (p,c) = comm::stream();
|
||||
do foo {
|
||||
c.send(()); //~ ERROR does not fulfill `Copy`
|
||||
}
|
||||
p.recv();
|
||||
}
|
||||
|
|
@ -2,38 +2,16 @@
|
|||
fn take_any(_: &fn:()) {
|
||||
}
|
||||
|
||||
fn take_copyable(_: &fn:Copy()) {
|
||||
}
|
||||
|
||||
fn take_copyable_owned(_: &fn:Copy+Send()) {
|
||||
}
|
||||
|
||||
fn take_const_owned(_: &fn:Freeze+Send()) {
|
||||
}
|
||||
|
||||
fn give_any(f: &fn:()) {
|
||||
take_any(f);
|
||||
take_copyable(f); //~ ERROR expected bounds `Copy` but found no bounds
|
||||
take_copyable_owned(f); //~ ERROR expected bounds `Copy+Send` but found no bounds
|
||||
}
|
||||
|
||||
fn give_copyable(f: &fn:Copy()) {
|
||||
take_any(f);
|
||||
take_copyable(f);
|
||||
take_copyable_owned(f); //~ ERROR expected bounds `Copy+Send` but found bounds `Copy`
|
||||
}
|
||||
|
||||
fn give_owned(f: &fn:Send()) {
|
||||
take_any(f);
|
||||
take_copyable(f); //~ ERROR expected bounds `Copy` but found bounds `Send`
|
||||
take_copyable_owned(f); //~ ERROR expected bounds `Copy+Send` but found bounds `Send`
|
||||
}
|
||||
|
||||
fn give_copyable_owned(f: &fn:Copy+Send()) {
|
||||
take_any(f);
|
||||
take_copyable(f);
|
||||
take_copyable_owned(f);
|
||||
take_const_owned(f); //~ ERROR expected bounds `Send+Freeze` but found bounds `Copy+Send`
|
||||
take_const_owned(f); //~ ERROR expected bounds `Freeze+Send` but found bounds `Send`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn reproduce<T:Copy>(t: T) -> @fn() -> T {
|
||||
fn reproduce<T>(t: T) -> @fn() -> T {
|
||||
let result: @fn() -> T = || t;
|
||||
result
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn mk_identity<T:Copy>() -> @fn(T) -> T {
|
||||
fn mk_identity<T>() -> @fn(T) -> T {
|
||||
let result: @fn(t: T) -> T = |t| t;
|
||||
result
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ fn main() {
|
|||
let mut res = foo(x);
|
||||
|
||||
let mut v = ~[];
|
||||
v = ~[(res)] + v; //~ instantiating a type parameter with an incompatible type `foo`, which does not fulfill `Copy`
|
||||
v = ~[(res)] + v; //~ instantiating a type parameter with an incompatible type `foo`, which does not fulfill `Clone`
|
||||
assert_eq!(v.len(), 2);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
// than the trait method it's implementing
|
||||
|
||||
trait A {
|
||||
fn b<C:Copy,D>(x: C) -> C;
|
||||
fn b<C,D>(x: C) -> C;
|
||||
}
|
||||
|
||||
struct E {
|
||||
|
|
@ -20,7 +20,7 @@ struct E {
|
|||
}
|
||||
|
||||
impl A for E {
|
||||
fn b<F:Copy + Freeze,G>(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Freeze`
|
||||
fn b<F:Freeze,G>(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Freeze`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
// an impl against a trait
|
||||
|
||||
trait A {
|
||||
fn b<C:Copy,D>(&self, x: C) -> C;
|
||||
fn b<C:Clone,D>(&self, x: C) -> C;
|
||||
}
|
||||
|
||||
struct E {
|
||||
|
|
@ -21,7 +21,7 @@ struct E {
|
|||
|
||||
impl A for E {
|
||||
// n.b. The error message is awful -- see #3404
|
||||
fn b<F:Copy,G>(&self, _x: G) -> G { fail!() } //~ ERROR method `b` has an incompatible type
|
||||
fn b<F:Clone,G>(&self, _x: G) -> G { fail!() } //~ ERROR method `b` has an incompatible type
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@
|
|||
|
||||
trait repeat<A> { fn get(&self) -> A; }
|
||||
|
||||
impl<A:Copy> repeat<A> for @A {
|
||||
impl<A:Clone> repeat<A> for @A {
|
||||
fn get(&self) -> A { **self }
|
||||
}
|
||||
|
||||
fn repeater<A:Copy>(v: @A) -> @repeat<A> {
|
||||
fn repeater<A:Clone>(v: @A) -> @repeat<A> {
|
||||
// Note: owned kind is not necessary as A appears in the trait type
|
||||
@v as @repeat<A> // No
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@ trait foo {
|
|||
fn foo(&self, i: &'self int) -> int;
|
||||
}
|
||||
|
||||
impl<T:Copy> foo for T {
|
||||
impl<T:Clone> foo for T {
|
||||
fn foo(&self, i: &'self int) -> int {*i}
|
||||
}
|
||||
|
||||
fn to_foo<T:Copy>(t: T) {
|
||||
fn to_foo<T:Clone>(t: T) {
|
||||
// This version is ok because, although T may contain borrowed
|
||||
// pointers, it never escapes the fn body. We know this because
|
||||
// the type of foo includes a region which will be resolved to
|
||||
|
|
@ -33,14 +33,14 @@ fn to_foo<T:Copy>(t: T) {
|
|||
assert_eq!(x.foo(v), 3);
|
||||
}
|
||||
|
||||
fn to_foo_2<T:Copy>(t: T) -> @foo {
|
||||
fn to_foo_2<T:Clone>(t: T) -> @foo {
|
||||
// Not OK---T may contain borrowed ptrs and it is going to escape
|
||||
// as part of the returned foo value
|
||||
struct F<T> { f: T }
|
||||
@F {f:t} as @foo //~ ERROR value may contain borrowed pointers; add `'static` bound
|
||||
}
|
||||
|
||||
fn to_foo_3<T:Copy + 'static>(t: T) -> @foo {
|
||||
fn to_foo_3<T:Clone + 'static>(t: T) -> @foo {
|
||||
// OK---T may escape as part of the returned foo value, but it is
|
||||
// owned and hence does not contain borrowed ptrs
|
||||
struct F<T> { f: T }
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@
|
|||
|
||||
trait foo { fn foo(&self); }
|
||||
|
||||
fn to_foo<T:Copy + foo>(t: T) -> @foo {
|
||||
fn to_foo<T:Clone + foo>(t: T) -> @foo {
|
||||
@t as @foo
|
||||
//~^ ERROR value may contain borrowed pointers; add `'static` bound
|
||||
//~^^ ERROR cannot pack type
|
||||
}
|
||||
|
||||
fn to_foo2<T:Copy + foo + 'static>(t: T) -> @foo {
|
||||
fn to_foo2<T:Clone + foo + 'static>(t: T) -> @foo {
|
||||
@t as @foo
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ trait Foo {
|
|||
fn a(_x: ~Foo:Send) {
|
||||
}
|
||||
|
||||
fn b(_x: ~Foo:Send+Copy) {
|
||||
fn b(_x: ~Foo:Send+Clone) {
|
||||
}
|
||||
|
||||
fn c(x: ~Foo:Freeze+Send) {
|
||||
b(x); //~ ERROR expected bounds `Copy+Send`
|
||||
b(x); //~ ERROR expected bounds `Clone+Send`
|
||||
}
|
||||
|
||||
fn d(x: ~Foo:) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue