about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2012-01-02 15:31:58 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2012-01-02 15:31:58 +0100
commit15be2fc73a4cbed9ac121a91b683812fd3cf1d8a (patch)
treebf590e46234f2fcc34a78e47ef42527bc0683612
parent8c14943dead216ce62b9197a6030dad8e2047428 (diff)
downloadrust-15be2fc73a4cbed9ac121a91b683812fd3cf1d8a.tar.gz
rust-15be2fc73a4cbed9ac121a91b683812fd3cf1d8a.zip
Add 'copy' bounds to functions that were faultily accepted without
Issue #1390
-rw-r--r--src/libcore/option.rs6
-rw-r--r--src/libcore/result.rs4
-rw-r--r--src/libstd/deque.rs2
-rw-r--r--src/libstd/util.rs2
-rw-r--r--src/test/run-pass/expr-alt-generic-box2.rs2
-rw-r--r--src/test/run-pass/expr-alt-generic-unique1.rs2
-rw-r--r--src/test/run-pass/expr-alt-generic-unique2.rs2
-rw-r--r--src/test/run-pass/expr-alt-generic.rs2
-rw-r--r--src/test/run-pass/expr-fn.rs2
9 files changed, 12 insertions, 12 deletions
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index aaaf82eb7cd..e0a137ca9e8 100644
--- a/src/libcore/option.rs
+++ b/src/libcore/option.rs
@@ -36,7 +36,7 @@ pure fn get<copy T>(opt: t<T>) -> T {
 
 /*
 */
-fn map<T, U>(opt: t<T>, f: block(T) -> U) -> t<U> {
+fn map<T, copy U>(opt: t<T>, f: block(T) -> U) -> t<U> {
     alt opt { some(x) { some(f(x)) } none. { none } }
 }
 
@@ -61,7 +61,7 @@ Function: from_maybe
 
 Returns the contained value or a default
 */
-pure fn from_maybe<T>(def: T, opt: t<T>) -> T {
+pure fn from_maybe<copy T>(def: T, opt: t<T>) -> T {
     alt opt { some(x) { x } none. { def } }
 }
 
@@ -70,7 +70,7 @@ Function: maybe
 
 Applies a function to the contained value or returns a default
 */
-fn maybe<T, U>(def: U, opt: t<T>, f: block(T) -> U) -> U {
+fn maybe<T, copy U>(def: U, opt: t<T>, f: block(T) -> U) -> U {
     alt opt { none. { def } some(t) { f(t) } }
 }
 
diff --git a/src/libcore/result.rs b/src/libcore/result.rs
index 84fbc3b7f90..91038474ead 100644
--- a/src/libcore/result.rs
+++ b/src/libcore/result.rs
@@ -37,7 +37,7 @@ Failure:
 
 If the result is an error
 */
-fn get<T, U>(res: t<T, U>) -> T {
+fn get<copy T, U>(res: t<T, U>) -> T {
     alt res {
       ok(t) { t }
       err(_) {
@@ -57,7 +57,7 @@ Failure:
 
 If the result is not an error
 */
-fn get_err<T, U>(res: t<T, U>) -> U {
+fn get_err<T, copy U>(res: t<T, U>) -> U {
     alt res {
       err(u) { u }
       ok(_) {
diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs
index 7c0a13bb5f8..8da26c55b10 100644
--- a/src/libstd/deque.rs
+++ b/src/libstd/deque.rs
@@ -57,7 +57,7 @@ fn create<copy T>() -> t<T> {
 
         ret rv;
     }
-    fn get<T>(elts: [mutable cell<T>], i: uint) -> T {
+    fn get<copy T>(elts: [mutable cell<T>], i: uint) -> T {
         ret alt elts[i] { option::some(t) { t } _ { fail } };
     }
     obj deque<copy T>(mutable nelts: uint,
diff --git a/src/libstd/util.rs b/src/libstd/util.rs
index a15b5291546..f4d984a8937 100644
--- a/src/libstd/util.rs
+++ b/src/libstd/util.rs
@@ -7,7 +7,7 @@ Function: id
 
 The identity function
 */
-pure fn id<T>(x: T) -> T { x }
+pure fn id<copy T>(x: T) -> T { x }
 
 /*
 Function: unreachable
diff --git a/src/test/run-pass/expr-alt-generic-box2.rs b/src/test/run-pass/expr-alt-generic-box2.rs
index 53cab4546e2..bc19200e323 100644
--- a/src/test/run-pass/expr-alt-generic-box2.rs
+++ b/src/test/run-pass/expr-alt-generic-box2.rs
@@ -4,7 +4,7 @@
 // -*- rust -*-
 type compare<T> = fn@(T, T) -> bool;
 
-fn test_generic<T>(expected: T, eq: compare<T>) {
+fn test_generic<copy T>(expected: T, eq: compare<T>) {
     let actual: T = alt true { true { expected } };
     assert (eq(expected, actual));
 }
diff --git a/src/test/run-pass/expr-alt-generic-unique1.rs b/src/test/run-pass/expr-alt-generic-unique1.rs
index e8b949e9410..301d56389b1 100644
--- a/src/test/run-pass/expr-alt-generic-unique1.rs
+++ b/src/test/run-pass/expr-alt-generic-unique1.rs
@@ -3,7 +3,7 @@
 // -*- rust -*-
 type compare<T> = fn@(~T, ~T) -> bool;
 
-fn test_generic<T>(expected: ~T, eq: compare<T>) {
+fn test_generic<copy T>(expected: ~T, eq: compare<T>) {
     let actual: ~T = alt true { true { expected } };
     assert (eq(expected, actual));
 }
diff --git a/src/test/run-pass/expr-alt-generic-unique2.rs b/src/test/run-pass/expr-alt-generic-unique2.rs
index ee0be17ffa2..5640dca0b4e 100644
--- a/src/test/run-pass/expr-alt-generic-unique2.rs
+++ b/src/test/run-pass/expr-alt-generic-unique2.rs
@@ -4,7 +4,7 @@
 // -*- rust -*-
 type compare<T> = fn@(T, T) -> bool;
 
-fn test_generic<T>(expected: T, eq: compare<T>) {
+fn test_generic<copy T>(expected: T, eq: compare<T>) {
     let actual: T = alt true { true { expected } };
     assert (eq(expected, actual));
 }
diff --git a/src/test/run-pass/expr-alt-generic.rs b/src/test/run-pass/expr-alt-generic.rs
index c3df90f7fdc..5a2f7d8b71c 100644
--- a/src/test/run-pass/expr-alt-generic.rs
+++ b/src/test/run-pass/expr-alt-generic.rs
@@ -4,7 +4,7 @@
 // -*- rust -*-
 type compare<T> = fn@(T, T) -> bool;
 
-fn test_generic<T>(expected: T, eq: compare<T>) {
+fn test_generic<copy T>(expected: T, eq: compare<T>) {
     let actual: T = alt true { true { expected } };
     assert (eq(expected, actual));
 }
diff --git a/src/test/run-pass/expr-fn.rs b/src/test/run-pass/expr-fn.rs
index 30ba5fa79e4..5cd3f2a178b 100644
--- a/src/test/run-pass/expr-fn.rs
+++ b/src/test/run-pass/expr-fn.rs
@@ -9,7 +9,7 @@ fn test_vec() {
 }
 
 fn test_generic() {
-    fn f<T>(t: T) -> T { t }
+    fn f<copy T>(t: T) -> T { t }
     assert (f(10) == 10);
 }