]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #15425 : jbclements/rust/hygiene-for-3-kinds-of-args, r=cmr
authorbors <bors@rust-lang.org>
Sat, 5 Jul 2014 03:16:50 +0000 (03:16 +0000)
committerbors <bors@rust-lang.org>
Sat, 5 Jul 2014 03:16:50 +0000 (03:16 +0000)
This pull request adds hygiene for 3 kinds of argument bindings:
- arguments to item fns,
- arguments to `ExprFnBlock`s, and
- arguments to `ExprProc`s

It also adds a bunch of unit tests, fixes a few macro uses to be non-capturing, and has a few cleanup items.

local `make check` succeeds.

80 files changed:
man/rustc.1
man/rustdoc.1
mk/main.mk
src/doc/README.md
src/doc/guide.md
src/doc/rust.css
src/doc/rust.md
src/doc/tutorial.md
src/etc/kate/rust.xml
src/liballoc/lib.rs
src/libarena/lib.rs
src/libcollections/lib.rs
src/libcore/lib.rs
src/libcore/tuple.rs [deleted file]
src/libcore/tuple/mod.rs [new file with mode: 0644]
src/libcore/tuple/unit.rs [new file with mode: 0644]
src/libdebug/lib.rs
src/libflate/lib.rs
src/libfmt_macros/lib.rs
src/libfourcc/lib.rs
src/libgetopts/lib.rs
src/libglob/lib.rs
src/libgraphviz/lib.rs
src/libgreen/lib.rs
src/libhexfloat/lib.rs
src/liblibc/lib.rs
src/liblog/lib.rs
src/libnative/io/c_win32.rs
src/libnative/io/mod.rs
src/libnative/io/timer_unix.rs
src/libnative/io/tty_win32.rs [new file with mode: 0644]
src/libnative/lib.rs
src/libnum/lib.rs
src/librand/lib.rs
src/libregex/lib.rs
src/libregex_macros/lib.rs
src/librlibc/lib.rs
src/librustc/driver/config.rs
src/librustc/front/std_inject.rs
src/librustc/lib.rs
src/librustc/lint/builtin.rs
src/librustc/middle/check_match.rs
src/librustc/middle/trans/_match.rs
src/librustc/middle/trans/foreign.rs
src/librustc/middle/typeck/infer/combine.rs
src/librustdoc/clean/mod.rs
src/librustdoc/html/format.rs
src/librustdoc/lib.rs
src/librustrt/lib.rs
src/librustuv/lib.rs
src/libsemver/lib.rs
src/libserialize/json.rs
src/libserialize/lib.rs
src/libstd/collections/hashmap.rs
src/libstd/lib.rs
src/libstd/rt/backtrace.rs
src/libsync/lib.rs
src/libsyntax/lib.rs
src/libsyntax/parse/parser.rs
src/libterm/lib.rs
src/libterm/terminfo/parser/compiled.rs
src/libtest/lib.rs
src/libtime/lib.rs
src/liburl/lib.rs
src/libuuid/lib.rs
src/test/auxiliary/issue-11908-1.rs
src/test/auxiliary/issue-11908-2.rs
src/test/compile-fail/borrowck-forbid-static-unsafe-interior.rs
src/test/compile-fail/check-static-values-constraints.rs
src/test/compile-fail/type-params-in-different-spaces-1.rs [new file with mode: 0644]
src/test/compile-fail/type-params-in-different-spaces-2.rs [new file with mode: 0644]
src/test/compile-fail/type-params-in-different-spaces-3.rs [new file with mode: 0644]
src/test/run-make/crate-data-smoke/Makefile
src/test/run-make/crate-data-smoke/crate.rs
src/test/run-pass/issue-12285.rs [new file with mode: 0644]
src/test/run-pass/issue-5917.rs
src/test/run-pass/issue-8578.rs
src/test/run-pass/trans-tag-static-padding.rs
src/test/run-pass/typeck_type_placeholder_1.rs
src/test/run-pass/use.rs

index a71547893ad0b828e968814b24bc2cef28b8dadd..df65cf7bb37ffdd41d4179763c0f7557adbb12a7 100644 (file)
@@ -1,4 +1,4 @@
-.TH RUSTC "1" "March 2014" "rustc 0.11-pre" "User Commands"
+.TH RUSTC "1" "March 2014" "rustc 0.11.0" "User Commands"
 .SH NAME
 rustc \- The Rust compiler
 .SH SYNOPSIS
index d5795c328e7d52d8bf4ef7382d355fb2862f0d8a..03414ca163ec2a01e09e4d83e5942fe4ccf32b51 100644 (file)
@@ -1,4 +1,4 @@
-.TH RUSTDOC "1" "March 2014" "rustdoc 0.11-pre" "User Commands"
+.TH RUSTDOC "1" "March 2014" "rustdoc 0.11.0" "User Commands"
 .SH NAME
 rustdoc \- generate documentation from Rust source code
 .SH SYNOPSIS
index 3f6103bafa52daee662391eb5a003ee03dce6626..c4be89033a648933ab411ad7196184b582e074f5 100644 (file)
@@ -14,7 +14,7 @@
 
 # The version number
 CFG_RELEASE_NUM=0.11.0
-CFG_RELEASE_LABEL=-pre
+CFG_RELEASE_LABEL=
 
 ifndef CFG_ENABLE_NIGHTLY
 # This is the normal version string
index 759a21af0ce5f1d4de1a19928f0ff4e572f26c0c..f8b0f07d19afbab0badcb490bf378cf95ad733e0 100644 (file)
@@ -53,12 +53,12 @@ To generate .pot and .po files, do something like:
 ~~~~
 po4a --copyright-holder="The Rust Project Developers" \
     --package-name="Rust" \
-    --package-version="0.11.0-pre" \
+    --package-version="0.11.0" \
     -M UTF-8 -L UTF-8 \
     src/doc/po4a.conf
 ~~~~
 
-(the version number must be changed if it is not 0.11.0-pre now.)
+(the version number must be changed if it is not 0.11.0 now.)
 
 Now you can translate documents with .po files, commonly used with gettext. If
 you are not familiar with gettext-based translation, please read the online
index aca726812d2c6b1bc3710d0e2170226e4e88eed2..dc9608563e176c08190d8ccd865c2037539837f6 100644 (file)
@@ -53,7 +53,7 @@ an uninstall option.
 
 You can re-run this script any time you want to update Rust. Which, at this
 point, is often. Rust is still pre-1.0, and so people assume that you're using
-a very recent Rust. 
+a very recent Rust.
 
 This brings me to one other point: some people, and somewhat rightfully so, get
 very upset when we tell you to `curl | sudo sh`. And they should be! Basically,
@@ -168,7 +168,7 @@ Success! Let's go over what just happened in detail.
 
 ```
 fn main() {
-   
+
 }
 ```
 
@@ -395,7 +395,7 @@ Once you have this file in place, we should be ready to build! Try this:
 ```{bash}
 $ cargo build
    Compiling hello_world v0.1.0 (file:/home/yourname/projects/hello_world)
-$ ./target/hello_world 
+$ ./target/hello_world
 Hello, world!
 ```
 
