]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #17654 : gereeter/rust/no-unnecessary-cell, r=alexcrichton
authorbors <bors@rust-lang.org>
Wed, 1 Oct 2014 13:27:24 +0000 (13:27 +0000)
committerbors <bors@rust-lang.org>
Wed, 1 Oct 2014 13:27:24 +0000 (13:27 +0000)
There is more that could be done, but this was the low hanging fruit.

136 files changed:
mk/dist.mk
src/compiletest/runtest.rs
src/doc/guide.md
src/doc/reference.md
src/etc/emacs/rust-mode-tests.el
src/etc/install.sh
src/etc/kate/rust.xml
src/etc/mklldeps.py
src/etc/vim/syntax/rust.vim
src/liballoc/heap.rs
src/libcollections/string.rs
src/libcore/any.rs
src/libcore/char.rs
src/libcore/fmt/num.rs
src/libcore/str.rs
src/libdebug/repr.rs
src/libgreen/basic.rs
src/libgreen/context.rs
src/libgreen/stack.rs
src/liblibc/lib.rs
src/libnative/io/c_unix.rs
src/libnative/io/file_unix.rs
src/libnative/io/mod.rs
src/libnative/io/net.rs
src/libnative/io/process.rs
src/libnative/io/tty_windows.rs
src/libnative/lib.rs
src/librand/distributions/gamma.rs
src/libregex/vm.rs
src/librustc/back/link.rs
src/librustc/diagnostics.rs
src/librustc/lint/builtin.rs
src/librustc/metadata/common.rs
src/librustc/metadata/csearch.rs
src/librustc/metadata/decoder.rs
src/librustc/metadata/encoder.rs
src/librustc/middle/astencode.rs
src/librustc/middle/cfg/construct.rs
src/librustc/middle/check_const.rs
src/librustc/middle/check_match.rs
src/librustc/middle/def.rs
src/librustc/middle/expr_use_visitor.rs
src/librustc/middle/intrinsicck.rs
src/librustc/middle/liveness.rs
src/librustc/middle/mem_categorization.rs
src/librustc/middle/privacy.rs
src/librustc/middle/resolve.rs
src/librustc/middle/save/mod.rs
src/librustc/middle/traits/mod.rs
src/librustc/middle/traits/select.rs
src/librustc/middle/traits/util.rs
src/librustc/middle/trans/asm.rs
src/librustc/middle/trans/callee.rs
src/librustc/middle/trans/closure.rs
src/librustc/middle/trans/consts.rs
src/librustc/middle/trans/context.rs
src/librustc/middle/trans/debuginfo.rs
src/librustc/middle/trans/expr.rs
src/librustc/middle/ty.rs
src/librustc/middle/typeck/check/method.rs
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/check/regionck.rs
src/librustc/middle/typeck/check/vtable2.rs
src/librustc/middle/typeck/check/wf.rs
src/librustc/util/ppaux.rs
src/librustc_back/fs.rs
src/librustc_back/rpath.rs
src/librustc_back/svh.rs
src/librustdoc/clean/inline.rs
src/librustdoc/clean/mod.rs
src/librustdoc/flock.rs
src/librustdoc/lib.rs
src/librustdoc/plugins.rs
src/librustrt/args.rs
src/librustrt/lib.rs
src/librustrt/libunwind.rs
src/librustrt/local_ptr.rs
src/librustrt/mutex.rs
src/librustrt/stack.rs
src/librustrt/thread_local_storage.rs
src/librustrt/unwind.rs
src/librustuv/uvll.rs
src/libserialize/base64.rs
src/libserialize/hex.rs
src/libserialize/json.rs
src/libstd/dynamic_lib.rs
src/libstd/io/net/addrinfo.rs
src/libstd/io/process.rs
src/libstd/io/signal.rs
src/libstd/num/strconv.rs
src/libstd/os.rs
src/libstd/rand/os.rs
src/libstd/rt/backtrace.rs
src/libsyntax/ast.rs
src/libsyntax/attr.rs
src/libsyntax/codemap.rs
src/libsyntax/config.rs
src/libsyntax/ext/build.rs
src/libsyntax/ext/cfg.rs
src/libsyntax/ext/expand.rs
src/libsyntax/feature_gate.rs
src/libsyntax/fold.rs
src/libsyntax/parse/classify.rs
src/libsyntax/parse/lexer/mod.rs
src/libsyntax/parse/parser.rs
src/libsyntax/print/pprust.rs
src/libsyntax/visit.rs
src/libterm/terminfo/parm.rs
src/libtime/lib.rs
src/libunicode/u_char.rs
src/liburl/lib.rs
src/libuuid/lib.rs
src/test/auxiliary/issue-12660-aux.rs [new file with mode: 0644]
src/test/compile-fail/if-let.rs [new file with mode: 0644]
src/test/compile-fail/lang-item-missing.rs [new file with mode: 0644]
src/test/compile-fail/lint-unnecessary-parens.rs
src/test/compile-fail/match-ill-type1.rs
src/test/compile-fail/match-range-fail-dominate.rs
src/test/compile-fail/match-range-fail.rs
src/test/compile-fail/refutable-pattern-errors.rs
src/test/debuginfo/issue12886.rs
src/test/run-pass/byte-literals.rs
src/test/run-pass/dst-deref-mut.rs
src/test/run-pass/fixup-deref-mut.rs [new file with mode: 0644]
src/test/run-pass/if-let.rs [new file with mode: 0644]
src/test/run-pass/inferred-suffix-in-pattern-range.rs
src/test/run-pass/issue-12582.rs
src/test/run-pass/issue-12660.rs [new file with mode: 0644]
src/test/run-pass/issue-13027.rs
src/test/run-pass/issue-13259-windows-tcb-trash.rs [new file with mode: 0644]
src/test/run-pass/issue-13867.rs
src/test/run-pass/issue-7222.rs
src/test/run-pass/match-range.rs
src/test/run-pass/out-of-stack.rs
src/test/run-pass/overloaded-autoderef-count.rs
src/test/run-pass/realloc-16687.rs

index 26169f3a13bd0f4c6884ddaf05feb8495d2d8072..4d82857ecea984542ac592eb04b2ab02c186cb9f 100644 (file)
@@ -283,7 +283,7 @@ distcheck-docs: dist-docs
 
 ifdef CFG_WINDOWSY_$(CFG_BUILD)
 
-dist: dist-win
+dist: dist-win dist-tar-bins
 
 distcheck: distcheck-win
        $(Q)rm -Rf tmp/distcheck
index 268a6020a10a5f9cdc56911a20e1d3ee3e14b2d6..b48ccfc43742d51e839152a9cdea7b7ded08a5a7 100644 (file)
@@ -1512,7 +1512,7 @@ fn _arm_exec_compiled_test(config: &Config,
     for c in exitcode_out.as_slice().chars() {
         if !c.is_digit() { break; }
         exitcode = exitcode * 10 + match c {
-            '0' .. '9' => c as int - ('0' as int),
+            '0' ... '9' => c as int - ('0' as int),
             _ => 101,
         }
     }
index 0474e5a31ce1d5947644ba0026fa28c1b304c910..074dfc17b0d78abb08a7418e4fb667f180a4cc65 100644 (file)
@@ -3757,27 +3757,27 @@ match x {
 }
 ```
 
-You can match a range of values with `..`:
+You can match a range of values with `...`:
 
 ```{rust}
 let x = 1i;
 
 match x {
-    1 .. 5 => println!("one through five"),
+    1 ... 5 => println!("one through five"),
     _ => println!("anything"),
 }
 ```
 
 Ranges are mostly used with integers and single characters.
 
-If you're matching multiple things, via a `|` or a `..`, you can bind
+If you're matching multiple things, via a `|` or a `...`, you can bind
 the value to a name with `@`:
 
 ```{rust}
 let x = 1i;
 
 match x {
-    x @ 1 .. 5 => println!("got {}", x),
+    x @ 1 ... 5 => println!("got {}", x),
     _ => println!("anything"),
 }
 ```
index 21da810a30098f59546039d038a0c6fcca9e969d..3da3d4c580755e6a0fb0a2bbb434ff169b355366 100644 (file)
@@ -2441,6 +2441,8 @@ The currently implemented features of the reference compiler are:
 * `default_type_params` - Allows use of default type parameters. The future of
                           this feature is uncertain.
 
+* `if_let` - Allows use of the `if let` syntax.
+
 * `intrinsics` - Allows use of the "rust-intrinsics" ABI. Compiler intrinsics
                  are inherently unstable and no promise about them is made.
 
@@ -3229,7 +3231,7 @@ for i in range(0u, 256) {
 if_expr : "if" no_struct_literal_expr '{' block '}'
           else_tail ? ;
 
-else_tail : "else" [ if_expr
+else_tail : "else" [ if_expr | if_let_expr
                    | '{' block '}' ] ;
 ```
 
@@ -3408,7 +3410,7 @@ may be specified with `..`. For example:
 
 let message = match x {
   0 | 1  => "not many",
-  2 .. 9 => "a few",
+  2 ... 9 => "a few",
   _      => "lots"
 };
 ```
@@ -3434,6 +3436,19 @@ let message = match maybe_digit {
 };
 ```
 
+### If let expressions
+
+```{.ebnf .gram}
+if_let_expr : "if" "let" pat '=' expr '{' block '}'
+               else_tail ? ;
+else_tail : "else" [ if_expr | if_let_expr | '{' block '}' ] ;
+```
+
+An `if let` expression is semantically identical to an `if` expression but in place
+of a condition expression it expects a refutable let statement. If the value of the
+expression on the right hand side of the let statement matches the pattern, the corresponding
+block will execute, otherwise flow proceeds to the first `else` block that follows.
+
 ### Return expressions
 
 ```{.ebnf .gram}
index 85800a6965daf348ec8b964ed1de52c9c666bd7e..1b6794e77f9f45484d7071eb760c5c77e5256996 100644 (file)
@@ -623,7 +623,7 @@ Convert the line-column information from that list into a buffer position value.
       (move-to-column column)
       (point))))
 
-;;; TODO: Maybe add an ERT explainer function (something that shows the
+;;; FIXME: Maybe add an ERT explainer function (something that shows the
 ;;; surrounding code of the final point, not just the position).
 (defun rust-test-motion (source-code init-pos final-pos manip-func &optional &rest args)
   "Test that MANIP-FUNC moves point from INIT-POS to FINAL-POS.
index c949743ea75949f4bd84b4e1b6812b391ec7f5d9..4f43b1ed130337afbfcbda523d92c750fe96f714 100644 (file)
@@ -325,7 +325,7 @@ then
     if [ -z "${CFG_UNINSTALL}" ]
     then
         msg "verifying platform can run binaries"
-        export $CFG_LD_PATH_VAR="${CFG_SRC_DIR}/lib":$CFG_OLD_LD_PATH_VAR
+        export $CFG_LD_PATH_VAR="${CFG_SRC_DIR}/lib:$CFG_OLD_LD_PATH_VAR"
         "${CFG_SRC_DIR}/bin/rustc" --version > /dev/null
         if [ $? -ne 0 ]
         then
@@ -489,7 +489,7 @@ then
     "${CFG_PREFIX}/bin/rustc" --version 2> /dev/null 1> /dev/null
     if [ $? -ne 0 ]
     then
-        export $CFG_LD_PATH_VAR="${CFG_PREFIX}/lib":$CFG_OLD_LD_PATH_VAR
+        export $CFG_LD_PATH_VAR="${CFG_PREFIX}/lib:$CFG_OLD_LD_PATH_VAR"
         "${CFG_PREFIX}/bin/rustc" --version > /dev/null
         if [ $? -ne 0 ]
         then
index 2b80c0ff39f5a43b6c24415689f436b56c5964cb..1c48b9d4f0c51f33ed50e2cb831452e1e23bf64b 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE language SYSTEM "language.dtd"
 [
-       <!-- TODO: Kate's regex engine has very limited support for
+       <!-- FIXME: Kate's regex engine has very limited support for
        predefined char classes, so making rustIdent consistent with actual
        Rust identifiers will be a bit difficult -->
        <!ENTITY rustIdent "[a-zA-Z_][a-zA-Z_0-9]*">
index f184e07891b9642cd2487cff40ef70eb5c04a744..0003de117a8359250ee02835d1c756e3948591d8 100644 (file)
@@ -67,7 +67,7 @@ for llconfig in sys.argv[4:]:
         "target_os = \"" + os + "\"",
     ]
 
-    f.write("#[cfg(" + ', '.join(cfg) + ")]\n")
+    f.write("#[cfg(all(" + ', '.join(cfg) + "))]\n")
 
     version = run([llconfig, '--version']).strip()
 
index 6ee610d9714db4938024c67cab95f2bff96fbd19..93931246a024043ae643a4bbf82c0eab7d927e53 100644 (file)
@@ -216,7 +216,7 @@ syn keyword rustTodo contained TODO FIXME XXX NB NOTE
 
 " Folding rules {{{2
 " Trivial folding rules to begin with.
-" TODO: use the AST to make really good folding
+" FIXME: use the AST to make really good folding
 syn region rustFoldBraces start="{" end="}" transparent fold
 
 " Default highlighting {{{1
index 349ae15eb32a0c58c0a59b50a95596ec807d9938..0d2872bcba06bbacf9eec24d7ec1a06cc1499fb7 100644 (file)
@@ -111,12 +111,12 @@ unsafe fn exchange_free(ptr: *mut u8, size: uint, align: uint) {
 // The minimum alignment guaranteed by the architecture. This value is used to
 // add fast paths for low alignment values. In practice, the alignment is a
 // constant at the call site and the branch will be optimized out.
-#[cfg(target_arch = "arm")]
-#[cfg(target_arch = "mips")]
-#[cfg(target_arch = "mipsel")]
+#[cfg(any(target_arch = "arm",
+          target_arch = "mips",
+          target_arch = "mipsel"))]
 static MIN_ALIGN: uint = 8;
-#[cfg(target_arch = "x86")]
-#[cfg(target_arch = "x86_64")]
+#[cfg(any(target_arch = "x86",
+          target_arch = "x86_64"))]
 static MIN_ALIGN: uint = 16;
 
 #[cfg(jemalloc)]
@@ -146,7 +146,7 @@ fn je_malloc_stats_print(write_cb: Option<extern "C" fn(cbopaque: *mut c_void,
     }
 
     // -lpthread needs to occur after -ljemalloc, the earlier argument isn't enough
-    #[cfg(not(windows), not(target_os = "android"))]
+    #[cfg(all(not(windows), not(target_os = "android")))]
     #[link(name = "pthread")]
     extern {}
 
@@ -206,7 +206,7 @@ pub fn stats_print() {
     }
 }
 
-#[cfg(not(jemalloc), unix)]
+#[cfg(all(not(jemalloc), unix))]
 mod imp {
     use core::cmp;
     use core::ptr;
@@ -268,7 +268,7 @@ pub fn usable_size(size: uint, _align: uint) -> uint {
     pub fn stats_print() {}
 }
 
-#[cfg(not(jemalloc), windows)]
+#[cfg(all(not(jemalloc), windows))]
 mod imp {
     use libc::{c_void, size_t};
     use libc;
index a856642c9361b80bc7fde910e20624f9ae59f436..d6adbd302645a0ba7777242b2e3c2792e69091ca 100644 (file)
@@ -199,10 +199,10 @@ macro_rules! error(() => ({
                     }
                     3 => {
                         match (byte, safe_get(v, i, total)) {
-                            (0xE0        , 0xA0 .. 0xBF) => (),
-                            (0xE1 .. 0xEC, 0x80 .. 0xBF) => (),
-                            (0xED        , 0x80 .. 0x9F) => (),
-                            (0xEE .. 0xEF, 0x80 .. 0xBF) => (),
+                            (0xE0         , 0xA0 ... 0xBF) => (),
+                            (0xE1 ... 0xEC, 0x80 ... 0xBF) => (),
+                            (0xED         , 0x80 ... 0x9F) => (),
+                            (0xEE ... 0xEF, 0x80 ... 0xBF) => (),
                             _ => {
                                 error!();
                                 continue;
@@ -217,9 +217,9 @@ macro_rules! error(() => ({
                     }
                     4 => {
                         match (byte, safe_get(v, i, total)) {
-                            (0xF0        , 0x90 .. 0xBF) => (),
-                            (0xF1 .. 0xF3, 0x80 .. 0xBF) => (),
-                            (0xF4        , 0x80 .. 0x8F) => (),
+                            (0xF0         , 0x90 ... 0xBF) => (),
+                            (0xF1 ... 0xF3, 0x80 ... 0xBF) => (),
+                            (0xF4         , 0x80 ... 0x8F) => (),
                             _ => {
                                 error!();
                                 continue;
index fb70cb5b752395d5d1bf01191cac056accf76b92..fd5007ff415f0869186b58c57a742ac0d9114433 100644 (file)
@@ -91,7 +91,7 @@ pub enum Void { }
 /// Every type with no non-`'static` references implements `Any`, so `Any` can
 /// be used as a trait object to emulate the effects dynamic typing.
 #[stable]
-pub trait Any: AnyPrivate {}
+pub trait Any: AnyPrivate + 'static {}
 
 /// An inner trait to ensure that only this module can call `get_type_id()`.
 pub trait AnyPrivate {
@@ -132,7 +132,7 @@ fn as_ref<T: 'static>(self) -> Option<&'a T> {
 }
 
 #[stable]
-impl<'a> AnyRefExt<'a> for &'a Any+'a {
+impl<'a> AnyRefExt<'a> for &'a Any {
     #[inline]
     #[stable]
     fn is<T: 'static>(self) -> bool {
@@ -181,7 +181,7 @@ fn as_mut<T: 'static>(self) -> Option<&'a mut T> {
 }
 
 #[stable]
-impl<'a> AnyMutRefExt<'a> for &'a mut Any+'a {
+impl<'a> AnyMutRefExt<'a> for &'a mut Any {
     #[inline]
     #[unstable = "naming conventions around acquiring references may change"]
     fn downcast_mut<T: 'static>(self) -> Option<&'a mut T> {
index c870f1b8f70a1dafa9f46cca72d40b5ededcc5d2..1e87d11d3736766f7bfa5928bce92b278773129e 100644 (file)
@@ -123,9 +123,9 @@ pub fn to_digit(c: char, radix: uint) -> Option<uint> {
         fail!("to_digit: radix is too high (maximum 36)");
     }
     let val = match c {
-      '0' .. '9' => c as uint - ('0' as uint),
-      'a' .. 'z' => c as uint + 10u - ('a' as uint),
-      'A' .. 'Z' => c as uint + 10u - ('A' as uint),
+      '0' ... '9' => c as uint - ('0' as uint),
+      'a' ... 'z' => c as uint + 10u - ('a' as uint),
+      'A' ... 'Z' => c as uint + 10u - ('A' as uint),
       _ => return None,
     };
     if val < radix { Some(val) }
@@ -184,7 +184,7 @@ pub fn escape_unicode(c: char, f: |char|) {
         let offset = offset as uint;
         unsafe {
             match ((c as i32) >> offset) & 0xf {
-                i @ 0 .. 9 => { f(transmute('0' as i32 + i)); }
+                i @ 0 ... 9 => { f(transmute('0' as i32 + i)); }
                 i => { f(transmute('a' as i32 + (i - 10))); }
             }
         }
@@ -211,7 +211,7 @@ pub fn escape_default(c: char, f: |char|) {
         '\\' => { f('\\'); f('\\'); }
         '\'' => { f('\\'); f('\''); }
         '"'  => { f('\\'); f('"'); }
-        '\x20' .. '\x7e' => { f(c); }
+        '\x20' ... '\x7e' => { f(c); }
         _ => c.escape_unicode(f),
     }
 }
index eb8d684fe50fdf5ade87ac4073ab11768da3474e..afcd0d1d645e6d9e38cf87e626ada16c1b094923 100644 (file)
@@ -99,13 +99,13 @@ fn digit(&self, x: u8) -> u8 {
     }
 }
 
-radix!(Binary,    2, "0b", x @  0 .. 2 => b'0' + x)
-radix!(Octal,     8, "0o", x @  0 .. 7 => b'0' + x)
-radix!(Decimal,  10, "",   x @  0 .. 9 => b'0' + x)
-radix!(LowerHex, 16, "0x", x @  0 .. 9 => b'0' + x,
-                           x @ 10 ..15 => b'a' + (x - 10))
-radix!(UpperHex, 16, "0x", x @  0 .. 9 => b'0' + x,
-                           x @ 10 ..15 => b'A' + (x - 10))
+radix!(Binary,    2, "0b", x @  0 .. 2 => b'0' + x)
+radix!(Octal,     8, "0o", x @  0 .. 7 => b'0' + x)
+radix!(Decimal,  10, "",   x @  0 .. 9 => b'0' + x)
+radix!(LowerHex, 16, "0x", x @  0 .. 9 => b'0' + x,
+                           x @ 10 ..15 => b'a' + (x - 10))
+radix!(UpperHex, 16, "0x", x @  0 .. 9 => b'0' + x,
+                           x @ 10 ..15 => b'A' + (x - 10))
 
 /// A radix with in the range of `2..36`.
 #[deriving(Clone, PartialEq)]
@@ -124,7 +124,7 @@ impl GenericRadix for Radix {
     fn base(&self) -> u8 { self.base }
     fn digit(&self, x: u8) -> u8 {
         match x {
-            x @  0 ..9 => b'0' + x,
+            x @  0 ..9 => b'0' + x,
             x if x < self.base() => b'a' + (x - 10),
             x => fail!("number not in the range 0..{}: {}", self.base() - 1, x),
         }
index 343b8e0b64b0faefb46506f990a84427932dae70..fd7c63a6b3262c353f0e4b618c35a0d489cc24b9 100644 (file)
@@ -843,18 +843,18 @@ macro_rules! next ( () => {
                 2 => if second & !CONT_MASK != TAG_CONT_U8 {err!()},
                 3 => {
                     match (first, second, next!() & !CONT_MASK) {
-                        (0xE0        , 0xA0 .. 0xBF, TAG_CONT_U8) |
-                        (0xE1 .. 0xEC, 0x80 .. 0xBF, TAG_CONT_U8) |
-                        (0xED        , 0x80 .. 0x9F, TAG_CONT_U8) |
-                        (0xEE .. 0xEF, 0x80 .. 0xBF, TAG_CONT_U8) => {}
+                        (0xE0         , 0xA0 ... 0xBF, TAG_CONT_U8) |
+                        (0xE1 ... 0xEC, 0x80 ... 0xBF, TAG_CONT_U8) |
+                        (0xED         , 0x80 ... 0x9F, TAG_CONT_U8) |
+                        (0xEE ... 0xEF, 0x80 ... 0xBF, TAG_CONT_U8) => {}
                         _ => err!()
                     }
                 }
                 4 => {
                     match (first, second, next!() & !CONT_MASK, next!() & !CONT_MASK) {
-                        (0xF0        , 0x90 .. 0xBF, TAG_CONT_U8, TAG_CONT_U8) |
-                        (0xF1 .. 0xF3, 0x80 .. 0xBF, TAG_CONT_U8, TAG_CONT_U8) |
-                        (0xF4        , 0x80 .. 0x8F, TAG_CONT_U8, TAG_CONT_U8) => {}
+                        (0xF0         , 0x90 ... 0xBF, TAG_CONT_U8, TAG_CONT_U8) |
+                        (0xF1 ... 0xF3, 0x80 ... 0xBF, TAG_CONT_U8, TAG_CONT_U8) |
+                        (0xF4         , 0x80 ... 0x8F, TAG_CONT_U8, TAG_CONT_U8) => {}
                         _ => err!()
                     }
                 }
index 64dc87908824b43bb184838598771c231a199f76..5fbba286feadf0f34a82e80f595e1850d86161e4 100644 (file)
@@ -227,7 +227,7 @@ fn write_escaped_char(&mut self, ch: char, is_str: bool) -> bool {
                     self.writer.write("\"".as_bytes())
                 }
             }
-            '\x20'..'\x7e' => self.writer.write([ch as u8]),
+            '\x20'...'\x7e' => self.writer.write([ch as u8]),
             _ => {
                 char::escape_unicode(ch, |c| {
                     let _ = self.writer.write([c as u8]);
index 27c71cb3e7c7e7a8cc1112ba467f4480bc2b88ae..129d37638a3168dd1167534f78e036e347b51b37 100644 (file)
@@ -116,7 +116,7 @@ fn run(&mut self) {
             }
 
             unsafe {
-                let mut messages = self.messages.lock();
+                let messages = self.messages.lock();
                 // We block here if we have no messages to process and we may
                 // receive a message at a later date
                 if self.remotes.len() > 0 && messages.len() == 0 &&
index 296615e15ffa065cc1081035dfbff1e806a4697c..a665d41aadf96531ec64a067366fb98358201547 100644 (file)
@@ -188,27 +188,27 @@ fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint,
 
 // windows requires saving more registers (both general and XMM), so the windows
 // register context must be larger.
-#[cfg(windows, target_arch = "x86_64")]
+#[cfg(all(windows, target_arch = "x86_64"))]
 #[repr(C)]
 struct Registers {
     gpr:[libc::uintptr_t, ..14],
     _xmm:[simd::u32x4, ..10]
 }
-#[cfg(not(windows), target_arch = "x86_64")]
+#[cfg(all(not(windows), target_arch = "x86_64"))]
 #[repr(C)]
 struct Registers {
     gpr:[libc::uintptr_t, ..10],
     _xmm:[simd::u32x4, ..6]
 }
 
-#[cfg(windows, target_arch = "x86_64")]
+#[cfg(all(windows, target_arch = "x86_64"))]
 fn new_regs() -> Box<Registers> {
     box() Registers {
         gpr:[0,..14],
         _xmm:[simd::u32x4(0,0,0,0),..10]
     }
 }
-#[cfg(not(windows), target_arch = "x86_64")]
+#[cfg(all(not(windows), target_arch = "x86_64"))]
 fn new_regs() -> Box<Registers> {
     box() Registers {
         gpr:[0,..10],
@@ -288,16 +288,13 @@ fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint,
     regs[14] = rust_bootstrap_green_task as libc::uintptr_t;   // #56 pc, r14 --> lr
 }
 
-#[cfg(target_arch = "mips")]
-#[cfg(target_arch = "mipsel")]
+#[cfg(any(target_arch = "mips", target_arch = "mipsel"))]
 type Registers = [libc::uintptr_t, ..32];
 
-#[cfg(target_arch = "mips")]
-#[cfg(target_arch = "mipsel")]
+#[cfg(any(target_arch = "mips", target_arch = "mipsel"))]
 fn new_regs() -> Box<Registers> { box {[0, .. 32]} }
 
-#[cfg(target_arch = "mips")]
-#[cfg(target_arch = "mipsel")]
+#[cfg(any(target_arch = "mips", target_arch = "mipsel"))]
 fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint,
                          procedure: raw::Procedure, sp: *mut uint) {
     let sp = align_down(sp);
index 4673e7b3ba2092b318b807fe42f140528ebae3fd..23b41f6c6e75bc2a8c2d1c83a1d5b140d1caae0a 100644 (file)
@@ -28,11 +28,10 @@ pub struct Stack {
 //
 // DragonFly BSD also seems to suffer from the same problem. When MAP_STACK is
 // used, it returns the same `ptr` multiple times.
-#[cfg(not(windows), not(target_os = "freebsd"), not(target_os = "dragonfly"))]
+#[cfg(not(any(windows, target_os = "freebsd", target_os = "dragonfly")))]
 static STACK_FLAGS: libc::c_int = libc::MAP_STACK | libc::MAP_PRIVATE |
                                   libc::MAP_ANON;
-#[cfg(target_os = "freebsd")]
-#[cfg(target_os = "dragonfly")]
+#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
 static STACK_FLAGS: libc::c_int = libc::MAP_PRIVATE | libc::MAP_ANON;
 #[cfg(windows)]
 static STACK_FLAGS: libc::c_int = 0;
index eabc02e3e26eba628528ddc859d72f55a5a745be..affa452eb49de06b09d79e1f207cd97f8c88f6d0 100644 (file)
 #[cfg(windows)] pub use funcs::extra::msvcrt::{get_osfhandle, open_osfhandle};
 #[cfg(windows)] pub use funcs::extra::winsock::{ioctlsocket};
 
-#[cfg(target_os = "linux")] #[cfg(target_os = "android")]
-#[cfg(target_os = "freebsd")] #[cfg(target_os = "dragonfly")]
+#[cfg(any(target_os = "linux",
+          target_os = "android",
+          target_os = "freebsd",
+          target_os = "dragonfly"))]
 pub use consts::os::posix01::{CLOCK_REALTIME, CLOCK_MONOTONIC};
 
-#[cfg(target_os = "linux")] #[cfg(target_os = "android")]
+#[cfg(any(target_os = "linux", target_os = "android"))]
 pub use funcs::posix01::unistd::{fdatasync};
-#[cfg(target_os = "linux")] #[cfg(target_os = "android")]
+#[cfg(any(target_os = "linux", target_os = "android"))]
 pub use types::os::arch::extra::{sockaddr_ll};
-#[cfg(target_os = "linux")] #[cfg(target_os = "android")]
+#[cfg(any(target_os = "linux", target_os = "android"))]
 pub use consts::os::extra::{AF_PACKET};
 
-#[cfg(unix, not(target_os = "freebsd"))]
+#[cfg(all(unix, not(target_os = "freebsd")))]
 pub use consts::os::extra::{MAP_STACK};
 
-#[cfg(target_os = "freebsd")]
-#[cfg(target_os = "dragonfly")]
+#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
 pub use consts::os::bsd44::{TCP_KEEPIDLE};
 
-#[cfg(target_os = "macos")]
-#[cfg(target_os = "ios")]
+#[cfg(any(target_os = "macos", target_os = "ios"))]
 pub use consts::os::bsd44::{TCP_KEEPALIVE};
-#[cfg(target_os = "macos")]
-#[cfg(target_os = "ios")]
+#[cfg(any(target_os = "macos", target_os = "ios"))]
 pub use consts::os::extra::{F_FULLFSYNC};
-#[cfg(target_os = "macos")]
-#[cfg(target_os = "ios")]
+
+#[cfg(any(target_os = "macos", target_os = "ios"))]
 pub use types::os::arch::extra::{mach_timebase_info};
 
 
@@ -372,8 +371,7 @@ pub mod bsd44 {}
 
     // Standard types that are scalar but vary by OS and arch.
 
-    #[cfg(target_os = "linux")]
-    #[cfg(target_os = "android")]
+    #[cfg(any(target_os = "linux", target_os = "android"))]
     pub mod os {
         pub mod common {
             pub mod posix01 {
@@ -506,10 +504,10 @@ pub struct ifaddrs {
             }
         }
 
-        #[cfg(target_arch = "x86")]
-        #[cfg(target_arch = "arm")]
-        #[cfg(target_arch = "mips")]
-        #[cfg(target_arch = "mipsel")]
+        #[cfg(any(target_arch = "x86",
+                  target_arch = "arm",
+                  target_arch = "mips",
+                  target_arch = "mipsel"))]
         pub mod arch {
             pub mod c95 {
                 pub type c_char = i8;
@@ -536,9 +534,9 @@ pub mod c99 {
                 pub type intptr_t = i32;
                 pub type uintptr_t = u32;
             }
-            #[cfg(target_arch = "x86")]
-            #[cfg(target_arch = "mips")]
-            #[cfg(target_arch = "mipsel")]
+            #[cfg(any(target_arch = "x86",
+                      target_arch = "mips",
+                      target_arch = "mipsel"))]
             pub mod posix88 {
                 pub type off_t = i32;
                 pub type dev_t = u64;
@@ -652,8 +650,7 @@ pub struct pthread_attr_t {
                     pub __size: [u32, ..9]
                 }
             }
-            #[cfg(target_arch = "mips")]
-            #[cfg(target_arch = "mipsel")]
+            #[cfg(any(target_arch = "mips", target_arch = "mipsel"))]
             pub mod posix01 {
                 use types::os::arch::c95::{c_long, c_ulong, time_t};
                 use types::os::arch::posix88::{gid_t, ino_t};
@@ -1660,8 +1657,7 @@ pub struct WIN32_FIND_DATAW {
         }
     }
 
-    #[cfg(target_os = "macos")]
-    #[cfg(target_os = "ios")]
+    #[cfg(any(target_os = "macos", target_os = "ios"))]
     pub mod os {
         pub mod common {
             pub mod posix01 {
@@ -1793,8 +1789,7 @@ pub struct ifaddrs {
             }
         }
 
-        #[cfg(target_arch = "arm")]
-        #[cfg(target_arch = "x86")]
+        #[cfg(any(target_arch = "arm", target_arch = "x86"))]
         pub mod arch {
             pub mod c95 {
                 pub type c_char = i8;
@@ -2383,8 +2378,7 @@ pub mod sysconf {
     }
 
 
-    #[cfg(target_os = "linux")]
-    #[cfg(target_os = "android")]
+    #[cfg(any(target_os = "linux", target_os = "android"))]
     pub mod os {
         pub mod c95 {
             use types::os::arch::c95::{c_int, c_uint};
@@ -2407,9 +2401,9 @@ pub mod c95 {
         }
         pub mod c99 {
         }
-        #[cfg(target_arch = "x86")]
-        #[cfg(target_arch = "x86_64")]
-        #[cfg(target_arch = "arm")]
+        #[cfg(any(target_arch = "x86",
+                  target_arch = "x86_64",
+                  target_arch = "arm"))]
         pub mod posix88 {
             use types::os::arch::c95::c_int;
             use types::common::c95::c_void;
@@ -2621,8 +2615,7 @@ pub mod posix88 {
             pub static EHWPOISON: c_int = 133;
         }
 
-        #[cfg(target_arch = "mips")]
-        #[cfg(target_arch = "mipsel")]
+        #[cfg(any(target_arch = "mips", target_arch = "mipsel"))]
         pub mod posix88 {
             use types::os::arch::c95::c_int;
             use types::common::c95::c_void;
@@ -2898,13 +2891,14 @@ pub mod posix01 {
             #[cfg(target_os = "android")]
             pub static PTHREAD_STACK_MIN: size_t = 8192;
 
-            #[cfg(target_arch = "arm", target_os = "linux")]
-            #[cfg(target_arch = "x86", target_os = "linux")]
-            #[cfg(target_arch = "x86_64", target_os = "linux")]
+            #[cfg(all(target_os = "linux",
+                      any(target_arch = "arm",
+                          target_arch = "x86",
+                          target_arch = "x86_64")))]
             pub static PTHREAD_STACK_MIN: size_t = 16384;
 
-            #[cfg(target_arch = "mips", target_os = "linux")]
-            #[cfg(target_arch = "mipsel", target_os = "linux")]
+            #[cfg(all(target_os = "linux",
+                      any(target_arch = "mips", target_arch = "mipsel")))]
             pub static PTHREAD_STACK_MIN: size_t = 131072;
 
             pub static CLOCK_REALTIME: c_int = 0;
@@ -2912,9 +2906,9 @@ pub mod posix01 {
         }
         pub mod posix08 {
         }
-        #[cfg(target_arch = "arm")]
-        #[cfg(target_arch = "x86")]
-        #[cfg(target_arch = "x86_64")]
+        #[cfg(any(target_arch = "arm",
+                  target_arch = "x86",
+                  target_arch = "x86_64"))]
         pub mod bsd44 {
             use types::os::arch::c95::c_int;
 
@@ -2961,8 +2955,7 @@ pub mod bsd44 {
             pub static SHUT_WR: c_int = 1;
             pub static SHUT_RDWR: c_int = 2;
         }
-        #[cfg(target_arch = "mips")]
-        #[cfg(target_arch = "mipsel")]
+        #[cfg(any(target_arch = "mips", target_arch = "mipsel"))]
         pub mod bsd44 {
             use types::os::arch::c95::c_int;
 
@@ -3007,9 +3000,9 @@ pub mod bsd44 {
             pub static SHUT_WR: c_int = 1;
             pub static SHUT_RDWR: c_int = 2;
         }
-        #[cfg(target_arch = "x86")]
-        #[cfg(target_arch = "x86_64")]
-        #[cfg(target_arch = "arm")]
+        #[cfg(any(target_arch = "x86",
+                  target_arch = "x86_64",
+                  target_arch = "arm"))]
         pub mod extra {
             use types::os::arch::c95::c_int;
 
@@ -3036,8 +3029,7 @@ pub mod extra {
             pub static MAP_NONBLOCK : c_int = 0x010000;
             pub static MAP_STACK : c_int = 0x020000;
         }
-        #[cfg(target_arch = "mips")]
-        #[cfg(target_arch = "mipsel")]
+        #[cfg(any(target_arch = "mips", target_arch = "mipsel"))]
         pub mod extra {
             use types::os::arch::c95::c_int;
 
@@ -3160,8 +3152,7 @@ pub mod sysconf {
         }
     }
 
-    #[cfg(target_os = "freebsd")]
-    #[cfg(target_os = "dragonfly")]
+    #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
     pub mod os {
         pub mod c95 {
             use types::os::arch::c95::{c_int, c_uint};
@@ -3421,10 +3412,11 @@ pub mod posix01 {
             #[cfg(target_arch = "arm")]
             pub static PTHREAD_STACK_MIN: size_t = 4096;
 
-            #[cfg(target_os = "freebsd", target_arch = "mips")]
-            #[cfg(target_os = "freebsd", target_arch = "mipsel")]
-            #[cfg(target_os = "freebsd", target_arch = "x86")]
-            #[cfg(target_os = "freebsd", target_arch = "x86_64")]
+            #[cfg(all(target_os = "freebsd",
+                      any(target_arch = "mips",
+                          target_arch = "mipsel",
+                          target_arch = "x86",
+                          target_arch = "x86_64")))]
             pub static PTHREAD_STACK_MIN: size_t = 2048;
 
             #[cfg(target_os = "dragonfly")]
@@ -3569,8 +3561,7 @@ pub mod sysconf {
         }
     }
 
-    #[cfg(target_os = "macos")]
-    #[cfg(target_os = "ios")]
+    #[cfg(any(target_os = "macos", target_os = "ios"))]
     pub mod os {
         pub mod c95 {
             use types::os::arch::c95::{c_int, c_uint};
@@ -4261,13 +4252,12 @@ pub mod mman {
         }
     }
 
-
-    #[cfg(target_os = "linux")]
-    #[cfg(target_os = "android")]
-    #[cfg(target_os = "macos")]
-    #[cfg(target_os = "ios")]
-    #[cfg(target_os = "freebsd")]
-    #[cfg(target_os = "dragonfly")]
+    #[cfg(any(target_os = "linux",
+              target_os = "android",
+              target_os = "macos",
+              target_os = "ios",
+              target_os = "freebsd",
+              target_os = "dragonfly"))]
     pub mod posix88 {
         pub mod stat_ {
             use types::os::arch::c95::{c_char, c_int};
@@ -4278,11 +4268,11 @@ pub mod stat_ {
                 pub fn chmod(path: *const c_char, mode: mode_t) -> c_int;
                 pub fn fchmod(fd: c_int, mode: mode_t) -> c_int;
 
-                #[cfg(target_os = "linux")]
-                #[cfg(target_os = "freebsd")]
-                #[cfg(target_os = "dragonfly")]
-                #[cfg(target_os = "android")]
-                #[cfg(target_os = "ios")]
+                #[cfg(any(target_os = "linux",
+                          target_os = "freebsd",
+                          target_os = "dragonfly",
+                          target_os = "android",
+                          target_os = "ios"))]
                 pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
 
                 #[cfg(target_os = "macos")]
@@ -4292,11 +4282,11 @@ pub mod stat_ {
                 pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int;
                 pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int;
 
-                #[cfg(target_os = "linux")]
-                #[cfg(target_os = "freebsd")]
-                #[cfg(target_os = "dragonfly")]
-                #[cfg(target_os = "android")]
-                #[cfg(target_os = "ios")]
+                #[cfg(any(target_os = "linux",
+                          target_os = "freebsd",
+                          target_os = "dragonfly",
+                          target_os = "android",
+                          target_os = "ios"))]
                 pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
 
                 #[cfg(target_os = "macos")]
