]> git.lizzy.rs Git - rust.git/commitdiff
test: Fix tests.
authorPatrick Walton <pcwalton@mimiga.net>
Thu, 11 Jul 2013 19:05:17 +0000 (12:05 -0700)
committerPatrick Walton <pcwalton@mimiga.net>
Wed, 17 Jul 2013 21:57:54 +0000 (14:57 -0700)
36 files changed:
doc/rust.md
doc/tutorial.md
src/compiletest/common.rs
src/compiletest/compiletest.rs
src/compiletest/errors.rs
src/compiletest/header.rs
src/compiletest/runtest.rs
src/libextra/bitv.rs
src/libextra/crypto/sha1.rs
src/libextra/fileinput.rs
src/libextra/list.rs
src/libextra/net/ip.rs
src/libextra/net/tcp.rs
src/libextra/priority_queue.rs
src/libextra/sort.rs
src/libextra/test.rs
src/libextra/uv_ll.rs
src/librustpkg/tests.rs
src/librustpkg/testsuite/pass/src/fancy-lib/pkg.rs
src/libstd/io.rs
src/libstd/rt/uv/net.rs
src/libstd/to_str.rs
src/libstd/vec.rs
src/libsyntax/ast_util.rs
src/test/bench/core-std.rs
src/test/bench/graph500-bfs.rs
src/test/bench/shootout-fasta.rs
src/test/bench/shootout-k-nucleotide-pipes.rs
src/test/compile-fail/closure-bounds-subtype.rs
src/test/compile-fail/issue-2548.rs
src/test/compile-fail/trait-bounds-cant-coerce.rs
src/test/compile-fail/vec-res-add.rs
src/test/run-pass/issue-2989.rs
src/test/run-pass/log-knows-the-names-of-variants-in-std.rs
src/test/run-pass/non-boolean-pure-fns.rs
src/test/run-pass/repeated-vector-syntax.rs

index 9948ec79fc6cd8e2264115ddd8f4595293d905ee..f58d420bff58c0494f4c6c61eb8d7fe3ac1c211d 100644 (file)
@@ -206,7 +206,6 @@ The keywords are the following strings:
 ~~~~~~~~ {.keyword}
 as
 break
-copy
 do
 else enum extern
 false fn for
@@ -443,7 +442,7 @@ Two examples of paths with type arguments:
 ~~~~
 # use std::hashmap::HashMap;
 # fn f() {
-# fn id<T:Copy>(t: T) -> T { t }
+# fn id<T>(t: T) -> T { t }
 type t = HashMap<int,~str>;  // Type arguments used in a type expression
 let x = id::<int>(10);         // Type arguments used in a call expression
 # }
@@ -907,11 +906,10 @@ example, `sys::size_of::<u32>() == 4`.
 
 Since a parameter type is opaque to the generic function, the set of
 operations that can be performed on it is limited. Values of parameter