index b9d585c953c6dfe54a0cfa407020cda50b7b9c0d..3dd770fd976b2829f312912a53cc255f5224a1bc 100644 (file)
@@ -132,6 +132,7 @@ nav {
     -moz-column-count: 2;
     -webkit-column-count: 2;
     font-size: 15px;
+    margin: 0 0 1em 0;
 }
 p {
     margin: 0 0 1em 0;
@@ -275,7 +276,7 @@ dd {
 
 nav ul {
     list-style-type: none;
-    margin: 0 0 20px 0;
+    margin: 0;
     padding-left: 0px;
 }
 
index 11e635a5af69737062021686b9a4234b055dbb9f..e149920ab352d9fe9362f64e5208164115387fd3 100644 (file)
@@ -2539,7 +2539,7 @@ A temporary's lifetime equals the largest lifetime of any reference that points
 #### Moved and copied types
 
 When a [local variable](#memory-slots) is used
-as an [rvalue](#lvalues-rvalues-and-temporaries)
+as an [rvalue](#lvalues,-rvalues-and-temporaries)
 the variable will either be moved or copied, depending on its type.
 For types that contain [owning pointers](#pointer-types)
 or values that implement the special trait `Drop`,
@@ -2562,7 +2562,7 @@ string, boolean value, or the unit value.
 ### Path expressions
 
 A [path](#paths) used as an expression context denotes either a local variable or an item.
-Path expressions are [lvalues](#lvalues-rvalues-and-temporaries).
+Path expressions are [lvalues](#lvalues,-rvalues-and-temporaries).
 
 ### Tuple expressions
 
@@ -2675,7 +2675,7 @@ foo().x;
 (Struct {a: 10, b: 20}).a;
 ~~~~
 
-A field access is an [lvalue](#lvalues-rvalues-and-temporaries) referring to the value of that field.
+A field access is an [lvalue](#lvalues,-rvalues-and-temporaries) referring to the value of that field.
 When the type providing the field inherits mutabilty, it can be [assigned](#assignment-expressions) to.
 
 Also, if the type of the expression to the left of the dot is a pointer,
@@ -2711,7 +2711,7 @@ idx_expr : expr '[' expr ']' ;
 
 [Vector](#vector-types)-typed expressions can be indexed by writing a
 square-bracket-enclosed expression (the index) after them. When the
-vector is mutable, the resulting [lvalue](#lvalues-rvalues-and-temporaries) can be assigned to.
+vector is mutable, the resulting [lvalue](#lvalues,-rvalues-and-temporaries) can be assigned to.
 
 Indices are zero-based, and may be of any integral type. Vector access
 is bounds-checked at run-time. When the check fails, it will put the
@@ -2737,7 +2737,7 @@ before the expression they apply to.
   : Negation. May only be applied to numeric types.
 * `*`
   : Dereference. When applied to a [pointer](#pointer-types) it denotes the pointed-to location.
-    For pointers to mutable locations, the resulting [lvalue](#lvalues-rvalues-and-temporaries) can be assigned to.
+    For pointers to mutable locations, the resulting [lvalue](#lvalues,-rvalues-and-temporaries) can be assigned to.
     On non-pointer types, it calls the `deref` method of the `std::ops::Deref` trait, or the
     `deref_mut` method of the `std::ops::DerefMut` trait (if implemented by the type and required
     for an outer expression that will or could mutate the dereference), and produces the
@@ -2872,8 +2872,8 @@ fn avg(v: &[f64]) -> f64 {
 
 #### Assignment expressions
 
-An _assignment expression_ consists of an [lvalue](#lvalues-rvalues-and-temporaries) expression followed by an
-equals sign (`=`) and an [rvalue](#lvalues-rvalues-and-temporaries) expression.
+An _assignment expression_ consists of an [lvalue](#lvalues,-rvalues-and-temporaries) expression followed by an
+equals sign (`=`) and an [rvalue](#lvalues,-rvalues-and-temporaries) expression.
 
 Evaluating an assignment expression [either copies or moves](#moved-and-copied-types) its right-hand operand to its left-hand operand.
 
@@ -3186,7 +3186,7 @@ fn main() {
 ~~~~
 
 A `match` behaves differently depending on whether or not the head expression
-is an [lvalue or an rvalue](#lvalues-rvalues-and-temporaries).
+is an [lvalue or an rvalue](#lvalues,-rvalues-and-temporaries).
 If the head expression is an rvalue, it is
 first evaluated into a temporary location, and the resulting value
 is sequentially compared to the patterns in the arms until a match
@@ -3550,7 +3550,7 @@ There are four varieties of pointer in Rust:
   : These point to memory _owned by some other value_.
     References arise by (automatic) conversion from owning pointers, managed pointers,
     or by applying the borrowing operator `&` to some other value,
-    including [lvalues, rvalues or temporaries](#lvalues-rvalues-and-temporaries).
+    including [lvalues, rvalues or temporaries](#lvalues,-rvalues-and-temporaries).
     References are written `&content`, or in some cases `&'f content` for some lifetime-variable `f`,
     for example `&int` means a reference to an integer.
     Copying a reference is a "shallow" operation:
@@ -3852,7 +3852,7 @@ references to any boxes; the remainder of its heap is immediately freed.
 A task's stack contains slots.
 
 A _slot_ is a component of a stack frame, either a function parameter,
-a [temporary](#lvalues-rvalues-and-temporaries), or a local variable.
+a [temporary](#lvalues,-rvalues-and-temporaries), or a local variable.
 
 A _local variable_ (or *stack-local* allocation) holds a value directly,
 allocated within the stack's memory. The value is a part of the stack frame.
index 2a788d7e7934c495d1d6ca218209faa3181c062c..0522def2d0f034bf3e6c95599090ffa5aee23b90 100644 (file)
@@ -3038,7 +3038,7 @@ fn main() {
 ~~~{.ignore}
 // `b/mod.rs`
 pub mod c;
-pub fn foo() { println!("Foo!"; }
+pub fn foo() { println!("Foo!"); }
 ~~~
 
 ~~~{.ignore}
index c0289fc6d83e188778feb0972428294f7d11b1b1..deb713ac1ae01bcc7f057d27d48c5e33a4965762 100644 (file)
@@ -7,7 +7,7 @@
        <!ENTITY rustIdent "[a-zA-Z_][a-zA-Z_0-9]*">
        <!ENTITY rustIntSuf "([iu](8|16|32|64)?)?">
 ]>
-<language name="Rust" version="0.11.0-pre" kateversion="2.4" section="Sources" extensions="*.rs" mimetype="text/x-rust" priority="15">
+<language name="Rust" version="0.11.0" kateversion="2.4" section="Sources" extensions="*.rs" mimetype="text/x-rust" priority="15">
 <highlighting>
        <list name="fn">
                <item> fn </item>
index 77333b4dc2aee614fb6087692d14758d952358b0..26b8ccaf573718523428bd8f82c76b61be87c3e4 100644 (file)
@@ -60,7 +60,7 @@
 //! by libc malloc/free.  The `libc_heap` module is defined to be wired up to
 //! the system malloc/free.
 
-#![crate_id = "alloc#0.11.0-pre"]
+#![crate_id = "alloc#0.11.0"]
 #![experimental]
 #![license = "MIT/ASL2"]
 #![crate_type = "rlib"]
index 152967cb4e90841f2cd83b4e62fe4dda0a8a27f6..917de94470b35e0bf3ceb4f189e464fb747d2310 100644 (file)
 //! arena but can only hold objects of a single type, and Arena, which is a
 //! more complex, slower Arena which can hold objects of any type.
 
-#![crate_id = "arena#0.11.0-pre"]
+#![crate_id = "arena#0.11.0"]
 #![experimental]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
 #![license = "MIT/ASL2"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/")]
+       html_root_url = "http://doc.rust-lang.org/0.11.0/")]
 
 #![feature(unsafe_destructor)]
 #![allow(missing_doc)]
index c5b8704439850e76ea3154b004a0c707cf7db5bb..c698b35c84811db2176daa87733a8394d99daafd 100644 (file)
  * Collection types.
  */
 
-#![crate_id = "collections#0.11.0-pre"]
+#![crate_id = "collections#0.11.0"]
 #![experimental]
 #![crate_type = "rlib"]
 #![license = "MIT/ASL2"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/",
+       html_root_url = "http://doc.rust-lang.org/0.11.0/",
        html_playground_url = "http://play.rust-lang.org/")]
 
 #![feature(macro_rules, managed_boxes, default_type_params, phase, globs)]
index 385a33fb92a4c67cd02d71ecd26acb5d3813fc96..5e238aeae32711004f1c5bfc6397985d06c63e1d 100644 (file)
 // Since libcore defines many fundamental lang items, all tests live in a
 // separate crate, libcoretest, to avoid bizarre issues.
 
-#![crate_id = "core#0.11.0-pre"]
+#![crate_id = "core#0.11.0"]
 #![experimental]
 #![license = "MIT/ASL2"]
 #![crate_type = "rlib"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/",
+       html_root_url = "http://doc.rust-lang.org/0.11.0/",
        html_playground_url = "http://play.rust-lang.org/")]
 
 #![no_std]
 pub mod slice;
 pub mod str;
 pub mod tuple;
+// FIXME #15320: primitive documentation needs top-level modules, this
+// should be `core::tuple::unit`.
+#[path = "tuple/unit.rs"]
+pub mod unit;
 pub mod fmt;
 
 #[doc(hidden)]
diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs
deleted file mode 100644 (file)
index 0e37228..0000000
+++ /dev/null
@@ -1,304 +0,0 @@
-// Copyright 2012 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.
-
-//! Operations on tuples
-//!
-//! To access a single element of a tuple one can use the following
-//! methods:
-//!
-//! * `valN` - returns a value of _N_-th element
-//! * `refN` - returns a reference to _N_-th element
-//! * `mutN` - returns a mutable reference to _N_-th element
-//!
-//! Indexing starts from zero, so `val0` returns first value, `val1`
-//! returns second value, and so on. In general, a tuple with _S_
-//! elements provides aforementioned methods suffixed with numbers
-//! from `0` to `S-1`. Traits which contain these methods are
-//! implemented for tuples with up to 12 elements.
-//!
-//! If every type inside a tuple implements one of the following
-//! traits, then a tuple itself also implements it.
-//!
-//! * `Clone`
-//! * `PartialEq`
-//! * `Eq`
-//! * `PartialOrd`
-//! * `Ord`
-//! * `Default`
-//!
-//! # Examples
-//!
-//! Using methods:
-//!
-//! ```
-//! let pair = ("pi", 3.14f64);
-//! assert_eq!(pair.val0(), "pi");
-//! assert_eq!(pair.val1(), 3.14f64);
-//! ```
-//!
-//! Using traits implemented for tuples:
-//!
-//! ```
-//! use std::default::Default;
-//!
-//! let a = (1i, 2i);
-//! let b = (3i, 4i);
-//! assert!(a != b);
-//!
-//! let c = b.clone();
-//! assert!(b == c);
-//!
-//! let d : (u32, f32) = Default::default();
-//! assert_eq!(d, (0u32, 0.0f32));
-//! ```
-
-#![doc(primitive = "tuple")]
-
-use clone::Clone;
-use cmp::*;
-use default::Default;
-use option::{Option, Some};
-
-// macro for implementing n-ary tuple functions and operations
-macro_rules! tuple_impls {
-    ($(
-        $Tuple:ident {
-            $(($valN:ident, $refN:ident, $mutN:ident) -> $T:ident {
-                ($($x:ident),+) => $ret:expr
-            })+
-        }
-    )+) => {
-        $(
-            #[allow(missing_doc)]
-            pub trait $Tuple<$($T),+> {
-                $(fn $valN(self) -> $T;)+
-                $(fn $refN<'a>(&'a self) -> &'a $T;)+
-                $(fn $mutN<'a>(&'a mut self) -> &'a mut $T;)+
-            }
-
-            impl<$($T),+> $Tuple<$($T),+> for ($($T,)+) {
-                $(
-                    #[inline]
-                    #[allow(unused_variable)]
-                    fn $valN(self) -> $T {
-                        let ($($x,)+) = self; $ret
-                    }
-
-                    #[inline]
-                    #[allow(unused_variable)]
-                    fn $refN<'a>(&'a self) -> &'a $T {
-                        let ($(ref $x,)+) = *self; $ret
-                    }
-
-                    #[inline]
-                    #[allow(unused_variable)]
-                    fn $mutN<'a>(&'a mut self) -> &'a mut $T {
-                        let ($(ref mut $x,)+) = *self; $ret
-                    }
-                )+
-            }
-
-            #[unstable]
-            impl<$($T:Clone),+> Clone for ($($T,)+) {
-                fn clone(&self) -> ($($T,)+) {
-                    ($(self.$refN().clone(),)+)
-                }
-            }
-
-            impl<$($T:PartialEq),+> PartialEq for ($($T,)+) {
-                #[inline]
-                fn eq(&self, other: &($($T,)+)) -> bool {
-                    $(*self.$refN() == *other.$refN())&&+
-                }
-                #[inline]
-                fn ne(&self, other: &($($T,)+)) -> bool {
-                    $(*self.$refN() != *other.$refN())||+
-                }
-            }
-
-            impl<$($T:Eq),+> Eq for ($($T,)+) {}
-
-            impl<$($T:PartialOrd + PartialEq),+> PartialOrd for ($($T,)+) {
-                #[inline]
-                fn partial_cmp(&self, other: &($($T,)+)) -> Option<Ordering> {
-                    lexical_partial_cmp!($(self.$refN(), other.$refN()),+)
-                }
-                #[inline]
-                fn lt(&self, other: &($($T,)+)) -> bool {
-                    lexical_ord!(lt, $(self.$refN(), other.$refN()),+)
-                }
-                #[inline]
-                fn le(&self, other: &($($T,)+)) -> bool {
-                    lexical_ord!(le, $(self.$refN(), other.$refN()),+)
-                }
-                #[inline]
-                fn ge(&self, other: &($($T,)+)) -> bool {
-                    lexical_ord!(ge, $(self.$refN(), other.$refN()),+)
-                }
-                #[inline]
-                fn gt(&self, other: &($($T,)+)) -> bool {
-                    lexical_ord!(gt, $(self.$refN(), other.$refN()),+)
-                }
-            }
-
-            impl<$($T:Ord),+> Ord for ($($T,)+) {
-                #[inline]
-                fn cmp(&self, other: &($($T,)+)) -> Ordering {
-                    lexical_cmp!($(self.$refN(), other.$refN()),+)
-                }
-            }
-
-            impl<$($T:Default),+> Default for ($($T,)+) {
-                #[inline]
-                fn default() -> ($($T,)+) {
-                    ($({ let x: $T = Default::default(); x},)+)
-                }
-            }
-        )+
-    }
-}
-
-// Constructs an expression that performs a lexical ordering using method $rel.
-// The values are interleaved, so the macro invocation for
-// `(a1, a2, a3) < (b1, b2, b3)` would be `lexical_ord!(lt, a1, b1, a2, b2,
-// a3, b3)` (and similarly for `lexical_cmp`)
-macro_rules! lexical_ord {
-    ($rel: ident, $a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => {
-        if *$a != *$b { lexical_ord!($rel, $a, $b) }
-        else { lexical_ord!($rel, $($rest_a, $rest_b),+) }
-    };
-    ($rel: ident, $a:expr, $b:expr) => { (*$a) . $rel ($b) };
-}
-
-macro_rules! lexical_partial_cmp {
-    ($a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => {
-        match ($a).partial_cmp($b) {
-            Some(Equal) => lexical_partial_cmp!($($rest_a, $rest_b),+),
-            ordering   => ordering
-        }
-    };
-    ($a:expr, $b:expr) => { ($a).partial_cmp($b) };
-}
-
-macro_rules! lexical_cmp {
-    ($a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => {
-        match ($a).cmp($b) {
-            Equal => lexical_cmp!($($rest_a, $rest_b),+),
-            ordering   => ordering
-        }
-    };
-    ($a:expr, $b:expr) => { ($a).cmp($b) };
-}
-
-tuple_impls! {
-    Tuple1 {
-        (val0, ref0, mut0) -> A { (a) => a }
-    }
-    Tuple2 {
-        (val0, ref0, mut0) -> A { (a, b) => a }
-        (val1, ref1, mut1) -> B { (a, b) => b }
-    }
-    Tuple3 {
-        (val0, ref0, mut0) -> A { (a, b, c) => a }
-        (val1, ref1, mut1) -> B { (a, b, c) => b }
-        (val2, ref2, mut2) -> C { (a, b, c) => c }
-    }
-    Tuple4 {
-        (val0, ref0, mut0) -> A { (a, b, c, d) => a }
-        (val1, ref1, mut1) -> B { (a, b, c, d) => b }
-        (val2, ref2, mut2) -> C { (a, b, c, d) => c }
-        (val3, ref3, mut3) -> D { (a, b, c, d) => d }
-    }
-    Tuple5 {
-        (val0, ref0, mut0) -> A { (a, b, c, d, e) => a }
-        (val1, ref1, mut1) -> B { (a, b, c, d, e) => b }
-        (val2, ref2, mut2) -> C { (a, b, c, d, e) => c }
-        (val3, ref3, mut3) -> D { (a, b, c, d, e) => d }
-        (val4, ref4, mut4) -> E { (a, b, c, d, e) => e }
-    }
-    Tuple6 {
-        (val0, ref0, mut0) -> A { (a, b, c, d, e, f) => a }
-        (val1, ref1, mut1) -> B { (a, b, c, d, e, f) => b }
-        (val2, ref2, mut2) -> C { (a, b, c, d, e, f) => c }
-        (val3, ref3, mut3) -> D { (a, b, c, d, e, f) => d }
-        (val4, ref4, mut4) -> E { (a, b, c, d, e, f) => e }
-        (val5, ref5, mut5) -> F { (a, b, c, d, e, f) => f }
-    }
-    Tuple7 {
-        (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g) => a }
-        (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g) => b }
-        (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g) => c }
-        (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g) => d }
-        (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g) => e }
-        (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g) => f }
-        (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g) => g }
-    }
-    Tuple8 {
-        (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h) => a }
-        (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h) => b }
-        (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h) => c }
-        (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h) => d }
-        (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h) => e }
-        (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h) => f }
-        (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h) => g }
-        (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h) => h }
-    }
-    Tuple9 {
-        (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h, i) => a }
-        (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h, i) => b }
-        (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h, i) => c }
-        (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h, i) => d }
-        (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h, i) => e }
-        (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h, i) => f }
-        (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h, i) => g }
-        (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h, i) => h }
-        (val8, ref8, mut8) -> I { (a, b, c, d, e, f, g, h, i) => i }
-    }
-    Tuple10 {
-        (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h, i, j) => a }
-        (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h, i, j) => b }
-        (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h, i, j) => c }
-        (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h, i, j) => d }
-        (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h, i, j) => e }
-        (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h, i, j) => f }
-        (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h, i, j) => g }
-        (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h, i, j) => h }
-        (val8, ref8, mut8) -> I { (a, b, c, d, e, f, g, h, i, j) => i }
-        (val9, ref9, mut9) -> J { (a, b, c, d, e, f, g, h, i, j) => j }
-    }
-    Tuple11 {
-        (val0,  ref0,  mut0)  -> A { (a, b, c, d, e, f, g, h, i, j, k) => a }
-        (val1,  ref1,  mut1)  -> B { (a, b, c, d, e, f, g, h, i, j, k) => b }
-        (val2,  ref2,  mut2)  -> C { (a, b, c, d, e, f, g, h, i, j, k) => c }
-        (val3,  ref3,  mut3)  -> D { (a, b, c, d, e, f, g, h, i, j, k) => d }
-        (val4,  ref4,  mut4)  -> E { (a, b, c, d, e, f, g, h, i, j, k) => e }
-        (val5,  ref5,  mut5)  -> F { (a, b, c, d, e, f, g, h, i, j, k) => f }
-        (val6,  ref6,  mut6)  -> G { (a, b, c, d, e, f, g, h, i, j, k) => g }
-        (val7,  ref7,  mut7)  -> H { (a, b, c, d, e, f, g, h, i, j, k) => h }
-        (val8,  ref8,  mut8)  -> I { (a, b, c, d, e, f, g, h, i, j, k) => i }
-        (val9,  ref9,  mut9)  -> J { (a, b, c, d, e, f, g, h, i, j, k) => j }
-        (val10, ref10, mut10) -> K { (a, b, c, d, e, f, g, h, i, j, k) => k }
-    }
-    Tuple12 {
-        (val0,  ref0,  mut0)  -> A { (a, b, c, d, e, f, g, h, i, j, k, l) => a }
-        (val1,  ref1,  mut1)  -> B { (a, b, c, d, e, f, g, h, i, j, k, l) => b }
-        (val2,  ref2,  mut2)  -> C { (a, b, c, d, e, f, g, h, i, j, k, l) => c }
-        (val3,  ref3,  mut3)  -> D { (a, b, c, d, e, f, g, h, i, j, k, l) => d }
-        (val4,  ref4,  mut4)  -> E { (a, b, c, d, e, f, g, h, i, j, k, l) => e }
-        (val5,  ref5,  mut5)  -> F { (a, b, c, d, e, f, g, h, i, j, k, l) => f }
-        (val6,  ref6,  mut6)  -> G { (a, b, c, d, e, f, g, h, i, j, k, l) => g }
-        (val7,  ref7,  mut7)  -> H { (a, b, c, d, e, f, g, h, i, j, k, l) => h }
-        (val8,  ref8,  mut8)  -> I { (a, b, c, d, e, f, g, h, i, j, k, l) => i }
-        (val9,  ref9,  mut9)  -> J { (a, b, c, d, e, f, g, h, i, j, k, l) => j }
-        (val10, ref10, mut10) -> K { (a, b, c, d, e, f, g, h, i, j, k, l) => k }
-        (val11, ref11, mut11) -> L { (a, b, c, d, e, f, g, h, i, j, k, l) => l }
-    }
-}
-
diff --git a/src/libcore/tuple/mod.rs b/src/libcore/tuple/mod.rs
new file mode 100644 (file)
index 0000000..4f34c64
--- /dev/null
@@ -0,0 +1,306 @@
+// Copyright 2012 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.
+
+//! Operations on tuples
+//!
+//! To access a single element of a tuple one can use the following
+//! methods:
+//!
+//! * `valN` - returns a value of _N_-th element
+//! * `refN` - returns a reference to _N_-th element
+//! * `mutN` - returns a mutable reference to _N_-th element
+//!
+//! Indexing starts from zero, so `val0` returns first value, `val1`
+//! returns second value, and so on. In general, a tuple with _S_
+//! elements provides aforementioned methods suffixed with numbers
+//! from `0` to `S-1`. Traits which contain these methods are
+//! implemented for tuples with up to 12 elements.
+//!
+//! If every type inside a tuple implements one of the following
+//! traits, then a tuple itself also implements it.
+//!
+//! * `Clone`
+//! * `PartialEq`
+//! * `Eq`
+//! * `PartialOrd`
+//! * `Ord`
+//! * `Default`
+//!
+//! # Examples
+//!
+//! Using methods:
+//!
+//! ```
+//! let pair = ("pi", 3.14f64);
+//! assert_eq!(pair.val0(), "pi");
+//! assert_eq!(pair.val1(), 3.14f64);
+//! ```
+//!
+//! Using traits implemented for tuples:
+//!
+//! ```
+//! use std::default::Default;
+//!
+//! let a = (1i, 2i);
+//! let b = (3i, 4i);
+//! assert!(a != b);
+//!
+//! let c = b.clone();
+//! assert!(b == c);
+//!
+//! let d : (u32, f32) = Default::default();
+//! assert_eq!(d, (0u32, 0.0f32));
+//! ```
+
+#![doc(primitive = "tuple")]
+
+pub use unit;
+
+use clone::Clone;
+use cmp::*;
+use default::Default;
+use option::{Option, Some};
+
+// macro for implementing n-ary tuple functions and operations
+macro_rules! tuple_impls {
+    ($(
+        $Tuple:ident {
+            $(($valN:ident, $refN:ident, $mutN:ident) -> $T:ident {
+                ($($x:ident),+) => $ret:expr
+            })+
+        }
+    )+) => {
+        $(
+            #[allow(missing_doc)]
+            pub trait $Tuple<$($T),+> {
+                $(fn $valN(self) -> $T;)+
+                $(fn $refN<'a>(&'a self) -> &'a $T;)+
+                $(fn $mutN<'a>(&'a mut self) -> &'a mut $T;)+
+            }
+
+            impl<$($T),+> $Tuple<$($T),+> for ($($T,)+) {
+                $(
+                    #[inline]
+                    #[allow(unused_variable)]
+                    fn $valN(self) -> $T {
+                        let ($($x,)+) = self; $ret
+                    }
+
+                    #[inline]
+                    #[allow(unused_variable)]
+                    fn $refN<'a>(&'a self) -> &'a $T {
+                        let ($(ref $x,)+) = *self; $ret
+                    }
+
+                    #[inline]
+                    #[allow(unused_variable)]
+                    fn $mutN<'a>(&'a mut self) -> &'a mut $T {
+                        let ($(ref mut $x,)+) = *self; $ret
+                    }
+                )+
+            }
+
+            #[unstable]
+            impl<$($T:Clone),+> Clone for ($($T,)+) {
+                fn clone(&self) -> ($($T,)+) {
+                    ($(self.$refN().clone(),)+)
+                }
+            }
+
+            impl<$($T:PartialEq),+> PartialEq for ($($T,)+) {
+                #[inline]
+                fn eq(&self, other: &($($T,)+)) -> bool {
+                    $(*self.$refN() == *other.$refN())&&+
+                }
+                #[inline]
+                fn ne(&self, other: &($($T,)+)) -> bool {
+                    $(*self.$refN() != *other.$refN())||+
+                }
+            }
+
+            impl<$($T:Eq),+> Eq for ($($T,)+) {}
+
+            impl<$($T:PartialOrd + PartialEq),+> PartialOrd for ($($T,)+) {
+                #[inline]
+                fn partial_cmp(&self, other: &($($T,)+)) -> Option<Ordering> {
+                    lexical_partial_cmp!($(self.$refN(), other.$refN()),+)
+                }
+                #[inline]
+                fn lt(&self, other: &($($T,)+)) -> bool {
+                    lexical_ord!(lt, $(self.$refN(), other.$refN()),+)
+                }
+                #[inline]
+                fn le(&self, other: &($($T,)+)) -> bool {
+                    lexical_ord!(le, $(self.$refN(), other.$refN()),+)
+                }
+                #[inline]
+                fn ge(&self, other: &($($T,)+)) -> bool {
+                    lexical_ord!(ge, $(self.$refN(), other.$refN()),+)
+                }
+                #[inline]
+                fn gt(&self, other: &($($T,)+)) -> bool {
+                    lexical_ord!(gt, $(self.$refN(), other.$refN()),+)
+                }
+            }
+
+            impl<$($T:Ord),+> Ord for ($($T,)+) {
+                #[inline]
+                fn cmp(&self, other: &($($T,)+)) -> Ordering {
+                    lexical_cmp!($(self.$refN(), other.$refN()),+)
+                }
+            }
+
+            impl<$($T:Default),+> Default for ($($T,)+) {
+                #[inline]
+                fn default() -> ($($T,)+) {
+                    ($({ let x: $T = Default::default(); x},)+)
+                }
+            }
+        )+
+    }
+}
+
+// Constructs an expression that performs a lexical ordering using method $rel.
+// The values are interleaved, so the macro invocation for
+// `(a1, a2, a3) < (b1, b2, b3)` would be `lexical_ord!(lt, a1, b1, a2, b2,
+// a3, b3)` (and similarly for `lexical_cmp`)
+macro_rules! lexical_ord {
+    ($rel: ident, $a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => {
+        if *$a != *$b { lexical_ord!($rel, $a, $b) }
+        else { lexical_ord!($rel, $($rest_a, $rest_b),+) }
+    };
+    ($rel: ident, $a:expr, $b:expr) => { (*$a) . $rel ($b) };
+}
+
+macro_rules! lexical_partial_cmp {
+    ($a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => {
+        match ($a).partial_cmp($b) {
+            Some(Equal) => lexical_partial_cmp!($($rest_a, $rest_b),+),
+            ordering   => ordering
+        }
+    };
+    ($a:expr, $b:expr) => { ($a).partial_cmp($b) };
+}
+
+macro_rules! lexical_cmp {
+    ($a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => {
+        match ($a).cmp($b) {
+            Equal => lexical_cmp!($($rest_a, $rest_b),+),
+            ordering   => ordering
+        }
+    };
+    ($a:expr, $b:expr) => { ($a).cmp($b) };
+}
+
+tuple_impls! {
+    Tuple1 {
+        (val0, ref0, mut0) -> A { (a) => a }
+    }
+    Tuple2 {
+        (val0, ref0, mut0) -> A { (a, b) => a }
+        (val1, ref1, mut1) -> B { (a, b) => b }
+    }
+    Tuple3 {
+        (val0, ref0, mut0) -> A { (a, b, c) => a }
+        (val1, ref1, mut1) -> B { (a, b, c) => b }
+        (val2, ref2, mut2) -> C { (a, b, c) => c }
+    }
+    Tuple4 {
+        (val0, ref0, mut0) -> A { (a, b, c, d) => a }
+        (val1, ref1, mut1) -> B { (a, b, c, d) => b }
+        (val2, ref2, mut2) -> C { (a, b, c, d) => c }
+        (val3, ref3, mut3) -> D { (a, b, c, d) => d }
+    }
+    Tuple5 {
+        (val0, ref0, mut0) -> A { (a, b, c, d, e) => a }
+        (val1, ref1, mut1) -> B { (a, b, c, d, e) => b }
+        (val2, ref2, mut2) -> C { (a, b, c, d, e) => c }
+        (val3, ref3, mut3) -> D { (a, b, c, d, e) => d }
+        (val4, ref4, mut4) -> E { (a, b, c, d, e) => e }
+    }
+    Tuple6 {
+        (val0, ref0, mut0) -> A { (a, b, c, d, e, f) => a }
+        (val1, ref1, mut1) -> B { (a, b, c, d, e, f) => b }
+        (val2, ref2, mut2) -> C { (a, b, c, d, e, f) => c }
+        (val3, ref3, mut3) -> D { (a, b, c, d, e, f) => d }
+        (val4, ref4, mut4) -> E { (a, b, c, d, e, f) => e }
+        (val5, ref5, mut5) -> F { (a, b, c, d, e, f) => f }
+    }
+    Tuple7 {
+        (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g) => a }
+        (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g) => b }
+        (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g) => c }
+        (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g) => d }
+        (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g) => e }
+        (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g) => f }
+        (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g) => g }
+    }
+    Tuple8 {
+        (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h) => a }
+        (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h) => b }
+        (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h) => c }
+        (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h) => d }
+        (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h) => e }
+        (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h) => f }
+        (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h) => g }
+        (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h) => h }
+    }
+    Tuple9 {
+        (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h, i) => a }
+        (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h, i) => b }
+        (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h, i) => c }
+        (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h, i) => d }
+        (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h, i) => e }
+        (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h, i) => f }
+        (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h, i) => g }
+        (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h, i) => h }
+        (val8, ref8, mut8) -> I { (a, b, c, d, e, f, g, h, i) => i }
+    }
+    Tuple10 {
+        (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h, i, j) => a }
+        (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h, i, j) => b }
+        (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h, i, j) => c }
+        (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h, i, j) => d }
+        (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h, i, j) => e }
+        (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h, i, j) => f }
+        (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h, i, j) => g }
+        (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h, i, j) => h }
+        (val8, ref8, mut8) -> I { (a, b, c, d, e, f, g, h, i, j) => i }
+        (val9, ref9, mut9) -> J { (a, b, c, d, e, f, g, h, i, j) => j }
+    }
+    Tuple11 {
+        (val0,  ref0,  mut0)  -> A { (a, b, c, d, e, f, g, h, i, j, k) => a }
+        (val1,  ref1,  mut1)  -> B { (a, b, c, d, e, f, g, h, i, j, k) => b }
+        (val2,  ref2,  mut2)  -> C { (a, b, c, d, e, f, g, h, i, j, k) => c }
+        (val3,  ref3,  mut3)  -> D { (a, b, c, d, e, f, g, h, i, j, k) => d }
+        (val4,  ref4,  mut4)  -> E { (a, b, c, d, e, f, g, h, i, j, k) => e }
+        (val5,  ref5,  mut5)  -> F { (a, b, c, d, e, f, g, h, i, j, k) => f }
+        (val6,  ref6,  mut6)  -> G { (a, b, c, d, e, f, g, h, i, j, k) => g }
+        (val7,  ref7,  mut7)  -> H { (a, b, c, d, e, f, g, h, i, j, k) => h }
+        (val8,  ref8,  mut8)  -> I { (a, b, c, d, e, f, g, h, i, j, k) => i }
+        (val9,  ref9,  mut9)  -> J { (a, b, c, d, e, f, g, h, i, j, k) => j }
+        (val10, ref10, mut10) -> K { (a, b, c, d, e, f, g, h, i, j, k) => k }
+    }
+    Tuple12 {
+        (val0,  ref0,  mut0)  -> A { (a, b, c, d, e, f, g, h, i, j, k, l) => a }
+        (val1,  ref1,  mut1)  -> B { (a, b, c, d, e, f, g, h, i, j, k, l) => b }
+        (val2,  ref2,  mut2)  -> C { (a, b, c, d, e, f, g, h, i, j, k, l) => c }
+        (val3,  ref3,  mut3)  -> D { (a, b, c, d, e, f, g, h, i, j, k, l) => d }
+        (val4,  ref4,  mut4)  -> E { (a, b, c, d, e, f, g, h, i, j, k, l) => e }
+        (val5,  ref5,  mut5)  -> F { (a, b, c, d, e, f, g, h, i, j, k, l) => f }
+        (val6,  ref6,  mut6)  -> G { (a, b, c, d, e, f, g, h, i, j, k, l) => g }
+        (val7,  ref7,  mut7)  -> H { (a, b, c, d, e, f, g, h, i, j, k, l) => h }
+        (val8,  ref8,  mut8)  -> I { (a, b, c, d, e, f, g, h, i, j, k, l) => i }
+        (val9,  ref9,  mut9)  -> J { (a, b, c, d, e, f, g, h, i, j, k, l) => j }
+        (val10, ref10, mut10) -> K { (a, b, c, d, e, f, g, h, i, j, k, l) => k }
+        (val11, ref11, mut11) -> L { (a, b, c, d, e, f, g, h, i, j, k, l) => l }
+    }
+}
+
diff --git a/src/libcore/tuple/unit.rs b/src/libcore/tuple/unit.rs
new file mode 100644 (file)
index 0000000..a60b3d0
--- /dev/null
@@ -0,0 +1,44 @@
+// Copyright 2014 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.
+
+#![doc(primitive = "unit")]
+
+//! The `()` type, sometimes called "unit" or "nil".
+//!
+//! The `()` type has exactly one value `()`, and is used when there
+//! is no other meaningful value that could be returned. `()` is most
+//! commonly seen implicitly: functions without a `-> ...` implicitly
+//! have return type `()`, that is, these are equivalent:
+//!
+//! ```rust
+//! fn long() -> () {}
+//!
+//! fn short() {}
+//! ```
+//!
+//! The semicolon `;` can be used to discard the result of an
+//! expression at the end of a block, making the expression (and thus
+//! the block) evaluate to `()`. For example,
+//!
+//! ```rust
+//! fn returns_i64() -> i64 {
+//!     1i64
+//! }
+//! fn returns_unit() {
+//!     1i64;
+//! }
+//!
+//! let is_i64 = {
+//!     returns_i64()
+//! };
+//! let is_unit = {
+//!     returns_i64();
+//! };
+//! ```
index b5afb3381ada92c3219c55c704c2f828ea4e9776..850002b595e91a0031981e494e4be42cc9cef124 100644 (file)
 //! Additionally, it is not guaranteed that functionality such as reflection
 //! will persist into the future.
 