@@ -4481,23 +4471,23 @@ pub mod net {
 
     }
 
-    #[cfg(target_os = "linux")]
-    #[cfg(target_os = "android")]
-    #[cfg(target_os = "macos")]
-    #[cfg(target_os = "ios")]
-    #[cfg(target_os = "freebsd")]
-    #[cfg(target_os = "dragonfly")]
+    #[cfg(any(target_os = "linux",
+              target_os = "android",
+              target_os = "macos",
+              target_os = "ios",
+              target_os = "freebsd",
+              target_os = "dragonfly"))]
     pub mod posix01 {
         pub mod stat_ {
             use types::os::arch::c95::{c_char, c_int};
             use types::os::arch::posix01::stat;
 
             extern {
-                #[cfg(target_os = "linux")]
-                #[cfg(target_os = "freebsd")]
-                #[cfg(target_os = "dragonfly")]
-                #[cfg(target_os = "android")]
-                #[cfg(target_os = "ios")]
+                #[cfg(any(target_os = "linux",
+                          target_os = "freebsd",
+                          target_os = "dragonfly",
+                          target_os = "android",
+                          target_os = "ios"))]
                 pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int;
 
                 #[cfg(target_os = "macos")]
@@ -4518,8 +4508,7 @@ pub fn readlink(path: *const c_char,
 
                 pub fn fsync(fd: c_int) -> c_int;
 
-                #[cfg(target_os = "linux")]
-                #[cfg(target_os = "android")]
+                #[cfg(any(target_os = "linux", target_os = "android"))]
                 pub fn fdatasync(fd: c_int) -> c_int;
 
                 pub fn setenv(name: *const c_char, val: *const c_char,
@@ -4598,13 +4587,13 @@ pub mod net {
     }
 
 
-    #[cfg(target_os = "windows")]
-    #[cfg(target_os = "linux")]
-    #[cfg(target_os = "android")]
-    #[cfg(target_os = "macos")]
-    #[cfg(target_os = "ios")]
-    #[cfg(target_os = "freebsd")]
-    #[cfg(target_os = "dragonfly")]
+    #[cfg(any(target_os = "windows",
+              target_os = "linux",
+              target_os = "android",
+              target_os = "macos",
+              target_os = "ios",
+              target_os = "freebsd",
+              target_os = "dragonfly"))]
     pub mod posix08 {
         pub mod unistd {
         }
@@ -4687,10 +4676,10 @@ pub fn sendto(socket: SOCKET, buf: *const c_void, len: c_int,
         }
     }
 
-    #[cfg(target_os = "macos")]
-    #[cfg(target_os = "ios")]
-    #[cfg(target_os = "freebsd")]
-    #[cfg(target_os = "dragonfly")]
+    #[cfg(any(target_os = "macos",
+              target_os = "ios",
+              target_os = "freebsd",
+              target_os = "dragonfly"))]
     pub mod bsd44 {
         use types::common::c95::{c_void};
         use types::os::arch::c95::{c_char, c_uchar, c_int, c_uint, c_ulong, size_t};
@@ -4723,8 +4712,7 @@ pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar)
     }
 
 
-    #[cfg(target_os = "linux")]
-    #[cfg(target_os = "android")]
+    #[cfg(any(target_os = "linux", target_os = "android"))]
     pub mod bsd44 {
         use types::common::c95::{c_void};
         use types::os::arch::c95::{c_uchar, c_int, size_t};
@@ -4744,8 +4732,7 @@ pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar)
     pub mod bsd44 {
     }
 
-    #[cfg(target_os = "macos")]
-    #[cfg(target_os = "ios")]
+    #[cfg(any(target_os = "macos", target_os = "ios"))]
     pub mod extra {
         use types::os::arch::c95::{c_char, c_int};
 
@@ -4755,13 +4742,11 @@ pub fn _NSGetExecutablePath(buf: *mut c_char, bufsize: *mut u32)
         }
     }
 
-    #[cfg(target_os = "freebsd")]
-    #[cfg(target_os = "dragonfly")]
+    #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
     pub mod extra {
     }
 
-    #[cfg(target_os = "linux")]
-    #[cfg(target_os = "android")]
+    #[cfg(any(target_os = "linux", target_os = "android"))]
     pub mod extra {
     }
 
index fa7da1de914b4489a380faac44e0e6c08386221c..2601d493443a17099ab64da5652a23a39029aa08 100644 (file)
 
 use libc;
 
-#[cfg(target_os = "macos")]
-#[cfg(target_os = "ios")]
-#[cfg(target_os = "freebsd")]
-#[cfg(target_os = "dragonfly")]
+#[cfg(any(target_os = "macos",
+          target_os = "ios",
+          target_os = "freebsd",
+          target_os = "dragonfly"))]
 pub static FIONBIO: libc::c_ulong = 0x8004667e;
-#[cfg(target_os = "linux", target_arch = "x86")]
-#[cfg(target_os = "linux", target_arch = "x86_64")]
-#[cfg(target_os = "linux", target_arch = "arm")]
-#[cfg(target_os = "android")]
+#[cfg(any(all(target_os = "linux",
+              any(target_arch = "x86",
+                  target_arch = "x86_64",
+                  target_arch = "arm")),
+          target_os = "android"))]
 pub static FIONBIO: libc::c_ulong = 0x5421;
-#[cfg(target_os = "linux", target_arch = "mips")]
-#[cfg(target_os = "linux", target_arch = "mipsel")]
+#[cfg(all(target_os = "linux",
+          any(target_arch = "mips", target_arch = "mipsel")))]
 pub static FIONBIO: libc::c_ulong = 0x667e;
 
-#[cfg(target_os = "macos")]
-#[cfg(target_os = "ios")]
-#[cfg(target_os = "freebsd")]
-#[cfg(target_os = "dragonfly")]
+#[cfg(any(target_os = "macos",
+          target_os = "ios",
+          target_os = "freebsd",
+          target_os = "dragonfly"))]
 pub static FIOCLEX: libc::c_ulong = 0x20006601;
-#[cfg(target_os = "linux", target_arch = "x86")]
-#[cfg(target_os = "linux", target_arch = "x86_64")]
-#[cfg(target_os = "linux", target_arch = "arm")]
-#[cfg(target_os = "android")]
+#[cfg(any(all(target_os = "linux",
+              any(target_arch = "x86",
+                  target_arch = "x86_64",
+                  target_arch = "arm")),
+          target_os = "android"))]
 pub static FIOCLEX: libc::c_ulong = 0x5451;
-#[cfg(target_os = "linux", target_arch = "mips")]
-#[cfg(target_os = "linux", target_arch = "mipsel")]
+#[cfg(all(target_os = "linux",
+          any(target_arch = "mips", target_arch = "mipsel")))]
 pub static FIOCLEX: libc::c_ulong = 0x6601;
 
-#[cfg(target_os = "macos")]
-#[cfg(target_os = "ios")]
-#[cfg(target_os = "freebsd")]
-#[cfg(target_os = "dragonfly")]
+#[cfg(any(target_os = "macos",
+          target_os = "ios",
+          target_os = "freebsd",
+          target_os = "dragonfly"))]
 pub static MSG_DONTWAIT: libc::c_int = 0x80;
-#[cfg(target_os = "linux")]
-#[cfg(target_os = "android")]
+#[cfg(any(target_os = "linux", target_os = "android"))]
 pub static MSG_DONTWAIT: libc::c_int = 0x40;
 
 pub static WNOHANG: libc::c_int = 1;
@@ -86,8 +87,7 @@ pub fn sigaction(signum: libc::c_int,
     pub fn sigemptyset(set: *mut sigset_t) -> libc::c_int;
 }
 
-#[cfg(target_os = "macos")]
-#[cfg(target_os = "ios")]
+#[cfg(any(target_os = "macos", target_os = "ios"))]
 mod select {
     pub static FD_SETSIZE: uint = 1024;
 
@@ -101,10 +101,10 @@ pub fn fd_set(set: &mut fd_set, fd: i32) {
     }
 }
 
-#[cfg(target_os = "android")]
-#[cfg(target_os = "freebsd")]
-#[cfg(target_os = "dragonfly")]
-#[cfg(target_os = "linux")]
+#[cfg(any(target_os = "android",
+          target_os = "freebsd",
+          target_os = "dragonfly",
+          target_os = "linux"))]
 mod select {
     use std::uint;
     use libc;
@@ -123,10 +123,11 @@ pub fn fd_set(set: &mut fd_set, fd: i32) {
     }
 }
 
-#[cfg(target_os = "linux", target_arch = "x86")]
-#[cfg(target_os = "linux", target_arch = "x86_64")]
-#[cfg(target_os = "linux", target_arch = "arm")]
-#[cfg(target_os = "android")]
+#[cfg(any(all(target_os = "linux",
+              any(target_arch = "x86",
+                  target_arch = "x86_64",
+                  target_arch = "arm")),
+          target_os = "android"))]
 mod signal {
     use libc;
 
@@ -173,8 +174,8 @@ pub struct sigset_t {
     }
 }
 
-#[cfg(target_os = "linux", target_arch = "mips")]
-#[cfg(target_os = "linux", target_arch = "mipsel")]
+#[cfg(all(target_os = "linux",
+          any(target_arch = "mips", target_arch = "mipsel")))]
 mod signal {
     use libc;
 
@@ -215,10 +216,10 @@ pub struct sigset_t {
     }
 }
 
-#[cfg(target_os = "macos")]
-#[cfg(target_os = "ios")]
-#[cfg(target_os = "freebsd")]
-#[cfg(target_os = "dragonfly")]
+#[cfg(any(target_os = "macos",
+          target_os = "ios",
+          target_os = "freebsd",
+          target_os = "dragonfly"))]
 mod signal {
     use libc;
 
index 1688b009ad7fb3b063951840af8c22facb44de0f..67aad1904b96f86971a45ac429b34d4a5625f8c9 100644 (file)
@@ -130,8 +130,7 @@ fn fsync(&mut self) -> IoResult<()> {
     fn datasync(&mut self) -> IoResult<()> {
         return super::mkerr_libc(os_datasync(self.fd()));
 
-        #[cfg(target_os = "macos")]
-        #[cfg(target_os = "ios")]
+        #[cfg(any(target_os = "macos", target_os = "ios"))]
         fn os_datasync(fd: c_int) -> c_int {
             unsafe { libc::fcntl(fd, libc::F_FULLFSYNC) }
         }
@@ -139,7 +138,7 @@ fn os_datasync(fd: c_int) -> c_int {
         fn os_datasync(fd: c_int) -> c_int {
             retry(|| unsafe { libc::fdatasync(fd) })
         }
-        #[cfg(not(target_os = "macos"), not(target_os = "ios"), not(target_os = "linux"))]
+        #[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "linux")))]
         fn os_datasync(fd: c_int) -> c_int {
             retry(|| unsafe { libc::fsync(fd) })
         }
@@ -445,14 +444,14 @@ fn mkstat(stat: &libc::stat) -> rtio::FileStat {
     // FileStat times are in milliseconds
     fn mktime(secs: u64, nsecs: u64) -> u64 { secs * 1000 + nsecs / 1000000 }
 
-    #[cfg(not(target_os = "linux"), not(target_os = "android"))]
+    #[cfg(not(any(target_os = "linux", target_os = "android")))]
     fn flags(stat: &libc::stat) -> u64 { stat.st_flags as u64 }
-    #[cfg(target_os = "linux")] #[cfg(target_os = "android")]
+    #[cfg(any(target_os = "linux", target_os = "android"))]
     fn flags(_stat: &libc::stat) -> u64 { 0 }
 
-    #[cfg(not(target_os = "linux"), not(target_os = "android"))]
+    #[cfg(not(any(target_os = "linux", target_os = "android")))]
     fn gen(stat: &libc::stat) -> u64 { stat.st_gen as u64 }
-    #[cfg(target_os = "linux")] #[cfg(target_os = "android")]
+    #[cfg(any(target_os = "linux", target_os = "android"))]
     fn gen(_stat: &libc::stat) -> u64 { 0 }
 
     rtio::FileStat {
index 86f72bf65ddd399ca8d23fce1d5891bc10202995..954f7bbc59adcd0dd48b8b4039d99d5e1419c26a 100644 (file)
 #[path = "file_windows.rs"]
 pub mod file;
 
-#[cfg(target_os = "macos")]
-#[cfg(target_os = "ios")]
-#[cfg(target_os = "freebsd")]
-#[cfg(target_os = "dragonfly")]
-#[cfg(target_os = "android")]
-#[cfg(target_os = "linux")]
+#[cfg(any(target_os = "macos",
+          target_os = "ios",
+          target_os = "freebsd",
+          target_os = "dragonfly",
+          target_os = "android",
+          target_os = "linux"))]
 #[path = "timer_unix.rs"]
 pub mod timer;
 
index 335a52b0bbed6ce63ed5f030b79ffeb52ef40a90..419748b75c324c56f47a736ce2942ca035f8a4d4 100644 (file)
@@ -282,20 +282,20 @@ fn set_keepalive(&mut self, seconds: Option<uint>) -> IoResult<()> {
         }
     }
 
-    #[cfg(target_os = "macos")]
-    #[cfg(target_os = "ios")]
+    #[cfg(any(target_os = "macos", target_os = "ios"))]
     fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> {
         setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPALIVE,
                    seconds as libc::c_int)
     }
-    #[cfg(target_os = "freebsd")]
-    #[cfg(target_os = "dragonfly")]
+    #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
     fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> {
         setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPIDLE,
                    seconds as libc::c_int)
     }
-    #[cfg(not(target_os = "macos"), not(target_os = "ios"), not(target_os = "freebsd"),
-      not(target_os = "dragonfly"))]
+    #[cfg(not(any(target_os = "macos",
+                  target_os = "ios",
+                  target_os = "freebsd",
+                  target_os = "dragonfly")))]
     fn set_tcp_keepalive(&mut self, _seconds: uint) -> IoResult<()> {
         Ok(())
     }
index cb392e1675feb2dc2ab6f2630a93fd773380c576..3a6ae42f9468dfe6da214182b4873c07308f091b 100644 (file)
@@ -840,18 +840,17 @@ fn free_handle(_handle: *mut ()) {
 #[cfg(unix)]
 fn translate_status(status: c_int) -> rtio::ProcessExit {
     #![allow(non_snake_case)]
-    #[cfg(target_os = "linux")]
-    #[cfg(target_os = "android")]
+    #[cfg(any(target_os = "linux", target_os = "android"))]
     mod imp {
         pub fn WIFEXITED(status: i32) -> bool { (status & 0xff) == 0 }
         pub fn WEXITSTATUS(status: i32) -> i32 { (status >> 8) & 0xff }
         pub fn WTERMSIG(status: i32) -> i32 { status & 0x7f }
     }
 
-    #[cfg(target_os = "macos")]
-    #[cfg(target_os = "ios")]
-    #[cfg(target_os = "freebsd")]
-    #[cfg(target_os = "dragonfly")]
+    #[cfg(any(target_os = "macos",
+              target_os = "ios",
+              target_os = "freebsd",
+              target_os = "dragonfly"))]
     mod imp {
         pub fn WIFEXITED(status: i32) -> bool { (status & 0x7f) == 0 }
         pub fn WEXITSTATUS(status: i32) -> i32 { status >> 8 }
index 7263036e1659eb8024cf922443b9b237dd724d89..1c3904a89433e0e9c2bb2de4ccd6455579738e37 100644 (file)
@@ -67,7 +67,7 @@ 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,
+            0...2 => false,
             _ => true,
         };
         let handle = unsafe { get_osfhandle(fd) as HANDLE };
index 06f89d38ca0a183da8e7b9a8795a53ade841ec39..267ff3d2a81742542cd3ee61c5538d6635042b35 100644 (file)
 pub mod io;
 pub mod task;
 
