]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #31627 - KiChjang:unstable-lint, r=alexcrichton
authorbors <bors@rust-lang.org>
Tue, 16 Feb 2016 05:16:55 +0000 (05:16 +0000)
committerbors <bors@rust-lang.org>
Tue, 16 Feb 2016 05:16:55 +0000 (05:16 +0000)
Fixes #31122.

250 files changed:
.gitignore
README.md
configure
mk/cfg/i586-unknown-linux-gnu.mk [new file with mode: 0644]
mk/crates.mk
mk/dist.mk
mk/docs.mk
mk/prepare.mk
mk/rt.mk
mk/tests.mk
src/bootstrap/build/clean.rs [new file with mode: 0644]
src/bootstrap/build/flags.rs
src/bootstrap/build/job.rs
src/bootstrap/build/mod.rs
src/bootstrap/mk/Makefile.in
src/doc/book/concurrency.md
src/doc/book/documentation.md
src/doc/book/functions.md
src/doc/book/ownership.md
src/doc/book/strings.md
src/doc/book/using-rust-without-the-standard-library.md
src/doc/book/vectors.md
src/doc/uptack.tex [deleted file]
src/error-index-generator/main.rs [deleted file]
src/error_index_generator/main.rs [new file with mode: 0644]
src/etc/maketest.py
src/etc/regex-match-tests.py [deleted file]
src/liballoc_jemalloc/build.rs
src/liballoc_jemalloc/lib.rs
src/libcollections/vec.rs
src/libcore/num/mod.rs
src/libcore/num/u16.rs
src/libcore/num/u32.rs
src/libcore/num/u64.rs
src/libcore/num/u8.rs
src/libcore/num/uint_macros.rs
src/libcore/num/usize.rs
src/libcore/ptr.rs
src/libcore/str/mod.rs
src/librustc/middle/infer/mod.rs
src/librustc/middle/traits/fulfill.rs
src/librustc/session/config.rs
src/librustc_back/target/i586_unknown_linux_gnu.rs [new file with mode: 0644]
src/librustc_back/target/i686_pc_windows_msvc.rs
src/librustc_back/target/mod.rs
src/librustc_data_structures/fnv.rs
src/librustc_driver/pretty.rs
src/librustc_front/lowering.rs
src/librustc_mir/build/scope.rs
src/librustc_passes/const_fn.rs
src/librustc_passes/consts.rs
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/lib.rs
src/librustc_resolve/resolve_imports.rs
src/librustc_trans/back/link.rs
src/librustc_trans/save/dump_csv.rs
src/librustc_trans/save/mod.rs
src/librustc_trans/trans/cabi_asmjs.rs
src/librustc_trans/trans/collector.rs
src/librustc_trans/trans/common.rs
src/librustc_typeck/check/closure.rs
src/librustc_typeck/check/compare_method.rs
src/librustc_typeck/check/dropck.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/regionck.rs
src/librustc_typeck/coherence/mod.rs
src/librustdoc/clean/mod.rs
src/librustdoc/html/layout.rs
src/librustdoc/html/render.rs
src/librustdoc/html/static/main.js
src/libstd/ascii.rs
src/libstd/fs.rs
src/libstd/macros.rs
src/libstd/os/android/fs.rs [new file with mode: 0644]
src/libstd/os/android/mod.rs
src/libstd/os/android/raw.rs
src/libstd/os/bitrig/fs.rs [new file with mode: 0644]
src/libstd/os/bitrig/mod.rs
src/libstd/os/bitrig/raw.rs
src/libstd/os/dragonfly/fs.rs [new file with mode: 0644]
src/libstd/os/dragonfly/mod.rs
src/libstd/os/dragonfly/raw.rs
src/libstd/os/freebsd/fs.rs [new file with mode: 0644]
src/libstd/os/freebsd/mod.rs
src/libstd/os/freebsd/raw.rs
src/libstd/os/ios/fs.rs [new file with mode: 0644]
src/libstd/os/ios/mod.rs
src/libstd/os/ios/raw.rs
src/libstd/os/linux/fs.rs [new file with mode: 0644]
src/libstd/os/linux/mod.rs
src/libstd/os/linux/raw.rs
src/libstd/os/macos/fs.rs [new file with mode: 0644]
src/libstd/os/macos/mod.rs
src/libstd/os/macos/raw.rs
src/libstd/os/nacl/fs.rs [new file with mode: 0644]
src/libstd/os/nacl/mod.rs
src/libstd/os/nacl/raw.rs
src/libstd/os/netbsd/fs.rs [new file with mode: 0644]
src/libstd/os/netbsd/mod.rs
src/libstd/os/netbsd/raw.rs
src/libstd/os/openbsd/fs.rs [new file with mode: 0644]
src/libstd/os/openbsd/mod.rs
src/libstd/os/openbsd/raw.rs
src/libstd/os/raw.rs
src/libstd/os/solaris/fs.rs [new file with mode: 0644]
src/libstd/os/solaris/mod.rs
src/libstd/os/solaris/raw.rs
src/libstd/prelude/mod.rs
src/libstd/sys/common/poison.rs
src/libstd/sys/unix/ext/fs.rs
src/libstd/sys/unix/ext/process.rs
src/libstd/sys/unix/ext/raw.rs
src/libstd/sys/unix/ext/thread.rs
src/libstd/sys/unix/fs.rs
src/libstd/sys/windows/c.rs
src/libstd/sys/windows/fs.rs
src/libsyntax/ast.rs
src/libsyntax/ast_util.rs
src/libsyntax/codemap.rs
src/libsyntax/ext/base.rs
src/libsyntax/ext/build.rs
src/libsyntax/ext/expand.rs
src/libsyntax/feature_gate.rs
src/libsyntax/fold.rs
src/libsyntax/parse/mod.rs
src/libsyntax/parse/parser.rs
src/libsyntax/print/pprust.rs
src/libsyntax/visit.rs
src/libsyntax_ext/deriving/generic/mod.rs
src/test/auxiliary/issue-26606-macro.rs [new file with mode: 0644]
src/test/compile-fail/cfg-arg-invalid.rs [new file with mode: 0644]
src/test/compile-fail/enum-and-module-in-same-scope.rs
src/test/compile-fail/issue-30715.rs
src/test/compile-fail/macro-incomplete-parse.rs
src/test/compile-fail/no-extern-crate-in-glob-import.rs
src/test/compile-fail/parser-recovery-1.rs [new file with mode: 0644]
src/test/compile-fail/parser-recovery-2.rs [new file with mode: 0644]
src/test/parse-fail/brace-after-qualified-path-in-match.rs
src/test/parse-fail/issue-10636-2.rs
src/test/parse-fail/issue-14303-path.rs
src/test/parse-fail/issue-2354.rs
src/test/parse-fail/match-refactor-to-expr.rs
src/test/parse-fail/paren-after-qualified-path-in-match.rs
src/test/parse-fail/pat-lt-bracket-4.rs
src/test/parse-fail/pat-lt-bracket-6.rs
src/test/parse-fail/pat-lt-bracket-7.rs
src/test/parse-fail/struct-literal-in-for.rs
src/test/parse-fail/struct-literal-in-if.rs
src/test/parse-fail/struct-literal-in-match-discriminant.rs
src/test/parse-fail/struct-literal-in-while.rs
src/test/parse-fail/variadic-ffi-1.rs [deleted file]
src/test/run-make/codegen-options-parsing/Makefile
src/test/run-make/llvm-module-pass/Makefile [new file with mode: 0644]
src/test/run-make/llvm-module-pass/llvm-pass.so.cc [new file with mode: 0644]
src/test/run-make/llvm-module-pass/main.rs [new file with mode: 0644]
src/test/run-make/llvm-module-pass/plugin.rs [new file with mode: 0644]
src/test/run-make/lto-no-link-whole-rlib/Makefile [new file with mode: 0644]
src/test/run-make/lto-no-link-whole-rlib/bar.c [new file with mode: 0644]
src/test/run-make/lto-no-link-whole-rlib/foo.c [new file with mode: 0644]
src/test/run-make/lto-no-link-whole-rlib/lib1.rs [new file with mode: 0644]
src/test/run-make/lto-no-link-whole-rlib/lib2.rs [new file with mode: 0644]
src/test/run-make/lto-no-link-whole-rlib/main.rs [new file with mode: 0644]
src/test/run-pass/atomic-print.rs
src/test/run-pass/box-of-array-of-drop-1.rs
src/test/run-pass/box-of-array-of-drop-2.rs
src/test/run-pass/cci_capture_clause.rs
src/test/run-pass/child-outlives-parent.rs
src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs
src/test/run-pass/clone-with-exterior.rs
src/test/run-pass/coerce-expect-unsized.rs
src/test/run-pass/comm.rs
src/test/run-pass/core-run-destroy.rs
src/test/run-pass/drop-flag-skip-sanity-check.rs
src/test/run-pass/extern-call-deep2.rs
src/test/run-pass/extern-call-scrub.rs
src/test/run-pass/fds-are-cloexec.rs
src/test/run-pass/foreign-call-no-runtime.rs
src/test/run-pass/init-large-type.rs
src/test/run-pass/int-abs-overflow.rs
src/test/run-pass/intrinsic-move-val-cleanups.rs
src/test/run-pass/issue-13494.rs
src/test/run-pass/issue-16560.rs
src/test/run-pass/issue-16671.rs
src/test/run-pass/issue-21291.rs
src/test/run-pass/issue-22864-2.rs
src/test/run-pass/issue-25089.rs
src/test/run-pass/issue-26655.rs
src/test/run-pass/issue-29488.rs
src/test/run-pass/issue-30018-panic.rs
src/test/run-pass/issue-4446.rs
src/test/run-pass/issue-4448.rs
src/test/run-pass/issue-8460.rs
src/test/run-pass/issue-8827.rs
src/test/run-pass/issue-9396.rs
src/test/run-pass/ivec-tag.rs
src/test/run-pass/logging-only-prints-once.rs
src/test/run-pass/macro-with-braces-in-expr-position.rs
src/test/run-pass/moves-based-on-type-capture-clause.rs
src/test/run-pass/nested-vec-3.rs
src/test/run-pass/no-landing-pads.rs
src/test/run-pass/panic-handler-flail-wildly.rs
src/test/run-pass/panic-handler-set-twice.rs
src/test/run-pass/panic-in-dtor-drops-fields.rs
src/test/run-pass/panic-recover-propagate.rs
src/test/run-pass/process-sigpipe.rs
src/test/run-pass/rust-log-filter.rs
src/test/run-pass/send-resource.rs
src/test/run-pass/sendfn-spawn-with-fn-arg.rs
src/test/run-pass/sepcomp-unwind.rs
src/test/run-pass/slice-panic-1.rs
src/test/run-pass/slice-panic-2.rs
src/test/run-pass/spawn-fn.rs
src/test/run-pass/spawn-types.rs
src/test/run-pass/spawn.rs
src/test/run-pass/spawn2.rs
src/test/run-pass/spawning-with-debug.rs
src/test/run-pass/task-comm-0.rs
src/test/run-pass/task-comm-1.rs
src/test/run-pass/task-comm-10.rs
src/test/run-pass/task-comm-11.rs
src/test/run-pass/task-comm-12.rs
src/test/run-pass/task-comm-13.rs
src/test/run-pass/task-comm-14.rs
src/test/run-pass/task-comm-15.rs
src/test/run-pass/task-comm-17.rs
src/test/run-pass/task-comm-3.rs
src/test/run-pass/task-comm-7.rs
src/test/run-pass/task-comm-9.rs
src/test/run-pass/task-life-0.rs
src/test/run-pass/task-spawn-move-and-copy.rs
src/test/run-pass/task-stderr.rs
src/test/run-pass/tcp-stress.rs
src/test/run-pass/terminate-in-initializer.rs
src/test/run-pass/threads.rs
src/test/run-pass/tls-dtors-are-run-in-a-static-binary.rs
src/test/run-pass/tls-init-on-init.rs
src/test/run-pass/trait-bounds-in-arc.rs
src/test/run-pass/unique-send-2.rs
src/test/run-pass/unit-like-struct-drop-run.rs
src/test/run-pass/unwind-resource.rs
src/test/run-pass/unwind-unique.rs
src/test/run-pass/vector-sort-panic-safe.rs
src/test/run-pass/weak-lang-item.rs
src/test/run-pass/yield.rs
src/test/run-pass/yield1.rs
src/test/rustdoc/assoc-consts.rs
src/test/rustdoc/issue-21092.rs
src/test/rustdoc/issue-25001.rs
src/test/rustdoc/issue-26606.rs [new file with mode: 0644]
src/test/rustdoc/issue-30366.rs [new file with mode: 0644]

index b6f5f04bff62fc209f6f42654cba6079df8270ef..5f1778376ebf46765b126b610aca624c89ba869a 100644 (file)
@@ -17,6 +17,7 @@
 *.elc
 *.epub
 *.exe
+*.pdb
 *.fn
 *.html
 *.kdev4
index 293f585d105cbd5cd39cfc9f290fcdec5f2eb749..a83f51e157155cfcdd893f643549506de3d9c710 100644 (file)
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@ Read ["Installing Rust"] from [The Book].
 1. Make sure you have installed the dependencies:
 
    * `g++` 4.7 or `clang++` 3.x
-   * `python` 2.7 or later (but not 3.x)
+   * `python` 2.7 (but not 3.x)
    * GNU `make` 3.81 or later
    * `curl`
    * `git`
index 7958ac9bfcfe3a5f4e24ed84637d09d0175e2659..c05765975d4790795bb55844422d7987e02d8e67 100755 (executable)
--- a/configure
+++ b/configure
@@ -729,12 +729,12 @@ step_msg "looking for build programs"
 
 probe_need CFG_CURLORWGET  curl wget
 if [ -z "$CFG_PYTHON_PROVIDED" ]; then
-    probe_need CFG_PYTHON      python2.7 python2.6 python2 python
+    probe_need CFG_PYTHON      python2.7 python2 python
 fi
 
 python_version=$($CFG_PYTHON -V 2>&1)
-if [ $(echo $python_version | grep -c '^Python 2\.[4567]') -ne 1 ]; then
-    err "Found $python_version, but LLVM requires Python 2.4-2.7"
+if [ $(echo $python_version | grep -c '^Python 2\.7') -ne 1 ]; then
+    err "Found $python_version, but Python 2.7 is required"
 fi
 
 # If we have no git directory then we are probably a tarball distribution
diff --git a/mk/cfg/i586-unknown-linux-gnu.mk b/mk/cfg/i586-unknown-linux-gnu.mk
new file mode 100644 (file)
index 0000000..0609f36
--- /dev/null
@@ -0,0 +1,23 @@
+# i586-unknown-linux-gnu configuration
+CC_i586-unknown-linux-gnu=$(CC)
+CXX_i586-unknown-linux-gnu=$(CXX)
+CPP_i586-unknown-linux-gnu=$(CPP)
+AR_i586-unknown-linux-gnu=$(AR)
+CFG_LIB_NAME_i586-unknown-linux-gnu=lib$(1).so
+CFG_STATIC_LIB_NAME_i586-unknown-linux-gnu=lib$(1).a
+CFG_LIB_GLOB_i586-unknown-linux-gnu=lib$(1)-*.so
+CFG_LIB_DSYM_GLOB_i586-unknown-linux-gnu=lib$(1)-*.dylib.dSYM
+CFG_JEMALLOC_CFLAGS_i586-unknown-linux-gnu := -m32 $(CFLAGS)
+CFG_GCCISH_CFLAGS_i586-unknown-linux-gnu := -Wall -Werror -g -fPIC -m32 $(CFLAGS)
+CFG_GCCISH_CXXFLAGS_i586-unknown-linux-gnu := -fno-rtti $(CXXFLAGS)
+CFG_GCCISH_LINK_FLAGS_i586-unknown-linux-gnu := -shared -fPIC -ldl -pthread  -lrt -g -m32
+CFG_GCCISH_DEF_FLAG_i586-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list=
+CFG_LLC_FLAGS_i586-unknown-linux-gnu :=
+CFG_INSTALL_NAME_i586-unknown-linux-gnu =
+CFG_EXE_SUFFIX_i586-unknown-linux-gnu =
+CFG_WINDOWSY_i586-unknown-linux-gnu :=
+CFG_UNIXY_i586-unknown-linux-gnu := 1
+CFG_LDPATH_i586-unknown-linux-gnu :=
+CFG_RUN_i586-unknown-linux-gnu=$(2)
+CFG_RUN_TARG_i586-unknown-linux-gnu=$(call CFG_RUN_i586-unknown-linux-gnu,,$(2))
+CFG_GNU_TRIPLE_i586-unknown-linux-gnu := i586-unknown-linux-gnu
index bfd054ae988f2f6d2743c21756862eafc8c0b930..cf3e479ec21f7bd08375c27b93b632d6414a3235 100644 (file)
@@ -59,7 +59,7 @@ RUSTC_CRATES := rustc rustc_typeck rustc_mir rustc_borrowck rustc_resolve rustc_
                 rustc_data_structures rustc_front rustc_platform_intrinsics \
                 rustc_plugin rustc_metadata rustc_passes
 HOST_CRATES := syntax syntax_ext $(RUSTC_CRATES) rustdoc fmt_macros
-TOOLS := compiletest rustdoc rustc rustbook error-index-generator
+TOOLS := compiletest rustdoc rustc rustbook error_index_generator
 
 DEPS_core :=
 DEPS_alloc := core libc alloc_system
@@ -120,12 +120,12 @@ TOOL_DEPS_compiletest := test getopts
 TOOL_DEPS_rustdoc := rustdoc
 TOOL_DEPS_rustc := rustc_driver
 TOOL_DEPS_rustbook := std rustdoc
-TOOL_DEPS_error-index-generator := rustdoc syntax serialize
+TOOL_DEPS_error_index_generator := rustdoc syntax serialize
 TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs
 TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs
 TOOL_SOURCE_rustc := $(S)src/driver/driver.rs
 TOOL_SOURCE_rustbook := $(S)src/rustbook/main.rs
-TOOL_SOURCE_error-index-generator := $(S)src/error-index-generator/main.rs
+TOOL_SOURCE_error_index_generator := $(S)src/error_index_generator/main.rs
 
 ONLY_RLIB_core := 1
 ONLY_RLIB_libc := 1
index 685fb2b5b46792ce6f10da38961e4b6a85efc4ad..31d3764eefab13ca3fdb455037d2aa519d1de599 100644 (file)
@@ -52,7 +52,7 @@ PKG_FILES := \
       doc                                      \
       driver                                   \
       etc                                      \
-      error-index-generator                    \
+      error_index_generator                    \
       $(foreach crate,$(CRATES),lib$(crate))   \
       libcollectionstest                       \
       libcoretest                              \
index 7f73b99863f093fe349962a1b67a72fc159d6f94..83cdb7f8023bcdac86de2ce319bde1c4a1d9a0d1 100644 (file)
@@ -59,8 +59,8 @@ RUSTBOOK_EXE = $(HBIN2_H_$(CFG_BUILD))/rustbook$(X_$(CFG_BUILD))
 # ./configure
 RUSTBOOK = $(RPATH_VAR2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $(RUSTBOOK_EXE)
 
-# The error-index-generator executable...
-ERR_IDX_GEN_EXE = $(HBIN2_H_$(CFG_BUILD))/error-index-generator$(X_$(CFG_BUILD))
+# The error_index_generator executable...
+ERR_IDX_GEN_EXE = $(HBIN2_H_$(CFG_BUILD))/error_index_generator$(X_$(CFG_BUILD))
 ERR_IDX_GEN = $(RPATH_VAR2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $(ERR_IDX_GEN_EXE)
 ERR_IDX_GEN_MD = $(RPATH_VAR2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $(ERR_IDX_GEN_EXE) markdown
 
@@ -221,9 +221,9 @@ error-index: doc/error-index.html
 # Metadata used to generate the index is created as a side effect of
 # the build so this depends on every crate being up to date.
 doc/error-index.html: $(ERR_IDX_GEN_EXE) $(CSREQ$(2)_T_$(CFG_BUILD)_H_$(CFG_BUILD)) | doc/
-       $(Q)$(call E, error-index-generator: $@)
+       $(Q)$(call E, error_index_generator: $@)
        $(Q)$(ERR_IDX_GEN)
 
 doc/error-index.md: $(ERR_IDX_GEN_EXE) $(CSREQ$(2)_T_$(CFG_BUILD)_H_$(CFG_BUILD)) | doc/
-       $(Q)$(call E, error-index-generator: $@)
+       $(Q)$(call E, error_index_generator: $@)
        $(Q)$(ERR_IDX_GEN_MD)
index 87a445000ada4cc617df2def665a60a935394838..2488de4ad5bdf32850aee70658f6600e3b70f4bc 100644 (file)
@@ -82,7 +82,7 @@ define PREPARE_MAN
 
 endef
 
-PREPARE_TOOLS = $(filter-out compiletest rustbook error-index-generator, $(TOOLS))
+PREPARE_TOOLS = $(filter-out compiletest rustbook error_index_generator, $(TOOLS))
 
 
 # $(1) is tool
index cfb210952bcfb419abe7d3c2c7b815969d2017e9..bd17490955d1e5bbabf97d257097da1af3b12a6b 100644 (file)
--- a/mk/rt.mk
+++ b/mk/rt.mk
@@ -148,7 +148,15 @@ ifeq ($$(CFG_WINDOWSY_$(1)),1)
 else ifeq ($(OSTYPE_$(1)), apple-ios)
   JEMALLOC_ARGS_$(1) := --disable-tls
 else ifeq ($(findstring android, $(OSTYPE_$(1))), android)
-  JEMALLOC_ARGS_$(1) := --disable-tls
+  # We force android to have prefixed symbols because apparently replacement of
+  # the libc allocator doesn't quite work. When this was tested (unprefixed
+  # symbols), it was found that the `realpath` function in libc would allocate
+  # with libc malloc (not jemalloc malloc), and then the standard library would
+  # free with jemalloc free, causing a segfault.
+  #
+  # If the test suite passes, however, without symbol prefixes then we should be
+  # good to go!
+  JEMALLOC_ARGS_$(1) := --disable-tls --with-jemalloc-prefix=je_
 endif
 
 ifdef CFG_ENABLE_DEBUG_JEMALLOC
@@ -186,7 +194,7 @@ JEMALLOC_LOCAL_$(1) := $$(JEMALLOC_BUILD_DIR_$(1))/lib/$$(JEMALLOC_REAL_NAME_$(1
 $$(JEMALLOC_LOCAL_$(1)): $$(JEMALLOC_DEPS) $$(MKFILE_DEPS)
        @$$(call E, make: jemalloc)
        cd "$$(JEMALLOC_BUILD_DIR_$(1))"; "$(S)src/jemalloc/configure" \
-               $$(JEMALLOC_ARGS_$(1)) --with-jemalloc-prefix=je_ $(CFG_JEMALLOC_FLAGS) \
+               $$(JEMALLOC_ARGS_$(1)) $(CFG_JEMALLOC_FLAGS) \
                --build=$$(CFG_GNU_TRIPLE_$(CFG_BUILD)) --host=$$(CFG_GNU_TRIPLE_$(1)) \
                CC="$$(CC_$(1)) $$(CFG_JEMALLOC_CFLAGS_$(1))" \
                AR="$$(AR_$(1))" \
index 2e530095cbe1c92d5b38df47b229f686b02965ea..acb75bb7cdc3b0ced461a73676972e5b6b5cb16b 100644 (file)
@@ -1071,7 +1071,8 @@ $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
            $$(S) \
            $(3) \
            "$$(LLVM_LIBDIR_RUSTFLAGS_$(3))" \
-           "$$(LLVM_ALL_COMPONENTS_$(3))"
+           "$$(LLVM_ALL_COMPONENTS_$(3))" \
+           "$$(LLVM_CXXFLAGS_$(3))"
        @touch -r $$@.start_time $$@ && rm $$@.start_time
 else
 # FIXME #11094 - The above rule doesn't work right for multiple targets
diff --git a/src/bootstrap/build/clean.rs b/src/bootstrap/build/clean.rs
new file mode 100644 (file)
index 0000000..8f78fed
--- /dev/null
@@ -0,0 +1,36 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::fs;
+use std::path::Path;
+
+use build::Build;
+
+pub fn clean(build: &Build) {
+    for host in build.config.host.iter() {
+
+        let out = build.out.join(host);
+
+        rm_rf(build, &out.join("compiler-rt"));
+
+        for stage in 0..4 {
+            rm_rf(build, &out.join(format!("stage{}", stage)));
+            rm_rf(build, &out.join(format!("stage{}-std", stage)));
+            rm_rf(build, &out.join(format!("stage{}-rustc", stage)));
+        }
+    }
+}
+
+fn rm_rf(build: &Build, path: &Path) {
+    if path.exists() {
+        build.verbose(&format!("removing `{}`", path.display()));
+        t!(fs::remove_dir_all(path));
+    }
+}
index cd538bb0a905ad5598c7060854d5711f85366fa5..d91dfe0903d1144e58e7ddcad322691f20ba88ee 100644 (file)
@@ -26,6 +26,7 @@ pub struct Flags {
     pub src: Option<PathBuf>,
     pub jobs: Option<u32>,
     pub args: Vec<String>,
+    pub clean: bool,
 }
 
 pub struct Filter {
@@ -44,6 +45,7 @@ pub fn parse(args: &[String]) -> Flags {
         opts.optopt("", "stage", "stage to build", "N");
         opts.optopt("", "src", "path to repo root", "DIR");
         opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS");
+        opts.optflag("", "clean", "clean output directory");
         opts.optflag("h", "help", "print this help message");
 
         let usage = |n| -> ! {
@@ -75,6 +77,7 @@ pub fn parse(args: &[String]) -> Flags {
 
         Flags {
             verbose: m.opt_present("v"),
+            clean: m.opt_present("clean"),
             stage: m.opt_str("stage").map(|j| j.parse().unwrap()),
             build: m.opt_str("build").unwrap(),
             host: Filter { values: m.opt_strs("host") },
index 49e027ffda596112ceaf635f7ebbfe5fd8ac762b..a4e53bc45fcfbf979836b89b8ea1bba17b834122 100644 (file)
@@ -64,9 +64,20 @@ pub unsafe fn setup() {
                                     mem::size_of_val(&info) as DWORD);
     assert!(r != 0, "{}", io::Error::last_os_error());
 
-    // Assign our process to this job object
+    // Assign our process to this job object. Note that if this fails, one very
+    // likely reason is that we are ourselves already in a job object! This can
+    // happen on the build bots that we've got for Windows, or if just anyone
+    // else is instrumenting the build. In this case we just bail out
+    // immediately and assume that they take care of it.
+    //
+    // Also note that nested jobs (why this might fail) are supported in recent
+    // versions of Windows, but the version of Windows that our bots are running
+    // at least don't support nested job objects.
     let r = AssignProcessToJobObject(job, GetCurrentProcess());
-    assert!(r != 0, "{}", io::Error::last_os_error());
+    if r == 0 {
+        CloseHandle(job);
+        return
+    }
 
     // If we've got a parent process (e.g. the python script that called us)
     // then move ownership of this job object up to them. That way if the python
index 6f962aae923348040e1222da35a6902d38c9c530..92043ee3f253df496afc3ae1d248a5e9a3fc50bb 100644 (file)
@@ -30,6 +30,7 @@ macro_rules! t {
 
 mod cc;
 mod channel;
+mod clean;
 mod compile;
 mod config;
 mod flags;
@@ -122,6 +123,10 @@ fn setup_job() {
         #[cfg(not(windows))] fn setup_job() {}
         setup_job();
 
+        if self.flags.clean {
+            return clean::clean(self);
+        }
+
         cc::find(self);
         sanity::check(self);
         channel::collect(self);
index 1157346d774ab3882f9d65f12d604c8e36833125..bd29fd8612d4e5741ff23fe3a9cbc01cc8e5dd8e 100644 (file)
@@ -21,3 +21,6 @@ BOOTSTRAP := $(CFG_PYTHON) $(CFG_SRC_DIR)src/bootstrap/bootstrap.py $(BOOTSTRAP_
 
 all:
        $(Q)$(BOOTSTRAP)
+
+clean:
+       $(Q)$(BOOTSTRAP) --clean
index 44569a04b98243e0f3b3ce2bb87bcf63f30f63a9..752c097210243e8d0d7d24349f21960842947959 100644 (file)
@@ -286,6 +286,8 @@ use std::sync::mpsc;
 fn main() {
     let data = Arc::new(Mutex::new(0));
 
+    // `tx` is the "transmitter" or "sender"
+    // `rx` is the "receiver"
     let (tx, rx) = mpsc::channel();
 
     for _ in 0..10 {
index ede3100194e5bd308e9f2a47c2373bd3519ced57..8d1e58ac17397559b8a534c25c164b31dbf8f34f 100644 (file)
@@ -319,7 +319,7 @@ our source code:
 ```text
     First, we set `x` to five:
 
-    ```text
+    ```rust
     let x = 5;
     # let y = 6;
     # println!("{}", x + y);
@@ -327,7 +327,7 @@ our source code:
 
     Next, we set `y` to six:
 
-    ```text
+    ```rust
     # let x = 5;
     let y = 6;
     # println!("{}", x + y);
@@ -335,7 +335,7 @@ our source code:
 
     Finally, we print the sum of `x` and `y`:
 
-    ```text
+    ```rust
     # let x = 5;
     # let y = 6;
     println!("{}", x + y);
index be905599c64415684110f730bd1e4e3ec0149646..31c9da3fadae2cd0f983938d99b81d6294094535 100644 (file)
@@ -68,7 +68,7 @@ You get this error:
 
 ```text
 expected one of `!`, `:`, or `@`, found `)`
-fn print_number(x, y) {
+fn print_sum(x, y) {
 ```
 
 This is a deliberate design decision. While full-program inference is possible,
index a62d31d362b14f217c367efbfe76779167dd1ded..175960f67b6930700d740a721f5775d81ff97a1d 100644 (file)
@@ -51,10 +51,11 @@ fn foo() {
 }
 ```
 
-When `v` comes into scope, a new [vector] is created, and it allocates space on
-[the heap][heap] for each of its elements. When `v` goes out of scope at the
-end of `foo()`, Rust will clean up everything related to the vector, even the
-heap-allocated memory. This happens deterministically, at the end of the scope.
+When `v` comes into scope, a new [vector] is created on [the stack][stack],
+and it allocates space on [the heap][heap] for its elements. When `v` goes out
+of scope at the end of `foo()`, Rust will clean up everything related to the
+vector, even the heap-allocated memory. This happens deterministically, at the
+end of the scope.
 
 We'll cover [vectors] in detail later in this chapter; we only use them
 here as an example of a type that allocates space on the heap at runtime. They
@@ -67,6 +68,7 @@ Vectors have a [generic type][generics] `Vec<T>`, so in this example `v` will ha
 [arrays]: primitive-types.html#arrays
 [vectors]: vectors.html
 [heap]: the-stack-and-the-heap.html
+[stack]: the-stack-and-the-heap.html#the-stack
 [bindings]: variable-bindings.html
 [generics]: generics.html
 
index 751619d544a4af57746c31b0acf734bd6dab6adf..68c7235975e8c39a1b68ee4ca43fb1d49def0de0 100644 (file)
@@ -39,7 +39,7 @@ The second, with a `\`, trims the spaces and the newline:
 
 ```rust
 let s = "foo\
-    bar"; 
+    bar";
 
 assert_eq!("foobar", s);
 ```
index 59182e1a4efcee7fefd0a9bc0d7068052cc7ef94..2c7a097fe8045c4fc2f813b4d04e3caadd6b9329 100644 (file)
@@ -11,7 +11,7 @@ don’t want to use the standard library via an attribute: `#![no_std]`.
 > For details on binaries without the standard library, see [the nightly
 > chapter on `#![no_std]`](no-stdlib.html)
 
-To use `#![no_std]`, add it to your crate root:
+To use `#![no_std]`, add it to your crate root:
 
 ```rust
 #![no_std]
index b09735c3feee6b9d12c7816fe06c8adafa6933d0..f5a543d75b1b40baecb74f5605172b36157a4c0c 100644 (file)
@@ -11,8 +11,8 @@ let v = vec![1, 2, 3, 4, 5]; // v: Vec<i32>
 ```
 
 (Notice that unlike the `println!` macro we’ve used in the past, we use square
-brackets `[]` with `vec!` macro. Rust allows you to use either in either situation,
-this is just convention.)
+brackets `[]` with `vec!` macro. Rust allows you to use either in either
+situation, this is just convention.)
 
 There’s an alternate form of `vec!` for repeating an initial value:
 
@@ -20,6 +20,12 @@ There’s an alternate form of `vec!` for repeating an initial value:
 let v = vec![0; 10]; // ten zeroes
 ```
 
+Vectors store their contents as contiguous arrays of `T` on the heap. This means
+that they must be able to know the size of `T` at compile time (that is, how
+many bytes are needed to store a `T`?). The size of some things can't be known
+at compile time. For these you'll have to store a pointer to that thing:
+thankfully, the [`Box`][box] type works perfectly for this.
+
 ## Accessing elements
 
 To get the value at a particular index in the vector, we use `[]`s:
@@ -113,6 +119,7 @@ Vectors have many more useful methods, which you can read about in [their
 API documentation][vec].
 
 [vec]: ../std/vec/index.html
+[box]: ../std/boxed/index.html
 [generic]: generics.html
 [panic]: concurrency.html#panics
 [get]: http://doc.rust-lang.org/std/vec/struct.Vec.html#method.get
diff --git a/src/doc/uptack.tex b/src/doc/uptack.tex
deleted file mode 100644 (file)
index 32158ea..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-\usepackage{newunicodechar}
-\newunicodechar⊥{{$\bot$}}
diff --git a/src/error-index-generator/main.rs b/src/error-index-generator/main.rs
deleted file mode 100644 (file)
index db9dd00..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-// Copyright 2015 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(rustc_private, rustdoc)]
-
-extern crate syntax;
-extern crate rustdoc;
-extern crate serialize as rustc_serialize;
-
-use std::collections::BTreeMap;
-use std::fs::{read_dir, File};
-use std::io::{Read, Write};
-use std::env;
-use std::path::Path;
-use std::error::Error;
-
-use syntax::diagnostics::metadata::{get_metadata_dir, ErrorMetadataMap, ErrorMetadata};
-
-use rustdoc::html::markdown::Markdown;
-use rustc_serialize::json;
-
-enum OutputFormat {
-    HTML(HTMLFormatter),
-    Markdown(MarkdownFormatter),
-    Unknown(String),
-}
-
-impl OutputFormat {
-    fn from(format: &str) -> OutputFormat {
-        match &*format.to_lowercase() {
-            "html"     => OutputFormat::HTML(HTMLFormatter),
-            "markdown" => OutputFormat::Markdown(MarkdownFormatter),
-            s          => OutputFormat::Unknown(s.to_owned()),
-        }
-    }
-}
-
-trait Formatter {
-    fn header(&self, output: &mut Write) -> Result<(), Box<Error>>;
-    fn title(&self, output: &mut Write) -> Result<(), Box<Error>>;
-    fn error_code_block(&self, output: &mut Write, info: &ErrorMetadata,
-                        err_code: &str) -> Result<(), Box<Error>>;
-    fn footer(&self, output: &mut Write) -> Result<(), Box<Error>>;
-}
-
-struct HTMLFormatter;
-struct MarkdownFormatter;
-
-impl Formatter for HTMLFormatter {
-    fn header(&self, output: &mut Write) -> Result<(), Box<Error>> {
-        try!(write!(output, r##"<!DOCTYPE html>
-<html>
-<head>
-<title>Rust Compiler Error Index</title>
-<meta charset="utf-8">
-<!-- Include rust.css after main.css so its rules take priority. -->
-<link rel="stylesheet" type="text/css" href="main.css"/>
-<link rel="stylesheet" type="text/css" href="rust.css"/>
-<style>
-.error-undescribed {{
-    display: none;
-}}
-</style>
-</head>
-<body>
-"##));
-        Ok(())
-    }
-
-    fn title(&self, output: &mut Write) -> Result<(), Box<Error>> {
-        try!(write!(output, "<h1>Rust Compiler Error Index</h1>\n"));
-        Ok(())
-    }
-
-    fn error_code_block(&self, output: &mut Write, info: &ErrorMetadata,
-                        err_code: &str) -> Result<(), Box<Error>> {
-        // Enclose each error in a div so they can be shown/hidden en masse.
-        let desc_desc = match info.description {
-            Some(_) => "error-described",
-            None => "error-undescribed",
-        };
-        let use_desc = match info.use_site {
-            Some(_) => "error-used",
-            None => "error-unused",
-        };
-        try!(write!(output, "<div class=\"{} {}\">", desc_desc, use_desc));
-
-        // Error title (with self-link).
-        try!(write!(output,
-                    "<h2 id=\"{0}\" class=\"section-header\"><a href=\"#{0}\">{0}</a></h2>\n",
-                    err_code));
-
-        // Description rendered as markdown.
-        match info.description {
-            Some(ref desc) => try!(write!(output, "{}", Markdown(desc))),
-            None => try!(write!(output, "<p>No description.</p>\n")),
-        }
-
-        try!(write!(output, "</div>\n"));
-        Ok(())
-    }
-
-    fn footer(&self, output: &mut Write) -> Result<(), Box<Error>> {
-        try!(write!(output, "</body>\n</html>"));
-        Ok(())
-    }
-}
-
-impl Formatter for MarkdownFormatter {
-    #[allow(unused_variables)]
-    fn header(&self, output: &mut Write) -> Result<(), Box<Error>> {
-        Ok(())
-    }
-
-    fn title(&self, output: &mut Write) -> Result<(), Box<Error>> {
-        try!(write!(output, "# Rust Compiler Error Index\n"));
-        Ok(())
-    }
-
-    fn error_code_block(&self, output: &mut Write, info: &ErrorMetadata,
-                        err_code: &str) -> Result<(), Box<Error>> {
-        Ok(match info.description {
-            Some(ref desc) => try!(write!(output, "## {}\n{}\n", err_code, desc)),
-            None => (),
-        })
-    }
-
-    #[allow(unused_variables)]
-    fn footer(&self, output: &mut Write) -> Result<(), Box<Error>> {
-        Ok(())
-    }
-}
-
-/// Load all the metadata files from `metadata_dir` into an in-memory map.
-fn load_all_errors(metadata_dir: &Path) -> Result<ErrorMetadataMap, Box<Error>> {
-    let mut all_errors = BTreeMap::new();
-
-    for entry in try!(read_dir(metadata_dir)) {
-        let path = try!(entry).path();
-
-        let mut metadata_str = String::new();
-        try!(File::open(&path).and_then(|mut f| f.read_to_string(&mut metadata_str)));
-
-        let some_errors: ErrorMetadataMap = try!(json::decode(&metadata_str));
-
-        for (err_code, info) in some_errors {
-            all_errors.insert(err_code, info);
-        }
-    }
-
-    Ok(all_errors)
-}
-
-/// Output an HTML page for the errors in `err_map` to `output_path`.
-fn render_error_page<T: Formatter>(err_map: &ErrorMetadataMap, output_path: &Path,
-                                   formatter: T) -> Result<(), Box<Error>> {
-    let mut output_file = try!(File::create(output_path));
-
-    try!(formatter.header(&mut output_file));
-    try!(formatter.title(&mut output_file));
-
-    for (err_code, info) in err_map {
-        try!(formatter.error_code_block(&mut output_file, info, err_code));
-    }
-
-    formatter.footer(&mut output_file)
-}
-
-fn main_with_result(format: OutputFormat) -> Result<(), Box<Error>> {
-    let build_arch = try!(env::var("CFG_BUILD"));
-    let metadata_dir = get_metadata_dir(&build_arch);
-    let err_map = try!(load_all_errors(&metadata_dir));
-    match format {
-        OutputFormat::Unknown(s)  => panic!("Unknown output format: {}", s),
-        OutputFormat::HTML(h)     => try!(render_error_page(&err_map,
-                                                            Path::new("doc/error-index.html"),
-                                                            h)),
-        OutputFormat::Markdown(m) => try!(render_error_page(&err_map,
-                                                            Path::new("doc/error-index.md"),
-                                                            m)),
-    }
-    Ok(())
-}
-
-fn parse_args() -> OutputFormat {
-    for arg in env::args().skip(1) {
-        return OutputFormat::from(&arg);
-    }
-    OutputFormat::from("html")
-}
-
-fn main() {
-    if let Err(e) = main_with_result(parse_args()) {
-        panic!("{}", e.description());
-    }
-}
diff --git a/src/error_index_generator/main.rs b/src/error_index_generator/main.rs
new file mode 100644 (file)
index 0000000..db9dd00
--- /dev/null
@@ -0,0 +1,203 @@
+// Copyright 2015 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(rustc_private, rustdoc)]
+
+extern crate syntax;
+extern crate rustdoc;
+extern crate serialize as rustc_serialize;
+
+use std::collections::BTreeMap;
+use std::fs::{read_dir, File};
+use std::io::{Read, Write};
+use std::env;
+use std::path::Path;
+use std::error::Error;
+
+use syntax::diagnostics::metadata::{get_metadata_dir, ErrorMetadataMap, ErrorMetadata};
+
+use rustdoc::html::markdown::Markdown;
+use rustc_serialize::json;
+
+enum OutputFormat {
+    HTML(HTMLFormatter),
+    Markdown(MarkdownFormatter),
+    Unknown(String),
+}
+
+impl OutputFormat {
+    fn from(format: &str) -> OutputFormat {
+        match &*format.to_lowercase() {
+            "html"     => OutputFormat::HTML(HTMLFormatter),
+            "markdown" => OutputFormat::Markdown(MarkdownFormatter),
+            s          => OutputFormat::Unknown(s.to_owned()),
+        }
+    }
+}
+
+trait Formatter {
+    fn header(&self, output: &mut Write) -> Result<(), Box<Error>>;
+    fn title(&self, output: &mut Write) -> Result<(), Box<Error>>;
+    fn error_code_block(&self, output: &mut Write, info: &ErrorMetadata,
+                        err_code: &str) -> Result<(), Box<Error>>;
+    fn footer(&self, output: &mut Write) -> Result<(), Box<Error>>;
+}
+
+struct HTMLFormatter;
+struct MarkdownFormatter;
+
+impl Formatter for HTMLFormatter {
+    fn header(&self, output: &mut Write) -> Result<(), Box<Error>> {
+        try!(write!(output, r##"<!DOCTYPE html>
+<html>
+<head>
+<title>Rust Compiler Error Index</title>
+<meta charset="utf-8">
+<!-- Include rust.css after main.css so its rules take priority. -->
+<link rel="stylesheet" type="text/css" href="main.css"/>
+<link rel="stylesheet" type="text/css" href="rust.css"/>
+<style>
+.error-undescribed {{
+    display: none;
+}}
+</style>
+</head>
+<body>
+"##));
+        Ok(())
+    }
+
+    fn title(&self, output: &mut Write) -> Result<(), Box<Error>> {
+        try!(write!(output, "<h1>Rust Compiler Error Index</h1>\n"));
+        Ok(())
+    }
+
+    fn error_code_block(&self, output: &mut Write, info: &ErrorMetadata,
+                        err_code: &str) -> Result<(), Box<Error>> {
+        // Enclose each error in a div so they can be shown/hidden en masse.
+        let desc_desc = match info.description {
+            Some(_) => "error-described",
+            None => "error-undescribed",
+        };
+        let use_desc = match info.use_site {
+            Some(_) => "error-used",
+            None => "error-unused",
+        };
+        try!(write!(output, "<div class=\"{} {}\">", desc_desc, use_desc));
+
+        // Error title (with self-link).
+        try!(write!(output,
+                    "<h2 id=\"{0}\" class=\"section-header\"><a href=\"#{0}\">{0}</a></h2>\n",
+                    err_code));
+
+        // Description rendered as markdown.
+        match info.description {
+            Some(ref desc) => try!(write!(output, "{}", Markdown(desc))),
+            None => try!(write!(output, "<p>No description.</p>\n")),
+        }
+
+        try!(write!(output, "</div>\n"));
+        Ok(())
+    }
+
+    fn footer(&self, output: &mut Write) -> Result<(), Box<Error>> {
+        try!(write!(output, "</body>\n</html>"));
+        Ok(())
+    }
+}
+
+impl Formatter for MarkdownFormatter {
+    #[allow(unused_variables)]
+    fn header(&self, output: &mut Write) -> Result<(), Box<Error>> {
+        Ok(())
+    }
+
+    fn title(&self, output: &mut Write) -> Result<(), Box<Error>> {
+        try!(write!(output, "# Rust Compiler Error Index\n"));
+        Ok(())
+    }
+
+    fn error_code_block(&self, output: &mut Write, info: &ErrorMetadata,
+                        err_code: &str) -> Result<(), Box<Error>> {
+        Ok(match info.description {
+            Some(ref desc) => try!(write!(output, "## {}\n{}\n", err_code, desc)),
+            None => (),
+        })
+    }
+
+    #[allow(unused_variables)]
+    fn footer(&self, output: &mut Write) -> Result<(), Box<Error>> {
+        Ok(())
+    }
+}
+
+/// Load all the metadata files from `metadata_dir` into an in-memory map.
+fn load_all_errors(metadata_dir: &Path) -> Result<ErrorMetadataMap, Box<Error>> {
+    let mut all_errors = BTreeMap::new();
+
+    for entry in try!(read_dir(metadata_dir)) {
+        let path = try!(entry).path();
+
+        let mut metadata_str = String::new();
+        try!(File::open(&path).and_then(|mut f| f.read_to_string(&mut metadata_str)));
+
+        let some_errors: ErrorMetadataMap = try!(json::decode(&metadata_str));
+
+        for (err_code, info) in some_errors {
+            all_errors.insert(err_code, info);
+        }
+    }
+
+    Ok(all_errors)
+}
+
+/// Output an HTML page for the errors in `err_map` to `output_path`.
+fn render_error_page<T: Formatter>(err_map: &ErrorMetadataMap, output_path: &Path,
+                                   formatter: T) -> Result<(), Box<Error>> {
+    let mut output_file = try!(File::create(output_path));
+
+    try!(formatter.header(&mut output_file));
+    try!(formatter.title(&mut output_file));
+
+    for (err_code, info) in err_map {
+        try!(formatter.error_code_block(&mut output_file, info, err_code));
+    }
+
+    formatter.footer(&mut output_file)
+}
+
+fn main_with_result(format: OutputFormat) -> Result<(), Box<Error>> {
+    let build_arch = try!(env::var("CFG_BUILD"));
+    let metadata_dir = get_metadata_dir(&build_arch);
+    let err_map = try!(load_all_errors(&metadata_dir));
+    match format {
+        OutputFormat::Unknown(s)  => panic!("Unknown output format: {}", s),
+        OutputFormat::HTML(h)     => try!(render_error_page(&err_map,
+                                                            Path::new("doc/error-index.html"),
+                                                            h)),
+        OutputFormat::Markdown(m) => try!(render_error_page(&err_map,
+                                                            Path::new("doc/error-index.md"),
+                                                            m)),
+    }
+    Ok(())
+}
+
+fn parse_args() -> OutputFormat {
+    for arg in env::args().skip(1) {
+        return OutputFormat::from(&arg);
+    }
+    OutputFormat::from("html")
+}
+
+fn main() {
+    if let Err(e) = main_with_result(parse_args()) {
+        panic!("{}", e.description());
+    }
+}
index 34c2cdbef353869d84c96b65529258da36835ace..1687838289babc0bd42cb11587fa995864e07435 100644 (file)
@@ -46,6 +46,7 @@ make = sys.argv[2]
 putenv('RUSTC', os.path.abspath(sys.argv[3]))
 putenv('TMPDIR', os.path.abspath(sys.argv[4]))
 putenv('CC', sys.argv[5] + ' ' + sys.argv[6])
+putenv('CFLAGS', sys.argv[6])
 putenv('RUSTDOC', os.path.abspath(sys.argv[7]))
 filt = sys.argv[8]
 putenv('LD_LIB_PATH_ENVVAR', sys.argv[9])
@@ -55,6 +56,7 @@ putenv('RUST_BUILD_STAGE', sys.argv[12])
 putenv('S', os.path.abspath(sys.argv[13]))
 putenv('RUSTFLAGS', sys.argv[15])
 putenv('LLVM_COMPONENTS', sys.argv[16])
+putenv('LLVM_CXXFLAGS', sys.argv[17])
 putenv('PYTHON', sys.executable)
 os.putenv('TARGET', target_triple)
 
diff --git a/src/etc/regex-match-tests.py b/src/etc/regex-match-tests.py
deleted file mode 100755 (executable)
index ea7f51c..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-#!/usr/bin/env python2
-
-# 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.
-
-from __future__ import absolute_import, division, print_function
-import argparse
-import datetime
-import os.path as path
-
-
-def print_tests(tests):
-    print('\n'.join([test_tostr(t) for t in tests]))
-
-
-def read_tests(f):
-    basename, _ = path.splitext(path.basename(f))
-    tests = []
-    for lineno, line in enumerate(open(f), 1):
-        fields = filter(None, map(str.strip, line.split('\t')))
-        if not (4 <= len(fields) <= 5) \
-           or 'E' not in fields[0] or fields[0][0] == '#':
-            continue
-
-        opts, pat, text, sgroups = fields[0:4]
-        groups = []  # groups as integer ranges
-        if sgroups == 'NOMATCH':
-            groups = [None]
-        elif ',' in sgroups:
-            noparen = map(lambda s: s.strip('()'), sgroups.split(')('))
-            for g in noparen:
-                s, e = map(str.strip, g.split(','))
-                if s == '?' and e == '?':
-                    groups.append(None)
-                else:
-                    groups.append((int(s), int(e)))
-        else:
-            # This skips tests that should result in an error.
-            # There aren't many, so I think we can just capture those
-            # manually. Possibly fix this in future.
-            continue
-
-        if pat == 'SAME':
-            pat = tests[-1][1]
-        if '$' in opts:
-            pat = pat.decode('string_escape')
-            text = text.decode('string_escape')
-        if 'i' in opts:
-            pat = '(?i)%s' % pat
-
-        name = '%s_%d' % (basename, lineno)
-        tests.append((name, pat, text, groups))
-    return tests
-
-
-def test_tostr(t):
-    lineno, pat, text, groups = t
-    options = map(group_tostr, groups)
-    return 'mat!{match_%s, r"%s", r"%s", %s}' \
-           % (lineno, pat, '' if text == "NULL" else text, ', '.join(options))
-
-
-def group_tostr(g):
-    if g is None:
-        return 'None'
-    else:
-        return 'Some((%d, %d))' % (g[0], g[1])
-
-
-if __name__ == '__main__':
-    parser = argparse.ArgumentParser(
-        description='Generate match tests from an AT&T POSIX test file.')
-    aa = parser.add_argument
-    aa('files', nargs='+',
-       help='A list of dat AT&T POSIX test files. See src/libregexp/testdata')
-    args = parser.parse_args()
-
-    tests = []
-    for f in args.files:
-        tests += read_tests(f)
-
-    tpl = '''// 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.
-
-// ignore-tidy-linelength
-
-// DO NOT EDIT. Automatically generated by 'src/etc/regexp-match-tests'
-// on {date}.
-'''
-    print(tpl.format(date=str(datetime.datetime.now())))
-
-    for f in args.files:
-        print('// Tests from %s' % path.basename(f))
-        print_tests(read_tests(f))
-        print('')
index 4bc752af48eee5fdfb58a41b5fbb5b37ea987bc5..c9508322a31a7d7292d14b25426b562b31d08519 100644 (file)
@@ -50,7 +50,7 @@ fn main() {
        .env("AR", &ar)
        .env("RANLIB", format!("{} s", ar.display()));
 
-    if target.contains("windows-gnu") {
+    if target.contains("windows") {
         // A bit of history here, this used to be --enable-lazy-lock added in
         // #14006 which was filed with jemalloc in jemalloc/jemalloc#83 which
         // was also reported to MinGW:
@@ -72,7 +72,19 @@ fn main() {
         //        locking, but requires passing an option due to a historical
         //        default with jemalloc.
         cmd.arg("--disable-lazy-lock");
-    } else if target.contains("ios") || target.contains("android") {
+    } else if target.contains("ios") {
+        cmd.arg("--disable-tls");
+    } else if target.contains("android") {
+        // We force android to have prefixed symbols because apparently
+        // replacement of the libc allocator doesn't quite work. When this was
+        // tested (unprefixed symbols), it was found that the `realpath`
+        // function in libc would allocate with libc malloc (not jemalloc
+        // malloc), and then the standard library would free with jemalloc free,
+        // causing a segfault.
+        //
+        // If the test suite passes, however, without symbol prefixes then we
+        // should be good to go!
+        cmd.arg("--with-jemalloc-prefix=je_");
         cmd.arg("--disable-tls");
     }
 
@@ -82,7 +94,6 @@ fn main() {
 
     // Turn off broken quarantine (see jemalloc/jemalloc#161)
     cmd.arg("--disable-fill");
-    cmd.arg("--with-jemalloc-prefix=je_");
     cmd.arg(format!("--host={}", build_helper::gnu_target(&target)));
     cmd.arg(format!("--build={}", build_helper::gnu_target(&host)));
 
index 2c46e37ac32b20e7aa7efe7c83975c8f1da58990..bda001eb4f426fbac09f0de84a7eeeb01ec62542 100644 (file)
 #[cfg(not(cargobuild))]
 extern {}
 
+// Note that the symbols here are prefixed by default on OSX (we don't
+// explicitly request it), and on Android we explicitly request it as
+// unprefixing cause segfaults (mismatches in allocators).
 extern {
-    fn je_mallocx(size: size_t, flags: c_int) -> *mut c_void;
-    fn je_rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void;
-    fn je_xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t;
-    fn je_sdallocx(ptr: *mut c_void, size: size_t, flags: c_int);
-    fn je_nallocx(size: size_t, flags: c_int) -> size_t;
+    #[cfg_attr(any(target_os = "macos", target_os = "android"),
+               link_name = "je_mallocx")]
+    fn mallocx(size: size_t, flags: c_int) -> *mut c_void;
+    #[cfg_attr(any(target_os = "macos", target_os = "android"),
+               link_name = "je_rallocx")]
+    fn rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void;
+    #[cfg_attr(any(target_os = "macos", target_os = "android"),
+               link_name = "je_xallocx")]
+    fn xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t;
+    #[cfg_attr(any(target_os = "macos", target_os = "android"),
+               link_name = "je_sdallocx")]
+    fn sdallocx(ptr: *mut c_void, size: size_t, flags: c_int);
+    #[cfg_attr(any(target_os = "macos", target_os = "android"),
+               link_name = "je_nallocx")]
+    fn nallocx(size: size_t, flags: c_int) -> size_t;
 }
 
 // The minimum alignment guaranteed by the architecture. This value is used to
@@ -78,7 +91,7 @@ fn align_to_flags(align: usize) -> c_int {
 #[no_mangle]
 pub extern "C" fn __rust_allocate(size: usize, align: usize) -> *mut u8 {
     let flags = align_to_flags(align);
-    unsafe { je_mallocx(size as size_t, flags) as *mut u8 }
+    unsafe { mallocx(size as size_t, flags) as *mut u8 }
 }
 
 #[no_mangle]
@@ -88,7 +101,7 @@ pub extern "C" fn __rust_reallocate(ptr: *mut u8,
                                     align: usize)
                                     -> *mut u8 {
     let flags = align_to_flags(align);
-    unsafe { je_rallocx(ptr as *mut c_void, size as size_t, flags) as *mut u8 }
+    unsafe { rallocx(ptr as *mut c_void, size as size_t, flags) as *mut u8 }
 }
 
 #[no_mangle]
@@ -98,19 +111,19 @@ pub extern "C" fn __rust_reallocate_inplace(ptr: *mut u8,
                                             align: usize)
                                             -> usize {
     let flags = align_to_flags(align);
-    unsafe { je_xallocx(ptr as *mut c_void, size as size_t, 0, flags) as usize }
+    unsafe { xallocx(ptr as *mut c_void, size as size_t, 0, flags) as usize }
 }
 
 #[no_mangle]
 pub extern "C" fn __rust_deallocate(ptr: *mut u8, old_size: usize, align: usize) {
     let flags = align_to_flags(align);
-    unsafe { je_sdallocx(ptr as *mut c_void, old_size as size_t, flags) }
+    unsafe { sdallocx(ptr as *mut c_void, old_size as size_t, flags) }
 }
 
 #[no_mangle]
 pub extern "C" fn __rust_usable_size(size: usize, align: usize) -> usize {
     let flags = align_to_flags(align);
-    unsafe { je_nallocx(size as size_t, flags) as usize }
+    unsafe { nallocx(size as size_t, flags) as usize }
 }
 
 // These symbols are used by jemalloc on android but the really old android
index 805d9a9807a33172c7ed3b8c9cccb978598d70c1..270a01014c14b0051523f0ce2c2800e1317113ca 100644 (file)
@@ -8,8 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-//! A growable list type with heap-allocated contents, written `Vec<T>` but
-//! pronounced 'vector.'
+//! A contiguous growable array type with heap-allocated contents, written
+//! `Vec<T>` but pronounced 'vector.'
 //!
 //! Vectors have `O(1)` indexing, amortized `O(1)` push (to the end) and
 //! `O(1)` pop (from the end).
@@ -78,7 +78,7 @@
 
 use super::range::RangeArgument;
 
-/// A growable list type, written `Vec<T>` but pronounced 'vector.'
+/// A contiguous growable array type, written `Vec<T>` but pronounced 'vector.'
 ///
 /// # Examples
 ///
@@ -528,7 +528,7 @@ pub fn swap_remove(&mut self, index: usize) -> T {
     }
 
     /// Inserts an element at position `index` within the vector, shifting all
-    /// elements after position `i` one position to the right.
+    /// elements after it to the right.
     ///
     /// # Panics
     ///
@@ -570,7 +570,7 @@ pub fn insert(&mut self, index: usize, element: T) {
     }
 
     /// Removes and returns the element at position `index` within the vector,
-    /// shifting all elements after position `index` one position to the left.
+    /// shifting all elements after it to the left.
     ///
     /// # Panics
     ///
index 9a9dfaa26797a3977c39708940c4cefcce3a8dc9..ed370bb91648fc457a9359bdae4d4667a8701783 100644 (file)
@@ -479,7 +479,7 @@ pub fn checked_rem(self, other: Self) -> Option<Self> {
             }
         }
 
-        /// Checked negation. Computes `!self`, returning `None` if `self ==
+        /// Checked negation. Computes `-self`, returning `None` if `self ==
         /// MIN`.
         ///
         /// # Examples
@@ -741,6 +741,13 @@ pub fn wrapping_neg(self) -> Self {
         /// where `mask` removes any high-order bits of `rhs` that
         /// would cause the shift to exceed the bitwidth of the type.
         ///
+        /// Note that this is *not* the same as a rotate-left; the
+        /// RHS of a wrapping shift-left is restricted to the range
+        /// of the type, rather than the bits shifted out of the LHS
+        /// being returned to the other end. The primitive integer
+        /// types all implement a `rotate_left` function, which may
+        /// be what you want instead.
+        ///
         /// # Examples
         ///
         /// Basic usage:
@@ -759,6 +766,13 @@ pub fn wrapping_shl(self, rhs: u32) -> Self {
         /// where `mask` removes any high-order bits of `rhs` that
         /// would cause the shift to exceed the bitwidth of the type.
         ///
+        /// Note that this is *not* the same as a rotate-right; the
+        /// RHS of a wrapping shift-right is restricted to the range
+        /// of the type, rather than the bits shifted out of the LHS
+        /// being returned to the other end. The primitive integer
+        /// types all implement a `rotate_right` function, which may
+        /// be what you want instead.
+        ///
         /// # Examples
         ///
         /// Basic usage:
index 68e50e8a400ea021a472b0542c64509c7eaa976c..d7e320267c60777c8dafa3a304a36db74cf0d771 100644 (file)
@@ -14,4 +14,4 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-uint_module! { u16, i16, 16 }
+uint_module! { u16, 16 }
index c1ee96b363c27783e016f113c6a59b54e0a3f651..9a26a39d5b36546b2f22c2ab1998dcbf346bfdcf 100644 (file)
@@ -14,4 +14,4 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-uint_module! { u32, i32, 32 }
+uint_module! { u32, 32 }
index c0d18d850a796d9a841c17f85c448a42f5becb47..e12c2c265420bcef49127a67cbbb10da64d7aa78 100644 (file)
@@ -14,4 +14,4 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-uint_module! { u64, i64, 64 }
+uint_module! { u64, 64 }
index a60c480d810ea4e20be74b5add6271c9e95c7760..0eb63bd9f3a9d863b74a7951958915e2bdab935a 100644 (file)
@@ -14,4 +14,4 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-uint_module! { u8, i8, 8 }
+uint_module! { u8, 8 }
index 16d84cf81e11db8a74608c2ebd9f3404476e65fa..9539a311390f6407e96c7456c61839adf232df46 100644 (file)
@@ -10,7 +10,7 @@
 
 #![doc(hidden)]
 
-macro_rules! uint_module { ($T:ty, $T_SIGNED:ty, $bits:expr) => (
+macro_rules! uint_module { ($T:ty, $bits:expr) => (
 
 #[unstable(feature = "num_bits_bytes",
            reason = "may want to be an associated function",
index a6a7be023ebf4e3851fff0372f51090f54b21e7a..875ab32fa8c572efdd9d5339128b55d27926b320 100644 (file)
@@ -15,6 +15,6 @@
 #![stable(feature = "rust1", since = "1.0.0")]
 
 #[cfg(target_pointer_width = "32")]
-uint_module! { usize, isize, 32 }
+uint_module! { usize, 32 }
 #[cfg(target_pointer_width = "64")]
-uint_module! { usize, isize, 64 }
+uint_module! { usize, 64 }
index a826f2bb4440f9e4d344fa29d2886bab8b01584a..3cbb2f17be78b0343aa63d42c9596343df5e18b5 100644 (file)
@@ -127,8 +127,7 @@ pub unsafe fn read<T>(src: *const T) -> T {
     tmp
 }
 
-/// Variant of read_and_zero that writes the specific drop-flag byte
-/// (which may be more appropriate than zero).
+#[allow(missing_docs)]
 #[inline(always)]
 #[unstable(feature = "filling_drop",
            reason = "may play a larger role in std::ptr future extensions",
index fa169416a1081ab6042fe2327ae8f71e99b8cb54..4d367cfd432f94a2f5333ec3bbbcdc94b33b493c 100644 (file)
@@ -157,7 +157,7 @@ impl Utf8Error {
     /// // std::str::from_utf8 returns a Utf8Error
     /// let error = str::from_utf8(&sparkle_heart).unwrap_err();
     ///
-    /// // the first byte is invalid here
+    /// // the second byte is invalid here
     /// assert_eq!(1, error.valid_up_to());
     /// ```
     #[stable(feature = "utf8_error", since = "1.5.0")]
@@ -174,10 +174,10 @@ pub fn valid_up_to(&self) -> usize { self.valid_up_to }
 ///
 /// If you are sure that the byte slice is valid UTF-8, and you don't want to
 /// incur the overhead of the validity check, there is an unsafe version of
-/// this function, [`from_utf8_unchecked()`][fromutf8], which has the same
+/// this function, [`from_utf8_unchecked()`][fromutf8u], which has the same
 /// behavior but skips the check.
 ///
-/// [fromutf8]: fn.from_utf8.html
+/// [fromutf8u]: fn.from_utf8_unchecked.html
 ///
 /// If you need a `String` instead of a `&str`, consider
 /// [`String::from_utf8()`][string].
@@ -275,7 +275,7 @@ unsafe fn from_raw_parts_mut<'a>(p: *mut u8, len: usize) -> &'a mut str {
 /// Converts a slice of bytes to a string slice without checking
 /// that the string contains valid UTF-8.
 ///
-/// See the safe version, [`from_utf8()`][fromutf8], for more.
+/// See the safe version, [`from_utf8()`][fromutf8], for more information.
 ///
 /// [fromutf8]: fn.from_utf8.html
 ///
index 15e368812f25d99a9ec729c68beafeeacd88eeea..26ea5454693e1bd741051ca2c8d7edf46ce0881c 100644 (file)
@@ -88,8 +88,6 @@ pub struct InferCtxt<'a, 'tcx: 'a> {
 
     pub parameter_environment: ty::ParameterEnvironment<'a, 'tcx>,
 
-    pub fulfillment_cx: RefCell<traits::FulfillmentContext<'tcx>>,
-
     // the set of predicates on which errors have been reported, to
     // avoid reporting the same error twice.
     pub reported_trait_errors: RefCell<FnvHashSet<traits::TraitErrorKey<'tcx>>>,
@@ -366,7 +364,6 @@ pub fn new_infer_ctxt<'a, 'tcx>(tcx: &'a ty::ctxt<'tcx>,
         float_unification_table: RefCell::new(UnificationTable::new()),
         region_vars: RegionVarBindings::new(tcx),
         parameter_environment: param_env.unwrap_or(tcx.empty_parameter_environment()),
-        fulfillment_cx: RefCell::new(traits::FulfillmentContext::new()),
         reported_trait_errors: RefCell::new(FnvHashSet()),
         normalize: false,
         err_count_on_creation: tcx.sess.err_count()
@@ -525,7 +522,7 @@ pub fn normalize_associated_type<'tcx,T>(tcx: &ty::ctxt<'tcx>, value: &T) -> T
            result,
            obligations);
 
-    let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
+    let mut fulfill_cx = traits::FulfillmentContext::new();
 
     for obligation in obligations {
         fulfill_cx.register_predicate_obligation(&infcx, obligation);
index bb411e76e929bbe935377b9bf08d9c33b9279579..c89aa4c18333cde85362b2050c9bb86f40a59c54 100644 (file)
@@ -133,7 +133,7 @@ pub fn normalize_projection_type<'a>(&mut self,
                                          cause: ObligationCause<'tcx>)
                                          -> Ty<'tcx>
     {
-        debug!("normalize_associated_type(projection_ty={:?})",
+        debug!("normalize_projection_type(projection_ty={:?})",
                projection_ty);
 
         assert!(!projection_ty.has_escaping_regions());
@@ -147,7 +147,7 @@ pub fn normalize_projection_type<'a>(&mut self,
             self.register_predicate_obligation(infcx, obligation);
         }
 
-        debug!("normalize_associated_type: result={:?}", normalized.value);
+        debug!("normalize_projection_type: result={:?}", normalized.value);
 
         normalized.value
     }
@@ -185,11 +185,11 @@ pub fn register_predicate_obligation<'a>(&mut self,
         assert!(!obligation.has_escaping_regions());
 
         if self.is_duplicate_or_add(infcx.tcx, &obligation.predicate) {
-            debug!("register_predicate({:?}) -- already seen, skip", obligation);
+            debug!("register_predicate_obligation({:?}) -- already seen, skip", obligation);
             return;
         }
 
-        debug!("register_predicate({:?})", obligation);
+        debug!("register_predicate_obligation({:?})", obligation);
         let obligation = PendingPredicateObligation {
             obligation: obligation,
             stalled_on: vec![]
@@ -274,7 +274,7 @@ fn select<'a>(&mut self,
         let mut errors = Vec::new();
 
         loop {
-            debug!("select_where_possible: starting another iteration");
+            debug!("select: starting another iteration");
 
             // Process pending obligations.
             let outcome = {
@@ -287,7 +287,7 @@ fn select<'a>(&mut self,
                                                                      region_obligations))
             };
 
-            debug!("select_where_possible: outcome={:?}", outcome);
+            debug!("select: outcome={:?}", outcome);
 
             // these are obligations that were proven to be true.
             for pending_obligation in outcome.completed {
index c96713a72851a3ff930e06eef53bdc70d49e2d5c..864ff40fe10748479c01939c744e0f39afe8240b 100644 (file)
@@ -28,6 +28,7 @@
 use syntax::attr::AttrMetaMethods;
 use syntax::errors::{ColorConfig, Handler};
 use syntax::parse;
+use syntax::parse::lexer::Reader;
 use syntax::parse::token::InternedString;
 use syntax::feature_gate::UnstableFeatures;
 
@@ -509,7 +510,7 @@ fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool {
     link_args: Option<Vec<String>> = (None, parse_opt_list,
         "extra arguments to pass to the linker (space separated)"),
     link_dead_code: bool = (false, parse_bool,
-        "let the linker strip dead coded (turning it on can be used for code coverage)"),
+        "don't let linker strip dead code (turning it on can be used for code coverage)"),
     lto: bool = (false, parse_bool,
         "perform LLVM link-time optimizations"),
     target_cpu: Option<String> = (None, parse_opt_string,
@@ -906,10 +907,19 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
 // Convert strings provided as --cfg [cfgspec] into a crate_cfg
 pub fn parse_cfgspecs(cfgspecs: Vec<String> ) -> ast::CrateConfig {
     cfgspecs.into_iter().map(|s| {
-        parse::parse_meta_from_source_str("cfgspec".to_string(),
-                                          s.to_string(),
-                                          Vec::new(),
-                                          &parse::ParseSess::new())
+        let sess = parse::ParseSess::new();
+        let mut parser = parse::new_parser_from_source_str(&sess,
+                                                           Vec::new(),
+                                                           "cfgspec".to_string(),
+                                                           s.to_string());
+        let meta_item = panictry!(parser.parse_meta_item());
+
+        if !parser.reader.is_eof() {
+            early_error(ErrorOutputType::default(), &format!("invalid --cfg argument: {}",
+                                                             s))
+        }
+
+        meta_item
     }).collect::<ast::CrateConfig>()
 }
 
diff --git a/src/librustc_back/target/i586_unknown_linux_gnu.rs b/src/librustc_back/target/i586_unknown_linux_gnu.rs
new file mode 100644 (file)
index 0000000..42d5674
--- /dev/null
@@ -0,0 +1,28 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use target::Target;
+
+pub fn target() -> Target {
+    let mut base = super::linux_base::opts();
+    base.cpu = "pentium".to_string();
+    base.pre_link_args.push("-m32".to_string());
+
+    Target {
+        llvm_target: "i586-unknown-linux-gnu".to_string(),
+        target_endian: "little".to_string(),
+        target_pointer_width: "32".to_string(),
+        arch: "x86".to_string(),
+        target_os: "linux".to_string(),
+        target_env: "gnu".to_string(),
+        target_vendor: "unknown".to_string(),
+        options: base,
+    }
+}
index 96b2d37ab2088135a374386130487e12905b1533..7fe6590618941acfaa55182e7bfb484d64404be6 100644 (file)
@@ -14,6 +14,15 @@ pub fn target() -> Target {
     let mut base = super::windows_msvc_base::opts();
     base.cpu = "pentium4".to_string();
 
+    // Mark all dynamic libraries and executables as compatible with the larger 4GiB address
+    // space available to x86 Windows binaries on x86_64.
+    base.pre_link_args.push("/LARGEADDRESSAWARE".to_string());
+
+    // Ensure the linker will only produce an image if it can also produce a table of
+    // the image's safe exception handlers.
+    // https://msdn.microsoft.com/en-us/library/9a89h429.aspx
+    base.pre_link_args.push("/SAFESEH".to_string());
+
     Target {
         llvm_target: "i686-pc-windows-msvc".to_string(),
         target_endian: "little".to_string(),
index 95b7c2e3f0748a304ffecd2423f567d70aa7303b..a868178b14fb9d8aabcc8b2dc737926ef5a95133 100644 (file)
@@ -89,6 +89,7 @@ fn load_specific(target: &str) -> Option<Target> {
 supported_targets! {
     ("x86_64-unknown-linux-gnu", x86_64_unknown_linux_gnu),
     ("i686-unknown-linux-gnu", i686_unknown_linux_gnu),
+    ("i586-unknown-linux-gnu", i586_unknown_linux_gnu),
     ("mips-unknown-linux-gnu", mips_unknown_linux_gnu),
     ("mipsel-unknown-linux-gnu", mipsel_unknown_linux_gnu),
     ("powerpc-unknown-linux-gnu", powerpc_unknown_linux_gnu),
index 6f4dc28e12221c13c423f67e9b6904dde5c029a8..da5f9f20892007c764f0a27a54f27820505a2c67 100644 (file)
@@ -35,10 +35,12 @@ pub fn FnvHashSet<V: Hash + Eq>() -> FnvHashSet<V> {
 pub struct FnvHasher(u64);
 
 impl Default for FnvHasher {
+    #[inline]
     fn default() -> FnvHasher { FnvHasher(0xcbf29ce484222325) }
 }
 
 impl Hasher for FnvHasher {
+    #[inline]
     fn write(&mut self, bytes: &[u8]) {
         let FnvHasher(mut hash) = *self;
         for byte in bytes {
@@ -47,5 +49,7 @@ fn write(&mut self, bytes: &[u8]) {
         }
         *self = FnvHasher(hash);
     }
+
+    #[inline]
     fn finish(&self) -> u64 { self.0 }
 }
index 4a82aa7282599e2c18c5c65c172492f7e2c0a38f..0517357892161c6ffdb1da1bbeb460841292f88d 100644 (file)
@@ -30,6 +30,8 @@
 use rustc_resolve as resolve;
 use rustc_metadata::cstore::CStore;
 
+use rustc_mir::pretty::write_mir_pretty;
+
 use syntax::ast::{self, BlockCheckMode};
 use syntax::codemap;
 use syntax::fold::{self, Folder};
@@ -77,6 +79,7 @@ pub enum PpMode {
     PpmSource(PpSourceMode),
     PpmHir(PpSourceMode),
     PpmFlowGraph(PpFlowGraphMode),
+    PpmMir,
 }
 
 pub fn parse_pretty(sess: &Session,
@@ -96,6 +99,7 @@ pub fn parse_pretty(sess: &Session,
         ("hir", true) => PpmHir(PpmNormal),
         ("hir,identified", true) => PpmHir(PpmIdentified),
         ("hir,typed", true) => PpmHir(PpmTyped),
+        ("mir", true) => PpmMir,
         ("flowgraph", true) => PpmFlowGraph(PpFlowGraphMode::Default),
         ("flowgraph,unlabelled", true) => PpmFlowGraph(PpFlowGraphMode::UnlabelledEdges),
         _ => {
@@ -103,7 +107,7 @@ pub fn parse_pretty(sess: &Session,
                 sess.fatal(&format!("argument to `unpretty` must be one of `normal`, \
                                      `expanded`, `flowgraph[,unlabelled]=<nodeid>`, \
                                      `identified`, `expanded,identified`, `everybody_loops`, \
-                                     `hir`, `hir,identified`, or `hir,typed`; got {}",
+                                     `hir`, `hir,identified`, `hir,typed`, or `mir`; got {}",
                                     name));
             } else {
                 sess.fatal(&format!("argument to `pretty` must be one of `normal`, `expanded`, \
@@ -569,6 +573,7 @@ fn needs_ast_map(ppm: &PpMode, opt_uii: &Option<UserIdentifiedItem>) -> bool {
         PpmSource(PpmExpandedIdentified) |
         PpmSource(PpmExpandedHygiene) |
         PpmHir(_) |
+        PpmMir |
         PpmFlowGraph(_) => true,
         PpmSource(PpmTyped) => panic!("invalid state"),
     }
@@ -584,6 +589,7 @@ fn needs_expansion(ppm: &PpMode) -> bool {
         PpmSource(PpmExpandedIdentified) |
         PpmSource(PpmExpandedHygiene) |
         PpmHir(_) |
+        PpmMir |
         PpmFlowGraph(_) => true,
         PpmSource(PpmTyped) => panic!("invalid state"),
     }
@@ -801,6 +807,48 @@ pub fn pretty_print_input(sess: Session,
             })
         }
 
+        (PpmMir, None) => {
+            debug!("pretty printing MIR for whole crate");
+            let ast_map = ast_map.expect("--unpretty mir missing ast_map");
+            abort_on_err(driver::phase_3_run_analysis_passes(&sess,
+                                                             &cstore,
+                                                             ast_map,
+                                                             &arenas,
+                                                             &id,
+                                                             resolve::MakeGlobMap::No,
+                                                             |tcx, mir_map, _, _| {
+                let mir_map = mir_map.unwrap();
+
+                for (nodeid, mir) in &mir_map.map {
+                    try!(writeln!(out, "MIR for {}", tcx.map.node_to_string(*nodeid)));
+                    try!(write_mir_pretty(mir, &mut out));
+                }
+
+                Ok(())
+            }), &sess)
+        }
+
+        (PpmMir, Some(uii)) => {
+            debug!("pretty printing MIR for {:?}", uii);
+            let ast_map = ast_map.expect("--unpretty mir missing ast_map");
+            let nodeid = uii.to_one_node_id("--unpretty", &sess, &ast_map);
+
+            abort_on_err(driver::phase_3_run_analysis_passes(&sess,
+                                                             &cstore,
+                                                             ast_map,
+                                                             &arenas,
+                                                             &id,
+                                                             resolve::MakeGlobMap::No,
+                                                             |tcx, mir_map, _, _| {
+                let mir_map = mir_map.unwrap();
+                try!(writeln!(out, "MIR for {}", tcx.map.node_to_string(nodeid)));
+                let mir = mir_map.map.get(&nodeid).unwrap_or_else(|| {
+                    sess.fatal(&format!("no MIR map entry for node {}", nodeid))
+                });
+                write_mir_pretty(mir, &mut out)
+            }), &sess)
+        }
+
         (PpmFlowGraph(mode), opt_uii) => {
             debug!("pretty printing flow graph for {:?}", opt_uii);
             let uii = opt_uii.unwrap_or_else(|| {
index 977f271c3014aa77148bf4aeb99f2f845c4b72ac..bb113a7ad6a773444f547aa17ac20059274b892f 100644 (file)
@@ -913,26 +913,29 @@ pub fn lower_pat(lctx: &LoweringContext, p: &Pat) -> P<hir::Pat> {
     P(hir::Pat {
         id: p.id,
         node: match p.node {
-            PatWild => hir::PatWild,
-            PatIdent(ref binding_mode, pth1, ref sub) => {
+            PatKind::Wild => hir::PatWild,
+            PatKind::Ident(ref binding_mode, pth1, ref sub) => {
                 hir::PatIdent(lower_binding_mode(lctx, binding_mode),
                               respan(pth1.span, lower_ident(lctx, pth1.node)),
                               sub.as_ref().map(|x| lower_pat(lctx, x)))
             }
-            PatLit(ref e) => hir::PatLit(lower_expr(lctx, e)),
-            PatEnum(ref pth, ref pats) => {
+            PatKind::Lit(ref e) => hir::PatLit(lower_expr(lctx, e)),
+            PatKind::TupleStruct(ref pth, ref pats) => {
                 hir::PatEnum(lower_path(lctx, pth),
                              pats.as_ref()
                                  .map(|pats| pats.iter().map(|x| lower_pat(lctx, x)).collect()))
             }
-            PatQPath(ref qself, ref pth) => {
+            PatKind::Path(ref pth) => {
+                hir::PatEnum(lower_path(lctx, pth), Some(hir::HirVec::new()))
+            }
+            PatKind::QPath(ref qself, ref pth) => {
                 let qself = hir::QSelf {
                     ty: lower_ty(lctx, &qself.ty),
                     position: qself.position,
                 };
                 hir::PatQPath(qself, lower_path(lctx, pth))
             }
-            PatStruct(ref pth, ref fields, etc) => {
+            PatKind::Struct(ref pth, ref fields, etc) => {
                 let pth = lower_path(lctx, pth);
                 let fs = fields.iter()
                                .map(|f| {
@@ -948,20 +951,22 @@ pub fn lower_pat(lctx: &LoweringContext, p: &Pat) -> P<hir::Pat> {
                                .collect();
                 hir::PatStruct(pth, fs, etc)
             }
-            PatTup(ref elts) => hir::PatTup(elts.iter().map(|x| lower_pat(lctx, x)).collect()),
-            PatBox(ref inner) => hir::PatBox(lower_pat(lctx, inner)),
-            PatRegion(ref inner, mutbl) => {
+            PatKind::Tup(ref elts) => {
+                hir::PatTup(elts.iter().map(|x| lower_pat(lctx, x)).collect())
+            }
+            PatKind::Box(ref inner) => hir::PatBox(lower_pat(lctx, inner)),
+            PatKind::Ref(ref inner, mutbl) => {
                 hir::PatRegion(lower_pat(lctx, inner), lower_mutability(lctx, mutbl))
             }
-            PatRange(ref e1, ref e2) => {
+            PatKind::Range(ref e1, ref e2) => {
                 hir::PatRange(lower_expr(lctx, e1), lower_expr(lctx, e2))
             }
-            PatVec(ref before, ref slice, ref after) => {
+            PatKind::Vec(ref before, ref slice, ref after) => {
                 hir::PatVec(before.iter().map(|x| lower_pat(lctx, x)).collect(),
                             slice.as_ref().map(|x| lower_pat(lctx, x)),
                             after.iter().map(|x| lower_pat(lctx, x)).collect())
             }
-            PatMac(_) => panic!("Shouldn't exist here"),
+            PatKind::Mac(_) => panic!("Shouldn't exist here"),
         },
         span: p.span,
     })
index 3d7c61cd2c1b42835a026085a18b0d3dce366fec..167317f426b7160b853cf955bc41847b16ca9d30 100644 (file)
@@ -622,8 +622,8 @@ fn build_free<'tcx>(tcx: &ty::ctxt<'tcx>,
                     unit_temp: Lvalue<'tcx>,
                     data: &FreeData<'tcx>,
                     target: BasicBlock) -> Terminator<'tcx> {
-    let free_func = tcx.lang_items.box_free_fn()
-                       .expect("box_free language item is missing");
+    let free_func = tcx.lang_items.require(lang_items::BoxFreeFnLangItem)
+                       .unwrap_or_else(|e| tcx.sess.fatal(&e));
     let substs = tcx.mk_substs(Substs::new(
         VecPerParamSpace::new(vec![], vec![], vec![data.item_ty]),
         VecPerParamSpace::new(vec![], vec![], vec![])
index edbc6424ccd90dcc64e45ffb062550ef5f623739..54dcda27b77a3b6823f22f6dab83ecc55d9cca46 100644 (file)
@@ -13,7 +13,7 @@
 
 use rustc::session::{Session, CompileResult};
 
-use syntax::ast;
+use syntax::ast::{self, PatKind};
 use syntax::visit::{self, Visitor, FnKind};
 use syntax::codemap::Span;
 
@@ -104,8 +104,8 @@ fn visit_fn(&mut self,
         // Ensure the arguments are simple, not mutable/by-ref or patterns.
         for arg in &fd.inputs {
             match arg.pat.node {
-                ast::PatWild => {}
-                ast::PatIdent(ast::BindingMode::ByValue(ast::Mutability::Immutable), _, None) => {}
+                PatKind::Wild => {}
+                PatKind::Ident(ast::BindingMode::ByValue(ast::Mutability::Immutable), _, None) => {}
                 _ => {
                     span_err!(self.sess, arg.pat.span, E0022,
                               "arguments of constant functions can only \
index 50dd33ca993cf42454b737ad7e1294faedf51603..c3699735ae8670cbe50ff230c4ec872e37252312 100644 (file)
@@ -249,9 +249,9 @@ fn check_static_type(&self, e: &hir::Expr) {
         let ty = self.tcx.node_id_to_type(e.id);
         let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, None);
         let cause = traits::ObligationCause::new(e.span, e.id, traits::SharedStatic);
-        let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
-        fulfill_cx.register_builtin_bound(&infcx, ty, ty::BoundSync, cause);
-        match fulfill_cx.select_all_or_error(&infcx) {
+        let mut fulfillment_cx = traits::FulfillmentContext::new();
+        fulfillment_cx.register_builtin_bound(&infcx, ty, ty::BoundSync, cause);
+        match fulfillment_cx.select_all_or_error(&infcx) {
             Ok(()) => { },
             Err(ref errors) => {
                 traits::report_fulfillment_errors(&infcx, errors);
index 775ed34ab073cc01f957ea754256476dcfe940d7..5c94c6e4369b09288f336f9046e8f6310385c1a9 100644 (file)
@@ -306,6 +306,7 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent: Module<'b>) -> M
                 let def = Def::Mod(self.ast_map.local_def_id(item.id));
                 let module = self.new_module(parent_link, Some(def), false, is_public);
                 self.define(parent, name, TypeNS, (module, sp));
+                parent.module_children.borrow_mut().insert(item.id, module);
                 module
             }
 
@@ -474,7 +475,7 @@ fn build_reduced_graph_for_block(&mut self, block: &Block, parent: Module<'b>) -
 
             let parent_link = BlockParentLink(parent, block_id);
             let new_module = self.new_module(parent_link, None, false, false);
-            parent.anonymous_children.borrow_mut().insert(block_id, new_module);
+            parent.module_children.borrow_mut().insert(block_id, new_module);
             new_module
         } else {
             parent
index f0e4d7578e373e6f4044f0db32a6ff0dadd352a0..3244d2f1d96090cfd50249366414b68937d4f4a3 100644 (file)
@@ -798,12 +798,12 @@ pub struct ModuleS<'a> {
     is_public: bool,
     is_extern_crate: bool,
 
-    children: RefCell<HashMap<(Name, Namespace), NameResolution<'a>>>,
+    resolutions: RefCell<HashMap<(Name, Namespace), NameResolution<'a>>>,
     imports: RefCell<Vec<ImportDirective>>,
 
-    // The anonymous children of this node. Anonymous children are pseudo-
-    // modules that are implicitly created around items contained within
-    // blocks.
+    // The module children of this node, including normal modules and anonymous modules.
+    // Anonymous children are pseudo-modules that are implicitly created around items
+    // contained within blocks.
     //
     // For example, if we have this:
     //
@@ -815,7 +815,7 @@ pub struct ModuleS<'a> {
     //
     // There will be an anonymous module created around `g` with the ID of the
     // entry block for `f`.
-    anonymous_children: RefCell<NodeMap<Module<'a>>>,
+    module_children: RefCell<NodeMap<Module<'a>>>,
 
     shadowed_traits: RefCell<Vec<&'a NameBinding<'a>>>,
 
@@ -846,9 +846,9 @@ fn new(parent_link: ParentLink<'a>, def: Option<Def>, external: bool, is_public:
             def: def,
             is_public: is_public,
             is_extern_crate: false,
-            children: RefCell::new(HashMap::new()),
+            resolutions: RefCell::new(HashMap::new()),
             imports: RefCell::new(Vec::new()),
-            anonymous_children: RefCell::new(NodeMap()),
+            module_children: RefCell::new(NodeMap()),
             shadowed_traits: RefCell::new(Vec::new()),
             glob_count: Cell::new(0),
             pub_count: Cell::new(0),
@@ -863,7 +863,7 @@ fn resolve_name(&self, name: Name, ns: Namespace, allow_private_imports: bool)
         let glob_count =
             if allow_private_imports { self.glob_count.get() } else { self.pub_glob_count.get() };
 
-        self.children.borrow().get(&(name, ns)).cloned().unwrap_or_default().result(glob_count)
+        self.resolutions.borrow().get(&(name, ns)).cloned().unwrap_or_default().result(glob_count)
             .and_then(|binding| {
                 let allowed = allow_private_imports || !binding.is_import() || binding.is_public();
                 if allowed { Success(binding) } else { Failed(None) }
@@ -873,7 +873,7 @@ fn resolve_name(&self, name: Name, ns: Namespace, allow_private_imports: bool)
     // Define the name or return the existing binding if there is a collision.
     fn try_define_child(&self, name: Name, ns: Namespace, binding: &'a NameBinding<'a>)
                         -> Result<(), &'a NameBinding<'a>> {
-        let mut children = self.children.borrow_mut();
+        let mut children = self.resolutions.borrow_mut();
         let resolution = children.entry((name, ns)).or_insert_with(Default::default);
 
         // FIXME #31379: We can use methods from imported traits shadowed by non-import items
@@ -889,31 +889,23 @@ fn try_define_child(&self, name: Name, ns: Namespace, binding: &'a NameBinding<'
     }
 
     fn increment_outstanding_references_for(&self, name: Name, ns: Namespace) {
-        let mut children = self.children.borrow_mut();
+        let mut children = self.resolutions.borrow_mut();
         children.entry((name, ns)).or_insert_with(Default::default).outstanding_references += 1;
     }
 
     fn decrement_outstanding_references_for(&self, name: Name, ns: Namespace) {
-        match self.children.borrow_mut().get_mut(&(name, ns)).unwrap().outstanding_references {
+        match self.resolutions.borrow_mut().get_mut(&(name, ns)).unwrap().outstanding_references {
             0 => panic!("No more outstanding references!"),
             ref mut outstanding_references => { *outstanding_references -= 1; }
         }
     }
 
     fn for_each_child<F: FnMut(Name, Namespace, &'a NameBinding<'a>)>(&self, mut f: F) {
-        for (&(name, ns), name_resolution) in self.children.borrow().iter() {
+        for (&(name, ns), name_resolution) in self.resolutions.borrow().iter() {
             name_resolution.binding.map(|binding| f(name, ns, binding));
         }
     }
 
-    fn for_each_local_child<F: FnMut(Name, Namespace, &'a NameBinding<'a>)>(&self, mut f: F) {
-        self.for_each_child(|name, ns, name_binding| {
-            if !name_binding.is_import() && !name_binding.is_extern_crate() {
-                f(name, ns, name_binding)
-            }
-        })
-    }
-
     fn def_id(&self) -> Option<DefId> {
         self.def.as_ref().map(Def::def_id)
     }
@@ -1640,20 +1632,7 @@ fn report_unresolved_imports(&mut self, module_: Module<'a>) {
         }
 
         // Descend into children and anonymous children.
-        build_reduced_graph::populate_module_if_necessary(self, module_);
-
-        module_.for_each_local_child(|_, _, child_node| {
-            match child_node.module() {
-                None => {
-                    // Continue.
-                }
-                Some(child_module) => {
-                    self.report_unresolved_imports(child_module);
-                }
-            }
-        });
-
-        for (_, module_) in module_.anonymous_children.borrow().iter() {
+        for (_, module_) in module_.module_children.borrow().iter() {
             self.report_unresolved_imports(module_);
         }
     }
@@ -1676,32 +1655,14 @@ fn report_unresolved_imports(&mut self, module_: Module<'a>) {
     // generate a fake "implementation scope" containing all the
     // implementations thus found, for compatibility with old resolve pass.
 
-    fn with_scope<F>(&mut self, name: Option<Name>, f: F)
+    fn with_scope<F>(&mut self, id: NodeId, f: F)
         where F: FnOnce(&mut Resolver)
     {
         let orig_module = self.current_module;
 
         // Move down in the graph.
-        match name {
-            None => {
-                // Nothing to do.
-            }
-            Some(name) => {
-                build_reduced_graph::populate_module_if_necessary(self, &orig_module);
-
-                if let Success(name_binding) = orig_module.resolve_name(name, TypeNS, false) {
-                    match name_binding.module() {
-                        None => {
-                            debug!("!!! (with scope) didn't find module for `{}` in `{}`",
-                                   name,
-                                   module_to_string(orig_module));
-                        }
-                        Some(module) => {
-                            self.current_module = module;
-                        }
-                    }
-                }
-            }
+        if let Some(module) = orig_module.module_children.borrow().get(&id) {
+            self.current_module = module;
         }
 
         f(self);
@@ -1825,7 +1786,7 @@ fn resolve_item(&mut self, item: &Item) {
             }
 
             ItemMod(_) | ItemForeignMod(_) => {
-                self.with_scope(Some(name), |this| {
+                self.with_scope(item.id, |this| {
                     intravisit::walk_item(this, item);
                 });
             }
@@ -2261,7 +2222,7 @@ fn resolve_block(&mut self, block: &Block) {
         // Move down in the graph, if there's an anonymous module rooted here.
         let orig_module = self.current_module;
         let anonymous_module =
-            orig_module.anonymous_children.borrow().get(&block.id).map(|module| *module);
+            orig_module.module_children.borrow().get(&block.id).map(|module| *module);
 
         if let Some(anonymous_module) = anonymous_module {
             debug!("(resolving block) found anonymous module, moving down");
index f21ffb9b9a16d61d1d42b800e1c405a1044a026d..1253d4f9ceff055ed7f04d1388d4c67b2f3aacea 100644 (file)
@@ -243,19 +243,7 @@ fn resolve_imports_for_module_subtree(&mut self,
         errors.extend(self.resolve_imports_for_module(module_));
         self.resolver.current_module = orig_module;
 
-        build_reduced_graph::populate_module_if_necessary(self.resolver, module_);
-        module_.for_each_local_child(|_, _, child_node| {
-            match child_node.module() {
-                None => {
-                    // Nothing to do.
-                }
-                Some(child_module) => {
-                    errors.extend(self.resolve_imports_for_module_subtree(child_module));
-                }
-            }
-        });
-
-        for (_, child_module) in module_.anonymous_children.borrow().iter() {
+        for (_, child_module) in module_.module_children.borrow().iter() {
             errors.extend(self.resolve_imports_for_module_subtree(child_module));
         }
 
@@ -403,6 +391,23 @@ fn resolve_single_import(&mut self,
             module_.increment_outstanding_references_for(target, TypeNS);
         }
 
+        match (&value_result, &type_result) {
+            (&Indeterminate, _) | (_, &Indeterminate) => return Indeterminate,
+            (&Failed(_), &Failed(_)) => {
+                let children = target_module.resolutions.borrow();
+                let names = children.keys().map(|&(ref name, _)| name);
+                let lev_suggestion = match find_best_match_for_name(names, &source.as_str(), None) {
+                    Some(name) => format!(". Did you mean to use `{}`?", name),
+                    None => "".to_owned(),
+                };
+                let msg = format!("There is no `{}` in `{}`{}",
+                                  source,
+                                  module_to_string(target_module), lev_suggestion);
+                return Failed(Some((directive.span, msg)));
+            }
+            _ => (),
+        }
+
         match (&value_result, &type_result) {
             (&Success(name_binding), _) if !name_binding.is_import() &&
                                            directive.is_public &&
@@ -437,23 +442,6 @@ fn resolve_single_import(&mut self,
             _ => {}
         }
 
-        match (&value_result, &type_result) {
-            (&Indeterminate, _) | (_, &Indeterminate) => return Indeterminate,
-            (&Failed(_), &Failed(_)) => {
-                let children = target_module.children.borrow();
-                let names = children.keys().map(|&(ref name, _)| name);
-                let lev_suggestion = match find_best_match_for_name(names, &source.as_str(), None) {
-                    Some(name) => format!(". Did you mean to use `{}`?", name),
-                    None => "".to_owned(),
-                };
-                let msg = format!("There is no `{}` in `{}`{}",
-                                  source,
-                                  module_to_string(target_module), lev_suggestion);
-                return Failed(Some((directive.span, msg)));
-            }
-            _ => (),
-        }
-
         for &(ns, result) in &[(ValueNS, &value_result), (TypeNS, &type_result)] {
             if let Success(binding) = *result {
                 if !binding.defined_with(DefModifiers::IMPORTABLE) {
@@ -524,6 +512,7 @@ fn resolve_glob_import(&mut self,
         build_reduced_graph::populate_module_if_necessary(self.resolver, target_module);
         target_module.for_each_child(|name, ns, binding| {
             if !binding.defined_with(DefModifiers::IMPORTABLE | DefModifiers::PUBLIC) { return }
+            if binding.is_extern_crate() { return }
             self.define(module_, name, ns, directive.import(binding));
 
             if ns == TypeNS && directive.is_public &&
index 69a70cdf144b35eb494df8c8f51ee0878254d30d..33734d615a621fd16375e1bd70718daf8e0fbf39 100644 (file)
@@ -1253,7 +1253,11 @@ fn add_static_crate(cmd: &mut Linker, sess: &Session, tmpdir: &Path,
 
             if any_objects {
                 archive.build();
-                cmd.link_whole_rlib(&fix_windows_verbatim_for_gcc(&dst));
+                if dylib {
+                    cmd.link_whole_rlib(&fix_windows_verbatim_for_gcc(&dst));
+                } else {
+                    cmd.link_rlib(&fix_windows_verbatim_for_gcc(&dst));
+                }
             }
         });
     }
index 2b3899ac03ecf84c4f91409ec7b2c23b22c4bec5..d79f284a13500cd7f642d0797f01ef6d1a23e445 100644 (file)
@@ -40,7 +40,7 @@
 use std::hash::*;
 use std::collections::HashSet;
 
-use syntax::ast::{self, NodeId};
+use syntax::ast::{self, NodeId, PatKind};
 use syntax::codemap::*;
 use syntax::parse::token::{self, keywords};
 use syntax::visit::{self, Visitor};
@@ -780,7 +780,7 @@ fn process_method_call(&mut self, ex: &ast::Expr, args: &Vec<P<ast::Expr>>) {
 
     fn process_pat(&mut self, p: &ast::Pat) {
         match p.node {
-            ast::PatStruct(ref path, ref fields, _) => {
+            PatKind::Struct(ref path, ref fields, _) => {
                 visit::walk_path(self, path);
                 let adt = self.tcx.node_id_to_type(p.id).ty_adt_def().unwrap();
                 let def = self.tcx.def_map.borrow()[&p.id].full_def();
index d336ab21962de01506f27490dffb5c98743d6c4c..9c529ccbe00672dc2b899d77b6c862180431e75b 100644 (file)
@@ -21,7 +21,7 @@
 use rustc::front::map::NodeItem;
 use rustc::session::config::CrateType::CrateTypeExecutable;
 
-use syntax::ast::{self, NodeId};
+use syntax::ast::{self, NodeId, PatKind};
 use syntax::ast_util;
 use syntax::codemap::*;
 use syntax::parse::token::{self, keywords};
@@ -758,16 +758,17 @@ fn new() -> PathCollector {
 impl<'v> Visitor<'v> for PathCollector {
     fn visit_pat(&mut self, p: &ast::Pat) {
         match p.node {
-            ast::PatStruct(ref path, _, _) => {
+            PatKind::Struct(ref path, _, _) => {
                 self.collected_paths.push((p.id, path.clone(),
                                            ast::Mutability::Mutable, recorder::TypeRef));
             }
-            ast::PatEnum(ref path, _) |
-            ast::PatQPath(_, ref path) => {
+            PatKind::TupleStruct(ref path, _) |
+            PatKind::Path(ref path) |
+            PatKind::QPath(_, ref path) => {
                 self.collected_paths.push((p.id, path.clone(),
                                            ast::Mutability::Mutable, recorder::VarRef));
             }
-            ast::PatIdent(bm, ref path1, _) => {
+            PatKind::Ident(bm, ref path1, _) => {
                 debug!("PathCollector, visit ident in pat {}: {:?} {:?}",
                        path1.node,
                        p.span,
index 823f333f3317b77469f242958dd0088ceb62796c..3a4a6b9960e9cea6bd62cb3260b08423def164b6 100644 (file)
@@ -8,15 +8,65 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use trans::cabi::FnType;
-use trans::cabi_arm;
+#![allow(non_upper_case_globals)]
+
+use llvm::{Struct, Array, Attribute};
+use trans::cabi::{FnType, ArgType};
 use trans::context::CrateContext;
 use trans::type_::Type;
 
+// Data layout: e-p:32:32-i64:64-v128:32:128-n32-S128
+
+// See the https://github.com/kripken/emscripten-fastcomp-clang repository.
+// The class `EmscriptenABIInfo` in `/lib/CodeGen/TargetInfo.cpp` contains the ABI definitions.
+
+fn classify_ret_ty(ccx: &CrateContext, ty: Type) -> ArgType {
+    match ty.kind() {
+        Struct => {
+            let field_types = ty.field_types();
+            if field_types.len() == 1 {
+                ArgType::direct(ty, Some(field_types[0]), None, None)
+            } else {
+                ArgType::indirect(ty, Some(Attribute::StructRet))
+            }
+        },
+        Array => {
+            ArgType::indirect(ty, Some(Attribute::StructRet))
+        },
+        _ => {
+            let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None };
+            ArgType::direct(ty, None, None, attr)
+        }
+    }
+}
+
+fn classify_arg_ty(ccx: &CrateContext, ty: Type) -> ArgType {
+    if ty.is_aggregate() {
+        ArgType::indirect(ty, Some(Attribute::ByVal))
+    } else {
+        let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None };
+        ArgType::direct(ty, None, None, attr)
+    }
+}
+
 pub fn compute_abi_info(ccx: &CrateContext,
                         atys: &[Type],
                         rty: Type,
                         ret_def: bool) -> FnType {
-    cabi_arm::compute_abi_info(ccx, atys, rty, ret_def,
-                               cabi_arm::Flavor::General)
+    let mut arg_tys = Vec::new();
+    for &aty in atys {
+        let ty = classify_arg_ty(ccx, aty);
+        arg_tys.push(ty);
+    }
+
+    let ret_ty = if ret_def {
+        classify_ret_ty(ccx, rty)
+    } else {
+        ArgType::direct(Type::void(ccx), None, None, None)
+    };
+
+    return FnType {
+        arg_tys: arg_tys,
+        ret_ty: ret_ty,
+    };
 }
index 21cb082f0660cd8c179f3c2e64596d106521c842..b5b0f0a82d4ec6d0c3d79d7a602d740c1c9b9d33 100644 (file)
@@ -501,7 +501,7 @@ fn visit_rvalue(&mut self, rvalue: &mir::Rvalue<'tcx>) {
                         .tcx()
                         .lang_items
                         .require(ExchangeMallocFnLangItem)
-                        .expect("Could not find ExchangeMallocFnLangItem");
+                        .unwrap_or_else(|e| self.ccx.sess().fatal(&e));
 
                 assert!(can_have_local_instance(self.ccx, exchange_malloc_fn_def_id));
                 let exchange_malloc_fn_trans_item =
@@ -645,7 +645,7 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
         let exchange_free_fn_def_id = ccx.tcx()
                                          .lang_items
                                          .require(ExchangeFreeFnLangItem)
-                                         .expect("Could not find ExchangeFreeFnLangItem");
+                                         .unwrap_or_else(|e| ccx.sess().fatal(&e));
 
         assert!(can_have_local_instance(ccx, exchange_free_fn_def_id));
         let exchange_free_fn_trans_item =
index 1269c266c7c10ade2bcab46130bbd5924d83ff1e..eb54527b3733d3078e12049437c32f97e0fd58ac 100644 (file)
@@ -1159,7 +1159,7 @@ pub fn fulfill_obligation<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
     // Currently, we use a fulfillment context to completely resolve
     // all nested obligations. This is because they can inform the
     // inference of the impl's type parameters.
-    let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
+    let mut fulfill_cx = traits::FulfillmentContext::new();
     let vtable = selection.map(|predicate| {
         fulfill_cx.register_predicate_obligation(&infcx, predicate);
     });
@@ -1188,7 +1188,7 @@ pub fn normalize_and_test_predicates<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
     let tcx = ccx.tcx();
     let infcx = infer::normalizing_infer_ctxt(tcx, &tcx.tables);
     let mut selcx = traits::SelectionContext::new(&infcx);
-    let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
+    let mut fulfill_cx = traits::FulfillmentContext::new();
     let cause = traits::ObligationCause::dummy();
     let traits::Normalized { value: predicates, obligations } =
         traits::normalize(&mut selcx, cause.clone(), &predicates);
index d3e66bde4f4c38ce66aa968b367111b39e215fa8..a4fb2e381459e7ced59e5708f377ae534bf91c17 100644 (file)
@@ -134,7 +134,7 @@ fn deduce_expectations_from_obligations<'a,'tcx>(
     expected_vid: ty::TyVid)
     -> (Option<ty::FnSig<'tcx>>, Option<ty::ClosureKind>)
 {
-    let fulfillment_cx = fcx.inh.infcx.fulfillment_cx.borrow();
+    let fulfillment_cx = fcx.inh.fulfillment_cx.borrow();
     // Here `expected_ty` is known to be a type inference variable.
 
     let expected_sig =
index d5f242201892512ce71f85fe74d496b279a8834d..d674fa145dc9ace491fcbff26b438947e6736f27 100644 (file)
@@ -43,7 +43,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
            impl_trait_ref);
 
     let mut infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None);
-    let mut fulfillment_cx = infcx.fulfillment_cx.borrow_mut();
+    let mut fulfillment_cx = traits::FulfillmentContext::new();
 
     let trait_to_impl_substs = &impl_trait_ref.substs;
 
@@ -417,7 +417,7 @@ pub fn compare_const_impl<'tcx>(tcx: &ty::ctxt<'tcx>,
            impl_trait_ref);
 
     let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None);
-    let mut fulfillment_cx = infcx.fulfillment_cx.borrow_mut();
+    let mut fulfillment_cx = traits::FulfillmentContext::new();
 
     // The below is for the most part highly similar to the procedure
     // for methods above. It is simpler in many respects, especially
index deda0b818ee06d4e90f7af1386de524addf182d4..9d39653375739531f56660c839397f1319d83fa6 100644 (file)
@@ -84,6 +84,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
 
     let impl_param_env = ty::ParameterEnvironment::for_item(tcx, self_type_node_id);
     let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(impl_param_env));
+    let mut fulfillment_cx = traits::FulfillmentContext::new();
 
     let named_type = tcx.lookup_item_type(self_type_did).ty;
     let named_type = named_type.subst(tcx, &infcx.parameter_environment.free_substs);
@@ -105,7 +106,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
         return Err(());
     }
 
-    if let Err(ref errors) = infcx.fulfillment_cx.borrow_mut().select_all_or_error(&infcx) {
+    if let Err(ref errors) = fulfillment_cx.select_all_or_error(&infcx) {
         // this could be reached when we get lazy normalization
         traits::report_fulfillment_errors(&infcx, errors);
         return Err(());
index e485bdd66fc9f265ca8f27fb9511eedbb480380d..f890e087573b5ceb3f21563c47550a0932bc1ca0 100644 (file)
@@ -161,6 +161,8 @@ pub struct Inherited<'a, 'tcx: 'a> {
     infcx: infer::InferCtxt<'a, 'tcx>,
     locals: RefCell<NodeMap<Ty<'tcx>>>,
 
+    fulfillment_cx: RefCell<traits::FulfillmentContext<'tcx>>,
+
     tables: &'a RefCell<ty::Tables<'tcx>>,
 
     // When we process a call like `c()` where `c` is a closure type,
@@ -306,6 +308,7 @@ fn new(tcx: &'a ty::ctxt<'tcx>,
 
         Inherited {
             infcx: infer::new_infer_ctxt(tcx, tables, Some(param_env)),
+            fulfillment_cx: RefCell::new(traits::FulfillmentContext::new()),
             locals: RefCell::new(NodeMap()),
             tables: tables,
             deferred_call_resolutions: RefCell::new(DefIdMap()),
@@ -320,9 +323,8 @@ fn normalize_associated_types_in<T>(&self,
                                         -> T
         where T : TypeFoldable<'tcx>
     {
-        let mut fulfillment_cx = self.infcx.fulfillment_cx.borrow_mut();
         assoc::normalize_associated_types_in(&self.infcx,
-                                             &mut fulfillment_cx,
+                                             &mut self.fulfillment_cx.borrow_mut(),
                                              span,
                                              body_id,
                                              value)
@@ -1370,7 +1372,6 @@ fn normalize_associated_type(&self,
                                                  self.body_id,
                                                  traits::ObligationCauseCode::MiscObligation);
         self.inh
-            .infcx
             .fulfillment_cx
             .borrow_mut()
             .normalize_projection_type(self.infcx(),
@@ -1505,7 +1506,7 @@ pub fn register_builtin_bound(&self,
                                   builtin_bound: ty::BuiltinBound,
                                   cause: traits::ObligationCause<'tcx>)
     {
-        self.inh.infcx.fulfillment_cx.borrow_mut()
+        self.inh.fulfillment_cx.borrow_mut()
             .register_builtin_bound(self.infcx(), ty, builtin_bound, cause);
     }
 
@@ -1514,7 +1515,7 @@ pub fn register_predicate(&self,
     {
         debug!("register_predicate({:?})",
                obligation);
-        self.inh.infcx.fulfillment_cx
+        self.inh.fulfillment_cx
             .borrow_mut()
             .register_predicate_obligation(self.infcx(), obligation);
     }
@@ -1646,7 +1647,7 @@ pub fn register_region_obligation(&self,
                                       region: ty::Region,
                                       cause: traits::ObligationCause<'tcx>)
     {
-        let mut fulfillment_cx = self.inh.infcx.fulfillment_cx.borrow_mut();
+        let mut fulfillment_cx = self.inh.fulfillment_cx.borrow_mut();
         fulfillment_cx.register_region_obligation(ty, region, cause);
     }
 
@@ -2003,7 +2004,7 @@ fn select_all_obligations_or_error(&self) {
 
         self.select_all_obligations_and_apply_defaults();
 
-        let mut fulfillment_cx = self.inh.infcx.fulfillment_cx.borrow_mut();
+        let mut fulfillment_cx = self.inh.fulfillment_cx.borrow_mut();
         match fulfillment_cx.select_all_or_error(self.infcx()) {
             Ok(()) => { }
             Err(errors) => { report_fulfillment_errors(self.infcx(), &errors); }
@@ -2013,7 +2014,7 @@ fn select_all_obligations_or_error(&self) {
     /// Select as many obligations as we can at present.
     fn select_obligations_where_possible(&self) {
         match
-            self.inh.infcx.fulfillment_cx
+            self.inh.fulfillment_cx
             .borrow_mut()
             .select_where_possible(self.infcx())
         {
@@ -3827,7 +3828,7 @@ impl<'tcx> Expectation<'tcx> {
     /// for examples of where this comes up,.
     fn rvalue_hint(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> Expectation<'tcx> {
         match tcx.struct_tail(ty).sty {
-            ty::TySlice(_) | ty::TyTrait(..) => {
+            ty::TySlice(_) | ty::TyStr | ty::TyTrait(..) => {
                 ExpectRvalueLikeUnsized(ty)
             }
             _ => ExpectHasType(ty)
index 1ee0542f633372c405d6e6f1b5b94c70bd868e13..2335b76626b170bd46d0a635c31d4c1256751118 100644 (file)
@@ -353,7 +353,6 @@ fn visit_region_obligations(&mut self, node_id: ast::NodeId)
         let region_obligations =
             self.fcx
                 .inh
-                .infcx
                 .fulfillment_cx
                 .borrow()
                 .region_obligations(node_id)
@@ -369,7 +368,7 @@ fn visit_region_obligations(&mut self, node_id: ast::NodeId)
 
         // Processing the region obligations should not cause the list to grow further:
         assert_eq!(region_obligations.len(),
-                   self.fcx.inh.infcx.fulfillment_cx.borrow().region_obligations(node_id).len());
+                   self.fcx.inh.fulfillment_cx.borrow().region_obligations(node_id).len());
     }
 
     fn code_to_origin(&self,
index 7e63fd47d61e15c61bd8163320ecad34dedceaab..2dfbaab2844754f9a81841835ee4448d10f766a9 100644 (file)
@@ -473,7 +473,7 @@ fn check_implementations_of_coerce_unsized(&self) {
                 }
             };
 
-            let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
+            let mut fulfill_cx = traits::FulfillmentContext::new();
 
             // Register an obligation for `A: Trait<B>`.
             let cause = traits::ObligationCause::misc(span, impl_node_id);
index ca05806d8f95a181f7d242fb74e10e517c4a14d8..d6e4b7e4a51d60881dda6d0d81124ef8228677cf 100644 (file)
@@ -1281,10 +1281,8 @@ impl Clean<Item> for hir::ImplItem {
     fn clean(&self, cx: &DocContext) -> Item {
         let inner = match self.node {
             hir::ImplItemKind::Const(ref ty, ref expr) => {
-                ConstantItem(Constant{
-                    type_: ty.clean(cx),
-                    expr: expr.span.to_src(cx),
-                })
+                AssociatedConstItem(ty.clean(cx),
+                                    Some(expr.span.to_src(cx)))
             }
             hir::ImplItemKind::Method(ref sig, _) => {
                 MethodItem(sig.clean(cx))
index ffcd22fa8209604daeda1542306d22cc1e13c07a..975b4d3636f2d10b983fb0a79c61b6d92d550c01 100644 (file)
@@ -122,7 +122,7 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
 
                 <p>
                     Search functions by type signature (e.g.
-                    <code>vec -> usize</code>)
+                    <code>vec -> usize</code> or <code>* -> vec</code>)
                 </p>
             </div>
         </div>
index 12a17afcc7c502a281ca4245e69d649bf4f87bb0..2053fc73e8fc2c2c2d025fabfa89dca5b4b026e2 100644 (file)
@@ -554,7 +554,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
                         ty: shortty(item),
                         name: item.name.clone().unwrap(),
                         path: fqp[..fqp.len() - 1].join("::"),
-                        desc: shorter(item.doc_value()),
+                        desc: Escape(&shorter(item.doc_value())).to_string(),
                         parent: Some(did),
                         search_type: get_index_search_type(&item, parent_basename),
                     });
@@ -1065,7 +1065,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
                             ty: shortty(&item),
                             name: s.to_string(),
                             path: path.join("::").to_string(),
-                            desc: shorter(item.doc_value()),
+                            desc: Escape(&shorter(item.doc_value())).to_string(),
                             parent: parent,
                             search_type: get_index_search_type(&item, parent_basename),
                         });
@@ -1501,11 +1501,17 @@ fn href(&self, cx: &Context) -> Option<String> {
                           true, |component| {
                 path.push(component.to_string());
             });
-            Some(format!("{root}src/{krate}/{path}.html#{href}",
-                         root = self.cx.root_path,
-                         krate = self.cx.layout.krate,
-                         path = path.join("/"),
-                         href = href))
+            // If the span points into an external macro the
+            // source-file will be bogus, i.e `<foo macros>`
+            if Path::new(&self.item.source.filename).is_file() {
+                Some(format!("{root}src/{krate}/{path}.html#{href}",
+                             root = self.cx.root_path,
+                             krate = self.cx.layout.krate,
+                             path = path.join("/"),
+                             href = href))
+            } else {
+                None
+            }
 
         // If this item is not part of the local crate, then things get a little
         // trickier. We don't actually know the span of the external item, but
@@ -1653,8 +1659,8 @@ fn shorter<'a>(s: Option<&'a str>) -> String {
 
 #[inline]
 fn plain_summary_line(s: Option<&str>) -> String {
-    let line = shorter(s).replace("\n", " ");
-    markdown::plain_summary_line(&line[..])
+    let md = markdown::plain_summary_line(s.unwrap_or(""));
+    shorter(Some(&md)).replace("\n", " ")
 }
 
 fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Result {
@@ -1781,6 +1787,7 @@ fn cmp(i1: &clean::Item, i2: &clean::Item, idx1: usize, idx2: usize) -> Ordering
                 } else {
                     String::new()
                 };
+                let doc_value = myitem.doc_value().unwrap_or("");
                 try!(write!(w, "
                     <tr class='{stab} module-item'>
                         <td><a class='{class}' href='{href}'
@@ -1792,7 +1799,7 @@ fn cmp(i1: &clean::Item, i2: &clean::Item, idx1: usize, idx2: usize) -> Ordering
                 ",
                 name = *myitem.name.as_ref().unwrap(),
                 stab_docs = stab_docs,
-                docs = Markdown(&shorter(myitem.doc_value())),
+                docs = shorter(Some(&Markdown(doc_value).to_string())),
                 class = shortty(myitem),
                 stab = myitem.stability_class(),
                 href = item_path(myitem),
@@ -2550,25 +2557,25 @@ fn doctraititem(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item,
                 }
             }
             clean::TypedefItem(ref tydef, _) => {
-                let id = derive_id(format!("assoc_type.{}", name));
+                let id = derive_id(format!("associatedtype.{}", name));
                 try!(write!(w, "<h4 id='{}' class='{}'><code>", id, shortty(item)));
                 try!(write!(w, "type {} = {}", name, tydef.type_));
                 try!(write!(w, "</code></h4>\n"));
             }
             clean::AssociatedConstItem(ref ty, ref default) => {
-                let id = derive_id(format!("assoc_const.{}", name));
+                let id = derive_id(format!("associatedconstant.{}", name));
                 try!(write!(w, "<h4 id='{}' class='{}'><code>", id, shortty(item)));
                 try!(assoc_const(w, item, ty, default.as_ref()));
                 try!(write!(w, "</code></h4>\n"));
             }
             clean::ConstantItem(ref c) => {
-                let id = derive_id(format!("assoc_const.{}", name));
+                let id = derive_id(format!("associatedconstant.{}", name));
                 try!(write!(w, "<h4 id='{}' class='{}'><code>", id, shortty(item)));
                 try!(assoc_const(w, item, &c.type_, Some(&c.expr)));
                 try!(write!(w, "</code></h4>\n"));
             }
             clean::AssociatedTypeItem(ref bounds, ref default) => {
-                let id = derive_id(format!("assoc_type.{}", name));
+                let id = derive_id(format!("associatedtype.{}", name));
                 try!(write!(w, "<h4 id='{}' class='{}'><code>", id, shortty(item)));
                 try!(assoc_type(w, item, bounds, default));
                 try!(write!(w, "</code></h4>\n"));
index 8844ed82bb5e29cd73c956d28ad56bee6d1a7451..08f70ae9ce7a0ec1896c7442a2cf50b43566ddfa 100644 (file)
                 var parts = val.split("->").map(trimmer);
                 var input = parts[0];
                 // sort inputs so that order does not matter
-                var inputs = input.split(",").map(trimmer).sort();
+                var inputs = input.split(",").map(trimmer).sort().toString();
                 var output = parts[1];
 
                 for (var i = 0; i < nSearchWords; ++i) {
 
                     // allow searching for void (no output) functions as well
                     var typeOutput = type.output ? type.output.name : "";
-                    if (inputs.toString() === typeInputs.toString() &&
-                        output == typeOutput) {
+                    if ((inputs === "*" || inputs === typeInputs.toString()) &&
+                        (output === "*" || output == typeOutput)) {
                         results.push({id: i, index: -1, dontValidate: true});
                     }
                 }
index 38f79079b29f3a00420c59ff1007d0c27bd8b4ec..8cabdc41a0583324bb700ff8f79a88d78a78c5d9 100644 (file)
@@ -45,7 +45,7 @@ pub trait AsciiExt {
     #[stable(feature = "rust1", since = "1.0.0")]
     type Owned;
 
-    /// Checks if within the ASCII range.
+    /// Checks if the value is within the ASCII range.
     ///
     /// # Examples
     ///
@@ -55,8 +55,8 @@ pub trait AsciiExt {
     /// let ascii = 'a';
     /// let utf8 = '❤';
     ///
-    /// assert_eq!(true, ascii.is_ascii());
-    /// assert_eq!(false, utf8.is_ascii())
+    /// assert!(ascii.is_ascii());
+    /// assert!(!utf8.is_ascii());
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     fn is_ascii(&self) -> bool;
@@ -114,9 +114,9 @@ pub trait AsciiExt {
     /// let ascii3 = 'A';
     /// let ascii4 = 'z';
     ///
-    /// assert_eq!(true, ascii1.eq_ignore_ascii_case(&ascii2));
-    /// assert_eq!(true, ascii1.eq_ignore_ascii_case(&ascii3));
-    /// assert_eq!(false, ascii1.eq_ignore_ascii_case(&ascii4));
+    /// assert!(ascii1.eq_ignore_ascii_case(&ascii2));
+    /// assert!(ascii1.eq_ignore_ascii_case(&ascii3));
+    /// assert!(!ascii1.eq_ignore_ascii_case(&ascii4));
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     fn eq_ignore_ascii_case(&self, other: &Self) -> bool;
index d42b948918049ba2291048438e8eb82dad97252a..badbba21d55cc9ddfbf7c55f266a7be4760550ea 100644 (file)
@@ -2151,6 +2151,26 @@ fn symlink_noexist() {
                    "foo");
     }
 
+    #[test]
+    fn read_link() {
+        if cfg!(windows) {
+            // directory symlink
+            assert_eq!(check!(fs::read_link(r"C:\Users\All Users")).to_str().unwrap(),
+                       r"C:\ProgramData");
+            // junction
+            assert_eq!(check!(fs::read_link(r"C:\Users\Default User")).to_str().unwrap(),
+                       r"C:\Users\Default");
+            // junction with special permissions
+            assert_eq!(check!(fs::read_link(r"C:\Documents and Settings\")).to_str().unwrap(),
+                       r"C:\Users");
+        }
+        let tmpdir = tmpdir();
+        let link = tmpdir.join("link");
+        if !got_symlink_permission(&tmpdir) { return };
+        check!(symlink_file(&"foo", &link));
+        assert_eq!(check!(fs::read_link(&link)).to_str().unwrap(), "foo");
+    }
+
     #[test]
     fn readlink_not_symlink() {
         let tmpdir = tmpdir();
index b7afd12d8e527bcc0c440c3015c059273cf093be..d241cd032ed4c07872f56a632077a59fabd93d4a 100644 (file)
@@ -269,9 +269,10 @@ macro_rules! option_env { ($name:expr) => ({ /* compiler built-in */ }) }
     /// This macro takes any number of comma-separated identifiers, and
     /// concatenates them all into one, yielding an expression which is a new
     /// identifier. Note that hygiene makes it such that this macro cannot
-    /// capture local variables, and macros are only allowed in item,
-    /// statement or expression position, meaning this macro may be difficult to
-    /// use in some situations.
+    /// capture local variables. Also, as a general rule, macros are only
+    /// allowed in item, statement or expression position. That means while
+    /// you may use this macro for referring to existing variables, functions or
+    /// modules etc, you cannot define a new one with it.
     ///
     /// # Examples
     ///
@@ -283,6 +284,8 @@ macro_rules! option_env { ($name:expr) => ({ /* compiler built-in */ }) }
     ///
     /// let f = concat_idents!(foo, bar);
     /// println!("{}", f());
+    ///
+    /// // fn concat_idents!(new, fun, name) { } // not usable in this way!
     /// # }
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
diff --git a/src/libstd/os/android/fs.rs b/src/libstd/os/android/fs.rs
new file mode 100644 (file)
index 0000000..a51b465
--- /dev/null
@@ -0,0 +1,129 @@
+// Copyright 2016 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.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::android::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+    /// Gain a reference to the underlying `stat` structure which contains
+    /// the raw information returned by the OS.
+    ///
+    /// The contents of the returned `stat` are **not** consistent across
+    /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+    /// cross-Unix abstractions contained within the raw stat.
+    #[stable(feature = "metadata_ext", since = "1.1.0")]
+    #[rustc_deprecated(since = "1.8.0",
+                       reason = "deprecated in favor of the accessor \
+                                 methods of this trait")]
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat;
+
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_dev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ino(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mode(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_nlink(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_uid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_gid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_rdev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_size(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blksize(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blocks(&self) -> u64;
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat {
+        unsafe {
+            &*(self.as_inner().as_inner() as *const libc::stat
+                                          as *const raw::stat)
+        }
+    }
+    fn st_dev(&self) -> u64 {
+        self.as_inner().as_inner().st_dev as u64
+    }
+    fn st_ino(&self) -> u64 {
+        self.as_inner().as_inner().st_ino as u64
+    }
+    fn st_mode(&self) -> u32 {
+        self.as_inner().as_inner().st_mode as u32
+    }
+    fn st_nlink(&self) -> u64 {
+        self.as_inner().as_inner().st_nlink as u64
+    }
+    fn st_uid(&self) -> u32 {
+        self.as_inner().as_inner().st_uid as u32
+    }
+    fn st_gid(&self) -> u32 {
+        self.as_inner().as_inner().st_gid as u32
+    }
+    fn st_rdev(&self) -> u64 {
+        self.as_inner().as_inner().st_rdev as u64
+    }
+    fn st_size(&self) -> u64 {
+        self.as_inner().as_inner().st_size as u64
+    }
+    fn st_atime(&self) -> i64 {
+        self.as_inner().as_inner().st_atime as i64
+    }
+    fn st_atime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_atime_nsec as i64
+    }
+    fn st_mtime(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime as i64
+    }
+    fn st_mtime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime_nsec as i64
+    }
+    fn st_ctime(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime as i64
+    }
+    fn st_ctime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime_nsec as i64
+    }
+    fn st_blksize(&self) -> u64 {
+        self.as_inner().as_inner().st_blksize as u64
+    }
+    fn st_blocks(&self) -> u64 {
+        self.as_inner().as_inner().st_blocks as u64
+    }
+}
+
index 15380dc350e67d4437eae6aa196daf598a3bbeef..7cc37769c1e0b99aa773db3c72e00205297304c7 100644 (file)
@@ -13,9 +13,4 @@
 #![stable(feature = "raw_ext", since = "1.1.0")]
 
 pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
-    #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub use sys::fs::MetadataExt;
-}
+pub mod fs;
index e58ba03ec67ae999802f277979d236df7c4bc86f..ce6e810592c6c62e4ce71b600f382d66678c9bcc 100644 (file)
 //! Android-specific raw type definitions
 
 #![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+                    reason = "these type aliases are no longer supported by \
+                              the standard library, the `libc` crate on \
+                              crates.io should be used instead for the correct \
+                              definitions")]
+#![allow(deprecated)]
 
 use os::raw::c_long;
 
@@ -26,22 +32,22 @@ mod arch {
     use os::unix::raw::{uid_t, gid_t};
 
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub type dev_t = u32;
+    pub type dev_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub type mode_t = u16;
+    pub type mode_t = u32;
 
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub type blkcnt_t = u32;
+    pub type blkcnt_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub type blksize_t = u32;
+    pub type blksize_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub type ino_t = u32;
+    pub type ino_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub type nlink_t = u16;
+    pub type nlink_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub type off_t = i32;
+    pub type off_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub type time_t = i32;
+    pub type time_t = i64;
 
     #[repr(C)]
     #[derive(Clone)]
@@ -52,7 +58,7 @@ pub struct stat {
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub __pad0: [c_uchar; 4],
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub __st_ino: ino_t,
+        pub __st_ino: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_mode: c_uint,
         #[stable(feature = "raw_ext", since = "1.1.0")]
@@ -68,19 +74,19 @@ pub struct stat {
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_size: c_longlong,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_blksize: blksize_t,
+        pub st_blksize: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_blocks: c_ulonglong,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_atime: time_t,
+        pub st_atime: c_ulong,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_atime_nsec: c_ulong,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_mtime: time_t,
+        pub st_mtime: c_ulong,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_mtime_nsec: c_ulong,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_ctime: time_t,
+        pub st_ctime: c_ulong,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_ctime_nsec: c_ulong,
         #[stable(feature = "raw_ext", since = "1.1.0")]
@@ -103,13 +109,13 @@ mod arch {
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub type blkcnt_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub type blksize_t = u32;
+    pub type blksize_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub type ino_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub type nlink_t = u32;
+    pub type nlink_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub type off_t = i64;
+    pub type off_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub type time_t = i64;
 
diff --git a/src/libstd/os/bitrig/fs.rs b/src/libstd/os/bitrig/fs.rs
new file mode 100644 (file)
index 0000000..e4f1c94
--- /dev/null
@@ -0,0 +1,149 @@
+// Copyright 2016 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.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::bitrig::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+    /// Gain a reference to the underlying `stat` structure which contains
+    /// the raw information returned by the OS.
+    ///
+    /// The contents of the returned `stat` are **not** consistent across
+    /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+    /// cross-Unix abstractions contained within the raw stat.
+    #[stable(feature = "metadata_ext", since = "1.1.0")]
+    #[rustc_deprecated(since = "1.8.0",
+                       reason = "deprecated in favor of the accessor \
+                                 methods of this trait")]
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat;
+
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_dev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ino(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mode(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_nlink(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_uid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_gid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_rdev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_size(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_birthtime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_birthtime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blksize(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blocks(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_flags(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_gen(&self) -> u32;
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat {
+        unsafe {
+            &*(self.as_inner().as_inner() as *const libc::stat
+                                          as *const raw::stat)
+        }
+    }
+    fn st_dev(&self) -> u64 {
+        self.as_inner().as_inner().st_dev as u64
+    }
+    fn st_ino(&self) -> u64 {
+        self.as_inner().as_inner().st_ino as u64
+    }
+    fn st_mode(&self) -> u32 {
+        self.as_inner().as_inner().st_mode as u32
+    }
+    fn st_nlink(&self) -> u64 {
+        self.as_inner().as_inner().st_nlink as u64
+    }
+    fn st_uid(&self) -> u32 {
+        self.as_inner().as_inner().st_uid as u32
+    }
+    fn st_gid(&self) -> u32 {
+        self.as_inner().as_inner().st_gid as u32
+    }
+    fn st_rdev(&self) -> u64 {
+        self.as_inner().as_inner().st_rdev as u64
+    }
+    fn st_size(&self) -> u64 {
+        self.as_inner().as_inner().st_size as u64
+    }
+    fn st_atime(&self) -> i64 {
+        self.as_inner().as_inner().st_atime as i64
+    }
+    fn st_atime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_atime_nsec as i64
+    }
+    fn st_mtime(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime as i64
+    }
+    fn st_mtime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime_nsec as i64
+    }
+    fn st_ctime(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime as i64
+    }
+    fn st_ctime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime_nsec as i64
+    }
+    fn st_birthtime(&self) -> i64 {
+        self.as_inner().as_inner().st_birthtime as i64
+    }
+    fn st_birthtime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_birthtime_nsec as i64
+    }
+    fn st_blksize(&self) -> u64 {
+        self.as_inner().as_inner().st_blksize as u64
+    }
+    fn st_blocks(&self) -> u64 {
+        self.as_inner().as_inner().st_blocks as u64
+    }
+    fn st_gen(&self) -> u32 {
+        self.as_inner().as_inner().st_gen as u32
+    }
+    fn st_flags(&self) -> u32 {
+        self.as_inner().as_inner().st_flags as u32
+    }
+}
+
index 126eab92fe34bef3f0db1e93805a23cfb6c3d5b8..fb58818a5baf101a8f1468a01a6901ce0158a0d1 100644 (file)
@@ -13,9 +13,4 @@
 #![stable(feature = "raw_ext", since = "1.1.0")]
 
 pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
-    #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub use sys::fs::MetadataExt;
-}
+pub mod fs;
index 81de8810cba5db277f32adb578eac9aac4ed0378..3fc3c5937f4da7fe9758b3179320eb355185dcf8 100644 (file)
 //! Bitrig-specific raw type definitions
 
 #![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+                    reason = "these type aliases are no longer supported by \
+                              the standard library, the `libc` crate on \
+                              crates.io should be used instead for the correct \
+                              definitions")]
+#![allow(deprecated)]
 
 use os::raw::c_long;
 use os::unix::raw::{uid_t, gid_t};
 
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = i32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type fflags_t = u32;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
 
 #[unstable(feature = "pthread_t", issue = "29791")] pub type pthread_t = usize;
 #[stable(feature = "raw_ext", since = "1.1.0")]
 pub struct stat {
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_mode: mode_t,
+    pub st_mode: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_dev: dev_t,
+    pub st_dev: i32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_ino: ino_t,
+    pub st_ino: u64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_nlink: nlink_t,
+    pub st_nlink: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_uid: uid_t,
+    pub st_uid: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_gid: gid_t,
+    pub st_gid: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_rdev: dev_t,
+    pub st_rdev: i32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_atime: time_t,
+    pub st_atime: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_atime_nsec: c_long,
+    pub st_atime_nsec: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_mtime: time_t,
+    pub st_mtime: u64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_mtime_nsec: c_long,
+    pub st_mtime_nsec: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_ctime: time_t,
+    pub st_ctime: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_ctime_nsec: c_long,
+    pub st_ctime_nsec: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_size: off_t,
+    pub st_size: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_blocks: blkcnt_t,
+    pub st_blocks: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_blksize: blksize_t,
+    pub st_blksize: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_flags: fflags_t,
+    pub st_flags: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_gen: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_birthtime: time_t,
+    pub st_birthtime: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_birthtime_nsec: c_long,
+    pub st_birthtime_nsec: i64,
 }
diff --git a/src/libstd/os/dragonfly/fs.rs b/src/libstd/os/dragonfly/fs.rs
new file mode 100644 (file)
index 0000000..eb09800
--- /dev/null
@@ -0,0 +1,154 @@
+// Copyright 2016 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.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::dragonfly::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+    /// Gain a reference to the underlying `stat` structure which contains
+    /// the raw information returned by the OS.
+    ///
+    /// The contents of the returned `stat` are **not** consistent across
+    /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+    /// cross-Unix abstractions contained within the raw stat.
+    #[stable(feature = "metadata_ext", since = "1.1.0")]
+    #[rustc_deprecated(since = "1.8.0",
+                       reason = "deprecated in favor of the accessor \
+                                 methods of this trait")]
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat;
+
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_dev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ino(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mode(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_nlink(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_uid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_gid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_rdev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_size(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_birthtime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_birthtime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blksize(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blocks(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_flags(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_gen(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_lspare(&self) -> u32;
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat {
+        unsafe {
+            &*(self.as_inner().as_inner() as *const libc::stat
+                                          as *const raw::stat)
+        }
+    }
+    fn st_dev(&self) -> u64 {
+        self.as_inner().as_inner().st_dev as u64
+    }
+    fn st_ino(&self) -> u64 {
+        self.as_inner().as_inner().st_ino as u64
+    }
+    fn st_mode(&self) -> u32 {
+        self.as_inner().as_inner().st_mode as u32
+    }
+    fn st_nlink(&self) -> u64 {
+        self.as_inner().as_inner().st_nlink as u64
+    }
+    fn st_uid(&self) -> u32 {
+        self.as_inner().as_inner().st_uid as u32
+    }
+    fn st_gid(&self) -> u32 {
+        self.as_inner().as_inner().st_gid as u32
+    }
+    fn st_rdev(&self) -> u64 {
+        self.as_inner().as_inner().st_rdev as u64
+    }
+    fn st_size(&self) -> u64 {
+        self.as_inner().as_inner().st_size as u64
+    }
+    fn st_atime(&self) -> i64 {
+        self.as_inner().as_inner().st_atime as i64
+    }
+    fn st_atime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_atime_nsec as i64
+    }
+    fn st_mtime(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime as i64
+    }
+    fn st_mtime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime_nsec as i64
+    }
+    fn st_ctime(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime as i64
+    }
+    fn st_ctime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime_nsec as i64
+    }
+    fn st_birthtime(&self) -> i64 {
+        self.as_inner().as_inner().st_birthtime as i64
+    }
+    fn st_birthtime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_birthtime_nsec as i64
+    }
+    fn st_blksize(&self) -> u64 {
+        self.as_inner().as_inner().st_blksize as u64
+    }
+    fn st_blocks(&self) -> u64 {
+        self.as_inner().as_inner().st_blocks as u64
+    }
+    fn st_gen(&self) -> u32 {
+        self.as_inner().as_inner().st_gen as u32
+    }
+    fn st_flags(&self) -> u32 {
+        self.as_inner().as_inner().st_flags as u32
+    }
+    fn st_lspare(&self) -> u32 {
+        self.as_inner().as_inner().st_lspare as u32
+    }
+}
+
index b48604fa83f1cd66759f1962ed5f2acac685884d..645561823fcf98ea8a66c0d7ea23141ad35672b4 100644 (file)
@@ -13,9 +13,4 @@
 #![stable(feature = "raw_ext", since = "1.1.0")]
 
 pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
-    #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub use sys::fs::MetadataExt;
-}
+pub mod fs;
index 581aebebc034f8f9d6059b067a4dee448205cbc6..f3bde9cd1f31508ed03e322d78a8d737040f154b 100644 (file)
 //! Dragonfly-specific raw type definitions
 
 #![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+                    reason = "these type aliases are no longer supported by \
+                              the standard library, the `libc` crate on \
+                              crates.io should be used instead for the correct \
+                              definitions")]
+#![allow(deprecated)]
 
 use os::raw::c_long;
 use os::unix::raw::{uid_t, gid_t};
 
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type fflags_t = u32;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u16;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u16;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
 
 #[unstable(feature = "pthread_t", issue = "29791")] pub type pthread_t = usize;
 #[stable(feature = "raw_ext", since = "1.1.0")]
 pub struct stat {
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_ino: ino_t,
+    pub st_dev: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_nlink: nlink_t,
+    pub st_ino: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_dev: dev_t,
+    pub st_mode: u16,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_mode: mode_t,
+    pub st_nlink: u16,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_padding1: u16,
+    pub st_uid: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_uid: uid_t,
+    pub st_gid: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_gid: gid_t,
+    pub st_rdev: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_rdev: dev_t,
+    pub st_atime: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_atime: time_t,
+    pub st_atime_nsec: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_atime_nsec: c_long,
+    pub st_mtime: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_mtime: time_t,
+    pub st_mtime_nsec: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_mtime_nsec: c_long,
+    pub st_ctime: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_ctime: time_t,
+    pub st_ctime_nsec: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_ctime_nsec: c_long,
+    pub st_size: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_size: off_t,
+    pub st_blocks: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_blocks: blkcnt_t,
+    pub st_blksize: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_blksize: blksize_t,
-    #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_flags: fflags_t,
+    pub st_flags: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_gen: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_lspare: i32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_qspare1: i64,
+    pub st_birthtime: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_qspare2: i64,
+    pub st_birthtime_nsec: i64,
 }
diff --git a/src/libstd/os/freebsd/fs.rs b/src/libstd/os/freebsd/fs.rs
new file mode 100644 (file)
index 0000000..2f17d2f
--- /dev/null
@@ -0,0 +1,154 @@
+// Copyright 2016 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.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::freebsd::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+    /// Gain a reference to the underlying `stat` structure which contains
+    /// the raw information returned by the OS.
+    ///
+    /// The contents of the returned `stat` are **not** consistent across
+    /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+    /// cross-Unix abstractions contained within the raw stat.
+    #[stable(feature = "metadata_ext", since = "1.1.0")]
+    #[rustc_deprecated(since = "1.8.0",
+                       reason = "deprecated in favor of the accessor \
+                                 methods of this trait")]
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat;
+
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_dev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ino(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mode(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_nlink(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_uid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_gid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_rdev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_size(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_birthtime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_birthtime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blksize(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blocks(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_flags(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_gen(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_lspare(&self) -> u32;
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat {
+        unsafe {
+            &*(self.as_inner().as_inner() as *const libc::stat
+                                          as *const raw::stat)
+        }
+    }
+    fn st_dev(&self) -> u64 {
+        self.as_inner().as_inner().st_dev as u64
+    }
+    fn st_ino(&self) -> u64 {
+        self.as_inner().as_inner().st_ino as u64
+    }
+    fn st_mode(&self) -> u32 {
+        self.as_inner().as_inner().st_mode as u32
+    }
+    fn st_nlink(&self) -> u64 {
+        self.as_inner().as_inner().st_nlink as u64
+    }
+    fn st_uid(&self) -> u32 {
+        self.as_inner().as_inner().st_uid as u32
+    }
+    fn st_gid(&self) -> u32 {
+        self.as_inner().as_inner().st_gid as u32
+    }
+    fn st_rdev(&self) -> u64 {
+        self.as_inner().as_inner().st_rdev as u64
+    }
+    fn st_size(&self) -> u64 {
+        self.as_inner().as_inner().st_size as u64
+    }
+    fn st_atime(&self) -> i64 {
+        self.as_inner().as_inner().st_atime as i64
+    }
+    fn st_atime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_atime_nsec as i64
+    }
+    fn st_mtime(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime as i64
+    }
+    fn st_mtime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime_nsec as i64
+    }
+    fn st_ctime(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime as i64
+    }
+    fn st_ctime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime_nsec as i64
+    }
+    fn st_birthtime(&self) -> i64 {
+        self.as_inner().as_inner().st_birthtime as i64
+    }
+    fn st_birthtime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_birthtime_nsec as i64
+    }
+    fn st_blksize(&self) -> u64 {
+        self.as_inner().as_inner().st_blksize as u64
+    }
+    fn st_blocks(&self) -> u64 {
+        self.as_inner().as_inner().st_blocks as u64
+    }
+    fn st_gen(&self) -> u32 {
+        self.as_inner().as_inner().st_gen as u32
+    }
+    fn st_flags(&self) -> u32 {
+        self.as_inner().as_inner().st_flags as u32
+    }
+    fn st_lspare(&self) -> u32 {
+        self.as_inner().as_inner().st_lspare as u32
+    }
+}
+
index b1d61f8ae12d3ef6b3c0b488a4637e1230f2ed4b..ce7b91ea41c877c7579bf005aecef6e1e05d9cdc 100644 (file)
@@ -13,9 +13,4 @@
 #![stable(feature = "raw_ext", since = "1.1.0")]
 
 pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
-    #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub use sys::fs::MetadataExt;
-}
+pub mod fs;
index a1e39721bcf63056fc501eed9c04469a8ecc3633..073ddf10d1ccdd57056d3428bcf94274acf75bb1 100644 (file)
 //! FreeBSD-specific raw type definitions
 
 #![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+                    reason = "these type aliases are no longer supported by \
+                              the standard library, the `libc` crate on \
+                              crates.io should be used instead for the correct \
+                              definitions")]
+#![allow(deprecated)]
 
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u16;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u16;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type fflags_t = u32;
 
 #[unstable(feature = "pthread_t", issue = "29791")] pub type pthread_t = usize;
@@ -33,7 +39,7 @@ mod arch {
     use os::raw::c_long;
     use os::unix::raw::{uid_t, gid_t};
 
-    #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
 
     #[repr(C)]
     #[derive(Clone)]
@@ -99,47 +105,47 @@ mod arch {
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub struct stat {
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_dev: dev_t,
+        pub st_dev: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_ino: ino_t,
+        pub st_ino: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_mode: mode_t,
+        pub st_mode: u16,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_nlink: nlink_t,
+        pub st_nlink: u16,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_uid: uid_t,
+        pub st_uid: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_gid: gid_t,
+        pub st_gid: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_rdev: dev_t,
+        pub st_rdev: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_atime: time_t,
+        pub st_atime: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_atime_nsec: c_long,
+        pub st_atime_nsec: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_mtime: time_t,
+        pub st_mtime: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_mtime_nsec: c_long,
+        pub st_mtime_nsec: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_ctime: time_t,
+        pub st_ctime: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_ctime_nsec: c_long,
+        pub st_ctime_nsec: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_size: off_t,
+        pub st_size: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_blocks: blkcnt_t,
+        pub st_blocks: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_blksize: blksize_t,
+        pub st_blksize: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_flags: fflags_t,
+        pub st_flags: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_gen: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_lspare: i32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_birthtime: time_t,
+        pub st_birthtime: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_birthtime_nsec: c_long,
+        pub st_birthtime_nsec: i64,
     }
 }
 
diff --git a/src/libstd/os/ios/fs.rs b/src/libstd/os/ios/fs.rs
new file mode 100644 (file)
index 0000000..275daf3
--- /dev/null
@@ -0,0 +1,154 @@
+// Copyright 2016 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.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::ios::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+    /// Gain a reference to the underlying `stat` structure which contains
+    /// the raw information returned by the OS.
+    ///
+    /// The contents of the returned `stat` are **not** consistent across
+    /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+    /// cross-Unix abstractions contained within the raw stat.
+    #[stable(feature = "metadata_ext", since = "1.1.0")]
+    #[rustc_deprecated(since = "1.8.0",
+                       reason = "deprecated in favor of the accessor \
+                                 methods of this trait")]
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat;
+
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_dev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ino(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mode(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_nlink(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_uid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_gid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_rdev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_size(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_birthtime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_birthtime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blksize(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blocks(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_flags(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_gen(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_lspare(&self) -> u32;
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat {
+        unsafe {
+            &*(self.as_inner().as_inner() as *const libc::stat
+                                          as *const raw::stat)
+        }
+    }
+    fn st_dev(&self) -> u64 {
+        self.as_inner().as_inner().st_dev as u64
+    }
+    fn st_ino(&self) -> u64 {
+        self.as_inner().as_inner().st_ino as u64
+    }
+    fn st_mode(&self) -> u32 {
+        self.as_inner().as_inner().st_mode as u32
+    }
+    fn st_nlink(&self) -> u64 {
+        self.as_inner().as_inner().st_nlink as u64
+    }
+    fn st_uid(&self) -> u32 {
+        self.as_inner().as_inner().st_uid as u32
+    }
+    fn st_gid(&self) -> u32 {
+        self.as_inner().as_inner().st_gid as u32
+    }
+    fn st_rdev(&self) -> u64 {
+        self.as_inner().as_inner().st_rdev as u64
+    }
+    fn st_size(&self) -> u64 {
+        self.as_inner().as_inner().st_size as u64
+    }
+    fn st_atime(&self) -> i64 {
+        self.as_inner().as_inner().st_atime as i64
+    }
+    fn st_atime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_atime_nsec as i64
+    }
+    fn st_mtime(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime as i64
+    }
+    fn st_mtime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime_nsec as i64
+    }
+    fn st_ctime(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime as i64
+    }
+    fn st_ctime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime_nsec as i64
+    }
+    fn st_birthtime(&self) -> i64 {
+        self.as_inner().as_inner().st_birthtime as i64
+    }
+    fn st_birthtime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_birthtime_nsec as i64
+    }
+    fn st_blksize(&self) -> u64 {
+        self.as_inner().as_inner().st_blksize as u64
+    }
+    fn st_blocks(&self) -> u64 {
+        self.as_inner().as_inner().st_blocks as u64
+    }
+    fn st_gen(&self) -> u32 {
+        self.as_inner().as_inner().st_gen as u32
+    }
+    fn st_flags(&self) -> u32 {
+        self.as_inner().as_inner().st_flags as u32
+    }
+    fn st_lspare(&self) -> u32 {
+        self.as_inner().as_inner().st_lspare as u32
+    }
+}
+
index 07fba4b182be166525224c8354cfe98e33bb8f1d..4cad23389d02e214db5bb55fc5e23fd1da2ef62f 100644 (file)
@@ -13,9 +13,4 @@
 #![stable(feature = "raw_ext", since = "1.1.0")]
 
 pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
-    #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub use sys::fs::MetadataExt;
-}
+pub mod fs;
index 20fe833a98076930eb5e597f67155acf4050190b..5a2de14b28b0c4be4c2eb3a138ed02aa9f8ccd45 100644 (file)
 //! iOS-specific raw type definitions
 
 #![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+                    reason = "these type aliases are no longer supported by \
+                              the standard library, the `libc` crate on \
+                              crates.io should be used instead for the correct \
+                              definitions")]
+#![allow(deprecated)]
 
 use os::raw::c_long;
-use os::unix::raw::{uid_t, gid_t};
 
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = i32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u16;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u16;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = c_long;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
 
 #[unstable(feature = "pthread_t", issue = "29791")] pub type pthread_t = usize;
 
 #[stable(feature = "raw_ext", since = "1.1.0")]
 pub struct stat {
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_dev: dev_t,
+    pub st_dev: i32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_mode: mode_t,
+    pub st_mode: u16,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_nlink: nlink_t,
+    pub st_nlink: u16,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_ino: ino_t,
+    pub st_ino: u64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_uid: uid_t,
+    pub st_uid: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_gid: gid_t,
+    pub st_gid: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_rdev: dev_t,
+    pub st_rdev: i32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_atime: time_t,
+    pub st_atime: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_atime_nsec: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_mtime: time_t,
+    pub st_mtime: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_mtime_nsec: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_ctime: time_t,
+    pub st_ctime: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_ctime_nsec: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_birthtime: time_t,
+    pub st_birthtime: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_birthtime_nsec: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_size: off_t,
+    pub st_size: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_blocks: blkcnt_t,
+    pub st_blocks: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_blksize: blksize_t,
+    pub st_blksize: i32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_flags: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
diff --git a/src/libstd/os/linux/fs.rs b/src/libstd/os/linux/fs.rs
new file mode 100644 (file)
index 0000000..11c4181
--- /dev/null
@@ -0,0 +1,128 @@
+// Copyright 2016 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.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::linux::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+    /// Gain a reference to the underlying `stat` structure which contains
+    /// the raw information returned by the OS.
+    ///
+    /// The contents of the returned `stat` are **not** consistent across
+    /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+    /// cross-Unix abstractions contained within the raw stat.
+    #[stable(feature = "metadata_ext", since = "1.1.0")]
+    #[rustc_deprecated(since = "1.8.0",
+                       reason = "deprecated in favor of the accessor \
+                                 methods of this trait")]
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat;
+
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_dev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ino(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mode(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_nlink(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_uid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_gid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_rdev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_size(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blksize(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blocks(&self) -> u64;
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat {
+        unsafe {
+            &*(self.as_inner().as_inner() as *const libc::stat64
+                                          as *const raw::stat)
+        }
+    }
+    fn st_dev(&self) -> u64 {
+        self.as_inner().as_inner().st_dev as u64
+    }
+    fn st_ino(&self) -> u64 {
+        self.as_inner().as_inner().st_ino as u64
+    }
+    fn st_mode(&self) -> u32 {
+        self.as_inner().as_inner().st_mode as u32
+    }
+    fn st_nlink(&self) -> u64 {
+        self.as_inner().as_inner().st_nlink as u64
+    }
+    fn st_uid(&self) -> u32 {
+        self.as_inner().as_inner().st_uid as u32
+    }
+    fn st_gid(&self) -> u32 {
+        self.as_inner().as_inner().st_gid as u32
+    }
+    fn st_rdev(&self) -> u64 {
+        self.as_inner().as_inner().st_rdev as u64
+    }
+    fn st_size(&self) -> u64 {
+        self.as_inner().as_inner().st_size as u64
+    }
+    fn st_atime(&self) -> i64 {
+        self.as_inner().as_inner().st_atime as i64
+    }
+    fn st_atime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_atime_nsec as i64
+    }
+    fn st_mtime(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime as i64
+    }
+    fn st_mtime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime_nsec as i64
+    }
+    fn st_ctime(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime as i64
+    }
+    fn st_ctime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime_nsec as i64
+    }
+    fn st_blksize(&self) -> u64 {
+        self.as_inner().as_inner().st_blksize as u64
+    }
+    fn st_blocks(&self) -> u64 {
+        self.as_inner().as_inner().st_blocks as u64
+    }
+}
index ea0b00c9998b260a19feb05eb60862f9e03407cf..8ec44b9fae49759aef99fb752456b87be4200050 100644 (file)
@@ -13,9 +13,4 @@
 #![stable(feature = "raw_ext", since = "1.1.0")]
 
 pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
-    #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub use sys::fs::MetadataExt;
-}
+pub mod fs;
index 10d37f9f59779461f7a9ce030131c7214b8e40c5..4113966841b24bdcd0d98ef74ac0908d17b701ec 100644 (file)
 //! Linux-specific raw type definitions
 
 #![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+                    reason = "these type aliases are no longer supported by \
+                              the standard library, the `libc` crate on \
+                              crates.io should be used instead for the correct \
+                              definitions")]
+#![allow(deprecated)]
 
 use os::raw::c_ulong;
 
           target_arch = "arm",
           target_arch = "asmjs"))]
 mod arch {
-    use super::{dev_t, mode_t};
-    use os::raw::{c_long, c_short};
-    use os::unix::raw::{gid_t, uid_t};
+    use os::raw::{c_long, c_short, c_uint};
 
-    #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i32;
-    #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
-
-    #[stable(feature = "raw_ext", since = "1.1.0")]
-    #[cfg(not(any(target_env = "musl", target_arch = "asmjs")))]
-    pub type ino_t = u32;
-    #[stable(feature = "raw_ext", since = "1.1.0")]
-    #[cfg(any(target_env = "musl", target_arch = "asmjs"))]
-    pub type ino_t = u64;
-
-    #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
-    #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i32;
-    #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
 
     #[repr(C)]
     #[derive(Clone)]
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub struct stat {
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_dev: dev_t,
+        pub st_dev: u64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub __pad1: c_short,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_ino: ino_t,
+        pub __st_ino: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_mode: mode_t,
+        pub st_mode: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_nlink: nlink_t,
+        pub st_nlink: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_uid: uid_t,
+        pub st_uid: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_gid: gid_t,
+        pub st_gid: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_rdev: dev_t,
+        pub st_rdev: u64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub __pad2: c_short,
+        pub __pad2: c_uint,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_size: off_t,
+        pub st_size: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_blksize: blksize_t,
+        pub st_blksize: i32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_blocks: blkcnt_t,
+        pub st_blocks: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_atime: time_t,
+        pub st_atime: i32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_atime_nsec: c_long,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_mtime: time_t,
+        pub st_mtime: i32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_mtime_nsec: c_long,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_ctime: time_t,
+        pub st_ctime: i32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_ctime_nsec: c_long,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub __unused4: c_long,
-        #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub __unused5: c_long,
+        pub st_ino: u64,
     }
 }
 
 #[cfg(target_arch = "mips")]
 mod arch {
-    use super::mode_t;
     use os::raw::{c_long, c_ulong};
-    use os::unix::raw::{gid_t, uid_t};
 
     #[cfg(target_env = "musl")]
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
     #[cfg(not(target_env = "musl"))]
-    #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i32;
-    #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
     #[cfg(target_env = "musl")]
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
     #[cfg(not(target_env = "musl"))]
-    #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u32;
-    #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
     #[cfg(target_env = "musl")]
-    #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i32;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
     #[cfg(not(target_env = "musl"))]
-    #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
-    #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
 
     #[repr(C)]
     #[derive(Clone)]
@@ -125,39 +118,37 @@ pub struct stat {
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_pad1: [c_long; 3],
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_ino: ino_t,
+        pub st_ino: u64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_mode: mode_t,
+        pub st_mode: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_nlink: nlink_t,
+        pub st_nlink: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_uid: uid_t,
+        pub st_uid: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_gid: gid_t,
+        pub st_gid: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_rdev: c_ulong,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_pad2: [c_long; 2],
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_size: off_t,
-        #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_pad3: c_long,
+        pub st_size: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_atime: time_t,
+        pub st_atime: i32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_atime_nsec: c_long,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_mtime: time_t,
+        pub st_mtime: i32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_mtime_nsec: c_long,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_ctime: time_t,
+        pub st_ctime: i32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_ctime_nsec: c_long,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_blksize: blksize_t,
+        pub st_blksize: i32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_blocks: blkcnt_t,
+        pub st_blocks: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_pad5: [c_long; 14],
     }
@@ -165,15 +156,13 @@ pub struct stat {
 
 #[cfg(target_arch = "aarch64")]
 mod arch {
-    use super::{dev_t, mode_t};
     use os::raw::{c_long, c_int};
-    use os::unix::raw::{gid_t, uid_t};
 
-    #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
-    #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
-    #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
-    #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
 
     #[repr(C)]
@@ -181,39 +170,39 @@ mod arch {
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub struct stat {
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_dev: dev_t,
+        pub st_dev: u64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_ino: ino_t,
+        pub st_ino: u64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_mode: mode_t,
+        pub st_mode: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_nlink: nlink_t,
+        pub st_nlink: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_uid: uid_t,
+        pub st_uid: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_gid: gid_t,
+        pub st_gid: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_rdev: dev_t,
+        pub st_rdev: u64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub __pad1: dev_t,
+        pub __pad1: u64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_size: off_t,
+        pub st_size: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_blksize: blksize_t,
+        pub st_blksize: i32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub __pad2: c_int,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_blocks: blkcnt_t,
+        pub st_blocks: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_atime: time_t,
+        pub st_atime: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_atime_nsec: c_long,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_mtime: time_t,
+        pub st_mtime: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_mtime_nsec: c_long,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_ctime: time_t,
+        pub st_ctime: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_ctime_nsec: c_long,
         #[stable(feature = "raw_ext", since = "1.1.0")]
@@ -223,15 +212,13 @@ pub struct stat {
 
 #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64"))]
 mod arch {
-    use super::{dev_t, mode_t};
     use os::raw::{c_long, c_int};
-    use os::unix::raw::{gid_t, uid_t};
 
-    #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
-    #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i64;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
-    #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
+    #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
 
     #[repr(C)]
@@ -239,37 +226,37 @@ mod arch {
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub struct stat {
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_dev: dev_t,
+        pub st_dev: u64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_ino: ino_t,
+        pub st_ino: u64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_nlink: nlink_t,
+        pub st_nlink: u64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_mode: mode_t,
+        pub st_mode: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_uid: uid_t,
+        pub st_uid: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_gid: gid_t,
+        pub st_gid: u32,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub __pad0: c_int,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_rdev: dev_t,
+        pub st_rdev: u64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_size: off_t,
+        pub st_size: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_blksize: blksize_t,
+        pub st_blksize: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_blocks: blkcnt_t,
+        pub st_blocks: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_atime: time_t,
+        pub st_atime: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_atime_nsec: c_long,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_mtime: time_t,
+        pub st_mtime: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_mtime_nsec: c_long,
         #[stable(feature = "raw_ext", since = "1.1.0")]
-        pub st_ctime: time_t,
+        pub st_ctime: i64,
         #[stable(feature = "raw_ext", since = "1.1.0")]
         pub st_ctime_nsec: c_long,
         #[stable(feature = "raw_ext", since = "1.1.0")]
diff --git a/src/libstd/os/macos/fs.rs b/src/libstd/os/macos/fs.rs
new file mode 100644 (file)
index 0000000..12b4490
--- /dev/null
@@ -0,0 +1,160 @@
+// Copyright 2016 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.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::macos::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+    /// Gain a reference to the underlying `stat` structure which contains
+    /// the raw information returned by the OS.
+    ///
+    /// The contents of the returned `stat` are **not** consistent across
+    /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+    /// cross-Unix abstractions contained within the raw stat.
+    #[stable(feature = "metadata_ext", since = "1.1.0")]
+    #[rustc_deprecated(since = "1.8.0",
+                       reason = "deprecated in favor of the accessor \
+                                 methods of this trait")]
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat;
+
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_dev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ino(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mode(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_nlink(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_uid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_gid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_rdev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_size(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_birthtime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_birthtime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blksize(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blocks(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_flags(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_gen(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_lspare(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_qspare(&self) -> [u64; 2];
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat {
+        unsafe {
+            &*(self.as_inner().as_inner() as *const libc::stat
+                                          as *const raw::stat)
+        }
+    }
+    fn st_dev(&self) -> u64 {
+        self.as_inner().as_inner().st_dev as u64
+    }
+    fn st_ino(&self) -> u64 {
+        self.as_inner().as_inner().st_ino as u64
+    }
+    fn st_mode(&self) -> u32 {
+        self.as_inner().as_inner().st_mode as u32
+    }
+    fn st_nlink(&self) -> u64 {
+        self.as_inner().as_inner().st_nlink as u64
+    }
+    fn st_uid(&self) -> u32 {
+        self.as_inner().as_inner().st_uid as u32
+    }
+    fn st_gid(&self) -> u32 {
+        self.as_inner().as_inner().st_gid as u32
+    }
+    fn st_rdev(&self) -> u64 {
+        self.as_inner().as_inner().st_rdev as u64
+    }
+    fn st_size(&self) -> u64 {
+        self.as_inner().as_inner().st_size as u64
+    }
+    fn st_atime(&self) -> i64 {
+        self.as_inner().as_inner().st_atime as i64
+    }
+    fn st_atime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_atime_nsec as i64
+    }
+    fn st_mtime(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime as i64
+    }
+    fn st_mtime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime_nsec as i64
+    }
+    fn st_ctime(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime as i64
+    }
+    fn st_ctime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime_nsec as i64
+    }
+    fn st_birthtime(&self) -> i64 {
+        self.as_inner().as_inner().st_birthtime as i64
+    }
+    fn st_birthtime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_birthtime_nsec as i64
+    }
+    fn st_blksize(&self) -> u64 {
+        self.as_inner().as_inner().st_blksize as u64
+    }
+    fn st_blocks(&self) -> u64 {
+        self.as_inner().as_inner().st_blocks as u64
+    }
+    fn st_gen(&self) -> u32 {
+        self.as_inner().as_inner().st_gen as u32
+    }
+    fn st_flags(&self) -> u32 {
+        self.as_inner().as_inner().st_flags as u32
+    }
+    fn st_lspare(&self) -> u32 {
+        self.as_inner().as_inner().st_lspare as u32
+    }
+    fn st_qspare(&self) -> [u64; 2] {
+        let qspare = self.as_inner().as_inner().st_qspare;
+        [qspare[0] as u64, qspare[1] as u64]
+    }
+}
+
index 703b64ceb24843eeb1181ae498c677076b1e1ab4..4e995358fd8763580ba2ad7d8e8ab139c996944f 100644 (file)
@@ -13,9 +13,4 @@
 #![stable(feature = "raw_ext", since = "1.1.0")]
 
 pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
-    #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub use sys::fs::MetadataExt;
-}
+pub mod fs;
index 1407132b9c96de52583005f46be7a4ab9bbf6f8f..2148670ccbd2a5ec5b580f89870df6df627a3b57 100644 (file)
 //! MacOS-specific raw type definitions
 
 #![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+                    reason = "these type aliases are no longer supported by \
+                              the standard library, the `libc` crate on \
+                              crates.io should be used instead for the correct \
+                              definitions")]
+#![allow(deprecated)]
 
 use os::raw::c_long;
-use os::unix::raw::{uid_t, gid_t};
 
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = i32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u16;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u16;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = c_long;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
 
 #[unstable(feature = "pthread_t", issue = "29791")] pub type pthread_t = usize;
 
 #[stable(feature = "raw_ext", since = "1.1.0")]
 pub struct stat {
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_dev: dev_t,
+    pub st_dev: i32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_mode: mode_t,
+    pub st_mode: u16,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_nlink: nlink_t,
+    pub st_nlink: u16,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_ino: ino_t,
+    pub st_ino: u64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_uid: uid_t,
+    pub st_uid: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_gid: gid_t,
+    pub st_gid: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_rdev: dev_t,
+    pub st_rdev: i32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_atime: time_t,
+    pub st_atime: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_atime_nsec: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_mtime: time_t,
+    pub st_mtime: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_mtime_nsec: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_ctime: time_t,
+    pub st_ctime: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_ctime_nsec: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_birthtime: time_t,
+    pub st_birthtime: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_birthtime_nsec: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_size: off_t,
+    pub st_size: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_blocks: blkcnt_t,
+    pub st_blocks: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_blksize: blksize_t,
+    pub st_blksize: i32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_flags: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
diff --git a/src/libstd/os/nacl/fs.rs b/src/libstd/os/nacl/fs.rs
new file mode 100644 (file)
index 0000000..3e0fb44
--- /dev/null
@@ -0,0 +1,128 @@
+// Copyright 2016 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.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::nacl::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+    /// Gain a reference to the underlying `stat` structure which contains
+    /// the raw information returned by the OS.
+    ///
+    /// The contents of the returned `stat` are **not** consistent across
+    /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+    /// cross-Unix abstractions contained within the raw stat.
+    #[stable(feature = "metadata_ext", since = "1.1.0")]
+    #[rustc_deprecated(since = "1.8.0",
+                       reason = "deprecated in favor of the accessor \
+                                 methods of this trait")]
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat;
+
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_dev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ino(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mode(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_nlink(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_uid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_gid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_rdev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_size(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blksize(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blocks(&self) -> u64;
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat {
+        unsafe {
+            &*(self.as_inner().as_inner() as *const libc::stat64
+                                          as *const raw::stat)
+        }
+    }
+    fn st_dev(&self) -> u64 {
+        self.as_inner().as_inner().st_dev as u64
+    }
+    fn st_ino(&self) -> u64 {
+        self.as_inner().as_inner().st_ino as u64
+    }
+    fn st_mode(&self) -> u32 {
+        self.as_inner().as_inner().st_mode as u32
+    }
+    fn st_nlink(&self) -> u64 {
+        self.as_inner().as_inner().st_nlink as u64
+    }
+    fn st_uid(&self) -> u32 {
+        self.as_inner().as_inner().st_uid as u32
+    }
+    fn st_gid(&self) -> u32 {
+        self.as_inner().as_inner().st_gid as u32
+    }
+    fn st_rdev(&self) -> u64 {
+        self.as_inner().as_inner().st_rdev as u64
+    }
+    fn st_size(&self) -> u64 {
+        self.as_inner().as_inner().st_size as u64
+    }
+    fn st_atime(&self) -> i64 {
+        self.as_inner().as_inner().st_atime as i64
+    }
+    fn st_atime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_atime_nsec as i64
+    }
+    fn st_mtime(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime as i64
+    }
+    fn st_mtime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime_nsec as i64
+    }
+    fn st_ctime(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime as i64
+    }
+    fn st_ctime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime_nsec as i64
+    }
+    fn st_blksize(&self) -> u64 {
+        self.as_inner().as_inner().st_blksize as u64
+    }
+    fn st_blocks(&self) -> u64 {
+        self.as_inner().as_inner().st_blocks as u64
+    }
+}
index b87ee4beb2cbdcd328aa3acc8a17963b091ba69e..7dfa2eabe3e1721b4ae240cdd53f34c8046f5389 100644 (file)
@@ -13,9 +13,4 @@
 #![stable(feature = "raw_ext", since = "1.1.0")]
 
 pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
-    #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub use sys::fs::MetadataExt;
-}
+pub mod fs;
index 7258a14aaf4b357d258738a2ca435d7d505074e9..9a10fbcc30b72dac612a3f800eb58fa45e7bd359 100644 (file)
 //! Nacl-specific raw type definitions
 
 #![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+                    reason = "these type aliases are no longer supported by \
+                              the standard library, the `libc` crate on \
+                              crates.io should be used instead for the correct \
+                              definitions")]
+#![allow(deprecated)]
 
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type pid_t = i32;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type uid_t = u32;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type gid_t = u32;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
 
 #[unstable(feature = "pthread_t", issue = "29791")] pub type pthread_t = usize;
 
diff --git a/src/libstd/os/netbsd/fs.rs b/src/libstd/os/netbsd/fs.rs
new file mode 100644 (file)
index 0000000..f11e231
--- /dev/null
@@ -0,0 +1,154 @@
+// Copyright 2016 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.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::netbsd::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+    /// Gain a reference to the underlying `stat` structure which contains
+    /// the raw information returned by the OS.
+    ///
+    /// The contents of the returned `stat` are **not** consistent across
+    /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+    /// cross-Unix abstractions contained within the raw stat.
+    #[stable(feature = "metadata_ext", since = "1.1.0")]
+    #[rustc_deprecated(since = "1.8.0",
+                       reason = "deprecated in favor of the accessor \
+                                 methods of this trait")]
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat;
+
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_dev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ino(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mode(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_nlink(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_uid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_gid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_rdev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_size(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_birthtime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_birthtime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blksize(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blocks(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_flags(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_gen(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_spare(&self) -> u32;
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat {
+        unsafe {
+            &*(self.as_inner().as_inner() as *const libc::stat
+                                          as *const raw::stat)
+        }
+    }
+    fn st_dev(&self) -> u64 {
+        self.as_inner().as_inner().st_dev as u64
+    }
+    fn st_ino(&self) -> u64 {
+        self.as_inner().as_inner().st_ino as u64
+    }
+    fn st_mode(&self) -> u32 {
+        self.as_inner().as_inner().st_mode as u32
+    }
+    fn st_nlink(&self) -> u64 {
+        self.as_inner().as_inner().st_nlink as u64
+    }
+    fn st_uid(&self) -> u32 {
+        self.as_inner().as_inner().st_uid as u32
+    }
+    fn st_gid(&self) -> u32 {
+        self.as_inner().as_inner().st_gid as u32
+    }
+    fn st_rdev(&self) -> u64 {
+        self.as_inner().as_inner().st_rdev as u64
+    }
+    fn st_size(&self) -> u64 {
+        self.as_inner().as_inner().st_size as u64
+    }
+    fn st_atime(&self) -> i64 {
+        self.as_inner().as_inner().st_atime as i64
+    }
+    fn st_atime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_atime_nsec as i64
+    }
+    fn st_mtime(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime as i64
+    }
+    fn st_mtime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime_nsec as i64
+    }
+    fn st_ctime(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime as i64
+    }
+    fn st_ctime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime_nsec as i64
+    }
+    fn st_birthtime(&self) -> i64 {
+        self.as_inner().as_inner().st_birthtime as i64
+    }
+    fn st_birthtime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_birthtime_nsec as i64
+    }
+    fn st_blksize(&self) -> u64 {
+        self.as_inner().as_inner().st_blksize as u64
+    }
+    fn st_blocks(&self) -> u64 {
+        self.as_inner().as_inner().st_blocks as u64
+    }
+    fn st_gen(&self) -> u32 {
+        self.as_inner().as_inner().st_gen as u32
+    }
+    fn st_flags(&self) -> u32 {
+        self.as_inner().as_inner().st_flags as u32
+    }
+    fn st_spare(&self) -> u32 {
+        self.as_inner().as_inner().st_spare as u32
+    }
+}
+
index ff6f76ba1d5b340fe3dac6f02464496a9ab85097..06efbd83707d3e1fbe397c2ee48d240ced546c04 100644 (file)
@@ -13,9 +13,4 @@
 #![stable(feature = "raw_ext", since = "1.1.0")]
 
 pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
-    #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub use sys::fs::MetadataExt;
-}
+pub mod fs;
index 9ca58924955103c1e18f90771b3d7e14fd925d77..7eb3f6d47d13cb06ab2571945e0112d0d2dd7c82 100644 (file)
 //! NetBSD-specific raw type definitions
 
 #![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+                    reason = "these type aliases are no longer supported by \
+                              the standard library, the `libc` crate on \
+                              crates.io should be used instead for the correct \
+                              definitions")]
+#![allow(deprecated)]
 
 use os::raw::c_long;
 use os::unix::raw::{uid_t, gid_t};
 
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type fflags_t = u32;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
 
 #[unstable(feature = "pthread_t", issue = "29791")] pub type pthread_t = usize;
 #[stable(feature = "raw_ext", since = "1.1.0")]
 pub struct stat {
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_mode: mode_t,
+    pub st_dev: u64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_dev: dev_t,
+    pub st_mode: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_ino: ino_t,
+    pub st_ino: u64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_nlink: nlink_t,
+    pub st_nlink: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_uid: uid_t,
+    pub st_uid: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_gid: gid_t,
+    pub st_gid: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_rdev: dev_t,
+    pub st_rdev: u64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_atime: time_t,
+    pub st_atime: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_atime_nsec: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_mtime: time_t,
+    pub st_mtime: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_mtime_nsec: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_ctime: time_t,
+    pub st_ctime: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_ctime_nsec: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_birthtime: time_t,
+    pub st_birthtime: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_birthtime_nsec: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_size: off_t,
+    pub st_size: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_blocks: blkcnt_t,
+    pub st_blocks: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_blksize: blksize_t,
+    pub st_blksize: i32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_flags: fflags_t,
+    pub st_flags: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_gen: u32,
     st_spare: [u32; 2],
diff --git a/src/libstd/os/openbsd/fs.rs b/src/libstd/os/openbsd/fs.rs
new file mode 100644 (file)
index 0000000..cc812fc
--- /dev/null
@@ -0,0 +1,149 @@
+// Copyright 2016 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.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::openbsd::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+    /// Gain a reference to the underlying `stat` structure which contains
+    /// the raw information returned by the OS.
+    ///
+    /// The contents of the returned `stat` are **not** consistent across
+    /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+    /// cross-Unix abstractions contained within the raw stat.
+    #[stable(feature = "metadata_ext", since = "1.1.0")]
+    #[rustc_deprecated(since = "1.8.0",
+                       reason = "deprecated in favor of the accessor \
+                                 methods of this trait")]
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat;
+
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_dev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ino(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mode(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_nlink(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_uid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_gid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_rdev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_size(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_birthtime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_birthtime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blksize(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blocks(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_flags(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_gen(&self) -> u32;
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat {
+        unsafe {
+            &*(self.as_inner().as_inner() as *const libc::stat
+                                          as *const raw::stat)
+        }
+    }
+    fn st_dev(&self) -> u64 {
+        self.as_inner().as_inner().st_dev as u64
+    }
+    fn st_ino(&self) -> u64 {
+        self.as_inner().as_inner().st_ino as u64
+    }
+    fn st_mode(&self) -> u32 {
+        self.as_inner().as_inner().st_mode as u32
+    }
+    fn st_nlink(&self) -> u64 {
+        self.as_inner().as_inner().st_nlink as u64
+    }
+    fn st_uid(&self) -> u32 {
+        self.as_inner().as_inner().st_uid as u32
+    }
+    fn st_gid(&self) -> u32 {
+        self.as_inner().as_inner().st_gid as u32
+    }
+    fn st_rdev(&self) -> u64 {
+        self.as_inner().as_inner().st_rdev as u64
+    }
+    fn st_size(&self) -> u64 {
+        self.as_inner().as_inner().st_size as u64
+    }
+    fn st_atime(&self) -> i64 {
+        self.as_inner().as_inner().st_atime as i64
+    }
+    fn st_atime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_atime_nsec as i64
+    }
+    fn st_mtime(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime as i64
+    }
+    fn st_mtime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime_nsec as i64
+    }
+    fn st_ctime(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime as i64
+    }
+    fn st_ctime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime_nsec as i64
+    }
+    fn st_birthtime(&self) -> i64 {
+        self.as_inner().as_inner().st_birthtime as i64
+    }
+    fn st_birthtime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_birthtime_nsec as i64
+    }
+    fn st_blksize(&self) -> u64 {
+        self.as_inner().as_inner().st_blksize as u64
+    }
+    fn st_blocks(&self) -> u64 {
+        self.as_inner().as_inner().st_blocks as u64
+    }
+    fn st_gen(&self) -> u32 {
+        self.as_inner().as_inner().st_gen as u32
+    }
+    fn st_flags(&self) -> u32 {
+        self.as_inner().as_inner().st_flags as u32
+    }
+}
+
index ff6f76ba1d5b340fe3dac6f02464496a9ab85097..06efbd83707d3e1fbe397c2ee48d240ced546c04 100644 (file)
@@ -13,9 +13,4 @@
 #![stable(feature = "raw_ext", since = "1.1.0")]
 
 pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
-    #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub use sys::fs::MetadataExt;
-}
+pub mod fs;
index b4d493953030e8e7f7e3ee8e168859aa0435934e..0e9a2128bc2a3ad84a0a82f2c665c181a45c2d98 100644 (file)
 //! OpenBSD-specific raw type definitions
 
 #![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+                    reason = "these type aliases are no longer supported by \
+                              the standard library, the `libc` crate on \
+                              crates.io should be used instead for the correct \
+                              definitions")]
+#![allow(deprecated)]
 
 use os::raw::c_long;
-use os::unix::raw::{uid_t, gid_t};
 
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = i32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type fflags_t = u32;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
 
 #[unstable(feature = "pthread_t", issue = "29791")] pub type pthread_t = usize;
 #[stable(feature = "raw_ext", since = "1.1.0")]
 pub struct stat {
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_mode: mode_t,
+    pub st_mode: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_dev: dev_t,
+    pub st_dev: i32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_ino: ino_t,
+    pub st_ino: u64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_nlink: nlink_t,
+    pub st_nlink: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_uid: uid_t,
+    pub st_uid: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_gid: gid_t,
+    pub st_gid: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_rdev: dev_t,
+    pub st_rdev: i32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_atime: time_t,
+    pub st_atime: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_atime_nsec: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_mtime: time_t,
+    pub st_mtime: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_mtime_nsec: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_ctime: time_t,
+    pub st_ctime: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_ctime_nsec: c_long,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_size: off_t,
+    pub st_size: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_blocks: blkcnt_t,
+    pub st_blocks: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_blksize: blksize_t,
+    pub st_blksize: i32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_flags: fflags_t,
+    pub st_flags: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_gen: u32,
     #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub st_birthtime: time_t,
+    pub st_birthtime: i64,
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub st_birthtime_nsec: c_long,
 }
index 4200e105ceaad43cb39809e5df43c6f95a9b94e0..55d8ad17460dd25111bde63fa1ee24c7e8cf6f3e 100644 (file)
@@ -81,36 +81,10 @@ macro_rules! ok {
         )*}
     }
 
-    macro_rules! ok_size {
-        ($($t:ident)*) => {$(
-            assert!(mem::size_of::<libc::$t>() == mem::size_of::<raw::$t>(),
-                    "{} is wrong", stringify!($t));
-        )*}
-    }
-
     #[test]
     fn same() {
         use os::raw;
         ok!(c_char c_schar c_uchar c_short c_ushort c_int c_uint c_long c_ulong
             c_longlong c_ulonglong c_float c_double);
     }
-
-    #[cfg(all(unix, not(target_os = "android")))]
-    #[test]
-    fn unix() {
-        {
-            use os::unix::raw;
-            ok!(uid_t gid_t dev_t ino_t mode_t nlink_t off_t blksize_t blkcnt_t);
-        }
-        {
-            use sys::platform::raw;
-            ok_size!(stat);
-        }
-    }
-
-    #[cfg(windows)]
-    #[test]
-    fn windows() {
-        use os::windows::raw;
-    }
 }
diff --git a/src/libstd/os/solaris/fs.rs b/src/libstd/os/solaris/fs.rs
new file mode 100644 (file)
index 0000000..1c043af
--- /dev/null
@@ -0,0 +1,128 @@
+// Copyright 2016 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.
+
+#![stable(feature = "metadata_ext", since = "1.1.0")]
+
+use libc;
+
+use fs::Metadata;
+use sys_common::AsInner;
+
+#[allow(deprecated)]
+use os::solaris::raw;
+
+/// OS-specific extension methods for `fs::Metadata`
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+pub trait MetadataExt {
+    /// Gain a reference to the underlying `stat` structure which contains
+    /// the raw information returned by the OS.
+    ///
+    /// The contents of the returned `stat` are **not** consistent across
+    /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
+    /// cross-Unix abstractions contained within the raw stat.
+    #[stable(feature = "metadata_ext", since = "1.1.0")]
+    #[rustc_deprecated(since = "1.8.0",
+                       reason = "deprecated in favor of the accessor \
+                                 methods of this trait")]
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat;
+
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_dev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ino(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mode(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_nlink(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_uid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_gid(&self) -> u32;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_rdev(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_size(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_atime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_mtime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_ctime_nsec(&self) -> i64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blksize(&self) -> u64;
+    #[stable(feature = "metadata_ext2", since = "1.8.0")]
+    fn st_blocks(&self) -> u64;
+}
+
+#[stable(feature = "metadata_ext", since = "1.1.0")]
+impl MetadataExt for Metadata {
+    #[allow(deprecated)]
+    fn as_raw_stat(&self) -> &raw::stat {
+        unsafe {
+            &*(self.as_inner().as_inner() as *const libc::stat64
+                                          as *const raw::stat)
+        }
+    }
+    fn st_dev(&self) -> u64 {
+        self.as_inner().as_inner().st_dev as u64
+    }
+    fn st_ino(&self) -> u64 {
+        self.as_inner().as_inner().st_ino as u64
+    }
+    fn st_mode(&self) -> u32 {
+        self.as_inner().as_inner().st_mode as u32
+    }
+    fn st_nlink(&self) -> u64 {
+        self.as_inner().as_inner().st_nlink as u64
+    }
+    fn st_uid(&self) -> u32 {
+        self.as_inner().as_inner().st_uid as u32
+    }
+    fn st_gid(&self) -> u32 {
+        self.as_inner().as_inner().st_gid as u32
+    }
+    fn st_rdev(&self) -> u64 {
+        self.as_inner().as_inner().st_rdev as u64
+    }
+    fn st_size(&self) -> u64 {
+        self.as_inner().as_inner().st_size as u64
+    }
+    fn st_atime(&self) -> i64 {
+        self.as_inner().as_inner().st_atime as i64
+    }
+    fn st_atime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_atime_nsec as i64
+    }
+    fn st_mtime(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime as i64
+    }
+    fn st_mtime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_mtime_nsec as i64
+    }
+    fn st_ctime(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime as i64
+    }
+    fn st_ctime_nsec(&self) -> i64 {
+        self.as_inner().as_inner().st_ctime_nsec as i64
+    }
+    fn st_blksize(&self) -> u64 {
+        self.as_inner().as_inner().st_blksize as u64
+    }
+    fn st_blocks(&self) -> u64 {
+        self.as_inner().as_inner().st_blocks as u64
+    }
+}
index f265233bd54a550eaefefb3a6de494a262279b2c..1e0166947bf5c1dd1938e22b6850fb2b34e8b6a5 100644 (file)
@@ -13,9 +13,4 @@
 #![stable(feature = "raw_ext", since = "1.1.0")]
 
 pub mod raw;
-
-#[stable(feature = "raw_ext", since = "1.1.0")]
-pub mod fs {
-    #[stable(feature = "raw_ext", since = "1.1.0")]
-    pub use sys::fs::MetadataExt;
-}
+pub mod fs;
index cf46ae4a3600d9b1a5e78cbcd92e8a9cb748faf5..6a75b36bd6bdea776308356e268e9bb32fef48d1 100644 (file)
 //! Solaris-specific raw type definitions
 
 #![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+                    reason = "these type aliases are no longer supported by \
+                              the standard library, the `libc` crate on \
+                              crates.io should be used instead for the correct \
+                              definitions")]
+#![allow(deprecated)]
 
 use os::raw::c_long;
 use os::unix::raw::{uid_t, gid_t};
 
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type fflags_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = i64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
 
 #[unstable(feature = "pthread_t", issue = "29791")] pub type pthread_t = usize;
index a0db471deceb3e8619d82e306228802d1e2da31d..ebd299efa78db9ca89206ec41af9885f921b861a 100644 (file)
@@ -55,7 +55,7 @@
 //! * [`std::marker`]::{[`Copy`], [`Send`], [`Sized`], [`Sync`]}. The marker
 //!   traits indicate fundamental properties of types.
 //! * [`std::ops`]::{[`Drop`], [`Fn`], [`FnMut`], [`FnOnce`]}. Various
-//!   operations for both destuctors and overloading `()`.
+//!   operations for both destructors and overloading `()`.
 //! * [`std::mem`]::[`drop`], a convenience function for explicitly dropping a
 //!   value.
 //! * [`std::boxed`]::[`Box`], a way to allocate values on the heap.
index 2cfa04c843b6b55fc800a220d17966776f6c6825..d858c0027558ced777dcfddd0fbe84e9ff5a7801 100644 (file)
@@ -111,7 +111,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<T: Send + Reflect> Error for PoisonError<T> {
+impl<T: Reflect> Error for PoisonError<T> {
     fn description(&self) -> &str {
         "poisoned lock: another task failed inside"
     }
@@ -158,14 +158,17 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<T: Send + Reflect> fmt::Display for TryLockError<T> {
+impl<T> fmt::Display for TryLockError<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        self.description().fmt(f)
+        match *self {
+            TryLockError::Poisoned(..) => "poisoned lock: another task failed inside",
+            TryLockError::WouldBlock => "try_lock failed because the operation would block"
+        }.fmt(f)
     }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<T: Send + Reflect> Error for TryLockError<T> {
+impl<T: Reflect> Error for TryLockError<T> {
     fn description(&self) -> &str {
         match *self {
             TryLockError::Poisoned(ref p) => p.description(),
index 2a3117864d06336584490f11dd4593ad91bedb3a..bdde25648ed8707e56f009d02fa52f1986ea59fb 100644 (file)
 use fs::{self, Permissions, OpenOptions};
 use io;
 use libc;
-use os::raw::c_long;
+#[allow(deprecated)]
 use os::unix::raw;
 use path::Path;
-use sys::fs::MetadataExt as UnixMetadataExt;
 use sys;
 use sys_common::{FromInner, AsInner, AsInnerMut};
+use sys::platform::fs::MetadataExt as UnixMetadataExt;
 
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
 #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
 pub const USER_READ: raw::mode_t = 0o400;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
 #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
 pub const USER_WRITE: raw::mode_t = 0o200;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
 #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
 pub const USER_EXECUTE: raw::mode_t = 0o100;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
 #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
 pub const USER_RWX: raw::mode_t = 0o700;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
 #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
 pub const GROUP_READ: raw::mode_t = 0o040;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
 #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
 pub const GROUP_WRITE: raw::mode_t = 0o020;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
 #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
 pub const GROUP_EXECUTE: raw::mode_t = 0o010;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
 #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
 pub const GROUP_RWX: raw::mode_t = 0o070;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
 #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
 pub const OTHER_READ: raw::mode_t = 0o004;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
 #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
 pub const OTHER_WRITE: raw::mode_t = 0o002;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
 #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
 pub const OTHER_EXECUTE: raw::mode_t = 0o001;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
 #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
 pub const OTHER_RWX: raw::mode_t = 0o007;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
 #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
 pub const ALL_READ: raw::mode_t = 0o444;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
 #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
 pub const ALL_WRITE: raw::mode_t = 0o222;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
 #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
 pub const ALL_EXECUTE: raw::mode_t = 0o111;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
 #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
 pub const ALL_RWX: raw::mode_t = 0o777;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
 #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
 pub const SETUID: raw::mode_t = 0o4000;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
 #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
 pub const SETGID: raw::mode_t = 0o2000;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
 #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
+#[allow(deprecated)]
 pub const STICKY_BIT: raw::mode_t = 0o1000;
 
 /// Unix-specific extensions to `Permissions`
@@ -86,28 +105,30 @@ pub trait PermissionsExt {
     /// Returns the underlying raw `mode_t` bits that are the standard Unix
     /// permissions for this file.
     #[stable(feature = "fs_ext", since = "1.1.0")]
-    fn mode(&self) -> raw::mode_t;
+    fn mode(&self) -> u32;
 
-    /// Sets the underlying raw `mode_t` bits for this set of permissions.
+    /// Sets the underlying raw bits for this set of permissions.
     #[stable(feature = "fs_ext", since = "1.1.0")]
-    fn set_mode(&mut self, mode: raw::mode_t);
+    fn set_mode(&mut self, mode: u32);
 
     /// Creates a new instance of `Permissions` from the given set of Unix
     /// permission bits.
     #[stable(feature = "fs_ext", since = "1.1.0")]
-    fn from_mode(mode: raw::mode_t) -> Self;
+    fn from_mode(mode: u32) -> Self;
 }
 
 #[stable(feature = "fs_ext", since = "1.1.0")]
 impl PermissionsExt for Permissions {
-    fn mode(&self) -> raw::mode_t { self.as_inner().mode() }
+    fn mode(&self) -> u32 {
+        self.as_inner().mode()
+    }
 
-    fn set_mode(&mut self, mode: raw::mode_t) {
-        *self = FromInner::from_inner(FromInner::from_inner(mode));
+    fn set_mode(&mut self, mode: u32) {
+        *self = Permissions::from_inner(FromInner::from_inner(mode));
     }
 
-    fn from_mode(mode: raw::mode_t) -> Permissions {
-        FromInner::from_inner(FromInner::from_inner(mode))
+    fn from_mode(mode: u32) -> Permissions {
+        Permissions::from_inner(FromInner::from_inner(mode))
     }
 }
 
@@ -122,7 +143,7 @@ pub trait OpenOptionsExt {
     /// The operating system masks out bits with the systems `umask`, to produce
     /// the final permissions.
     #[stable(feature = "fs_ext", since = "1.1.0")]
-    fn mode(&mut self, mode: raw::mode_t) -> &mut Self;
+    fn mode(&mut self, mode: u32) -> &mut Self;
 
     /// Pass custom flags to the `flags` agument of `open`.
     ///
@@ -154,7 +175,7 @@ pub trait OpenOptionsExt {
 
 #[stable(feature = "fs_ext", since = "1.1.0")]
 impl OpenOptionsExt for OpenOptions {
-    fn mode(&mut self, mode: raw::mode_t) -> &mut OpenOptions {
+    fn mode(&mut self, mode: u32) -> &mut OpenOptions {
         self.as_inner_mut().mode(mode); self
     }
 
@@ -173,62 +194,57 @@ fn custom_flags(&mut self, flags: i32) -> &mut OpenOptions {
 #[stable(feature = "metadata_ext", since = "1.1.0")]
 pub trait MetadataExt {
     #[stable(feature = "metadata_ext", since = "1.1.0")]
-    fn dev(&self) -> raw::dev_t;
+    fn dev(&self) -> u64;
     #[stable(feature = "metadata_ext", since = "1.1.0")]
-    fn ino(&self) -> raw::ino_t;
+    fn ino(&self) -> u64;
     #[stable(feature = "metadata_ext", since = "1.1.0")]
-    fn mode(&self) -> raw::mode_t;
+    fn mode(&self) -> u32;
     #[stable(feature = "metadata_ext", since = "1.1.0")]
-    fn nlink(&self) -> raw::nlink_t;
+    fn nlink(&self) -> u64;
     #[stable(feature = "metadata_ext", since = "1.1.0")]
-    fn uid(&self) -> raw::uid_t;
+    fn uid(&self) -> u32;
     #[stable(feature = "metadata_ext", since = "1.1.0")]
-    fn gid(&self) -> raw::gid_t;
+    fn gid(&self) -> u32;
     #[stable(feature = "metadata_ext", since = "1.1.0")]
-    fn rdev(&self) -> raw::dev_t;
+    fn rdev(&self) -> u64;
     #[stable(feature = "metadata_ext", since = "1.1.0")]
-    fn size(&self) -> raw::off_t;
+    fn size(&self) -> u64;
     #[stable(feature = "metadata_ext", since = "1.1.0")]
-    fn atime(&self) -> raw::time_t;
+    fn atime(&self) -> i64;
     #[stable(feature = "metadata_ext", since = "1.1.0")]
-    fn atime_nsec(&self) -> c_long;
+    fn atime_nsec(&self) -> i64;
     #[stable(feature = "metadata_ext", since = "1.1.0")]
-    fn mtime(&self) -> raw::time_t;
+    fn mtime(&self) -> i64;
     #[stable(feature = "metadata_ext", since = "1.1.0")]
-    fn mtime_nsec(&self) -> c_long;
+    fn mtime_nsec(&self) -> i64;
     #[stable(feature = "metadata_ext", since = "1.1.0")]
-    fn ctime(&self) -> raw::time_t;
+    fn ctime(&self) -> i64;
     #[stable(feature = "metadata_ext", since = "1.1.0")]
-    fn ctime_nsec(&self) -> c_long;
+    fn ctime_nsec(&self) -> i64;
     #[stable(feature = "metadata_ext", since = "1.1.0")]
-    fn blksize(&self) -> raw::blksize_t;
+    fn blksize(&self) -> u64;
     #[stable(feature = "metadata_ext", since = "1.1.0")]
-    fn blocks(&self) -> raw::blkcnt_t;
+    fn blocks(&self) -> u64;
 }
 
 #[stable(feature = "metadata_ext", since = "1.1.0")]
 impl MetadataExt for fs::Metadata {
-    fn dev(&self) -> raw::dev_t { self.as_raw_stat().st_dev as raw::dev_t }
-    fn ino(&self) -> raw::ino_t { self.as_raw_stat().st_ino as raw::ino_t }
-    fn mode(&self) -> raw::mode_t { self.as_raw_stat().st_mode as raw::mode_t }
-    fn nlink(&self) -> raw::nlink_t { self.as_raw_stat().st_nlink as raw::nlink_t }
-    fn uid(&self) -> raw::uid_t { self.as_raw_stat().st_uid as raw::uid_t }
-    fn gid(&self) -> raw::gid_t { self.as_raw_stat().st_gid as raw::gid_t }
-    fn rdev(&self) -> raw::dev_t { self.as_raw_stat().st_rdev as raw::dev_t }
-    fn size(&self) -> raw::off_t { self.as_raw_stat().st_size as raw::off_t }
-    fn atime(&self) -> raw::time_t { self.as_raw_stat().st_atime }
-    fn atime_nsec(&self) -> c_long { self.as_raw_stat().st_atime_nsec as c_long }
-    fn mtime(&self) -> raw::time_t { self.as_raw_stat().st_mtime }
-    fn mtime_nsec(&self) -> c_long { self.as_raw_stat().st_mtime_nsec as c_long }
-    fn ctime(&self) -> raw::time_t { self.as_raw_stat().st_ctime }
-    fn ctime_nsec(&self) -> c_long { self.as_raw_stat().st_ctime_nsec as c_long }
-
-    fn blksize(&self) -> raw::blksize_t {
-        self.as_raw_stat().st_blksize as raw::blksize_t
-    }
-    fn blocks(&self) -> raw::blkcnt_t {
-        self.as_raw_stat().st_blocks as raw::blkcnt_t
-    }
+    fn dev(&self) -> u64 { self.st_dev() }
+    fn ino(&self) -> u64 { self.st_ino() }
+    fn mode(&self) -> u32 { self.st_mode() }
+    fn nlink(&self) -> u64 { self.st_nlink() }
+    fn uid(&self) -> u32 { self.st_uid() }
+    fn gid(&self) -> u32 { self.st_gid() }
+    fn rdev(&self) -> u64 { self.st_rdev() }
+    fn size(&self) -> u64 { self.st_size() }
+    fn atime(&self) -> i64 { self.st_atime() }
+    fn atime_nsec(&self) -> i64 { self.st_atime_nsec() }
+    fn mtime(&self) -> i64 { self.st_mtime() }
+    fn mtime_nsec(&self) -> i64 { self.st_mtime_nsec() }
+    fn ctime(&self) -> i64 { self.st_ctime() }
+    fn ctime_nsec(&self) -> i64 { self.st_ctime_nsec() }
+    fn blksize(&self) -> u64 { self.st_blksize() }
+    fn blocks(&self) -> u64 { self.st_blocks() }
 }
 
 /// Add special unix types (block/char device, fifo and socket)
@@ -262,12 +278,12 @@ pub trait DirEntryExt {
     /// Returns the underlying `d_ino` field in the contained `dirent`
     /// structure.
     #[stable(feature = "dir_entry_ext", since = "1.1.0")]
-    fn ino(&self) -> raw::ino_t;
+    fn ino(&self) -> u64;
 }
 
 #[stable(feature = "dir_entry_ext", since = "1.1.0")]
 impl DirEntryExt for fs::DirEntry {
-    fn ino(&self) -> raw::ino_t { self.as_inner().ino() }
+    fn ino(&self) -> u64 { self.as_inner().ino() }
 }
 
 /// Creates a new symbolic link on the filesystem.
@@ -305,12 +321,12 @@ pub trait DirBuilderExt {
     /// Sets the mode to create new directories with. This option defaults to
     /// 0o777.
     #[stable(feature = "dir_builder", since = "1.6.0")]
-    fn mode(&mut self, mode: raw::mode_t) -> &mut Self;
+    fn mode(&mut self, mode: u32) -> &mut Self;
 }
 
 #[stable(feature = "dir_builder", since = "1.6.0")]
 impl DirBuilderExt for fs::DirBuilder {
-    fn mode(&mut self, mode: raw::mode_t) -> &mut fs::DirBuilder {
+    fn mode(&mut self, mode: u32) -> &mut fs::DirBuilder {
         self.as_inner_mut().set_mode(mode);
         self
     }
index fa19a2620bacffcd83a0a9fd4460a099cbf54551..8cc291d00ee027cf4cca947a1db1b0a6829ed556 100644 (file)
@@ -16,7 +16,6 @@
 
 use io;
 use os::unix::io::{FromRawFd, RawFd, AsRawFd, IntoRawFd};
-use os::unix::raw::{uid_t, gid_t};
 use process;
 use sys;
 use sys_common::{AsInnerMut, AsInner, FromInner, IntoInner};
@@ -28,12 +27,12 @@ pub trait CommandExt {
     /// `setuid` call in the child process. Failure in the `setuid`
     /// call will cause the spawn to fail.
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn uid(&mut self, id: uid_t) -> &mut process::Command;
+    fn uid(&mut self, id: u32) -> &mut process::Command;
 
     /// Similar to `uid`, but sets the group id of the child process. This has
     /// the same semantics as the `uid` field.
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn gid(&mut self, id: gid_t) -> &mut process::Command;
+    fn gid(&mut self, id: u32) -> &mut process::Command;
 
     /// Create a new session (cf. `setsid(2)`) for the child process. This means
     /// that the child is the leader of a new process group. The parent process
@@ -101,12 +100,12 @@ fn before_exec<F>(&mut self, f: F) -> &mut process::Command
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl CommandExt for process::Command {
-    fn uid(&mut self, id: uid_t) -> &mut process::Command {
+    fn uid(&mut self, id: u32) -> &mut process::Command {
         self.as_inner_mut().uid(id);
         self
     }
 
-    fn gid(&mut self, id: gid_t) -> &mut process::Command {
+    fn gid(&mut self, id: u32) -> &mut process::Command {
         self.as_inner_mut().gid(id);
         self
     }
index d1cc6cba51dbc06dfc7e1e1518f65e5da2116276..96535e886041803b50598d8e4a1f1f2ae1811800 100644 (file)
 //! Unix-specific primitives available on all unix platforms
 
 #![stable(feature = "raw_ext", since = "1.1.0")]
+#![rustc_deprecated(since = "1.8.0",
+                    reason = "these type aliases are no longer supported by \
+                              the standard library, the `libc` crate on \
+                              crates.io should be used instead for the correct \
+                              definitions")]
+#![allow(deprecated)]
 
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type uid_t = u32;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type gid_t = u32;
index c1c1609632a9444343c7fed0669233a440c9a129..bb8200ff8597a9bf6ad4639c155158217d9dc611 100644 (file)
 
 #![unstable(feature = "thread_extensions", issue = "29791")]
 
-use os::unix::raw::{pthread_t};
+#[allow(deprecated)]
+use os::unix::raw::pthread_t;
 use sys_common::{AsInner, IntoInner};
-use thread::{JoinHandle};
+use thread::JoinHandle;
 
 #[unstable(feature = "thread_extensions", issue = "29791")]
+#[allow(deprecated)]
 pub type RawPthread = pthread_t;
 
 /// Unix-specific extensions to `std::thread::JoinHandle`
index ee81c516e33d6c75d7336071c2eb6d4bf45637ad..14f30a6257660bcf4ffa31819c1ce15b09103f4f 100644 (file)
 use ptr;
 use sync::Arc;
 use sys::fd::FileDesc;
-use sys::platform::raw;
 use sys::time::SystemTime;
 use sys::{cvt, cvt_r};
 use sys_common::{AsInner, FromInner};
 
+#[cfg(target_os = "linux")]
+use libc::{stat64, fstat64, lstat64};
+#[cfg(not(target_os = "linux"))]
+use libc::{stat as stat64, fstat as fstat64, lstat as lstat64};
+
 pub struct File(FileDesc);
 
 #[derive(Clone)]
 pub struct FileAttr {
-    stat: raw::stat,
+    stat: stat64,
 }
 
 pub struct ReadDir {
@@ -116,14 +120,14 @@ pub fn created(&self) -> io::Result<SystemTime> {
 impl FileAttr {
     pub fn modified(&self) -> io::Result<SystemTime> {
         Ok(SystemTime::from(libc::timespec {
-            tv_sec: self.stat.st_mtime,
+            tv_sec: self.stat.st_mtime as libc::time_t,
             tv_nsec: self.stat.st_mtime_nsec as libc::c_long,
         }))
     }
 
     pub fn accessed(&self) -> io::Result<SystemTime> {
         Ok(SystemTime::from(libc::timespec {
-            tv_sec: self.stat.st_atime,
+            tv_sec: self.stat.st_atime as libc::time_t,
             tv_nsec: self.stat.st_atime_nsec as libc::c_long,
         }))
     }
@@ -133,7 +137,7 @@ pub fn accessed(&self) -> io::Result<SystemTime> {
               target_os = "openbsd"))]
     pub fn created(&self) -> io::Result<SystemTime> {
         Ok(SystemTime::from(libc::timespec {
-            tv_sec: self.stat.st_birthtime,
+            tv_sec: self.stat.st_birthtime as libc::time_t,
             tv_nsec: self.stat.st_birthtime_nsec as libc::c_long,
         }))
     }
@@ -148,26 +152,8 @@ pub fn created(&self) -> io::Result<SystemTime> {
     }
 }
 
-impl AsInner<raw::stat> for FileAttr {
-    fn as_inner(&self) -> &raw::stat { &self.stat }
-}
-
-/// OS-specific extension methods for `fs::Metadata`
-#[stable(feature = "metadata_ext", since = "1.1.0")]
-pub trait MetadataExt {
-    /// Gain a reference to the underlying `stat` structure which contains the
-    /// raw information returned by the OS.
-    ///
-    /// The contents of the returned `stat` are **not** consistent across Unix
-    /// platforms. The `os::unix::fs::MetadataExt` trait contains the cross-Unix
-    /// abstractions contained within the raw stat.
-    #[stable(feature = "metadata_ext", since = "1.1.0")]
-    fn as_raw_stat(&self) -> &raw::stat;
-}
-
-#[stable(feature = "metadata_ext", since = "1.1.0")]
-impl MetadataExt for ::fs::Metadata {
-    fn as_raw_stat(&self) -> &raw::stat { &self.as_inner().stat }
+impl AsInner<stat64> for FileAttr {
+    fn as_inner(&self) -> &stat64 { &self.stat }
 }
 
 impl FilePermissions {
@@ -179,7 +165,7 @@ pub fn set_readonly(&mut self, readonly: bool) {
             self.mode |= 0o222;
         }
     }
-    pub fn mode(&self) -> raw::mode_t { self.mode }
+    pub fn mode(&self) -> u32 { self.mode as u32 }
 }
 
 impl FileType {
@@ -190,8 +176,8 @@ pub fn is_symlink(&self) -> bool { self.is(libc::S_IFLNK) }
     pub fn is(&self, mode: mode_t) -> bool { self.mode & libc::S_IFMT == mode }
 }
 
-impl FromInner<raw::mode_t> for FilePermissions {
-    fn from_inner(mode: raw::mode_t) -> FilePermissions {
+impl FromInner<u32> for FilePermissions {
+    fn from_inner(mode: u32) -> FilePermissions {
         FilePermissions { mode: mode as mode_t }
     }
 }
@@ -293,15 +279,11 @@ pub fn file_type(&self) -> io::Result<FileType> {
     #[cfg(any(target_os = "macos",
               target_os = "ios",
               target_os = "linux",
-              target_os = "solaris",
-              target_os = "emscripten"))]
-    pub fn ino(&self) -> raw::ino_t {
-        self.entry.d_ino
-    }
-
-    #[cfg(target_os = "android")]
-    pub fn ino(&self) -> raw::ino_t {
-        self.entry.d_ino as raw::ino_t
+              target_os = "emscripten",
+              target_os = "android",
+              target_os = "solaris"))]
+    pub fn ino(&self) -> u64 {
+        self.entry.d_ino as u64
     }
 
     #[cfg(any(target_os = "freebsd",
@@ -309,8 +291,8 @@ pub fn ino(&self) -> raw::ino_t {
               target_os = "bitrig",
               target_os = "netbsd",
               target_os = "dragonfly"))]
-    pub fn ino(&self) -> raw::ino_t {
-        self.entry.d_fileno
+    pub fn ino(&self) -> u64 {
+        self.entry.d_fileno as u64
     }
 
     #[cfg(any(target_os = "macos",
@@ -364,7 +346,7 @@ pub fn new() -> OpenOptions {
     pub fn create_new(&mut self, create_new: bool) { self.create_new = create_new; }
 
     pub fn custom_flags(&mut self, flags: i32) { self.custom_flags = flags; }
-    pub fn mode(&mut self, mode: raw::mode_t) { self.mode = mode as mode_t; }
+    pub fn mode(&mut self, mode: u32) { self.mode = mode as mode_t; }
 
     fn get_access_mode(&self) -> io::Result<c_int> {
         match (self.read, self.write, self.append) {
@@ -431,9 +413,9 @@ pub fn open_c(path: &CStr, opts: &OpenOptions) -> io::Result<File> {
     }
 
     pub fn file_attr(&self) -> io::Result<FileAttr> {
-        let mut stat: raw::stat = unsafe { mem::zeroed() };
+        let mut stat: stat64 = unsafe { mem::zeroed() };
         try!(cvt(unsafe {
-            libc::fstat(self.0.raw(), &mut stat as *mut _ as *mut _)
+            fstat64(self.0.raw(), &mut stat)
         }));
         Ok(FileAttr { stat: stat })
     }
@@ -506,8 +488,8 @@ pub fn mkdir(&self, p: &Path) -> io::Result<()> {
         Ok(())
     }
 
-    pub fn set_mode(&mut self, mode: mode_t) {
-        self.mode = mode;
+    pub fn set_mode(&mut self, mode: u32) {
+        self.mode = mode as mode_t;
     }
 }
 
@@ -689,18 +671,18 @@ pub fn link(src: &Path, dst: &Path) -> io::Result<()> {
 
 pub fn stat(p: &Path) -> io::Result<FileAttr> {
     let p = try!(cstr(p));
-    let mut stat: raw::stat = unsafe { mem::zeroed() };
+    let mut stat: stat64 = unsafe { mem::zeroed() };
     try!(cvt(unsafe {
-        libc::stat(p.as_ptr(), &mut stat as *mut _ as *mut _)
+        stat64(p.as_ptr(), &mut stat as *mut _ as *mut _)
     }));
     Ok(FileAttr { stat: stat })
 }
 
 pub fn lstat(p: &Path) -> io::Result<FileAttr> {
     let p = try!(cstr(p));
-    let mut stat: raw::stat = unsafe { mem::zeroed() };
+    let mut stat: stat64 = unsafe { mem::zeroed() };
     try!(cvt(unsafe {
-        libc::lstat(p.as_ptr(), &mut stat as *mut _ as *mut _)
+        lstat64(p.as_ptr(), &mut stat as *mut _ as *mut _)
     }));
     Ok(FileAttr { stat: stat })
 }
index 9fdeb0aef14c8317527531f07ee8b12ee8ecb584..d25d8e0b8048d9ba6f9b7ef03759312d2df8f376 100644 (file)
@@ -240,6 +240,7 @@ fn clone(&self) -> Self { *self }
 pub const FSCTL_GET_REPARSE_POINT: DWORD = 0x900a8;
 pub const IO_REPARSE_TAG_SYMLINK: DWORD = 0xa000000c;
 pub const IO_REPARSE_TAG_MOUNT_POINT: DWORD = 0xa0000003;
+pub const SYMLINK_FLAG_RELATIVE: DWORD = 0x00000001;
 pub const FSCTL_SET_REPARSE_POINT: DWORD = 0x900a4;
 pub const FSCTL_DELETE_REPARSE_POINT: DWORD = 0x900ac;
 
@@ -533,6 +534,15 @@ pub struct SYMBOLIC_LINK_REPARSE_BUFFER {
     pub PathBuffer: WCHAR,
 }
 
+#[repr(C)]
+pub struct MOUNT_POINT_REPARSE_BUFFER {
+    pub SubstituteNameOffset: c_ushort,
+    pub SubstituteNameLength: c_ushort,
+    pub PrintNameOffset: c_ushort,
+    pub PrintNameLength: c_ushort,
+    pub PathBuffer: WCHAR,
+}
+
 pub type LPPROGRESS_ROUTINE = ::option::Option<unsafe extern "system" fn(
     TotalFileSize: LARGE_INTEGER,
     TotalBytesTransferred: LARGE_INTEGER,
index 3062d38f8c259ae4245378151a3b818d0b3b9ccc..d4d95a12f81c42a00be3d76007f6ff2e6990df4e 100644 (file)
@@ -150,7 +150,12 @@ pub fn metadata(&self) -> io::Result<FileAttr> {
                 nFileSizeHigh: self.data.nFileSizeHigh,
                 nFileSizeLow: self.data.nFileSizeLow,
             },
-            reparse_tag: self.data.dwReserved0,
+            reparse_tag: if self.data.dwFileAttributes & c::FILE_ATTRIBUTE_REPARSE_POINT != 0 {
+                    // reserved unless this is a reparse point
+                    self.data.dwReserved0
+                } else {
+                    0
+                },
         })
     }
 }
@@ -240,15 +245,6 @@ fn get_flags_and_attributes(&self) -> c::DWORD {
 }
 
 impl File {
-    fn open_reparse_point(path: &Path, write: bool) -> io::Result<File> {
-        let mut opts = OpenOptions::new();
-        opts.read(!write);
-        opts.write(write);
-        opts.custom_flags(c::FILE_FLAG_OPEN_REPARSE_POINT |
-                          c::FILE_FLAG_BACKUP_SEMANTICS);
-        File::open(path, &opts)
-    }
-
     pub fn open(path: &Path, opts: &OpenOptions) -> io::Result<File> {
         let path = try!(to_u16s(path));
         let handle = unsafe {
@@ -371,19 +367,34 @@ fn reparse_point<'a>(&self,
     fn readlink(&self) -> io::Result<PathBuf> {
         let mut space = [0u8; c::MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
         let (_bytes, buf) = try!(self.reparse_point(&mut space));
-        if buf.ReparseTag != c::IO_REPARSE_TAG_SYMLINK {
-            return Err(io::Error::new(io::ErrorKind::Other, "not a symlink"))
-        }
-
         unsafe {
-            let info: *const c::SYMBOLIC_LINK_REPARSE_BUFFER =
-                    &buf.rest as *const _ as *const _;
-            let path_buffer = &(*info).PathBuffer as *const _ as *const u16;
-            let subst_off = (*info).SubstituteNameOffset / 2;
+            let (path_buffer, subst_off, subst_len, relative) = match buf.ReparseTag {
+                c::IO_REPARSE_TAG_SYMLINK => {
+                    let info: *const c::SYMBOLIC_LINK_REPARSE_BUFFER =
+                        &buf.rest as *const _ as *const _;
+                    (&(*info).PathBuffer as *const _ as *const u16,
+                     (*info).SubstituteNameOffset / 2,
+                     (*info).SubstituteNameLength / 2,
+                     (*info).Flags & c::SYMLINK_FLAG_RELATIVE != 0)
+                },
+                c::IO_REPARSE_TAG_MOUNT_POINT => {
+                    let info: *const c::MOUNT_POINT_REPARSE_BUFFER =
+                        &buf.rest as *const _ as *const _;
+                    (&(*info).PathBuffer as *const _ as *const u16,
+                     (*info).SubstituteNameOffset / 2,
+                     (*info).SubstituteNameLength / 2,
+                     false)
+                },
+                _ => return Err(io::Error::new(io::ErrorKind::Other,
+                                               "Unsupported reparse point type"))
+            };
             let subst_ptr = path_buffer.offset(subst_off as isize);
-            let subst_len = (*info).SubstituteNameLength / 2;
-            let subst = slice::from_raw_parts(subst_ptr, subst_len as usize);
-
+            let mut subst = slice::from_raw_parts(subst_ptr, subst_len as usize);
+            // Absolute paths start with an NT internal namespace prefix `\??\`
+            // We should not let it leak through.
+            if !relative && subst.starts_with(&[92u16, 63u16, 63u16, 92u16]) {
+                subst = &subst[4..];
+            }
             Ok(PathBuf::from(OsString::from_wide(subst)))
         }
     }
@@ -577,8 +588,15 @@ fn remove_dir_all_recursive(path: &Path) -> io::Result<()> {
     rmdir(path)
 }
 
-pub fn readlink(p: &Path) -> io::Result<PathBuf> {
-    let file = try!(File::open_reparse_point(p, false));
+pub fn readlink(path: &Path) -> io::Result<PathBuf> {
+    // Open the link with no access mode, instead of generic read.
+    // By default FILE_LIST_DIRECTORY is denied for the junction "C:\Documents and Settings", so
+    // this is needed for a common case.
+    let mut opts = OpenOptions::new();
+    opts.access_mode(0);
+    opts.custom_flags(c::FILE_FLAG_OPEN_REPARSE_POINT |
+                      c::FILE_FLAG_BACKUP_SEMANTICS);
+    let file = try!(File::open(&path, &opts));
     file.readlink()
 }
 
@@ -605,42 +623,23 @@ pub fn link(src: &Path, dst: &Path) -> io::Result<()> {
     Ok(())
 }
 
-pub fn stat(p: &Path) -> io::Result<FileAttr> {
-    let attr = try!(lstat(p));
-
-    // If this is a reparse point, then we need to reopen the file to get the
-    // actual destination. We also pass the FILE_FLAG_BACKUP_SEMANTICS flag to
-    // ensure that we can open directories (this path may be a directory
-    // junction). Once the file is opened we ask the opened handle what its
-    // metadata information is.
-    if attr.is_reparse_point() {
-        let mut opts = OpenOptions::new();
-        // No read or write permissions are necessary
-        opts.access_mode(0);
-        // This flag is so we can open directories too
-        opts.custom_flags(c::FILE_FLAG_BACKUP_SEMANTICS);
-        let file = try!(File::open(p, &opts));
-        file.file_attr()
-    } else {
-        Ok(attr)
-    }
+pub fn stat(path: &Path) -> io::Result<FileAttr> {
+    let mut opts = OpenOptions::new();
+    // No read or write permissions are necessary
+    opts.access_mode(0);
+    // This flag is so we can open directories too
+    opts.custom_flags(c::FILE_FLAG_BACKUP_SEMANTICS);
+    let file = try!(File::open(path, &opts));
+    file.file_attr()
 }
 
-pub fn lstat(p: &Path) -> io::Result<FileAttr> {
-    let u16s = try!(to_u16s(p));
-    unsafe {
-        let mut attr: FileAttr = mem::zeroed();
-        try!(cvt(c::GetFileAttributesExW(u16s.as_ptr(),
-                                         c::GetFileExInfoStandard,
-                                         &mut attr.data as *mut _ as *mut _)));
-        if attr.is_reparse_point() {
-            attr.reparse_tag = File::open_reparse_point(p, false).and_then(|f| {
-                let mut b = [0; c::MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
-                f.reparse_point(&mut b).map(|(_, b)| b.ReparseTag)
-            }).unwrap_or(0);
-        }
-        Ok(attr)
-    }
+pub fn lstat(path: &Path) -> io::Result<FileAttr> {
+    let mut opts = OpenOptions::new();
+    // No read or write permissions are necessary
+    opts.access_mode(0);
+    opts.custom_flags(c::FILE_FLAG_BACKUP_SEMANTICS | c::FILE_FLAG_OPEN_REPARSE_POINT);
+    let file = try!(File::open(path, &opts));
+    file.file_attr()
 }
 
 pub fn set_perm(p: &Path, perm: FilePermissions) -> io::Result<()> {
@@ -709,7 +708,12 @@ pub fn symlink_junction<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::R
 fn symlink_junction_inner(target: &Path, junction: &Path) -> io::Result<()> {
     let d = DirBuilder::new();
     try!(d.mkdir(&junction));
-    let f = try!(File::open_reparse_point(junction, true));
+
+    let mut opts = OpenOptions::new();
+    opts.write(true);
+    opts.custom_flags(c::FILE_FLAG_OPEN_REPARSE_POINT |
+                      c::FILE_FLAG_BACKUP_SEMANTICS);
+    let f = try!(File::open(junction, &opts));
     let h = f.handle().raw();
 
     unsafe {
index d220508a741f1841904d7738b1ee04a2e4485473..cb79c609c1bfc19f3208fbcb140cdb9c84f152cf 100644 (file)
@@ -10,7 +10,6 @@
 
 // The Rust abstract syntax tree.
 
-pub use self::Pat_::*;
 pub use self::StructFieldKind::*;
 pub use self::TyParamBound::*;
 pub use self::UnsafeSource::*;
@@ -521,7 +520,7 @@ pub struct Block {
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
 pub struct Pat {
     pub id: NodeId,
-    pub node: Pat_,
+    pub node: PatKind,
     pub span: Span,
 }
 
@@ -552,47 +551,53 @@ pub enum BindingMode {
 }
 
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
-pub enum Pat_ {
+pub enum PatKind {
     /// Represents a wildcard pattern (`_`)
-    PatWild,
+    Wild,
 
-    /// A PatIdent may either be a new bound variable,
-    /// or a nullary enum (in which case the third field
-    /// is None).
+    /// A `PatKind::Ident` may either be a new bound variable,
+    /// or a unit struct/variant pattern, or a const pattern (in the last two cases
+    /// the third field must be `None`).
     ///
-    /// In the nullary enum case, the parser can't determine
+    /// In the unit or const pattern case, the parser can't determine
     /// which it is. The resolver determines this, and
-    /// records this pattern's NodeId in an auxiliary
-    /// set (of "PatIdents that refer to nullary enums")
-    PatIdent(BindingMode, SpannedIdent, Option<P<Pat>>),
+    /// records this pattern's `NodeId` in an auxiliary
+    /// set (of "PatIdents that refer to unit patterns or constants").
+    Ident(BindingMode, SpannedIdent, Option<P<Pat>>),
 
+    /// A struct or struct variant pattern, e.g. `Variant {x, y, ..}`.
+    /// The `bool` is `true` in the presence of a `..`.
+    Struct(Path, Vec<Spanned<FieldPat>>, bool),
+
+    /// A tuple struct/variant pattern `Variant(x, y, z)`.
     /// "None" means a `Variant(..)` pattern where we don't bind the fields to names.
-    PatEnum(Path, Option<Vec<P<Pat>>>),
+    TupleStruct(Path, Option<Vec<P<Pat>>>),
+
+    /// A path pattern.
+    /// Such pattern can be resolved to a unit struct/variant or a constant.
+    Path(Path),
 
     /// An associated const named using the qualified path `<T>::CONST` or
     /// `<T as Trait>::CONST`. Associated consts from inherent impls can be
     /// referred to as simply `T::CONST`, in which case they will end up as
-    /// PatEnum, and the resolver will have to sort that out.
-    PatQPath(QSelf, Path),
+    /// PatKind::Enum, and the resolver will have to sort that out.
+    QPath(QSelf, Path),
 
-    /// Destructuring of a struct, e.g. `Foo {x, y, ..}`
-    /// The `bool` is `true` in the presence of a `..`
-    PatStruct(Path, Vec<Spanned<FieldPat>>, bool),
     /// A tuple pattern `(a, b)`
-    PatTup(Vec<P<Pat>>),
+    Tup(Vec<P<Pat>>),
     /// A `box` pattern
-    PatBox(P<Pat>),
+    Box(P<Pat>),
     /// A reference pattern, e.g. `&mut (a, b)`
-    PatRegion(P<Pat>, Mutability),
+    Ref(P<Pat>, Mutability),
     /// A literal
-    PatLit(P<Expr>),
+    Lit(P<Expr>),
     /// A range pattern, e.g. `1...2`
-    PatRange(P<Expr>, P<Expr>),
+    Range(P<Expr>, P<Expr>),
     /// `[a, b, ..i, y, z]` is represented as:
-    ///     `PatVec(box [a, b], Some(i), box [y, z])`
-    PatVec(Vec<P<Pat>>, Option<P<Pat>>, Vec<P<Pat>>),
+    ///     `PatKind::Vec(box [a, b], Some(i), box [y, z])`
+    Vec(Vec<P<Pat>>, Option<P<Pat>>, Vec<P<Pat>>),
     /// A macro pattern; pre-expansion
-    PatMac(Mac),
+    Mac(Mac),
 }
 
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
@@ -1609,7 +1614,7 @@ pub fn new_self(span: Span, mutability: Mutability, self_ident: Ident) -> Arg {
             }),
             pat: P(Pat {
                 id: DUMMY_NODE_ID,
-                node: PatIdent(BindingMode::ByValue(mutability), path, None),
+                node: PatKind::Ident(BindingMode::ByValue(mutability), path, None),
                 span: span
             }),
             id: DUMMY_NODE_ID
index e22cdab97e8ed5ac119d2f8413ed049c2af673c9..5d55b6f8f88d3218e9acec6039ed77cd5321bd51 100644 (file)
@@ -69,7 +69,7 @@ pub fn ident_to_pat(id: NodeId, s: Span, i: Ident) -> P<Pat> {
     let spanned = codemap::Spanned{ span: s, node: i };
     P(Pat {
         id: id,
-        node: PatIdent(BindingMode::ByValue(Mutability::Immutable), spanned, None),
+        node: PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), spanned, None),
         span: s
     })
 }
@@ -348,7 +348,7 @@ pub fn compute_id_range_for_fn_body(fk: FnKind,
 /// and false otherwise.
 pub fn pat_is_ident(pat: P<ast::Pat>) -> bool {
     match pat.node {
-        ast::PatIdent(..) => true,
+        PatKind::Ident(..) => true,
         _ => false,
     }
 }
index 74302e2f6a0fdb7b0f32cfaa9fe5bd0ebadfccdb..c7f8a56135d298c8a1372c6054cd10661f9d1618 100644 (file)
@@ -341,7 +341,7 @@ pub fn push_trim(&mut self, mut sp: Span) {
         for idx in 0.. {
             if let Some(sp_trim) = sp.trim_start(prev) {
                 // Implies `sp.hi > prev.hi`
-                let cur = match self.spans.as_slice().get(idx) {
+                let cur = match self.spans.get(idx) {
                     Some(s) => *s,
                     None => {
                         sp = sp_trim;
index b4e86e4cfd36f717e1b86054e4849ad3cc5350bb..8fc72418eb0bc45500658c2f42806daa0680d7b8 100644 (file)
@@ -11,7 +11,7 @@
 pub use self::SyntaxExtension::*;
 
 use ast;
-use ast::Name;
+use ast::{Name, PatKind};
 use codemap;
 use codemap::{CodeMap, Span, ExpnId, ExpnInfo, NO_EXPANSION};
 use errors::DiagnosticBuilder;
@@ -307,7 +307,7 @@ fn make_pat(self: Box<Self>) -> Option<P<ast::Pat>> {
                 return Some(P(ast::Pat {
                     id: ast::DUMMY_NODE_ID,
                     span: e.span,
-                    node: ast::PatLit(e),
+                    node: PatKind::Lit(e),
                 }));
             }
         }
@@ -359,7 +359,7 @@ pub fn raw_expr(sp: Span) -> P<ast::Expr> {
     pub fn raw_pat(sp: Span) -> ast::Pat {
         ast::Pat {
             id: ast::DUMMY_NODE_ID,
-            node: ast::PatWild,
+            node: PatKind::Wild,
             span: sp,
         }
     }
index 38af8353aea843ca68c743f56baf741293b1a4ca..0eb42f17f68b41f59e054c1282308ef476a79eb4 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use abi::Abi;
-use ast::{self, Ident, Generics, Expr, BlockCheckMode, UnOp};
+use ast::{self, Ident, Generics, Expr, BlockCheckMode, UnOp, PatKind};
 use attr;
 use codemap::{Span, respan, Spanned, DUMMY_SP, Pos};
 use ext::base::ExtCtxt;
@@ -166,7 +166,7 @@ fn expr_struct_ident(&self, span: Span, id: ast::Ident,
     fn expr_err(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Expr>;
     fn expr_try(&self, span: Span, head: P<ast::Expr>) -> P<ast::Expr>;
 
-    fn pat(&self, span: Span, pat: ast::Pat_) -> P<ast::Pat>;
+    fn pat(&self, span: Span, pat: PatKind) -> P<ast::Pat>;
     fn pat_wild(&self, span: Span) -> P<ast::Pat>;
     fn pat_lit(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Pat>;
     fn pat_ident(&self, span: Span, ident: ast::Ident) -> P<ast::Pat>;
@@ -805,14 +805,14 @@ fn expr_try(&self, sp: Span, head: P<ast::Expr>) -> P<ast::Expr> {
     }
 
 
-    fn pat(&self, span: Span, pat: ast::Pat_) -> P<ast::Pat> {
+    fn pat(&self, span: Span, pat: PatKind) -> P<ast::Pat> {
         P(ast::Pat { id: ast::DUMMY_NODE_ID, node: pat, span: span })
     }
     fn pat_wild(&self, span: Span) -> P<ast::Pat> {
-        self.pat(span, ast::PatWild)
+        self.pat(span, PatKind::Wild)
     }
     fn pat_lit(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Pat> {
-        self.pat(span, ast::PatLit(expr))
+        self.pat(span, PatKind::Lit(expr))
     }
     fn pat_ident(&self, span: Span, ident: ast::Ident) -> P<ast::Pat> {
         let binding_mode = ast::BindingMode::ByValue(ast::Mutability::Immutable);
@@ -823,20 +823,24 @@ fn pat_ident_binding_mode(&self,
                               span: Span,
                               ident: ast::Ident,
                               bm: ast::BindingMode) -> P<ast::Pat> {
-        let pat = ast::PatIdent(bm, Spanned{span: span, node: ident}, None);
+        let pat = PatKind::Ident(bm, Spanned{span: span, node: ident}, None);
         self.pat(span, pat)
     }
     fn pat_enum(&self, span: Span, path: ast::Path, subpats: Vec<P<ast::Pat>>) -> P<ast::Pat> {
-        let pat = ast::PatEnum(path, Some(subpats));
+        let pat = if subpats.is_empty() {
+            PatKind::Path(path)
+        } else {
+            PatKind::TupleStruct(path, Some(subpats))
+        };
         self.pat(span, pat)
     }
     fn pat_struct(&self, span: Span,
                   path: ast::Path, field_pats: Vec<Spanned<ast::FieldPat>>) -> P<ast::Pat> {
-        let pat = ast::PatStruct(path, field_pats, false);
+        let pat = PatKind::Struct(path, field_pats, false);
         self.pat(span, pat)
     }
     fn pat_tuple(&self, span: Span, pats: Vec<P<ast::Pat>>) -> P<ast::Pat> {
-        self.pat(span, ast::PatTup(pats))
+        self.pat(span, PatKind::Tup(pats))
     }
 
     fn pat_some(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat> {
index 123a21fb8f0c00690b14eaef5b15292154c64276..e8e042c13217ab3a1c58b9ab2c2acc683ae06007 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use ast::{Block, Crate, DeclKind, PatMac};
+use ast::{Block, Crate, DeclKind, PatKind};
 use ast::{Local, Ident, Mac_, Name};
 use ast::{MacStmtStyle, Mrk, Stmt, StmtKind, ItemKind};
 use ast::TokenTree;
@@ -666,7 +666,7 @@ fn rename_in_scope<X, F>(pats: Vec<P<ast::Pat>>,
     (f(&mut rename_fld, fld, x), rewritten_pats)
 }
 
-/// A visitor that extracts the PatIdent (binding) paths
+/// A visitor that extracts the PatKind::Ident (binding) paths
 /// from a given thingy and puts them in a mutable
 /// array
 #[derive(Clone)]
@@ -677,9 +677,9 @@ struct PatIdentFinder {
 impl<'v> Visitor<'v> for PatIdentFinder {
     fn visit_pat(&mut self, pattern: &ast::Pat) {
         match *pattern {
-            ast::Pat { id: _, node: ast::PatIdent(_, ref path1, ref inner), span: _ } => {
+            ast::Pat { id: _, node: PatKind::Ident(_, ref path1, ref inner), span: _ } => {
                 self.ident_accumulator.push(path1.node);
-                // visit optional subpattern of PatIdent:
+                // visit optional subpattern of PatKind::Ident:
                 if let Some(ref subpat) = *inner {
                     self.visit_pat(subpat)
                 }
@@ -690,14 +690,14 @@ fn visit_pat(&mut self, pattern: &ast::Pat) {
     }
 }
 
-/// find the PatIdent paths in a pattern
+/// find the PatKind::Ident paths in a pattern
 fn pattern_bindings(pat: &ast::Pat) -> Vec<ast::Ident> {
     let mut name_finder = PatIdentFinder{ident_accumulator:Vec::new()};
     name_finder.visit_pat(pat);
     name_finder.ident_accumulator
 }
 
-/// find the PatIdent paths in a
+/// find the PatKind::Ident paths in a
 fn fn_decl_arg_bindings(fn_decl: &ast::FnDecl) -> Vec<ast::Ident> {
     let mut pat_idents = PatIdentFinder{ident_accumulator:Vec::new()};
     for arg in &fn_decl.inputs {
@@ -746,12 +746,12 @@ pub fn expand_block_elts(b: P<Block>, fld: &mut MacroExpander) -> P<Block> {
 
 fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {
     match p.node {
-        PatMac(_) => {}
+        PatKind::Mac(_) => {}
         _ => return noop_fold_pat(p, fld)
     }
     p.map(|ast::Pat {node, span, ..}| {
         let (pth, tts) = match node {
-            PatMac(mac) => (mac.node.path, mac.node.tts),
+            PatKind::Mac(mac) => (mac.node.path, mac.node.tts),
             _ => unreachable!()
         };
         if pth.segments.len() > 1 {
@@ -840,7 +840,7 @@ fn fold_mac(&mut self, mac: ast::Mac) -> ast::Mac {
 }
 
 /// A tree-folder that applies every rename in its list to
-/// the idents that are in PatIdent patterns. This is more narrowly
+/// the idents that are in PatKind::Ident patterns. This is more narrowly
 /// focused than IdentRenamer, and is needed for FnDecl,
 /// where we want to rename the args but not the fn name or the generics etc.
 pub struct PatIdentRenamer<'a> {
@@ -850,16 +850,16 @@ pub struct PatIdentRenamer<'a> {
 impl<'a> Folder for PatIdentRenamer<'a> {
     fn fold_pat(&mut self, pat: P<ast::Pat>) -> P<ast::Pat> {
         match pat.node {
-            ast::PatIdent(..) => {},
+            PatKind::Ident(..) => {},
             _ => return noop_fold_pat(pat, self)
         }
 
         pat.map(|ast::Pat {id, node, span}| match node {
-            ast::PatIdent(binding_mode, Spanned{span: sp, node: ident}, sub) => {
+            PatKind::Ident(binding_mode, Spanned{span: sp, node: ident}, sub) => {
                 let new_ident = Ident::new(ident.name,
                                            mtwt::apply_renames(self.renames, ident.ctxt));
                 let new_node =
-                    ast::PatIdent(binding_mode,
+                    PatKind::Ident(binding_mode,
                                   Spanned{span: self.new_span(sp), node: new_ident},
                                   sub.map(|p| self.fold_pat(p)));
                 ast::Pat {
index 5dfec8dafcf3776e10193ff07ddb1dd7f8a1b4c3..70bd85c00d453ebe74a568c8e767b4aa908c84a4 100644 (file)
@@ -27,7 +27,7 @@
 use self::AttributeGate::*;
 
 use abi::Abi;
-use ast::NodeId;
+use ast::{NodeId, PatKind};
 use ast;
 use attr;
 use attr::AttrMetaMethods;
@@ -1005,19 +1005,19 @@ fn visit_expr(&mut self, e: &ast::Expr) {
 
     fn visit_pat(&mut self, pattern: &ast::Pat) {
         match pattern.node {
-            ast::PatVec(_, Some(_), ref last) if !last.is_empty() => {
+            PatKind::Vec(_, Some(_), ref last) if !last.is_empty() => {
                 self.gate_feature("advanced_slice_patterns",
                                   pattern.span,
                                   "multiple-element slice matches anywhere \
                                    but at the end of a slice (e.g. \
                                    `[0, ..xs, 0]`) are experimental")
             }
-            ast::PatVec(..) => {
+            PatKind::Vec(..) => {
                 self.gate_feature("slice_patterns",
                                   pattern.span,
                                   "slice pattern syntax is experimental");
             }
-            ast::PatBox(..) => {
+            PatKind::Box(..) => {
                 self.gate_feature("box_patterns",
                                   pattern.span,
                                   "box pattern syntax is experimental");
index 6df313177a08cb4b37f8a9007cfd43e78601ea6b..d75e8f796ae891143d18c56ccfe6c4eb5cf0d996 100644 (file)
@@ -1119,23 +1119,26 @@ pub fn noop_fold_pat<T: Folder>(p: P<Pat>, folder: &mut T) -> P<Pat> {
     p.map(|Pat {id, node, span}| Pat {
         id: folder.new_id(id),
         node: match node {
-            PatWild => PatWild,
-            PatIdent(binding_mode, pth1, sub) => {
-                PatIdent(binding_mode,
+            PatKind::Wild => PatKind::Wild,
+            PatKind::Ident(binding_mode, pth1, sub) => {
+                PatKind::Ident(binding_mode,
                         Spanned{span: folder.new_span(pth1.span),
                                 node: folder.fold_ident(pth1.node)},
                         sub.map(|x| folder.fold_pat(x)))
             }
-            PatLit(e) => PatLit(folder.fold_expr(e)),
-            PatEnum(pth, pats) => {
-                PatEnum(folder.fold_path(pth),
+            PatKind::Lit(e) => PatKind::Lit(folder.fold_expr(e)),
+            PatKind::TupleStruct(pth, pats) => {
+                PatKind::TupleStruct(folder.fold_path(pth),
                         pats.map(|pats| pats.move_map(|x| folder.fold_pat(x))))
             }
-            PatQPath(qself, pth) => {
+            PatKind::Path(pth) => {
+                PatKind::Path(folder.fold_path(pth))
+            }
+            PatKind::QPath(qself, pth) => {
                 let qself = QSelf {ty: folder.fold_ty(qself.ty), .. qself};
-                PatQPath(qself, folder.fold_path(pth))
+                PatKind::QPath(qself, folder.fold_path(pth))
             }
-            PatStruct(pth, fields, etc) => {
+            PatKind::Struct(pth, fields, etc) => {
                 let pth = folder.fold_path(pth);
                 let fs = fields.move_map(|f| {
                     Spanned { span: folder.new_span(f.span),
@@ -1145,20 +1148,20 @@ pub fn noop_fold_pat<T: Folder>(p: P<Pat>, folder: &mut T) -> P<Pat> {
                                   is_shorthand: f.node.is_shorthand,
                               }}
                 });
-                PatStruct(pth, fs, etc)
+                PatKind::Struct(pth, fs, etc)
             }
-            PatTup(elts) => PatTup(elts.move_map(|x| folder.fold_pat(x))),
-            PatBox(inner) => PatBox(folder.fold_pat(inner)),
-            PatRegion(inner, mutbl) => PatRegion(folder.fold_pat(inner), mutbl),
-            PatRange(e1, e2) => {
-                PatRange(folder.fold_expr(e1), folder.fold_expr(e2))
+            PatKind::Tup(elts) => PatKind::Tup(elts.move_map(|x| folder.fold_pat(x))),
+            PatKind::Box(inner) => PatKind::Box(folder.fold_pat(inner)),
+            PatKind::Ref(inner, mutbl) => PatKind::Ref(folder.fold_pat(inner), mutbl),
+            PatKind::Range(e1, e2) => {
+                PatKind::Range(folder.fold_expr(e1), folder.fold_expr(e2))
             },
-            PatVec(before, slice, after) => {
-                PatVec(before.move_map(|x| folder.fold_pat(x)),
+            PatKind::Vec(before, slice, after) => {
+                PatKind::Vec(before.move_map(|x| folder.fold_pat(x)),
                        slice.map(|x| folder.fold_pat(x)),
                        after.move_map(|x| folder.fold_pat(x)))
             }
-            PatMac(mac) => PatMac(folder.fold_mac(mac))
+            PatKind::Mac(mac) => PatKind::Mac(folder.fold_mac(mac))
         },
         span: folder.new_span(span)
     })
index aaa6f79cb188adcd7769e1fdceca72dd18565639..1ec2479058cc8d22d4deb5105b2b7a6d6840a2f7 100644 (file)
@@ -675,7 +675,7 @@ mod tests {
     use super::*;
     use std::rc::Rc;
     use codemap::{Span, BytePos, Pos, Spanned, NO_EXPANSION};
-    use ast::{self, TokenTree};
+    use ast::{self, TokenTree, PatKind};
     use abi::Abi;
     use attr::{first_attr_value_str_by_name, AttrMetaMethods};
     use parse;
@@ -896,7 +896,7 @@ fn parser_done(p: Parser){
         assert!(panictry!(parser.parse_pat())
                 == P(ast::Pat{
                 id: ast::DUMMY_NODE_ID,
-                node: ast::PatIdent(ast::BindingMode::ByValue(ast::Mutability::Immutable),
+                node: PatKind::Ident(ast::BindingMode::ByValue(ast::Mutability::Immutable),
                                     Spanned{ span:sp(0, 1),
                                              node: str_to_ident("b")
                     },
@@ -931,7 +931,7 @@ fn parser_done(p: Parser){
                                     }),
                                     pat: P(ast::Pat {
                                         id: ast::DUMMY_NODE_ID,
-                                        node: ast::PatIdent(
+                                        node: PatKind::Ident(
                                             ast::BindingMode::ByValue(ast::Mutability::Immutable),
                                                 Spanned{
                                                     span: sp(6,7),
@@ -1020,7 +1020,7 @@ struct PatIdentVisitor {
         impl<'v> ::visit::Visitor<'v> for PatIdentVisitor {
             fn visit_pat(&mut self, p: &'v ast::Pat) {
                 match p.node {
-                    ast::PatIdent(_ , ref spannedident, _) => {
+                    PatKind::Ident(_ , ref spannedident, _) => {
                         self.spans.push(spannedident.span.clone());
                     }
                     _ => {
index 1e1877ec6ae0ace68d0a984b4d8885aaa1b6e23e..59e79200568a05f46144b5875a545028c96b5e52 100644 (file)
@@ -30,8 +30,7 @@
 use ast::Mac_;
 use ast::{MutTy, Mutability};
 use ast::NamedField;
-use ast::{Pat, PatBox, PatEnum, PatIdent, PatLit, PatQPath, PatMac, PatRange};
-use ast::{PatRegion, PatStruct, PatTup, PatVec, PatWild};
+use ast::{Pat, PatKind};
 use ast::{PolyTraitRef, QSelf};
 use ast::{Stmt, StmtKind};
 use ast::{VariantData, StructField};
@@ -106,6 +105,12 @@ pub enum ParsePub {
     No,
 }
 
+#[derive(Clone, Copy, PartialEq)]
+pub enum SemiColonMode {
+    Break,
+    Ignore,
+}
+
 /// Possibly accept an `token::Interpolated` expression (a pre-parsed expression
 /// dropped into the token stream, which happens while parsing the result of
 /// macro expansion). Placement of these is not as complex as I feared it would
@@ -599,7 +604,7 @@ pub fn parse_path_list_item(&mut self) -> PResult<'a, ast::PathListItem> {
 
     /// Check if the next token is `tok`, and return `true` if so.
     ///
-    /// This method is will automatically add `tok` to `expected_tokens` if `tok` is not
+    /// This method will automatically add `tok` to `expected_tokens` if `tok` is not
     /// encountered.
     pub fn check(&mut self, tok: &token::Token) -> bool {
         let is_present = self.token == *tok;
@@ -841,6 +846,15 @@ pub fn parse_seq_to_gt_or_return<T, F>(&mut self,
         return Ok((v, returned));
     }
 
+    /// Eat and discard tokens until one of `kets` is encountered. Respects token trees,
+    /// passes through any errors encountered. Used for error recovery.
+    pub fn eat_to_tokens(&mut self, kets: &[&token::Token]) {
+        self.parse_seq_to_before_tokens(kets,
+                                        seq_sep_none(),
+                                        |p| p.parse_token_tree(),
+                                        |mut e| e.cancel());
+    }
+
     /// Parse a sequence, including the closing delimiter. The function
     /// f must consume tokens until reaching the next separator or
     /// closing bracket.
@@ -851,7 +865,7 @@ pub fn parse_seq_to_end<T, F>(&mut self,
                                   -> PResult<'a, Vec<T>> where
         F: FnMut(&mut Parser<'a>) -> PResult<'a,  T>,
     {
-        let val = try!(self.parse_seq_to_before_end(ket, sep, f));
+        let val = self.parse_seq_to_before_end(ket, sep, f);
         self.bump();
         Ok(val)
     }
@@ -862,24 +876,53 @@ pub fn parse_seq_to_end<T, F>(&mut self,
     pub fn parse_seq_to_before_end<T, F>(&mut self,
                                          ket: &token::Token,
                                          sep: SeqSep,
-                                         mut f: F)
-                                         -> PResult<'a, Vec<T>> where
-        F: FnMut(&mut Parser<'a>) -> PResult<'a,  T>,
+                                         f: F)
+                                         -> Vec<T>
+        where F: FnMut(&mut Parser<'a>) -> PResult<'a,  T>,
+    {
+        self.parse_seq_to_before_tokens(&[ket], sep, f, |mut e| e.emit())
+    }
+
+    // `fe` is an error handler.
+    fn parse_seq_to_before_tokens<T, F, Fe>(&mut self,
+                                            kets: &[&token::Token],
+                                            sep: SeqSep,
+                                            mut f: F,
+                                            mut fe: Fe)
+                                            -> Vec<T>
+        where F: FnMut(&mut Parser<'a>) -> PResult<'a,  T>,
+              Fe: FnMut(DiagnosticBuilder)
     {
         let mut first: bool = true;
         let mut v = vec!();
-        while self.token != *ket {
+        while !kets.contains(&&self.token) {
             match sep.sep {
-              Some(ref t) => {
-                if first { first = false; }
-                else { try!(self.expect(t)); }
-              }
-              _ => ()
+                Some(ref t) => {
+                    if first {
+                        first = false;
+                    } else {
+                        if let Err(e) = self.expect(t) {
+                            fe(e);
+                            break;
+                        }
+                    }
+                }
+                _ => ()
+            }
+            if sep.trailing_sep_allowed && kets.iter().any(|k| self.check(k)) {
+                break;
+            }
+
+            match f(self) {
+                Ok(t) => v.push(t),
+                Err(e) => {
+                    fe(e);
+                    break;
+                }
             }
-            if sep.trailing_sep_allowed && self.check(ket) { break; }
-            v.push(try!(f(self)));
         }
-        return Ok(v);
+
+        v
     }
 
     /// Parse a sequence, including the closing delimiter. The function
@@ -894,7 +937,7 @@ pub fn parse_unspanned_seq<T, F>(&mut self,
         F: FnMut(&mut Parser<'a>) -> PResult<'a,  T>,
     {
         try!(self.expect(bra));
-        let result = try!(self.parse_seq_to_before_end(ket, sep, f));
+        let result = self.parse_seq_to_before_end(ket, sep, f);
         self.bump();
         Ok(result)
     }
@@ -930,7 +973,7 @@ pub fn parse_seq<T, F>(&mut self,
     {
         let lo = self.span.lo;
         try!(self.expect(bra));
-        let result = try!(self.parse_seq_to_before_end(ket, sep, f));
+        let result = self.parse_seq_to_before_end(ket, sep, f);
         let hi = self.span.hi;
         self.bump();
         Ok(spanned(lo, hi, result))
@@ -1217,7 +1260,25 @@ pub fn parse_trait_items(&mut self) -> PResult<'a,  Vec<TraitItem>> {
                 };
                 (ident, TraitItemKind::Const(ty, default))
             } else {
-                let (constness, unsafety, abi) = try!(p.parse_fn_front_matter());
+                let (constness, unsafety, abi) = match p.parse_fn_front_matter() {
+                    Ok(cua) => cua,
+                    Err(e) => {
+                        loop {
+                            p.bump();
+                            if p.token == token::Semi {
+                                p.bump();
+                                break;
+                            }
+
+                            if p.token == token::OpenDelim(token::DelimToken::Brace) {
+                                try!(p.parse_token_tree());
+                                break;
+                            }
+                        }
+
+                        return Err(e);
+                    }
+                };
 
                 let ident = try!(p.parse_ident());
                 let mut generics = try!(p.parse_generics());
@@ -2290,14 +2351,37 @@ fn parse_bottom_expr(&mut self) -> PResult<'a, P<Expr>> {
 
                             while self.token != token::CloseDelim(token::Brace) {
                                 if self.eat(&token::DotDot) {
-                                    base = Some(try!(self.parse_expr()));
+                                    match self.parse_expr() {
+                                        Ok(e) => {
+                                            base = Some(e);
+                                        }
+                                        Err(mut e) => {
+                                            e.emit();
+                                            self.recover_stmt();
+                                        }
+                                    }
                                     break;
                                 }
 
-                                fields.push(try!(self.parse_field()));
-                                try!(self.commit_expr(&fields.last().unwrap().expr,
-                                                 &[token::Comma],
-                                                 &[token::CloseDelim(token::Brace)]));
+                                match self.parse_field() {
+                                    Ok(f) => fields.push(f),
+                                    Err(mut e) => {
+                                        e.emit();
+                                        self.recover_stmt();
+                                        break;
+                                    }
+                                }
+
+                                match self.commit_expr(&fields.last().unwrap().expr,
+                                                       &[token::Comma],
+                                                       &[token::CloseDelim(token::Brace)]) {
+                                    Ok(()) => {}
+                                    Err(mut e) => {
+                                        e.emit();
+                                        self.recover_stmt();
+                                        break;
+                                    }
+                                }
                             }
 
                             hi = self.span.hi;
@@ -2642,45 +2726,16 @@ pub fn parse_token_tree(&mut self) -> PResult<'a, TokenTree> {
         // yet.
         maybe_whole!(deref self, NtTT);
 
-        // this is the fall-through for the 'match' below.
-        // invariants: the current token is not a left-delimiter,
-        // not an EOF, and not the desired right-delimiter (if
-        // it were, parse_seq_to_before_end would have prevented
-        // reaching this point.
-        fn parse_non_delim_tt_tok<'b>(p: &mut Parser<'b>) -> PResult<'b,  TokenTree> {
-            maybe_whole!(deref p, NtTT);
-            match p.token {
-                token::CloseDelim(_) => {
-                    let token_str = p.this_token_to_string();
-                    let mut err = p.fatal(
-                        &format!("incorrect close delimiter: `{}`", token_str));
-                    // This is a conservative error: only report the last unclosed delimiter. The
-                    // previous unclosed delimiters could actually be closed! The parser just hasn't
-                    // gotten to them yet.
-                    if let Some(&sp) = p.open_braces.last() {
-                        err.span_note(sp, "unclosed delimiter");
-                    };
-                    Err(err)
-                },
-                /* we ought to allow different depths of unquotation */
-                token::Dollar | token::SubstNt(..) if p.quote_depth > 0 => {
-                    p.parse_unquoted()
-                }
-                _ => {
-                    Ok(TokenTree::Token(p.span, p.bump_and_get()))
-                }
-            }
-        }
-
         match self.token {
             token::Eof => {
-                let open_braces = self.open_braces.clone();
                 let mut err: DiagnosticBuilder<'a> =
-                    self.fatal("this file contains an un-closed delimiter");
-                for sp in &open_braces {
+                    self.diagnostic().struct_span_err(self.span,
+                                                      "this file contains an un-closed delimiter");
+                for sp in &self.open_braces {
                     err.span_help(*sp, "did you mean to close this delimiter?");
                 }
-                return Err(err);
+
+                Err(err)
             },
             token::OpenDelim(delim) => {
                 // The span for beginning of the delimited section
@@ -2692,11 +2747,9 @@ fn parse_non_delim_tt_tok<'b>(p: &mut Parser<'b>) -> PResult<'b,  TokenTree> {
                 self.bump();
 
                 // Parse the token trees within the delimiters
-                let tts = try!(self.parse_seq_to_before_end(
-                    &token::CloseDelim(delim),
-                    seq_sep_none(),
-                    |p| p.parse_token_tree()
-                ));
+                let tts = self.parse_seq_to_before_end(&token::CloseDelim(delim),
+                                                       seq_sep_none(),
+                                                       |p| p.parse_token_tree());
 
                 // Parse the close delimiter.
                 let close_span = self.span;
@@ -2713,7 +2766,35 @@ fn parse_non_delim_tt_tok<'b>(p: &mut Parser<'b>) -> PResult<'b,  TokenTree> {
                     close_span: close_span,
                 })))
             },
-            _ => parse_non_delim_tt_tok(self),
+            _ => {
+                // invariants: the current token is not a left-delimiter,
+                // not an EOF, and not the desired right-delimiter (if
+                // it were, parse_seq_to_before_end would have prevented
+                // reaching this point.
+                maybe_whole!(deref self, NtTT);
+                match self.token {
+                    token::CloseDelim(_) => {
+                        let token_str = self.this_token_to_string();
+                        let mut err = self.diagnostic().struct_span_err(self.span,
+                            &format!("incorrect close delimiter: `{}`", token_str));
+                        // This is a conservative error: only report the last unclosed delimiter.
+                        // The previous unclosed delimiters could actually be closed! The parser
+                        // just hasn't gotten to them yet.
+                        if let Some(&sp) = self.open_braces.last() {
+                            err.span_note(sp, "unclosed delimiter");
+                        };
+
+                        Err(err)
+                    },
+                    /* we ought to allow different depths of unquotation */
+                    token::Dollar | token::SubstNt(..) if self.quote_depth > 0 => {
+                        self.parse_unquoted()
+                    }
+                    _ => {
+                        Ok(TokenTree::Token(self.span, self.bump_and_get()))
+                    }
+                }
+            }
         }
     }
 
@@ -3150,8 +3231,8 @@ pub fn parse_loop_expr(&mut self, opt_ident: Option<ast::Ident>,
     fn parse_match_expr(&mut self, attrs: ThinAttributes) -> PResult<'a, P<Expr>> {
         let match_span = self.last_span;
         let lo = self.last_span.lo;
-        let discriminant = try!(self.parse_expr_res(
-            Restrictions::RESTRICTION_NO_STRUCT_LITERAL, None));
+        let discriminant = try!(self.parse_expr_res(Restrictions::RESTRICTION_NO_STRUCT_LITERAL,
+                                                    None));
         if let Err(mut e) = self.commit_expr_expecting(&discriminant,
                                                        token::OpenDelim(token::Brace)) {
             if self.token == token::Token::Semi {
@@ -3163,7 +3244,19 @@ fn parse_match_expr(&mut self, attrs: ThinAttributes) -> PResult<'a, P<Expr>> {
             try!(self.parse_inner_attributes()).into_thin_attrs());
         let mut arms: Vec<Arm> = Vec::new();
         while self.token != token::CloseDelim(token::Brace) {
-            arms.push(try!(self.parse_arm()));
+            match self.parse_arm() {
+                Ok(arm) => arms.push(arm),
+                Err(mut e) => {
+                    // Recover by skipping to the end of the block.
+                    e.emit();
+                    self.recover_stmt();
+                    let hi = self.span.hi;
+                    if self.token == token::CloseDelim(token::Brace) {
+                        self.bump();
+                    }
+                    return Ok(self.mk_expr(lo, hi, ExprKind::Match(discriminant, arms), attrs));
+                }
+            }
         }
         let hi = self.span.hi;
         self.bump();
@@ -3292,7 +3385,7 @@ fn parse_pat_vec_elements(
                             self.check(&token::CloseDelim(token::Bracket)) {
                         slice = Some(P(ast::Pat {
                             id: ast::DUMMY_NODE_ID,
-                            node: PatWild,
+                            node: PatKind::Wild,
                             span: self.span,
                         }));
                         before_slice = false;
@@ -3370,14 +3463,14 @@ fn parse_pat_fields(&mut self) -> PResult<'a, (Vec<codemap::Spanned<ast::FieldPa
                 let fieldpath = codemap::Spanned{span:self.last_span, node:fieldname};
                 let fieldpat = P(ast::Pat{
                     id: ast::DUMMY_NODE_ID,
-                    node: PatIdent(bind_type, fieldpath, None),
+                    node: PatKind::Ident(bind_type, fieldpath, None),
                     span: mk_sp(boxed_span_lo, hi),
                 });
 
                 let subpat = if is_box {
                     P(ast::Pat{
                         id: ast::DUMMY_NODE_ID,
-                        node: PatBox(fieldpat),
+                        node: PatKind::Box(fieldpat),
                         span: mk_sp(lo, hi),
                     })
                 } else {
@@ -3429,7 +3522,7 @@ pub fn parse_pat(&mut self) -> PResult<'a, P<Pat>> {
           token::Underscore => {
             // Parse _
             self.bump();
-            pat = PatWild;
+            pat = PatKind::Wild;
           }
           token::BinOp(token::And) | token::AndAnd => {
             // Parse &pat / &mut pat
@@ -3440,21 +3533,21 @@ pub fn parse_pat(&mut self) -> PResult<'a, P<Pat>> {
             }
 
             let subpat = try!(self.parse_pat());
-            pat = PatRegion(subpat, mutbl);
+            pat = PatKind::Ref(subpat, mutbl);
           }
           token::OpenDelim(token::Paren) => {
             // Parse (pat,pat,pat,...) as tuple pattern
             self.bump();
             let fields = try!(self.parse_pat_tuple_elements());
             try!(self.expect(&token::CloseDelim(token::Paren)));
-            pat = PatTup(fields);
+            pat = PatKind::Tup(fields);
           }
           token::OpenDelim(token::Bracket) => {
             // Parse [pat,pat,...] as slice pattern
             self.bump();
             let (before, slice, after) = try!(self.parse_pat_vec_elements());
             try!(self.expect(&token::CloseDelim(token::Bracket)));
-            pat = PatVec(before, slice, after);
+            pat = PatKind::Vec(before, slice, after);
           }
           _ => {
             // At this point, token != _, &, &&, (, [
@@ -3468,7 +3561,7 @@ pub fn parse_pat(&mut self) -> PResult<'a, P<Pat>> {
             } else if self.eat_keyword(keywords::Box) {
                 // Parse box pat
                 let subpat = try!(self.parse_pat());
-                pat = PatBox(subpat);
+                pat = PatKind::Box(subpat);
             } else if self.is_path_start() {
                 // Parse pattern starting with a path
                 if self.token.is_plain_ident() && self.look_ahead(1, |t| *t != token::DotDotDot &&
@@ -3487,7 +3580,7 @@ pub fn parse_pat(&mut self) -> PResult<'a, P<Pat>> {
                         let tts = try!(self.parse_seq_to_end(&token::CloseDelim(delim),
                                 seq_sep_none(), |p| p.parse_token_tree()));
                         let mac = Mac_ { path: path, tts: tts, ctxt: EMPTY_CTXT };
-                        pat = PatMac(codemap::Spanned {node: mac,
+                        pat = PatKind::Mac(codemap::Spanned {node: mac,
                                                        span: mk_sp(lo, self.last_span.hi)});
                     } else {
                         // Parse ident @ pat
@@ -3513,7 +3606,7 @@ pub fn parse_pat(&mut self) -> PResult<'a, P<Pat>> {
                         let begin = self.mk_expr(lo, hi, ExprKind::Path(qself, path), None);
                         self.bump();
                         let end = try!(self.parse_pat_range_end());
-                        pat = PatRange(begin, end);
+                        pat = PatKind::Range(begin, end);
                       }
                       token::OpenDelim(token::Brace) => {
                          if qself.is_some() {
@@ -3521,9 +3614,13 @@ pub fn parse_pat(&mut self) -> PResult<'a, P<Pat>> {
                         }
                         // Parse struct pattern
                         self.bump();
-                        let (fields, etc) = try!(self.parse_pat_fields());
+                        let (fields, etc) = self.parse_pat_fields().unwrap_or_else(|mut e| {
+                            e.emit();
+                            self.recover_stmt();
+                            (vec![], false)
+                        });
                         self.bump();
-                        pat = PatStruct(path, fields, etc);
+                        pat = PatKind::Struct(path, fields, etc);
                       }
                       token::OpenDelim(token::Paren) => {
                         if qself.is_some() {
@@ -3535,22 +3632,22 @@ pub fn parse_pat(&mut self) -> PResult<'a, P<Pat>> {
                             self.bump();
                             self.bump();
                             try!(self.expect(&token::CloseDelim(token::Paren)));
-                            pat = PatEnum(path, None);
+                            pat = PatKind::TupleStruct(path, None);
                         } else {
                             let args = try!(self.parse_enum_variant_seq(
                                     &token::OpenDelim(token::Paren),
                                     &token::CloseDelim(token::Paren),
                                     seq_sep_trailing_allowed(token::Comma),
                                     |p| p.parse_pat()));
-                            pat = PatEnum(path, Some(args));
+                            pat = PatKind::TupleStruct(path, Some(args));
                         }
                       }
                       _ => {
                         pat = match qself {
                             // Parse qualified path
-                            Some(qself) => PatQPath(qself, path),
+                            Some(qself) => PatKind::QPath(qself, path),
                             // Parse nullary enum
-                            None => PatEnum(path, Some(vec![]))
+                            None => PatKind::Path(path)
                         };
                       }
                     }
@@ -3560,9 +3657,9 @@ pub fn parse_pat(&mut self) -> PResult<'a, P<Pat>> {
                 let begin = try!(self.parse_pat_literal_maybe_minus());
                 if self.eat(&token::DotDotDot) {
                     let end = try!(self.parse_pat_range_end());
-                    pat = PatRange(begin, end);
+                    pat = PatKind::Range(begin, end);
                 } else {
-                    pat = PatLit(begin);
+                    pat = PatKind::Lit(begin);
                 }
             }
           }
@@ -3581,7 +3678,7 @@ pub fn parse_pat(&mut self) -> PResult<'a, P<Pat>> {
     /// error message when parsing mistakes like ref foo(a,b)
     fn parse_pat_ident(&mut self,
                        binding_mode: ast::BindingMode)
-                       -> PResult<'a, ast::Pat_> {
+                       -> PResult<'a, PatKind> {
         if !self.token.is_plain_ident() {
             let span = self.span;
             let tok_str = self.this_token_to_string();
@@ -3610,7 +3707,7 @@ fn parse_pat_ident(&mut self,
                 "expected identifier, found enum pattern"))
         }
 
-        Ok(PatIdent(binding_mode, name, sub))
+        Ok(PatKind::Ident(binding_mode, name, sub))
     }
 
     /// Parse a local variable declaration
@@ -3675,10 +3772,72 @@ fn expected_item_err(&self, attrs: &[Attribute]) {
 
     /// Parse a statement. may include decl.
     pub fn parse_stmt(&mut self) -> PResult<'a, Option<Stmt>> {
-        Ok(try!(self.parse_stmt_()))
+        Ok(self.parse_stmt_())
+    }
+
+    // Eat tokens until we can be relatively sure we reached the end of the
+    // statement. This is something of a best-effort heuristic.
+    //
+    // We terminate when we find an unmatched `}` (without consuming it).
+    fn recover_stmt(&mut self) {
+        self.recover_stmt_(SemiColonMode::Ignore)
+    }
+    // If `break_on_semi` is `Break`, then we will stop consuming tokens after
+    // finding (and consuming) a `;` outside of `{}` or `[]` (note that this is
+    // approximate - it can mean we break too early due to macros, but that
+    // shoud only lead to sub-optimal recovery, not inaccurate parsing).
+    fn recover_stmt_(&mut self, break_on_semi: SemiColonMode) {
+        let mut brace_depth = 0;
+        let mut bracket_depth = 0;
+        loop {
+            match self.token {
+                token::OpenDelim(token::DelimToken::Brace) => {
+                    brace_depth += 1;
+                    self.bump();
+                }
+                token::OpenDelim(token::DelimToken::Bracket) => {
+                    bracket_depth += 1;
+                    self.bump();
+                }
+                token::CloseDelim(token::DelimToken::Brace) => {
+                    if brace_depth == 0 {
+                        return;
+                    }
+                    brace_depth -= 1;
+                    self.bump();
+                }
+                token::CloseDelim(token::DelimToken::Bracket) => {
+                    bracket_depth -= 1;
+                    if bracket_depth < 0 {
+                        bracket_depth = 0;
+                    }
+                    self.bump();
+                }
+                token::Eof => return,
+                token::Semi => {
+                    self.bump();
+                    if break_on_semi == SemiColonMode::Break &&
+                       brace_depth == 0 &&
+                       bracket_depth == 0 {
+                        return;
+                    }
+                }
+                _ => {
+                    self.bump()
+                }
+            }
+        }
+    }
+
+    fn parse_stmt_(&mut self) -> Option<Stmt> {
+        self.parse_stmt_without_recovery().unwrap_or_else(|mut e| {
+            e.emit();
+            self.recover_stmt_(SemiColonMode::Break);
+            None
+        })
     }
 
-    fn parse_stmt_(&mut self) -> PResult<'a, Option<Stmt>> {
+    fn parse_stmt_without_recovery(&mut self) -> PResult<'a, Option<Stmt>> {
         maybe_whole!(Some deref self, NtStmt);
 
         let attrs = try!(self.parse_outer_attributes());
@@ -3834,7 +3993,7 @@ fn parse_inner_attrs_and_block(&mut self) -> PResult<'a, (Vec<Attribute>, P<Bloc
         let lo = self.span.lo;
         try!(self.expect(&token::OpenDelim(token::Brace)));
         Ok((try!(self.parse_inner_attributes()),
-         try!(self.parse_block_tail(lo, BlockCheckMode::Default))))
+            try!(self.parse_block_tail(lo, BlockCheckMode::Default))))
     }
 
     /// Parse the rest of a block expression or function body
@@ -3844,7 +4003,7 @@ fn parse_block_tail(&mut self, lo: BytePos, s: BlockCheckMode) -> PResult<'a, P<
         let mut expr = None;
 
         while !self.eat(&token::CloseDelim(token::Brace)) {
-            let Spanned {node, span} = if let Some(s) = try!(self.parse_stmt_()) {
+            let Spanned {node, span} = if let Some(s) = self.parse_stmt_() {
                 s
             } else {
                 // Found only `;` or `}`.
@@ -3929,17 +4088,21 @@ fn parse_block_tail(&mut self, lo: BytePos, s: BlockCheckMode) -> PResult<'a, P<
         }))
     }
 
-    fn handle_expression_like_statement(
-            &mut self,
-            e: P<Expr>,
-            span: Span,
-            stmts: &mut Vec<Stmt>,
-            last_block_expr: &mut Option<P<Expr>>) -> PResult<'a, ()> {
+    fn handle_expression_like_statement(&mut self,
+                                        e: P<Expr>,
+                                        span: Span,
+                                        stmts: &mut Vec<Stmt>,
+                                        last_block_expr: &mut Option<P<Expr>>)
+                                        -> PResult<'a, ()> {
         // expression without semicolon
         if classify::expr_requires_semi_to_be_stmt(&e) {
             // Just check for errors and recover; do not eat semicolon yet.
-            try!(self.commit_stmt(&[],
-                             &[token::Semi, token::CloseDelim(token::Brace)]));
+            if let Err(mut e) =
+                self.commit_stmt(&[], &[token::Semi, token::CloseDelim(token::Brace)])
+            {
+                e.emit();
+                self.recover_stmt();
+            }
         }
 
         match self.token {
@@ -4172,8 +4335,8 @@ fn parse_generic_values_after_lt(&mut self) -> PResult<'a, (Vec<ast::Lifetime>,
     fn forbid_lifetime(&mut self) -> PResult<'a, ()> {
         if self.token.is_lifetime() {
             let span = self.span;
-            return Err(self.span_fatal(span, "lifetime parameters must be declared \
-                                        prior to type parameters"))
+            return Err(self.diagnostic().struct_span_err(span, "lifetime parameters must be \
+                                                                declared prior to type parameters"))
         }
         Ok(())
     }
@@ -4301,7 +4464,8 @@ pub fn parse_where_clause(&mut self) -> PResult<'a, ast::WhereClause> {
     fn parse_fn_args(&mut self, named_args: bool, allow_variadic: bool)
                      -> PResult<'a, (Vec<Arg> , bool)> {
         let sp = self.span;
-        let mut args: Vec<Option<Arg>> =
+        let mut variadic = false;
+        let args: Vec<Option<Arg>> =
             try!(self.parse_unspanned_seq(
                 &token::OpenDelim(token::Paren),
                 &token::CloseDelim(token::Paren),
@@ -4312,38 +4476,36 @@ fn parse_fn_args(&mut self, named_args: bool, allow_variadic: bool)
                         if allow_variadic {
                             if p.token != token::CloseDelim(token::Paren) {
                                 let span = p.span;
-                                return Err(p.span_fatal(span,
-                                    "`...` must be last in argument list for variadic function"))
+                                p.span_err(span,
+                                    "`...` must be last in argument list for variadic function");
                             }
                         } else {
                             let span = p.span;
-                            return Err(p.span_fatal(span,
-                                         "only foreign functions are allowed to be variadic"))
+                            p.span_err(span,
+                                       "only foreign functions are allowed to be variadic");
                         }
+                        variadic = true;
                         Ok(None)
                     } else {
-                        Ok(Some(try!(p.parse_arg_general(named_args))))
+                        match p.parse_arg_general(named_args) {
+                            Ok(arg) => Ok(Some(arg)),
+                            Err(mut e) => {
+                                e.emit();
+                                p.eat_to_tokens(&[&token::Comma, &token::CloseDelim(token::Paren)]);
+                                Ok(None)
+                            }
+                        }
                     }
                 }
             ));
 
-        let variadic = match args.pop() {
-            Some(None) => true,
-            Some(x) => {
-                // Need to put back that last arg
-                args.push(x);
-                false
-            }
-            None => false
-        };
+        let args: Vec<_> = args.into_iter().filter_map(|x| x).collect();
 
         if variadic && args.is_empty() {
             self.span_err(sp,
                           "variadic function must be declared with at least one named argument");
         }
 
-        let args = args.into_iter().map(|x| x.unwrap()).collect();
-
         Ok((args, variadic))
     }
 
@@ -4520,11 +4682,11 @@ macro_rules! parse_remaining_arguments {
                 token::Comma => {
                     self.bump();
                     let sep = seq_sep_trailing_allowed(token::Comma);
-                    let mut fn_inputs = try!(self.parse_seq_to_before_end(
+                    let mut fn_inputs = self.parse_seq_to_before_end(
                         &token::CloseDelim(token::Paren),
                         sep,
                         parse_arg_fn
-                    ));
+                    );
                     fn_inputs.insert(0, Arg::new_self(explicit_self_sp, mutbl_self, $self_id));
                     fn_inputs
                 }
@@ -4543,8 +4705,7 @@ macro_rules! parse_remaining_arguments {
         let fn_inputs = match explicit_self {
             SelfKind::Static =>  {
                 let sep = seq_sep_trailing_allowed(token::Comma);
-                try!(self.parse_seq_to_before_end(&token::CloseDelim(token::Paren),
-                                                  sep, parse_arg_fn))
+                self.parse_seq_to_before_end(&token::CloseDelim(token::Paren), sep, parse_arg_fn)
             }
             SelfKind::Value(id) => parse_remaining_arguments!(id),
             SelfKind::Region(_,_,id) => parse_remaining_arguments!(id),
@@ -4575,11 +4736,11 @@ fn parse_fn_block_decl(&mut self) -> PResult<'a, P<FnDecl>> {
             } else {
                 try!(self.expect(&token::BinOp(token::Or)));
                 try!(self.parse_obsolete_closure_kind());
-                let args = try!(self.parse_seq_to_before_end(
+                let args = self.parse_seq_to_before_end(
                     &token::BinOp(token::Or),
                     seq_sep_trailing_allowed(token::Comma),
                     |p| p.parse_fn_block_arg()
-                ));
+                );
                 self.bump();
                 args
             }
@@ -4741,8 +4902,8 @@ fn parse_impl_method(&mut self, vis: Visibility)
             // eat a matched-delimiter token tree:
             let delim = try!(self.expect_open_delim());
             let tts = try!(self.parse_seq_to_end(&token::CloseDelim(delim),
-                                            seq_sep_none(),
-                                            |p| p.parse_token_tree()));
+                                                 seq_sep_none(),
+                                                 |p| p.parse_token_tree()));
             let m_ = Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT };
             let m: ast::Mac = codemap::Spanned { node: m_,
                                                 span: mk_sp(lo,
@@ -5801,8 +5962,8 @@ fn parse_macro_use_or_failure(
             // eat a matched-delimiter token tree:
             let delim = try!(self.expect_open_delim());
             let tts = try!(self.parse_seq_to_end(&token::CloseDelim(delim),
-                                            seq_sep_none(),
-                                            |p| p.parse_token_tree()));
+                                                 seq_sep_none(),
+                                                 |p| p.parse_token_tree()));
             // single-variant-enum... :
             let m = Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT };
             let m: ast::Mac = codemap::Spanned { node: m,
index 2eb719627da50dad109bbbaeccb6f2c6263569c4..b4e08d65a0a8d7a228aeb0b39cedb1399325ed53 100644 (file)
@@ -11,7 +11,7 @@
 pub use self::AnnNode::*;
 
 use abi::{self, Abi};
-use ast::{self, TokenTree, BlockCheckMode};
+use ast::{self, TokenTree, BlockCheckMode, PatKind};
 use ast::{RegionTyParamBound, TraitTyParamBound, TraitBoundModifier};
 use ast::Attribute;
 use attr::ThinAttributesExt;
@@ -2457,8 +2457,8 @@ pub fn print_pat(&mut self, pat: &ast::Pat) -> io::Result<()> {
         /* Pat isn't normalized, but the beauty of it
          is that it doesn't matter */
         match pat.node {
-            ast::PatWild => try!(word(&mut self.s, "_")),
-            ast::PatIdent(binding_mode, ref path1, ref sub) => {
+            PatKind::Wild => try!(word(&mut self.s, "_")),
+            PatKind::Ident(binding_mode, ref path1, ref sub) => {
                 match binding_mode {
                     ast::BindingMode::ByRef(mutbl) => {
                         try!(self.word_nbsp("ref"));
@@ -2478,24 +2478,25 @@ pub fn print_pat(&mut self, pat: &ast::Pat) -> io::Result<()> {
                     None => ()
                 }
             }
-            ast::PatEnum(ref path, ref args_) => {
+            PatKind::TupleStruct(ref path, ref args_) => {
                 try!(self.print_path(path, true, 0));
                 match *args_ {
                     None => try!(word(&mut self.s, "(..)")),
                     Some(ref args) => {
-                        if !args.is_empty() {
-                            try!(self.popen());
-                            try!(self.commasep(Inconsistent, &args[..],
-                                              |s, p| s.print_pat(&p)));
-                            try!(self.pclose());
-                        }
+                        try!(self.popen());
+                        try!(self.commasep(Inconsistent, &args[..],
+                                          |s, p| s.print_pat(&p)));
+                        try!(self.pclose());
                     }
                 }
             }
-            ast::PatQPath(ref qself, ref path) => {
+            PatKind::Path(ref path) => {
+                try!(self.print_path(path, true, 0));
+            }
+            PatKind::QPath(ref qself, ref path) => {
                 try!(self.print_qpath(path, qself, false));
             }
-            ast::PatStruct(ref path, ref fields, etc) => {
+            PatKind::Struct(ref path, ref fields, etc) => {
                 try!(self.print_path(path, true, 0));
                 try!(self.nbsp());
                 try!(self.word_space("{"));
@@ -2518,7 +2519,7 @@ pub fn print_pat(&mut self, pat: &ast::Pat) -> io::Result<()> {
                 try!(space(&mut self.s));
                 try!(word(&mut self.s, "}"));
             }
-            ast::PatTup(ref elts) => {
+            PatKind::Tup(ref elts) => {
                 try!(self.popen());
                 try!(self.commasep(Inconsistent,
                                    &elts[..],
@@ -2528,32 +2529,32 @@ pub fn print_pat(&mut self, pat: &ast::Pat) -> io::Result<()> {
                 }
                 try!(self.pclose());
             }
-            ast::PatBox(ref inner) => {
+            PatKind::Box(ref inner) => {
                 try!(word(&mut self.s, "box "));
                 try!(self.print_pat(&inner));
             }
-            ast::PatRegion(ref inner, mutbl) => {
+            PatKind::Ref(ref inner, mutbl) => {
                 try!(word(&mut self.s, "&"));
                 if mutbl == ast::Mutability::Mutable {
                     try!(word(&mut self.s, "mut "));
                 }
                 try!(self.print_pat(&inner));
             }
-            ast::PatLit(ref e) => try!(self.print_expr(&e)),
-            ast::PatRange(ref begin, ref end) => {
+            PatKind::Lit(ref e) => try!(self.print_expr(&**e)),
+            PatKind::Range(ref begin, ref end) => {
                 try!(self.print_expr(&begin));
                 try!(space(&mut self.s));
                 try!(word(&mut self.s, "..."));
                 try!(self.print_expr(&end));
             }
-            ast::PatVec(ref before, ref slice, ref after) => {
+            PatKind::Vec(ref before, ref slice, ref after) => {
                 try!(word(&mut self.s, "["));
                 try!(self.commasep(Inconsistent,
                                    &before[..],
                                    |s, p| s.print_pat(&p)));
                 if let Some(ref p) = *slice {
                     if !before.is_empty() { try!(self.word_space(",")); }
-                    if p.node != ast::PatWild {
+                    if p.node != PatKind::Wild {
                         try!(self.print_pat(&p));
                     }
                     try!(word(&mut self.s, ".."));
@@ -2564,7 +2565,7 @@ pub fn print_pat(&mut self, pat: &ast::Pat) -> io::Result<()> {
                                    |s, p| s.print_pat(&p)));
                 try!(word(&mut self.s, "]"));
             }
-            ast::PatMac(ref m) => try!(self.print_mac(m, token::Paren)),
+            PatKind::Mac(ref m) => try!(self.print_mac(m, token::Paren)),
         }
         self.ann.post(self, NodePat(pat))
     }
@@ -2671,7 +2672,7 @@ pub fn print_fn_args(&mut self, decl: &ast::FnDecl,
             let m = match *explicit_self {
                 ast::SelfKind::Static => ast::Mutability::Immutable,
                 _ => match decl.inputs[0].pat.node {
-                    ast::PatIdent(ast::BindingMode::ByValue(m), _, _) => m,
+                    PatKind::Ident(ast::BindingMode::ByValue(m), _, _) => m,
                     _ => ast::Mutability::Immutable
                 }
             };
@@ -2962,7 +2963,7 @@ pub fn print_arg(&mut self, input: &ast::Arg, is_closure: bool) -> io::Result<()
             ast::TyKind::Infer if is_closure => try!(self.print_pat(&input.pat)),
             _ => {
                 match input.pat.node {
-                    ast::PatIdent(_, ref path1, _) if
+                    PatKind::Ident(_, ref path1, _) if
                         path1.node.name ==
                             parse::token::special_idents::invalid.name => {
                         // Do nothing.
index 66ac370c149f8c63e2f0b4cba1b5e7e39d41e0b4..f26610b8b8d14613ec1f237e168719f1840832e0 100644 (file)
@@ -419,46 +419,49 @@ pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(visitor: &mut V,
 
 pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
     match pattern.node {
-        PatEnum(ref path, ref opt_children) => {
+        PatKind::TupleStruct(ref path, ref opt_children) => {
             visitor.visit_path(path, pattern.id);
             if let Some(ref children) = *opt_children {
                 walk_list!(visitor, visit_pat, children);
             }
         }
-        PatQPath(ref qself, ref path) => {
+        PatKind::Path(ref path) => {
+            visitor.visit_path(path, pattern.id);
+        }
+        PatKind::QPath(ref qself, ref path) => {
             visitor.visit_ty(&qself.ty);
             visitor.visit_path(path, pattern.id)
         }
-        PatStruct(ref path, ref fields, _) => {
+        PatKind::Struct(ref path, ref fields, _) => {
             visitor.visit_path(path, pattern.id);
             for field in fields {
                 visitor.visit_ident(field.span, field.node.ident);
                 visitor.visit_pat(&field.node.pat)
             }
         }
-        PatTup(ref tuple_elements) => {
+        PatKind::Tup(ref tuple_elements) => {
             walk_list!(visitor, visit_pat, tuple_elements);
         }
-        PatBox(ref subpattern) |
-        PatRegion(ref subpattern, _) => {
+        PatKind::Box(ref subpattern) |
+        PatKind::Ref(ref subpattern, _) => {
             visitor.visit_pat(subpattern)
         }
-        PatIdent(_, ref pth1, ref optional_subpattern) => {
+        PatKind::Ident(_, ref pth1, ref optional_subpattern) => {
             visitor.visit_ident(pth1.span, pth1.node);
             walk_list!(visitor, visit_pat, optional_subpattern);
         }
-        PatLit(ref expression) => visitor.visit_expr(expression),
-        PatRange(ref lower_bound, ref upper_bound) => {
+        PatKind::Lit(ref expression) => visitor.visit_expr(expression),
+        PatKind::Range(ref lower_bound, ref upper_bound) => {
             visitor.visit_expr(lower_bound);
             visitor.visit_expr(upper_bound)
         }
-        PatWild => (),
-        PatVec(ref prepatterns, ref slice_pattern, ref postpatterns) => {
+        PatKind::Wild => (),
+        PatKind::Vec(ref prepatterns, ref slice_pattern, ref postpatterns) => {
             walk_list!(visitor, visit_pat, prepatterns);
             walk_list!(visitor, visit_pat, slice_pattern);
             walk_list!(visitor, visit_pat, postpatterns);
         }
-        PatMac(ref mac) => visitor.visit_mac(mac),
+        PatKind::Mac(ref mac) => visitor.visit_mac(mac),
     }
 }
 
index 6088fdf940ac1c689722869667ea1709c45943c6..bdba49f2f294ba3cf927dbc86c591f1ebaa695e1 100644 (file)
 use std::vec;
 
 use syntax::abi::Abi;
-use syntax::ast::{EnumDef, Expr, Ident, Generics, VariantData, BinOpKind, self};
+use syntax::ast::{self, EnumDef, Expr, Ident, Generics, VariantData, BinOpKind, PatKind};
 use syntax::ast_util;
 use syntax::attr;
 use syntax::attr::AttrMetaMethods;
@@ -1142,7 +1142,7 @@ fn build_enum_match_tuple<'b>(
                         variant,
                         self_arg_name,
                         ast::Mutability::Immutable);
-                    (cx.pat(sp, ast::PatRegion(p, ast::Mutability::Immutable)), idents)
+                    (cx.pat(sp, PatKind::Ref(p, ast::Mutability::Immutable)), idents)
                 };
 
                 // A single arm has form (&VariantK, &VariantK, ...) => BodyK
@@ -1472,7 +1472,7 @@ fn create_subpatterns(&self,
                           -> Vec<P<ast::Pat>> {
         field_paths.iter().map(|path| {
             cx.pat(path.span,
-                        ast::PatIdent(ast::BindingMode::ByRef(mutbl), (*path).clone(), None))
+                        PatKind::Ident(ast::BindingMode::ByRef(mutbl), (*path).clone(), None))
         }).collect()
     }
 
diff --git a/src/test/auxiliary/issue-26606-macro.rs b/src/test/auxiliary/issue-26606-macro.rs
new file mode 100644 (file)
index 0000000..6059a25
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2016 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.
+
+#[macro_export]
+macro_rules! make_item (
+    ($name: ident) => (pub const $name: usize = 42;)
+);
diff --git a/src/test/compile-fail/cfg-arg-invalid.rs b/src/test/compile-fail/cfg-arg-invalid.rs
new file mode 100644 (file)
index 0000000..4046303
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2016 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.
+
+// compile-flags: --cfg a{b}
+// error-pattern: invalid --cfg argument: a{b}
+fn main() {}
index 67969616ca3c93215fda25ae8670a4aad10d33a7..28e969b21498a6cce2fbaa9b4b6e19cb174de748 100644 (file)
@@ -8,12 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-mod Foo {
-    pub static X: isize = 42;
+enum Foo {
+    X
 }
 
-enum Foo {  //~ ERROR duplicate definition of type or module `Foo`
-    X
+mod Foo { //~ ERROR duplicate definition of type or module `Foo`
+    pub static X: isize = 42;
+    fn f() { f() } // Check that this does not result in a resolution error
 }
 
 fn main() {}
index 7ad43954010b9b4333e422e3cdab9c47a16ceaad..67f619b4de4f433f79f771dd6fe431cf24c2f584 100644 (file)
@@ -25,7 +25,7 @@ macro_rules! parallel {
 fn main() {
     parallel! {
         for i in 0..n {
-            x += i; //~ ERROR no rules expected the token `+=`
-        }
+            x += i; //~ ERROR expected `:`, found `+=`
+        } //~ ERROR unexpected end of macro invocation
     }
 }
index 32770d9018938b96da18a91a61abc5beeb0e8330..364a7e9cf6d75cb025ea9fc3f4691739ff95d2b2 100644 (file)
@@ -18,7 +18,7 @@ fn bar() {}
 
 macro_rules! ignored_expr {
     () => ( 1,  //~ ERROR unexpected token: `,`
-            2 ) //~ ERROR macro expansion ignores token `2`
+            2 )
 }
 
 macro_rules! ignored_pat {
@@ -28,7 +28,7 @@ macro_rules! ignored_pat {
 ignored_item!(); //~ NOTE caused by the macro expansion here
 
 fn main() {
-    ignored_expr!(); //~ NOTE caused by the macro expansion here
+    ignored_expr!();
     match 1 {
         ignored_pat!() => (), //~ NOTE caused by the macro expansion here
         _ => (),
index 5d3efd85134ad6e5e899a91816ea751cff84e62f..75882c5e9812911d0338cc1e2c7f5d3feaecb027 100644 (file)
@@ -14,7 +14,7 @@
 extern crate core;
 
 mod T {
-    use super::*;
+    pub use super::*;
 }
 
 fn main() {
diff --git a/src/test/compile-fail/parser-recovery-1.rs b/src/test/compile-fail/parser-recovery-1.rs
new file mode 100644 (file)
index 0000000..674418d
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2016 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 we can recover from missing braces in the parser.
+
+trait Foo {
+    fn bar() {
+        let x = foo(); //~ ERROR unresolved name `foo`
+
+}
+
+fn main() {
+    let x = y.;  //~ ERROR unexpected token
+                 //~^ ERROR unresolved name `y`
+} //~ ERROR this file contains an un-closed delimiter
diff --git a/src/test/compile-fail/parser-recovery-2.rs b/src/test/compile-fail/parser-recovery-2.rs
new file mode 100644 (file)
index 0000000..f1eb696
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2016 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 we can recover from mismatched braces in the parser.
+
+trait Foo {
+    fn bar() {
+        let x = foo(); //~ ERROR unresolved name `foo`
+    ) //~ ERROR incorrect close delimiter: `)`
+}
+
+fn main() {
+    let x = y.;  //~ ERROR unexpected token
+                 //~^ ERROR unresolved name `y`
+}
index 66f462df05ac9d05b04d0ad9f288448efa7c4eb3..ff434d87e1fb2c141955f5f363ad7d4837a56974 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// compile-flags: -Z parse-only
+
 fn foo() {
     match x {
         <T as Trait>::Type{key: value} => (),
index f57abf8929e83647f3037c35d749363947ada5e3..41a3b06e6556e9bd1d8ba065256f345de9b1cf90 100644 (file)
@@ -8,8 +8,14 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// FIXME(31528) we emit a bunch of silly errors here due to continuing past the
+// first one. This would be easy-ish to address by better recovery in tokenisation.
+
 // compile-flags: -Z parse-only
 
-pub fn trace_option(option: Option<isize>) {
+pub fn trace_option(option: Option<isize>) { //~ HELP did you mean to close this delimiter?
     option.map(|some| 42; //~ NOTE: unclosed delimiter
+                          //~^ ERROR: expected one of
 } //~ ERROR: incorrect close delimiter
+//~^ ERROR: expected one of
+//~ ERROR: this file contains an un-closed delimiter
index f0d1feffec80bbe57568f53000e64adde3120d2f..7c30b5f26296ba0ef0583de657fc0b95742f08f4 100644 (file)
@@ -12,3 +12,4 @@
 
 fn bar<'a, T>(x: mymodule::X<'a, T, 'b, 'c>) {}
 //~^ ERROR lifetime parameters must be declared prior to type parameters
+//~^^ ERROR unexpected token
index 0b380d6ae8847f010439126ab47eb733cd7474a1..2e799a72c81af7b6b1a3bba5c65a8149cb7b48e6 100644 (file)
@@ -12,8 +12,8 @@
 
 fn foo() { //~ HELP did you mean to close this delimiter?
   match Some(x) {
-      Some(y) { panic!(); }
-      None    { panic!(); }
+      Some(y) => { panic!(); }
+      None => { panic!(); }
 }
 
 fn bar() {
index e85fb3c9dd53d9c655e419246304696911fc3386..b99d0493ff7333b2f402829193a766a3ecc1f382 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// compile-flags: -Z parse-only
+
 fn main() {
     let foo =
         match //~ NOTE did you mean to remove this `match` keyword?
index d06fd2bb4e704846f4344df39a6b61c40439774f..d3aa4b72b78a55190c1fdadb9e6d982c217a7709 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// compile-flags: -Z parse-only
+
 fn foo() {
     match x {
         <T as Trait>::Type(2) => (),
index 3d9b492307a7cd7493b66e6dbfab58b5e5ecd652..a163b38b49270ac25f18c67d055074e39689c038 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// compile-flags: -Z parse-only
+
 enum BtNode {
     Node(u32,Box<BtNode>,Box<BtNode>),
     Leaf(u32),
index 72fdae82260eafed8485fa05c69f8b347836dda6..bc27aedb627ee5fe7c784b6b7c920df0bb88e0f5 100644 (file)
@@ -10,4 +10,5 @@
 
 fn main() {
     let Test(&desc[..]) = x; //~ error: expected one of `,` or `@`, found `[`
+    //~^ ERROR expected one of `:`, `;`, or `=`, found `..`
 }
index c7731d156ad626fd345cb2ba5895e373f848e0de..3e9478da44de596853501b9c5a90cceec4c5efe9 100644 (file)
@@ -9,5 +9,6 @@
 // except according to those terms.
 
 fn main() {
-    for thing(x[]) {} //~ error: expected one of `,` or `@`, found `[`
+    for thing(x[]) in foo {} //~ error: expected one of `,` or `@`, found `[`
+    //~^ ERROR: expected `in`, found `]`
 }
index 107b836d160a5669bbb47bed4b4090795e923205..e57298f72804af423ba7a55a3c6e5e9d91529934 100644 (file)
@@ -23,7 +23,7 @@ fn hi(&self) -> bool {
 fn main() {
     for x in Foo {
         x: 3    //~ ERROR expected type, found `3`
-    }.hi() {
+    }.hi() { //~ ERROR expected one of `.`, `;`, `}`, or an operator, found `{`
         println!("yo");
     }
 }
index b1cccc51d7bb9acc70bb389e09a4a83047d0c277..6bf41b7a450aff70a1c6492c4ce331b7c82e3b5d 100644 (file)
@@ -23,7 +23,7 @@ fn hi(&self) -> bool {
 fn main() {
     if Foo {
         x: 3    //~ ERROR expected type, found `3`
-    }.hi() {
+    }.hi() { //~ ERROR expected one of `.`, `;`, `}`, or an operator, found `{`
         println!("yo");
     }
 }
index 42b3e75bcf6d1a4f92c20769f7e64c473577367e..679f4542824fbd0ff4155e7429add1bd28daac80 100644 (file)
@@ -20,6 +20,6 @@ fn main() {
     } {
         Foo {
             x: x
-        } => {}
+        } => {} //~ ERROR expected one of `.`, `;`, `}`, or an operator, found `=>`
     }
 }
index 1c52dc48ccd1ac125f4271f00b7810006f806e47..b388aac2c54875400a3ea4b0e35c770ec43c2fd5 100644 (file)
@@ -23,7 +23,7 @@ fn hi(&self) -> bool {
 fn main() {
     while Foo {
         x: 3    //~ ERROR expected type, found `3`
-    }.hi() {
+    }.hi() { //~ ERROR expected one of `.`, `;`, `}`, or an operator, found `{`
         println!("yo");
     }
 }
diff --git a/src/test/parse-fail/variadic-ffi-1.rs b/src/test/parse-fail/variadic-ffi-1.rs
deleted file mode 100644 (file)
index 63a36e9..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2013 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.
-
-// compile-flags: -Z parse-only
-
-extern {
-    fn printf(...); //~ ERROR: variadic function must be declared with at least one named argument
-    fn printf(..., foo: isize); //~ ERROR: `...` must be last in argument list for variadic function
-}
-
-fn main() {}
index c1f9065e9d2d621d37bbf8574f0b7725da3ec218..9543fad8e533b55649e17c1c0158ec69e1199680 100644 (file)
@@ -25,7 +25,7 @@ all:
 
        # Should not link dead code...
        $(RUSTC) -Z print-link-args dummy.rs 2>&1 | \
-               grep -e '--gc-sections\|-dead_strip\|/OPT:REF,ICF'
+               grep -e '--gc-sections' -e '-dead_strip' -e '/OPT:REF,ICF'
        # ... unless you specifically ask to keep it
        $(RUSTC) -Z print-link-args -C link-dead-code dummy.rs 2>&1 | \
-               (! grep -e '--gc-sections\|-dead_strip\|/OPT:REF,ICF')
+               (! grep -e '--gc-sections' -e '-dead_strip' -e '/OPT:REF,ICF')
diff --git a/src/test/run-make/llvm-module-pass/Makefile b/src/test/run-make/llvm-module-pass/Makefile
new file mode 100644 (file)
index 0000000..93c7c4f
--- /dev/null
@@ -0,0 +1,14 @@
+-include ../tools.mk
+
+# Windows doesn't correctly handle include statements with escaping paths,
+# so this test will not get run on Windows.
+ifdef IS_WINDOWS
+all:
+else
+all: $(call NATIVE_STATICLIB,llvm-pass)
+       $(RUSTC) plugin.rs -C prefer-dynamic
+       $(RUSTC) main.rs
+
+$(TMPDIR)/libllvm-pass.o:
+       $(CXX) $(CFLAGS) $(LLVM_CXXFLAGS) -c llvm-pass.so.cc -o $(TMPDIR)/libllvm-pass.o
+endif
diff --git a/src/test/run-make/llvm-module-pass/llvm-pass.so.cc b/src/test/run-make/llvm-module-pass/llvm-pass.so.cc
new file mode 100644 (file)
index 0000000..06b0d6c
--- /dev/null
@@ -0,0 +1,55 @@
+// Copyright 2016 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.
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "llvm/IR/Module.h"
+
+using namespace llvm;
+
+namespace {
+
+  class TestLLVMPass : public ModulePass {
+
+  public:
+
+    static char ID;
+    TestLLVMPass() : ModulePass(ID) { }
+
+    bool runOnModule(Module &M) override;
+
+    const char *getPassName() const override {
+      return "Some LLVM pass";
+    }
+
+  };
+
+}
+
+bool TestLLVMPass::runOnModule(Module &M) {
+  // A couple examples of operations that previously caused segmentation faults
+  // https://github.com/rust-lang/rust/issues/31067
+
+  for (auto F = M.begin(); F != M.end(); ++F) {
+    /* code */
+  }
+
+  LLVMContext &C = M.getContext();
+  IntegerType *Int8Ty  = IntegerType::getInt8Ty(C);
+  PointerType::get(Int8Ty, 0);
+  return true;
+}
+
+char TestLLVMPass::ID = 0;
+
+static RegisterPass<TestLLVMPass> RegisterAFLPass(
+  "some-llvm-pass", "Some LLVM pass");
diff --git a/src/test/run-make/llvm-module-pass/main.rs b/src/test/run-make/llvm-module-pass/main.rs
new file mode 100644 (file)
index 0000000..5b5ab94
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2016 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(plugin)]
+#![plugin(some_plugin)]
+
+fn main() {}
diff --git a/src/test/run-make/llvm-module-pass/plugin.rs b/src/test/run-make/llvm-module-pass/plugin.rs
new file mode 100644 (file)
index 0000000..039de3c
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright 2016 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(plugin_registrar, rustc_private)]
+#![crate_type = "dylib"]
+#![crate_name = "some_plugin"]
+
+extern crate rustc;
+extern crate rustc_plugin;
+
+#[link(name = "llvm-pass", kind = "static")]
+extern {}
+
+use rustc_plugin::registry::Registry;
+
+#[plugin_registrar]
+pub fn plugin_registrar(reg: &mut Registry) {
+    reg.register_llvm_pass("some-llvm-pass");
+}
diff --git a/src/test/run-make/lto-no-link-whole-rlib/Makefile b/src/test/run-make/lto-no-link-whole-rlib/Makefile
new file mode 100644 (file)
index 0000000..1d45cb4
--- /dev/null
@@ -0,0 +1,18 @@
+# Copyright 2016 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.
+
+-include ../tools.mk
+
+all: $(call NATIVE_STATICLIB,foo) $(call NATIVE_STATICLIB,bar)
+       $(RUSTC) lib1.rs
+       $(RUSTC) lib2.rs
+       $(RUSTC) main.rs -Clto
+       $(call RUN,main)
+
diff --git a/src/test/run-make/lto-no-link-whole-rlib/bar.c b/src/test/run-make/lto-no-link-whole-rlib/bar.c
new file mode 100644 (file)
index 0000000..716d1ab
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2016 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.
+
+int foo() {
+  return 2;
+}
diff --git a/src/test/run-make/lto-no-link-whole-rlib/foo.c b/src/test/run-make/lto-no-link-whole-rlib/foo.c
new file mode 100644 (file)
index 0000000..1b36874
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2016 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.
+
+int foo() {
+  return 1;
+}
diff --git a/src/test/run-make/lto-no-link-whole-rlib/lib1.rs b/src/test/run-make/lto-no-link-whole-rlib/lib1.rs
new file mode 100644 (file)
index 0000000..0a87c8e
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright 2016 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 = "rlib"]
+
+#[link(name = "foo", kind = "static")]
+extern {
+    fn foo() -> i32;
+}
+
+pub fn foo1() -> i32 {
+    unsafe { foo() }
+}
diff --git a/src/test/run-make/lto-no-link-whole-rlib/lib2.rs b/src/test/run-make/lto-no-link-whole-rlib/lib2.rs
new file mode 100644 (file)
index 0000000..6e3f382
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2016 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 = "rlib"]
+
+extern crate lib1;
+
+#[link(name = "bar", kind = "static")]
+extern {
+    fn foo() -> i32;
+}
+
+pub fn foo2() -> i32 {
+    unsafe { foo() }
+}
+
diff --git a/src/test/run-make/lto-no-link-whole-rlib/main.rs b/src/test/run-make/lto-no-link-whole-rlib/main.rs
new file mode 100644 (file)
index 0000000..8417af6
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright 2016 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 lib1;
+extern crate lib2;
+
+fn main() {
+    assert_eq!(lib1::foo1(), 2);
+    assert_eq!(lib2::foo2(), 2);
+}
index aa1ef2025a015a8894e4508fba5a509b073aa01d..ebc9f801931195c392e7c0273d1e72ad4e07f1aa 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 use std::{env, fmt, process, sync, thread};
 
 struct SlowFmt(u32);
index e889d74c7ccc4e85be6317f0087bc3bf66e34c69..a63a232e1b5be8e09ee2cbf1434554662d2f89d8 100644 (file)
@@ -11,6 +11,8 @@
 // Test that we cleanup a fixed size Box<[D; k]> properly when D has a
 // destructor.
 
+// ignore-emscripten no threads support
+
 #![feature(const_fn)]
 
 use std::thread;
index f108ef4f5d22de94deefff812dc0ceca310bb88c..ca17942917281329f9fa745760e845f3749a3f3a 100644 (file)
@@ -11,6 +11,8 @@
 // Test that we cleanup dynamic sized Box<[D]> properly when D has a
 // destructor.
 
+// ignore-emscripten no threads support
+
 #![feature(const_fn)]
 
 use std::thread;
index 80b75af6e441e915cf36f77aefcd62c4f2af8e32..5019455c2a7f0a51ae63edc9975d07eaa1ad05ac 100644 (file)
@@ -14,6 +14,7 @@
 // that use capture clauses.
 
 // pretty-expanded FIXME #23616
+// ignore-emscripten no threads support
 
 extern crate cci_capture_clause;
 
index 7da1416602f6daec46d6961d456da65febc39cc8..e45f7c2bba66860ad255c82ebb8e591bb38c97b9 100644 (file)
@@ -11,6 +11,7 @@
 // Reported as issue #126, child leaks the string.
 
 // pretty-expanded FIXME #23616
+// ignore-emscripten no threads support
 
 #![feature(std_misc)]
 
index 344ea63c7c74da6d474372fc8320b667e1a4e659..25d3eb3bbe28c4d80d632fc93805efc6484eefd8 100644 (file)
@@ -24,6 +24,7 @@
 // It's unclear how likely such a bug is to recur, but it seems like a
 // scenario worth testing.
 
+// ignore-emscripten no threads support
 
 #![allow(unknown_features)]
 #![feature(box_syntax)]
index 5a7b1c83dfda3acca3a9e410b34cac239b9efe09..384fb92954de2fcca1ba8db6f22d9f3f3b085b1e 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
 
 #![allow(unknown_features)]
 #![feature(box_syntax, std_misc)]
index ee4ec24b7e3dad97370ca4831ad9d57806656861..f846ee8f3d0b924035886db8f93ecda1c4464404 100644 (file)
@@ -44,6 +44,13 @@ pub fn main() {
     let _: &Debug = &if true { false } else { true };
     let _: &Debug = &match true { true => 'a', false => 'b' };
 
+    let _: &str = &{ String::new() };
+    let _: &str = &if true { String::from("...") } else { 5.to_string() };
+    let _: &str = &match true {
+        true => format!("{}", false),
+        false => ["x", "y"].join("+")
+    };
+
     let _: Box<[isize]> = Box::new([1, 2, 3]);
     let _: Box<Fn(isize) -> _> = Box::new(|x| (x as u8));
 
index 72f623ccfde7aaa30a0e207a8c5834acaec7ff7e..d7cb8bc991ada836f3497cd5d6984578cdae311b 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 #![feature(std_misc)]
 
 use std::thread;
index d6b6d673ca5433f223b03430debd5f5cf885a2e9..ffcc1891c579e22357bb0fd210dff143caa6cd67 100644 (file)
@@ -10,6 +10,7 @@
 
 // ignore-pretty
 // compile-flags:--test
+// ignore-emscripten
 
 // NB: These tests kill child processes. Valgrind sees these children as leaking
 // memory, which makes for some *confusing* logs. That's why these are here
index 4a6c8ce70dcee16d2dc711b8d836c055904369d3..07a10c8d45443892151490ea3b7e50d315ac427b 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // compile-flags: -Z force-dropflag-checks=off
+// ignore-emscripten no threads support
 
 // Quick-and-dirty test to ensure -Z force-dropflag-checks=off works as
 // expected. Note that the inlined drop-flag is slated for removal
index 252086ad014da6d65a485fc9d54e11a6e1632d39..1a0191b70530a5af0661aa79b6726dbd56a91245 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 #![feature(libc)]
 
 extern crate libc;
index 9a39b1773e533e58f48bd3839755e04d92e79c8a..1beb6d3519aeeb4c5bb9b46ddfe4487804eae949 100644 (file)
@@ -12,6 +12,8 @@
 // make sure the stack pointers are maintained properly in both
 // directions
 
+// ignore-emscripten no threads support
+
 #![feature(libc, std_misc)]
 
 extern crate libc;
index 3c7d2861c877e317d4e2918e9381311b4f7e9e8e..c2916ccd75b8e4a58e8d926714b02b35b608c60f 100644 (file)
@@ -10,6 +10,7 @@
 
 // ignore-windows
 // ignore-android
+// ignore-emscripten
 
 #![feature(libc)]
 
index f4792c212165de330540a7ee4f657189a53b787c..ca118899798b864a82200d54db37d493a7e52996 100644 (file)
@@ -9,6 +9,8 @@
 // except according to those terms.
 
 // ignore-aarch64
+// ignore-emscripten no threads support
+
 #![feature(libc)]
 
 extern crate libc;
index dafa8ee10339ee706c810153987fe7787bbc35a3..2ff024a693aae4f4f0d609045a0200b78d86a21d 100644 (file)
@@ -13,6 +13,7 @@
 // optimisation.
 
 // pretty-expanded FIXME #23616
+// ignore-emscripten no threads support
 
 #![feature(intrinsics, std_misc)]
 
index 3f50a7d6c02983da66145b3ab26c230c44013ce0..e17e3a16d6834ab1afabac378094e08679499eaa 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // compile-flags: -Z force-overflow-checks=on
+// ignore-emscripten no threads support
 
 use std::thread;
 
index 9fd4f2133b70d36287f9b7cd02010fbb2ad0beca..8f22579423fd5a68e190fc44b2916b3dedff3677 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 // This test is checking that the move_val_init intrinsic is
 // respecting cleanups for both of its argument expressions.
 //
index e94368925abee2b261c0d6d0ac9cc104e59cb54b..316190b54eb08e989755e627b282368133f4e920 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 // This test may not always fail, but it can be flaky if the race it used to
 // expose is still present.
 
index a9f7d86f95ee6148d22417004dabdd06de850a36..596f0d20155df88801e1dcaaf850abc6f1df95dc 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
 
 #![feature(unboxed_closures)]
 
index 1ebe3a7f068acc7184c3e334e70876dc919dcaf8..2be04551cb92f82244a8fe1c16f2d730d6e65ab7 100644 (file)
@@ -11,6 +11,8 @@
 // DON'T REENABLE THIS UNLESS YOU'VE ACTUALLY FIXED THE UNDERLYING ISSUE
 // ignore-android seems to block forever
 
+// ignore-emscripten no threads support
+
 #![forbid(warnings)]
 
 // Pretty printing tests complain about `use std::predule::*`
index ec095d4895ff40e20ffe89596ab5ced6a55b79f1..6b45a4d0a520723e2a01e41f24c2aad3b47df580 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 // Regression test for unwrapping the result of `join`, issue #21291
 
 use std::thread;
index da78578329b73200768026101e407015b27c1f40..f9360af011bc9cbf2ff6256b8b73e642aab29bb7 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 pub fn main() {
     let f = || || 0;
     std::thread::spawn(f());
index b619d1dd4488c015e165cf1340a71b400cc76a88..e707023530be89d0a0492665f9ad3d7f22ba1f81 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 use std::thread;
 
 struct Foo(i32);
index bdd3a80d74cf4a4da7409d6f7fb5e15df398956e..402460e7253d31b8c5b5f057792bbce232d67c58 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 #![feature(const_fn)]
 
 // Check that the destructors of simple enums are run on unwinding
index eee0f663df24cff775714da4f0e4160d0492da2d..17a6e9bd6b2e7afefbc051446490ac1bfbb490ef 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 use std::thread;
 
 struct Foo;
index da4d5f19d4a2e9b585f825c93d539602e531fd6f..e39ffb87425dc91c957736e991323720348c371b 100644 (file)
@@ -13,6 +13,8 @@
 // spawned thread to isolate the expected error result from the
 // SIGTRAP injected by the drop-flag consistency checking.
 
+// ignore-emscripten no threads support
+
 struct Foo;
 
 impl Drop for Foo {
index 9292a9c608eb9fbd028b0008548a07780f09f0e2..5eec800d5884608b294e66f8f75b940137704169 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 use std::sync::mpsc::channel;
 use std::thread;
 
index eb411ff4417784643f1395073e17f0716d312efc..6f0356b5bfbc8c0193042c3c7dfeada826189267 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
 
 use std::sync::mpsc::channel;
 use std::thread;
index 4ebc43163ede894d451b8a85d612a218ff334271..8ec9f8aff8ec72da5143d30a96941768db3ed82c 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 #![feature(zero_one)]
 
 use std::num::Zero;
index 280311af6fbd12ea94121129cc608f6f9a8f12f2..6e01131cfcaa41562f0789af8f3161bd08bdc679 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 #![feature(std_misc)]
 
 use std::thread;
index ed67630bcac44540024f6834e9065d65799855a2..5af2006f08146c42cb5d49214c82df56af68922b 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 use std::sync::mpsc::{TryRecvError, channel};
 use std::thread;
 
index 3f0daf2610ce970704f31a2fa685b3a23b8fda7d..e7498f7c1741dbff45d0720d948e3351151edb30 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // pretty-expanded FIXME #23616
+// ignore-emscripten no threads support
 
 #![feature(std_misc)]
 
index 1b1cdcb1102a2d3015e772388af3e32799254e92..11ab43fd08763d16a738d6fc27b91e5d6ed3bbf0 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // ignore-windows
+// ignore-emscripten no threads support
 // exec-env:RUST_LOG=debug
 
 use std::cell::Cell;
index 326d1cafe6c782fe47ba3a2bf62af3516dd01c2f..c3fad3a19f92792d459af15ba54cc7122a2c7872 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 use std::thread;
 
 macro_rules! expr { ($e: expr) => { $e } }
index c7ef9776367bd10d410d56e80f68dd398b428557..d3c028070fd143cfd97a1ee515c44df5ef42df62 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 #![feature(std_misc)]
 
 use std::thread;
index 89ac626158392f73f33da2da2c93039add3d0f0b..458b6c16e62a776a8234c77013accf9a13a34c0f 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 // Test that using the `vec!` macro nested within itself works when
 // the contents implement Drop and we hit a panic in the middle of
 // construction.
index d90e7ef5e473d8ee1139d39d6209a47ff29775c9..8445bccf134934985471d9605197e32b03fb6f44 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 // compile-flags: -Z no-landing-pads
-
+// ignore-emscripten no threads support
 
 use std::thread;
 
index 783a44beaf36a0b256a3d4b8a130fe8c300db549..39ea987f71ba4b0f93914b94ca60036c50f4277e 100644 (file)
@@ -9,6 +9,8 @@
 // except according to those terms.
 #![feature(panic_handler, std_panic)]
 
+// ignore-emscripten no threads support
+
 use std::panic;
 use std::thread;
 
index edf65e8e2aa699f373116e7d20bf5ef095df782e..ed9a02c1d3eccdde8c9a0b64333fa0c32ea15aeb 100644 (file)
@@ -9,6 +9,8 @@
 // except according to those terms.
 #![feature(panic_handler, const_fn, std_panic)]
 
+// ignore-emscripten no threads support
+
 use std::sync::atomic::{AtomicUsize, Ordering};
 use std::panic;
 use std::thread;
index f84a823d3db22e290310aa24b1d27857e603ceb5..c5f92fbd55aadc851bbbdd3bef0c628dcc7d5b43 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
 
 use std::thread;
 
index c0b2f25d99c07aa9c20e48a368a9299739e9ae91..d420ef99863c29c750485180fc1c9103a699a9fa 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 #![feature(std_panic, recover, panic_propagate, panic_handler, const_fn)]
 
 use std::sync::atomic::{AtomicUsize, Ordering};
index 5bff4fa080a34d2aa4f2220807342ea06b6edf91..ebc7f134610457835220282f58a96881d523d729 100644 (file)
@@ -18,6 +18,8 @@
 // (instead of running forever), and that it does not print an error
 // message about a broken pipe.
 
+// ignore-emscripten no threads support
+
 use std::process;
 use std::thread;
 
index 59179206104f8421cf8229d053dcccac638dcd29..306d24e317754208d55c9cd4ee49dedd8c898b9b 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 // exec-env:RUST_LOG=rust_log_filter/foo
-
+// ignore-emscripten no threads support
 
 #![allow(unknown_features)]
 #![feature(box_syntax, std_misc, rustc_private)]
index 66878d98c840cf5088112c79cb33c96aabb0f041..7dd1c3c597876b2b1cce90441ccbe5e9884e1c50 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // pretty-expanded FIXME #23616
+// ignore-emscripten no threads support
 
 #![feature(std_misc)]
 
index 63ffa552405bea33680bcc7195ce5f5367217ff8..fb5877b8a48987af81eadb78e6925ae37f231705 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 #![allow(unknown_features)]
 #![feature(box_syntax)]
 
index 766e2b6b7228f0f37b946bd39008a5b2f1cb3616..96e9c1ed2ccf9ead559a295f7eacd18fa9ac4aba 100644 (file)
@@ -10,6 +10,7 @@
 
 // ignore-bitrig
 // compile-flags: -C codegen-units=3
+// ignore-emscripten no threads support
 
 // Test unwinding through multiple compilation units.
 
index ed949fe082877ae50c9d388d5ccff252227c85f0..afec06adc864fd271208810bcbe3cfcaad936537 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 // Test that if a slicing expr[..] fails, the correct cleanups happen.
 
 
index 4103c9495e102ca063b894a5713ec531968c0ed8..2932b585b8805b34e8bfe74b74921ed3bb30485d 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 // Test that if a slicing expr[..] fails, the correct cleanups happen.
 
 
index 4a35ed609e0801c793997c53785cc46d39e63549..751d833ff9c8baec05c86ecc5c2e468e45f94e11 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 use std::thread;
 
 fn x(s: String, n: isize) {
index ae4fabd34d6299536a9ac6a854959b0fb40e8883..cab190d025f8b648ede2c35737e991f9f8058aa0 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
 
 /*
   Make sure we can spawn tasks that take different types of
index 00be41a27d2c2727fa9e0c3880d3ebb2e5cc5740..c9a030cf053c735d599f3caa21cd8c201975e956 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 use std::thread;
 
 pub fn main() {
index 93dc3faaa205dfb47e72ef6fe27f10a75e7b7d94..2a5fab8a209273268ea55314858055aa8787819e 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 use std::thread;
 
 pub fn main() {
index 858b7a83c6274f475f484666c2f6e36bed5be558..c09ddf5296661300b7b545add98a4dd947e00d14 100644 (file)
@@ -10,6 +10,7 @@
 
 // ignore-windows
 // exec-env:RUST_LOG=debug
+// ignore-emscripten no threads support
 
 // regression test for issue #10405, make sure we don't call println! too soon.
 
index 1409caf9c702db352b046f27e46c8419571c9941..0ac232e2e12b3fab3ae14a53ff13b1f9e58c2b5d 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 #![feature(std_misc)]
 
 use std::thread;
index b3327d82c3ebe8b05707b35cef118278f52479b4..9a43780f08f0100f66e87263a3f1d054b51816af 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 #![feature(std_misc)]
 
 use std::thread;
index ced240502ed8b9fff17d2ab0d6f7a8d3a8d59f19..13b40f17292fbbe45f815ef0681a9d4789aa4cc0 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 #![feature(std_misc)]
 
 use std::thread;
index 7af8f5d3b35759b109760146dadec7000bf09828..be846795962da9b3904c5fe5db1987163e0f7522 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // pretty-expanded FIXME #23616
+// ignore-emscripten no threads support
 
 #![feature(std_misc)]
 
index a3dfa361cecd6268cda9c0cbf5760bd4f7383acc..fdf02e65d8eb3910fc7ec5149cfa96ec21f573e8 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 #![feature(std_misc)]
 
 use std::thread;
index 156ddd9c77fc339d817b749a9e13b5bef09d9c31..46c5d3a7ce32baaefb9719fcbc4b3af85059128a 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 #![feature(std_misc)]
 
 use std::sync::mpsc::{channel, Sender};
index 90f68deb303e847d34ca6f9bb4afe8ad7528c155..e75a6cf0c87097f19e8f296c856110f117f650dc 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 #![feature(std_misc)]
 
 use std::sync::mpsc::{channel, Sender};
index 2994b9c53849093260a53399ac49d83cc3909461..f2ff48ebd95a93ff12258e00884275fc50d9b7e6 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
 // pretty-expanded FIXME #23616
 
 #![feature(std_misc)]
index 8f6f971ce35c817dd4a06a2a3a2ca4a9592da68a..fe00f1aba363bcabf1cbe6a1696a083c091c9388 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
 // pretty-expanded FIXME #23616
 
 #![feature(std_misc)]
index 890107998ccb75f44b53aff4332bf59a3ed8468f..0e8542bababdda6190fbe4d495cbd88cae4f0801 100644 (file)
@@ -10,6 +10,7 @@
 
 #![feature(std_misc)]
 
+// ignore-emscripten no threads support
 // no-pretty-expanded FIXME #15189
 
 use std::thread;
index e37160f979c268849d3756587f6703012fd00c60..7b2b9fde9ee4aebe45afb509b727b094b65ab67a 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
 
 #![feature(std_misc)]
 #![allow(dead_assignment)]
index d8eec4169e3531c0f749a827b39ffc64256ec97a..75fd1826b585320aee31a1ac8b38126df4d915a4 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 #![feature(std_misc)]
 
 use std::thread;
index ba8819fd0b0fee8e236977c8ac70b97672a3c15d..312a9f499250112a1ed39284a60bdf13cc321194 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
 // pretty-expanded FIXME #23616
 
 #![feature(std_misc)]
index 6a84ec47c93a1a0a22f0db4b299428c3d5a040e2..9b9081019e482cc86734816e25fee4c20e5a47b2 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
 
 #![allow(unknown_features)]
 #![feature(box_syntax, std_misc)]
index 4a1bb5a5916f0dfaea28f83fafb7f8a55742f3ad..1f64f40c5255baead14e2e11b8488ffe4f305466 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 #![feature(box_syntax, set_stdio)]
 
 use std::io::prelude::*;
index dca65f03f690af16f126e1c746e80e64d39f26a9..52c920b6f5e03a34a6361b350aeedaffaf42e498 100644 (file)
@@ -12,6 +12,7 @@
 // ignore-bitrig system ulimit (Too many open files)
 // ignore-netbsd system ulimit (Too many open files)
 // ignore-openbsd system ulimit (Too many open files)
+// ignore-emscripten no threads or sockets support
 
 use std::io::prelude::*;
 use std::net::{TcpListener, TcpStream};
index 83eb351df530f1536c6559b22476752c5dbe3c1f..2875f73fc6cfa5e3825ac2e0d9f4568244f29919 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
 
 // Issue #787
 // Don't try to clean up uninitialized locals
index 184338c3294ff9290502609af17cd762263705d3..8c5b84b2c82c3e58c873a24c5ce8f2af5a98263c 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 #![feature(std_misc)]
 
 use std::thread;
index da30100f67ff9a421ea981e066b59942c23c920b..82e586196e3791be5d1ce1677db24aaca2ee1103 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // no-prefer-dynamic
+// ignore-emscripten no threads support
 
 static mut HIT: bool = false;
 
index 195b814492af1e68052c0b321a484b455ec98fe1..b44c535d3a487f4755b4454cefeb8c0d9e4d5f7c 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 #![feature(thread_local_state)]
 
 use std::thread::{self, LocalKeyState};
index 9aa2badd80b94e4cda7245179293c4fb80df8c91..24dc73d4a43d175906a0d8505dc967df094ec2eb 100644 (file)
@@ -11,6 +11,7 @@
 // Tests that a heterogeneous list of existential types can be put inside an Arc
 // and shared between threads as long as all types fulfill Send.
 
+// ignore-emscripten no threads support
 // ignore-pretty
 
 #![allow(unknown_features)]
index c32483f629e03dd4d6130e8602a38834a550ad99..2e864797db056203312aa962d59eaa9c70563953 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
 
 #![allow(unknown_features)]
 #![feature(box_syntax)]
index e31d4c811fc63cb821c7a193bfc9bb2c8949c026..eaee3505a67ca79e7086b3ee5cd437a59710dc15 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 // Make sure the destructor is run for unit-like structs.
 
 
index 449e500edbe846345be09cb01ef50404d9f6aef9..85ee21e09025592244d37820aa4b0968e054132b 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 use std::sync::mpsc::{channel, Sender};
 use std::thread;
 
index 07bfc8062f9d4c2778c5c82e2bc6299bfb00d012..320a11f64d8ac50a36091ae8ab28ed486f2941be 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
 
 #![allow(unknown_features)]
 #![feature(box_syntax)]
index 42b05aeea2910a73de32b8872c3a9c0cd2b0120b..a4202217840e64a45bd0251e7ffc92210d9c3f21 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
 
 #![feature(rand, num_bits_bytes)]
 #![feature(const_fn)]
index 5a567758bf45f673b0e8dba0e8e7cb8a730ea58c..d9f4ec289203503eb1bab6458cef320dcaf4412b 100644 (file)
@@ -10,6 +10,7 @@
 
 // aux-build:weak-lang-items.rs
 
+// ignore-emscripten no threads support
 // pretty-expanded FIXME #23616
 
 extern crate weak_lang_items as other;
index 45a747509589d85572d18cd8ec40ddd09d502efd..db884638622d190ba23d5e81f70148c1449fa623 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 use std::thread;
 
 pub fn main() {
index 69d8431082c2f42995c1479b2dbee192e4d1da29..cab68794e1cc4d6a9ef04b731f8435532250ec2b 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-emscripten no threads support
+
 use std::thread;
 
 pub fn main() {
index 20d4c744414c6a3e5178e34375c5ef328af4d813..8d3f9b59bb2eebe0e25cf48f66bb659b267675e5 100644 (file)
@@ -20,7 +20,7 @@ pub trait Foo {
 pub struct Bar;
 
 impl Bar {
-    // @has assoc_consts/struct.Bar.html '//*[@id="assoc_const.BAR"]' \
+    // @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAR"]' \
     //      'const BAR: usize = 3'
     pub const BAR: usize = 3;
 }
index 745c6e2c6648da6822f4e6f6960e1b49e787cf69..ff48c70fc58dc6e0f463b75fdb4967d08c6dcf6a 100644 (file)
@@ -14,5 +14,5 @@
 extern crate issue_21092;
 
 // @has issue_21092/struct.Bar.html
-// @has - '//*[@id="assoc_type.Bar"]' 'type Bar = i32'
+// @has - '//*[@id="associatedtype.Bar"]' 'type Bar = i32'
 pub use issue_21092::{Foo, Bar};
index e4d97828d50a08c860ef7474b1c2577f3974b8e8..2343b610ce448c30414892a8f13f4b19b9654162 100644 (file)
@@ -31,21 +31,21 @@ pub fn pass() -> isize { 42 }
 }
 
 impl<T> Bar for Foo<T> {
-    // @has - '//*[@id="assoc_type.Item"]//code' 'type Item = T'
+    // @has - '//*[@id="associatedtype.Item"]//code' 'type Item = T'
     type Item=T;
 
     // @has - '//*[@id="method.quux"]//code' 'fn quux(self)'
     fn quux(self) {}
 }
 impl<'a, T> Bar for &'a Foo<T> {
-    // @has - '//*[@id="assoc_type.Item-1"]//code' "type Item = &'a T"
+    // @has - '//*[@id="associatedtype.Item-1"]//code' "type Item = &'a T"
     type Item=&'a T;
 
     // @has - '//*[@id="method.quux-1"]//code' 'fn quux(self)'
     fn quux(self) {}
 }
 impl<'a, T> Bar for &'a mut Foo<T> {
-    // @has - '//*[@id="assoc_type.Item-2"]//code' "type Item = &'a mut T"
+    // @has - '//*[@id="associatedtype.Item-2"]//code' "type Item = &'a mut T"
     type Item=&'a mut T;
 
     // @has - '//*[@id="method.quux-2"]//code' 'fn quux(self)'
diff --git a/src/test/rustdoc/issue-26606.rs b/src/test/rustdoc/issue-26606.rs
new file mode 100644 (file)
index 0000000..df40c01
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2016 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-26606-macro.rs
+// ignore-cross-compile
+// build-aux-docs
+
+// @has issue_26606_macro/macro.make_item!.html
+#[macro_use]
+extern crate issue_26606_macro;
+
+// @has issue_26606/constant.FOO.html
+// @!has - '//a/@href' '../src/'
+make_item!(FOO);
diff --git a/src/test/rustdoc/issue-30366.rs b/src/test/rustdoc/issue-30366.rs
new file mode 100644 (file)
index 0000000..e622257
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2016 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.
+
+// @has issue_30366/index.html '//a/@href' 'http://www.rust-lang.org/'
+
+/// Describe it. [Link somewhere][1].
+///
+/// [1]: http://www.rust-lang.org/
+pub fn here_is_a_fn() { }