-type can always be moved, but they can only be copied when the
-parameter is given a [`Copy` bound](#type-kinds).
+type can only be moved, not copied.
 
 ~~~~
-fn id<T: Copy>(x: T) -> T { x }
+fn id<T>(x: T) -> T { x }
 ~~~~
 
 Similarly, [trait](#traits) bounds can be specified for type
@@ -1519,8 +1517,6 @@ A complete list of the built-in language items follows:
 
 `const`
   : Cannot be mutated.
-`copy`
-  : Can be implicitly copied.
 `owned`
   : Are uniquely owned.
 `durable`
@@ -1587,7 +1583,8 @@ A complete list of the built-in language items follows:
 `check_not_borrowed`
   : Fail if a value has existing borrowed pointers to it.
 `strdup_uniq`
-  : Return a new unique string containing a copy of the contents of a unique string.
+  : Return a new unique string
+    containing a copy of the contents of a unique string.
 
 > **Note:** This list is likely to become out of date. We should auto-generate it
 > from `librustc/middle/lang_items.rs`.
@@ -1736,10 +1733,13 @@ A temporary's lifetime equals the largest lifetime of any borrowed pointer that
 
 #### Moved and copied types
 
-When a [local variable](#memory-slots) is used as an [rvalue](#lvalues-rvalues-and-temporaries)
-the variable will either be [moved](#move-expressions) or [copied](#copy-expressions),
+When a [local variable](#memory-slots) is used
+as an [rvalue](#lvalues-rvalues-and-temporaries)
+the variable will either be [moved](#move-expressions) or copied,
 depending on its type.
-For types that contain mutable fields or [owning pointers](#owning-pointers), the variable is moved.
+For types that contain [owning pointers](#owning-pointers)
+or values that implement the special trait `Drop`,
+the variable is moved.
 All other types are copied.
 
 
@@ -1918,9 +1918,9 @@ task in a _failing state_.
 
 ### Unary operator expressions
 
-Rust defines six symbolic unary operators,
-in addition to the unary [copy](#unary-copy-expressions) and [move](#unary-move-expressions) operators.
-They are all written as prefix operators, before the expression they apply to.
+Rust defines six symbolic unary operators.
+They are all written as prefix operators,
+before the expression they apply to.
 
 `-`
   : Negation. May only be applied to numeric types.
@@ -2119,60 +2119,6 @@ An example of a parenthesized expression:
 let x = (2 + 3) * 4;
 ~~~~
 
-### Unary copy expressions
-
-~~~~~~~~{.ebnf .gram}
-copy_expr : "copy" expr ;
-~~~~~~~~
-
-> **Note:** `copy` expressions are deprecated. It's preferable to use
-> the `Clone` trait and `clone()` method.
-
-A _unary copy expression_ consists of the unary `copy` operator applied to
-some argument expression.
-
-Evaluating a copy expression first evaluates the argument expression, then
-copies the resulting value, allocating any memory necessary to hold the new
-copy.
-
-[Managed boxes](#pointer-types) (type `@`) are, as usual, shallow-copied,
-as are raw and borrowed pointers.
-[Owned boxes](#pointer-types), [owned vectors](#vector-types) and similar owned types are deep-copied.
-
-Since the binary [assignment operator](#assignment-expressions) `=` performs a copy or move implicitly,
-the unary copy operator is typically only used to cause an argument to a function to be copied and passed by value.
-
-An example of a copy expression:
-
-~~~~
-fn mutate(mut vec: ~[int]) {
-   vec[0] = 10;
-}
-
-let v = ~[1,2,3];
-
-mutate(copy v);   // Pass a copy
-
-assert!(v[0] == 1); // Original was not modified
-~~~~
-
-### Unary move expressions
-
-~~~~~~~~{.ebnf .gram}
-move_expr : "move" expr ;
-~~~~~~~~
-
-A _unary move expression_ is similar to a [unary copy](#unary-copy-expressions) expression,
-except that it can only be applied to a [local variable](#memory-slots),
-and it performs a _move_ on its operand, rather than a copy.
-That is, the memory location denoted by its operand is de-initialized after evaluation,
-and the resulting value is a shallow copy of the operand,
-even if the operand is an [owning type](#type-kinds).
-
-
-> **Note:** In future versions of Rust, `move` may be removed as a separate operator;
-> moves are now [automatically performed](#moved-and-copied-types) for most cases `move` would be appropriate.
-
 
 ### Call expressions
 
@@ -2507,10 +2453,11 @@ match x {
 }
 ~~~~
 
-Patterns that bind variables default to binding to a copy or move of the matched value
+Patterns that bind variables
+default to binding to a copy or move of the matched value
 (depending on the matched value's type).
-This can be made explicit using the ```copy``` keyword,
-changed to bind to a borrowed pointer by using the ```ref``` keyword,
+This can be changed to bind to a borrowed pointer by
+using the ```ref``` keyword,
 or to a mutable borrowed pointer using ```ref mut```.
 
 A pattern that's just an identifier,
@@ -2896,16 +2843,18 @@ and the cast expression in `main`.
 Within the body of an item that has type parameter declarations, the names of its type parameters are types:
 
 ~~~~~~~
-fn map<A: Copy, B: Copy>(f: &fn(A) -> B, xs: &[A]) -> ~[B] {
-   if xs.len() == 0 { return ~[]; }
-   let first: B = f(copy xs[0]);
-   let rest: ~[B] = map(f, xs.slice(1, xs.len()));
-   return ~[first] + rest;
+fn map<A: Clone, B: Clone>(f: &fn(A) -> B, xs: &[A]) -> ~[B] {
+    if xs.len() == 0 {
+       return ~[];
+    }
+    let first: B = f(xs[0].clone());
+    let rest: ~[B] = map(f, xs.slice(1, xs.len()));
+    return ~[first] + rest;
 }
 ~~~~~~~
 
-Here, `first` has type `B`, referring to `map`'s `B` type parameter; and `rest` has
-type `~[B]`, a vector type with element type `B`.
+Here, `first` has type `B`, referring to `map`'s `B` type parameter;
+and `rest` has type `~[B]`, a vector type with element type `B`.
 
 ### Self types
 
@@ -2919,7 +2868,9 @@ trait Printable {
 }
 
 impl Printable for ~str {
-  fn make_string(&self) -> ~str { copy *self }
+    fn make_string(&self) -> ~str {
+        (*self).clone()
+    }
 }
 ~~~~~~~~
 
@@ -2933,23 +2884,29 @@ The kinds are:
 
 `Freeze`
   : Types of this kind are deeply immutable;
-    they contain no mutable memory locations directly or indirectly via pointers.
+    they contain no mutable memory locations
+    directly or indirectly via pointers.
 `Send`
   : Types of this kind can be safely sent between tasks.
     This kind includes scalars, owning pointers, owned closures, and
-    structural types containing only other owned types. All `Send` types are `Static`.
-`Copy`
-  : This kind includes all types that can be copied. All types with
-    sendable kind are copyable, as are managed boxes, managed closures,
-    trait types, and structural types built out of these.
-    Types with destructors (types that implement `Drop`) can not implement `Copy`.
+    structural types containing only other owned types.
+    All `Send` types are `'static`.
+`'static`
+  : Types of this kind do not contain any borrowed pointers;
+    this can be a useful guarantee for code
+    that breaks borrowing assumptions
+    using [`unsafe` operations](#unsafe-functions).
 `Drop`
-  : This is not strictly a kind, but its presence interacts with kinds: the `Drop`
-    trait provides a single method `drop` that takes no parameters, and is run
-    when values of the type are dropped. Such a method is called a "destructor",
-    and are always executed in "top-down" order: a value is completely destroyed
-    before any of the values it owns run their destructors. Only `Send` types
-    that do not implement `Copy` can implement `Drop`.
+  : This is not strictly a kind,
+    but its presence interacts with kinds:
+    the `Drop` trait provides a single method `drop`
+    that takes no parameters,
+    and is run when values of the type are dropped.
+    Such a method is called a "destructor",
+    and are always executed in "top-down" order:
+    a value is completely destroyed
+    before any of the values it owns run their destructors.
+    Only `Send` types can implement `Drop`.
 
 _Default_
   : Types with destructors, closure environments,
@@ -2962,30 +2919,15 @@ Kinds can be supplied as _bounds_ on type parameters, like traits,
 in which case the parameter is constrained to types satisfying that kind.
 
 By default, type parameters do not carry any assumed kind-bounds at all.
+When instantiating a type parameter,
+the kind bounds on the parameter are checked
+to be the same or narrower than the kind
+of the type that it is instantiated with.
 
-Any operation that causes a value to be copied requires the type of that value to be of copyable kind,
-so the `Copy` bound is frequently required on function type parameters.
-For example, this is not a valid program:
-
-~~~~{.xfail-test}
-fn box<T>(x: T) -> @T { @x }
-~~~~
-
-Putting `x` into a managed box involves copying, and the `T` parameter has the default (non-copyable) kind.
-To change that, a bound is declared:
-
-~~~~
-fn box<T: Copy>(x: T) -> @T { @x }
-~~~~
-
-Calling this second version of `box` on a noncopyable type is not
-allowed. When instantiating a type parameter, the kind bounds on the
-parameter are checked to be the same or narrower than the kind of the
-type that it is instantiated with.
-
-Sending operations are not part of the Rust language, but are
-implemented in the library. Generic functions that send values bound
-the kind of these values to sendable.
+Sending operations are not part of the Rust language,
+but are implemented in the library.
+Generic functions that send values
+bound the kind of these values to sendable.
 
 # Memory and concurrency models
 
@@ -3093,9 +3035,7 @@ managed box value makes a shallow copy of the pointer (optionally incrementing
 a reference count, if the managed box is implemented through
 reference-counting).
 
-Owned box values exist in 1:1 correspondence with their heap allocation;
-copying an owned box value makes a deep copy of the heap allocation and
-produces a pointer to the new allocation.
+Owned box values exist in 1:1 correspondence with their heap allocation.
 
 An example of constructing one managed box type and value, and one owned box
 type and value:
index b282679b1a1d45490f54f651e554ac8722a573de..3c0400cd3afb5c449c6adab061c3c6f097940747 100644 (file)
@@ -1275,6 +1275,11 @@ The `+` operator means concatenation when applied to vector types.
 # enum Crayon { Almond, AntiqueBrass, Apricot,
 #               Aquamarine, Asparagus, AtomicTangerine,
 #               BananaMania, Beaver, Bittersweet };
+# impl Clone for Crayon {
+#     fn clone(&self) -> Crayon {
+#         *self
+#     }
+# }
 
 let my_crayons = ~[Almond, AntiqueBrass, Apricot];
 let your_crayons = ~[BananaMania, Beaver, Bittersweet];
@@ -1827,15 +1832,17 @@ similarities to type classes. Rust's traits are a form of *bounded
 polymorphism*: a trait is a way of limiting the set of possible types
 that a type parameter could refer to.
 
-As motivation, let us consider copying in Rust. The `copy` operation
-is not defined for all Rust types. One reason is user-defined
-destructors: copying a type that has a destructor could result in the
-destructor running multiple times. Therefore, types with user-defined
-destructors cannot be copied, either implicitly or explicitly, and
-neither can types that own other types containing destructors.
-
-This complicates handling of generic functions. If you have a type
-parameter `T`, can you copy values of that type? In Rust, you can't,
+As motivation, let us consider copying in Rust.
+The `clone` method is not defined for all Rust types.
+One reason is user-defined destructors:
+copying a type that has a destructor
+could result in the destructor running multiple times.
+Therefore, types with destructors cannot be copied
+unless you explicitly implement `Clone` for them.
+
+This complicates handling of generic functions.
+If you have a type parameter `T`, can you copy values of that type?
+In Rust, you can't,
 and if you try to run the following code the compiler will complain.
 
 ~~~~ {.xfail-test}
@@ -1845,42 +1852,43 @@ fn head_bad<T>(v: &[T]) -> T {
 }
 ~~~~
 
-However, we can tell the compiler that the `head` function is only for
-copyable types: that is, those that have the `Copy` trait. In that
-case, we can explicitly create a second copy of the value we are
-returning using the `copy` keyword:
+However, we can tell the compiler
+that the `head` function is only for copyable types:
+that is, those that implement the `Clone` trait.
+In that case,
+we can explicitly create a second copy of the value we are returning
+using the `clone` keyword:
 
 ~~~~
 // This does
-fn head<T: Copy>(v: &[T]) -> T {
-    copy v[0]
+fn head<T: Clone>(v: &[T]) -> T {
+    v[0].clone()
 }
 ~~~~
 
-This says that we can call `head` on any type `T` as long as that type
-implements the `Copy` trait. When instantiating a generic function,
-you can only instantiate it with types that implement the correct
-trait, so you could not apply `head` to a type with a
-destructor. (`Copy` is a special trait that is built in to the
-compiler, making it possible for the compiler to enforce this
-restriction.)
-
-While most traits can be defined and implemented by user code, three
-traits are automatically derived and implemented for all applicable
-types by the compiler, and may not be overridden:
+This says that we can call `head` on any type `T`
+as long as that type implements the `Clone` trait.
+When instantiating a generic function,
+you can only instantiate it with types
+that implement the correct trait,
+so you could not apply `head` to a type
+that does not implement `Clone`.
 
-* `Copy` - Types that can be copied, either implicitly, or explicitly with the
-  `copy` operator. All types are copyable unless they have destructors or
-  contain types with destructors.
+While most traits can be defined and implemented by user code,
+two traits are automatically derived and implemented
+for all applicable types by the compiler,
+and may not be overridden:
 
-* `Owned` - Owned types. Types are owned unless they contain managed
-  boxes, managed closures, or borrowed pointers. Owned types may or
-  may not be copyable.
+* `Send` - Sendable types.
+Types are sendable
+unless they contain managed boxes, managed closures, or borrowed pointers.
 
-* `Const` - Constant (immutable) types. These are types that do not contain
-  mutable fields.
+* `Freeze` - Constant (immutable) types.
+These are types that do not contain anything intrinsically mutable.
+Intrinsically mutable values include `@mut`
+and `Cell` in the standard library.
 
-> ***Note:*** These three traits were referred to as 'kinds' in earlier
+> ***Note:*** These two traits were referred to as 'kinds' in earlier
 > iterations of the language, and often still are.
 
 Additionally, the `Drop` trait is used to define destructors. This
@@ -1908,10 +1916,11 @@ may call it.
 
 ## Declaring and implementing traits
 
-A trait consists of a set of methods, without bodies, or may be empty,
-as is the case with `Copy`, `Owned`, and `Const`. For example, we could
-declare the trait `Printable` for things that can be printed to the
-console, with a single method:
+A trait consists of a set of methods without bodies,
+or may be empty, as is the case with `Send` and `Freeze`.
+For example, we could declare the trait
+`Printable` for things that can be printed to the console,
+with a single method:
 
 ~~~~
 trait Printable {
@@ -2030,7 +2039,7 @@ fn print_all<T: Printable>(printable_things: ~[T]) {
 ~~~~
 
 Declaring `T` as conforming to the `Printable` trait (as we earlier
-did with `Copy`) makes it possible to call methods from that trait
+did with `Clone`) makes it possible to call methods from that trait
 on values of type `T` inside the function. It will also cause a
 compile-time error when anyone tries to call `print_all` on an array
 whose element type does not have a `Printable` implementation.
@@ -2040,10 +2049,10 @@ as in this version of `print_all` that copies elements.
 
 ~~~
 # trait Printable { fn print(&self); }
-fn print_all<T: Printable + Copy>(printable_things: ~[T]) {
+fn print_all<T: Printable + Clone>(printable_things: ~[T]) {
     let mut i = 0;
     while i < printable_things.len() {
-        let copy_of_thing = copy printable_things[i];
+        let copy_of_thing = printable_things[i].clone();
         copy_of_thing.print();
         i += 1;
     }
index 4add16fd7a95b08bf9c19b0cac74eec1d0678fd0..bc5741de2b98f5723e83450a415dc7d940c36d0d 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#[deriving(Eq)]
+#[deriving(Clone, Eq)]
 pub enum mode {
     mode_compile_fail,
     mode_run_fail,
@@ -18,6 +18,7 @@ pub enum mode {
     mode_codegen
 }
 
+#[deriving(Clone)]
 pub struct config {
     // The library paths required for running the compiler
     compile_lib_path: ~str,
index 76e3f2f32ee77090bf8dff3f9e00f813c6d1361f..012db7409a487703de8e166a0beddc1832282e25 100644 (file)
 pub mod common;
 pub mod errors;
 
+<<<<<<< HEAD
+=======
+mod std {
+    pub use core::clone;
+    pub use core::cmp;
+    pub use core::str;
+    pub use core::sys;
+    pub use core::unstable;
+}
+
+>>>>>>> test: Fix tests.
 pub fn main() {
     let args = os::args();
     let config = parse_config(args);
@@ -117,10 +128,17 @@ fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
         mode: str_mode(getopts::opt_str(matches, "mode")),
         run_ignored: getopts::opt_present(matches, "ignored"),
         filter:
+<<<<<<< HEAD
             if !matches.free.is_empty() {
                  Some(matches.free[0].clone())
             } else {
                 None
+=======
+             if !matches.free.is_empty() {
+                option::Some(matches.free[0].clone())
+             } else {
+                option::None
+>>>>>>> test: Fix tests.
             },
         logfile: getopts::opt_maybe_str(matches, "logfile").map(|s| Path(*s)),
         save_metrics: getopts::opt_maybe_str(matches, "save-metrics").map(|s| Path(*s)),
index 780a917c019b22cca0a31da042d2e1b2aea1e707..b044f19dcd6292bca19191c26083d3112b95b11b 100644 (file)
@@ -15,7 +15,7 @@ pub struct ExpectedError { line: uint, kind: ~str, msg: ~str }
 // Load any test directives embedded in the file
 pub fn load_errors(testfile: &Path) -> ~[ExpectedError] {
     let mut error_patterns = ~[];
-    let rdr = io::file_reader(testfile).get();
+    let rdr = io::file_reader(testfile).unwrap();
     let mut line_num = 1u;
     while !rdr.eof() {
         let ln = rdr.read_line();
index 9cd489f05766afd2591bffb4be2210a51172efd5..0860219e1a999723a89171aaf2b38045f609eaba 100644 (file)
@@ -101,7 +101,7 @@ fn xfail_target() -> ~str {
 }
 
 fn iter_header(testfile: &Path, it: &fn(~str) -> bool) -> bool {
-    let rdr = io::file_reader(testfile).get();
+    let rdr = io::file_reader(testfile).unwrap();
     while !rdr.eof() {
         let ln = rdr.read_line();
 
index f071c204810f0fdaee6d5783e83eea8271fd5031..76e5d3e6b4e3448b878fc9c6c760a2935a367599 100644 (file)
@@ -672,7 +672,7 @@ fn dump_output_file(config: &config, testfile: &Path,
                     out: &str, extension: &str) {
     let outfile = make_out_name(config, testfile, extension);
     let writer =
-        io::file_writer(&outfile, [io::Create, io::Truncate]).get();
+        io::file_writer(&outfile, [io::Create, io::Truncate]).unwrap();
     writer.write_str(out);
 }
 
index f3f0f42125d4513a82b191959a745cf9571f2897..106b7c80f18f42bc8ebd710e499fe16ce7815db7 100644 (file)
@@ -1453,7 +1453,7 @@ fn bench_big_bitv_small(b: &mut BenchHarness) {
     fn bench_big_bitv_big(b: &mut BenchHarness) {
         let mut r = rng();
         let mut storage = ~[];
-        storage.grow(BENCH_BITS / uint::bits, &0);
+        storage.grow(BENCH_BITS / uint::bits, &0u);
         let mut bitv = BigBitv::new(storage);
         do b.iter {
             bitv.set((r.next() as uint) % BENCH_BITS, true);
index 0f2d44f57e34c457762a38ec3160cded370aca3e..83cef9972d7356c36d0aa99afa250be4607c9333 100644 (file)
@@ -244,14 +244,15 @@ mod tests {
     use digest::{Digest, DigestUtil};
     use sha1::Sha1;
 
+    #[deriving(Clone)]
+    struct Test {
+        input: ~str,
+        output: ~[u8],
+        output_str: ~str,
+    }
+
     #[test]
     fn test() {
-        struct Test {
-            input: ~str,
-            output: ~[u8],
-            output_str: ~str,
-        }
-
         fn a_million_letter_a() -> ~str {
             let mut i = 0;
             let mut rs = ~"";
index cc87809ad5b716d1faa21e0e1d3c3e2d162fbf70..f7c54634fe4c208bea7a723337fde8b10669ee3d 100644 (file)
@@ -417,7 +417,7 @@ mod test {
     use std::vec;
 
     fn make_file(path : &Path, contents: &[~str]) {
-        let file = io::file_writer(path, [io::Create, io::Truncate]).get();
+        let file = io::file_writer(path, [io::Create, io::Truncate]).unwrap();
 
         for contents.iter().advance |str| {
             file.write_str(*str);
@@ -562,9 +562,11 @@ fn test_no_trailing_newline() {
         let f2 =
             Some(Path("tmp/lib-fileinput-test-no-trailing-newline-2.tmp"));
 
-        let wr = io::file_writer(f1.get_ref(), [io::Create, io::Truncate]).get();
+        let wr = io::file_writer(f1.get_ref(),
+                                 [io::Create, io::Truncate]).unwrap();
         wr.write_str("1\n2");
-        let wr = io::file_writer(f2.get_ref(), [io::Create, io::Truncate]).get();
+        let wr = io::file_writer(f2.get_ref(),
+                                 [io::Create, io::Truncate]).unwrap();
         wr.write_str("3\n4");
 
         let mut lines = ~[];
index 87d0c05aec1e783fac19638a4e1922dac8f9f015..0348176057960ef0cc416e714ab6c86748387916 100644 (file)
@@ -12,7 +12,7 @@
 
 
 
-#[deriving(Eq)]
+#[deriving(Clone, Eq)]
 pub enum List<T> {
     Cons(T, @List<T>),
     Nil,
index 4c3fefc6eed92ebb392bab4b0260c18e572a9b6a..c1633ffa04114aea8ffe4a669123ed7fbeff3170 100644 (file)
@@ -38,6 +38,7 @@
 use ll = uv_ll;
 
 /// An IP address
+#[deriving(Clone)]
 pub enum IpAddr {
     /// An IPv4 address
     Ipv4(sockaddr_in),
index eebb8490aa2876196883de0aabfdeded32645c38..122d4b85628e2294293de9ca40366acae0a22392 100644 (file)
@@ -93,6 +93,7 @@ pub struct TcpErrData {
 }
 
 /// Details returned as part of a `Result::Err` result from `tcp::listen`
+#[deriving(Clone)]
 pub enum TcpListenErrData {
     /**
      * Some unplanned-for error. The first and second fields correspond
@@ -120,6 +121,7 @@ pub enum TcpListenErrData {
     AccessDenied
 }
 /// Details returned as part of a `Result::Err` result from `tcp::connect`
+#[deriving(Clone)]
 pub enum TcpConnectErrData {
     /**
      * Some unplanned-for error. The first and second fields correspond
index dc274dfb814139b733138ab79f6094d21ac83f7c..d07b645a541d22e9c9f229aa5eeb14a915bde6c5 100644 (file)
 
 #[allow(missing_doc)];
 
-
+use std::clone::Clone;
 use std::unstable::intrinsics::{move_val_init, init};
 use std::util::{replace, swap};
 use std::vec;
 use std::iterator::FromIterator;
 
 /// A priority queue implemented with a binary heap
+#[deriving(Clone)]
 pub struct PriorityQueue<T> {
     priv data: ~[T],
 }
index a11b819dda115c3266b8aa7893dd56ea7f391f9a..a1cd2dfb2400b46afc1842ae7d6bde44cd7bdb55 100644 (file)
@@ -926,6 +926,7 @@ mod test_tim_sort {
     use std::rand;
     use std::vec;
 
+    #[deriving(Clone)]
     struct CVal {
         val: float,
     }
@@ -992,7 +993,10 @@ fn crash_test() {
         fail!("Guarantee the fail");
     }
 
-    struct DVal { val: uint }
+    #[deriving(Clone)]
+    struct DVal {
+        val: uint,
+    }
 
     impl Ord for DVal {
         fn lt(&self, _x: &DVal) -> bool { true }
index b45e1d6323bdd32490de1a2e6bb685439eedbf0f..0a1811968f02af4db050c830291b5eeb7f583c26 100644 (file)
@@ -1245,7 +1245,7 @@ fn testfn() { }
                         ignore: false,
                         should_fail: false
                     },
-                    testfn: DynTestFn(testfn.clone()),
+                    testfn: DynTestFn(testfn),
                 };
                 tests.push(test);
             }
index 74798d260c175451f8f5a3fe29317f9c689149cd..1527b090f94c8c6c7cccdc3503fa346face04a6d 100644 (file)
@@ -266,6 +266,7 @@ pub struct uv_timer_t {
 }
 
 // unix size: 16
+#[deriving(Clone)]
 pub struct sockaddr_in {
     sin_family: u16,
     sin_port: u16,
@@ -280,6 +281,7 @@ pub struct sockaddr_in6 {
     a0: *u8, a1: *u8,
     a2: *u8, a3: *u8,
 }
+
 #[cfg(target_arch="x86")]
 #[cfg(target_arch="arm")]
 #[cfg(target_arch="mips")]
@@ -290,6 +292,12 @@ pub struct sockaddr_in6 {
     a6: *u8, a7: *u8,
 }
 
+impl Clone for sockaddr_in6 {
+    fn clone(&self) -> sockaddr_in6 {
+        *self
+    }
+}
+
 // unix size: 28 .. FIXME #1645
 // stuck with 32 because of rust padding structs?
 pub type addr_in = addr_in_impl::addr_in;
index b6dabfd0b1292fa15d6f4695937899dc64ead9e7..7c75b9c34b3020c5da347de1bd84f14104102d84 100644 (file)
@@ -63,8 +63,8 @@ fn git_repo_pkg() -> PkgId {
 
 fn writeFile(file_path: &Path, contents: &str) {
     let out: @io::Writer =
-        result::get(&io::file_writer(file_path,
-                                     [io::Create, io::Truncate]));
+        result::unwrap(io::file_writer(file_path,
+                                       [io::Create, io::Truncate]));
     out.write_line(contents);
 }
 
index ef3546efac18fe4f5833333a1baf9c3e6571d8e6..ebd6f9bf9d8cd920b5a37b1ad60de527b7966bb4 100644 (file)
@@ -44,7 +44,7 @@ pub fn main() {
     }
 
     let file = io::file_writer(&out_path.push("generated.rs"),
-                               [io::Create]).get();
+                               [io::Create]).unwrap();
     file.write_str("pub fn wheeeee() { for [1, 2, 3].each() |_| { assert!(true); } }");
 
 
index e074eba68aef9bf07c802ad182c0510b503242c5..338f9335806dd5cba93f20ff1a89f4f84c2a8954 100644 (file)
@@ -1856,11 +1856,11 @@ fn test_simple() {
         debug!(frood.clone());
         {
             let out: @io::Writer =
-                result::get(
-                    &io::file_writer(tmpfile, [io::Create, io::Truncate]));
+                result::unwrap(
+                    io::file_writer(tmpfile, [io::Create, io::Truncate]));
             out.write_str(frood);
         }
-        let inp: @io::Reader = result::get(&io::file_reader(tmpfile));
+        let inp: @io::Reader = result::unwrap(io::file_reader(tmpfile));
         let frood2: ~str = inp.read_c_str();
         debug!(frood2.clone());
         assert_eq!(frood, frood2);
@@ -1958,10 +1958,10 @@ fn file_reader_not_exist() {
     fn test_read_buffer_too_small() {
         let path = &Path("tmp/lib-io-test-read-buffer-too-small.tmp");
         // ensure the file exists
-        io::file_writer(path, [io::Create]).get();
+        io::file_writer(path, [io::Create]).unwrap();
 
-        let file = io::file_reader(path).get();
-        let mut buf = vec::from_elem(5, 0);
+        let file = io::file_reader(path).unwrap();
+        let mut buf = vec::from_elem(5, 0u8);
         file.read(buf, 6); // this should fail because buf is too small
     }
 
@@ -1969,17 +1969,17 @@ fn test_read_buffer_too_small() {
     fn test_read_buffer_big_enough() {
         let path = &Path("tmp/lib-io-test-read-buffer-big-enough.tmp");
         // ensure the file exists
-        io::file_writer(path, [io::Create]).get();
+        io::file_writer(path, [io::Create]).unwrap();
 
-        let file = io::file_reader(path).get();
-        let mut buf = vec::from_elem(5, 0);
+        let file = io::file_reader(path).unwrap();
+        let mut buf = vec::from_elem(5, 0u8);
         file.read(buf, 4); // this should succeed because buf is big enough
     }
 
     #[test]
     fn test_write_empty() {
         let file = io::file_writer(&Path("tmp/lib-io-test-write-empty.tmp"),
-                                   [io::Create]).get();
+                                   [io::Create]).unwrap();
         file.write([]);
     }
 
@@ -2025,7 +2025,7 @@ fn test_read_write_le() {
 
         // write the ints to the file
         {
-            let file = io::file_writer(&path, [io::Create]).get();
+            let file = io::file_writer(&path, [io::Create]).unwrap();
             for uints.iter().advance |i| {
                 file.write_le_u64(*i);
             }
@@ -2033,7 +2033,7 @@ fn test_read_write_le() {
 
         // then read them back and check that they are the same
         {
-            let file = io::file_reader(&path).get();
+            let file = io::file_reader(&path).unwrap();
             for uints.iter().advance |i| {
                 assert_eq!(file.read_le_u64(), *i);
             }
@@ -2047,7 +2047,7 @@ fn test_read_write_be() {
 
         // write the ints to the file
         {
-            let file = io::file_writer(&path, [io::Create]).get();
+            let file = io::file_writer(&path, [io::Create]).unwrap();
             for uints.iter().advance |i| {
                 file.write_be_u64(*i);
             }
@@ -2055,7 +2055,7 @@ fn test_read_write_be() {
 
         // then read them back and check that they are the same
         {
-            let file = io::file_reader(&path).get();
+            let file = io::file_reader(&path).unwrap();
             for uints.iter().advance |i| {
                 assert_eq!(file.read_be_u64(), *i);
             }
@@ -2069,7 +2069,7 @@ fn test_read_be_int_n() {
 
         // write the ints to the file
         {
-            let file = io::file_writer(&path, [io::Create]).get();
+            let file = io::file_writer(&path, [io::Create]).unwrap();
             for ints.iter().advance |i| {
                 file.write_be_i32(*i);
             }
@@ -2077,7 +2077,7 @@ fn test_read_be_int_n() {
 
         // then read them back and check that they are the same
         {
-            let file = io::file_reader(&path).get();
+            let file = io::file_reader(&path).unwrap();
             for ints.iter().advance |i| {
                 // this tests that the sign extension is working
                 // (comparing the values as i32 would not test this)
@@ -2093,12 +2093,12 @@ fn test_read_f32() {
         let buf = ~[0x41, 0x02, 0x00, 0x00];
 
         {
-            let file = io::file_writer(&path, [io::Create]).get();
+            let file = io::file_writer(&path, [io::Create]).unwrap();
             file.write(buf);
         }
 
         {
-            let file = io::file_reader(&path).get();
+            let file = io::file_reader(&path).unwrap();
             let f = file.read_be_f32();
             assert_eq!(f, 8.1250);
         }
@@ -2110,13 +2110,13 @@ fn test_read_write_f32() {
         let f:f32 = 8.1250;
 
         {
-            let file = io::file_writer(&path, [io::Create]).get();
+            let file = io::file_writer(&path, [io::Create]).unwrap();
             file.write_be_f32(f);
             file.write_le_f32(f);
         }
 
         {
-            let file = io::file_reader(&path).get();
+            let file = io::file_reader(&path).unwrap();
             assert_eq!(file.read_be_f32(), 8.1250);
             assert_eq!(file.read_le_f32(), 8.1250);
         }
index 09c748ec04782e9bd5e5926d2c7661f2398f9118..ec6e909219dbb251d2990ba1dae9e795f6fa33ea 100644 (file)
@@ -736,7 +736,7 @@ fn listen_ip6() {
                 let server_stream_watcher = server_stream_watcher;
                 rtdebug!("starting read");
                 let alloc: AllocCallback = |size| {
-                    vec_to_uv_buf(vec::from_elem(size, 0))
+                    vec_to_uv_buf(vec::from_elem(size, 0u8))
                 };
                 do client_tcp_watcher.read_start(alloc)
                     |stream_watcher, nread, buf, status| {
index 0c82df7e43a5ed023026052c630f6fbd4b8d36a2..b655dc828bf0ab15d9fac8562a1c12cf2d2c8720 100644 (file)
@@ -178,7 +178,6 @@ fn to_str(&self) -> ~str {
 }
 
 #[cfg(test)]
-#[allow(non_implicitly_copyable_typarams)]
 mod tests {
     use hashmap::HashMap;
     use hashmap::HashSet;
index c9c5217ca6132022536c5fc7b924bd3c9de70bc8..e380cc36b324ca36826acdd2e937405f707c7f82 100644 (file)
@@ -3049,7 +3049,6 @@ fn test_build_fail() {
     #[test]
     #[ignore(windows)]
     #[should_fail]
-    #[allow(non_implicitly_copyable_typarams)]
     fn test_grow_fn_fail() {
         let mut v = ~[];
         do v.grow_fn(100) |i| {
@@ -3108,7 +3107,6 @@ fn test_rposition_fail() {
     #[test]
     #[ignore(windows)]
     #[should_fail]
-    #[allow(non_implicitly_copyable_typarams)]
     fn test_permute_fail() {
         let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
         let mut i = 0;
index d0dfb0fb06e58330b6afcd5a332ca814620bed72..09fea560f37b2fa0f2f82c40961b62d14160e215 100644 (file)
@@ -835,7 +835,7 @@ fn id (u : uint, s: SyntaxContext) -> ident {
 
     // because of the SCTable, I now need a tidy way of
     // creating syntax objects. Sigh.
-    #[deriving(Eq)]
+    #[deriving(Clone, Eq)]
     enum TestSC {
         M(Mrk),
         R(ident,Name)
index 82139ca3c16a4116baa61bfb95181bb6d08f308e..1f98865a10c02cd73bd1f21e0d7e6eab0cfcf732 100644 (file)
@@ -75,7 +75,7 @@ fn read_line() {
         .push_rel(&Path("src/test/bench/shootout-k-nucleotide.data"));
 
     for int::range(0, 3) |_i| {
-        let reader = result::get(&io::file_reader(&path));
+        let reader = result::unwrap(io::file_reader(&path));
         while !reader.eof() {
             reader.read_line();
         }
index bbdfd3ecf79445ad8ad4e5bccaf826dcb34c1121..6280fca1cc63ac468097611dbe28102b6a62f1b4 100644 (file)
@@ -154,6 +154,15 @@ fn bfs(graph: graph, key: node_id) -> bfs_result {
     marks
 }
 
+#[deriving(Clone)]
+enum color {
+    white,
+    // node_id marks which node turned this gray/black.
+    // the node id later becomes the parent.
+    gray(node_id),
+    black(node_id)
+}
+
 /**
  * Another version of the bfs function.
  *
@@ -163,14 +172,6 @@ fn bfs(graph: graph, key: node_id) -> bfs_result {
 fn bfs2(graph: graph, key: node_id) -> bfs_result {
     // This works by doing functional updates of a color vector.
 
-    enum color {
-        white,
-        // node_id marks which node turned this gray/black.
-        // the node id later becomes the parent.
-        gray(node_id),
-        black(node_id)
-    };
-
     let mut colors = do vec::from_fn(graph.len()) |i| {
         if i as node_id == key {
             gray(key)
@@ -236,14 +237,6 @@ fn is_gray(c: &color) -> bool {
 fn pbfs(graph: &arc::ARC<graph>, key: node_id) -> bfs_result {
     // This works by doing functional updates of a color vector.
 
-    enum color {
-        white,
-        // node_id marks which node turned this gray/black.
-        // the node id later becomes the parent.
-        gray(node_id),
-        black(node_id)
-    };
-
     let graph_vec = graph.get(); // FIXME #3387 requires this temp
     let mut colors = do vec::from_fn(graph_vec.len()) |i| {
         if i as node_id == key {
index f6e90d1b7456bf50975b769aad3ea4bb0c2fe4c5..5d05817e512a0e59ca1831365b34222af82637d2 100644 (file)
@@ -124,8 +124,8 @@ fn main() {
     };
 
     let writer = if os::getenv("RUST_BENCH").is_some() {
-        result::get(&io::file_writer(&Path("./shootout-fasta.data"),
-                                    [io::Truncate, io::Create]))
+        result::unwrap(io::file_writer(&Path("./shootout-fasta.data"),
+                                       [io::Truncate, io::Create]))
     } else {
         io::stdout()
     };
index 86ab99407b98a6c4440bed7ff0c3d53a19ae715f..6a09238c2f2745ac9a2134adc0a61df9ffa5729b 100644 (file)
@@ -162,7 +162,7 @@ fn main() {
        // get to this massive data set, but include_bin! chokes on it (#2598)
        let path = Path(env!("CFG_SRC_DIR"))
            .push_rel(&Path("src/test/bench/shootout-k-nucleotide.data"));
-       result::get(&io::file_reader(&path))
+       result::unwrap(io::file_reader(&path))
    } else {
       io::stdin()
    };
index 324634ac66db8fcd27d5105af61f54cb82b05fb0..f04da0575b9540a75e7d2bcd020a0cc014b492ba 100644 (file)
@@ -11,7 +11,7 @@ fn give_any(f: &fn:()) {
 
 fn give_owned(f: &fn:Send()) {
     take_any(f);
-    take_const_owned(f); //~ ERROR expected bounds `Freeze+Send` but found bounds `Send`
+    take_const_owned(f); //~ ERROR expected bounds `Send+Freeze` but found bounds `Send`
 }
 
 fn main() {}
index 47087337e340719405bc250a05bd150706fd3a41..cb0b8afbf8ba4454f4bf688c4d6468e675145b20 100644 (file)
@@ -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 `Clone`
+        v = ~[(res)] + v; //~ failed to find an implementation of trait
         assert_eq!(v.len(), 2);
     }
 
index 72d6b70a7c2caff56a787cd1cacbb5c6de9116a5..7f8a26716cd8585d6a1b1c71922668359c065335 100644 (file)
@@ -14,11 +14,8 @@ trait Foo {
 fn a(_x: ~Foo:Send) {
 }
 
-fn b(_x: ~Foo:Send+Clone) {
-}
-
 fn c(x: ~Foo:Freeze+Send) {
-    b(x); //~ ERROR expected bounds `Clone+Send`
+    a(x);
 }
 
 fn d(x: ~Foo:) {
index e0fc3357d7bd0da23e4b46931d8061c79785d246..2d59e490e0d7b21140dd38952cee9fb96c1f1df7 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern: instantiating a type parameter with an incompatible type
+// error-pattern: failed to find an implementation
 
 struct r {
   i:int
index c13821bddf16b5dcd178025d68b9ebd714127e68..5b3333fb998cc205ad71f54a5a497231dc27187a 100644 (file)
@@ -20,7 +20,7 @@ trait methods {
 
 impl methods for () {
     fn to_bytes(&self) -> ~[u8] {
-        vec::from_elem(0, 0)
+        vec::from_elem(0, 0u8)
     }
 }
 
index ae2ae6dbf9ce01bf4a928d399aacabef5662b29a..d7897223d47107a19e21eff3b124c5f07867ad8d 100644 (file)
@@ -13,6 +13,7 @@
 extern mod extra;
 use extra::list;
 
+#[deriving(Clone)]
 enum foo {
   a(uint),
   b(~str),
index 8257d495d4606f196ef4d74584d65c7791e93b19..f4026c83c3e1fb98755c09fa2f1e9e5a530b6ff3 100644 (file)
 
 use extra::list::*;
 
-fn pure_length_go<T>(ls: @List<T>, acc: uint) -> uint {
+fn pure_length_go<T:Clone>(ls: @List<T>, acc: uint) -> uint {
     match *ls { Nil => { acc } Cons(_, tl) => { pure_length_go(tl, acc + 1u) } }
 }
 
-fn pure_length<T>(ls: @List<T>) -> uint { pure_length_go(ls, 0u) }
+fn pure_length<T:Clone>(ls: @List<T>) -> uint { pure_length_go(ls, 0u) }
 
-fn nonempty_list<T>(ls: @List<T>) -> bool { pure_length(ls) > 0u }
+fn nonempty_list<T:Clone>(ls: @List<T>) -> bool { pure_length(ls) > 0u }
 
-fn safe_head<T>(ls: @List<T>) -> T {
+fn safe_head<T:Clone>(ls: @List<T>) -> T {
     assert!(!is_empty(ls));
     return head(ls);
 }
index f3d6c1640d88178c9ff113d82c5d55fac554618a..40ce248f28625ec986eedbacd53c46f52152969e 100644 (file)
@@ -8,16 +8,15 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-pub fn main() {
-    struct Foo { a: ~str }
+#[deriving(Clone)]
+struct Foo {
+    a: ~str,
+}
 
-    let v = [ ~Foo { a: ~"Hello!" }, ..129 ];
-    let w = [ ~"Hello!", ..129 ];
+pub fn main() {
     let x = [ @[true], ..512 ];
     let y = [ 0, ..1 ];
 
-    error!("%?", v);
-    error!("%?", w);
     error!("%?", x);
     error!("%?", y);
 }