-#[cfg(windows)]
-#[cfg(android)]
+#[cfg(any(windows, android))]
 static OS_DEFAULT_STACK_ESTIMATE: uint = 1 << 20;
-#[cfg(unix, not(android))]
+#[cfg(all(unix, not(android)))]
 static OS_DEFAULT_STACK_ESTIMATE: uint = 2 * (1 << 20);
 
 #[lang = "start"]
index 7b6e94eaa92092ab5af560e8040bce1f56ea2778..8ae7f070ddb25e6e10a27b8c7269f3675840adcc 100644 (file)
@@ -98,9 +98,9 @@ pub fn new(shape: f64, scale: f64) -> Gamma {
         assert!(scale > 0.0, "Gamma::new called with scale <= 0");
 
         let repr = match shape {
-            1.0        => One(Exp::new(1.0 / scale)),
-            0.0 .. 1.0 => Small(GammaSmallShape::new_raw(shape, scale)),
-            _          => Large(GammaLargeShape::new_raw(shape, scale))
+            1.0         => One(Exp::new(1.0 / scale)),
+            0.0 ... 1.0 => Small(GammaSmallShape::new_raw(shape, scale)),
+            _           => Large(GammaLargeShape::new_raw(shape, scale))
         };
         Gamma { repr: repr }
     }
index 6db07923c4d574019eca79a5db61e56a694b7d00..085975580b7579865164037b03294c385419114f 100644 (file)
@@ -512,7 +512,7 @@ pub fn is_word(c: Option<char>) -> bool {
     };
     // Try the common ASCII case before invoking binary search.
     match c {
-        '_' | '0' .. '9' | 'a' .. 'z' | 'A' .. 'Z' => true,
+        '_' | '0' ... '9' | 'a' ... 'z' | 'A' ... 'Z' => true,
         _ => PERLW.binary_search(|&(start, end)| {
             if c >= start && c <= end {
                 Equal
index b793096b30a4f3ec5f41018ef59c242d6bc31f15..0708fdc6eba1e932abaaeaa05f89699ff77f50de 100644 (file)
@@ -277,9 +277,9 @@ pub fn sanitize(s: &str) -> String {
             '-' | ':' => result.push_char('.'),
 
             // These are legal symbols
-            'a' .. 'z'
-            | 'A' .. 'Z'
-            | '0' .. '9'
+            'a' ... 'z'
+            | 'A' ... 'Z'
+            | '0' ... '9'
             | '_' | '.' | '$' => result.push_char(c),
 
             _ => {
index 36ba28dfc2a806456c6aaea1a83f0f07dcf15557..0e85d7cc0752d8e33b8eb4c6991581ef84d21c7e 100644 (file)
     E0157,
     E0158,
     E0159,
-    E0161
+    E0161,
+    E0162
 )
index b812073c3a82affb904beb9a843b168475fbafdc..277ecfc686b4d4e0e78371db95342417243cf478 100644 (file)
@@ -593,6 +593,7 @@ fn check_attribute(&mut self, cx: &Context, attr: &ast::Attribute) {
             "static_assert",
             "thread_local",
             "no_debug",
+            "unsafe_no_drop_flag",
 
             // used in resolve
             "prelude_import",
@@ -1091,7 +1092,10 @@ fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
         let (value, msg, struct_lit_needs_parens) = match e.node {
             ast::ExprIf(ref cond, _, _) => (cond, "`if` condition", true),
             ast::ExprWhile(ref cond, _, _) => (cond, "`while` condition", true),
-            ast::ExprMatch(ref head, _) => (head, "`match` head expression", true),
+            ast::ExprMatch(ref head, _, source) => match source {
+                ast::MatchNormal => (head, "`match` head expression", true),
+                ast::MatchIfLetDesugar => (head, "`if let` head expression", true)
+            },
             ast::ExprRet(Some(ref value)) => (value, "`return` value", false),
             ast::ExprAssign(_, ref value) => (value, "assigned value", false),
             ast::ExprAssignOp(_, _, ref value) => (value, "assigned value", false),
@@ -1241,7 +1245,7 @@ fn get_lints(&self) -> LintArray {
 
     fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
         match e.node {
-            ast::ExprMatch(_, ref arms) => {
+            ast::ExprMatch(_, ref arms, _) => {
                 for a in arms.iter() {
                     self.check_unused_mut_pat(cx, a.pats.as_slice())
                 }
index 3ec91bf9840527668c442f0eb67ca881dcfabac4..2a8aa791c61a66a52d01e9faac7cd53ef268d4dd 100644 (file)
@@ -214,6 +214,8 @@ pub fn from_uint(value : uint) -> Option<astencode_tag> {
 
 pub static tag_items_data_item_stability: uint = 0x92;
 
+pub static tag_items_data_item_repr: uint = 0x93;
+
 #[deriving(Clone, Show)]
 pub struct LinkMeta {
     pub crate_name: String,
index c8ed926d6fe483dcaa50a92a0a2e835937821e4c..f0ec5beec460721a247e3aa5049e160f22fb1dd2 100644 (file)
@@ -350,6 +350,12 @@ pub fn get_stability(cstore: &cstore::CStore,
     decoder::get_stability(&*cdata, def.node)
 }
 
+pub fn get_repr_attrs(cstore: &cstore::CStore, def: ast::DefId)
+                      -> Vec<attr::ReprAttr> {
+    let cdata = cstore.get_crate_data(def.krate);
+    decoder::get_repr_attrs(&*cdata, def.node)
+}
+
 pub fn is_associated_type(cstore: &cstore::CStore, def: ast::DefId) -> bool {
     let cdata = cstore.get_crate_data(def.krate);
     decoder::is_associated_type(&*cdata, def.node)
index ac7f83cb385c2d6f8c12ee230d477e815c844136..6d4407f96a7a444bc4c7fd6867e864b3bf59c9c1 100644 (file)
@@ -112,6 +112,7 @@ enum Family {
     MutStatic,             // b
     Fn,                    // f
     UnsafeFn,              // u
+    CtorFn,                // o
     StaticMethod,          // F
     UnsafeStaticMethod,    // U
     Type,                  // y
@@ -135,6 +136,7 @@ fn item_family(item: rbml::Doc) -> Family {
       'b' => MutStatic,
       'f' => Fn,
       'u' => UnsafeFn,
+      'o' => CtorFn,
       'F' => StaticMethod,
       'U' => UnsafeStaticMethod,
       'y' => Type,
@@ -304,8 +306,9 @@ fn item_to_def_like(item: rbml::Doc, did: ast::DefId, cnum: ast::CrateNum)
         ImmStatic => DlDef(def::DefStatic(did, false)),
         MutStatic => DlDef(def::DefStatic(did, true)),
         Struct    => DlDef(def::DefStruct(did)),
-        UnsafeFn  => DlDef(def::DefFn(did, ast::UnsafeFn)),
-        Fn        => DlDef(def::DefFn(did, ast::NormalFn)),
+        UnsafeFn  => DlDef(def::DefFn(did, ast::UnsafeFn, false)),
+        Fn        => DlDef(def::DefFn(did, ast::NormalFn, false)),
+        CtorFn    => DlDef(def::DefFn(did, ast::NormalFn, true)),
         StaticMethod | UnsafeStaticMethod => {
             let fn_style = if fam == UnsafeStaticMethod {
                 ast::UnsafeFn
@@ -384,6 +387,17 @@ pub fn get_stability(cdata: Cmd, id: ast::NodeId) -> Option<attr::Stability> {
     })
 }
 
+pub fn get_repr_attrs(cdata: Cmd, id: ast::NodeId) -> Vec<attr::ReprAttr> {
+    let item = lookup_item(id, cdata.data());
+    match reader::maybe_get_doc(item, tag_items_data_item_repr).map(|doc| {
+        let mut decoder = reader::Decoder::new(doc);
+        Decodable::decode(&mut decoder).unwrap()
+    }) {
+        Some(attrs) => attrs,
+        None => Vec::new(),
+    }
+}
+
 pub fn get_impl_trait(cdata: Cmd,
                       id: ast::NodeId,
                       tcx: &ty::ctxt) -> Option<Rc<ty::TraitRef>>
index 111d372004bd5ecbf8d85cdcea4639ae3dff3be8..de0c36f2af33a41594b4b82fc1a8354827dd0dfb 100644 (file)
@@ -332,6 +332,7 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
         encode_parent_item(rbml_w, local_def(id));
         encode_visibility(rbml_w, variant.node.vis);
         encode_attributes(rbml_w, variant.node.attrs.as_slice());
+        encode_repr_attrs(rbml_w, ecx, variant.node.attrs.as_slice());
 
         let stab = stability::lookup(ecx.tcx, ast_util::local_def(variant.node.id));
         encode_stability(rbml_w, stab);
@@ -760,7 +761,7 @@ fn encode_info_for_struct_ctor(ecx: &EncodeContext,
 
     rbml_w.start_tag(tag_items_data_item);
     encode_def_id(rbml_w, local_def(ctor_id));
-    encode_family(rbml_w, 'f');
+    encode_family(rbml_w, 'o');
     encode_bounds_and_type(rbml_w, ecx,
                            &lookup_item_type(ecx.tcx, local_def(ctor_id)));
     encode_name(rbml_w, name.name);
@@ -948,6 +949,19 @@ fn encode_method_argument_names(rbml_w: &mut Encoder,
     rbml_w.end_tag();
 }
 
+fn encode_repr_attrs(rbml_w: &mut Encoder,
+                     ecx: &EncodeContext,
+                     attrs: &[Attribute]) {
+    let mut repr_attrs = Vec::new();
+    for attr in attrs.iter() {
+        repr_attrs.extend(attr::find_repr_attrs(ecx.tcx.sess.diagnostic(),
+                                                attr).into_iter());
+    }
+    rbml_w.start_tag(tag_items_data_item_repr);
+    repr_attrs.encode(rbml_w);
+    rbml_w.end_tag();
+}
+
 fn encode_inlined_item(ecx: &EncodeContext,
                        rbml_w: &mut Encoder,
                        ii: InlinedItemRef) {
@@ -1137,6 +1151,7 @@ fn add_to_index(item: &Item, rbml_w: &Encoder,
         encode_bounds_and_type(rbml_w, ecx, &lookup_item_type(tcx, def_id));
         encode_name(rbml_w, item.ident.name);
         encode_attributes(rbml_w, item.attrs.as_slice());
+        encode_repr_attrs(rbml_w, ecx, item.attrs.as_slice());
         for v in (*enum_definition).variants.iter() {
             encode_variant_id(rbml_w, local_def(v.node.id));
         }
@@ -1183,6 +1198,7 @@ fn add_to_index(item: &Item, rbml_w: &Encoder,
         encode_path(rbml_w, path.clone());
         encode_stability(rbml_w, stab);
         encode_visibility(rbml_w, vis);
+        encode_repr_attrs(rbml_w, ecx, item.attrs.as_slice());
 
         /* Encode def_ids for each field and method
          for methods, write all the stuff get_trait_method
index f40d6d47281c16bcdb6d37a036572603ba67baff..2bd145706aaad09c917eb0e3a46e092016196bbb 100644 (file)
@@ -440,7 +440,7 @@ fn decode_def(dcx: &DecodeContext, doc: rbml::Doc) -> def::Def {
 impl tr for def::Def {
     fn tr(&self, dcx: &DecodeContext) -> def::Def {
         match *self {
-          def::DefFn(did, p) => def::DefFn(did.tr(dcx), p),
+          def::DefFn(did, p, is_ctor) => def::DefFn(did.tr(dcx), p, is_ctor),
           def::DefStaticMethod(did, wrapped_did2, p) => {
             def::DefStaticMethod(did.tr(dcx),
                                    match wrapped_did2 {
index b268c2a7a518b7ae08f975a3542453c82c74f7c5..a9a3981ab5fc8687c5006e267a53eedc062e1e40 100644 (file)
@@ -222,6 +222,10 @@ fn expr(&mut self, expr: &ast::Expr, pred: CFGIndex) -> CFGIndex {
                 self.add_node(expr.id, [then_exit, else_exit])           // 4, 5
             }
 
+            ast::ExprIfLet(..) => {
+                self.tcx.sess.span_bug(expr.span, "non-desugared ExprIfLet");
+            }
+
             ast::ExprWhile(ref cond, ref body, _) => {
                 //
                 //         [pred]
@@ -322,7 +326,7 @@ fn expr(&mut self, expr: &ast::Expr, pred: CFGIndex) -> CFGIndex {
                 expr_exit
             }
 
-            ast::ExprMatch(ref discr, ref arms) => {
+            ast::ExprMatch(ref discr, ref arms, _) => {
                 //
                 //     [pred]
                 //       |
index 9b699a240cbafe91486ac67c14e3d3f9be454e9a..cc3679ec31deb3059924acfb8b7faca264759739 100644 (file)
@@ -133,7 +133,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr) {
             }
             match v.tcx.def_map.borrow().find(&e.id) {
               Some(&DefStatic(..)) |
-              Some(&DefFn(_, _)) |
+              Some(&DefFn(..)) |
               Some(&DefVariant(_, _, _)) |
               Some(&DefStruct(_)) => { }
 
index d3321e555a40ae264b7bd03357f266911b0c1db2..de9125ec44918419319650d7fac240e9a0c44f74 100644 (file)
@@ -147,7 +147,7 @@ pub fn check_crate(tcx: &ty::ctxt) {
 fn check_expr(cx: &mut MatchCheckCtxt, ex: &Expr) {
     visit::walk_expr(cx, ex);
     match ex.node {
-        ExprMatch(ref scrut, ref arms) => {
+        ExprMatch(ref scrut, ref arms, source) => {
             // First, check legality of move bindings.
             for arm in arms.iter() {
                 check_legality_of_move_bindings(cx,
@@ -184,7 +184,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &Expr) {
             }
 
             // Fourth, check for unreachable arms.
-            check_arms(cx, inlined_arms.as_slice());
+            check_arms(cx, inlined_arms.as_slice(), source);
 
             // Finally, check if the whole match expression is exhaustive.
             // Check for empty enum, because is_useful only works on inhabited types.
@@ -252,13 +252,31 @@ fn check_for_static_nan(cx: &MatchCheckCtxt, pats: &[P<Pat>]) {
 }
 
 // Check for unreachable patterns
-fn check_arms(cx: &MatchCheckCtxt, arms: &[(Vec<P<Pat>>, Option<&Expr>)]) {
+fn check_arms(cx: &MatchCheckCtxt, arms: &[(Vec<P<Pat>>, Option<&Expr>)], source: MatchSource) {
     let mut seen = Matrix(vec![]);
+    let mut printed_if_let_err = false;
     for &(ref pats, guard) in arms.iter() {
         for pat in pats.iter() {
             let v = vec![&**pat];
+
             match is_useful(cx, &seen, v.as_slice(), LeaveOutWitness) {
-                NotUseful => span_err!(cx.tcx.sess, pat.span, E0001, "unreachable pattern"),
+                NotUseful => {
+                    if source == MatchIfLetDesugar {
+                        if printed_if_let_err {
+                            // we already printed an irrefutable if-let pattern error.
+                            // We don't want two, that's just confusing.
+                        } else {
+                            // find the first arm pattern so we can use its span
+                            let &(ref first_arm_pats, _) = &arms[0];
+                            let first_pat = first_arm_pats.get(0);
+                            let span = first_pat.span;
+                            span_err!(cx.tcx.sess, span, E0162, "irrefutable if-let pattern");
+                            printed_if_let_err = true;
+                        }
+                    } else {
+                        span_err!(cx.tcx.sess, pat.span, E0001, "unreachable pattern");
+                    }
+                }
                 Useful => (),
                 UsefulWithWitness(_) => unreachable!()
             }
index 1863a19b56d02ad462992580a00b7b1c49a423b4..bd42586435f26aca56db1cb94a7a58ab81346cb8 100644 (file)
@@ -14,7 +14,7 @@
 
 #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum Def {
-    DefFn(ast::DefId, ast::FnStyle),
+    DefFn(ast::DefId, ast::FnStyle, bool /* is_ctor */),
     DefStaticMethod(/* method */ ast::DefId, MethodProvenance, ast::FnStyle),
     DefSelfTy(/* trait id */ ast::NodeId),
     DefMod(ast::DefId),
@@ -57,7 +57,7 @@ pub enum MethodProvenance {
 impl Def {
     pub fn def_id(&self) -> ast::DefId {
         match *self {
-            DefFn(id, _) | DefStaticMethod(id, _, _) | DefMod(id) |
+            DefFn(id, _, _) | DefStaticMethod(id, _, _) | DefMod(id) |
             DefForeignMod(id) | DefStatic(id, _) |
             DefVariant(_, id, _) | DefTy(id, _) | DefAssociatedTy(id) |
             DefTyParam(_, id, _) | DefUse(id) | DefStruct(id) | DefTrait(id) |
index 81994ee64a8cf956f19400754533c49c059f5423..51cdbfcf2514c17298ed9e49356780d805d82989 100644 (file)
@@ -374,7 +374,11 @@ pub fn walk_expr(&mut self, expr: &ast::Expr) {
                 }
             }
 
-            ast::ExprMatch(ref discr, ref arms) => {
+            ast::ExprIfLet(..) => {
+                self.tcx().sess.span_bug(expr.span, "non-desugared ExprIfLet");
+            }
+
+            ast::ExprMatch(ref discr, ref arms, _) => {
                 let discr_cmt = return_if_err!(self.mc.cat_expr(&**discr));
                 self.borrow_expr(&**discr, ty::ReEmpty, ty::ImmBorrow, MatchDiscriminant);
 
index 9d0d21d6d2af6e40f23d804832834b62908ffa03..dccb93f58cc8de148043f936af6a933804c20310 100644 (file)
@@ -121,7 +121,7 @@ fn visit_expr(&mut self, expr: &ast::Expr) {
         match expr.node {
             ast::ExprPath(..) => {
                 match ty::resolve_expr(self.tcx, expr) {
-                    DefFn(did, _) if self.def_id_is_transmute(did) => {
+                    DefFn(did, _, _) if self.def_id_is_transmute(did) => {
                         let typ = ty::node_id_to_type(self.tcx, expr.id);
                         match ty::get(typ).sty {
                             ty_bare_fn(ref bare_fn_ty)
index b6893a6a3b41925100f5f110eba322e79c146e41..2176cd565894375db7a36c1b7f1c2ab4d2d6ca58 100644 (file)
@@ -481,6 +481,9 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
         ir.add_live_node_for_node(expr.id, ExprNode(expr.span));
         visit::walk_expr(ir, expr);
       }
+      ExprIfLet(..) => {
+          ir.tcx.sess.span_bug(expr.span, "non-desugared ExprIfLet");
+      }
       ExprForLoop(ref pat, _, _, _) => {
         pat_util::pat_bindings(&ir.tcx.def_map, &**pat, |bm, p_id, sp, path1| {
             debug!("adding local variable {} from for loop with bm {:?}",
@@ -1011,6 +1014,10 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
             self.propagate_through_expr(&**cond, ln)
           }
 
+          ExprIfLet(..) => {
+              self.ir.tcx.sess.span_bug(expr.span, "non-desugared ExprIfLet");
+          }
+
           ExprWhile(ref cond, ref blk, _) => {
             self.propagate_through_loop(expr, WhileLoop(&**cond), &**blk, succ)
           }
@@ -1026,7 +1033,7 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
             self.propagate_through_loop(expr, LoopLoop, &**blk, succ)
           }
 
-          ExprMatch(ref e, ref arms) => {
+          ExprMatch(ref e, ref arms, _) => {
             //
             //      (e)
             //       |
@@ -1470,6 +1477,9 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
       ExprPath(..) | ExprBox(..) => {
         visit::walk_expr(this, expr);
       }
+      ExprIfLet(..) => {
+        this.ir.tcx.sess.span_bug(expr.span, "non-desugared ExprIfLet");
+      }
     }
 }
 
index 3b831dd6847a1b07414a10ce06654a5df736cfce..bb44b1f55cb450344ae4efa635a7a0c0549e4c22 100644 (file)
@@ -405,6 +405,8 @@ pub fn cat_expr(&self, expr: &ast::Expr) -> McResult<cmt> {
             Some(adjustment) => {
                 match *adjustment {
                     ty::AdjustAddEnv(..) => {
+                        debug!("cat_expr(AdjustAddEnv): {}",
+                               expr.repr(self.tcx()));
                         // Convert a bare fn to a closure by adding NULL env.
                         // Result is an rvalue.
                         let expr_ty = if_ok!(self.expr_ty_adjusted(expr));
@@ -414,6 +416,8 @@ pub fn cat_expr(&self, expr: &ast::Expr) -> McResult<cmt> {
                     ty::AdjustDerefRef(
                         ty::AutoDerefRef {
                             autoref: Some(_), ..}) => {
+                        debug!("cat_expr(AdjustDerefRef): {}",
+                               expr.repr(self.tcx()));
                         // Equivalent to &*expr or something similar.
                         // Result is an rvalue.
                         let expr_ty = if_ok!(self.expr_ty_adjusted(expr));
@@ -436,6 +440,9 @@ pub fn cat_expr_autoderefd(&self,
                                autoderefs: uint)
                                -> McResult<cmt> {
         let mut cmt = if_ok!(self.cat_expr_unadjusted(expr));
+        debug!("cat_expr_autoderefd: autoderefs={}, cmt={}",
+               autoderefs,
+               cmt.repr(self.tcx()));
         for deref in range(1u, autoderefs + 1) {
             cmt = self.cat_deref(expr, cmt, deref, false);
         }
@@ -454,6 +461,10 @@ pub fn cat_expr_unadjusted(&self, expr: &ast::Expr) -> McResult<cmt> {
 
           ast::ExprField(ref base, f_name, _) => {
             let base_cmt = if_ok!(self.cat_expr(&**base));
+            debug!("cat_expr(cat_field): id={} expr={} base={}",
+                   expr.id,
+                   expr.repr(self.tcx()),
+                   base_cmt.repr(self.tcx()));
             Ok(self.cat_field(expr, base_cmt, f_name.node, expr_ty))
           }
 
@@ -505,6 +516,10 @@ pub fn cat_expr_unadjusted(&self, expr: &ast::Expr) -> McResult<cmt> {
           ast::ExprForLoop(..) => {
             Ok(self.cat_rvalue_node(expr.id(), expr.span(), expr_ty))
           }
+
+          ast::ExprIfLet(..) => {
+            self.tcx().sess.span_bug(expr.span, "non-desugared ExprIfLet");
+          }
         }
     }
 
index e97010cc0c7ccbd196d5e80c2144d8c134630701..22ac390602dfee9e20e4ee008860d67f12f7e0e1 100644 (file)
@@ -933,7 +933,7 @@ struct type?!"),
                     }
                     // Tuple struct constructors across crates are identified as
                     // DefFn types, so we explicitly handle that case here.
-                    Some(&def::DefFn(did, _)) if !is_local(did) => {
+                    Some(&def::DefFn(did, _, _)) if !is_local(did) => {
                         match csearch::get_tuple_struct_definition_if_ctor(
                                     &self.tcx.sess.cstore, did) {
                             Some(did) => guard(did),
index 1f19cf1aef5bf0c0cebbfdb27a38de35e2ef8976..42a98be0fb84e1a93db2f5d78c88128b3bd42133 100644 (file)
@@ -1247,7 +1247,7 @@ fn build_reduced_graph_for_item(&mut self,
                 let name_bindings =
                     self.add_child(ident, parent.clone(), ForbidDuplicateValues, sp);
 
-                let def = DefFn(local_def(item.id), fn_style);
+                let def = DefFn(local_def(item.id), fn_style, false);
                 name_bindings.define_value(def, sp, is_public);
                 parent
             }
@@ -1703,7 +1703,7 @@ fn build_reduced_graph_for_foreign_item(&mut self,
 
         match foreign_item.node {
             ForeignItemFn(_, ref generics) => {
-                let def = DefFn(local_def(foreign_item.id), UnsafeFn);
+                let def = DefFn(local_def(foreign_item.id), UnsafeFn, false);
                 name_bindings.define_value(def, foreign_item.span, is_public);
 
                 self.with_type_parameter_rib(
@@ -2017,7 +2017,8 @@ fn build_reduced_graph_for_external_crate_def(&mut self,
                                                        DUMMY_SP);
                                     let def = DefFn(
                                         static_method_info.def_id,
-                                        static_method_info.fn_style);
+                                        static_method_info.fn_style,
+                                        false);
 
                                     method_name_bindings.define_value(
                                         def, DUMMY_SP,
@@ -2586,7 +2587,8 @@ fn get_binding(this: &mut Resolver,
 
         match value_result {
             BoundResult(ref target_module, ref name_bindings) => {
-                debug!("(resolving single import) found value target");
+                debug!("(resolving single import) found value target: {:?}",
+                       { name_bindings.value_def.borrow().clone().unwrap().def });
                 self.check_for_conflicting_import(
                     &import_resolution.value_target,
                     directive.span,
index 0f4ed202ec20750c9b80030fd92db4b841d4d188..c956c2d2b006b9bd6a26a0ec72e8a9dcd454ebec 100644 (file)
@@ -234,7 +234,7 @@ fn lookup_def_kind(&self, ref_id: NodeId, span: Span) -> Option<recorder::Row> {
             def::DefVariant(_, _, _) |
             def::DefUpvar(..) => Some(recorder::VarRef),
 
-            def::DefFn(_, _) => Some(recorder::FnRef),
+            def::DefFn(..) => Some(recorder::FnRef),
 
             def::DefSelfTy(_) |
             def::DefRegion(_) |
@@ -792,10 +792,10 @@ fn process_path(&mut self,
                                        Some(declid),
                                        self.cur_scope);
             },
-            def::DefFn(def_id, _) => self.fmt.fn_call_str(ex.span,
-                                                          sub_span,
-                                                          def_id,
-                                                          self.cur_scope),
+            def::DefFn(def_id, _, _) => self.fmt.fn_call_str(ex.span,
+                                                             sub_span,
+                                                             def_id,
+                                                             self.cur_scope),
             _ => self.sess.span_bug(ex.span,
                                     format!("Unexpected def kind while looking up path in '{}'",
                                             self.span.snippet(ex.span)).as_slice()),
@@ -808,7 +808,7 @@ fn process_path(&mut self,
             def::DefLocal(_) |
             def::DefStatic(_,_) |
             def::DefStruct(_) |
-            def::DefFn(_, _) => self.write_sub_paths_truncated(path),
+            def::DefFn(..) => self.write_sub_paths_truncated(path),
             _ => {},
         }
 
index 9d66108cfc99051f2073cba36fb46a36f41afa75..88685101b31325440365d10e8d825c97e1f67d94 100644 (file)
@@ -86,6 +86,10 @@ pub enum ObligationCauseCode {
     FieldSized,
 }
 
+// An error has already been reported to the user, so no need to continue checking.
+#[deriving(Clone,Show)]
+pub struct ErrorReported;
+
 pub type Obligations = subst::VecPerParamSpace<Obligation>;
 
 pub type Selection = Vtable<Obligation>;
@@ -332,7 +336,7 @@ pub fn obligation_for_builtin_bound(tcx: &ty::ctxt,
                                     cause: ObligationCause,
                                     source_ty: ty::t,
                                     builtin_bound: ty::BuiltinBound)
-                                    -> Obligation
+                                    -> Result<Obligation, ErrorReported>
 {
     util::obligation_for_builtin_bound(tcx, cause, builtin_bound, 0, source_ty)
 }
index 63fbeb797c4d46e37ea80f8228b1551083d6ab8e..61477fdeed5f7ba00f91bee0608d6b4af99831a3 100644 (file)
@@ -228,6 +228,11 @@ fn evaluate_builtin_bound_recursively(&mut self,
                 bound,
                 previous_stack.obligation.recursion_depth + 1,
                 ty);
+        let obligation = match obligation {
+            Ok(ob) => ob,
+            _ => return EvaluatedToMatch
+        };
+
         self.evaluate_obligation_recursively(previous_stack, &obligation)
     }
 
index cad86003ce9dd920356263640e16172f875a0ba4..ab5bbf4363f31915a5a5da794b1d37cc072e70e7 100644 (file)
@@ -20,7 +20,8 @@
 use syntax::codemap::Span;
 use util::ppaux::Repr;
 
-use super::{Obligation, ObligationCause, VtableImpl, VtableParam, VtableParamData, VtableImplData};
+use super::{ErrorReported, Obligation, ObligationCause, VtableImpl,
+            VtableParam, VtableParamData, VtableImplData};
 
 ///////////////////////////////////////////////////////////////////////////
 // Supertrait iterator
@@ -82,7 +83,7 @@ fn push(&mut self, trait_ref: &ty::TraitRef) {
             let bound_trait_ref = trait_ref_for_builtin_bound(self.tcx,
                                                               builtin_bound,
                                                               trait_ref.self_ty());
-            trait_bounds.push(bound_trait_ref);
+            bound_trait_ref.map(|trait_ref| trait_bounds.push(trait_ref));
         }
 
         // Only keep those bounds that we haven't already seen.  This
@@ -213,13 +214,15 @@ fn push_obligations_for_param_bounds(
     let param_ty = *param_substs.types.get(space, index);
 
     for builtin_bound in param_bounds.builtin_bounds.iter() {
-        obligations.push(
-            space,
-            obligation_for_builtin_bound(tcx,
-                                         cause,
-                                         builtin_bound,
-                                         recursion_depth,
-                                         param_ty));
+        let obligation = obligation_for_builtin_bound(tcx,
+                                                      cause,
+                                                      builtin_bound,
+                                                      recursion_depth,
+                                                      param_ty);
+        match obligation {
+            Ok(ob) => obligations.push(space, ob),
+            _ => {}
+        }
     }
 
     for bound_trait_ref in param_bounds.trait_bounds.iter() {
@@ -236,17 +239,18 @@ pub fn trait_ref_for_builtin_bound(
     tcx: &ty::ctxt,
     builtin_bound: ty::BuiltinBound,
     param_ty: ty::t)
-    -> Rc<ty::TraitRef>
+    -> Option<Rc<ty::TraitRef>>
 {
     match tcx.lang_items.from_builtin_kind(builtin_bound) {
         Ok(def_id) => {
-            Rc::new(ty::TraitRef {
+            Some(Rc::new(ty::TraitRef {
                 def_id: def_id,
                 substs: Substs::empty().with_self_ty(param_ty)
-            })
+            }))
         }
         Err(e) => {
-            tcx.sess.bug(e.as_slice());
+            tcx.sess.err(e.as_slice());
+            None
         }
     }
 }
@@ -257,13 +261,16 @@ pub fn obligation_for_builtin_bound(
     builtin_bound: ty::BuiltinBound,
     recursion_depth: uint,
     param_ty: ty::t)
-    -> Obligation
+    -> Result<Obligation, ErrorReported>
 {
     let trait_ref = trait_ref_for_builtin_bound(tcx, builtin_bound, param_ty);
-    Obligation {
-        cause: cause,
-        recursion_depth: recursion_depth,
-        trait_ref: trait_ref
+    match trait_ref {
+        Some(trait_ref) => Ok(Obligation {
+                cause: cause,
+                recursion_depth: recursion_depth,
+                trait_ref: trait_ref
+            }),
+        None => Err(ErrorReported)
     }
 }
 
index c51e242026241c72ee355dc4c7781e29368d8114..d898931cb330b64307761b0b943a4e7179dbde2c 100644 (file)
@@ -162,15 +162,14 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm)
 // Default per-arch clobbers
 // Basically what clang does
 
-#[cfg(target_arch = "arm")]
-#[cfg(target_arch = "mips")]
-#[cfg(target_arch = "mipsel")]
+#[cfg(any(target_arch = "arm",
+          target_arch = "mips",
+          target_arch = "mipsel"))]
 fn get_clobbers() -> String {
     "".to_string()
 }
 
-#[cfg(target_arch = "x86")]
-#[cfg(target_arch = "x86_64")]
+#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
 fn get_clobbers() -> String {
     "~{dirflag},~{fpsr},~{flags}".to_string()
 }
index 5962bee023abcd7ca6c9e6477e04167db9926d75..7942a0211e4e694ffcd128dcac694c15d79fb5b6 100644 (file)
@@ -142,7 +142,7 @@ fn trans_def<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, def: def::Def, ref_expr: &ast::
         debug!("trans_def(def={}, ref_expr={})", def.repr(bcx.tcx()), ref_expr.repr(bcx.tcx()));
         let expr_ty = node_id_type(bcx, ref_expr.id);
         match def {
-            def::DefFn(did, _) if {
+            def::DefFn(did, _, _) if {
                 let maybe_def_id = inline::get_local_instance(bcx.ccx(), did);
                 let maybe_ast_node = maybe_def_id.and_then(|def_id| bcx.tcx().map
                                                                              .find(def_id.node));
@@ -157,7 +157,7 @@ fn trans_def<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, def: def::Def, ref_expr: &ast::
                     data: NamedTupleConstructor(substs, 0)
                 }
             }
-            def::DefFn(did, _) if match ty::get(expr_ty).sty {
+            def::DefFn(did, _, _) if match ty::get(expr_ty).sty {
                 ty::ty_bare_fn(ref f) => f.abi == synabi::RustIntrinsic,
                 _ => false
             } => {
@@ -165,7 +165,7 @@ fn trans_def<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, def: def::Def, ref_expr: &ast::
                 let def_id = inline::maybe_instantiate_inline(bcx.ccx(), did);
                 Callee { bcx: bcx, data: Intrinsic(def_id.node, substs) }
             }
-            def::DefFn(did, _) |
+            def::DefFn(did, _, _) |
             def::DefStaticMethod(did, def::FromImpl(_), _) => {
                 fn_callee(bcx, trans_fn_ref(bcx, did, ExprId(ref_expr.id)))
             }
index fa8c6b8b4482f63ad514c2930dbc87ed79a04305..f08736335c37d4a784de6ab99557e40cf3869755 100644 (file)
@@ -532,7 +532,7 @@ pub fn get_wrapper_for_bare_fn(ccx: &CrateContext,
                                is_local: bool) -> ValueRef {
 
     let def_id = match def {
-        def::DefFn(did, _) | def::DefStaticMethod(did, _, _) |
+        def::DefFn(did, _, _) | def::DefStaticMethod(did, _, _) |
         def::DefVariant(_, did, _) | def::DefStruct(did) => did,
         _ => {
             ccx.sess().bug(format!("get_wrapper_for_bare_fn: \
index d39fe4a1e700306551513c542c6be122bfa4d739..c499fcf4bf8dfd2a89009aa52aec18b21e69942d 100644 (file)
@@ -623,7 +623,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
 
             let opt_def = cx.tcx().def_map.borrow().find_copy(&e.id);
             match opt_def {
-                Some(def::DefFn(def_id, _fn_style)) => {
+                Some(def::DefFn(def_id, _fn_style, _)) => {
                     if !ast_util::is_local(def_id) {
                         let ty = csearch::get_type(cx.tcx(), def_id).ty;
                         (base::trans_external_path(cx, def_id, ty), true)
index 962f97ab74c6fc8908e7df162b0691e1a871a957..5c8c6a24b4fa53032052a86150b76ed976b27b60 100644 (file)
@@ -546,7 +546,7 @@ pub fn get_intrinsic(&self, key: & &'static str) -> ValueRef {
     // but it could be enabled (with patched LLVM)
     pub fn is_split_stack_supported(&self) -> bool {
         let ref cfg = self.sess().targ_cfg;
-        cfg.os != abi::OsiOS || cfg.arch != abi::Arm
+        (cfg.os != abi::OsiOS || cfg.arch != abi::Arm) && cfg.os != abi::OsWindows
     }
 
 
index 7a0e5aea7fffc90873080de035f44d9f64a5cc53..aada90d260e8f2f2b283d44907a78ef714b73235 100644 (file)
@@ -3576,6 +3576,11 @@ fn walk_expr(cx: &CrateContext,
                 }
             }
 
+            ast::ExprIfLet(..) => {
+                cx.sess().span_bug(exp.span, "debuginfo::populate_scope_map() - \
+                                              Found unexpanded if-let.");
+            }
+
             ast::ExprWhile(ref cond_exp, ref loop_body, _) => {
                 walk_expr(cx, &**cond_exp, scope_stack, scope_map);
 
@@ -3654,7 +3659,7 @@ fn walk_expr(cx: &CrateContext,
                 }
             }
 
-            ast::ExprMatch(ref discriminant_exp, ref arms) => {
+            ast::ExprMatch(ref discriminant_exp, ref arms, _) => {
                 walk_expr(cx, &**discriminant_exp, scope_stack, scope_map);
 
                 // For each arm we have to first walk the pattern as these might
index 120e8404f2c67502671aa2be8fdd383d4c5e698b..37a39ef8e3bef37b245ff3c3c46d34cbabce11d0 100644 (file)
@@ -1013,7 +1013,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
         ast::ExprIf(ref cond, ref thn, ref els) => {
             controlflow::trans_if(bcx, expr.id, &**cond, &**thn, els.as_ref().map(|e| &**e), dest)
         }
-        ast::ExprMatch(ref discr, ref arms) => {
+        ast::ExprMatch(ref discr, ref arms, _) => {
             _match::trans_match(bcx, expr, &**discr, arms.as_slice(), dest)
         }
         ast::ExprBlock(ref blk) => {
@@ -1194,7 +1194,7 @@ fn trans_def_fn_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     let _icx = push_ctxt("trans_def_datum_unadjusted");
 
     let llfn = match def {
-        def::DefFn(did, _) |
+        def::DefFn(did, _, _) |
         def::DefStruct(did) | def::DefVariant(_, did, _) |
         def::DefStaticMethod(did, def::FromImpl(_), _) => {
             callee::trans_fn_ref(bcx, did, ExprId(ref_expr.id))
index 875a79373a69dc3c200948d794dbb23dffd91a14..b38f362dcf18d815f764c7265415fb31893d2c84 100644 (file)
@@ -583,6 +583,9 @@ pub struct ctxt<'tcx> {
     /// Caches the results of trait selection. This cache is used
     /// for things that do not have to do with the parameters in scope.
     pub selection_cache: traits::SelectionCache,
+
+    /// Caches the representation hints for struct definitions.
+    pub repr_hint_cache: RefCell<DefIdMap<Rc<Vec<attr::ReprAttr>>>>,
 }
 
 pub enum tbox_flag {
@@ -1533,6 +1536,7 @@ pub fn mk_ctxt<'tcx>(s: Session,
         associated_types: RefCell::new(DefIdMap::new()),
         trait_associated_types: RefCell::new(DefIdMap::new()),
         selection_cache: traits::SelectionCache::new(),
+        repr_hint_cache: RefCell::new(DefIdMap::new()),
    }
 }
 
@@ -3588,6 +3592,12 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
                     }
                 }
 
+                // Special case: A unit like struct's constructor must be called without () at the
+                // end (like `UnitStruct`) which means this is an ExprPath to a DefFn. But in case
+                // of unit structs this is should not be interpretet as function pointer but as
+                // call to the constructor.
+                def::DefFn(_, _, true) => RvalueDpsExpr,
+
                 // Fn pointers are just scalar values.
                 def::DefFn(..) | def::DefStaticMethod(..) => RvalueDatumExpr,
 
@@ -3631,6 +3641,10 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
             RvalueDpsExpr
         }
 
+        ast::ExprIfLet(..) => {
+            tcx.sess.span_bug(expr.span, "non-desugared ExprIfLet");
+        }
+
         ast::ExprLit(ref lit) if lit_is_str(&**lit) => {
             RvalueDpsExpr
         }
@@ -4326,7 +4340,7 @@ pub fn ty_dtor(cx: &ctxt, struct_id: DefId) -> DtorKind {
 }
 
 pub fn has_dtor(cx: &ctxt, struct_id: DefId) -> bool {
-    ty_dtor(cx, struct_id).is_present()
+    cx.destructor_for_type.borrow().contains_key(&struct_id)
 }
 
 pub fn with_path<T>(cx: &ctxt, id: ast::DefId, f: |ast_map::PathElems| -> T) -> T {
@@ -4513,14 +4527,26 @@ pub fn lookup_simd(tcx: &ctxt, did: DefId) -> bool {
 }
 
 /// Obtain the representation annotation for a struct definition.
-pub fn lookup_repr_hints(tcx: &ctxt, did: DefId) -> Vec<attr::ReprAttr> {
-    let mut acc = Vec::new();
+pub fn lookup_repr_hints(tcx: &ctxt, did: DefId) -> Rc<Vec<attr::ReprAttr>> {
+    match tcx.repr_hint_cache.borrow().find(&did) {
+        None => {}
+        Some(ref hints) => return (*hints).clone(),
+    }
 
-    ty::each_attr(tcx, did, |meta| {
-        acc.extend(attr::find_repr_attrs(tcx.sess.diagnostic(), meta).into_iter());
-        true
-    });
+    let acc = if did.krate == LOCAL_CRATE {
+        let mut acc = Vec::new();
+        ty::each_attr(tcx, did, |meta| {
+            acc.extend(attr::find_repr_attrs(tcx.sess.diagnostic(),
+                                             meta).into_iter());
+            true
+        });
+        acc
+    } else {
+        csearch::get_repr_attrs(&tcx.sess.cstore, did)
+    };
 
+    let acc = Rc::new(acc);
+    tcx.repr_hint_cache.borrow_mut().insert(did, acc.clone());
     acc
 }
 
index 141b03d9b9f17c2d00f36e27d42e1208f1ba380f..3d522a7c54860bc3bb0da46b7a0b351609caa27f 100644 (file)
@@ -86,10 +86,11 @@ trait `ToString` imported, and I call `to_string()` on a value of type `T`,
 use middle::ty::*;
 use middle::ty;
 use middle::typeck::astconv::AstConv;
-use middle::typeck::check::{FnCtxt, PreferMutLvalue, impl_self_ty};
+use middle::typeck::check::{FnCtxt, NoPreference, PreferMutLvalue};
+use middle::typeck::check::{impl_self_ty};
 use middle::typeck::check;
 use middle::typeck::infer;
-use middle::typeck::MethodCallee;
+use middle::typeck::{MethodCall, MethodCallee};
 use middle::typeck::{MethodOrigin, MethodParam, MethodTypeParam};
 use middle::typeck::{MethodStatic, MethodStaticUnboxedClosure, MethodObject, MethodTraitObject};
 use middle::typeck::check::regionmanip::replace_late_bound_regions_in_fn_sig;
@@ -353,11 +354,15 @@ fn search(&self, self_ty: ty::t) -> Option<MethodCallee> {
 
         let (_, _, result) =
             check::autoderef(
-                self.fcx, span, self_ty, self_expr_id, PreferMutLvalue,
+                self.fcx, span, self_ty, self_expr_id, NoPreference,
                 |self_ty, autoderefs| self.search_step(self_ty, autoderefs));
 
         match result {
-            Some(Some(result)) => Some(result),
+            Some(Some(result)) => {
+                self.fixup_derefs_on_method_receiver_if_necessary(&result,
+                                                                  self_ty);
+                Some(result)
+            }
             _ => None
         }
     }
@@ -430,7 +435,7 @@ fn push_inherent_candidates(&mut self, self_ty: ty::t) {
          */
 
         let span = self.self_expr.map_or(self.span, |e| e.span);
-        check::autoderef(self.fcx, span, self_ty, None, PreferMutLvalue, |self_ty, _| {
+        check::autoderef(self.fcx, span, self_ty, None, NoPreference, |self_ty, _| {
             match get(self_ty).sty {
                 ty_trait(box TyTrait { def_id, ref substs, bounds, .. }) => {
                     self.push_inherent_candidates_from_object(
@@ -458,7 +463,7 @@ fn push_inherent_candidates(&mut self, self_ty: ty::t) {
 
     fn push_bound_candidates(&mut self, self_ty: ty::t, restrict_to: Option<DefId>) {
         let span = self.self_expr.map_or(self.span, |e| e.span);
-        check::autoderef(self.fcx, span, self_ty, None, PreferMutLvalue, |self_ty, _| {
+        check::autoderef(self.fcx, span, self_ty, None, NoPreference, |self_ty, _| {
             match get(self_ty).sty {
                 ty_param(p) => {
                     self.push_inherent_candidates_from_param(self_ty, restrict_to, p);
@@ -1135,7 +1140,7 @@ fn search_for_some_kind_of_autorefd_method(
         };
 
         // This is hokey. We should have mutability inference as a
-        // variable.  But for now, try &const, then &, then &mut:
+        // variable.  But for now, try &, then &mut:
         let region =
             self.infcx().next_region_var(infer::Autoref(self.span));
         for mutbl in mutbls.iter() {
@@ -1381,6 +1386,77 @@ fn confirm_candidate(&self, rcvr_ty: ty::t, candidate: &Candidate)
         }
     }
 
+    fn fixup_derefs_on_method_receiver_if_necessary(
+            &self,
+            method_callee: &MethodCallee,
+            self_ty: ty::t) {
+        let sig = match ty::get(method_callee.ty).sty {
+            ty::ty_bare_fn(ref f) => f.sig.clone(),
+            ty::ty_closure(ref f) => f.sig.clone(),
+            _ => return,
+        };
+
+        match ty::get(*sig.inputs.get(0)).sty {
+            ty::ty_rptr(_, ty::mt {
+                ty: _,
+                mutbl: ast::MutMutable,
+            }) => {}
+            _ => return,
+        }
+
+        // Fix up autoderefs and derefs.
+        let mut self_expr = match self.self_expr {
+            Some(expr) => expr,
+            None => return,
+        };
+        loop {
+            // Count autoderefs.
+            let autoderef_count = match self.fcx
+                                            .inh
+                                            .adjustments
+                                            .borrow()
+                                            .find(&self_expr.id) {
+                Some(&ty::AdjustDerefRef(ty::AutoDerefRef {
+                    autoderefs: autoderef_count,
+                    autoref: _
+                })) if autoderef_count > 0 => autoderef_count,
+                Some(_) | None => return,
+            };
+
+            check::autoderef(self.fcx,
+                             self_expr.span,
+                             self.fcx.expr_ty(self_expr),
+                             Some(self_expr.id),
+                             PreferMutLvalue,
+                             |_, autoderefs| {
+                                 if autoderefs == autoderef_count + 1 {
+                                     Some(())
+                                 } else {
+                                     None
+                                 }
+                             });
+
+            match self_expr.node {
+                ast::ExprParen(ref expr) |
+                ast::ExprIndex(ref expr, _) |
+                ast::ExprField(ref expr, _, _) |
+                ast::ExprTupField(ref expr, _, _) |
+                ast::ExprSlice(ref expr, _, _, _) => self_expr = &**expr,
+                ast::ExprUnary(ast::UnDeref, ref expr) => {
+                    drop(check::try_overloaded_deref(
+                            self.fcx,
+                            self_expr.span,
+                            Some(MethodCall::expr(self_expr.id)),
+                            Some(self_expr),
+                            self_ty,
+                            PreferMutLvalue));
+                    self_expr = &**expr
+                }
+                _ => break,
+            }
+        }
+    }
+
     fn enforce_object_limitations(&self, candidate: &Candidate) {
         /*!
          * There are some limitations to calling functions through an
index d4c38d48a8c561584c9acfae9250d2e6f7cb80de..b0c0a8a571bd0d1f3bb036a8f70acdf8711bb08e 100644 (file)
@@ -1795,12 +1795,15 @@ pub fn require_type_meets(&self,
                               code: traits::ObligationCauseCode,
                               bound: ty::BuiltinBound)
     {
-        self.register_obligation(
-            traits::obligation_for_builtin_bound(
-                self.tcx(),
-                traits::ObligationCause::new(span, code),
-                ty,
-                bound));
+        let obligation = traits::obligation_for_builtin_bound(
+            self.tcx(),
+            traits::ObligationCause::new(span, code),
+            ty,
+            bound);
+        match obligation {
+            Ok(ob) => self.register_obligation(ob),
+            _ => {}
+        }
     }
 
     pub fn require_type_is_sized(&self,
@@ -2075,6 +2078,7 @@ fn add_region_obligations_for_region_parameter(&self,
     }
 }
 
+#[deriving(Show)]
 pub enum LvaluePreference {
     PreferMutLvalue,
     NoPreference
@@ -4103,6 +4107,9 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
         check_then_else(fcx, &**cond, &**then_blk, opt_else_expr.as_ref().map(|e| &**e),
                         id, expr.span, expected);
       }
+      ast::ExprIfLet(..) => {
+        tcx.sess.span_bug(expr.span, "non-desugared ExprIfLet");
+      }
       ast::ExprWhile(ref cond, ref body, _) => {
         check_expr_has_type(fcx, &**cond, ty::mk_bool());
         check_block_no_value(fcx, &**body);
@@ -4140,7 +4147,7 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
             fcx.write_nil(id);
         }
       }
-      ast::ExprMatch(ref discrim, ref arms) => {
+      ast::ExprMatch(ref discrim, ref arms, _) => {
         _match::check_match(fcx, expr, &**discrim, arms.as_slice());
       }
       ast::ExprFnBlock(_, ref decl, ref body) => {
@@ -5079,7 +5086,7 @@ pub fn polytype_for_def(fcx: &FnCtxt,
           let typ = fcx.local_ty(sp, nid);
           return no_params(typ);
       }
-      def::DefFn(id, _) | def::DefStaticMethod(id, _, _) |
+      def::DefFn(id, _, _) | def::DefStaticMethod(id, _, _) |
       def::DefStatic(id, _) | def::DefVariant(_, id, _) |
       def::DefStruct(id) => {
         return ty::lookup_item_type(fcx.ccx.tcx, id);
index d45155c2ccd125e95e5442dab0b0c2442c757919..9e20028569bf497146335c4f758e0ef3e7a77f17 100644 (file)
@@ -725,7 +725,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
             visit::walk_expr(rcx, expr);
         }
 
-        ast::ExprMatch(ref discr, ref arms) => {
+        ast::ExprMatch(ref discr, ref arms, _) => {
             link_match(rcx, &**discr, arms.as_slice());
 
             visit::walk_expr(rcx, expr);
@@ -945,7 +945,13 @@ fn ensure_free_variable_types_outlive_closure_bound(
                 let cause = traits::ObligationCause::new(freevar.span, code);
                 let obligation = traits::obligation_for_builtin_bound(rcx.tcx(), cause,
                                                                       var_ty, builtin_bound);
-                rcx.fcx.inh.fulfillment_cx.borrow_mut().register_obligation(rcx.tcx(), obligation);
+                match obligation {
+                    Ok(obligation) => {
+                        rcx.fcx.inh.fulfillment_cx.borrow_mut().register_obligation(rcx.tcx(),
+                                                                                    obligation)
+                    }
+                    _ => {}
+                }
             }
             type_must_outlive(
                 rcx, infer::RelateProcBound(expr.span, var_node_id, var_ty),
index bcbcebc3f59279afd67f52bcbaf1dbc342f4bc6b..bdcf4d73c3b840f74d2135d315413f694679b06f 100644 (file)
@@ -170,13 +170,16 @@ pub fn register_object_cast_obligations(fcx: &FnCtxt,
     // object type is Foo+Send, this would create an obligation
     // for the Send check.)
     for builtin_bound in object_trait.bounds.builtin_bounds.iter() {
-        fcx.register_obligation(
-            obligation_for_builtin_bound(
+            let obligation = obligation_for_builtin_bound(
                 fcx.tcx(),
                 ObligationCause::new(span,
                                      traits::ObjectCastObligation(object_trait_ty)),
                 referent_ty,
-                builtin_bound));
+                builtin_bound);
+            match obligation {
+                Ok(obligation) => fcx.register_obligation(obligation),
+                _ => {}
+            }
     }
 
     object_trait_ref
index 67f93feae41971affeb060707fe4b8af60f1d19a..587aa072fa8636b18ac04a87d0ea9d38ba6d6f33 100644 (file)
@@ -124,11 +124,14 @@ fn check_type_defn(&mut self,
                 if variant.fields.len() > 0 {
                     for field in variant.fields.init().iter() {
                         let cause = traits::ObligationCause::new(field.span, traits::FieldSized);
-                        fcx.register_obligation(
-                            traits::obligation_for_builtin_bound(fcx.tcx(),
-                                                                 cause,
-                                                                 field.ty,
-                                                                 ty::BoundSized));
+                        let obligation = traits::obligation_for_builtin_bound(fcx.tcx(),
+                                                                              cause,
+                                                                              field.ty,
+                                                                              ty::BoundSized);
+                        match obligation {
+                            Ok(obligation) => fcx.register_obligation(obligation),
+                            _ => {}
+                        }
                     }
                 }
             }
@@ -213,11 +216,14 @@ fn check_impl(&mut self,
                                                           &trait_def.bounds,
                                                           trait_ref.self_ty());
             for builtin_bound in trait_def.bounds.builtin_bounds.iter() {
-                fcx.register_obligation(
-                    traits::obligation_for_builtin_bound(fcx.tcx(),
-                                                         cause,
-                                                         trait_ref.self_ty(),
-                                                         builtin_bound));
+                let obligation = traits::obligation_for_builtin_bound(fcx.tcx(),
+                                                                      cause,
+                                                                      trait_ref.self_ty(),
+                                                                      builtin_bound);
+                match obligation {
+                    Ok (obligation) => fcx.register_obligation(obligation),
+                    _ => {}
+                }
             }
             for trait_bound in trait_def.bounds.trait_bounds.iter() {
                 let trait_bound = trait_bound.subst(fcx.tcx(), &trait_ref.substs);
@@ -453,12 +459,14 @@ fn check_struct_safe_for_destructor(fcx: &FnCtxt,
         && !struct_tpt.generics.has_region_params(subst::TypeSpace)
     {
         let cause = traits::ObligationCause::new(span, traits::DropTrait);
-        fcx.register_obligation(
-            traits::obligation_for_builtin_bound(
-                fcx.tcx(),
-                cause,
-                self_ty,
-                ty::BoundSend));
+        let obligation = traits::obligation_for_builtin_bound(fcx.tcx(),
+                                                              cause,
+                                                              self_ty,
+                                                              ty::BoundSend);
+        match obligation {
+            Ok(obligation) => fcx.register_obligation(obligation),
+            _ => {}
+        }
     } else {
         span_err!(fcx.tcx().sess, span, E0141,
                   "cannot implement a destructor on a structure \
index fcb613426fcb54182faa2b70c61671dec1a82d8f..638aea10e37952fa1bc9306ffce827e83d27b6db 100644 (file)
@@ -92,6 +92,7 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
               ast::ExprMethodCall(..) => {
                 explain_span(cx, "method call", expr.span)
               },
+              ast::ExprMatch(_, _, ast::MatchIfLetDesugar) => explain_span(cx, "if let", expr.span),
               ast::ExprMatch(..) => explain_span(cx, "match", expr.span),
               _ => explain_span(cx, "expression", expr.span)
             }
index c051b8e60cd80ef0cbdf46f83b0b620ab6350e21..756516d17a2ea844636170bd1527ba7ba29140b0 100644 (file)
@@ -51,7 +51,7 @@ pub fn realpath(original: &Path) -> io::IoResult<Path> {
     return Ok(result);
 }
 
-#[cfg(not(windows), test)]
+#[cfg(all(not(windows), test))]
 mod test {
     use std::io;
     use std::io::fs::{File, symlink, mkdir, mkdir_recursive};
index e0946366abc818541f39014a94fa3afe5491cfa4..abb594d6e47a847a503b9612418a0d3ddab54142 100644 (file)
@@ -147,7 +147,7 @@ fn minimize_rpaths(rpaths: &[String]) -> Vec<String> {
     minimized
 }
 
-#[cfg(unix, test)]
+#[cfg(all(unix, test))]
 mod test {
     use super::{RPathConfig};
     use super::{minimize_rpaths, rpaths_to_flags, get_rpath_relative_to_output};
index f98a2dac0841cd5ebbd37a7252b26a11fdd8a748..35e42e3c54b23764fac9a5a79a804461b866089f 100644 (file)
@@ -110,7 +110,7 @@ pub fn calculate(metadata: &Vec<String>, krate: &ast::Crate) -> Svh {
         fn hex(b: u64) -> char {
             let b = (b & 0xf) as u8;
             let b = match b {
-                0 .. 9 => '0' as u8 + b,
+                0 ... 9 => '0' as u8 + b,
                 _ => 'a' as u8 + b - 10,
             };
             b as char
@@ -293,6 +293,7 @@ fn saw_expr<'a>(node: &'a Expr_) -> SawExprComponent<'a> {
             ExprForLoop(..)          => SawExprForLoop,
 
             // just syntactic artifacts, expanded away by time of SVH.
+            ExprIfLet(..)            => unreachable!(),
             ExprMac(..)              => unreachable!(),
         }
     }
index 1a324e25472cf186a20f1638f4734c4fb22221e1..b86f4d8cfb54195d0771814bb438afd8497dc596 100644 (file)
@@ -73,12 +73,8 @@ fn try_inline_def(cx: &DocContext, tcx: &ty::ctxt,
             record_extern_fqn(cx, did, clean::TypeTrait);
             clean::TraitItem(build_external_trait(cx, tcx, did))
         }
-        def::DefFn(did, style) => {
+        def::DefFn(did, style, false) => {
             // If this function is a tuple struct constructor, we just skip it
-            if csearch::get_tuple_struct_definition_if_ctor(&tcx.sess.cstore,
-                                                            did).is_some() {
-                return None
-            }
             record_extern_fqn(cx, did, clean::TypeFunction);
             clean::FunctionItem(build_external_function(cx, tcx, did, style))
         }
index 666be2debdaabd8fbac8e4d5759220f2ed7c06fc..054fbda73379c2b7c9bc421eeb8c62aafa4cf716 100644 (file)
@@ -2078,7 +2078,7 @@ fn resolve_type(cx: &DocContext, path: Path,
 
 fn register_def(cx: &DocContext, def: def::Def) -> ast::DefId {
     let (did, kind) = match def {
-        def::DefFn(i, _) => (i, TypeFunction),
+        def::DefFn(i, _, _) => (i, TypeFunction),
         def::DefTy(i, false) => (i, TypeTypedef),
         def::DefTy(i, true) => (i, TypeEnum),
         def::DefTrait(i) => (i, TypeTrait),
index 8b72bd9e10283a6cbe7832feebc62e21524ee312..d1cc37497dc44ef061def74d0156d5e9d221d8fc 100644 (file)
@@ -84,8 +84,7 @@ pub struct flock {
         pub static F_SETLKW: libc::c_int = 9;
     }
 
-    #[cfg(target_os = "macos")]
-    #[cfg(target_os = "ios")]
+    #[cfg(any(target_os = "macos", target_os = "ios"))]
     mod os {
         use libc;
 
index 237a88ded711b9626ab07876fe36290b78352913..71d00e50af83d20ab900305b78741fb5955c8988 100644 (file)
@@ -89,47 +89,7 @@ pub mod html {
 type Output = (clean::Crate, Vec<plugins::PluginJson> );
 
 pub fn main() {
-    // Why run rustdoc in a separate task? That's a good question!
-    //
-    // We first begin our adventure at the ancient commit of e7c4fb69. In this
-    // commit it was discovered that the stack limit frobbing on windows ended
-    // up causing some syscalls to fail. This was worked around manually in the
-    // relevant location.
-    //
-    // Our journey now continues with #13259 where it was discovered that this
-    // stack limit frobbing has the ability to affect nearly any syscall. Note
-    // that the key idea here is that there is currently no knowledge as to why
-    // this is happening or how to preserve it, fun times!
-    //
-    // Now we continue along to #16275 where it was discovered that --test on
-    // windows didn't work at all! Yet curiously rustdoc worked without --test.
-    // The exact reason that #16275 cropped up is that during the expansion
-    // phase the compiler attempted to open libstd to read out its macros. This
-    // invoked the LLVMRustOpenArchive shim which in turned went to LLVM to go
-    // open a file and read it. Lo and behold this function returned an error!
-    // It was then discovered that when the same fix mentioned in #13259 was
-    // applied, the error went away. The plot thickens!
-    //
-    // Remember that rustdoc works without --test, which raises the question of
-    // how because the --test and non --test paths are almost identical. The
-    // first thing both paths do is parse and expand a crate! It turns out that
-    // the difference is that --test runs on the *main task* while the normal
-    // path runs in subtask. It turns out that running --test in a sub task also
-    // fixes the problem!
-    //
-    // So, in summary, it is unknown why this is necessary, what it is
-    // preventing, or what the actual bug is. In the meantime, this allows
-    // --test to work on windows, which seems good, right? Fun times.
-    let (tx, rx) = channel();
-    spawn(proc() {
-        std::os::set_exit_status(main_args(std::os::args().as_slice()));
-        tx.send(());
-    });
-
-    // If the task failed, set an error'd exit status
-    if rx.recv_opt().is_err() {
-        std::os::set_exit_status(std::rt::DEFAULT_ERROR_CODE);
-    }
+    std::os::set_exit_status(main_args(std::os::args().as_slice()));
 }
 
 pub fn opts() -> Vec<getopts::OptGroup> {
index fe217a6d123aa3c84268ed45819dac064410c9a7..2b5595131d0a7e74c22c5d01ad2295ee3f8cb49c 100644 (file)
@@ -85,7 +85,7 @@ fn libname(mut n: String) -> String {
     n
 }
 
-#[cfg(not(target_os="windows"), not(target_os="macos"))]
+#[cfg(all(not(target_os="windows"), not(target_os="macos")))]
 fn libname(n: String) -> String {
     let mut i = String::from_str("lib");
     i.push_str(n.as_slice());
index c0a17a720147377c2608a8655a44d178bf441e04..bd63886baeeda176a95558d77445a7046e474d1e 100644 (file)
@@ -39,10 +39,10 @@ pub fn put(args: Vec<Vec<u8>>) { imp::put(args) }
 /// Make a clone of the global arguments.
 pub fn clone() -> Option<Vec<Vec<u8>>> { imp::clone() }
 
-#[cfg(target_os = "linux")]
-#[cfg(target_os = "android")]
-#[cfg(target_os = "freebsd")]
-#[cfg(target_os = "dragonfly")]
+#[cfg(any(target_os = "linux",
+          target_os = "android",
+          target_os = "freebsd",
+          target_os = "dragonfly"))]
 mod imp {
     use core::prelude::*;
 
@@ -146,9 +146,9 @@ fn smoke_test() {
     }
 }
 
-#[cfg(target_os = "macos")]
-#[cfg(target_os = "ios")]
-#[cfg(target_os = "windows")]
+#[cfg(any(target_os = "macos",
+          target_os = "ios",
+          target_os = "windows"))]
 mod imp {
     use core::prelude::*;
     use collections::vec::Vec;
index b4ad1f23154b4d83a225ba0e4a594209b529d8c7..72c7d89a3b98b701c007b106436e088bc8ce6d9c 100644 (file)
@@ -160,7 +160,7 @@ pub unsafe fn cleanup() {
 pub mod shouldnt_be_public {
     #[cfg(not(test))]
     pub use super::local_ptr::native::maybe_tls_key;
-    #[cfg(not(windows), not(target_os = "android"), not(target_os = "ios"))]
+    #[cfg(all(not(windows), not(target_os = "android"), not(target_os = "ios")))]
     pub use super::local_ptr::compiled::RT_TLS_PTR;
 }
 
index aab75d7f7746d7b6126f2c01595627e7078e7838..2e7408d91591cc05b6cf3a12b9ac9773cc257bb4 100644 (file)
@@ -16,8 +16,7 @@
 
 use libc;
 
-#[cfg(not(target_arch = "arm"))]
-#[cfg(target_os = "ios")]
+#[cfg(any(not(target_arch = "arm"), target_os = "ios"))]
 #[repr(C)]
 pub enum _Unwind_Action {
     _UA_SEARCH_PHASE = 1,
@@ -62,14 +61,13 @@ pub enum _Unwind_Reason_Code {
 #[cfg(target_arch = "x86_64")]
 pub static unwinder_private_data_size: uint = 6;
 
-#[cfg(target_arch = "arm", not(target_os = "ios"))]
+#[cfg(all(target_arch = "arm", not(target_os = "ios")))]
 pub static unwinder_private_data_size: uint = 20;
 
-#[cfg(target_arch = "arm", target_os = "ios")]
+#[cfg(all(target_arch = "arm", target_os = "ios"))]
 pub static unwinder_private_data_size: uint = 5;
 
-#[cfg(target_arch = "mips")]
-#[cfg(target_arch = "mipsel")]
+#[cfg(any(target_arch = "mips", target_arch = "mipsel"))]
 pub static unwinder_private_data_size: uint = 2;
 
 #[repr(C)]
@@ -85,8 +83,7 @@ pub enum _Unwind_Context {}
         extern "C" fn(unwind_code: _Unwind_Reason_Code,
                       exception: *mut _Unwind_Exception);
 
-#[cfg(target_os = "linux")]
-#[cfg(target_os = "freebsd")]
+#[cfg(any(target_os = "linux", target_os = "freebsd"))]
 #[link(name = "gcc_s")]
 extern {}
 
@@ -101,11 +98,11 @@ pub enum _Unwind_Context {}
 extern "C" {
     // iOS on armv7 uses SjLj exceptions and requires to link
     // against corresponding routine (..._SjLj_...)
-    #[cfg(not(target_os = "ios", target_arch = "arm"))]
+    #[cfg(not(all(target_os = "ios", target_arch = "arm")))]
     pub fn _Unwind_RaiseException(exception: *mut _Unwind_Exception)
                                   -> _Unwind_Reason_Code;
 
-    #[cfg(target_os = "ios", target_arch = "arm")]
+    #[cfg(all(target_os = "ios", target_arch = "arm"))]
     fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception)
                                    -> _Unwind_Reason_Code;
 
@@ -115,7 +112,7 @@ fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception)
 // ... and now we just providing access to SjLj counterspart
 // through a standard name to hide those details from others
 // (see also comment above regarding _Unwind_RaiseException)
-#[cfg(target_os = "ios", target_arch = "arm")]
+#[cfg(all(target_os = "ios", target_arch = "arm"))]
 #[inline(always)]
 pub unsafe fn _Unwind_RaiseException(exc: *mut _Unwind_Exception)
                                      -> _Unwind_Reason_Code {
index 912e4ef4d40f434a11e29a7b062cf574b962f34a..58f8f8b310f5551dd14f591efa8de292de6371d9 100644 (file)
 use core::mem;
 use alloc::boxed::Box;
 
-#[cfg(windows)]               // mingw-w32 doesn't like thread_local things
-#[cfg(target_os = "android")] // see #10686
-#[cfg(target_os = "ios")]
+#[cfg(any(windows, // mingw-w32 doesn't like thread_local things
+          target_os = "android", // see #10686
+          target_os = "ios"))]
 pub use self::native::{init, cleanup, put, take, try_take, unsafe_take, exists,
                        unsafe_borrow, try_unsafe_borrow};
 
-#[cfg(not(windows), not(target_os = "android"), not(target_os = "ios"))]
+#[cfg(not(any(windows, target_os = "android", target_os = "ios")))]
 pub use self::compiled::{init, cleanup, put, take, try_take, unsafe_take, exists,
                          unsafe_borrow, try_unsafe_borrow};
 
@@ -82,7 +82,7 @@ pub unsafe fn borrow<T>() -> Borrowed<T> {
 /// implemented using LLVM's thread_local attribute which isn't necessarily
 /// working on all platforms. This implementation is faster, however, so we use
 /// it wherever possible.
-#[cfg(not(windows), not(target_os = "android"), not(target_os = "ios"))]
+#[cfg(not(any(windows, target_os = "android", target_os = "ios")))]
 pub mod compiled {
     use core::prelude::*;
 
index f4fff43fd7c4f6dad6d845834ffa64e9bf948fab..86dc9b85a792dc769db4e89ae32459697222b2c2 100644 (file)
@@ -346,8 +346,7 @@ mod imp {
     type pthread_mutexattr_t = libc::c_void;
     type pthread_condattr_t = libc::c_void;
 
-    #[cfg(target_os = "freebsd")]
-    #[cfg(target_os = "dragonfly")]
+    #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
     mod os {
         use libc;
 
@@ -360,8 +359,7 @@ mod os {
             0 as pthread_cond_t;
     }
 
-    #[cfg(target_os = "macos")]
-    #[cfg(target_os = "ios")]
+    #[cfg(any(target_os = "macos", target_os = "ios"))]
     mod os {
         use libc;
 
index 3190e9f784149a2d0130d6e8cf391cf3c13b7818..5c94ef61bfdb7ceb68f56c6cdf1b8adbe76b21b1 100644 (file)
@@ -156,13 +156,13 @@ pub unsafe fn record_rust_managed_stack_bounds(stack_lo: uint, stack_hi: uint) {
     #[cfg(not(windows))] #[inline(always)]
     unsafe fn target_record_stack_bounds(_stack_lo: uint, _stack_hi: uint) {}
 
-    #[cfg(windows, target_arch = "x86")] #[inline(always)]
+    #[cfg(all(windows, target_arch = "x86"))] #[inline(always)]
     unsafe fn target_record_stack_bounds(stack_lo: uint, stack_hi: uint) {
         // stack range is at TIB: %fs:0x04 (top) and %fs:0x08 (bottom)
         asm!("mov $0, %fs:0x04" :: "r"(stack_hi) :: "volatile");
         asm!("mov $0, %fs:0x08" :: "r"(stack_lo) :: "volatile");
     }
-    #[cfg(windows, target_arch = "x86_64")] #[inline(always)]
+    #[cfg(all(windows, target_arch = "x86_64"))] #[inline(always)]
     unsafe fn target_record_stack_bounds(stack_lo: uint, stack_hi: uint) {
         // stack range is at TIB: %gs:0x08 (top) and %gs:0x10 (bottom)
         asm!("mov $0, %gs:0x08" :: "r"(stack_hi) :: "volatile");
@@ -189,56 +189,53 @@ pub unsafe fn record_sp_limit(limit: uint) {
     return target_record_sp_limit(limit);
 
     // x86-64
-    #[cfg(target_arch = "x86_64", target_os = "macos")]
-    #[cfg(target_arch = "x86_64", target_os = "ios")] #[inline(always)]
+    #[cfg(all(target_arch = "x86_64",
+              any(target_os = "macos", target_os = "ios")))]
+    #[inline(always)]
     unsafe fn target_record_sp_limit(limit: uint) {
         asm!("movq $$0x60+90*8, %rsi
               movq $0, %gs:(%rsi)" :: "r"(limit) : "rsi" : "volatile")
     }
-    #[cfg(target_arch = "x86_64", target_os = "linux")] #[inline(always)]
+    #[cfg(all(target_arch = "x86_64", target_os = "linux"))] #[inline(always)]
     unsafe fn target_record_sp_limit(limit: uint) {
         asm!("movq $0, %fs:112" :: "r"(limit) :: "volatile")
     }
-    #[cfg(target_arch = "x86_64", target_os = "windows")] #[inline(always)]
-    unsafe fn target_record_sp_limit(limit: uint) {
-        // see: http://en.wikipedia.org/wiki/Win32_Thread_Information_Block
-        // store this inside of the "arbitrary data slot", but double the size
-        // because this is 64 bit instead of 32 bit
-        asm!("movq $0, %gs:0x28" :: "r"(limit) :: "volatile")
+    #[cfg(all(target_arch = "x86_64", target_os = "windows"))] #[inline(always)]
+    unsafe fn target_record_sp_limit(_: uint) {
     }
-    #[cfg(target_arch = "x86_64", target_os = "freebsd")] #[inline(always)]
+    #[cfg(all(target_arch = "x86_64", target_os = "freebsd"))] #[inline(always)]
     unsafe fn target_record_sp_limit(limit: uint) {
         asm!("movq $0, %fs:24" :: "r"(limit) :: "volatile")
     }
-    #[cfg(target_arch = "x86_64", target_os = "dragonfly")] #[inline(always)]
+    #[cfg(all(target_arch = "x86_64", target_os = "dragonfly"))] #[inline(always)]
     unsafe fn target_record_sp_limit(limit: uint) {
         asm!("movq $0, %fs:32" :: "r"(limit) :: "volatile")
     }
 
     // x86
-    #[cfg(target_arch = "x86", target_os = "macos")]
-    #[cfg(target_arch = "x86", target_os = "ios")] #[inline(always)]
+    #[cfg(all(target_arch = "x86",
+              any(target_os = "macos", target_os = "ios")))]
+    #[inline(always)]
     unsafe fn target_record_sp_limit(limit: uint) {
         asm!("movl $$0x48+90*4, %eax
               movl $0, %gs:(%eax)" :: "r"(limit) : "eax" : "volatile")
     }
-    #[cfg(target_arch = "x86", target_os = "linux")]
-    #[cfg(target_arch = "x86", target_os = "freebsd")] #[inline(always)]
+    #[cfg(all(target_arch = "x86",
+              any(target_os = "linux", target_os = "freebsd")))]
+    #[inline(always)]
     unsafe fn target_record_sp_limit(limit: uint) {
         asm!("movl $0, %gs:48" :: "r"(limit) :: "volatile")
     }
-    #[cfg(target_arch = "x86", target_os = "windows")] #[inline(always)]
-    unsafe fn target_record_sp_limit(limit: uint) {
-        // see: http://en.wikipedia.org/wiki/Win32_Thread_Information_Block
-        // store this inside of the "arbitrary data slot"
-        asm!("movl $0, %fs:0x14" :: "r"(limit) :: "volatile")
+    #[cfg(all(target_arch = "x86", target_os = "windows"))] #[inline(always)]
+    unsafe fn target_record_sp_limit(_: uint) {
     }
 
     // mips, arm - Some brave soul can port these to inline asm, but it's over
     //             my head personally
-    #[cfg(target_arch = "mips")]
-    #[cfg(target_arch = "mipsel")]
-    #[cfg(target_arch = "arm", not(target_os = "ios"))] #[inline(always)]
+    #[cfg(any(target_arch = "mips",
+              target_arch = "mipsel",
+              all(target_arch = "arm", not(target_os = "ios"))))]
+    #[inline(always)]
     unsafe fn target_record_sp_limit(limit: uint) {
         use libc::c_void;
         return record_sp_limit(limit as *const c_void);
@@ -248,7 +245,7 @@ unsafe fn target_record_sp_limit(limit: uint) {
     }
 
     // iOS segmented stack is disabled for now, see related notes
-    #[cfg(target_arch = "arm", target_os = "ios")] #[inline(always)]
+    #[cfg(all(target_arch = "arm", target_os = "ios"))] #[inline(always)]
     unsafe fn target_record_sp_limit(_: uint) {
     }
 }
@@ -266,33 +263,32 @@ pub unsafe fn get_sp_limit() -> uint {
     return target_get_sp_limit();
 
     // x86-64
-    #[cfg(target_arch = "x86_64", target_os = "macos")]
-    #[cfg(target_arch = "x86_64", target_os = "ios")] #[inline(always)]
+    #[cfg(all(target_arch = "x86_64",
+              any(target_os = "macos", target_os = "ios")))]
+    #[inline(always)]
     unsafe fn target_get_sp_limit() -> uint {
         let limit;
         asm!("movq $$0x60+90*8, %rsi
               movq %gs:(%rsi), $0" : "=r"(limit) :: "rsi" : "volatile");
         return limit;
     }
-    #[cfg(target_arch = "x86_64", target_os = "linux")] #[inline(always)]
+    #[cfg(all(target_arch = "x86_64", target_os = "linux"))] #[inline(always)]
     unsafe fn target_get_sp_limit() -> uint {
         let limit;
         asm!("movq %fs:112, $0" : "=r"(limit) ::: "volatile");
         return limit;
     }
-    #[cfg(target_arch = "x86_64", target_os = "windows")] #[inline(always)]
+    #[cfg(all(target_arch = "x86_64", target_os = "windows"))] #[inline(always)]
     unsafe fn target_get_sp_limit() -> uint {
-        let limit;
-        asm!("movq %gs:0x28, $0" : "=r"(limit) ::: "volatile");
-        return limit;
+        return 1024;
     }
-    #[cfg(target_arch = "x86_64", target_os = "freebsd")] #[inline(always)]
+    #[cfg(all(target_arch = "x86_64", target_os = "freebsd"))] #[inline(always)]
     unsafe fn target_get_sp_limit() -> uint {
         let limit;
         asm!("movq %fs:24, $0" : "=r"(limit) ::: "volatile");
         return limit;
     }
-    #[cfg(target_arch = "x86_64", target_os = "dragonfly")] #[inline(always)]
+    #[cfg(all(target_arch = "x86_64", target_os = "dragonfly"))] #[inline(always)]
     unsafe fn target_get_sp_limit() -> uint {
         let limit;
         asm!("movq %fs:32, $0" : "=r"(limit) ::: "volatile");
@@ -301,33 +297,34 @@ unsafe fn target_get_sp_limit() -> uint {
 
 
     // x86
-    #[cfg(target_arch = "x86", target_os = "macos")]
-    #[cfg(target_arch = "x86", target_os = "ios")] #[inline(always)]
+    #[cfg(all(target_arch = "x86",
+              any(target_os = "macos", target_os = "ios")))]
+    #[inline(always)]
     unsafe fn target_get_sp_limit() -> uint {
         let limit;
         asm!("movl $$0x48+90*4, %eax
               movl %gs:(%eax), $0" : "=r"(limit) :: "eax" : "volatile");
         return limit;
     }
-    #[cfg(target_arch = "x86", target_os = "linux")]
-    #[cfg(target_arch = "x86", target_os = "freebsd")] #[inline(always)]
+    #[cfg(all(target_arch = "x86",
+              any(target_os = "linux", target_os = "freebsd")))]
+    #[inline(always)]
     unsafe fn target_get_sp_limit() -> uint {
         let limit;
         asm!("movl %gs:48, $0" : "=r"(limit) ::: "volatile");
         return limit;
     }
-    #[cfg(target_arch = "x86", target_os = "windows")] #[inline(always)]
+    #[cfg(all(target_arch = "x86", target_os = "windows"))] #[inline(always)]
     unsafe fn target_get_sp_limit() -> uint {
-        let limit;
-        asm!("movl %fs:0x14, $0" : "=r"(limit) ::: "volatile");
-        return limit;
+        return 1024;
     }
 
     // mips, arm - Some brave soul can port these to inline asm, but it's over
     //             my head personally
-    #[cfg(target_arch = "mips")]
-    #[cfg(target_arch = "mipsel")]
-    #[cfg(target_arch = "arm", not(target_os = "ios"))] #[inline(always)]
+    #[cfg(any(target_arch = "mips",
+              target_arch = "mipsel",
+              all(target_arch = "arm", not(target_os = "ios"))))]
+    #[inline(always)]
     unsafe fn target_get_sp_limit() -> uint {
         use libc::c_void;
         return get_sp_limit() as uint;
@@ -339,7 +336,7 @@ unsafe fn target_get_sp_limit() -> uint {
     // iOS doesn't support segmented stacks yet. This function might
     // be called by runtime though so it is unsafe to mark it as
     // unreachable, let's return a fixed constant.
-    #[cfg(target_arch = "arm", target_os = "ios")] #[inline(always)]
+    #[cfg(all(target_arch = "arm", target_os = "ios"))] #[inline(always)]
     unsafe fn target_get_sp_limit() -> uint {
         1024
     }
index 6078ed990e41d6dd25c5f56dca10199874b1ddc2..aee70980bbaf7145e62eee52a36e7bbda01c07bc 100644 (file)
@@ -41,11 +41,11 @@ pub unsafe fn destroy(key: Key) {
 #[allow(non_camel_case_types)] // foreign type
 type pthread_key_t = ::libc::c_ulong;
 
-#[cfg(target_os="linux")]
-#[cfg(target_os="freebsd")]
-#[cfg(target_os="dragonfly")]
-#[cfg(target_os="android")]
-#[cfg(target_os = "ios")]
+#[cfg(any(target_os="linux",
+          target_os="freebsd",
+          target_os="dragonfly",
+          target_os="android",
+          target_os = "ios"))]
 #[allow(non_camel_case_types)] // foreign type
 type pthread_key_t = ::libc::c_uint;
 
index d3ab0f27c1328d5973374ae59fe4840a5c915614..1561f428ce5484f84a13ebee6b7ead3c5e5b7c04 100644 (file)
@@ -235,7 +235,9 @@ fn rust_exception_class() -> uw::_Unwind_Exception_Class {
 //
 // See also: rt/rust_try.ll
 
-#[cfg(not(target_arch = "arm"), not(windows, target_arch = "x86_64"), not(test))]
+#[cfg(all(not(target_arch = "arm"),
+          not(all(windows, target_arch = "x86_64")),
+          not(test)))]
 #[doc(hidden)]
 pub mod eabi {
     use libunwind as uw;
@@ -288,7 +290,7 @@ pub extern "C" fn rust_eh_personality_catch(
 // iOS on armv7 is using SjLj exceptions and therefore requires to use
 // a specialized personality routine: __gcc_personality_sj0
 
-#[cfg(target_os = "ios", target_arch = "arm", not(test))]
+#[cfg(all(target_os = "ios", target_arch = "arm", not(test)))]
 #[doc(hidden)]
 pub mod eabi {
     use libunwind as uw;
@@ -343,7 +345,7 @@ pub extern "C" fn rust_eh_personality_catch(
 
 // ARM EHABI uses a slightly different personality routine signature,
 // but otherwise works the same.
-#[cfg(target_arch = "arm", not(target_os = "ios"), not(test))]
+#[cfg(all(target_arch = "arm", not(target_os = "ios"), not(test)))]
 #[doc(hidden)]
 pub mod eabi {
     use libunwind as uw;
@@ -392,7 +394,7 @@ pub extern "C" fn rust_eh_personality_catch(
 // GCC reuses the same personality routine as for the other architectures by wrapping it
 // with an "API translator" layer (_GCC_specific_handler).
 
-#[cfg(windows, target_arch = "x86_64", not(test))]
+#[cfg(all(windows, target_arch = "x86_64", not(test)))]
 #[doc(hidden)]
 #[allow(non_camel_case_types, non_snake_case)]
 pub mod eabi {
index c7c278675c1821c2c5353b7bfa8f67cab29d1946..35bd20c0dd90b7bcee88e6f768c4d9278ae0a891 100644 (file)
@@ -723,12 +723,11 @@ pub fn uv_signal_start(h: *mut uv_signal_t, cb: uv_signal_cb,
 
 // libuv doesn't use pthread on windows
 // android libc (bionic) provides pthread, so no additional link is required
-#[cfg(not(windows), not(target_os = "android"))]
+#[cfg(not(any(windows, target_os = "android")))]
 #[link(name = "pthread")]
 extern {}
 
-#[cfg(target_os = "linux")]
-#[cfg(target_os = "dragonfly")]
+#[cfg(any(target_os = "linux", target_os = "dragonfly"))]
 #[link(name = "rt")]
 extern {}
 
@@ -738,7 +737,6 @@ pub fn uv_signal_start(h: *mut uv_signal_t, cb: uv_signal_cb,
 #[link(name = "iphlpapi")]
 extern {}
 
-#[cfg(target_os = "freebsd")]
-#[cfg(target_os = "dragonfly")]
+#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
 #[link(name = "kvm")]
 extern {}
index f85f3a43974b9a9435799616b39c99131a1e9b6c..19dcc3c132cd7328a26db09a303ef35ce92b757b 100644 (file)
@@ -224,9 +224,9 @@ fn from_base64(&self) -> Result<Vec<u8>, FromBase64Error> {
             let val = byte as u32;
 
             match byte {
-                b'A'..b'Z' => buf |= val - 0x41,
-                b'a'..b'z' => buf |= val - 0x47,
-                b'0'..b'9' => buf |= val + 0x04,
+                b'A'...b'Z' => buf |= val - 0x41,
+                b'a'...b'z' => buf |= val - 0x47,
+                b'0'...b'9' => buf |= val + 0x04,
                 b'+' | b'-' => buf |= 0x3E,
                 b'/' | b'_' => buf |= 0x3F,
                 b'\r' | b'\n' => continue,
index 5e8697ef0ade4d0a5683826ecb4023edebdc88bd..ffe63f738cf974eb485e4485a1d580f60938ac4a 100644 (file)
@@ -113,9 +113,9 @@ fn from_hex(&self) -> Result<Vec<u8>, FromHexError> {
             buf <<= 4;
 
             match byte {
-                b'A'..b'F' => buf |= byte - b'A' + 10,
-                b'a'..b'f' => buf |= byte - b'a' + 10,
-                b'0'..b'9' => buf |= byte - b'0',
+                b'A'...b'F' => buf |= byte - b'A' + 10,
+                b'a'...b'f' => buf |= byte - b'a' + 10,
+                b'0'...b'9' => buf |= byte - b'0',
                 b' '|b'\r'|b'\n'|b'\t' => {
                     buf >>= 4;
                     continue
index ed95fa341b39dee80ceae43bd2f77bf2292fd7b0..3007e160bf8ae536078e643e20078dfb273901d0 100644 (file)
@@ -1392,14 +1392,14 @@ fn parse_u64(&mut self) -> Result<u64, ParserError> {
 
                 // A leading '0' must be the only digit before the decimal point.
                 match self.ch_or_null() {
-                    '0' .. '9' => return self.error(InvalidNumber),
+                    '0' ... '9' => return self.error(InvalidNumber),
                     _ => ()
                 }
             },
-            '1' .. '9' => {
+            '1' ... '9' => {
                 while !self.eof() {
                     match self.ch_or_null() {
-                        c @ '0' .. '9' => {
+                        c @ '0' ... '9' => {
                             accum *= 10;
                             accum += (c as u64) - ('0' as u64);
 
@@ -1423,14 +1423,14 @@ fn parse_decimal(&mut self, mut res: f64) -> Result<f64, ParserError> {
 
         // Make sure a digit follows the decimal place.
         match self.ch_or_null() {
-            '0' .. '9' => (),
+            '0' ... '9' => (),
              _ => return self.error(InvalidNumber)
         }
 
         let mut dec = 1.0;
         while !self.eof() {
             match self.ch_or_null() {
-                c @ '0' .. '9' => {
+                c @ '0' ... '9' => {
                     dec /= 10.0;
                     res += (((c as int) - ('0' as int)) as f64) * dec;
                     self.bump();
@@ -1457,12 +1457,12 @@ fn parse_exponent(&mut self, mut res: f64) -> Result<f64, ParserError> {
 
         // Make sure a digit follows the exponent place.
         match self.ch_or_null() {
-            '0' .. '9' => (),
+            '0' ... '9' => (),
             _ => return self.error(InvalidNumber)
         }
         while !self.eof() {
             match self.ch_or_null() {
-                c @ '0' .. '9' => {
+                c @ '0' ... '9' => {
                     exp *= 10;
                     exp += (c as uint) - ('0' as uint);
 
@@ -1488,7 +1488,7 @@ fn decode_hex_escape(&mut self) -> Result<u16, ParserError> {
         while i < 4 && !self.eof() {
             self.bump();
             n = match self.ch_or_null() {
-                c @ '0' .. '9' => n * 16 + ((c as u16) - ('0' as u16)),
+                c @ '0' ... '9' => n * 16 + ((c as u16) - ('0' as u16)),
                 'a' | 'A' => n * 16 + 10,
                 'b' | 'B' => n * 16 + 11,
                 'c' | 'C' => n * 16 + 12,
@@ -1530,11 +1530,13 @@ fn parse_str(&mut self) -> Result<string::String, ParserError> {
                     'r' => res.push('\r'),
                     't' => res.push('\t'),
                     'u' => match try!(self.decode_hex_escape()) {
-                        0xDC00 .. 0xDFFF => return self.error(LoneLeadingSurrogateInHexEscape),
+                        0xDC00 ... 0xDFFF => {
+                            return self.error(LoneLeadingSurrogateInHexEscape)
+                        }
 
                         // Non-BMP characters are encoded as a sequence of
                         // two hex escapes, representing UTF-16 surrogates.
-                        n1 @ 0xD800 .. 0xDBFF => {
+                        n1 @ 0xD800 ... 0xDBFF => {
                             match (self.next_char(), self.next_char()) {
                                 (Some('\\'), Some('u')) => (),
                                 _ => return self.error(UnexpectedEndOfHexEscape),
@@ -1768,7 +1770,7 @@ fn parse_value(&mut self) -> JsonEvent {
             'n' => { self.parse_ident("ull", NullValue) }
             't' => { self.parse_ident("rue", BooleanValue(true)) }
             'f' => { self.parse_ident("alse", BooleanValue(false)) }
-            '0' .. '9' | '-' => self.parse_number(),
+            '0' ... '9' | '-' => self.parse_number(),
             '"' => match self.parse_str() {
                 Ok(s) => StringValue(s),
                 Err(e) => Error(e),
index a88448f47e0c6e9c62f3bfdc1e783242cba51ca4..bd2bd1ad0904a161fc98a35d96a9416c98435a03 100644 (file)
@@ -154,7 +154,7 @@ pub unsafe fn symbol<T>(&self, symbol: &str) -> Result<*mut T, String> {
     }
 }
 
-#[cfg(test, not(target_os = "ios"))]
+#[cfg(all(test, not(target_os = "ios")))]
 mod test {
     use super::*;
     use prelude::*;
@@ -189,10 +189,10 @@ fn test_loading_cosine() {
     }
 
     #[test]
-    #[cfg(target_os = "linux")]
-    #[cfg(target_os = "macos")]
-    #[cfg(target_os = "freebsd")]
-    #[cfg(target_os = "dragonfly")]
+    #[cfg(any(target_os = "linux",
+              target_os = "macos",
+              target_os = "freebsd",
+              target_os = "dragonfly"))]
     fn test_errors_do_not_crash() {
         // Open /dev/null as a library to get an error, and make sure
         // that only causes an error, and not a crash.
@@ -204,12 +204,12 @@ fn test_errors_do_not_crash() {
     }
 }
 
-#[cfg(target_os = "linux")]
-#[cfg(target_os = "android")]
-#[cfg(target_os = "macos")]
-#[cfg(target_os = "ios")]
-#[cfg(target_os = "freebsd")]
-#[cfg(target_os = "dragonfly")]
+#[cfg(any(target_os = "linux",
+          target_os = "android",
+          target_os = "macos",
+          target_os = "ios",
+          target_os = "freebsd",
+          target_os = "dragonfly"))]
 pub mod dl {
 
     use c_str::{CString, ToCStr};
index 867e8bcca826d25732c6c94692091667175435c6..ea1dd12f323a7f82a4ac2c1fef803b44e8d2524b 100644 (file)
@@ -123,7 +123,7 @@ fn lookup(hostname: Option<&str>, servname: Option<&str>, hint: Option<Hint>)
 
 // Ignored on android since we cannot give tcp/ip
 // permission without help of apk
-#[cfg(test, not(target_os = "android"))]
+#[cfg(all(test, not(target_os = "android")))]
 mod test {
     iotest!(fn dns_smoke_test() {
         let ipaddrs = get_host_addresses("localhost").unwrap();
index 83890d2b1275e09d7bbb0220b304e8b650043efb..f97e9f4647ba018321fc8f65e85dd9d5ae3fec4a 100644 (file)
@@ -693,7 +693,7 @@ mod tests {
         drop(p.wait().clone());
     })
 
-    #[cfg(unix, not(target_os="android"))]
+    #[cfg(all(unix, not(target_os="android")))]
     iotest!(fn signal_reported_right() {
         let p = Command::new("/bin/sh").arg("-c").arg("kill -1 $$").spawn();
         assert!(p.is_ok());
@@ -725,7 +725,7 @@ pub fn run_output(cmd: Command) -> String {
         assert_eq!(run_output(cmd), "foobar\n".to_string());
     })
 
-    #[cfg(unix, not(target_os="android"))]
+    #[cfg(all(unix, not(target_os="android")))]
     iotest!(fn set_cwd_works() {
         let mut cmd = Command::new("/bin/sh");
         cmd.arg("-c").arg("pwd")
@@ -734,7 +734,7 @@ pub fn run_output(cmd: Command) -> String {
         assert_eq!(run_output(cmd), "/\n".to_string());
     })
 
-    #[cfg(unix, not(target_os="android"))]
+    #[cfg(all(unix, not(target_os="android")))]
     iotest!(fn stdin_works() {
         let mut p = Command::new("/bin/sh")
                             .arg("-c").arg("read line; echo $line")
@@ -759,7 +759,7 @@ pub fn run_output(cmd: Command) -> String {
         assert!(Command::new("test").uid(10).spawn().is_err());
     })
 
-    #[cfg(unix, not(target_os="android"))]
+    #[cfg(all(unix, not(target_os="android")))]
     iotest!(fn uid_works() {
         use libc;
         let mut p = Command::new("/bin/sh")
@@ -770,7 +770,7 @@ pub fn run_output(cmd: Command) -> String {
         assert!(p.wait().unwrap().success());
     })
 
-    #[cfg(unix, not(target_os="android"))]
+    #[cfg(all(unix, not(target_os="android")))]
     iotest!(fn uid_to_root_fails() {
         use libc;
 
@@ -847,7 +847,7 @@ pub fn run_output(cmd: Command) -> String {
         }
     })
 
-    #[cfg(unix,not(target_os="android"))]
+    #[cfg(all(unix, not(target_os="android")))]
     pub fn pwd_cmd() -> Command {
         Command::new("pwd")
     }
@@ -897,7 +897,7 @@ pub fn pwd_cmd() -> Command {
         assert_eq!(parent_stat.unstable.inode, child_stat.unstable.inode);
     })
 
-    #[cfg(unix,not(target_os="android"))]
+    #[cfg(all(unix, not(target_os="android")))]
     pub fn env_cmd() -> Command {
         Command::new("env")
     }
index 1d882bdc0ad9e0fddd53ff318921029f8c43f265..79a00e90b40746d8fde0b6a3ce555bb3f17d8130 100644 (file)
@@ -160,7 +160,7 @@ pub fn unregister(&mut self, signum: Signum) {
     }
 }
 
-#[cfg(test, unix)]
+#[cfg(all(test, unix))]
 mod test_unix {
     use prelude::*;
     use libc;
@@ -218,7 +218,7 @@ fn test_io_signal_unregister() {
     }
 }
 
-#[cfg(test, windows)]
+#[cfg(all(test, windows))]
 mod test_windows {
     use super::{User1, Listener};
     use result::{Ok, Err};
index 407c8ea61d9146eeef1b061eb3ac96d6871586cd..b15f334e233e82197863e80b27ea2421146eed89 100644 (file)
@@ -199,8 +199,8 @@ pub fn int_to_str_bytes_common<T: Int>(num: T, radix: uint, sign: SignFormat, f:
             current_digit_signed
         };
         buf[cur] = match current_digit.to_u8().unwrap() {
-            i @ 0..9 => b'0' + i,
-            i        => b'a' + (i - 10),
+            i @ 0...9 => b'0' + i,
+            i         => b'a' + (i - 10),
         };
         cur += 1;
 
index 478a40f17b0d3c11d0e0bd2e0bc5c3d00261bce9..d904e657e403b082e61110c71af92c7b60732ca6 100644 (file)
@@ -653,8 +653,7 @@ pub fn dll_filename(base: &str) -> String {
 /// ```
 pub fn self_exe_name() -> Option<Path> {
 
-    #[cfg(target_os = "freebsd")]
-    #[cfg(target_os = "dragonfly")]
+    #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
     fn load_self() -> Option<Vec<u8>> {
         unsafe {
             use libc::funcs::bsd44::*;
@@ -680,8 +679,7 @@ fn load_self() -> Option<Vec<u8>> {
         }
     }
 
-    #[cfg(target_os = "linux")]
-    #[cfg(target_os = "android")]
+    #[cfg(any(target_os = "linux", target_os = "android"))]
     fn load_self() -> Option<Vec<u8>> {
         use std::io;
 
@@ -691,8 +689,7 @@ fn load_self() -> Option<Vec<u8>> {
         }
     }
 
-    #[cfg(target_os = "macos")]
-    #[cfg(target_os = "ios")]
+    #[cfg(any(target_os = "macos", target_os = "ios"))]
     fn load_self() -> Option<Vec<u8>> {
         unsafe {
             use libc::funcs::extra::_NSGetExecutablePath;
@@ -909,9 +906,9 @@ fn chdir(p: &Path) -> bool {
 #[cfg(unix)]
 /// Returns the platform-specific value of errno
 pub fn errno() -> int {
-    #[cfg(target_os = "macos")]
-    #[cfg(target_os = "ios")]
-    #[cfg(target_os = "freebsd")]
+    #[cfg(any(target_os = "macos",
+              target_os = "ios",
+              target_os = "freebsd"))]
     fn errno_location() -> *const c_int {
         extern {
             fn __error() -> *const c_int;
@@ -931,8 +928,7 @@ fn errno_location() -> *const c_int {
         }
     }
 
-    #[cfg(target_os = "linux")]
-    #[cfg(target_os = "android")]
+    #[cfg(any(target_os = "linux", target_os = "android"))]
     fn errno_location() -> *const c_int {
         extern {
             fn __errno_location() -> *const c_int;
@@ -975,11 +971,11 @@ pub fn error_string(errnum: uint) -> String {
 
     #[cfg(unix)]
     fn strerror(errnum: uint) -> String {
-        #[cfg(target_os = "macos")]
-        #[cfg(target_os = "ios")]
-        #[cfg(target_os = "android")]
-        #[cfg(target_os = "freebsd")]
-        #[cfg(target_os = "dragonfly")]
+        #[cfg(any(target_os = "macos",
+                  target_os = "ios",
+                  target_os = "android",
+                  target_os = "freebsd",
+                  target_os = "dragonfly"))]
         fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: libc::size_t)
                       -> c_int {
             extern {
@@ -1180,10 +1176,10 @@ fn real_args_as_bytes() -> Vec<Vec<u8>> {
     res
 }
 
-#[cfg(target_os = "linux")]
-#[cfg(target_os = "android")]
-#[cfg(target_os = "freebsd")]
-#[cfg(target_os = "dragonfly")]
+#[cfg(any(target_os = "linux",
+          target_os = "android",
+          target_os = "freebsd",
+          target_os = "dragonfly"))]
 fn real_args_as_bytes() -> Vec<Vec<u8>> {
     use rt;
 
index 95be3191bab493eb121b5933bdac6c2e6cda06f0..c5b7154ffdb57d00dd5d5eb6f03fb33fc31ccf1d 100644 (file)
@@ -13,7 +13,7 @@
 
 pub use self::imp::OsRng;
 
-#[cfg(unix, not(target_os = "ios"))]
+#[cfg(all(unix, not(target_os = "ios")))]
 mod imp {
     use io::{IoResult, File};
     use path::Path;
@@ -136,7 +136,6 @@ mod imp {
     use os;
     use rand::Rng;
     use result::{Ok, Err};
-    use rt::stack;
     use self::libc::{DWORD, BYTE, LPCSTR, BOOL};
     use self::libc::types::os::arch::extra::{LONG_PTR};
     use slice::MutableSlice;
@@ -159,7 +158,6 @@ pub struct OsRng {
     static PROV_RSA_FULL: DWORD = 1;
     static CRYPT_SILENT: DWORD = 64;
     static CRYPT_VERIFYCONTEXT: DWORD = 0xF0000000;
-    static NTE_BAD_SIGNATURE: DWORD = 0x80090006;
 
     #[allow(non_snake_case)]
     extern "system" {
@@ -178,48 +176,12 @@ impl OsRng {
         /// Create a new `OsRng`.
         pub fn new() -> IoResult<OsRng> {
             let mut hcp = 0;
-            let mut ret = unsafe {
+            let ret = unsafe {
                 CryptAcquireContextA(&mut hcp, 0 as LPCSTR, 0 as LPCSTR,
                                      PROV_RSA_FULL,
                                      CRYPT_VERIFYCONTEXT | CRYPT_SILENT)
             };
 
-            // FIXME #13259:
-            // It turns out that if we can't acquire a context with the
-            // NTE_BAD_SIGNATURE error code, the documentation states:
-            //
-            //     The provider DLL signature could not be verified. Either the
-            //     DLL or the digital signature has been tampered with.
-            //
-            // Sounds fishy, no? As it turns out, our signature can be bad
-            // because our Thread Information Block (TIB) isn't exactly what it
-            // expects. As to why, I have no idea. The only data we store in the
-            // TIB is the stack limit for each thread, but apparently that's
-            // enough to make the signature valid.
-            //
-            // Furthermore, this error only happens the *first* time we call
-            // CryptAcquireContext, so we don't have to worry about future
-            // calls.
-            //
-            // Anyway, the fix employed here is that if we see this error, we
-            // pray that we're not close to the end of the stack, temporarily
-            // set the stack limit to 0 (what the TIB originally was), acquire a
-            // context, and then reset the stack limit.
-            //
-            // Again, I'm not sure why this is the fix, nor why we're getting
-            // this error. All I can say is that this seems to allow libnative
-            // to progress where it otherwise would be hindered. Who knew?
-            if ret == 0 && os::errno() as DWORD == NTE_BAD_SIGNATURE {
-                unsafe {
-                    let limit = stack::get_sp_limit();
-                    stack::record_sp_limit(0);
-                    ret = CryptAcquireContextA(&mut hcp, 0 as LPCSTR, 0 as LPCSTR,
-                                               PROV_RSA_FULL,
-                                               CRYPT_VERIFYCONTEXT | CRYPT_SILENT);
-                    stack::record_sp_limit(limit);
-                }
-            }
-
             if ret == 0 {
                 Err(IoError::last_error())
             } else {
index aa9505d83fc275fcae49dc4e446122795029f54f..33f8713e1a13c9f61fa67856ec89997f4f268cd6 100644 (file)
@@ -253,7 +253,7 @@ mod imp {
     /// play well with green threads, so while it is extremely nice
     /// and simple to use it should be used only on iOS devices as the
     /// only viable option.
-    #[cfg(target_os = "ios", target_arch = "arm")]
+    #[cfg(all(target_os = "ios", target_arch = "arm"))]
     #[inline(never)]
     pub fn write(w: &mut Writer) -> IoResult<()> {
         use iter::{Iterator, range};
@@ -284,7 +284,7 @@ fn backtrace(buf: *mut *mut libc::c_void,
         result::fold(iter, (), |_, _| ())
     }
 
-    #[cfg(not(target_os = "ios", target_arch = "arm"))]
+    #[cfg(not(all(target_os = "ios", target_arch = "arm")))]
     #[inline(never)] // if we know this is a function call, we can skip it when
                      // tracing
     pub fn write(w: &mut Writer) -> IoResult<()> {
@@ -365,8 +365,7 @@ struct Context<'a> {
         }
     }
 
-    #[cfg(target_os = "macos")]
-    #[cfg(target_os = "ios")]
+    #[cfg(any(target_os = "macos", target_os = "ios"))]
     fn print(w: &mut Writer, idx: int, addr: *mut libc::c_void) -> IoResult<()> {
         use intrinsics;
         #[repr(C)]
@@ -391,7 +390,7 @@ fn dladdr(addr: *const libc::c_void,
         }
     }
 
-    #[cfg(not(target_os = "macos"), not(target_os = "ios"))]
+    #[cfg(not(any(target_os = "macos", target_os = "ios")))]
     fn print(w: &mut Writer, idx: int, addr: *mut libc::c_void) -> IoResult<()> {
         use collections::Collection;
         use iter::Iterator;
@@ -571,16 +570,17 @@ pub enum _Unwind_Context {}
 
         extern {
             // No native _Unwind_Backtrace on iOS
-            #[cfg(not(target_os = "ios", target_arch = "arm"))]
+            #[cfg(not(all(target_os = "ios", target_arch = "arm")))]
             pub fn _Unwind_Backtrace(trace: _Unwind_Trace_Fn,
                                      trace_argument: *mut libc::c_void)
                         -> _Unwind_Reason_Code;
 
-            #[cfg(not(target_os = "android"),
-                  not(target_os = "linux", target_arch = "arm"))]
+            #[cfg(all(not(target_os = "android"),
+                      not(all(target_os = "linux", target_arch = "arm"))))]
             pub fn _Unwind_GetIP(ctx: *mut _Unwind_Context) -> libc::uintptr_t;
-            #[cfg(not(target_os = "android"),
-                  not(target_os = "linux", target_arch = "arm"))]
+
+            #[cfg(all(not(target_os = "android"),
+                      not(all(target_os = "linux", target_arch = "arm"))))]
             pub fn _Unwind_FindEnclosingFunction(pc: *mut libc::c_void)
                 -> *mut libc::c_void;
         }
@@ -588,8 +588,8 @@ pub fn _Unwind_FindEnclosingFunction(pc: *mut libc::c_void)
         // On android, the function _Unwind_GetIP is a macro, and this is the
         // expansion of the macro. This is all copy/pasted directly from the
         // header file with the definition of _Unwind_GetIP.
-        #[cfg(target_os = "android")]
-        #[cfg(target_os = "linux", target_arch = "arm")]
+        #[cfg(any(target_os = "android",
+                  all(target_os = "linux", target_arch = "arm")))]
         pub unsafe fn _Unwind_GetIP(ctx: *mut _Unwind_Context) -> libc::uintptr_t {
             #[repr(C)]
             enum _Unwind_VRS_Result {
@@ -634,8 +634,8 @@ fn _Unwind_VRS_Get(ctx: *mut _Unwind_Context,
 
         // This function also doesn't exist on Android or ARM/Linux, so make it
         // a no-op
-        #[cfg(target_os = "android")]
-        #[cfg(target_os = "linux", target_arch = "arm")]
+        #[cfg(any(target_os = "android",
+                  all(target_os = "linux", target_arch = "arm")))]
         pub unsafe fn _Unwind_FindEnclosingFunction(pc: *mut libc::c_void)
             -> *mut libc::c_void
         {
index 0fee3ff32185049f222e304b143f72d0cbda1961..59c824d0eae772d865e769504837e4a330c66916 100644 (file)
@@ -521,6 +521,7 @@ pub enum Expr_ {
     ExprLit(P<Lit>),
     ExprCast(P<Expr>, P<Ty>),
     ExprIf(P<Expr>, P<Block>, Option<P<Expr>>),
+    ExprIfLet(P<Pat>, P<Expr>, P<Block>, Option<P<Expr>>),
     // FIXME #6993: change to Option<Name> ... or not, if these are hygienic.
     ExprWhile(P<Expr>, P<Block>, Option<Ident>),
     // FIXME #6993: change to Option<Name> ... or not, if these are hygienic.
@@ -528,7 +529,7 @@ pub enum Expr_ {
     // Conditionless loop (can be exited with break, cont, or ret)
     // FIXME #6993: change to Option<Name> ... or not, if these are hygienic.
     ExprLoop(P<Block>, Option<Ident>),
-    ExprMatch(P<Expr>, Vec<Arm>),
+    ExprMatch(P<Expr>, Vec<Arm>, MatchSource),
     ExprFnBlock(CaptureClause, P<FnDecl>, P<Block>),
     ExprProc(P<FnDecl>, P<Block>),
     ExprUnboxedFn(CaptureClause, UnboxedClosureKind, P<FnDecl>, P<Block>),
@@ -576,6 +577,12 @@ pub struct QPath {
     pub item_name: Ident,
 }
 
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
+pub enum MatchSource {
+    MatchNormal,
+    MatchIfLetDesugar
+}
+
 #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum CaptureClause {
     CaptureByValue,
index efc75de7142b86965f17fdf462fba0c6715bdbae..1491f02b3f5c15833c52940b063e752f6e963a53 100644 (file)
@@ -315,14 +315,11 @@ pub fn cfg_matches(diagnostic: &SpanHandler, cfgs: &[P<MetaItem>], cfg: &ast::Me
         ast::MetaList(ref pred, ref mis) if pred.get() == "all" =>
             mis.iter().all(|mi| cfg_matches(diagnostic, cfgs, &**mi)),
         ast::MetaList(ref pred, ref mis) if pred.get() == "not" => {
-            // NOTE: turn on after snapshot
-            /*
             if mis.len() != 1 {
                 diagnostic.span_warn(cfg.span, "the use of multiple cfgs in the same `not` \
                                                 statement is deprecated. Change `not(a, b)` to \
                                                 `not(all(a, b))`.");
             }
-            */
             !mis.iter().all(|mi| cfg_matches(diagnostic, cfgs, &**mi))
         }
         ast::MetaList(ref pred, _) => {
@@ -508,7 +505,7 @@ fn int_type_of_word(s: &str) -> Option<IntType> {
     }
 }
 
-#[deriving(PartialEq, Show)]
+#[deriving(PartialEq, Show, Encodable, Decodable)]
 pub enum ReprAttr {
     ReprAny,
     ReprInt(Span, IntType),
@@ -527,7 +524,7 @@ pub fn is_ffi_safe(&self) -> bool {
     }
 }
 
-#[deriving(Eq, Hash, PartialEq, Show)]
+#[deriving(Eq, Hash, PartialEq, Show, Encodable, Decodable)]
 pub enum IntType {
     SignedInt(ast::IntTy),
     UnsignedInt(ast::UintTy)
index e9b2556c53e25dd5a86c78e3cc2d90962b6f997f..cd215c1d68c51bb9f693268515088643d1346745 100644 (file)
@@ -290,6 +290,9 @@ pub fn next_line(&self, pos: BytePos) {
     }
 
     /// get a line from the list of pre-computed line-beginnings
+    ///
+    /// NOTE(stage0, pcwalton): Remove `#[allow(unused_mut)]` after snapshot.
+    #[allow(unused_mut)]
     pub fn get_line(&self, line: int) -> String {
         let mut lines = self.lines.borrow_mut();
         let begin: BytePos = *lines.get(line as uint) - self.start_pos;
@@ -512,6 +515,8 @@ fn lookup_filemap_idx(&self, pos: BytePos) -> uint {
         return a;
     }
 
+    // NOTE(stage0, pcwalton): Remove `#[allow(unused_mut)]` after snapshot.
+    #[allow(unused_mut)]
     fn lookup_line(&self, pos: BytePos) -> FileMapAndLine {
         let idx = self.lookup_filemap_idx(pos);
 
index 5b17f6f004a081ffcb64b8b1bd935ebe6eb9f2bf..9b4748f88ab25d7ac8f8f0995e0841f4d9cb6ba7 100644 (file)
@@ -210,10 +210,10 @@ fn fold_expr(cx: &mut Context, expr: P<ast::Expr>) -> P<ast::Expr> {
         fold::noop_fold_expr(ast::Expr {
             id: id,
             node: match node {
-                ast::ExprMatch(m, arms) => {
+                ast::ExprMatch(m, arms, source) => {
                     ast::ExprMatch(m, arms.into_iter()
                                         .filter(|a| (cx.in_cfg)(a.attrs.as_slice()))
-                                        .collect())
+                                        .collect(), source)
                 }
                 _ => node
             },
@@ -260,8 +260,6 @@ fn in_cfg(diagnostic: &SpanHandler, cfg: &[P<ast::MetaItem>], attrs: &[ast::Attr
             _ => continue
         };
 
-        // NOTE: turn on after snapshot
-        /*
         if mis.len() != 1 {
             diagnostic.span_warn(attr.span, "The use of multiple cfgs in the top level of \
                                              `#[cfg(..)]` is deprecated. Change `#[cfg(a, b)]` to \
@@ -274,7 +272,6 @@ fn in_cfg(diagnostic: &SpanHandler, cfg: &[P<ast::MetaItem>], attrs: &[ast::Attr
                                              the intersection of the cfgs. Change `#[cfg(a)] \
                                              #[cfg(b)]` to `#[cfg(any(a, b))]`.");
         }
-        */
 
         seen_cfg = true;
         in_cfg |= mis.iter().all(|mi| attr::cfg_matches(diagnostic, cfg, &**mi));
index 0586868eb4584f162ea598b1b90dc04c7952a070..f2b806f43ccbbb6822fbcf0e9b37ea7a9fd18eb0 100644 (file)
@@ -845,7 +845,7 @@ fn arm_unreachable(&self, span: Span) -> ast::Arm {
     }
 
     fn expr_match(&self, span: Span, arg: P<ast::Expr>, arms: Vec<ast::Arm>) -> P<Expr> {
-        self.expr(span, ast::ExprMatch(arg, arms))
+        self.expr(span, ast::ExprMatch(arg, arms, ast::MatchNormal))
     }
 
     fn expr_if(&self, span: Span, cond: P<ast::Expr>,
index 342e7e6d52e847e18083f151f90fe8a15b3ccbaf..74039da6cabdb07037c8331be45429a847e09ff1 100644 (file)
@@ -38,14 +38,11 @@ pub fn expand_cfg<'cx>(cx: &mut ExtCtxt,
         p.expect(&token::COMMA);
     }
 
-    // NOTE: turn on after snapshot
-    /*
     if cfgs.len() != 1 {
         cx.span_warn(sp, "The use of multiple cfgs at the top level of `cfg!` \
                           is deprecated. Change `cfg!(a, b)` to \
                           `cfg!(all(a, b))`.");
     }
-    */
 
     let matches_cfg = cfgs.iter().all(|cfg| attr::cfg_matches(&cx.parse_sess.span_diagnostic,
                                                               cx.cfg.as_slice(), &**cfg));
index 9f3df1a762398223a5c9f6c8e978415baf40f45d..fa3ccc8cf326e369bcec8fc5845ba3dfde6b14ae 100644 (file)
@@ -39,7 +39,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
     e.and_then(|ast::Expr {id, node, span}| match node {
         // expr_mac should really be expr_ext or something; it's the
         // entry-point for all syntax extensions.
-        ExprMac(mac) => {
+        ast::ExprMac(mac) => {
             let expanded_expr = match expand_mac_invoc(mac, span,
                                                        |r| r.make_expr(),
                                                        mark_expr, fld) {
@@ -67,6 +67,97 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
             fld.cx.expr(span, ast::ExprWhile(cond, body, opt_ident))
         }
 
+        // Desugar ExprIfLet
+        // From: `if let <pat> = <expr> <body> [<elseopt>]`
+        ast::ExprIfLet(pat, expr, body, mut elseopt) => {
+            // to:
+            //
+            //   match <expr> {
+            //     <pat> => <body>,
+            //     [_ if <elseopt_if_cond> => <elseopt_if_body>,]
+            //     _ => [<elseopt> | ()]
+            //   }
+
+            // `<pat> => <body>`
+            let pat_arm = {
+                let body_expr = fld.cx.expr_block(body);
+                fld.cx.arm(pat.span, vec![pat], body_expr)
+            };
+
+            // `[_ if <elseopt_if_cond> => <elseopt_if_body>,]`
+            let else_if_arms = {
+                let mut arms = vec![];
+                loop {
+                    let elseopt_continue = elseopt
+                        .and_then(|els| els.and_then(|els| match els.node {
+                        // else if
+                        ast::ExprIf(cond, then, elseopt) => {
+                            let pat_under = fld.cx.pat_wild(span);
+                            arms.push(ast::Arm {
+                                attrs: vec![],
+                                pats: vec![pat_under],
+                                guard: Some(cond),
+                                body: fld.cx.expr_block(then)
+                            });
+                            elseopt.map(|elseopt| (elseopt, true))
+                        }
+                        _ => Some((P(els), false))
+                    }));
+                    match elseopt_continue {
+                        Some((e, true)) => {
+                            elseopt = Some(e);
+                        }
+                        Some((e, false)) => {
+                            elseopt = Some(e);
+                            break;
+                        }
+                        None => {
+                            elseopt = None;
+                            break;
+                        }
+                    }
+                }
+                arms
+            };
+
+            // `_ => [<elseopt> | ()]`
+            let else_arm = {
+                let pat_under = fld.cx.pat_wild(span);
+                let else_expr = elseopt.unwrap_or_else(|| fld.cx.expr_lit(span, ast::LitNil));
+                fld.cx.arm(span, vec![pat_under], else_expr)
+            };
+
+            let mut arms = Vec::with_capacity(else_if_arms.len() + 2);
+            arms.push(pat_arm);
+            arms.push_all_move(else_if_arms);
+            arms.push(else_arm);
+
+            let match_expr = fld.cx.expr(span, ast::ExprMatch(expr, arms, ast::MatchIfLetDesugar));
+            fld.fold_expr(match_expr)
+        }
+
+        // Desugar support for ExprIfLet in the ExprIf else position
+        ast::ExprIf(cond, blk, elseopt) => {
+            let elseopt = elseopt.map(|els| els.and_then(|els| match els.node {
+                ast::ExprIfLet(..) => {
+                    // wrap the if-let expr in a block
+                    let span = els.span;
+                    let blk = P(ast::Block {
+                        view_items: vec![],
+                        stmts: vec![],
+                        expr: Some(P(els)),
+                        id: ast::DUMMY_NODE_ID,
+                        rules: ast::DefaultBlock,
+                        span: span
+                    });
+                    fld.cx.expr_block(blk)
+                }
+                _ => P(els)
+            }));
+            let if_expr = fld.cx.expr(span, ast::ExprIf(cond, blk, elseopt));
+            if_expr.map(|e| noop_fold_expr(e, fld))
+        }
+
         ast::ExprLoop(loop_block, opt_ident) => {
             let (loop_block, opt_ident) = expand_loop_block(loop_block, opt_ident, fld);
             fld.cx.expr(span, ast::ExprLoop(loop_block, opt_ident))
index 1c6ee8acc94a59077a2054fa2b9920288c183b7e..ca6d488772c613b520e641fb0f7887c63250c577 100644 (file)
@@ -71,6 +71,8 @@
     ("associated_types", Active),
     ("visible_private_types", Active),
 
+    ("if_let", Active),
+
     // if you change this list without updating src/doc/rust.md, cmr will be sad
 
     // A temporary feature gate used to enable parser extensions needed
@@ -356,6 +358,10 @@ fn visit_expr(&mut self, e: &ast::Expr) {
                                   e.span,
                                   "tuple indexing is experimental");
             }
+            ast::ExprIfLet(..) => {
+                self.gate_feature("if_let", e.span,
+                                  "`if let` syntax is experimental");
+            }
             _ => {}
         }
         visit::walk_expr(self, e);
index 53be7f2c20c4ea6a545adbc606d21466f33b62bc..31bec58a4daa6f24afd9b9c3e151fb686108c0a1 100644 (file)
@@ -1205,6 +1205,12 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
                        folder.fold_block(tr),
                        fl.map(|x| folder.fold_expr(x)))
             }
+            ExprIfLet(pat, expr, tr, fl) => {
+                ExprIfLet(folder.fold_pat(pat),
+                          folder.fold_expr(expr),
+                          folder.fold_block(tr),
+                          fl.map(|x| folder.fold_expr(x)))
+            }
             ExprWhile(cond, body, opt_ident) => {
                 ExprWhile(folder.fold_expr(cond),
                           folder.fold_block(body),
@@ -1220,9 +1226,10 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
                 ExprLoop(folder.fold_block(body),
                         opt_ident.map(|i| folder.fold_ident(i)))
             }
-            ExprMatch(expr, arms) => {
+            ExprMatch(expr, arms, source) => {
                 ExprMatch(folder.fold_expr(expr),
-                        arms.move_map(|x| folder.fold_arm(x)))
+                        arms.move_map(|x| folder.fold_arm(x)),
+                        source)
             }
             ExprFnBlock(capture_clause, decl, body) => {
                 ExprFnBlock(capture_clause,
index cdd221aca7cf01b72a94b2a255379af8682f5466..cb57318445e4164c600d512ec01c5af24a8a9436 100644 (file)
@@ -24,6 +24,7 @@
 pub fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool {
     match e.node {
         ast::ExprIf(..)
+        | ast::ExprIfLet(..)
         | ast::ExprMatch(..)
         | ast::ExprBlock(_)
         | ast::ExprWhile(..)
index 68ddd17dd012b4917e15f9ae810c5e9b08d29156..38c985af37082372b4aa3d2af68fe9f34a82b285 100644 (file)
@@ -637,7 +637,7 @@ fn scan_number(&mut self, c: char) -> token::Token {
                 'b' => { self.bump(); base = 2; num_digits = self.scan_digits(2); }
                 'o' => { self.bump(); base = 8; num_digits = self.scan_digits(8); }
                 'x' => { self.bump(); base = 16; num_digits = self.scan_digits(16); }
-                '0'..'9' | '_' | '.' => {
+                '0'...'9' | '_' | '.' => {
                     num_digits = self.scan_digits(10) + 1;
                 }
                 'u' | 'i' => {
index 415ff6a4097ac521a4d38d700073d8e203c10181..c8f1b7f9a8e6d39484af667fdd7f0a393c5f02c3 100644 (file)
@@ -23,7 +23,7 @@
 use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain};
 use ast::{ExprAssign, ExprAssignOp, ExprBinary, ExprBlock, ExprBox};
 use ast::{ExprBreak, ExprCall, ExprCast};
-use ast::{ExprField, ExprTupField, ExprFnBlock, ExprIf, ExprIndex, ExprSlice};
+use ast::{ExprField, ExprTupField, ExprFnBlock, ExprIf, ExprIfLet, ExprIndex, ExprSlice};
 use ast::{ExprLit, ExprLoop, ExprMac};
 use ast::{ExprMethodCall, ExprParen, ExprPath, ExprProc};
 use ast::{ExprRepeat, ExprRet, ExprStruct, ExprTup, ExprUnary, ExprUnboxedFn};
@@ -38,7 +38,7 @@
 use ast::{LifetimeDef, Lit, Lit_};
 use ast::{LitBool, LitChar, LitByte, LitBinary};
 use ast::{LitNil, LitStr, LitInt, Local, LocalLet};
-use ast::{MutImmutable, MutMutable, Mac_, MacInvocTT, Matcher, MatchNonterminal};
+use ast::{MutImmutable, MutMutable, Mac_, MacInvocTT, Matcher, MatchNonterminal, MatchNormal};
 use ast::{MatchSeq, MatchTok, Method, MutTy, BiMul, Mutability};
 use ast::{MethodImplItem, NamedField, UnNeg, NoReturn, UnNot};
 use ast::{Pat, PatEnum, PatIdent, PatLit, PatRange, PatRegion, PatStruct};
@@ -576,12 +576,11 @@ pub fn is_keyword(&mut self, kw: keywords::Keyword) -> bool {
     /// If the next token is the given keyword, eat it and return
     /// true. Otherwise, return false.
     pub fn eat_keyword(&mut self, kw: keywords::Keyword) -> bool {
-        match self.token {
-            token::IDENT(sid, false) if kw.to_name() == sid.name => {
-                self.bump();
-                true
-            }
-            _ => false
+        if self.is_keyword(kw) {
+            self.bump();
+            true
+        } else {
+            false
         }
     }
 
@@ -2860,8 +2859,11 @@ pub fn parse_assign_expr(&mut self) -> P<Expr> {
         }
     }
 
-    /// Parse an 'if' expression ('if' token already eaten)
+    /// Parse an 'if' or 'if let' expression ('if' token already eaten)
     pub fn parse_if_expr(&mut self) -> P<Expr> {
+        if self.is_keyword(keywords::Let) {
+            return self.parse_if_let_expr();
+        }
         let lo = self.last_span.lo;
         let cond = self.parse_expr_res(RestrictionNoStructLiteral);
         let thn = self.parse_block();
@@ -2875,6 +2877,23 @@ pub fn parse_if_expr(&mut self) -> P<Expr> {
         self.mk_expr(lo, hi, ExprIf(cond, thn, els))
     }
 
+    /// Parse an 'if let' expression ('if' token already eaten)
+    pub fn parse_if_let_expr(&mut self) -> P<Expr> {
+        let lo = self.last_span.lo;
+        self.expect_keyword(keywords::Let);
+        let pat = self.parse_pat();
+        self.expect(&token::EQ);
+        let expr = self.parse_expr_res(RestrictionNoStructLiteral);
+        let thn = self.parse_block();
+        let (hi, els) = if self.eat_keyword(keywords::Else) {
+            let expr = self.parse_else_expr();
+            (expr.span.hi, Some(expr))
+        } else {
+            (thn.span.hi, None)
+        };
+        self.mk_expr(lo, hi, ExprIfLet(pat, expr, thn, els))
+    }
+
     // `|args| expr`
     pub fn parse_lambda_expr(&mut self, capture_clause: CaptureClause)
                              -> P<Expr> {
@@ -2956,7 +2975,7 @@ fn parse_match_expr(&mut self) -> P<Expr> {
         }
         let hi = self.span.hi;
         self.bump();
-        return self.mk_expr(lo, hi, ExprMatch(discriminant, arms));
+        return self.mk_expr(lo, hi, ExprMatch(discriminant, arms, MatchNormal));
     }
 
     pub fn parse_arm(&mut self) -> Arm {
@@ -3237,8 +3256,7 @@ pub fn parse_pat(&mut self) -> P<Pat> {
             // These expressions are limited to literals (possibly
             // preceded by unary-minus) or identifiers.
             let val = self.parse_literal_maybe_minus();
-            // FIXME(#17295) remove the DOTDOT option.
-            if (self.token == token::DOTDOTDOT || self.token == token::DOTDOT) &&
+            if (self.token == token::DOTDOTDOT) &&
                     self.look_ahead(1, |t| {
                         *t != token::COMMA && *t != token::RBRACKET
                     }) {
@@ -3283,16 +3301,12 @@ pub fn parse_pat(&mut self) -> P<Pat> {
                 }
             });
 
-            // FIXME(#17295) remove the DOTDOT option.
-            if self.look_ahead(1, |t| *t == token::DOTDOTDOT || *t == token::DOTDOT) &&
+            if self.look_ahead(1, |t| *t == token::DOTDOTDOT) &&
                     self.look_ahead(2, |t| {
                         *t != token::COMMA && *t != token::RBRACKET
                     }) {
                 let start = self.parse_expr_res(RestrictionNoBarOp);
-                // FIXME(#17295) remove the DOTDOT option (self.eat(&token::DOTDOTDOT)).
-                if self.token == token::DOTDOTDOT || self.token == token::DOTDOT {
-                    self.bump();
-                }
+                self.eat(&token::DOTDOTDOT);
                 let end = self.parse_expr_res(RestrictionNoBarOp);
                 pat = PatRange(start, end);
             } else if is_plain_ident(&self.token) && !can_be_enum_or_struct {
index ae4ba611bab5317424266b6a14c65e6358eb4dbb..a8e99b4e85f2bd36db5ca49e4e866962d6fb4ea3 100644 (file)
@@ -1307,6 +1307,19 @@ fn print_else(&mut self, els: Option<&ast::Expr>) -> IoResult<()> {
                         try!(self.print_block(&**then));
                         self.print_else(e.as_ref().map(|e| &**e))
                     }
+                    // "another else-if-let"
+                    ast::ExprIfLet(ref pat, ref expr, ref then, ref e) => {
+                        try!(self.cbox(indent_unit - 1u));
+                        try!(self.ibox(0u));
+                        try!(word(&mut self.s, " else if let "));
+                        try!(self.print_pat(&**pat));
+                        try!(space(&mut self.s));
+                        try!(self.word_space("="));
+                        try!(self.print_expr(&**expr));
+                        try!(space(&mut self.s));
+                        try!(self.print_block(&**then));
+                        self.print_else(e.as_ref().map(|e| &**e))
+                    }
                     // "final else"
                     ast::ExprBlock(ref b) => {
                         try!(self.cbox(indent_unit - 1u));
@@ -1325,15 +1338,26 @@ fn print_else(&mut self, els: Option<&ast::Expr>) -> IoResult<()> {
     }
 
     pub fn print_if(&mut self, test: &ast::Expr, blk: &ast::Block,
-                    elseopt: Option<&ast::Expr>, chk: bool) -> IoResult<()> {
+                    elseopt: Option<&ast::Expr>) -> IoResult<()> {
         try!(self.head("if"));
-        if chk { try!(self.word_nbsp("check")); }
         try!(self.print_expr(test));
         try!(space(&mut self.s));
         try!(self.print_block(blk));
         self.print_else(elseopt)
     }
 
+    pub fn print_if_let(&mut self, pat: &ast::Pat, expr: &ast::Expr, blk: &ast::Block,
+                        elseopt: Option<&ast::Expr>) -> IoResult<()> {
+        try!(self.head("if let"));
+        try!(self.print_pat(pat));
+        try!(space(&mut self.s));
+        try!(self.word_space("="));
+        try!(self.print_expr(expr));
+        try!(space(&mut self.s));
+        try!(self.print_block(blk));
+        self.print_else(elseopt)
+    }
+
     pub fn print_mac(&mut self, m: &ast::Mac) -> IoResult<()> {
         match m.node {
             // I think it's reasonable to hide the ctxt here:
@@ -1474,7 +1498,10 @@ pub fn print_expr(&mut self, expr: &ast::Expr) -> IoResult<()> {
                 try!(self.print_type(&**ty));
             }
             ast::ExprIf(ref test, ref blk, ref elseopt) => {
-                try!(self.print_if(&**test, &**blk, elseopt.as_ref().map(|e| &**e), false));
+                try!(self.print_if(&**test, &**blk, elseopt.as_ref().map(|e| &**e)));
+            }
+            ast::ExprIfLet(ref pat, ref expr, ref blk, ref elseopt) => {
+                try!(self.print_if_let(&**pat, &**expr, &** blk, elseopt.as_ref().map(|e| &**e)));
             }
             ast::ExprWhile(ref test, ref blk, opt_ident) => {
                 for ident in opt_ident.iter() {
@@ -1508,7 +1535,7 @@ pub fn print_expr(&mut self, expr: &ast::Expr) -> IoResult<()> {
                 try!(space(&mut self.s));
                 try!(self.print_block(&**blk));
             }
-            ast::ExprMatch(ref expr, ref arms) => {
+            ast::ExprMatch(ref expr, ref arms, _) => {
                 try!(self.cbox(indent_unit));
                 try!(self.ibox(4));
                 try!(self.word_nbsp("match"));
index 3b2ed30b76d89866855fc03086ce30ae0a7552c7..6fc79e2c42ab9f2bff799a8e5fbabe2c96c5bd4d 100644 (file)
@@ -730,13 +730,19 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
             visitor.visit_expr(&**subexpression);
             visitor.visit_block(&**block)
         }
+        ExprIfLet(ref pattern, ref subexpression, ref if_block, ref optional_else) => {
+            visitor.visit_pat(&**pattern);
+            visitor.visit_expr(&**subexpression);
+            visitor.visit_block(&**if_block);
+            walk_expr_opt(visitor, optional_else);
+        }
         ExprForLoop(ref pattern, ref subexpression, ref block, _) => {
             visitor.visit_pat(&**pattern);
             visitor.visit_expr(&**subexpression);
             visitor.visit_block(&**block)
         }
         ExprLoop(ref block, _) => visitor.visit_block(&**block),
-        ExprMatch(ref subexpression, ref arms) => {
+        ExprMatch(ref subexpression, ref arms, _) => {
             visitor.visit_expr(&**subexpression);
             for arm in arms.iter() {
                 visitor.visit_arm(arm)
index 3f626d716f88bcb2c4bf13ad656dc2e00308f151..736cacbdeb78a36b959d940598752d639361b6a0 100644 (file)
@@ -256,7 +256,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
                         if res.is_err() { return res }
                         output.push_all(res.unwrap().as_slice())
                     } else { return Err("stack is empty".to_string()) },
-                    ':'|'#'|' '|'.'|'0'..'9' => {
+                    ':'|'#'|' '|'.'|'0'...'9' => {
                         let mut flags = Flags::new();
                         let mut fstate = FormatStateFlags;
                         match cur {
@@ -264,7 +264,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
                             '#' => flags.alternate = true,
                             ' ' => flags.space = true,
                             '.' => fstate = FormatStatePrecision,
-                            '0'..'9' => {
+                            '0'...'9' => {
                                 flags.width = cur as uint - '0' as uint;
                                 fstate = FormatStateWidth;
                             }
@@ -339,7 +339,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
                         stack.push(Number(i));
                         state = Nothing;
                     }
-                    '0'..'9' => {
+                    '0'...'9' => {
                         state = IntConstant(i*10 + (cur as int - '0' as int));
                         old_state = Nothing;
                     }
@@ -368,14 +368,14 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
                     (FormatStateFlags,' ') => {
                         flags.space = true;
                     }
-                    (FormatStateFlags,'0'..'9') => {
+                    (FormatStateFlags,'0'...'9') => {
                         flags.width = cur as uint - '0' as uint;
                         *fstate = FormatStateWidth;
                     }
                     (FormatStateFlags,'.') => {
                         *fstate = FormatStatePrecision;
                     }
-                    (FormatStateWidth,'0'..'9') => {
+                    (FormatStateWidth,'0'...'9') => {
                         let old = flags.width;
                         flags.width = flags.width * 10 + (cur as uint - '0' as uint);
                         if flags.width < old { return Err("format width overflow".to_string()) }
@@ -383,7 +383,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
                     (FormatStateWidth,'.') => {
                         *fstate = FormatStatePrecision;
                     }
-                    (FormatStatePrecision,'0'..'9') => {
+                    (FormatStatePrecision,'0'...'9') => {
                         let old = flags.precision;
                         flags.precision = flags.precision * 10 + (cur as uint - '0' as uint);
                         if flags.precision < old {
index 9cec71104d403f3efe66f7784dabfb37f7e4070f..6ca33f0dabc7ca28078d474a529bd2353137c2f0 100644 (file)
@@ -47,7 +47,7 @@ mod rustrt {
     }
 }
 
-#[cfg(unix, not(target_os = "macos"), not(target_os = "ios"))]
+#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios")))]
 mod imp {
     use libc::{c_int, timespec};
 
@@ -61,8 +61,7 @@ mod imp {
     }
 
 }
-#[cfg(target_os = "macos")]
-#[cfg(target_os = "ios")]
+#[cfg(any(target_os = "macos", target_os = "ios"))]
 mod imp {
     use libc::{timeval, timezone, c_int, mach_timebase_info};
 
@@ -150,8 +149,7 @@ unsafe fn os_get_time() -> (i64, i32) {
          ((ns_since_1970 % 1000000) * 1000) as i32)
     }
 
-    #[cfg(target_os = "macos")]
-    #[cfg(target_os = "ios")]
+    #[cfg(any(target_os = "macos", target_os = "ios"))]
     unsafe fn os_get_time() -> (i64, i32) {
         use std::ptr;
         let mut tv = libc::timeval { tv_sec: 0, tv_usec: 0 };
@@ -159,7 +157,7 @@ unsafe fn os_get_time() -> (i64, i32) {
         (tv.tv_sec as i64, tv.tv_usec * 1000)
     }
 
-    #[cfg(not(target_os = "macos"), not(target_os = "ios"), not(windows))]
+    #[cfg(not(any(target_os = "macos", target_os = "ios", windows)))]
     unsafe fn os_get_time() -> (i64, i32) {
         let mut tv = libc::timespec { tv_sec: 0, tv_nsec: 0 };
         imp::clock_gettime(libc::CLOCK_REALTIME, &mut tv);
@@ -190,8 +188,7 @@ fn os_precise_time_ns() -> u64 {
         return (ticks as u64 * 1000000000) / (ticks_per_s as u64);
     }
 
-    #[cfg(target_os = "macos")]
-    #[cfg(target_os = "ios")]
+    #[cfg(any(target_os = "macos", target_os = "ios"))]
     fn os_precise_time_ns() -> u64 {
         static mut TIMEBASE: libc::mach_timebase_info = libc::mach_timebase_info { numer: 0,
                                                                                    denom: 0 };
@@ -205,7 +202,7 @@ fn os_precise_time_ns() -> u64 {
         }
     }
 
-    #[cfg(not(windows), not(target_os = "macos"), not(target_os = "ios"))]
+    #[cfg(not(any(windows, target_os = "macos", target_os = "ios")))]
     fn os_precise_time_ns() -> u64 {
         let mut ts = libc::timespec { tv_sec: 0, tv_nsec: 0 };
         unsafe {
@@ -447,7 +444,7 @@ fn match_digits(ss: &str, pos: uint, digits: uint, ws: bool)
             pos = range.next;
 
             match range.ch {
-              '0' .. '9' => {
+              '0' ... '9' => {
                 value = value * 10_i32 + (range.ch as i32 - '0' as i32);
               }
               ' ' if ws => (),
@@ -472,7 +469,7 @@ fn match_fractional_seconds(ss: &str, pos: uint) -> (i32, uint) {
             let range = ss.char_range_at(pos);
 
             match range.ch {
-                '0' .. '9' => {
+                '0' ... '9' => {
                     pos = range.next;
                     // This will drop digits after the nanoseconds place
                     let digit = range.ch as i32 - '0' as i32;
index d866514385452b1b52823488550ee7c6f866f34b..f725cdba64ef5f0ff1f95b124967c99e731d4d30 100644 (file)
@@ -22,7 +22,7 @@
 /// code point
 pub fn is_alphabetic(c: char) -> bool {
     match c {
-        'a' .. 'z' | 'A' .. 'Z' => true,
+        'a' ... 'z' | 'A' ... 'Z' => true,
         c if c > '\x7f' => derived_property::Alphabetic(c),
         _ => false
     }
@@ -52,7 +52,7 @@ pub fn is_XID_continue(c: char) -> bool { derived_property::XID_Continue(c) }
 #[inline]
 pub fn is_lowercase(c: char) -> bool {
     match c {
-        'a' .. 'z' => true,
+        'a' ... 'z' => true,
         c if c > '\x7f' => derived_property::Lowercase(c),
         _ => false
     }
@@ -66,7 +66,7 @@ pub fn is_lowercase(c: char) -> bool {
 #[inline]
 pub fn is_uppercase(c: char) -> bool {
     match c {
-        'A' .. 'Z' => true,
+        'A' ... 'Z' => true,
         c if c > '\x7f' => derived_property::Uppercase(c),
         _ => false
     }
@@ -80,7 +80,7 @@ pub fn is_uppercase(c: char) -> bool {
 #[inline]
 pub fn is_whitespace(c: char) -> bool {
     match c {
-        ' ' | '\x09' .. '\x0d' => true,
+        ' ' | '\x09' ... '\x0d' => true,
         c if c > '\x7f' => property::White_Space(c),
         _ => false
     }
@@ -111,7 +111,7 @@ pub fn is_control(c: char) -> bool { general_category::Cc(c) }
 #[inline]
 pub fn is_digit(c: char) -> bool {
     match c {
-        '0' .. '9' => true,
+        '0' ... '9' => true,
         c if c > '\x7f' => general_category::N(c),
         _ => false
     }
index 0b227b68ca8968d0082bd777e2320f7ad926e283..cb4940861ebc5dca3063f08b49e52e3a34a7eff5 100644 (file)
@@ -190,9 +190,9 @@ fn encode_inner<T: BytesContainer>(c: T, full_url: bool) -> String {
     c.container_as_bytes().iter().fold(String::new(), |mut out, &b| {
         match b as char {
             // unreserved:
-            'A' .. 'Z'
-            | 'a' .. 'z'
-            | '0' .. '9'
+            'A' ... 'Z'
+            | 'a' ... 'z'
+            | '0' ... '9'
             | '-' | '.' | '_' | '~' => out.push_char(b as char),
 
             // gen-delims:
@@ -303,9 +303,9 @@ pub fn encode_form_urlencoded(m: &HashMap<String, Vec<String>>) -> String {
     fn encode_plus<T: Str>(s: &T) -> String {
         s.as_slice().bytes().fold(String::new(), |mut out, b| {
             match b as char {
-              'A' .. 'Z'
-              | 'a' .. 'z'
-              | '0' .. '9'
+              'A' ... 'Z'
+              | 'a' ... 'z'
+              | '0' ... '9'
               | '_' | '.' | '-' => out.push_char(b as char),
               ' ' => out.push_char('+'),
               ch => out.push_str(format!("%{:X}", ch as uint).as_slice())
@@ -473,9 +473,9 @@ pub fn query_to_str(query: &Query) -> String {
 pub fn get_scheme(rawurl: &str) -> DecodeResult<(&str, &str)> {
     for (i,c) in rawurl.chars().enumerate() {
         let result = match c {
-            'A' .. 'Z'
-            | 'a' .. 'z' => continue,
-            '0' .. '9' | '+' | '-' | '.' => {
+            'A' ... 'Z'
+            | 'a' ... 'z' => continue,
+            '0' ... '9' | '+' | '-' | '.' => {
                 if i != 0 { continue }
 
                 Err("url: Scheme must begin with a letter.".to_string())
@@ -538,15 +538,15 @@ enum Input {
                                .skip(2) {
         // deal with input class first
         match c {
-            '0' .. '9' => (),
-            'A' .. 'F'
-            | 'a' .. 'f' => {
+            '0' ... '9' => (),
+            'A' ... 'F'
+            | 'a' ... 'f' => {
                 if input == Digit {
                     input = Hex;
                 }
             }
-            'G' .. 'Z'
-            | 'g' .. 'z'
+            'G' ... 'Z'
+            | 'g' ... 'z'
             | '-' | '.' | '_' | '~' | '%'
             | '&' |'\'' | '(' | ')' | '+'
             | '!' | '*' | ',' | ';' | '=' => input = Unreserved,
@@ -671,9 +671,9 @@ fn get_path(rawurl: &str, is_authority: bool) -> DecodeResult<(String, &str)> {
     let mut end = len;
     for (i,c) in rawurl.chars().enumerate() {
         match c {
-          'A' .. 'Z'
-          | 'a' .. 'z'
-          | '0' .. '9'
+          'A' ... 'Z'
+          | 'a' ... 'z'
+          | '0' ... '9'
           | '&' |'\'' | '(' | ')' | '.'
           | '@' | ':' | '%' | '/' | '+'
           | '!' | '*' | ',' | ';' | '='
index 09dc8166908d92061944c4783888630f777fe38b..f728205c3a57f58068aa8a9f6b130b0d2ab0e5dd 100644 (file)
@@ -387,7 +387,7 @@ pub fn parse_string(us: &str) -> Result<Uuid, ParseError> {
         // Make sure all chars are either hex digits or hyphen
         for (i, c) in us.chars().enumerate() {
             match c {
-                '0'..'9' | 'A'..'F' | 'a'..'f' | '-' => {},
+                '0'...'9' | 'A'...'F' | 'a'...'f' | '-' => {},
                 _ => return Err(ErrorInvalidCharacter(c, i)),
             }
         }
diff --git a/src/test/auxiliary/issue-12660-aux.rs b/src/test/auxiliary/issue-12660-aux.rs
new file mode 100644 (file)
index 0000000..9f2bd5d
--- /dev/null
@@ -0,0 +1,21 @@
+// 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.
+
+#![crate_type="lib"]
+#![crate_name="issue12660aux"]
+
+pub use my_mod::{MyStruct, my_fn};
+
+mod my_mod {
+    pub struct MyStruct;
+
+    pub fn my_fn(my_struct: MyStruct) {
+    }
+}
diff --git a/src/test/compile-fail/if-let.rs b/src/test/compile-fail/if-let.rs
new file mode 100644 (file)
index 0000000..b82fb7a
--- /dev/null
@@ -0,0 +1,57 @@
+// 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.
+
+#![feature(macro_rules,if_let)]
+
+fn macros() {
+    macro_rules! foo{
+        ($p:pat, $e:expr, $b:block) => {{
+            if let $p = $e $b
+        }}
+    }
+    macro_rules! bar{
+        ($p:pat, $e:expr, $b:block) => {{
+            foo!($p, $e, $b)
+        }}
+    }
+
+    foo!(a, 1i, { //~ ERROR irrefutable if-let
+        println!("irrefutable pattern");
+    });
+    bar!(a, 1i, { //~ ERROR irrefutable if-let
+        println!("irrefutable pattern");
+    });
+}
+
+pub fn main() {
+    if let a = 1i { //~ ERROR irrefutable if-let
+        println!("irrefutable pattern");
+    }
+
+    if let a = 1i { //~ ERROR irrefutable if-let
+        println!("irrefutable pattern");
+    } else if true {
+        println!("else-if in irrefutable if-let");
+    } else {
+        println!("else in irrefutable if-let");
+    }
+
+    if let 1i = 2i {
+        println!("refutable pattern");
+    } else if let a = 1i { //~ ERROR irrefutable if-let
+        println!("irrefutable pattern");
+    }
+
+    if true {
+        println!("if");
+    } else if let a = 1i { //~ ERROR irrefutable if-let
+        println!("irrefutable pattern");
+    }
+}
diff --git a/src/test/compile-fail/lang-item-missing.rs b/src/test/compile-fail/lang-item-missing.rs
new file mode 100644 (file)
index 0000000..bcde10a
--- /dev/null
@@ -0,0 +1,21 @@
+// 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.
+
+// Test that a missing lang item (in this case `sized`) does not cause an ICE,
+// see #17392.
+
+// error-pattern: requires `sized` lang_item
+
+#![no_std]
+
+#[start]
+fn start(argc: int, argv: *const *const u8) -> int {
+    0
+}
index d51d5b4af87a99ce05ed2f15398deb1e08b757a4..3c962ebf21670190f429673cffe059865a093622 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 #![deny(unnecessary_parens)]
+#![feature(if_let)]
 
 #[deriving(Eq, PartialEq)]
 struct X { y: bool }
@@ -32,6 +33,7 @@ fn main() {
     match (true) { //~ ERROR unnecessary parentheses around `match` head expression
         _ => {}
     }
+    if let 1i = (1i) {} //~ ERROR unnecessary parentheses around `if let` head expression
     let v = X { y: false };
     // struct lits needs parens, so these shouldn't warn.
     if (v == X { y: true }) {}
index 5ffcb26e12ed53b549e2098a8cba19d71826f56d..2b4c77bf9e8734a4dfbc56d53680e108b87cfaba 100644 (file)
@@ -10,7 +10,7 @@
 
 fn main() {
     match 1 {
-        1..2u => 1, //~ ERROR mismatched types in range
+        1...2u => 1, //~ ERROR mismatched types in range
         _ => 2,
     };
 }
index 7c9c371c5267436934b911bdbbe97a30dfda1e37..7a4451f99ab0cb7871b10c8465c17d49cfbd3e8f 100644 (file)
 
 fn main() {
     match 5u {
-      1u .. 10u => { }
-      5u .. 6u => { }
+      1u ... 10u => { }
+      5u ... 6u => { }
       _ => {}
     };
 
     match 5u {
-      3u .. 6u => { }
-      4u .. 6u => { }
+      3u ... 6u => { }
+      4u ... 6u => { }
       _ => {}
     };
 
     match 5u {
-      4u .. 6u => { }
-      4u .. 6u => { }
+      4u ... 6u => { }
+      4u ... 6u => { }
       _ => {}
     };
 
     match 'c' {
-      'A' .. 'z' => {}
-      'a' .. 'z' => {}
+      'A' ... 'z' => {}
+      'a' ... 'z' => {}
       _ => {}
     };
 
     match 1.0f64 {
-      0.01f64 .. 6.5f64 => {}
+      0.01f64 ... 6.5f64 => {}
       0.02f64 => {}
       _ => {}
     };
index 5ac1eb8572fda197bcba8b6d00135955902d14c1..9fbd1545fcf6769569c69ddf3bb92556c35b069b 100644 (file)
 
 fn main() {
     match 5u {
-      6u .. 1u => { }
+      6u ... 1u => { }
       _ => { }
     };
 
     match "wow" {
-      "bar" .. "foo" => { }
+      "bar" ... "foo" => { }
     };
 
     match 5u {
-      'c' .. 100u => { }
+      'c' ... 100u => { }
       _ => { }
     };
 }
index 28533518a25a1be656c3e1246dba83bbd6ca4b2a..98d616ee3afb56629ee8a547fdd307fb436e2a53 100644 (file)
@@ -9,10 +9,10 @@
 // except according to those terms.
 
 
-fn func((1, (Some(1), 2..3)): (int, (Option<int>, int))) { }
+fn func((1, (Some(1), 2...3)): (int, (Option<int>, int))) { }
 //~^ ERROR refutable pattern in function argument: `(_, _)` not covered
 
 fn main() {
-    let (1i, (Some(1i), 2i..3i)) = (1i, (None, 2i));
+    let (1i, (Some(1i), 2i...3i)) = (1i, (None, 2i));
     //~^ ERROR refutable pattern in local binding: `(_, _)` not covered
 }
index 3b152cd3c1a8c2e265f928a1e1b79ffe0ac5145e..02ac01c6813e4921fb172786da447fc38b56cdce 100644 (file)
@@ -9,12 +9,13 @@
 // except according to those terms.
 
 // ignore-android: FIXME(#10381)
+// ignore-windows failing on 64-bit bots FIXME #17638
 
 // compile-flags:-g
-// gdb-command:break issue12886.rs:29
+// gdb-command:break issue12886.rs:30
 // gdb-command:run
 // gdb-command:next
-// gdb-check:[...]30[...]s
+// gdb-check:[...]31[...]s
 // gdb-command:continue
 
 // IF YOU MODIFY THIS FILE, BE CAREFUL TO ADAPT THE LINE NUMBERS IN THE DEBUGGER COMMANDS
index 058dc426766bce81c451211b61554fdb230b4833..aa45bfd14541cded421085bd0d12c309baabf2e7 100644 (file)
@@ -33,7 +33,7 @@ pub fn main() {
     }
 
     match 100 {
-        b'a' .. b'z' => {},
+        b'a' ... b'z' => {},
         _ => fail!()
     }
 
index d59c24e07b8f75778ddd527673c318fbc8b9f470..465529ac90941e1006bc0375aa56c3d344127f8a 100644 (file)
@@ -27,7 +27,6 @@ fn deref_mut(&mut self) -> &mut [uint] {
 }
 
 pub fn foo(arr: &mut Arr) {
-    assert!(arr.len() == 3);
     let x: &mut [uint] = &mut **arr;
     assert!(x[0] == 1);
     assert!(x[1] == 2);
diff --git a/src/test/run-pass/fixup-deref-mut.rs b/src/test/run-pass/fixup-deref-mut.rs
new file mode 100644 (file)
index 0000000..d2812ce
--- /dev/null
@@ -0,0 +1,52 @@
+// 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.
+
+// Generic unique/owned smaht pointer.
+struct Own<T> {
+    value: *mut T
+}
+
+impl<T> Deref<T> for Own<T> {
+    fn deref<'a>(&'a self) -> &'a T {
+        unsafe { &*self.value }
+    }
+}
+
+impl<T> DerefMut<T> for Own<T> {
+    fn deref_mut<'a>(&'a mut self) -> &'a mut T {
+        unsafe { &mut *self.value }
+    }
+}
+
+struct Point {
+    x: int,
+    y: int
+}
+
+impl Point {
+    fn get(&mut self) -> (int, int) {
+        (self.x, self.y)
+    }
+}
+
+fn test0(mut x: Own<Point>) {
+    let _ = x.get();
+}
+
+fn test1(mut x: Own<Own<Own<Point>>>) {
+    let _ = x.get();
+}
+
+fn test2(mut x: Own<Own<Own<Point>>>) {
+    let _ = (**x).get();
+}
+
+fn main() {}
+
diff --git a/src/test/run-pass/if-let.rs b/src/test/run-pass/if-let.rs
new file mode 100644 (file)
index 0000000..4bf3a85
--- /dev/null
@@ -0,0 +1,69 @@
+// 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.
+
+#![feature(if_let)]
+
+pub fn main() {
+    let x = Some(3i);
+    if let Some(y) = x {
+        assert_eq!(y, 3i);
+    } else {
+        fail!("if-let failed");
+    }
+    let mut worked = false;
+    if let Some(_) = x {
+        worked = true;
+    }
+    assert!(worked);
+    let clause: uint;
+    if let None = Some("test") {
+        clause = 1;
+    } else if 4u > 5 {
+        clause = 2;
+    } else if let Ok(()) = Err::<(),&'static str>("test") {
+        clause = 3;
+    } else {
+        clause = 4;
+    }
+    assert_eq!(clause, 4u);
+
+    if 3i > 4 {
+        fail!("bad math");
+    } else if let 1 = 2i {
+        fail!("bad pattern match");
+    }
+
+    enum Foo {
+        One,
+        Two(uint),
+        Three(String, int)
+    }
+
+    let foo = Three("three".to_string(), 42i);
+    if let One = foo {
+        fail!("bad pattern match");
+    } else if let Two(_x) = foo {
+        fail!("bad pattern match");
+    } else if let Three(s, _) = foo {
+        assert_eq!(s.as_slice(), "three");
+    } else {
+        fail!("bad else");
+    }
+
+    if false {
+        fail!("wat");
+    } else if let a@Two(_) = Two(42u) {
+        if let Two(b) = a {
+            assert_eq!(b, 42u);
+        } else {
+            fail!("fail in nested if-let");
+        }
+    }
+}
index a7b2a46f0c3a450d4a4c2ec34bb79cccc93e1964..a104ee6baaacec4fae4f610878b31ebaac441168 100644 (file)
 pub fn main() {
     let x = 2i;
     let x_message = match x {
-      0 .. 1     => { "not many".to_string() }
+      0 ... 1    => { "not many".to_string() }
       _          => { "lots".to_string() }
     };
     assert_eq!(x_message, "lots".to_string());
 
     let y = 2i;
     let y_message = match y {
-      0 .. 1     => { "not many".to_string() }
+      0 ... 1    => { "not many".to_string() }
       _          => { "lots".to_string() }
     };
     assert_eq!(y_message, "lots".to_string());
 
     let z = 1u64;
     let z_message = match z {
-      0 .. 1     => { "not many".to_string() }
+      0 ... 1    => { "not many".to_string() }
       _          => { "lots".to_string() }
     };
     assert_eq!(z_message, "not many".to_string());
index f68ba5dab8ae2756d45c25677b13057075fddbe5..ab2abc094f4db2f1000eb45f8c5ec5efd6762db8 100644 (file)
@@ -17,7 +17,7 @@ pub fn main() {
     assert_eq!(3i, match (x, y) {
         (1, 1) => 1,
         (2, 2) => 2,
-        (1..2, 2) => 3,
+        (1...2, 2) => 3,
         _ => 4,
     });
 
@@ -25,7 +25,7 @@ pub fn main() {
     assert_eq!(3i, match ((x, y),) {
         ((1, 1),) => 1,
         ((2, 2),) => 2,
-        ((1..2, 2),) => 3,
+        ((1...2, 2),) => 3,
         _ => 4,
     });
 }
diff --git a/src/test/run-pass/issue-12660.rs b/src/test/run-pass/issue-12660.rs
new file mode 100644 (file)
index 0000000..6b3fa58
--- /dev/null
@@ -0,0 +1,21 @@
+// 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.
+
+// aux-build:issue-12660-aux.rs
+
+extern crate issue12660aux;
+
+use issue12660aux::{my_fn, MyStruct};
+
+#[allow(path_statement)]
+fn main() {
+    my_fn(MyStruct);
+    MyStruct;
+}
index 0efe64448c3d04f4ba27c7e35c6ef14703b8b63c..6cd098aeb0f8c8761bcd1cf0f116b3d444381f9f 100644 (file)
@@ -31,7 +31,7 @@ pub fn main() {
 fn lit_shadow_range() {
     assert_eq!(2i, match 1i {
         1 if false => 1i,
-        1..2 => 2,
+        1...2 => 2,
         _ => 3
     });
 
@@ -39,34 +39,34 @@ fn lit_shadow_range() {
     assert_eq!(2i, match x+1 {
         0 => 0i,
         1 if false => 1,
-        1..2 => 2,
+        1...2 => 2,
         _ => 3
     });
 
     assert_eq!(2i, match val() {
         1 if false => 1i,
-        1..2 => 2,
+        1...2 => 2,
         _ => 3
     });
 
     assert_eq!(2i, match CONST {
         0 => 0i,
         1 if false => 1,
-        1..2 => 2,
+        1...2 => 2,
         _ => 3
     });
 
     // value is out of the range of second arm, should match wildcard pattern
     assert_eq!(3i, match 3i {
         1 if false => 1i,
-        1..2 => 2,
+        1...2 => 2,
         _ => 3
     });
 }
 
 fn range_shadow_lit() {
     assert_eq!(2i, match 1i {
-        1..2 if false => 1i,
+        1...2 if false => 1i,
         1 => 2,
         _ => 3
     });
@@ -74,27 +74,27 @@ fn range_shadow_lit() {
     let x = 0i;
     assert_eq!(2i, match x+1 {
         0 => 0i,
-        1..2 if false => 1,
+        1...2 if false => 1,
         1 => 2,
         _ => 3
     });
 
     assert_eq!(2i, match val() {
-        1..2 if false => 1i,
+        1...2 if false => 1i,
         1 => 2,
         _ => 3
     });
 
     assert_eq!(2i, match CONST {
         0 => 0i,
-        1..2 if false => 1,
+        1...2 if false => 1,
         1 => 2,
         _ => 3
     });
 
     // ditto
     assert_eq!(3i, match 3i {
-        1..2 if false => 1i,
+        1...2 if false => 1i,
         1 => 2,
         _ => 3
     });
@@ -102,36 +102,36 @@ fn range_shadow_lit() {
 
 fn range_shadow_range() {
     assert_eq!(2i, match 1i {
-        0..2 if false => 1i,
-        1..3 => 2,
+        0...2 if false => 1i,
+        1...3 => 2,
         _ => 3,
     });
 
     let x = 0i;
     assert_eq!(2i, match x+1 {
         100 => 0,
-        0..2 if false => 1,
-        1..3 => 2,
+        0...2 if false => 1,
+        1...3 => 2,
         _ => 3,
     });
 
     assert_eq!(2i, match val() {
-        0..2 if false => 1,
-        1..3 => 2,
+        0...2 if false => 1,
+        1...3 => 2,
         _ => 3,
     });
 
     assert_eq!(2i, match CONST {
         100 => 0,
-        0..2 if false => 1,
-        1..3 => 2,
+        0...2 if false => 1,
+        1...3 => 2,
         _ => 3,
     });
 
     // ditto
     assert_eq!(3i, match 5i {
-        0..2 if false => 1i,
-        1..3 => 2,
+        0...2 if false => 1i,
+        1...3 => 2,
         _ => 3,
     });
 }
@@ -139,7 +139,7 @@ fn range_shadow_range() {
 fn multi_pats_shadow_lit() {
     assert_eq!(2i, match 1i {
         100 => 0i,
-        0 | 1..10 if false => 1,
+        0 | 1...10 if false => 1,
         1 => 2,
         _ => 3,
     });
@@ -148,8 +148,8 @@ fn multi_pats_shadow_lit() {
 fn multi_pats_shadow_range() {
     assert_eq!(2i, match 1i {
         100 => 0i,
-        0 | 1..10 if false => 1,
-        1..3 => 2,
+        0 | 1...10 if false => 1,
+        1...3 => 2,
         _ => 3,
     });
 }
@@ -158,7 +158,7 @@ fn lit_shadow_multi_pats() {
     assert_eq!(2i, match 1i {
         100 => 0i,
         1 if false => 1,
-        0 | 1..10 => 2,
+        0 | 1...10 => 2,
         _ => 3,
     });
 }
@@ -166,8 +166,8 @@ fn lit_shadow_multi_pats() {
 fn range_shadow_multi_pats() {
     assert_eq!(2i, match 1i {
         100 => 0i,
-        1..3 if false => 1,
-        0 | 1..10 => 2,
+        1...3 if false => 1,
+        0 | 1...10 => 2,
         _ => 3,
     });
 }
diff --git a/src/test/run-pass/issue-13259-windows-tcb-trash.rs b/src/test/run-pass/issue-13259-windows-tcb-trash.rs
new file mode 100644 (file)
index 0000000..1a909db
--- /dev/null
@@ -0,0 +1,48 @@
+// 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.
+
+extern crate libc;
+
+#[cfg(windows)]
+mod imp {
+    use libc::{c_void, LPVOID, DWORD};
+    use libc::types::os::arch::extra::LPWSTR;
+
+    extern "system" {
+        fn FormatMessageW(flags: DWORD,
+                          lpSrc: LPVOID,
+                          msgId: DWORD,
+                          langId: DWORD,
+                          buf: LPWSTR,
+                          nsize: DWORD,
+                          args: *const c_void)
+                          -> DWORD;
+    }
+
+    pub fn test() {
+        let mut buf: [u16, ..50] = [0, ..50];
+        let ret = unsafe {
+            FormatMessageW(0x1000, 0 as *mut c_void, 1, 0x400,
+                           buf.as_mut_ptr(), buf.len() as u32, 0 as *const c_void)
+        };
+        // On some 32-bit Windowses (Win7-8 at least) this will fail with segmented
+        // stacks taking control of pvArbitrary
+        assert!(ret != 0);
+    }
+}
+
+#[cfg(not(windows))]
+mod imp {
+    pub fn test() { }
+}
+
+fn main() {
+    imp::test()
+}
index 8bea2e7804602c396b18061af4c79b3189c060e5..b1607ef174bb2a4d1849c583d1bdff5023c6b039 100644 (file)
@@ -18,14 +18,14 @@ enum Foo {
 
 fn main() {
     let r = match (FooNullary, 'a') {
-        (FooUint(..), 'a'..'z') => 1i,
+        (FooUint(..), 'a'...'z') => 1i,
         (FooNullary, 'x') => 2i,
         _ => 0
     };
     assert_eq!(r, 0);
 
     let r = match (FooUint(0), 'a') {
-        (FooUint(1), 'a'..'z') => 1i,
+        (FooUint(1), 'a'...'z') => 1i,
         (FooUint(..), 'x') => 2i,
         (FooNullary, 'a') => 3i,
         _ => 0
@@ -33,7 +33,7 @@ fn main() {
     assert_eq!(r, 0);
 
     let r = match ('a', FooUint(0)) {
-        ('a'..'z', FooUint(1)) => 1i,
+        ('a'...'z', FooUint(1)) => 1i,
         ('x', FooUint(..)) => 2i,
         ('a', FooNullary) => 3i,
         _ => 0
@@ -41,15 +41,15 @@ fn main() {
     assert_eq!(r, 0);
 
     let r = match ('a', 'a') {
-        ('a'..'z', 'b') => 1i,
-        ('x', 'a'..'z') => 2i,
+        ('a'...'z', 'b') => 1i,
+        ('x', 'a'...'z') => 2i,
         _ => 0
     };
     assert_eq!(r, 0);
 
     let r = match ('a', 'a') {
-        ('a'..'z', 'b') => 1i,
-        ('x', 'a'..'z') => 2i,
+        ('a'...'z', 'b') => 1i,
+        ('x', 'a'...'z') => 2i,
         ('a', 'a') => 3i,
         _ => 0
     };
index 5db170fd52100de0f6a941b8fdfe580598b7af3b..b86b9a83e35bcdc7a5fa88706d28c8183be67429 100644 (file)
@@ -12,7 +12,7 @@ pub fn main() {
     static FOO: f64 = 10.0;
 
     match 0.0 {
-        0.0 .. FOO => (),
+        0.0 ... FOO => (),
         _ => ()
     }
 }
index 8b782520536a0138b61df97dd447e79db6ca8975..4761d2606fc2a9185beaa5f4ec7ffcfd5c9d437b 100644 (file)
 
 pub fn main() {
     match 5u {
-      1u..5u => {}
+      1u...5u => {}
       _ => fail!("should match range"),
     }
     match 5u {
-      6u..7u => fail!("shouldn't match range"),
+      6u...7u => fail!("shouldn't match range"),
       _ => {}
     }
     match 5u {
       1u => fail!("should match non-first range"),
-      2u..6u => {}
+      2u...6u => {}
       _ => fail!("math is broken")
     }
     match 'c' {
-      'a'..'z' => {}
+      'a'...'z' => {}
       _ => fail!("should suppport char ranges")
     }
     match -3i {
-      -7..5 => {}
+      -7...5 => {}
       _ => fail!("should match signed range")
     }
     match 3.0f64 {
-      1.0..5.0 => {}
+      1.0...5.0 => {}
       _ => fail!("should match float range")
     }
     match -1.5f64 {
-      -3.6..3.6 => {}
+      -3.6...3.6 => {}
       _ => fail!("should match negative float range")
     }
 }
index 7f2f9f9ece83de1ffc9398d49b99b99db0be3ea2..bbaa09bfac3100d5a4f110f7c73395d2522a99f4 100644 (file)
@@ -42,11 +42,17 @@ fn main() {
         let silent = Command::new(args[0].as_slice()).arg("silent").output().unwrap();
         assert!(!silent.status.success());
         let error = String::from_utf8_lossy(silent.error.as_slice());
-        assert!(error.as_slice().contains("has overflowed its stack"));
+        // FIXME #17562: Windows is using stack probes and isn't wired up to print an error
+        if !cfg!(windows) {
+            assert!(error.as_slice().contains("has overflowed its stack"));
+        }
 
         let loud = Command::new(args[0].as_slice()).arg("loud").output().unwrap();
         assert!(!loud.status.success());
         let error = String::from_utf8_lossy(silent.error.as_slice());
-        assert!(error.as_slice().contains("has overflowed its stack"));
+        // FIXME #17562: Windows is using stack probes and isn't wired up to print an error
+        if !cfg!(windows) {
+            assert!(error.as_slice().contains("has overflowed its stack"));
+        }
     }
 }
index 24146c4a6ea6a46ab1845d45ed7a9e43275f5e47..4cf5e074139351f9176b2e32eff0788166b7b8cf 100644 (file)
@@ -74,7 +74,7 @@ pub fn main() {
     assert_eq!(p.counts(), (2, 2));
 
     p.get();
-    assert_eq!(p.counts(), (2, 3));
+    assert_eq!(p.counts(), (3, 2));
 
     // Check the final state.
     assert_eq!(*p, Point {x: 3, y: 0});
index fa38d647c7c9460b17f4c1960adbc78ea30fbd0f..fa458130c7ffa482dacf26c103bf80edd402a0bf 100644 (file)
@@ -56,6 +56,13 @@ unsafe fn allocate(size: uint, align: uint) -> *mut u8 {
 
         ret
     }
+    unsafe fn deallocate(ptr: *mut u8, size: uint, align: uint) {
+        if PRINT { println!("deallocate(ptr=0x{:010x} size={:u} align={:u})",
+                            ptr as uint, size, align);
+        }
+
+        heap::deallocate(ptr, size, align);
+    }
     unsafe fn reallocate(ptr: *mut u8, size: uint, align: uint,
                              old_size: uint) -> *mut u8 {
         if PRINT {
@@ -95,10 +102,16 @@ fn idx_to_size(i: uint) -> uint { (i+1) * 10 }
     }
 
     sanity_check(ascend.as_slice());
-    test_1(ascend);
-    test_2(ascend);
-    test_3(ascend);
-    test_4(ascend);
+    test_1(ascend); // triangle -> square
+    test_2(ascend); // square -> triangle
+    test_3(ascend); // triangle -> square
+    test_4(ascend); // square -> triangle
+
+    for i in range(0u, COUNT / 2) {
+        let size = idx_to_size(i);
+        deallocate(ascend[2*i], size, ALIGN);
+        deallocate(ascend[2*i+1], size, ALIGN);
+    }
 
     return true;