-#![crate_id = "debug#0.11.0-pre"]
+#![crate_id = "debug#0.11.0"]
 #![experimental]
 #![license = "MIT/ASL2"]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/")]
+       html_root_url = "http://doc.rust-lang.org/0.11.0/")]
 #![experimental]
 #![feature(managed_boxes, macro_rules)]
 #![allow(experimental)]
index 06f574f4c88a3a4b275620847e6f4e58e691ae3b..d944818abc56ad3a4054aa87590448e4d4c1a9b5 100644 (file)
 
 */
 
-#![crate_id = "flate#0.11.0-pre"]
+#![crate_id = "flate#0.11.0"]
 #![experimental]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
 #![license = "MIT/ASL2"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/")]
+       html_root_url = "http://doc.rust-lang.org/0.11.0/")]
 #![feature(phase)]
 
 #[cfg(test)] #[phase(plugin, link)] extern crate log;
index 90023ab0fc5051014e0fbe6c3b30dcce97ed8b03..b9c0fcce52da7c3e162412c0292392d358c59a24 100644 (file)
@@ -14,7 +14,7 @@
 //! Parsing does not happen at runtime: structures of `std::fmt::rt` are
 //! generated instead.
 
-#![crate_id = "fmt_macros#0.11.0-pre"]
+#![crate_id = "fmt_macros#0.11.0"]
 #![experimental]
 #![license = "MIT/ASL2"]
 #![crate_type = "rlib"]
index 848509cbab27883f21b589bd8c91660c43a60e06..e854cd3069c8a78d0ff031cfe203a4bd9977eae5 100644 (file)
@@ -39,14 +39,14 @@ fn main() {
 
 */
 
-#![crate_id = "fourcc#0.11.0-pre"]
+#![crate_id = "fourcc#0.11.0"]
 #![experimental]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
 #![license = "MIT/ASL2"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/")]
+       html_root_url = "http://doc.rust-lang.org/0.11.0/")]
 
 #![feature(plugin_registrar, managed_boxes)]
 
index 0e525bc46e7c8b124226b32c65210d6ed3f4afca..00e6df9ffbbb2eab49343ac77ca144970fe07e07 100644 (file)
 //! }
 //! ~~~
 
-#![crate_id = "getopts#0.11.0-pre"]
+#![crate_id = "getopts#0.11.0"]
 #![experimental]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
 #![license = "MIT/ASL2"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/",
+       html_root_url = "http://doc.rust-lang.org/0.11.0/",
        html_playground_url = "http://play.rust-lang.org/")]
 #![feature(globs, phase)]
 #![deny(missing_doc)]
index f80208c4743f7c74003029796dd12f8c10e81d7e..3cb21601e331d8f2f9d73022ecd076c4fde92bae 100644 (file)
  * `glob`/`fnmatch` functions.
  */
 
-#![crate_id = "glob#0.11.0-pre"]
+#![crate_id = "glob#0.11.0"]
 #![experimental]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
 #![license = "MIT/ASL2"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/",
+       html_root_url = "http://doc.rust-lang.org/0.11.0/",
        html_playground_url = "http://play.rust-lang.org/")]
 
 use std::cell::Cell;
index 13342633f4c232b082b67705c18e1229eee0bcfc..16298f51ea96b283a562537069a5ae98476f483b 100644 (file)
@@ -266,14 +266,14 @@ pub fn main() {
 
 */
 
-#![crate_id = "graphviz#0.11.0-pre"]
+#![crate_id = "graphviz#0.11.0"]
 #![experimental]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
 #![license = "MIT/ASL2"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/")]
+       html_root_url = "http://doc.rust-lang.org/0.11.0/")]
 
 #![experimental]
 
index e803c75ca5a725b03a2524fd8d1b91734c8f7e4f..1b34679b0a18a67a0857d39ee3ce5aaf68c23f0c 100644 (file)
 //! pool.shutdown();
 //! ```
 
-#![crate_id = "green#0.11.0-pre"]
+#![crate_id = "green#0.11.0"]
 #![experimental]
 #![license = "MIT/ASL2"]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/",
+       html_root_url = "http://doc.rust-lang.org/0.11.0/",
        html_playground_url = "http://play.rust-lang.org/")]
 
 // NB this does *not* include globs, please keep it that way.
index 369de484e8e84059d11b9517e48dc5724c81da9b..64538bd2212a47e8d7562c7faa619036927172de 100644 (file)
@@ -36,14 +36,14 @@ fn main() {
 
 */
 
-#![crate_id = "hexfloat#0.11.0-pre"]
+#![crate_id = "hexfloat#0.11.0"]
 #![experimental]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
 #![license = "MIT/ASL2"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/")]
+       html_root_url = "http://doc.rust-lang.org/0.11.0/")]
 #![feature(plugin_registrar, managed_boxes)]
 
 extern crate syntax;
index 3f7f0437baee4378592fa5b3edc1c0b806adab22..81e50889952ec2671e931604c50654d03e2dd996 100644 (file)
@@ -9,11 +9,15 @@
 // except according to those terms.
 
 #![feature(globs)]
-#![crate_id = "libc#0.11.0-pre"]
+#![crate_id = "libc#0.11.0"]
 #![experimental]
 #![no_std] // we don't need std, and we can't have std, since it doesn't exist
            // yet. std depends on us.
 #![crate_type = "rlib"]
+#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+       html_root_url = "http://doc.rust-lang.org/0.11.0/",
+       html_playground_url = "http://play.rust-lang.org/")]
 
 /*!
 * Bindings for the C standard library and other platform libraries
index 17349f41b98f74889a1df242ddc81ea041e37b90..6216e79fe841878f0ae73347f98c29609dcb8e1e 100644 (file)
@@ -105,14 +105,14 @@ fn main() {
 
 */
 
