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
|
|
@ -35,7 +35,7 @@ impl read for bool {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn read<T:read + Copy>(s: ~str) -> T {
|
||||
pub fn read<T:read>(s: ~str) -> T {
|
||||
match read::readMaybe(s) {
|
||||
Some(x) => x,
|
||||
_ => fail!("read failed!")
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ fn sort_and_fmt(mm: &HashMap<~[u8], uint>, total: uint) -> ~str {
|
|||
return (xx as float) * 100f / (yy as float);
|
||||
}
|
||||
|
||||
fn le_by_val<TT:Copy + Clone,
|
||||
UU:Copy + Clone + Ord>(
|
||||
fn le_by_val<TT:Clone,
|
||||
UU:Clone + Ord>(
|
||||
kv0: &(TT,UU),
|
||||
kv1: &(TT,UU))
|
||||
-> bool {
|
||||
|
|
@ -44,8 +44,8 @@ fn sort_and_fmt(mm: &HashMap<~[u8], uint>, total: uint) -> ~str {
|
|||
return v0 >= v1;
|
||||
}
|
||||
|
||||
fn le_by_key<TT:Copy + Clone + Ord,
|
||||
UU:Copy + Clone>(
|
||||
fn le_by_key<TT:Clone + Ord,
|
||||
UU:Clone>(
|
||||
kv0: &(TT,UU),
|
||||
kv1: &(TT,UU))
|
||||
-> bool {
|
||||
|
|
@ -55,10 +55,7 @@ fn sort_and_fmt(mm: &HashMap<~[u8], uint>, total: uint) -> ~str {
|
|||
}
|
||||
|
||||
// sort by key, then by value
|
||||
fn sortKV<TT:Copy + Clone + Ord,
|
||||
UU:Copy + Clone + Ord>(
|
||||
orig: ~[(TT,UU)])
|
||||
-> ~[(TT,UU)] {
|
||||
fn sortKV<TT:Clone + Ord, UU:Clone + Ord>(orig: ~[(TT,UU)]) -> ~[(TT,UU)] {
|
||||
return sort::merge_sort(sort::merge_sort(orig, le_by_key), le_by_val);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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:) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
struct Pair<T, U> { a: T, b: U }
|
||||
struct Triple { x: int, y: int, z: int }
|
||||
|
||||
fn f<T:Copy,U:Copy>(x: T, y: U) -> Pair<T, U> { return Pair {a: x, b: y}; }
|
||||
fn f<T,U>(x: T, y: U) -> Pair<T, U> { return Pair {a: x, b: y}; }
|
||||
|
||||
pub fn main() {
|
||||
info!("%?", f(Triple {x: 3, y: 4, z: 5}, 4).a.x);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn f<T:Copy>(x: ~[T]) -> T { return x[0]; }
|
||||
fn f<T>(x: ~[T]) -> T { return x[0]; }
|
||||
|
||||
fn g(act: &fn(~[int]) -> int) -> int { return act(~[1, 2, 3]); }
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn clamp<T:Copy + Ord + Signed>(x: T, mn: T, mx: T) -> T {
|
||||
fn clamp<T:Ord + Signed>(x: T, mn: T, mx: T) -> T {
|
||||
cond!(
|
||||
(x > mx) { return mx; }
|
||||
(x < mn) { return mn; }
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn clamp<T:Copy + Ord + Signed>(x: T, mn: T, mx: T) -> T {
|
||||
fn clamp<T:Ord + Signed>(x: T, mn: T, mx: T) -> T {
|
||||
cond!(
|
||||
(x > mx) { mx }
|
||||
(x < mn) { mn }
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
// are const.
|
||||
|
||||
|
||||
fn foo<T:Copy + Freeze>(x: T) -> T { x }
|
||||
fn foo<T:Freeze>(x: T) -> T { x }
|
||||
|
||||
struct F { field: int }
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
// -*- rust -*-
|
||||
type compare<T> = @fn(~T, ~T) -> bool;
|
||||
|
||||
fn test_generic<T:Copy+Clone>(expected: ~T, eq: compare<T>) {
|
||||
fn test_generic<T:Clone>(expected: ~T, eq: compare<T>) {
|
||||
let actual: ~T = { expected.clone() };
|
||||
assert!((eq(expected, actual)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ fn test_vec() {
|
|||
}
|
||||
|
||||
fn test_generic() {
|
||||
fn f<T:Copy>(t: T) -> T { t }
|
||||
fn f<T>(t: T) -> T { t }
|
||||
assert_eq!(f(10), 10);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
// -*- rust -*-
|
||||
type compare<T> = @fn(~T, ~T) -> bool;
|
||||
|
||||
fn test_generic<T:Copy+Clone>(expected: ~T, eq: compare<T>) {
|
||||
fn test_generic<T:Clone>(expected: ~T, eq: compare<T>) {
|
||||
let actual: ~T = match true {
|
||||
true => { expected.clone() },
|
||||
_ => fail!("wat")
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
type compare<T> = @fn(T, T) -> bool;
|
||||
|
||||
fn test_generic<T:Copy+Clone>(expected: T, eq: compare<T>) {
|
||||
fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
|
||||
let actual: T = match true {
|
||||
true => expected.clone(),
|
||||
_ => fail!("wat")
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
|
||||
|
||||
fn id<T:Copy>(t: T) -> T { return t; }
|
||||
fn id<T>(t: T) -> T { return t; }
|
||||
|
||||
pub fn main() {
|
||||
let expected = @100;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
|
||||
|
||||
fn id<T:Copy + Send>(t: T) -> T { return t; }
|
||||
fn id<T:Send>(t: T) -> T { return t; }
|
||||
|
||||
pub fn main() {
|
||||
let expected = ~100;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
|
||||
|
||||
fn box<T:Copy>(x: Box<T>) -> @Box<T> { return @x; }
|
||||
fn box<T>(x: Box<T>) -> @Box<T> { return @x; }
|
||||
|
||||
struct Box<T> {x: T, y: T, z: T}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@
|
|||
|
||||
struct Pair { x: @int, y: @int }
|
||||
|
||||
fn f<T:Copy>(t: T) { let t1: T = t; }
|
||||
fn f<T>(t: T) { let t1: T = t; }
|
||||
|
||||
pub fn main() { let x = Pair {x: @10, y: @12}; f(x); }
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
struct Recbox<T> {x: @T}
|
||||
|
||||
fn reclift<T:Copy>(t: T) -> Recbox<T> { return Recbox {x: @t}; }
|
||||
fn reclift<T>(t: T) -> Recbox<T> { return Recbox {x: @t}; }
|
||||
|
||||
pub fn main() {
|
||||
let foo: int = 17;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
struct Recbox<T> {x: ~T}
|
||||
|
||||
fn reclift<T:Copy>(t: T) -> Recbox<T> { return Recbox {x: ~t}; }
|
||||
fn reclift<T>(t: T) -> Recbox<T> { return Recbox {x: ~t}; }
|
||||
|
||||
pub fn main() {
|
||||
let foo: int = 17;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,6 @@
|
|||
// -*- rust -*-
|
||||
|
||||
// Issue #45: infer type parameters in function applications
|
||||
fn id<T:Copy>(x: T) -> T { return x; }
|
||||
fn id<T>(x: T) -> T { return x; }
|
||||
|
||||
pub fn main() { let x: int = 42; let y: int = id(x); assert!((x == y)); }
|
||||
|
|
|
|||
|
|
@ -9,6 +9,6 @@
|
|||
// except according to those terms.
|
||||
|
||||
|
||||
fn f<T:Copy>(x: ~T) -> ~T { return x; }
|
||||
fn f<T>(x: ~T) -> ~T { return x; }
|
||||
|
||||
pub fn main() { let x = f(~3); info!(*x); }
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
|
||||
// -*- rust -*-
|
||||
fn id<T:Copy>(x: T) -> T { return x; }
|
||||
fn id<T>(x: T) -> T { return x; }
|
||||
|
||||
struct Triple {x: int, y: int, z: int}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn get_third<T:Copy>(t: (T, T, T)) -> T { let (_, _, x) = t; return x; }
|
||||
fn get_third<T>(t: (T, T, T)) -> T { let (_, _, x) = t; return x; }
|
||||
|
||||
pub fn main() {
|
||||
info!(get_third((1, 2, 3)));
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
struct Triple<T> { x: T, y: T, z: T }
|
||||
|
||||
fn box<T:Copy>(x: Triple<T>) -> ~Triple<T> { return ~x; }
|
||||
fn box<T>(x: Triple<T>) -> ~Triple<T> { return ~x; }
|
||||
|
||||
pub fn main() {
|
||||
let x: ~Triple<int> = box::<int>(Triple{x: 1, y: 2, z: 3});
|
||||
|
|
|
|||
|
|
@ -8,25 +8,25 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
trait clam<A:Copy> {
|
||||
trait clam<A> {
|
||||
fn chowder(&self, y: A);
|
||||
}
|
||||
struct foo<A> {
|
||||
x: A,
|
||||
}
|
||||
|
||||
impl<A:Copy> clam<A> for foo<A> {
|
||||
impl<A> clam<A> for foo<A> {
|
||||
fn chowder(&self, y: A) {
|
||||
}
|
||||
}
|
||||
|
||||
fn foo<A:Copy>(b: A) -> foo<A> {
|
||||
fn foo<A>(b: A) -> foo<A> {
|
||||
foo {
|
||||
x: b
|
||||
}
|
||||
}
|
||||
|
||||
fn f<A:Copy>(x: @clam<A>, a: A) {
|
||||
fn f<A>(x: @clam<A>, a: A) {
|
||||
x.chowder(a);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,18 +8,18 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
trait clam<A:Copy> { }
|
||||
trait clam<A> { }
|
||||
struct foo<A> {
|
||||
x: A,
|
||||
}
|
||||
|
||||
impl<A:Copy> foo<A> {
|
||||
impl<A> foo<A> {
|
||||
pub fn bar<B,C:clam<A>>(&self, c: C) -> B {
|
||||
fail!();
|
||||
}
|
||||
}
|
||||
|
||||
fn foo<A:Copy>(b: A) -> foo<A> {
|
||||
fn foo<A>(b: A) -> foo<A> {
|
||||
foo {
|
||||
x: b
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,18 +12,18 @@ struct c1<T> {
|
|||
x: T,
|
||||
}
|
||||
|
||||
impl<T:Copy> c1<T> {
|
||||
impl<T> c1<T> {
|
||||
pub fn f1(&self, x: int) {
|
||||
}
|
||||
}
|
||||
|
||||
fn c1<T:Copy>(x: T) -> c1<T> {
|
||||
fn c1<T>(x: T) -> c1<T> {
|
||||
c1 {
|
||||
x: x
|
||||
}
|
||||
}
|
||||
|
||||
impl<T:Copy> c1<T> {
|
||||
impl<T> c1<T> {
|
||||
pub fn f2(&self, x: int) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,17 +12,17 @@ struct c1<T> {
|
|||
x: T,
|
||||
}
|
||||
|
||||
impl<T:Copy> c1<T> {
|
||||
impl<T> c1<T> {
|
||||
pub fn f1(&self, x: T) {}
|
||||
}
|
||||
|
||||
fn c1<T:Copy>(x: T) -> c1<T> {
|
||||
fn c1<T>(x: T) -> c1<T> {
|
||||
c1 {
|
||||
x: x
|
||||
}
|
||||
}
|
||||
|
||||
impl<T:Copy> c1<T> {
|
||||
impl<T> c1<T> {
|
||||
pub fn f2(&self, x: T) {}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ fn C(x: uint) -> C {
|
|||
}
|
||||
}
|
||||
|
||||
fn f<T:Copy>(_x: T) {
|
||||
fn f<T>(_x: T) {
|
||||
}
|
||||
|
||||
#[deny(non_implicitly_copyable_typarams)]
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
// than the traits require.
|
||||
|
||||
trait A {
|
||||
fn b<C:Copy + Freeze,D>(x: C) -> C;
|
||||
fn b<C:Freeze,D>(x: C) -> C;
|
||||
}
|
||||
|
||||
struct E {
|
||||
|
|
@ -20,7 +20,7 @@ struct E {
|
|||
}
|
||||
|
||||
impl A for E {
|
||||
fn b<F:Copy,G>(_x: F) -> F { fail!() } //~ ERROR in method `b`, type parameter 0 has 1 bound, but
|
||||
fn b<F,G>(_x: F) -> F { fail!() } //~ ERROR in method `b`, type parameter 0 has 1 bound, but
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -8,12 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn Matrix4<T:Copy>(m11: T, m12: T, m13: T, m14: T,
|
||||
m21: T, m22: T, m23: T, m24: T,
|
||||
m31: T, m32: T, m33: T, m34: T,
|
||||
m41: T, m42: T, m43: T, m44: T)
|
||||
-> Matrix4<T> {
|
||||
|
||||
fn Matrix4<T>(m11: T, m12: T, m13: T, m14: T,
|
||||
m21: T, m22: T, m23: T, m24: T,
|
||||
m31: T, m32: T, m33: T, m34: T,
|
||||
m41: T, m42: T, m43: T, m44: T)
|
||||
-> Matrix4<T> {
|
||||
Matrix4 {
|
||||
m11: m11, m12: m12, m13: m13, m14: m14,
|
||||
m21: m21, m22: m22, m23: m23, m24: m24,
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn quux<T:Copy>(x: T) -> T { let f = id::<T>; return f(x); }
|
||||
fn quux<T>(x: T) -> T { let f = id::<T>; return f(x); }
|
||||
|
||||
fn id<T:Copy>(x: T) -> T { return x; }
|
||||
fn id<T>(x: T) -> T { return x; }
|
||||
|
||||
pub fn main() { assert!((quux(10) == 10)); }
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn double<T:Copy + Clone>(a: T) -> ~[T] { return ~[a.clone()] + ~[a]; }
|
||||
fn double<T:Clone>(a: T) -> ~[T] { return ~[a.clone()] + ~[a]; }
|
||||
|
||||
fn double_int(a: int) -> ~[int] { return ~[a] + ~[a]; }
|
||||
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@
|
|||
use std::int;
|
||||
|
||||
trait vec_monad<A> {
|
||||
fn bind<B:Copy>(&self, f: &fn(&A) -> ~[B]) -> ~[B];
|
||||
fn bind<B>(&self, f: &fn(&A) -> ~[B]) -> ~[B];
|
||||
}
|
||||
|
||||
impl<A> vec_monad<A> for ~[A] {
|
||||
fn bind<B:Copy>(&self, f: &fn(&A) -> ~[B]) -> ~[B] {
|
||||
fn bind<B>(&self, f: &fn(&A) -> ~[B]) -> ~[B] {
|
||||
let mut r = ~[];
|
||||
for self.iter().advance |elt| {
|
||||
r.push_all_move(f(elt));
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ impl Serializable for int {
|
|||
|
||||
struct F<A> { a: A }
|
||||
|
||||
impl<A:Copy + Serializable> Serializable for F<A> {
|
||||
impl<A:Serializable> Serializable for F<A> {
|
||||
fn serialize<S:Serializer>(&self, s: S) {
|
||||
self.a.serialize(s);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,15 +14,15 @@ extern mod extra;
|
|||
|
||||
use extra::list::*;
|
||||
|
||||
fn pure_length_go<T:Copy>(ls: @List<T>, acc: uint) -> uint {
|
||||
fn pure_length_go<T>(ls: @List<T>, acc: uint) -> uint {
|
||||
match *ls { Nil => { acc } Cons(_, tl) => { pure_length_go(tl, acc + 1u) } }
|
||||
}
|
||||
|
||||
fn pure_length<T:Copy>(ls: @List<T>) -> uint { pure_length_go(ls, 0u) }
|
||||
fn pure_length<T>(ls: @List<T>) -> uint { pure_length_go(ls, 0u) }
|
||||
|
||||
fn nonempty_list<T:Copy>(ls: @List<T>) -> bool { pure_length(ls) > 0u }
|
||||
fn nonempty_list<T>(ls: @List<T>) -> bool { pure_length(ls) > 0u }
|
||||
|
||||
fn safe_head<T:Copy>(ls: @List<T>) -> T {
|
||||
fn safe_head<T>(ls: @List<T>) -> T {
|
||||
assert!(!is_empty(ls));
|
||||
return head(ls);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ fn iter<T>(v: ~[T], it: &fn(&T) -> bool) -> bool {
|
|||
return true;
|
||||
}
|
||||
|
||||
fn find_pos<T:Eq + Copy + Clone>(n: T, h: ~[T]) -> Option<uint> {
|
||||
fn find_pos<T:Eq + Clone>(n: T, h: ~[T]) -> Option<uint> {
|
||||
let mut i = 0u;
|
||||
for iter(h.clone()) |e| {
|
||||
if *e == n { return Some(i); }
|
||||
|
|
|
|||
|
|
@ -12,6 +12,6 @@
|
|||
|
||||
enum option<T> { none, some(T), }
|
||||
|
||||
fn f<T:Copy>() -> option<T> { return none; }
|
||||
fn f<T>() -> option<T> { return none; }
|
||||
|
||||
pub fn main() { f::<int>(); }
|
||||
|
|
|
|||
|
|
@ -43,13 +43,13 @@ impl uint_utils for uint {
|
|||
trait vec_utils<T> {
|
||||
fn length_(&self, ) -> uint;
|
||||
fn iter_(&self, f: &fn(&T));
|
||||
fn map_<U:Copy>(&self, f: &fn(&T) -> U) -> ~[U];
|
||||
fn map_<U>(&self, f: &fn(&T) -> U) -> ~[U];
|
||||
}
|
||||
|
||||
impl<T> vec_utils<T> for ~[T] {
|
||||
fn length_(&self) -> uint { self.len() }
|
||||
fn iter_(&self, f: &fn(&T)) { for self.iter().advance |x| { f(x); } }
|
||||
fn map_<U:Copy>(&self, f: &fn(&T) -> U) -> ~[U] {
|
||||
fn map_<U>(&self, f: &fn(&T) -> U) -> ~[U] {
|
||||
let mut r = ~[];
|
||||
for self.iter().advance |elt| {
|
||||
r.push(f(elt));
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ struct t_rec<A,B> {
|
|||
tB: a_tag<A,B>
|
||||
}
|
||||
|
||||
fn mk_rec<A:Copy,B:Copy>(a: A, b: B) -> t_rec<A,B> {
|
||||
fn mk_rec<A,B>(a: A, b: B) -> t_rec<A,B> {
|
||||
return t_rec{ chA:0u8, tA:varA(a), chB:1u8, tB:varB(b) };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ fn c(x: ~Foo:Freeze+Send) {
|
|||
a(x);
|
||||
}
|
||||
|
||||
fn d(x: ~Foo:Send+Copy) {
|
||||
fn d(x: ~Foo:Send) {
|
||||
b(x);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ impl to_str for () {
|
|||
}
|
||||
|
||||
trait map<T> {
|
||||
fn map<U:Copy>(&self, f: &fn(&T) -> U) -> ~[U];
|
||||
fn map<U>(&self, f: &fn(&T) -> U) -> ~[U];
|
||||
}
|
||||
impl<T> map<T> for ~[T] {
|
||||
fn map<U:Copy>(&self, f: &fn(&T) -> U) -> ~[U] {
|
||||
fn map<U>(&self, f: &fn(&T) -> U) -> ~[U] {
|
||||
let mut r = ~[];
|
||||
// FIXME: #7355 generates bad code with Iterator
|
||||
for std::uint::range(0, self.len()) |i| {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
extern mod trait_inheritance_overloading_xc;
|
||||
use trait_inheritance_overloading_xc::{MyNum, MyInt};
|
||||
|
||||
fn f<T:Copy + MyNum>(x: T, y: T) -> (T, T, T) {
|
||||
fn f<T:MyNum>(x: T, y: T) -> (T, T, T) {
|
||||
return (x + y, x - y, x * y);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ impl Eq for MyInt {
|
|||
|
||||
impl MyNum for MyInt;
|
||||
|
||||
fn f<T:Copy + MyNum>(x: T, y: T) -> (T, T, T) {
|
||||
fn f<T:MyNum>(x: T, y: T) -> (T, T, T) {
|
||||
return (x + y, x - y, x * y);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
// xfail-fast
|
||||
|
||||
fn p_foo<T>(pinned: T) { }
|
||||
fn s_foo<T:Copy>(shared: T) { }
|
||||
fn s_foo<T>(shared: T) { }
|
||||
fn u_foo<T:Send>(unique: T) { }
|
||||
|
||||
struct r {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ struct Pointy {
|
|||
d : ~fn() -> uint,
|
||||
}
|
||||
|
||||
fn make_uniq_closure<A:Send + Copy>(a: A) -> ~fn() -> uint {
|
||||
fn make_uniq_closure<A:Send>(a: A) -> ~fn() -> uint {
|
||||
let result: ~fn() -> uint = || ptr::to_unsafe_ptr(&a) as uint;
|
||||
result
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn f<T:Copy>(t: T) -> T {
|
||||
fn f<T>(t: T) -> T {
|
||||
let t1 = t;
|
||||
t1
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
// Issue #976
|
||||
|
||||
fn f<T:Copy>(x: ~T) {
|
||||
fn f<T>(x: ~T) {
|
||||
let _x2 = x;
|
||||
}
|
||||
pub fn main() { }
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ fn sendable() {
|
|||
|
||||
fn copyable() {
|
||||
|
||||
fn f<T:Copy + Eq>(i: T, j: T) {
|
||||
fn f<T:Eq>(i: T, j: T) {
|
||||
assert_eq!(i, j);
|
||||
}
|
||||
|
||||
fn g<T:Copy + Eq>(i: T, j: T) {
|
||||
fn g<T:Eq>(i: T, j: T) {
|
||||
assert!(i != j);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
fn foldl<T, U: Copy+Clone>(
|
||||
values: &[T],
|
||||
initial: U,
|
||||
function: &fn(partial: U, element: &T) -> U
|
||||
) -> U {
|
||||
fn foldl<T,U:Clone>(values: &[T],
|
||||
initial: U,
|
||||
function: &fn(partial: U, element: &T) -> U)
|
||||
-> U {
|
||||
match values {
|
||||
[ref head, ..tail] =>
|
||||
foldl(tail, function(initial, head), function),
|
||||
|
|
@ -10,11 +9,10 @@ fn foldl<T, U: Copy+Clone>(
|
|||
}
|
||||
}
|
||||
|
||||
fn foldr<T, U: Copy+Clone>(
|
||||
values: &[T],
|
||||
initial: U,
|
||||
function: &fn(element: &T, partial: U) -> U
|
||||
) -> U {
|
||||
fn foldr<T,U:Clone>(values: &[T],
|
||||
initial: U,
|
||||
function: &fn(element: &T, partial: U) -> U)
|
||||
-> U {
|
||||
match values {
|
||||
[..head, ref tail] =>
|
||||
foldr(head, function(tail, initial), function),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue