about summary refs log tree commit diff
diff options
context:
space:
mode:
authorErick Tryzelaar <erick.tryzelaar@gmail.com>2013-03-29 17:41:32 -0700
committerErick Tryzelaar <erick.tryzelaar@gmail.com>2013-03-29 17:41:32 -0700
commit529ae386056eefdfad04cab8a32d6e88ebbe0e5e (patch)
tree4396879dffede422bc085a8602891449ff6736e1
parent356438989830d8b9e597096a9d1ea2c7b6aa9af9 (diff)
parenta17a9d41f6bf06daacb0aedb0cb2144dc4ba1c53 (diff)
downloadrust-529ae386056eefdfad04cab8a32d6e88ebbe0e5e.tar.gz
rust-529ae386056eefdfad04cab8a32d6e88ebbe0e5e.zip
Merge remote-tracking branch 'remotes/origin/incoming' into serial
-rwxr-xr-xconfigure4
-rw-r--r--doc/tutorial.md86
-rw-r--r--src/librustc/middle/astencode.rs39
-rw-r--r--src/libstd/ebml.rs30
-rw-r--r--src/libstd/json.rs13
-rw-r--r--src/libstd/serialize.rs22
-rw-r--r--src/libsyntax/ext/auto_encode.rs6
-rw-r--r--src/snapshots.txt8
8 files changed, 88 insertions, 120 deletions
diff --git a/configure b/configure
index 287705a0e58..71beb8214b9 100755
--- a/configure
+++ b/configure
@@ -881,6 +881,10 @@ do
                 ;;
         esac
         need_ok "LLVM configure failed"
+
+        # Hack the tools Makefile to turn off the clang build
+        sed -i 's/clang//g' tools/Makefile
+
         cd $CFG_BUILD_DIR
     fi
 
diff --git a/doc/tutorial.md b/doc/tutorial.md
index 9f36786648a..7518e3ef676 100644
--- a/doc/tutorial.md
+++ b/doc/tutorial.md
@@ -1002,11 +1002,46 @@ refer to that through a pointer.
 
 ## Owned boxes
 
-An owned box (`~`) is a uniquely owned allocation on the heap. An owned box
-inherits the mutability and lifetime of the owner as it would if there was no
-box. The purpose of an owned box is to add a layer of indirection in order to
-create recursive data structures or cheaply pass around an object larger than a
-pointer.
+An owned box (`~`) is a uniquely owned allocation on the heap. It inherits the
+mutability and lifetime of the owner as it would if there was no box.
+
+~~~~
+let x = 5; // immutable
+let mut y = 5; // mutable
+y += 2;
+
+let x = ~5; // immutable
+let mut y = ~5; // mutable
+*y += 2; // the * operator is needed to access the contained value
+~~~~
+
+The purpose of an owned box is to add a layer of indirection in order to create
+recursive data structures or cheaply pass around an object larger than a
+pointer. Since an owned box has a unique owner, it can be used to represent any
+tree data structure.
+
+The following struct won't compile, because the lack of indirection would mean
+it has an infinite size:
+
+~~~~ {.xfail-test}
+struct Foo {
+    child: Option<Foo>
+}
+~~~~
+
+> ***Note:*** The `Option` type is an enum that represents an *optional* value.
+> It's comparable to a nullable pointer in many other languages, but stores the
+> contained value unboxed.
+
+Adding indirection with an owned pointer allocates the child outside of the
+struct on the heap, which makes it a finite size and won't result in a
+compile-time error:
+
+~~~~
+struct Foo {
+    child: Option<~Foo>
+}
+~~~~
 
 ## Managed boxes
 
@@ -1018,6 +1053,20 @@ mutability. They do own the contained object, and mutability is defined by the
 type of the shared box (`@` or `@mut`). An object containing a managed box is
 not `Owned`, and can't be sent between tasks.
 
+~~~~
+let a = @5; // immutable
+
+let mut b = @5; // mutable variable, immutable box
+b = @10;
+
+let c = @mut 5; // immutable variable, mutable box
+*c = 10;
+
+let mut d = @mut 5; // mutable variable, mutable box
+*d += 5;
+d = @mut 15;
+~~~~
+
 # Move semantics
 
 Rust uses a shallow copy for parameter passing, assignment and returning values
@@ -1035,10 +1084,10 @@ let z = x; // no new memory allocated, x can no longer be used
 # Borrowed pointers
 
 Rust's borrowed pointers are a general purpose reference type. In contrast with
-owned pointers, where the holder of an owned pointer is the owner of the
-pointed-to memory, borrowed pointers never imply ownership. A pointer can be
-borrowed to any object, and the compiler verifies that it cannot outlive the
-lifetime of the object.
+owned boxes, where the holder of an owned box is the owner of the pointed-to
+memory, borrowed pointers never imply ownership. A pointer can be borrowed to
+any object, and the compiler verifies that it cannot outlive the lifetime of
+the object.
 
 As an example, consider a simple struct type, `Point`:
 
@@ -1124,10 +1173,7 @@ For a more in-depth explanation of borrowed pointers, read the
 ## Freezing
 
 Borrowing an immutable pointer to an object freezes it and prevents mutation.
-`Owned` objects have freezing enforced statically at compile-time. Mutable
-managed boxes handle freezing dynamically when any of their contents are
-borrowed, and the task will fail if an attempt to modify them is made while
-they are frozen.
+`Owned` objects have freezing enforced statically at compile-time.
 
 ~~~~
 let mut x = 5;
@@ -1137,6 +1183,20 @@ let mut x = 5;
 // x is now unfrozen again
 ~~~~
 
+Mutable managed boxes handle freezing dynamically when any of their contents
+are borrowed, and the task will fail if an attempt to modify them is made while
+they are frozen:
+
+~~~~
+let x = @mut 5;
+let y = x;
+{
+    let y = &*y; // the managed box is now frozen
+    // modifying it through x or y will cause a task failure
+}
+// the box is now unfrozen again
+~~~~
+
 # Dereferencing pointers
 
 Rust uses the unary star operator (`*`) to access the contents of a
diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs
index f480ccd6241..36b1ad2096d 100644
--- a/src/librustc/middle/astencode.rs
+++ b/src/librustc/middle/astencode.rs
@@ -681,45 +681,6 @@ impl vtable_decoder_helpers for reader::Decoder {
         @self.read_to_vec(|| self.read_vtable_origin(xcx) )
     }
 
-    #[cfg(stage0)]
-    fn read_vtable_origin(&self, xcx: @ExtendedDecodeContext)
-        -> typeck::vtable_origin {
-        do self.read_enum(~"vtable_origin") {
-            do self.read_enum_variant |i| {
-                match i {
-                  0 => {
-                    typeck::vtable_static(
-                        do self.read_enum_variant_arg(0u) {
-                            self.read_def_id(xcx)
-                        },
-                        do self.read_enum_variant_arg(1u) {
-                            self.read_tys(xcx)
-                        },
-                        do self.read_enum_variant_arg(2u) {
-                            self.read_vtable_res(xcx)
-                        }
-                    )
-                  }
-                  1 => {
-                    typeck::vtable_param(
-                        do self.read_enum_variant_arg(0u) {
-                            self.read_uint()
-                        },
-                        do self.read_enum_variant_arg(1u) {
-                            self.read_uint()
-                        }
-                    )
-                  }
-                  // hard to avoid - user input
-                  _ => fail!(~"bad enum variant")
-                }
-            }
-        }
-    }
-
-    #[cfg(stage1)]
-    #[cfg(stage2)]
-    #[cfg(stage3)]
     fn read_vtable_origin(&self, xcx: @ExtendedDecodeContext)
         -> typeck::vtable_origin {
         do self.read_enum("vtable_origin") {
diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs
index ffb8dfd6e83..646f2ce6a84 100644
--- a/src/libstd/ebml.rs
+++ b/src/libstd/ebml.rs
@@ -321,19 +321,6 @@ pub mod reader {
             self.push_doc(self.next_doc(EsEnum), f)
         }
 
-        #[cfg(stage0)]
-        fn read_enum_variant<T>(&self, f: &fn(uint) -> T) -> T {
-            debug!("read_enum_variant()");
-            let idx = self._next_uint(EsEnumVid);
-            debug!("  idx=%u", idx);
-            do self.push_doc(self.next_doc(EsEnumBody)) {
-                f(idx)
-            }
-        }
-
-        #[cfg(stage1)]
-        #[cfg(stage2)]
-        #[cfg(stage3)]
         fn read_enum_variant<T>(&self, _names: &[&str], f: &fn(uint) -> T) -> T {
             debug!("read_enum_variant()");
             let idx = self._next_uint(EsEnumVid);
@@ -373,23 +360,6 @@ pub mod reader {
             f()
         }
 
-        #[cfg(stage0)]
-        fn read_option<T>(&self, f: &fn(bool) -> T) -> T {
-            debug!("read_option()");
-            do self.read_enum("Option") || {
-                do self.read_enum_variant |idx| {
-                    match idx {
-                        0 => f(false),
-                        1 => f(true),
-                        _ => fail!(),
-                    }
-                }
-            }
-        }
-
-        #[cfg(stage1)]
-        #[cfg(stage2)]
-        #[cfg(stage3)]
         fn read_option<T>(&self, f: &fn(bool) -> T) -> T {
             debug!("read_option()");
             do self.read_enum("Option") || {
diff --git a/src/libstd/json.rs b/src/libstd/json.rs
index d26c1606a5e..d12488ed01f 100644
--- a/src/libstd/json.rs
+++ b/src/libstd/json.rs
@@ -803,19 +803,6 @@ impl serialize::Decoder for Decoder {
         f()
     }
 
-    #[cfg(stage0)]
-    fn read_enum_variant<T>(&self, f: &fn(uint) -> T) -> T {
-        debug!("read_enum_variant()");
-        let idx = match self.stack.pop() {
-            Null => { self.stack.push(Null); 0 },
-            value => { self.stack.push(value); 1 },
-        };
-        f(idx)
-    }
-
-    #[cfg(stage1)]
-    #[cfg(stage2)]
-    #[cfg(stage3)]
     fn read_enum_variant<T>(&self, names: &[&str], f: &fn(uint) -> T) -> T {
         debug!("read_enum_variant(names=%?)", names);
         let name = match self.stack.pop() {
diff --git a/src/libstd/serialize.rs b/src/libstd/serialize.rs
index dd487218fe5..9e21d1f980d 100644
--- a/src/libstd/serialize.rs
+++ b/src/libstd/serialize.rs
@@ -83,11 +83,6 @@ pub trait Decoder {
 
     // Compound types:
     fn read_enum<T>(&self, name: &str, f: &fn() -> T) -> T;
-    #[cfg(stage0)]
-    fn read_enum_variant<T>(&self, f: &fn(uint) -> T) -> T;
-    #[cfg(stage1)]
-    #[cfg(stage2)]
-    #[cfg(stage3)]
     fn read_enum_variant<T>(&self, names: &[&str], f: &fn(uint) -> T) -> T;
     fn read_enum_variant_arg<T>(&self, idx: uint, f: &fn() -> T) -> T;
 
@@ -558,23 +553,6 @@ impl<
     K: Decodable<D> + Hash + IterBytes + Eq,
     V: Decodable<D>
 > Decodable<D> for LinearMap<K, V> {
-    #[cfg(stage0)]
-    fn decode(d: &D) -> LinearMap<K, V> {
-        do d.read_map |len| {
-            let mut map = LinearMap::new();
-            map.reserve_at_least(len);
-            for uint::range(0, len) |i| {
-                let key = d.read_map_elt_key(i, || Decodable::decode(d));
-                let val = d.read_map_elt_val(i, || Decodable::decode(d));
-                map.insert(key, val);
-            }
-            map
-        }
-    }
-
-    #[cfg(stage1)]
-    #[cfg(stage2)]
-    #[cfg(stage3)]
     fn decode(d: &D) -> LinearMap<K, V> {
         do d.read_map |len| {
             let mut map = LinearMap::with_capacity(len);
diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs
index de01d258449..52bb4110082 100644
--- a/src/libsyntax/ext/auto_encode.rs
+++ b/src/libsyntax/ext/auto_encode.rs
@@ -1281,13 +1281,13 @@ mod test {
             f();
         }
 
-        fn read_map<T>(&self, f: &fn(uint) -> T) -> T {
+        fn emit_map<T>(&self, f: &fn(uint) -> T) -> T {
             self.add_unknown_to_log(); f(0);
         }
-        fn read_map_elt_key<T>(&self, idx: uint, f: &fn() -> T) -> T {
+        fn emit_map_elt_key<T>(&self, idx: uint, f: &fn() -> T) -> T {
             self.add_unknown_to_log(); f();
         }
-        fn read_map_elt_val<T>(&self, idx: uint, f: &fn() -> T) -> T {
+        fn emit_map_elt_val<T>(&self, idx: uint, f: &fn() -> T) -> T {
             self.add_unknown_to_log(); f();
         }
     }
diff --git a/src/snapshots.txt b/src/snapshots.txt
index c3f8c8b1e63..fafd5467655 100644
--- a/src/snapshots.txt
+++ b/src/snapshots.txt
@@ -1,3 +1,11 @@
+S 2013-03-28 f7a2371
+  macos-i386 2e05a33716fc4982db53946c3b0dccf0194826fe
+  macos-x86_64 fbd3feec8dd17a6b6c8df114e6e9b4cd17cc6172
+  linux-i386 b89197edd3ba5be7c2ee6577f048d7663640e1d1
+  linux-x86_64 61a4377c6d0ca5814c2b2b752d73b61b741a23c9
+  winnt-i386 858a74afb210b30697227a87b67e44786b383a0c
+  freebsd-x86_64 01f1e4b94504045e763eecb71c7e0852f6e85036
+
 S 2013-03-27 8c15409
   macos-x86_64 05eb3801b60056d95715c891d00c5d372e34d00c
   macos-i386 4119e3fa614fa86adf60ed0183d00db3ce6d0dbc