-#![crate_id = "log#0.11.0-pre"]
+#![crate_id = "log#0.11.0"]
 #![experimental]
 #![license = "MIT/ASL2"]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/",
+       html_root_url = "http://doc.rust-lang.org/0.11.0/",
        html_playground_url = "http://play.rust-lang.org/")]
 
 #![feature(macro_rules)]
index 802526c91969524a9cfd4023466b7fce9f93aa72..482155c339c9b5e0b7f6b0973d725b69287a4c87 100644 (file)
 pub static FIONBIO: libc::c_long = 0x8004667e;
 static FD_SETSIZE: uint = 64;
 pub static MSG_DONTWAIT: libc::c_int = 0;
+pub static ERROR_ILLEGAL_CHARACTER: libc::c_int = 582;
+pub static ENABLE_ECHO_INPUT: libc::DWORD = 0x4;
+pub static ENABLE_EXTENDED_FLAGS: libc::DWORD = 0x80;
+pub static ENABLE_INSERT_MODE: libc::DWORD = 0x20;
+pub static ENABLE_LINE_INPUT: libc::DWORD = 0x2;
+pub static ENABLE_PROCESSED_INPUT: libc::DWORD = 0x1;
+pub static ENABLE_QUICK_EDIT_MODE: libc::DWORD = 0x40;
 
 #[repr(C)]
 pub struct WSADATA {
@@ -165,3 +172,24 @@ pub mod kernel32 {
         })
     }
 }
+
+extern "system" {
+    // FIXME - pInputControl should be PCONSOLE_READCONSOLE_CONTROL
+    pub fn ReadConsoleW(hConsoleInput: libc::HANDLE,
+                        lpBuffer: libc::LPVOID,
+                        nNumberOfCharsToRead: libc::DWORD,
+                        lpNumberOfCharsRead: libc::LPDWORD,
+                        pInputControl: libc::LPVOID) -> libc::BOOL;
+
+    pub fn WriteConsoleW(hConsoleOutput: libc::HANDLE,
+                         lpBuffer: libc::types::os::arch::extra::LPCVOID,
+                         nNumberOfCharsToWrite: libc::DWORD,
+                         lpNumberOfCharsWritten: libc::LPDWORD,
+                         lpReserved: libc::LPVOID) -> libc::BOOL;
+
+    pub fn GetConsoleMode(hConsoleHandle: libc::HANDLE,
+                          lpMode: libc::LPDWORD) -> libc::BOOL;
+
+    pub fn SetConsoleMode(hConsoleHandle: libc::HANDLE,
+                          lpMode: libc::DWORD) -> libc::BOOL;
+}
index f6764b8f26a790893853e1c88e716bb1bb51341e..ecdf4ad2c45f49b24af8653bc2d713bfed9dd1d3 100644 (file)
 #[path = "pipe_win32.rs"]
 pub mod pipe;
 
+#[cfg(windows)]
+#[path = "tty_win32.rs"]
+mod tty;
+
 #[cfg(unix)]    #[path = "c_unix.rs"]  mod c;
 #[cfg(windows)] #[path = "c_win32.rs"] mod c;
 
@@ -280,15 +284,27 @@ fn kill(&mut self, pid: libc::pid_t, signum: int) -> IoResult<()> {
     fn pipe_open(&mut self, fd: c_int) -> IoResult<Box<rtio::RtioPipe + Send>> {
         Ok(box file::FileDesc::new(fd, true) as Box<rtio::RtioPipe + Send>)
     }
+    #[cfg(unix)]
     fn tty_open(&mut self, fd: c_int, _readable: bool)
                 -> IoResult<Box<rtio::RtioTTY + Send>> {
-        #[cfg(unix)] use ERROR = libc::ENOTTY;
-        #[cfg(windows)] use ERROR = libc::ERROR_INVALID_HANDLE;
         if unsafe { libc::isatty(fd) } != 0 {
             Ok(box file::FileDesc::new(fd, true) as Box<rtio::RtioTTY + Send>)
         } else {
             Err(IoError {
-                code: ERROR as uint,
+                code: libc::ENOTTY as uint,
+                extra: 0,
+                detail: None,
+            })
+        }
+    }
+    #[cfg(windows)]
+    fn tty_open(&mut self, fd: c_int, _readable: bool)
+                -> IoResult<Box<rtio::RtioTTY + Send>> {
+        if tty::is_tty(fd) {
+            Ok(box tty::WindowsTTY::new(fd) as Box<rtio::RtioTTY + Send>)
+        } else {
+            Err(IoError {
+                code: libc::ERROR_INVALID_HANDLE as uint,
                 extra: 0,
                 detail: None,
             })
index 8d6563bafad6365c3ed287bda8a31b81731a3918..87c320e0457cbfe2f3e270e57592ed8306eb0bd9 100644 (file)
@@ -93,20 +93,7 @@ pub fn now() -> u64 {
     }
 }
 
-
-// Note: although the last parameter isn't used there is no way now to
-// convert it to unit type, because LLVM dies in SjLj preparation
-// step (unfortunately iOS uses SjLJ exceptions)
-//
-// It's definitely a temporary workaround just to get it working.
-// So far it looks like an LLVM issue and it was reported:
-// http://llvm.org/bugs/show_bug.cgi?id=19855
-// Actually this issue is pretty common while compiling for armv7 iOS
-// and in most cases it is simply solved by using --opt-level=2 (or -O)
-//
-// For this specific case unfortunately turning optimizations wasn't
-// enough.
-fn helper(input: libc::c_int, messages: Receiver<Req>, _: int) {
+fn helper(input: libc::c_int, messages: Receiver<Req>, _: ()) {
     let mut set: c::fd_set = unsafe { mem::zeroed() };
 
     let mut fd = FileDesc::new(input, true);
@@ -218,7 +205,7 @@ impl Timer {
     pub fn new() -> IoResult<Timer> {
         // See notes above regarding using int return value
         // instead of ()
-        unsafe { HELPER.boot(|| {0}, helper); }
+        unsafe { HELPER.boot(|| {}, helper); }
 
         static mut ID: atomics::AtomicUint = atomics::INIT_ATOMIC_UINT;
         let id = unsafe { ID.fetch_add(1, atomics::Relaxed) };
diff --git a/src/libnative/io/tty_win32.rs b/src/libnative/io/tty_win32.rs
new file mode 100644 (file)
index 0000000..72cf5e7
--- /dev/null
@@ -0,0 +1,156 @@
+// Copyright 2014 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.
+
+//! Windows specific console TTY implementation
+//!
+//! This module contains the implementation of a Windows specific console TTY.
+//! Also converts between UTF-16 and UTF-8. Windows has very poor support for
+//! UTF-8 and some functions will fail. In particular ReadFile and ReadConsole
+//! will fail when the codepage is set to UTF-8 and a unicode character is
+//! entered.
+//!
+//! FIXME
+//! This implementation does not account for codepoints that are split across
+//! multiple reads and writes. Also, this implementation does not expose a way
+//! to read/write UTF-16 directly. When/if Rust receives a Reader/Writer
+//! wrapper that performs encoding/decoding, this implementation should switch
+//! to working in raw UTF-16, with such a wrapper around it.
+
+use super::c::{ReadConsoleW, WriteConsoleW, GetConsoleMode, SetConsoleMode};
+use super::c::{ERROR_ILLEGAL_CHARACTER};
+use super::c::{ENABLE_ECHO_INPUT, ENABLE_EXTENDED_FLAGS};
+use super::c::{ENABLE_INSERT_MODE, ENABLE_LINE_INPUT};
+use super::c::{ENABLE_PROCESSED_INPUT, ENABLE_QUICK_EDIT_MODE};
+use libc::{c_int, HANDLE, LPDWORD, DWORD, LPVOID};
+use libc::{get_osfhandle, CloseHandle};
+use libc::types::os::arch::extra::LPCVOID;
+use std::io::MemReader;
+use std::ptr;
+use std::rt::rtio::{IoResult, IoError, RtioTTY};
+use std::str::{from_utf16, from_utf8};
+
+fn invalid_encoding() -> IoError {
+    IoError {
+        code: ERROR_ILLEGAL_CHARACTER as uint,
+        extra: 0,
+        detail: Some("text was not valid unicode".to_string()),
+    }
+}
+
+pub fn is_tty(fd: c_int) -> bool {
+    let mut out: DWORD = 0;
+    // If this function doesn't fail then fd is a TTY
+    match unsafe { GetConsoleMode(get_osfhandle(fd) as HANDLE,
+                                  &mut out as LPDWORD) } {
+        0 => false,
+        _ => true,
+    }
+}
+
+pub struct WindowsTTY {
+    closeme: bool,
+    handle: HANDLE,
+    utf8: MemReader,
+}
+
+impl WindowsTTY {
+    pub fn new(fd: c_int) -> WindowsTTY {
+        // If the file descriptor is one of stdin, stderr, or stdout
+        // then it should not be closed by us
+        let closeme = match fd {
+            0..2 => false,
+            _ => true,
+        };
+        let handle = unsafe { get_osfhandle(fd) as HANDLE };
+        WindowsTTY {
+            handle: handle,
+            utf8: MemReader::new(Vec::new()),
+            closeme: closeme,
+        }
+    }
+}
+
+impl Drop for WindowsTTY {
+    fn drop(&mut self) {
+        if self.closeme {
+            // Nobody cares about the return value
+            let _ = unsafe { CloseHandle(self.handle) };
+        }
+    }
+}
+
+impl RtioTTY for WindowsTTY {
+    fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
+        // Read more if the buffer is empty
+        if self.utf8.eof() {
+            let mut utf16 = Vec::from_elem(0x1000, 0u16);
+            let mut num: DWORD = 0;
+            match unsafe { ReadConsoleW(self.handle,
+                                         utf16.as_mut_ptr() as LPVOID,
+                                         utf16.len() as u32,
+                                         &mut num as LPDWORD,
+                                         ptr::mut_null()) } {
+                0 => return Err(super::last_error()),
+                _ => (),
+            };
+            utf16.truncate(num as uint);
+            let utf8 = match from_utf16(utf16.as_slice()) {
+                Some(utf8) => utf8.into_bytes(),
+                None => return Err(invalid_encoding()),
+            };
+            self.utf8 = MemReader::new(utf8);
+        }
+        // MemReader shouldn't error here since we just filled it
+        Ok(self.utf8.read(buf).unwrap())
+    }
+
+    fn write(&mut self, buf: &[u8]) -> IoResult<()> {
+        let utf16 = match from_utf8(buf) {
+            Some(utf8) => utf8.to_utf16(),
+            None => return Err(invalid_encoding()),
+        };
+        let mut num: DWORD = 0;
+        match unsafe { WriteConsoleW(self.handle,
+                                     utf16.as_ptr() as LPCVOID,
+                                     utf16.len() as u32,
+                                     &mut num as LPDWORD,
+                                     ptr::mut_null()) } {
+            0 => Err(super::last_error()),
+            _ => Ok(()),
+        }
+    }
+
+    fn set_raw(&mut self, raw: bool) -> IoResult<()> {
+        // FIXME
+        // Somebody needs to decide on which of these flags we want
+        match unsafe { SetConsoleMode(self.handle,
+            match raw {
+                true => 0,
+                false => ENABLE_ECHO_INPUT | ENABLE_EXTENDED_FLAGS |
+                         ENABLE_INSERT_MODE | ENABLE_LINE_INPUT |
+                         ENABLE_PROCESSED_INPUT | ENABLE_QUICK_EDIT_MODE,
+            }) } {
+            0 => Err(super::last_error()),
+            _ => Ok(()),
+        }
+    }
+
+    fn get_winsize(&mut self) -> IoResult<(int, int)> {
+        // FIXME
+        // Get console buffer via CreateFile with CONOUT$
+        // Make a CONSOLE_SCREEN_BUFFER_INFO
+        // Call GetConsoleScreenBufferInfo
+        // Maybe call GetLargestConsoleWindowSize instead?
+        Err(super::unimpl())
+    }
+
+    // Let us magically declare this as a TTY
+    fn isatty(&self) -> bool { true }
+}
index b6a4b08c60cafdfc7abba70ca2cf9f970cf53bef..2e43ddba6449ce08bb956b2c14711911472775b5 100644 (file)
 //! }
 //! ```
 
-#![crate_id = "native#0.11.0-pre"]
+#![crate_id = "native#0.11.0"]
 #![experimental]
 #![license = "MIT/ASL2"]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/")]
+       html_root_url = "http://doc.rust-lang.org/0.11.0/")]
 
 #![deny(unused_result, unused_must_use)]
 #![allow(non_camel_case_types, deprecated)]
index 1e82da5ef8de47c2902ec11d83a04ae4ef943162..db0cd7f2567243b006d36a0508bdd8cb55b601e0 100644 (file)
 
 #![feature(macro_rules)]
 
-#![crate_id = "num#0.11.0-pre"]
+#![crate_id = "num#0.11.0"]
 #![experimental]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
 #![license = "MIT/ASL2"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/",
+       html_root_url = "http://doc.rust-lang.org/0.11.0/",
        html_playground_url = "http://play.rust-lang.org/")]
 
 #![allow(deprecated)] // from_str_radix
index ae1a10f620663c3edcc6d9187bf17bf338cdd127..593b9785d475abb3f65ae9d3b49982ea7e8c5299 100644 (file)
 //! is not recommended to use this library directly, but rather the official
 //! interface through `std::rand`.
 
-#![crate_id = "rand#0.11.0-pre"]
+#![crate_id = "rand#0.11.0"]
 #![license = "MIT/ASL2"]
 #![crate_type = "rlib"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/",
+       html_root_url = "http://doc.rust-lang.org/0.11.0/",
        html_playground_url = "http://play.rust-lang.org/")]
 
 #![feature(macro_rules, phase, globs)]
index 61b133c4e68abef23ecb275231bb1d1f1cc0863d..b69c4471267bb6cefdf80f1d940966eb32b941b9 100644 (file)
 //! characters in the search text and `m` is the number of instructions in a
 //! compiled expression.
 
-#![crate_id = "regex#0.11.0-pre"]
+#![crate_id = "regex#0.11.0"]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
 #![experimental]
 #![license = "MIT/ASL2"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/",
+       html_root_url = "http://doc.rust-lang.org/0.11.0/",
        html_playground_url = "http://play.rust-lang.org/")]
 
 #![feature(macro_rules, phase)]
index 4108388e7766979df1df4e8a06e095d89d31e771..e699816347ca390846f89b8fc88c4ba963c1cd49 100644 (file)
 //! This crate provides the `regex!` macro. Its use is documented in the
 //! `regex` crate.
 
-#![crate_id = "regex_macros#0.11.0-pre"]
+#![crate_id = "regex_macros#0.11.0"]
 #![crate_type = "dylib"]
 #![experimental]
 #![license = "MIT/ASL2"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/")]
+       html_root_url = "http://doc.rust-lang.org/0.11.0/")]
 
 #![feature(plugin_registrar, managed_boxes, quote)]
 
@@ -316,7 +316,7 @@ fn pc(&self, i: uint) -> uint {
 
         #[inline]
         fn groups<'r>(&'r mut self, i: uint) -> &'r mut Captures {
-            &'r mut self.queue[i].groups
+            &mut self.queue[i].groups
         }
     }
 }
index 4423ab62f0dcfc83c851edcf86102a0f924298b3..c653e1ca07787afc4b141a772ac9588d26a847c9 100644 (file)
 //! necessary. It is an error to include this library when also linking with
 //! the system libc library.
 
-#![crate_id = "rlibc#0.11.0-pre"]
+#![crate_id = "rlibc#0.11.0"]
 #![license = "MIT/ASL2"]
 #![crate_type = "rlib"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/")]
+       html_root_url = "http://doc.rust-lang.org/0.11.0/")]
 #![feature(intrinsics)]
 
 #![no_std]
index 558d2ad71f33f3fa06927c119c5bec601851a634..09ba098b21dfb6cc33b3741d850e21fd3255f31a 100644 (file)
@@ -427,7 +427,7 @@ pub fn get_os(triple: &str) -> Option<abi::Os> {
     }
     None
 }
-static os_names : &'static [(&'static str, abi::Os)] = &'static [
+static os_names : &'static [(&'static str, abi::Os)] = &[
     ("mingw32", abi::OsWin32),
     ("win32",   abi::OsWin32),
     ("darwin",  abi::OsMacos),
@@ -442,7 +442,7 @@ pub fn get_arch(triple: &str) -> Option<abi::Architecture> {
     }
     None
 }
-static architecture_abis : &'static [(&'static str, abi::Architecture)] = &'static [
+static architecture_abis : &'static [(&'static str, abi::Architecture)] = &[
     ("i386",   abi::X86),
     ("i486",   abi::X86),
     ("i586",   abi::X86),
index 401d3fd9b244fa4f141d679a1108281ffd24623a..54ba9db570e6366af279777b1d4cdee4b96e4a11 100644 (file)
@@ -25,7 +25,7 @@
 use std::mem;
 use std::gc::{Gc, GC};
 
-pub static VERSION: &'static str = "0.11.0-pre";
+pub static VERSION: &'static str = "0.11.0";
 
 pub fn maybe_inject_crates_ref(sess: &Session, krate: ast::Crate)
                                -> ast::Crate {
index 2cd41cf14ab2128e380e5b794bfc54dd1c6f91ae..729eb908e3943be911df2c82cf1a159e4fb02494 100644 (file)
@@ -18,7 +18,7 @@
 
 */
 
-#![crate_id = "rustc#0.11.0-pre"]
+#![crate_id = "rustc#0.11.0"]
 #![experimental]
 #![comment = "The Rust compiler"]
 #![license = "MIT/ASL2"]
@@ -26,7 +26,7 @@
 #![crate_type = "rlib"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-      html_root_url = "http://doc.rust-lang.org/")]
+      html_root_url = "http://doc.rust-lang.org/0.11.0/")]
 
 #![allow(deprecated)]
 #![feature(macro_rules, globs, struct_variant, managed_boxes, quote)]
index a8f778934ae47e21c28b9b3c016d5326598bd1ea..0ab3d50cfbc3da3b9b7db5edb600dcba316ba235 100644 (file)
@@ -540,7 +540,7 @@ fn get_lints(&self) -> LintArray {
     }
 
     fn check_attribute(&mut self, cx: &Context, attr: &ast::Attribute) {
-        static ATTRIBUTE_WHITELIST: &'static [&'static str] = &'static [
+        static ATTRIBUTE_WHITELIST: &'static [&'static str] = &[
             // FIXME: #14408 whitelist docs since rustdoc looks at them
             "doc",
 
@@ -574,7 +574,7 @@ fn check_attribute(&mut self, cx: &Context, attr: &ast::Attribute) {
             "unstable",
         ];
 
-        static CRATE_ATTRS: &'static [&'static str] = &'static [
+        static CRATE_ATTRS: &'static [&'static str] = &[
             "crate_type",
             "feature",
             "no_start",
index cde83693f0b4174bd5da08b17ef876db97359739..8b5c7061a149faf4587ff9eecfd6a742ec6e5140 100644 (file)
@@ -93,9 +93,10 @@ pub enum Constructor {
     Slice(uint)
 }
 
-#[deriving(Clone)]
+#[deriving(Clone, PartialEq)]
 enum Usefulness {
-    Useful(Vec<Gc<Pat>>),
+    Useful,
+    UsefulWithWitness(Vec<Gc<Pat>>),
     NotUseful
 }
 
@@ -104,15 +105,6 @@ enum WitnessPreference {
     LeaveOutWitness
 }
 
-impl Usefulness {
-    fn useful(self) -> Option<Vec<Gc<Pat>>> {
-        match self {
-            Useful(pats) => Some(pats),
-            _ => None
-        }
-    }
-}
-
 impl<'a> Visitor<()> for MatchCheckCtxt<'a> {
     fn visit_expr(&mut self, ex: &Expr, _: ()) {
         check_expr(self, ex);
@@ -203,7 +195,8 @@ fn check_arms(cx: &MatchCheckCtxt, arms: &[Arm]) {
             let v = vec!(*pat);
             match is_useful(cx, &seen, v.as_slice(), LeaveOutWitness) {
                 NotUseful => cx.tcx.sess.span_err(pat.span, "unreachable pattern"),
-                _ => ()
+                Useful => (),
+                UsefulWithWitness(_) => unreachable!()
             }
             if arm.guard.is_none() {
                 let Matrix(mut rows) = seen;
@@ -223,7 +216,7 @@ fn raw_pat(p: Gc<Pat>) -> Gc<Pat> {
 
 fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, m: &Matrix) {
     match is_useful(cx, m, [wild()], ConstructWitness) {
-        Useful(pats) => {
+        UsefulWithWitness(pats) => {
             let witness = match pats.as_slice() {
                 [witness] => witness,
                 [] => wild(),
@@ -234,7 +227,8 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, m: &Matrix) {
         }
         NotUseful => {
             // This is good, wildcard pattern isn't reachable
-        }
+        },
+        _ => unreachable!()
     }
 }
 
@@ -404,11 +398,14 @@ fn all_constructors(cx: &MatchCheckCtxt, left_ty: ty::t,
 
 // Note: is_useful doesn't work on empty types, as the paper notes.
 // So it assumes that v is non-empty.
-fn is_useful(cx: &MatchCheckCtxt, m @ &Matrix(ref rows): &Matrix,
+fn is_useful(cx: &MatchCheckCtxt, matrix @ &Matrix(ref rows): &Matrix,
              v: &[Gc<Pat>], witness: WitnessPreference) -> Usefulness {
-    debug!("{:}", m);
+    debug!("{:}", matrix);
     if rows.len() == 0u {
-        return Useful(vec!());
+        return match witness {
+            ConstructWitness => UsefulWithWitness(vec!()),
+            LeaveOutWitness => Useful
+        };
     }
     if rows.get(0).len() == 0u {
         return NotUseful;
@@ -438,53 +435,46 @@ fn is_useful(cx: &MatchCheckCtxt, m @ &Matrix(ref rows): &Matrix,
 
     let constructors = pat_constructors(cx, v[0], left_ty, max_slice_length);
     if constructors.is_empty() {
-        match missing_constructor(cx, m, left_ty, max_slice_length) {
+        match missing_constructor(cx, matrix, left_ty, max_slice_length) {
             None => {
-                all_constructors(cx, left_ty, max_slice_length).move_iter().filter_map(|c| {
-                    is_useful_specialized(cx, m, v, c.clone(),
-                                          left_ty, witness).useful().map(|pats| {
-                        Useful(match witness {
-                            ConstructWitness => {
-                                let arity = constructor_arity(cx, &c, left_ty);
-                                let subpats = {
-                                    let pat_slice = pats.as_slice();
-                                    Vec::from_fn(arity, |i| {
-                                        pat_slice.get(i).map(|p| p.clone())
-                                            .unwrap_or_else(|| wild())
-                                    })
-                                };
-                                let mut result = vec!(construct_witness(cx, &c, subpats, left_ty));
-                                result.extend(pats.move_iter().skip(arity));
-                                result
-                            }
-                            LeaveOutWitness => vec!()
-                        })
-                    })
-                }).nth(0).unwrap_or(NotUseful)
+                all_constructors(cx, left_ty, max_slice_length).move_iter().map(|c| {
+                    match is_useful_specialized(cx, matrix, v, c.clone(), left_ty, witness) {
+                        UsefulWithWitness(pats) => UsefulWithWitness({
+                            let arity = constructor_arity(cx, &c, left_ty);
+                            let subpats = {
+                                let pat_slice = pats.as_slice();
+                                Vec::from_fn(arity, |i| {
+                                    pat_slice.get(i).map(|p| p.clone())
+                                        .unwrap_or_else(|| wild())
+                                })
+                            };
+                            let mut result = vec!(construct_witness(cx, &c, subpats, left_ty));
+                            result.extend(pats.move_iter().skip(arity));
+                            result
+                        }),
+                        result => result
+                    }
+                }).find(|result| result != &NotUseful).unwrap_or(NotUseful)
             },
 
             Some(constructor) => {
                 let matrix = Matrix(rows.iter().filter_map(|r|
                     default(cx, r.as_slice())).collect());
                 match is_useful(cx, &matrix, v.tail(), witness) {
-                    Useful(pats) => Useful(match witness {
-                        ConstructWitness => {
-                            let arity = constructor_arity(cx, &constructor, left_ty);
-                            let wild_pats = Vec::from_elem(arity, wild());
-                            let enum_pat = construct_witness(cx, &constructor, wild_pats, left_ty);
-                            (vec!(enum_pat)).append(pats.as_slice())
-                        }
-                        LeaveOutWitness => vec!()
-                    }),
+                    UsefulWithWitness(pats) => {
+                        let arity = constructor_arity(cx, &constructor, left_ty);
+                        let wild_pats = Vec::from_elem(arity, wild());
+                        let enum_pat = construct_witness(cx, &constructor, wild_pats, left_ty);
+                        UsefulWithWitness(vec!(enum_pat).append(pats.as_slice()))
+                    },
                     result => result
                 }
             }
         }
     } else {
-        constructors.move_iter().filter_map(|c| {
-            is_useful_specialized(cx, m, v, c.clone(), left_ty, witness)
-                .useful().map(|pats| Useful(pats))
-        }).nth(0).unwrap_or(NotUseful)
+        constructors.move_iter().map(|c|
+            is_useful_specialized(cx, matrix, v, c.clone(), left_ty, witness)
+        ).find(|result| result != &NotUseful).unwrap_or(NotUseful)
     }
 }
 
@@ -519,6 +509,7 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: Gc<Pat>,
                     let const_expr = lookup_const_by_id(cx.tcx, did).unwrap();
                     vec!(ConstantValue(eval_const_expr(cx.tcx, &*const_expr)))
                 },
+                Some(&DefStruct(_)) => vec!(Single),
                 Some(&DefVariant(_, id, _)) => vec!(Variant(id)),
                 _ => vec!()
             },
@@ -560,21 +551,6 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: Gc<Pat>,
     }
 }
 
-fn is_wild(cx: &MatchCheckCtxt, p: Gc<Pat>) -> bool {
-    let pat = raw_pat(p);
-    match pat.node {
-        PatWild | PatWildMulti => true,
-        PatIdent(_, _, _) =>
-            match cx.tcx.def_map.borrow().find(&pat.id) {
-                Some(&DefVariant(_, _, _)) | Some(&DefStatic(..)) => false,
-                _ => true
-            },
-        PatVec(ref before, Some(_), ref after) =>
-            before.is_empty() && after.is_empty(),
-        _ => false
-    }
-}
-
 /// This computes the arity of a constructor. The arity of a constructor
 /// is how many subpattern patterns of that constructor should be expanded to.
 ///
@@ -780,7 +756,7 @@ pub fn specialize(cx: &MatchCheckCtxt, r: &[Gc<Pat>],
 }
 
 fn default(cx: &MatchCheckCtxt, r: &[Gc<Pat>]) -> Option<Vec<Gc<Pat>>> {
-    if is_wild(cx, r[0]) {
+    if pat_is_binding_or_wild(&cx.tcx.def_map, &*raw_pat(r[0])) {
         Some(Vec::from_slice(r.tail()))
     } else {
         None
@@ -833,12 +809,14 @@ fn check_fn(cx: &mut MatchCheckCtxt,
 
 fn is_refutable(cx: &MatchCheckCtxt, pat: Gc<Pat>) -> Option<Gc<Pat>> {
     let pats = Matrix(vec!(vec!(pat)));
-    is_useful(cx, &pats, [wild()], ConstructWitness)
-        .useful()
-        .map(|pats| {
+    match is_useful(cx, &pats, [wild()], ConstructWitness) {
+        UsefulWithWitness(pats) => {
             assert_eq!(pats.len(), 1);
-            pats.get(0).clone()
-        })
+            Some(pats.get(0).clone())
+        },
+        NotUseful => None,
+        Useful => unreachable!()
+    }
 }
 
 // Legality of move bindings checking
index 5b599a06925f6244f68b970161d92451e2be86b8..d3905582a365fd1a076c1333166673ba191edcc6 100644 (file)
 use middle::trans::common::*;
 use middle::trans::consts;
 use middle::trans::controlflow;
-use middle::trans::datum;
 use middle::trans::datum::*;
 use middle::trans::expr::Dest;
 use middle::trans::expr;
 use syntax::codemap::Span;
 use syntax::parse::token::InternedString;
 
-// An option identifying a literal: either a unit-like struct or an
-// expression.
+// An option identifying a literal: either an expression or a DefId of a static expression.
 enum Lit {
-    UnitLikeStructLit(ast::NodeId),    // the node ID of the pattern
     ExprLit(Gc<ast::Expr>),
     ConstLit(ast::DefId),              // the def ID of the constant
 }
@@ -253,14 +250,12 @@ enum Opt {
 fn lit_to_expr(tcx: &ty::ctxt, a: &Lit) -> Gc<ast::Expr> {
     match *a {
         ExprLit(existing_a_expr) => existing_a_expr,
-        ConstLit(a_const) => const_eval::lookup_const_by_id(tcx, a_const).unwrap(),
-        UnitLikeStructLit(_) => fail!("lit_to_expr: unexpected struct lit"),
+        ConstLit(a_const) => const_eval::lookup_const_by_id(tcx, a_const).unwrap()
     }
 }
 
 fn opt_eq(tcx: &ty::ctxt, a: &Opt, b: &Opt) -> bool {
     match (a, b) {
-        (&lit(UnitLikeStructLit(a)), &lit(UnitLikeStructLit(b))) => a == b,
         (&lit(a), &lit(b)) => {
             let a_expr = lit_to_expr(tcx, &a);
             let b_expr = lit_to_expr(tcx, &b);
@@ -301,11 +296,6 @@ fn trans_opt<'a>(bcx: &'a Block<'a>, o: &Opt) -> opt_result<'a> {
             let lit_datum = unpack_datum!(bcx, lit_datum.to_appropriate_datum(bcx));
             return single_result(Result::new(bcx, lit_datum.val));
         }
-        lit(UnitLikeStructLit(pat_id)) => {
-            let struct_ty = ty::node_id_to_type(bcx.tcx(), pat_id);
-            let datum = datum::rvalue_scratch_datum(bcx, struct_ty, "");
-            return single_result(Result::new(bcx, datum.val));
-        }
         lit(l @ ConstLit(ref def_id)) => {
             let lit_ty = ty::node_id_to_type(bcx.tcx(), lit_to_expr(bcx.tcx(), &l).id);
             let (llval, _) = consts::get_const_val(bcx.ccx(), *def_id);
@@ -338,9 +328,6 @@ fn variant_opt(bcx: &Block, pat_id: ast::NodeId) -> Opt {
             let variant = ty::enum_variant_with_id(ccx.tcx(), enum_id, var_id);
             var(variant.disr_val, adt::represent_node(bcx, pat_id), var_id)
         }
-        def::DefFn(..) | def::DefStruct(_) => {
-            lit(UnitLikeStructLit(pat_id))
-        }
         _ => {
             ccx.sess().bug("non-variant or struct in variant_opt()");
         }
@@ -559,7 +546,6 @@ fn enter_opt<'a, 'b>(
     let _indenter = indenter();
 
     let ctor = match opt {
-        &lit(UnitLikeStructLit(_)) => check_match::Single,
         &lit(x) => check_match::ConstantValue(const_eval::eval_const_expr(
             bcx.tcx(), lit_to_expr(bcx.tcx(), &x))),
         &range(ref lo, ref hi) => check_match::ConstantRange(
@@ -664,11 +650,10 @@ fn add_veclen_to_set(set: &mut Vec<Opt> , i: uint,
                 add_to_set(ccx.tcx(), &mut found, lit(ExprLit(l)));
             }
             ast::PatIdent(..) => {
-                // This is one of: an enum variant, a unit-like struct, or a
-                // variable binding.
+                // This is either an enum variant or a variable binding.
                 let opt_def = ccx.tcx.def_map.borrow().find_copy(&cur.id);
                 match opt_def {
-                    Some(def::DefVariant(..)) | Some(def::DefStruct(..)) => {
+                    Some(def::DefVariant(..)) => {
                         add_to_set(ccx.tcx(), &mut found,
                                    variant_opt(bcx, cur.id));
                     }
@@ -819,7 +804,7 @@ fn any_irrefutable_adt_pat(bcx: &Block, m: &[Match], col: uint) -> bool {
         let pat = *br.pats.get(col);
         match pat.node {
             ast::PatTup(_) => true,
-            ast::PatStruct(_, _, _) | ast::PatEnum(_, _) =>
+            ast::PatEnum(..) | ast::PatIdent(_, _, None) | ast::PatStruct(..) =>
                 match bcx.tcx().def_map.borrow().find(&pat.id) {
                     Some(&def::DefFn(..)) |
                     Some(&def::DefStruct(..)) => true,
index 488dc6d99e35c7a0d6063d816250a778ccaab540..6d719873c768c54d9dc1510b9d22cb298d06e7f1 100644 (file)
@@ -17,7 +17,6 @@
 use middle::trans::base::push_ctxt;
 use middle::trans::base;
 use middle::trans::build::*;
-use middle::trans::builder::noname;
 use middle::trans::cabi;
 use middle::trans::common::*;
 use middle::trans::machine;
@@ -625,8 +624,8 @@ unsafe fn build_wrap_fn(ccx: &CrateContext,
             "the block".with_c_str(
                 |s| llvm::LLVMAppendBasicBlockInContext(ccx.llcx, llwrapfn, s));
 
-        let builder = ccx.builder.b;
-        llvm::LLVMPositionBuilderAtEnd(builder, the_block);
+        let builder = ccx.builder();
+        builder.position_at_end(the_block);
 
         // Array for the arguments we will pass to the rust function.
         let mut llrust_args = Vec::new();
@@ -666,10 +665,7 @@ unsafe fn build_wrap_fn(ccx: &CrateContext,
                     debug!("out pointer, foreign={}",
                            ccx.tn.val_to_str(llforeign_outptr));
                     let llrust_retptr =
-                        llvm::LLVMBuildBitCast(builder,
-                                               llforeign_outptr,
-                                               llrust_ret_ty.ptr_to().to_ref(),
-                                               noname());
+                        builder.bitcast(llforeign_outptr, llrust_ret_ty.ptr_to());
                     debug!("out pointer, foreign={} (casted)",
                            ccx.tn.val_to_str(llrust_retptr));
                     llrust_args.push(llrust_retptr);
@@ -677,12 +673,7 @@ unsafe fn build_wrap_fn(ccx: &CrateContext,
                 }
 
                 None => {
-                    let slot = {
-                        "return_alloca".with_c_str(
-                            |s| llvm::LLVMBuildAlloca(builder,
-                                                      llrust_ret_ty.to_ref(),
-                                                      s))
-                    };
+                    let slot = builder.alloca(llrust_ret_ty, "return_alloca");
                     debug!("out pointer, \
                             allocad={}, \
                             llrust_ret_ty={}, \
@@ -724,11 +715,8 @@ unsafe fn build_wrap_fn(ccx: &CrateContext,
             // pointer).  It makes adapting types easier, since we can
             // always just bitcast pointers.
             if !foreign_indirect {
-                let lltemp =
-                    llvm::LLVMBuildAlloca(
-                        builder, val_ty(llforeign_arg).to_ref(), noname());
-                llvm::LLVMBuildStore(
-                    builder, llforeign_arg, lltemp);
+                let lltemp = builder.alloca(val_ty(llforeign_arg), "");
+                builder.store(llforeign_arg, lltemp);
                 llforeign_arg = lltemp;
             }
 
@@ -737,15 +725,13 @@ unsafe fn build_wrap_fn(ccx: &CrateContext,
             // Rust expects.
             if llforeign_arg_ty.cast.is_some() {
                 assert!(!foreign_indirect);
-                llforeign_arg = llvm::LLVMBuildBitCast(
-                    builder, llforeign_arg,
-                    llrust_ty.ptr_to().to_ref(), noname());
+                llforeign_arg = builder.bitcast(llforeign_arg, llrust_ty.ptr_to());
             }
 
             let llrust_arg = if rust_indirect {
                 llforeign_arg
             } else {
-                llvm::LLVMBuildLoad(builder, llforeign_arg, noname())
+                builder.load(llforeign_arg)
             };
 
             debug!("llrust_arg {}{}: {}", "#",
@@ -755,13 +741,8 @@ unsafe fn build_wrap_fn(ccx: &CrateContext,
 
         // Perform the call itself
         debug!("calling llrustfn = {}, t = {}", ccx.tn.val_to_str(llrustfn), t.repr(ccx.tcx()));
-        let llrust_ret_val = llvm::LLVMBuildCall(builder, llrustfn, llrust_args.as_ptr(),
-                                                 llrust_args.len() as c_uint, noname());
-
         let attributes = base::get_fn_llvm_attributes(ccx, t);
-        for &(idx, attr) in attributes.iter() {
-            llvm::LLVMAddCallSiteAttribute(llrust_ret_val, idx as c_uint, attr);
-        }
+        let llrust_ret_val = builder.call(llrustfn, llrust_args.as_slice(), attributes.as_slice());
 
         // Get the return value where the foreign fn expects it.
         let llforeign_ret_ty = match tys.fn_ty.ret_ty.cast {
@@ -772,20 +753,16 @@ unsafe fn build_wrap_fn(ccx: &CrateContext,
             None if !tys.ret_def => {
                 // Function returns `()` or `bot`, which in Rust is the LLVM
                 // type "{}" but in foreign ABIs is "Void".
-                llvm::LLVMBuildRetVoid(builder);
+                builder.ret_void();
             }
 
             None if rust_uses_outptr => {
                 // Rust uses an outpointer, but the foreign ABI does not. Load.
                 let llrust_outptr = return_alloca.unwrap();
                 let llforeign_outptr_casted =
-                    llvm::LLVMBuildBitCast(builder,
-                                           llrust_outptr,
-                                           llforeign_ret_ty.ptr_to().to_ref(),
-                                           noname());
-                let llforeign_retval =
-                    llvm::LLVMBuildLoad(builder, llforeign_outptr_casted, noname());
-                llvm::LLVMBuildRet(builder, llforeign_retval);
+                    builder.bitcast(llrust_outptr, llforeign_ret_ty.ptr_to());
+                let llforeign_retval = builder.load(llforeign_outptr_casted);
+                builder.ret(llforeign_retval);
             }
 
             None if llforeign_ret_ty != llrust_ret_ty => {
@@ -795,43 +772,31 @@ unsafe fn build_wrap_fn(ccx: &CrateContext,
                 // right now we just use a temp memory location and
                 // bitcast the pointer, which is the same thing the
                 // old wrappers used to do.
-                let lltemp =
-                    llvm::LLVMBuildAlloca(
-                        builder, llforeign_ret_ty.to_ref(), noname());
-                let lltemp_casted =
-                    llvm::LLVMBuildBitCast(builder,
-                                           lltemp,
-                                           llrust_ret_ty.ptr_to().to_ref(),
-                                           noname());
-                llvm::LLVMBuildStore(
-                    builder, llrust_ret_val, lltemp_casted);
-                let llforeign_retval =
-                    llvm::LLVMBuildLoad(builder, lltemp, noname());
-                llvm::LLVMBuildRet(builder, llforeign_retval);
+                let lltemp = builder.alloca(llforeign_ret_ty, "");
+                let lltemp_casted = builder.bitcast(lltemp, llrust_ret_ty.ptr_to());
+                builder.store(llrust_ret_val, lltemp_casted);
+                let llforeign_retval = builder.load(lltemp);
+                builder.ret(llforeign_retval);
             }
 
             None => {
                 // Neither ABI uses an outpointer, and the types
                 // match. Easy peasy.
-                llvm::LLVMBuildRet(builder, llrust_ret_val);
+                builder.ret(llrust_ret_val);
             }
 
             Some(llforeign_outptr) if !rust_uses_outptr => {
                 // Foreign ABI requires an out pointer, but Rust doesn't.
                 // Store Rust return value.
                 let llforeign_outptr_casted =
-                    llvm::LLVMBuildBitCast(builder,
-                                           llforeign_outptr,
-                                           llrust_retptr_ty.to_ref(),
-                                           noname());
-                llvm::LLVMBuildStore(
-                    builder, llrust_ret_val, llforeign_outptr_casted);
-                llvm::LLVMBuildRetVoid(builder);
+                    builder.bitcast(llforeign_outptr, llrust_retptr_ty);
+                builder.store(llrust_ret_val, llforeign_outptr_casted);
+                builder.ret_void();
             }
 
             Some(_) => {
                 // Both ABIs use outpointers. Easy peasy.
-                llvm::LLVMBuildRetVoid(builder);
+                builder.ret_void();
             }
         }
     }
index f374f1dc26795104f2fc31ea551a254cbbd27c4a..2984ea086efc59064d00919ddf70c15ccf5ffa64 100644 (file)
@@ -445,7 +445,8 @@ fn check_ptr_to_unsized<C:Combine>(this: &C,
         }
       }
 
-      (&ty::ty_param(ref a_p), &ty::ty_param(ref b_p)) if a_p.idx == b_p.idx => {
+      (&ty::ty_param(ref a_p), &ty::ty_param(ref b_p)) if
+          a_p.idx == b_p.idx && a_p.space == b_p.space => {
         Ok(a)
       }
 
index d0873d4c66afc9ac9310355b71d55fd506717fe9..4808cbdb4b09b332986c01c64214088562e7a098 100644 (file)
@@ -1079,7 +1079,7 @@ pub enum Primitive {
     F32, F64,
     Char,
     Bool,
-    Nil,
+    Unit,
     Str,
     Slice,
     PrimitiveTuple,
@@ -1110,7 +1110,7 @@ fn from_str(s: &str) -> Option<Primitive> {
             "u32" => Some(U32),
             "u64" => Some(U64),
             "bool" => Some(Bool),
-            "nil" => Some(Nil),
+            "unit" => Some(Unit),
             "char" => Some(Char),
             "str" => Some(Str),
             "f32" => Some(F32),
@@ -1159,7 +1159,7 @@ pub fn to_str(&self) -> &'static str {
             Str => "str",
             Bool => "bool",
             Char => "char",
-            Nil => "()",
+            Unit => "()",
             Slice => "slice",
             PrimitiveTuple => "tuple",
         }
@@ -1167,7 +1167,7 @@ pub fn to_str(&self) -> &'static str {
 
     pub fn to_url_str(&self) -> &'static str {
         match *self {
-            Nil => "nil",
+            Unit => "unit",
             other => other.to_str(),
         }
     }
@@ -1184,7 +1184,7 @@ impl Clean<Type> for ast::Ty {
     fn clean(&self) -> Type {
         use syntax::ast::*;
         match self.node {
-            TyNil => Primitive(Nil),
+            TyNil => Primitive(Unit),
             TyPtr(ref m) => RawPointer(m.mutbl.clean(), box m.ty.clean()),
             TyRptr(ref l, ref m) =>
                 BorrowedRef {lifetime: l.clean(), mutability: m.mutbl.clean(),
@@ -1214,7 +1214,7 @@ impl Clean<Type> for ty::t {
     fn clean(&self) -> Type {
         match ty::get(*self).sty {
             ty::ty_bot => Bottom,
-            ty::ty_nil => Primitive(Nil),
+            ty::ty_nil => Primitive(Unit),
             ty::ty_bool => Primitive(Bool),
             ty::ty_char => Primitive(Char),
             ty::ty_int(ast::TyI) => Primitive(Int),
index 9677b9004cdf1a12e015b56191ab3426747f1e1d..cec665768d1ee86ab4aad758480f60792d7f5283 100644 (file)
@@ -362,7 +362,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                        },
                        args = decl.decl.inputs,
                        arrow = match decl.decl.output {
-                           clean::Primitive(clean::Nil) => "".to_string(),
+                           clean::Primitive(clean::Unit) => "".to_string(),
                            _ => format!(" -&gt; {}", decl.decl.output),
                        },
                        bounds = {
@@ -411,7 +411,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                                m.collect::<Vec<String>>().connect(" + "))
                        },
                        arrow = match decl.decl.output {
-                           clean::Primitive(clean::Nil) => "".to_string(),
+                           clean::Primitive(clean::Unit) => "".to_string(),
                            _ => format!(" -&gt; {}", decl.decl.output)
                        })
             }
@@ -472,7 +472,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "({args}){arrow}",
                args = self.inputs,
                arrow = match self.output {
-                   clean::Primitive(clean::Nil) => "".to_string(),
+                   clean::Primitive(clean::Unit) => "".to_string(),
                    _ => format!(" -&gt; {}", self.output),
                })
     }
@@ -505,7 +505,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "({args}){arrow}",
                args = args,
                arrow = match d.output {
-                   clean::Primitive(clean::Nil) => "".to_string(),
+                   clean::Primitive(clean::Unit) => "".to_string(),
                    _ => format!(" -&gt; {}", d.output),
                })
     }
index 86b80ee24943691a4abf49bab1ad1e7f0e9508c9..d878313ee28995c0e8e2f9507ff7d540ed3ad957 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![crate_id = "rustdoc#0.11.0-pre"]
+#![crate_id = "rustdoc#0.11.0"]
 #![experimental]
 #![desc = "rustdoc, the Rust documentation extractor"]
 #![license = "MIT/ASL2"]
index a040829ebe33ddf5ca7015c2a4f02e3c3ccb8585..fabef24e06ac724f5e7d2f5a0f839dabcafff553 100644 (file)
@@ -8,13 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![crate_id = "rustrt#0.11.0-pre"]
+#![crate_id = "rustrt#0.11.0"]
 #![license = "MIT/ASL2"]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/")]
+       html_root_url = "http://doc.rust-lang.org/0.11.0/")]
 
 #![feature(macro_rules, phase, globs, thread_local, managed_boxes, asm)]
 #![feature(linkage, lang_items, unsafe_destructor)]
index a1712394634b8c2d52d7e0cf50ab48c41661228d..c13263680aac7986a93ef11601c0e124866d3a03 100644 (file)
 
 */
 
-#![crate_id = "rustuv#0.11.0-pre"]
+#![crate_id = "rustuv#0.11.0"]
 #![experimental]
 #![license = "MIT/ASL2"]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
+#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+       html_root_url = "http://doc.rust-lang.org/0.11.0/",
+       html_playground_url = "http://play.rust-lang.org/")]
 
 #![feature(macro_rules, unsafe_destructor)]
 #![deny(unused_result, unused_must_use)]
index 675b2e507b3e9073448bfc99dc6369c53b39ed27..fc8aa8ac257a76f2769355979280750791041caa 100644 (file)
 //! An example version number with all five components is
 //! `0.8.1-rc.3.0+20130922.linux`.
 
-#![crate_id = "semver#0.11.0-pre"]
+#![crate_id = "semver#0.11.0"]
 #![experimental]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
 #![license = "MIT/ASL2"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/")]
+       html_root_url = "http://doc.rust-lang.org/0.11.0/")]
 
 use std::char;
 use std::cmp;
index 832bc9c4e10cbb2c8f6085a2303aaaa92900e8d2..f4e5c27a14b33638bb7b2db1f03921841d3a944d 100644 (file)
@@ -256,22 +256,63 @@ fn io_error_to_error(io: io::IoError) -> ParserError {
 pub type EncodeResult = io::IoResult<()>;
 pub type DecodeResult<T> = Result<T, DecoderError>;
 
-fn escape_str(s: &str) -> String {
-    let mut escaped = String::from_str("\"");
-    for c in s.chars() {
-        match c {
-            '"' => escaped.push_str("\\\""),
-            '\\' => escaped.push_str("\\\\"),
-            '\x08' => escaped.push_str("\\b"),
-            '\x0c' => escaped.push_str("\\f"),
-            '\n' => escaped.push_str("\\n"),
-            '\r' => escaped.push_str("\\r"),
-            '\t' => escaped.push_str("\\t"),
-            _ => escaped.push_char(c),
+pub fn escape_bytes(wr: &mut io::Writer, bytes: &[u8]) -> Result<(), io::IoError> {
+    try!(wr.write_str("\""));
+
+    let mut start = 0;
+
+    for (i, byte) in bytes.iter().enumerate() {
+        let escaped = match *byte {
+            b'"' => "\\\"",
+            b'\\' => "\\\\",
+            b'\x08' => "\\b",
+            b'\x0c' => "\\f",
+            b'\n' => "\\n",
+            b'\r' => "\\r",
+            b'\t' => "\\t",
+            _ => { continue; }
+        };
+
+        if start < i {
+            try!(wr.write(bytes.slice(start, i)));
         }
-    };
-    escaped.push_char('"');
-    escaped
+
+        try!(wr.write_str(escaped));
+
+        start = i + 1;
+    }
+
+    if start != bytes.len() {
+        try!(wr.write(bytes.slice_from(start)));
+    }
+
+    wr.write_str("\"")
+}
+
+fn escape_str(writer: &mut io::Writer, v: &str) -> Result<(), io::IoError> {
+    escape_bytes(writer, v.as_bytes())
+}
+
+fn escape_char(writer: &mut io::Writer, v: char) -> Result<(), io::IoError> {
+    let mut buf = [0, .. 4];
+    v.encode_utf8(buf);
+    escape_bytes(writer, buf)
+}
+
+fn spaces(wr: &mut io::Writer, mut n: uint) -> Result<(), io::IoError> {
+    static len: uint = 16;
+    static buf: [u8, ..len] = [b' ', ..len];
+
+    while n >= len {
+        try!(wr.write(buf));
+        n -= len;
+    }
+
+    if n > 0 {
+        wr.write(buf.slice_to(n))
+    } else {
+        Ok(())
+    }
 }
 
 fn fmt_number_or_null(v: f64) -> String {
@@ -281,10 +322,6 @@ fn fmt_number_or_null(v: f64) -> String {
     }
 }
 
-fn spaces(n: uint) -> String {
-    String::from_char(n, ' ')
-}
-
 /// A structure for implementing serialization to JSON.
 pub struct Encoder<'a> {
     writer: &'a mut io::Writer,
@@ -348,10 +385,10 @@ fn emit_f64(&mut self, v: f64) -> EncodeResult {
     fn emit_f32(&mut self, v: f32) -> EncodeResult { self.emit_f64(v as f64) }
 
     fn emit_char(&mut self, v: char) -> EncodeResult {
-        self.emit_str(str::from_char(v).as_slice())
+        escape_char(self.writer, v)
     }
     fn emit_str(&mut self, v: &str) -> EncodeResult {
-        write!(self.writer, "{}", escape_str(v))
+        escape_str(self.writer, v)
     }
 
     fn emit_enum(&mut self, _name: &str, f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
@@ -367,10 +404,10 @@ fn emit_enum_variant(&mut self,
         // Bunny => "Bunny"
         // Kangaroo(34,"William") => {"variant": "Kangaroo", "fields": [34,"William"]}
         if cnt == 0 {
-            write!(self.writer, "{}", escape_str(name))
+            escape_str(self.writer, name)
         } else {
             try!(write!(self.writer, "{{\"variant\":"));
-            try!(write!(self.writer, "{}", escape_str(name)));
+            try!(escape_str(self.writer, name));
             try!(write!(self.writer, ",\"fields\":["));
             try!(f(self));
             write!(self.writer, "]}}")
@@ -415,7 +452,8 @@ fn emit_struct_field(&mut self,
                          idx: uint,
                          f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
         if idx != 0 { try!(write!(self.writer, ",")); }
-        try!(write!(self.writer, "{}:", escape_str(name)));
+        try!(escape_str(self.writer, name));
+        try!(write!(self.writer, ":"));
         f(self)
     }
 
@@ -541,10 +579,10 @@ fn emit_f32(&mut self, v: f32) -> EncodeResult {
     }
 
     fn emit_char(&mut self, v: char) -> EncodeResult {
-        self.emit_str(str::from_char(v).as_slice())
+        escape_char(self.writer, v)
     }
     fn emit_str(&mut self, v: &str) -> EncodeResult {
-        write!(self.writer, "{}", escape_str(v))
+        escape_str(self.writer, v)
     }
 
     fn emit_enum(&mut self,
@@ -559,14 +597,18 @@ fn emit_enum_variant(&mut self,
                          cnt: uint,
                          f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult {
         if cnt == 0 {
-            write!(self.writer, "{}", escape_str(name))
+            escape_str(self.writer, name)
         } else {
             self.indent += 2;
-            try!(write!(self.writer, "[\n{}{},\n", spaces(self.indent),
-                          escape_str(name)));
+            try!(write!(self.writer, "[\n"));
+            try!(spaces(self.writer, self.indent));
+            try!(escape_str(self.writer, name));
+            try!(write!(self.writer, ",\n"));
             try!(f(self));
             self.indent -= 2;
-            write!(self.writer, "\n{}]", spaces(self.indent))
+            try!(write!(self.writer, "\n"));
+            try!(spaces(self.writer, self.indent));
+            write!(self.writer, "]")
         }
     }
 
@@ -576,7 +618,7 @@ fn emit_enum_variant_arg(&mut self,
         if idx != 0 {
             try!(write!(self.writer, ",\n"));
         }
-        try!(write!(self.writer, "{}", spaces(self.indent)));
+        try!(spaces(self.writer, self.indent));
         f(self)
     }
 
@@ -607,7 +649,9 @@ fn emit_struct(&mut self,
             self.indent += 2;
             try!(f(self));
             self.indent -= 2;
-            write!(self.writer, "\n{}}}", spaces(self.indent))
+            try!(write!(self.writer, "\n"));
+            try!(spaces(self.writer, self.indent));
+            write!(self.writer, "}}")
         }
     }
 
@@ -620,7 +664,9 @@ fn emit_struct_field(&mut self,
         } else {
             try!(write!(self.writer, ",\n"));
         }
-        try!(write!(self.writer, "{}{}: ", spaces(self.indent), escape_str(name)));
+        try!(spaces(self.writer, self.indent));
+        try!(escape_str(self.writer, name));
+        try!(write!(self.writer, ": "));
         f(self)
     }
 
@@ -665,7 +711,9 @@ fn emit_seq(&mut self,
             self.indent += 2;
             try!(f(self));
             self.indent -= 2;
-            write!(self.writer, "\n{}]", spaces(self.indent))
+            try!(write!(self.writer, "\n"));
+            try!(spaces(self.writer, self.indent));
+            write!(self.writer, "]")
         }
     }
 
@@ -677,7 +725,7 @@ fn emit_seq_elt(&mut self,
         } else {
             try!(write!(self.writer, ",\n"));
         }
-        try!(write!(self.writer, "{}", spaces(self.indent)));
+        try!(spaces(self.writer, self.indent));
         f(self)
     }
 
@@ -691,7 +739,9 @@ fn emit_map(&mut self,
             self.indent += 2;
             try!(f(self));
             self.indent -= 2;
-            write!(self.writer, "\n{}}}", spaces(self.indent))
+            try!(write!(self.writer, "\n"));
+            try!(spaces(self.writer, self.indent));
+            write!(self.writer, "}}")
         }
     }
 
@@ -703,7 +753,7 @@ fn emit_map_elt_key(&mut self,
         } else {
             try!(write!(self.writer, ",\n"));
         }
-        try!(write!(self.writer, "{}", spaces(self.indent)));
+        try!(spaces(self.writer, self.indent));
         // ref #12967, make sure to wrap a key in double quotes,
         // in the event that its of a type that omits them (eg numbers)
         let mut buf = MemWriter::new();
@@ -1118,7 +1168,7 @@ pub fn new(rdr: T) -> Parser<T> {
     /// Provides access to the current position in the logical structure of the
     /// JSON stream.
     pub fn stack<'l>(&'l self) -> &'l Stack {
-        return &'l self.stack;
+        return &self.stack;
     }
 
     fn eof(&self) -> bool { self.ch.is_none() }
index 275e5e242d66553a80aaa288f0ec056e1ef49ca1..a2a504132363332e60cffd698e95b38945388cb7 100644 (file)
 Core encoding and decoding interfaces.
 */
 
-#![crate_id = "serialize#0.11.0-pre"]
+#![crate_id = "serialize#0.11.0"]
 #![experimental]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
 #![license = "MIT/ASL2"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/",
+       html_root_url = "http://doc.rust-lang.org/0.11.0/",
        html_playground_url = "http://play.rust-lang.org/")]
 #![feature(macro_rules, managed_boxes, default_type_params, phase)]
 
index 7c01a0342edc71b30bbcaf89597f1bfc10240b4c..098e87243b69cfe8d75824de5e7cc91e744f0748 100644 (file)
@@ -294,8 +294,7 @@ pub fn read<'a>(&'a self, index: &FullIndex) -> (&'a K, &'a V) {
 
             unsafe {
                 debug_assert!(*self.hashes.offset(idx) != EMPTY_BUCKET);
-                (&'a *self.keys.offset(idx),
-                 &'a *self.vals.offset(idx))
+                (&*self.keys.offset(idx), &*self.vals.offset(idx))
             }
         }
 
@@ -306,8 +305,7 @@ pub fn read_mut<'a>(&'a mut self, index: &FullIndex) -> (&'a K, &'a mut V) {
 
             unsafe {
                 debug_assert!(*self.hashes.offset(idx) != EMPTY_BUCKET);
-                (&'a     *self.keys.offset(idx),
-                 &'a mut *self.vals.offset(idx))
+                (&*self.keys.offset(idx), &mut *self.vals.offset(idx))
             }
         }
 
@@ -319,8 +317,7 @@ pub fn read_all_mut<'a>(&'a mut self, index: &FullIndex)
             unsafe {
                 debug_assert!(*self.hashes.offset(idx) != EMPTY_BUCKET);
                 (transmute(self.hashes.offset(idx)),
-                 &'a mut *self.keys.offset(idx),
-                 &'a mut *self.vals.offset(idx))
+                 &mut *self.keys.offset(idx), &mut *self.vals.offset(idx))
             }
         }
 
index 06a1d069b6a72b25f9a75eae9c489a88b8545bd4..0e6f848fce85ab19fa9fc3d5b1d6aceba1db522c 100644 (file)
@@ -94,7 +94,7 @@
 //! all the standard macros, such as `assert!`, `fail!`, `println!`,
 //! and `format!`, also available to all Rust code.
 
-#![crate_id = "std#0.11.0-pre"]
+#![crate_id = "std#0.11.0"]
 #![unstable]
 #![comment = "The Rust standard library"]
 #![license = "MIT/ASL2"]
 #![crate_type = "dylib"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/",
+       html_root_url = "http://doc.rust-lang.org/0.11.0/",
        html_playground_url = "http://play.rust-lang.org/")]
 
 #![feature(macro_rules, globs, managed_boxes, linkage)]
 pub use core::raw;
 pub use core::simd;
 pub use core::tuple;
+// FIXME #15320: primitive documentation needs top-level modules, this
+// should be `std::tuple::unit`.
+pub use core::unit;
 #[cfg(not(test))] pub use core::ty;
 pub use core::result;
 pub use core::option;
index 2e0dcdd8eb69f83588a353615eba5a3cb8f7e344..404887823cbf8d0888db5b440c62b6473171ff37 100644 (file)
@@ -261,7 +261,7 @@ pub fn write(w: &mut Writer) -> IoResult<()> {
         use slice::{MutableVector};
 
         extern {
-            fn backtrace(buf: *mut *const libc::c_void,
+            fn backtrace(buf: *mut *mut libc::c_void,
                          sz: libc::c_int) -> libc::c_int;
         }
 
@@ -274,7 +274,7 @@ fn backtrace(buf: *mut *const libc::c_void,
         try!(writeln!(w, "stack backtrace:"));
         // 100 lines should be enough
         static SIZE: libc::c_int = 100;
-        let mut buf: [*const libc::c_void, ..SIZE] = unsafe {mem::zeroed()};
+        let mut buf: [*mut libc::c_void, ..SIZE] = unsafe {mem::zeroed()};
         let cnt = unsafe { backtrace(buf.as_mut_ptr(), SIZE) as uint};
 
         // skipping the first one as it is write itself
index beb75bab3f6ab6c8d1d83ee24176c53cb7b879b2..4f6d1a261c4917696b56d99a628f7a4cbb69333c 100644 (file)
 //! use this crate specifically. Instead, its functionality is reexported
 //! through `std::sync`.
 
-#![crate_id = "sync#0.11.0-pre"]
+#![crate_id = "sync#0.11.0"]
 #![experimental]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
 #![license = "MIT/ASL2"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/",
+       html_root_url = "http://doc.rust-lang.org/0.11.0/",
        html_playground_url = "http://play.rust-lang.org/")]
 
 #![feature(phase, globs, macro_rules, unsafe_destructor)]
index 0d6821fb30c08810471035c1c7593d3a117e257f..ce63d2bb7311acfece0c700fc8a478208822edbf 100644 (file)
 
 */
 
-#![crate_id = "syntax#0.11.0-pre"]
+#![crate_id = "syntax#0.11.0"]
 #![experimental]
 #![license = "MIT/ASL2"]
 #![crate_type = "dylib"]
 #![crate_type = "rlib"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/")]
+       html_root_url = "http://doc.rust-lang.org/0.11.0/")]
 
 #![feature(macro_rules, globs, managed_boxes, default_type_params, phase)]
 #![feature(quote, unsafe_destructor)]
index f3789e25bc8a7e5e39bc1e1ded000561e43c4578..960971b94d2f2e8fa6563748ec6915cbc54413ed 100644 (file)
@@ -2400,7 +2400,6 @@ pub fn parse_prefix_expr(&mut self) -> Gc<Expr> {
           }
           token::BINOP(token::AND) | token::ANDAND => {
             self.expect_and();
-            let _lt = self.parse_opt_lifetime();
             let m = self.parse_mutability();
             let e = self.parse_prefix_expr();
             hi = e.span.hi;
index 34d60ddbe9db9375416437d4f747508578bd2503..56694e28b666227e1a87c513d83c40c119e3c99e 100644 (file)
@@ -38,7 +38,7 @@
 //! [win]: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682010%28v=vs.85%29.aspx
 //! [ti]: https://en.wikipedia.org/wiki/Terminfo
 
-#![crate_id = "term#0.11.0-pre"]
+#![crate_id = "term#0.11.0"]
 #![experimental]
 #![comment = "Simple ANSI color library"]
 #![license = "MIT/ASL2"]
@@ -46,7 +46,7 @@
 #![crate_type = "dylib"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/",
+       html_root_url = "http://doc.rust-lang.org/0.11.0/",
        html_playground_url = "http://play.rust-lang.org/")]
 
 #![feature(macro_rules, phase)]
index 71fdea9b9ec8e80f3aaec65dbaa4dda624b10c95..9467eb699217074217d016d55405352385b8b43a 100644 (file)
@@ -19,7 +19,7 @@
 
 // These are the orders ncurses uses in its compiled format (as of 5.9). Not sure if portable.
 
-pub static boolfnames: &'static[&'static str] = &'static["auto_left_margin", "auto_right_margin",
+pub static boolfnames: &'static[&'static str] = &["auto_left_margin", "auto_right_margin",
     "no_esc_ctlc", "ceol_standout_glitch", "eat_newline_glitch", "erase_overstrike", "generic_type",
     "hard_copy", "has_meta_key", "has_status_line", "insert_null_glitch", "memory_above",
     "memory_below", "move_insert_mode", "move_standout_mode", "over_strike", "status_line_esc_ok",
     "no_correctly_working_cr", "gnu_has_meta_key", "linefeed_is_newline", "has_hardware_tabs",
     "return_does_clr_eol"];
 
-pub static boolnames: &'static[&'static str] = &'static["bw", "am", "xsb", "xhp", "xenl", "eo",
+pub static boolnames: &'static[&'static str] = &["bw", "am", "xsb", "xhp", "xenl", "eo",
     "gn", "hc", "km", "hs", "in", "db", "da", "mir", "msgr", "os", "eslok", "xt", "hz", "ul", "xon",
     "nxon", "mc5i", "chts", "nrrmc", "npc", "ndscr", "ccc", "bce", "hls", "xhpa", "crxm", "daisy",
     "xvpa", "sam", "cpix", "lpix", "OTbs", "OTns", "OTnc", "OTMT", "OTNL", "OTpt", "OTxr"];
 
-pub static numfnames: &'static[&'static str] = &'static[ "columns", "init_tabs", "lines",
+pub static numfnames: &'static[&'static str] = &[ "columns", "init_tabs", "lines",
     "lines_of_memory", "magic_cookie_glitch", "padding_baud_rate", "virtual_terminal",
     "width_status_line", "num_labels", "label_height", "label_width", "max_attributes",
     "maximum_windows", "max_colors", "max_pairs", "no_color_video", "buffer_capacity",
     "bit_image_entwining", "bit_image_type", "magic_cookie_glitch_ul", "carriage_return_delay",
     "new_line_delay", "backspace_delay", "horizontal_tab_delay", "number_of_function_keys"];
 
-pub static numnames: &'static[&'static str] = &'static[ "cols", "it", "lines", "lm", "xmc", "pb",
+pub static numnames: &'static[&'static str] = &[ "cols", "it", "lines", "lm", "xmc", "pb",
     "vt", "wsl", "nlab", "lh", "lw", "ma", "wnum", "colors", "pairs", "ncv", "bufsz", "spinv",
     "spinh", "maddr", "mjump", "mcs", "mls", "npins", "orc", "orl", "orhi", "orvi", "cps", "widcs",
     "btns", "bitwin", "bitype", "UTug", "OTdC", "OTdN", "OTdB", "OTdT", "OTkn"];
 
-pub static stringfnames: &'static[&'static str] = &'static[ "back_tab", "bell", "carriage_return",
+pub static stringfnames: &'static[&'static str] = &[ "back_tab", "bell", "carriage_return",
     "change_scroll_region", "clear_all_tabs", "clear_screen", "clr_eol", "clr_eos",
     "column_address", "command_character", "cursor_address", "cursor_down", "cursor_home",
     "cursor_invisible", "cursor_left", "cursor_mem_address", "cursor_normal", "cursor_right",
     "acs_lrcorner", "acs_ltee", "acs_rtee", "acs_btee", "acs_ttee", "acs_hline", "acs_vline",
     "acs_plus", "memory_lock", "memory_unlock", "box_chars_1"];
 
-pub static stringnames: &'static[&'static str] = &'static[ "cbt", "_", "cr", "csr", "tbc", "clear",
+pub static stringnames: &'static[&'static str] = &[ "cbt", "_", "cr", "csr", "tbc", "clear",
     "_", "_", "hpa", "cmdch", "cup", "cud1", "home", "civis", "cub1", "mrcup", "cnorm", "cuf1",
     "ll", "cuu1", "cvvis", "dch1", "dl1", "dsl", "hd", "smacs", "blink", "bold", "smcup", "smdc",
     "dim", "smir", "invis", "prot", "rev", "smso", "smul", "ech", "rmacs", "sgr0", "rmcup", "rmdc",
index ec31ffc93f38e8c68c67171d3de5b19c5225ebc8..02f7ebc6d21c816d007b4a4f3c1cabb7e8c67172 100644 (file)
@@ -23,7 +23,7 @@
 // running tests while providing a base that other test frameworks may
 // build off of.
 
-#![crate_id = "test#0.11.0-pre"]
+#![crate_id = "test#0.11.0"]
 #![experimental]
 #![comment = "Rust internal test library only used by rustc"]
 #![license = "MIT/ASL2"]
@@ -31,7 +31,7 @@
 #![crate_type = "dylib"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/")]
+       html_root_url = "http://doc.rust-lang.org/0.11.0/")]
 
 #![feature(asm, macro_rules, phase)]
 
index 98544a1218aad705ae5348d0cc32f137c9aa19eb..0e4de41959a33de9717bb41f8d73cdefac62a9a0 100644 (file)
@@ -10,7 +10,7 @@
 
 //! Simple time handling.
 
-#![crate_id = "time#0.11.0-pre"]
+#![crate_id = "time#0.11.0"]
 #![experimental]
 
 #![crate_type = "rlib"]
@@ -18,7 +18,7 @@
 #![license = "MIT/ASL2"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/",
+       html_root_url = "http://doc.rust-lang.org/0.11.0/",
        html_playground_url = "http://play.rust-lang.org/")]
 #![feature(phase)]
 
@@ -316,10 +316,24 @@ pub fn to_utc(&self) -> Tm {
     }
 
     /**
-     * Return a string of the current time in the form
-     * "Thu Jan  1 00:00:00 1970".
+     * Returns a time string formatted according to the `asctime` format in ISO
+     * C, in the local timezone.
+     *
+     * Example: "Thu Jan  1 00:00:00 1970"
+     */
+    pub fn ctime(&self) -> String {
+        self.to_local().asctime()
+    }
+
+    /**
+     * Returns a time string formatted according to the `asctime` format in ISO
+     * C.
+     *
+     * Example: "Thu Jan  1 00:00:00 1970"
      */
-    pub fn ctime(&self) -> String { self.strftime("%c") }
+    pub fn asctime(&self) -> String {
+        self.strftime("%c")
+    }
 
     /// Formats the time according to the format string.
     pub fn strftime(&self, format: &str) -> String {
@@ -1372,6 +1386,19 @@ fn test(s: &str, format: &str) -> bool {
         assert_eq!(strptime("360", "%Y-%m-%d"), Err("Invalid year".to_string()))
     }
 
+    fn test_asctime() {
+        set_time_zone();
+
+        let time = Timespec::new(1234567890, 54321);
+        let utc   = at_utc(time);
+        let local = at(time);
+
+        debug!("test_ctime: {:?} {:?}", utc.asctime(), local.asctime());
+
+        assert_eq!(utc.asctime(), "Fri Feb 13 23:31:30 2009".to_string());
+        assert_eq!(local.asctime(), "Fri Feb 13 15:31:30 2009".to_string());
+    }
+
     fn test_ctime() {
         set_time_zone();
 
@@ -1381,7 +1408,7 @@ fn test_ctime() {
 
         debug!("test_ctime: {:?} {:?}", utc.ctime(), local.ctime());
 
-        assert_eq!(utc.ctime(), "Fri Feb 13 23:31:30 2009".to_string());
+        assert_eq!(utc.ctime(), "Fri Feb 13 15:31:30 2009".to_string());
         assert_eq!(local.ctime(), "Fri Feb 13 15:31:30 2009".to_string());
     }
 
@@ -1436,11 +1463,13 @@ fn test_strftime() {
         assert_eq!(local.strftime("%z"), "-0800".to_string());
         assert_eq!(local.strftime("%%"), "%".to_string());
 
+        assert_eq!(local.asctime(), "Fri Feb 13 15:31:30 2009".to_string());
         assert_eq!(local.ctime(), "Fri Feb 13 15:31:30 2009".to_string());
         assert_eq!(local.rfc822z(), "Fri, 13 Feb 2009 15:31:30 -0800".to_string());
         assert_eq!(local.rfc3339(), "2009-02-13T15:31:30-08:00".to_string());
 
-        assert_eq!(utc.ctime(), "Fri Feb 13 23:31:30 2009".to_string());
+        assert_eq!(utc.asctime(), "Fri Feb 13 23:31:30 2009".to_string());
+        assert_eq!(utc.ctime(), "Fri Feb 13 15:31:30 2009".to_string());
         assert_eq!(utc.rfc822(), "Fri, 13 Feb 2009 23:31:30 GMT".to_string());
         assert_eq!(utc.rfc822z(), "Fri, 13 Feb 2009 23:31:30 -0000".to_string());
         assert_eq!(utc.rfc3339(), "2009-02-13T23:31:30Z".to_string());
@@ -1489,6 +1518,7 @@ fn run_tests() {
         test_to_timespec();
         test_conversions();
         test_strptime();
+        test_asctime();
         test_ctime();
         test_strftime();
         test_timespec_eq_ord();
index 577a1e8ea9e54957d1fef5952909c7251bac25af..a60cc8e992b4d58592ee11818f5a4ee84b90e207 100644 (file)
 
 //! Types/fns concerning URLs (see RFC 3986)
 
-#![crate_id = "url#0.11.0-pre"]
+#![crate_id = "url#0.11.0"]
 #![experimental]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
 #![license = "MIT/ASL2"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/",
+       html_root_url = "http://doc.rust-lang.org/0.11.0/",
        html_playground_url = "http://play.rust-lang.org/")]
 #![feature(default_type_params)]
 
index 0e73256893e9cc1c06450b755c3fc6ccdccbdc2d..297afe4aa598e4b21ac30e5c7a55331b1fb6daa5 100644 (file)
@@ -54,14 +54,14 @@ fn main() {
 
 */
 
-#![crate_id = "uuid#0.11.0-pre"]
+#![crate_id = "uuid#0.11.0"]
 #![experimental]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
 #![license = "MIT/ASL2"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-       html_root_url = "http://doc.rust-lang.org/",
+       html_root_url = "http://doc.rust-lang.org/0.11.0/",
        html_playground_url = "http://play.rust-lang.org/")]
 
 #![feature(default_type_params)]
index 4491adc74bd65d9f8610e7d76d125ec1265253b2..8a48e483029da5a265b1f7251554ca17a2c01751 100644 (file)
@@ -10,5 +10,5 @@
 
 // no-prefer-dynamic
 
-#![crate_id = "url#0.11.0-pre"]
+#![crate_id = "url#0.11.0"]
 #![crate_type = "dylib"]
index d921aeda3e01a99195b832228055e64570dcaaa5..0deece53451ee84a127f70cf7c13e8690916e267 100644 (file)
@@ -10,5 +10,5 @@
 
 // no-prefer-dynamic
 
-#![crate_id = "url#0.11.0-pre"]
+#![crate_id = "url#0.11.0"]
 #![crate_type = "rlib"]
index 9939fc791907d0fb166247c34f1b86e7563d91aa..1c7516ef7e2bfb2e3189c5e276f4f18d998d7a46 100644 (file)
@@ -32,7 +32,7 @@ enum UnsafeEnum<T> {
 static STATIC2: Unsafe<int> = Unsafe{value: 1, marker1: marker::InvariantType};
 static STATIC3: MyUnsafe<int> = MyUnsafe{value: STATIC2};
 
-static STATIC4: &'static Unsafe<int> = &'static STATIC2;
+static STATIC4: &'static Unsafe<int> = &STATIC2;
 //~^ ERROR borrow of immutable static items with unsafe interior is not allowed
 
 struct Wrap<T> {
index da5f7680d8ce759488dd30ffc8f446b05232e622..b7344d72a46c4253bbc19487d47ef34d159edc20 100644 (file)
@@ -113,12 +113,12 @@ fn drop(&mut self) {}
     field2: Variant4("str".to_string())
 };
 
-static STATIC15: &'static [Box<MyOwned>] = &'static [box MyOwned, box MyOwned];
+static STATIC15: &'static [Box<MyOwned>] = &[box MyOwned, box MyOwned];
 //~^ ERROR static items are not allowed to have custom pointers
 //~^^ ERROR static items are not allowed to have custom pointers
 
 static STATIC16: (&'static Box<MyOwned>, &'static Box<MyOwned>) =
-    (&'static box MyOwned, &'static box MyOwned);
+    (&box MyOwned, &box MyOwned);
 //~^ ERROR static items are not allowed to have custom pointers
 //~^^ ERROR static items are not allowed to have custom pointers
 
diff --git a/src/test/compile-fail/type-params-in-different-spaces-1.rs b/src/test/compile-fail/type-params-in-different-spaces-1.rs
new file mode 100644 (file)
index 0000000..6e32e6e
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright 2014 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::num::Num;
+
+trait BrokenAdd: Num {
+    fn broken_add<T>(&self, rhs: T) -> Self {
+        *self + rhs //~ ERROR mismatched types
+    }
+}
+
+impl<T: Num> BrokenAdd for T {}
+
+pub fn main() {
+    let foo: u8 = 0u8;
+    let x: u8 = foo.broken_add("hello darkness my old friend".to_string());
+    println!("{}", x);
+}
diff --git a/src/test/compile-fail/type-params-in-different-spaces-2.rs b/src/test/compile-fail/type-params-in-different-spaces-2.rs
new file mode 100644 (file)
index 0000000..955efee
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright 2014 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.
+
+trait Tr<T> {
+    fn op(T) -> Self;
+}
+
+// these compile as if Self: Tr<U>, even tho only Self: Tr<Self or T>
+trait A:    Tr<Self> {
+    fn test<U>(u: U) -> Self {
+        Tr::op(u)   //~ ERROR expected Tr<U>, but found Tr<Self>
+    }
+}
+trait B<T>: Tr<T> {
+    fn test<U>(u: U) -> Self {
+        Tr::op(u)   //~ ERROR expected Tr<U>, but found Tr<T>
+    }
+}
+
+impl<T> Tr<T> for T {
+    fn op(t: T) -> T { t }
+}
+impl<T> A for T {}
+
+fn main() {
+    std::io::println(A::test((&7306634593706211700, 8)));
+}
+
diff --git a/src/test/compile-fail/type-params-in-different-spaces-3.rs b/src/test/compile-fail/type-params-in-different-spaces-3.rs
new file mode 100644 (file)
index 0000000..a3d69d5
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright 2014 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.
+
+trait Tr {
+    fn test<X>(u: X) -> Self {
+        u   //~ ERROR mismatched types
+    }
+}
+
+fn main() {}
+
index a72e24cf2c3857441a8c33330ada8c321f0b5056..a44481b4b7f23d75f339fa247fe7729c05d8db14 100644 (file)
@@ -1,7 +1,7 @@
 -include ../tools.mk
 
 all:
-       [ `$(RUSTC) --crate-id crate.rs` = "foo#0.11.0-pre" ]
+       [ `$(RUSTC) --crate-id crate.rs` = "foo#0.11.0" ]
        [ `$(RUSTC) --crate-name crate.rs` = "foo" ]
        [ `$(RUSTC) --crate-file-name crate.rs` = "foo" ]
        [ `$(RUSTC) --crate-file-name --crate-type=lib --test crate.rs` = "foo" ]
index 31446a763e2dd978798a37ea766e35d1ce779a64..9faa7c016284bf054eec1849d20b436bb524263a 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![crate_id = "foo#0.11.0-pre"]
+#![crate_id = "foo#0.11.0"]
 
 // Querying about the crate metadata should *not* parse the entire crate, it
 // only needs the crate attributes (which are guaranteed to be at the top) be
diff --git a/src/test/run-pass/issue-12285.rs b/src/test/run-pass/issue-12285.rs
new file mode 100644 (file)
index 0000000..5637712
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2014 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.
+
+struct S;
+
+fn main() {
+    match Some(&S) {
+        Some(&S) => {},
+        _x => unreachable!()
+    }
+    match Some(&S) {
+        Some(&S) => {},
+        None => unreachable!()
+    }
+}
index 543f4bf027bfd10293662e2e1798414a78f6aa9a..5b6012673564d03447fa52a44ef99e7f6a362d11 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 struct T (&'static [int]);
-static t : T = T (&'static [5, 4, 3]);
+static t : T = T (&[5, 4, 3]);
 pub fn main () {
     let T(ref v) = t;
     assert_eq!(v[0], 5);
index 6ceb2cf87b9a3a528cda5430acea8f97e24957e9..275fe740db157ca60c5e136efde82437d80bae4a 100644 (file)
@@ -17,7 +17,7 @@ pub fn default_instance() -> &'static UninterpretedOption_NamePart {
         static instance: UninterpretedOption_NamePart = UninterpretedOption_NamePart {
             name_part: None,
         };
-        &'static instance
+        &instance
     }
 }
 
index c6a3a0b0409aa76ff8b3bf259c8d584905e6f03f..ed4712ff3be9c55bd8ba81e1b64498f0fee7445c 100644 (file)
@@ -43,7 +43,7 @@ fn default_instance() -> &'static Request {
         // size of struct may be not equal to size of struct, and
         // compiler crashes in internal assertion check.
     };
-    &'static instance
+    &instance
 }
 
 fn non_default_instance() -> &'static Request {
@@ -51,7 +51,7 @@ fn non_default_instance() -> &'static Request {
         foo: TestSome(0x1020304050607080),
         bar: 19,
     };
-    &'static instance
+    &instance
 }
 
 pub fn main() {
index 1a79edb30c9c640a36ac2d4e509ef51f623faf95..f95e9ad7d83c98a2d05bcd87aac823e96ca2d2f1 100644 (file)
@@ -11,7 +11,7 @@
 // This test checks that the `_` type placeholder works
 // correctly for enabling type inference.
 
-static CONSTEXPR: *const int = &'static 413 as *const _;
+static CONSTEXPR: *const int = &413 as *const _;
 
 pub fn main() {
     let x: Vec<_> = range(0u, 5).collect();
index de22f428713f71be7e15441b422dc729b7415502..3f152cc10610f3ae1894c654f09f4d6a9a9f33ed 100644 (file)
@@ -15,7 +15,7 @@
 #![no_std]
 extern crate std;
 extern crate zed = "std";
-extern crate bar = "std#0.11.0-pre";
+extern crate bar = "std#0.11.0";
 
 
 use std::str;