]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #10205 : brson/rust/unnamed_addr, r=thestinger
authorbors <bors@rust-lang.org>
Fri, 1 Nov 2013 11:06:23 +0000 (04:06 -0700)
committerbors <bors@rust-lang.org>
Fri, 1 Nov 2013 11:06:23 +0000 (04:06 -0700)
78 files changed:
Makefile.in
configure
doc/rust.md
doc/tutorial.md
mk/clean.mk
mk/dist.mk
mk/docs.mk
mk/host.mk
mk/install.mk
mk/llvm.mk
mk/perf.mk
mk/platform.mk
mk/pp.mk
mk/rt.mk
mk/rustllvm.mk
mk/snap.mk
mk/stage0.mk
mk/target.mk
mk/tests.mk
mk/tools.mk
src/etc/ziggurat_tables.py
src/libextra/extra.rs
src/libextra/treemap.rs
src/librustc/driver/driver.rs
src/librustc/front/feature_gate.rs
src/librustc/middle/resolve.rs
src/librustc/util/ppaux.rs
src/librustuv/uvio.rs
src/libstd/rand/distributions.rs
src/libstd/rand/ziggurat_tables.rs
src/libstd/rt/borrowck.rs
src/libstd/rt/io/buffered.rs
src/libstd/rt/io/comm_adapters.rs
src/libstd/rt/io/extensions.rs
src/libstd/rt/io/file.rs
src/libstd/rt/io/mem.rs
src/libstd/rt/io/mock.rs [deleted file]
src/libstd/rt/io/mod.rs
src/libstd/rt/io/native/file.rs
src/libstd/rt/io/net/tcp.rs
src/libstd/rt/io/net/udp.rs
src/libstd/rt/io/net/unix.rs
src/libstd/rt/io/pipe.rs
src/libstd/rt/io/stdio.rs
src/libstd/rt/kill.rs
src/libstd/rt/rtio.rs
src/libstd/rt/task.rs
src/libstd/std.rs
src/libstd/sys.rs
src/libstd/task/mod.rs
src/libstd/task/spawn.rs
src/libstd/unstable/lang.rs
src/libstd/unstable/raw.rs
src/libsyntax/ext/base.rs
src/libsyntax/ext/build.rs
src/libsyntax/ext/concat.rs [new file with mode: 0644]
src/libsyntax/ext/expand.rs
src/libsyntax/ext/format.rs
src/libsyntax/parse/attr.rs
src/libsyntax/parse/parser.rs
src/libsyntax/print/pprust.rs
src/libsyntax/syntax.rs
src/test/compile-fail/block-coerce-no-2.rs
src/test/compile-fail/closure-reform-bad.rs [new file with mode: 0644]
src/test/compile-fail/concat.rs [new file with mode: 0644]
src/test/compile-fail/fail-expr.rs [deleted file]
src/test/compile-fail/fail-type-err.rs [deleted file]
src/test/compile-fail/inner-static-type-parameter.rs [new file with mode: 0644]
src/test/compile-fail/non-str-meta.rs [new file with mode: 0644]
src/test/pretty/closure-reform-pretty.rs [new file with mode: 0644]
src/test/pretty/disamb-stmt-expr.rs
src/test/pretty/do1.rs
src/test/pretty/fn-types.rs
src/test/run-fail/fail-macro-send_str.rs [deleted file]
src/test/run-pass/closure-reform.rs
src/test/run-pass/concat.rs [new file with mode: 0644]
src/test/run-pass/item-attributes.rs
src/test/run-pass/unit-like-struct-drop-run.rs

index e4b08b2546ae8fd8b7aa1246beb02ac61a37f7a8..b4730a7952f64dc832279501c2bac2728e947a5a 100644 (file)
@@ -70,22 +70,22 @@ include config.mk
 ALL_OBJ_FILES :=
 
 MKFILE_DEPS := config.stamp $(call rwildcard,$(CFG_SRC_DIR)mk/,*)
-NON_BUILD_HOST_TRIPLES = $(filter-out $(CFG_BUILD_TRIPLE),$(CFG_HOST_TRIPLES))
-NON_BUILD_TARGET_TRIPLES = $(filter-out $(CFG_BUILD_TRIPLE),$(CFG_TARGET_TRIPLES))
+NON_BUILD_HOST = $(filter-out $(CFG_BUILD),$(CFG_HOST))
+NON_BUILD_TARGET = $(filter-out $(CFG_BUILD),$(CFG_TARGET))
 
 ifneq ($(MAKE_RESTARTS),)
 CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS))
 endif
 
-CFG_INFO := $(info cfg: build triple $(CFG_BUILD_TRIPLE))
-CFG_INFO := $(info cfg: host triples $(CFG_HOST_TRIPLES))
-CFG_INFO := $(info cfg: target triples $(CFG_TARGET_TRIPLES))
+CFG_INFO := $(info cfg: build triple $(CFG_BUILD))
+CFG_INFO := $(info cfg: host triples $(CFG_HOST))
+CFG_INFO := $(info cfg: target triples $(CFG_TARGET))
 
-ifneq ($(wildcard $(NON_BUILD_HOST_TRIPLES)),)
-CFG_INFO := $(info cfg: non-build host triples $(NON_BUILD_HOST_TRIPLES))
+ifneq ($(wildcard $(NON_BUILD_HOST)),)
+CFG_INFO := $(info cfg: non-build host triples $(NON_BUILD_HOST))
 endif
-ifneq ($(wildcard $(NON_BUILD_TARGET_TRIPLES)),)
-CFG_INFO := $(info cfg: non-build target triples $(NON_BUILD_TARGET_TRIPLES))
+ifneq ($(wildcard $(NON_BUILD_TARGET)),)
+CFG_INFO := $(info cfg: non-build target triples $(NON_BUILD_TARGET))
 endif
 
 CFG_RUSTC_FLAGS := $(RUSTFLAGS)
@@ -189,7 +189,7 @@ S := $(CFG_SRC_DIR)
 define DEF_X
 X_$(1) := $(CFG_EXE_SUFFIX_$(1))
 endef
-$(foreach target,$(CFG_TARGET_TRIPLES),\
+$(foreach target,$(CFG_TARGET),\
   $(eval $(call DEF_X,$(target))))
 
 # Look in doc and src dirs.
@@ -273,7 +273,7 @@ define LIST_ALL_OLD_GLOB_MATCHES_EXCEPT
 endef
 endif
 
-$(foreach target,$(CFG_TARGET_TRIPLES),\
+$(foreach target,$(CFG_TARGET),\
   $(eval $(call DEF_LIBS,$(target))))
 
 ######################################################################
@@ -347,7 +347,7 @@ LLC_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llc$$(X_$(1))
 
 endef
 
-$(foreach host,$(CFG_HOST_TRIPLES), \
+$(foreach host,$(CFG_HOST), \
  $(eval $(call DEF_LLVM_VARS,$(host))))
 
 ######################################################################
@@ -361,7 +361,7 @@ export CFG_SRC_DIR
 export CFG_BUILD_DIR
 export CFG_VERSION
 export CFG_VERSION_WIN
-export CFG_BUILD_TRIPLE
+export CFG_BUILD
 export CFG_LLVM_ROOT
 export CFG_ENABLE_MINGW_CROSS
 export CFG_PREFIX
@@ -484,7 +484,7 @@ CFGFLAG$(1)_T_$(2)_H_$(3) = stage$(1)
 # if you're building a cross config, the host->* parts are
 # effectively stage1, since it uses the just-built stage0.
 ifeq ($(1),0)
-ifneq ($(strip $(CFG_BUILD_TRIPLE)),$(strip $(3)))
+ifneq ($(strip $(CFG_BUILD)),$(strip $(3)))
 CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
 endif
 endif
@@ -507,8 +507,8 @@ PERF_STAGE$(1)_T_$(2)_H_$(3) :=                             \
 
 endef
 
-$(foreach build,$(CFG_HOST_TRIPLES), \
- $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
+$(foreach build,$(CFG_HOST), \
+ $(eval $(foreach target,$(CFG_TARGET), \
   $(eval $(foreach stage,$(STAGES), \
    $(eval $(call SREQ,$(stage),$(target),$(build))))))))
 
@@ -523,18 +523,18 @@ define DEF_RUSTC_STAGE_TARGET
 # $(2) == stage
 
 rustc-stage$(2)-H-$(1):                                                        \
-       $$(foreach target,$$(CFG_TARGET_TRIPLES),       \
+       $$(foreach target,$$(CFG_TARGET),       \
                $$(SREQ$(2)_T_$$(target)_H_$(1)))
 
 endef
 
-$(foreach host,$(CFG_HOST_TRIPLES),                                                    \
+$(foreach host,$(CFG_HOST),                                                    \
  $(eval $(foreach stage,1 2 3,                                                                 \
   $(eval $(call DEF_RUSTC_STAGE_TARGET,$(host),$(stage))))))
 
-rustc-stage1: rustc-stage1-H-$(CFG_BUILD_TRIPLE)
-rustc-stage2: rustc-stage2-H-$(CFG_BUILD_TRIPLE)
-rustc-stage3: rustc-stage3-H-$(CFG_BUILD_TRIPLE)
+rustc-stage1: rustc-stage1-H-$(CFG_BUILD)
+rustc-stage2: rustc-stage2-H-$(CFG_BUILD)
+rustc-stage3: rustc-stage3-H-$(CFG_BUILD)
 
 define DEF_RUSTC_TARGET
 # $(1) == architecture
@@ -542,15 +542,15 @@ define DEF_RUSTC_TARGET
 rustc-H-$(1): rustc-stage2-H-$(1)
 endef
 
-$(foreach host,$(CFG_TARGET_TRIPLES),                  \
+$(foreach host,$(CFG_TARGET),                  \
  $(eval $(call DEF_RUSTC_TARGET,$(host))))
 
-rustc-stage1: rustc-stage1-H-$(CFG_BUILD_TRIPLE)
-rustc-stage2: rustc-stage2-H-$(CFG_BUILD_TRIPLE)
-rustc-stage3: rustc-stage3-H-$(CFG_BUILD_TRIPLE)
-rustc: rustc-H-$(CFG_BUILD_TRIPLE)
+rustc-stage1: rustc-stage1-H-$(CFG_BUILD)
+rustc-stage2: rustc-stage2-H-$(CFG_BUILD)
+rustc-stage3: rustc-stage3-H-$(CFG_BUILD)
+rustc: rustc-H-$(CFG_BUILD)
 
-rustc-H-all: $(foreach host,$(CFG_HOST_TRIPLES),rustc-H-$(host))
+rustc-H-all: $(foreach host,$(CFG_HOST),rustc-H-$(host))
 
 ######################################################################
 # Entrypoint rule
@@ -566,12 +566,12 @@ CFG_INFO := $(info cfg: *** stage2 and later will not be built ***)
 CFG_INFO := $(info cfg:)
 
 #XXX This is surely busted
-all: $(SREQ1$(CFG_BUILD_TRIPLE)) $(GENERATED) docs
+all: $(SREQ1$(CFG_BUILD)) $(GENERATED) docs
 
 else
 
 define ALL_TARGET_N
-ifneq ($$(findstring $(1),$$(CFG_HOST_TRIPLES)),)
+ifneq ($$(findstring $(1),$$(CFG_HOST)),)
 # This is a host
 all-target-$(1)-host-$(2): $$(CSREQ2_T_$(1)_H_$(2))
 else
@@ -580,12 +580,12 @@ all-target-$(1)-host-$(2): $$(SREQ2_T_$(1)_H_$(2))
 endif
 endef
 
-$(foreach target,$(CFG_TARGET_TRIPLES), \
- $(foreach host,$(CFG_HOST_TRIPLES), \
+$(foreach target,$(CFG_TARGET), \
+ $(foreach host,$(CFG_HOST), \
  $(eval $(call ALL_TARGET_N,$(target),$(host)))))
 
-ALL_TARGET_RULES = $(foreach target,$(CFG_TARGET_TRIPLES), \
-       $(foreach host,$(CFG_HOST_TRIPLES), \
+ALL_TARGET_RULES = $(foreach target,$(CFG_TARGET), \
+       $(foreach host,$(CFG_HOST), \
  all-target-$(target)-host-$(host)))
 
 all: $(ALL_TARGET_RULES) $(GENERATED) docs
index 707649ec0e224abdf464d3199c0bd0ee103264ba..ad4b77598b3093e181bb41245ba2b524adc62b44 100755 (executable)
--- a/configure
+++ b/configure
@@ -336,7 +336,7 @@ then
 fi
 
 
-DEFAULT_BUILD_TRIPLE="${CFG_CPUTYPE}-${CFG_OSTYPE}"
+DEFAULT_BUILD="${CFG_CPUTYPE}-${CFG_OSTYPE}"
 
 CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/"
 CFG_BUILD_DIR="$(pwd)/"
@@ -385,12 +385,26 @@ opt pax-flags 0 "apply PaX flags to rustc binaries (required for GRSecurity/PaX-
 valopt prefix "/usr/local" "set installation prefix"
 valopt local-rust-root "/usr/local" "set prefix for local rust binary"
 valopt llvm-root "" "set LLVM root"
-valopt build-triple "${DEFAULT_BUILD_TRIPLE}" "LLVM build triple"
-valopt host-triples "${CFG_BUILD_TRIPLE}" "LLVM host triples"
-valopt target-triples "${CFG_HOST_TRIPLES}" "LLVM target triples"
 valopt android-cross-path "/opt/ndk_standalone" "Android NDK standalone path"
 valopt mingw32-cross-path "" "MinGW32 cross compiler path"
 
+valopt build "${DEFAULT_BUILD}" "GNUs ./configure syntax LLVM build triple"
+valopt host "${CFG_BUILD}" "GNUs ./configure syntax LLVM host triples"
+valopt target "${CFG_HOST}" "GNUs ./configure syntax LLVM target triples"
+
+valopt localstatedir "/var/lib" "local state directory"
+valopt sysconfdir "/etc" "install system configuration files"
+
+valopt datadir "${CFG_PREFIX}/share" "install data"
+valopt infodir "${CFG_PREFIX}/share/info" "install additional info"
+valopt mandir "${CFG_PREFIX}/share/man" "install man pages in PATH"
+valopt libdir "${CFG_PREFIX}/lib" "install libraries" 
+
+#Deprecated opts to keep compatibility
+valopt build-triple "${CFG_BUILD}" "LLVM build triple"
+valopt host-triples "${CFG_HOST}" "LLVM host triples"
+valopt target-triples "${CFG_TARGET}" "LLVM target triples"
+
 # Validate Options
 step_msg "validating $CFG_SELF args"
 validate_opt
@@ -589,23 +603,44 @@ fi
 # a little post-processing of various config values
 
 CFG_PREFIX=${CFG_PREFIX%/}
-CFG_HOST_TRIPLES="$(echo $CFG_HOST_TRIPLES | tr ',' ' ')"
-CFG_TARGET_TRIPLES="$(echo $CFG_TARGET_TRIPLES | tr ',' ' ')"
-CFG_SUPPORTED_TARGET_TRIPLES="$(grep ^CC_*=* $CFG_SRC_DIR/mk/platform.mk | sed -e 's/^CC_//' -e 's/\([^=]*\).*/\1/' | xargs)"
+CFG_MANDIR=${CFG_MANDIR%/}
+CFG_HOST="$(echo $CFG_HOST | tr ',' ' ')"
+CFG_TARGET="$(echo $CFG_TARGET | tr ',' ' ')"
+CFG_SUPPORTED_TARGET="$(grep ^CC_*=* $CFG_SRC_DIR/mk/platform.mk | sed -e 's/^CC_//' -e 's/\([^=]*\).*/\1/' | xargs)"
 
 # copy host-triples to target-triples so that hosts are a subset of targets
 V_TEMP=""
+for i in $CFG_HOST $CFG_TARGET;
+do
+   echo "$V_TEMP" | grep -qF $i || V_TEMP="$V_TEMP${V_TEMP:+ }$i"
+done
+CFG_TARGET=$V_TEMP
+
+# copy host-triples to target-triples so that hosts are a subset of targets
+# XXX: remove deprecated variables here
+V_TEMP=""
 for i in $CFG_HOST_TRIPLES $CFG_TARGET_TRIPLES;
 do
    echo "$V_TEMP" | grep -qF $i || V_TEMP="$V_TEMP${V_TEMP:+ }$i"
 done
 CFG_TARGET_TRIPLES=$V_TEMP
 
+# XXX: Support for deprecated syntax, should be dropped.
+if [ ! -z "$CFG_BUILD_TRIPLE" ]; then
+    CFG_BUILD=${CFG_BUILD_TRIPLE}
+fi
+if [ ! -z "$CFG_HOST_TRIPLES" ]; then
+    CFG_HOST=${CFG_HOST_TRIPLES}
+fi
+if [ ! -z "$CFG_TARGET_TRIPLES" ]; then
+    CFG_TARGET=${CFG_TARGET_TRIPLES}
+fi
+
 # check target-specific tool-chains
-for i in $CFG_TARGET_TRIPLES
+for i in $CFG_TARGET
 do
     L_CHECK=false
-    for j in $CFG_SUPPORTED_TARGET_TRIPLES
+    for j in $CFG_SUPPORTED_TARGET
     do
         if [ $i = $j ]
         then
@@ -635,6 +670,13 @@ do
             fi
             ;;
 
+        arm-apple-darwin)
+            if [ $CFG_OSTYPE != apple-darwin ]
+            then
+                err "The iOS target is only supported on Mac OS X"
+            fi
+            ;;
+
         *)
             ;;
     esac
@@ -664,17 +706,17 @@ do
     make_dir $i
 done
 
-for t in $CFG_HOST_TRIPLES
+for t in $CFG_HOST
 do
     make_dir $t/llvm
 done
 
-for t in $CFG_HOST_TRIPLES
+for t in $CFG_HOST
 do
     make_dir $t/rustllvm
 done
 
-for t in $CFG_TARGET_TRIPLES
+for t in $CFG_TARGET
 do
   make_dir $t/rt
   for s in 0 1 2 3
@@ -703,9 +745,9 @@ then
     CFG_LIBDIR=bin
 fi
 
-for h in $CFG_HOST_TRIPLES
+for h in $CFG_HOST
 do
-    for t in $CFG_TARGET_TRIPLES
+    for t in $CFG_TARGET
     do
         for i in 0 1 2 3
         do
@@ -785,7 +827,7 @@ fi
 # Configure llvm, only if necessary
 step_msg "looking at LLVM"
 CFG_LLVM_SRC_DIR=${CFG_SRC_DIR}src/llvm/
-for t in $CFG_HOST_TRIPLES
+for t in $CFG_HOST
 do
     do_reconfigure=1
 
@@ -961,20 +1003,15 @@ putvar CFG_OSTYPE
 putvar CFG_CPUTYPE
 putvar CFG_CONFIGURE_ARGS
 putvar CFG_PREFIX
-putvar CFG_BUILD_TRIPLE
-putvar CFG_HOST_TRIPLES
-putvar CFG_TARGET_TRIPLES
+putvar CFG_BUILD
+putvar CFG_HOST
+putvar CFG_TARGET
 putvar CFG_C_COMPILER
 putvar CFG_LIBDIR
 putvar CFG_DISABLE_MANAGE_SUBMODULES
 putvar CFG_ANDROID_CROSS_PATH
 putvar CFG_MINGW32_CROSS_PATH
-
-if [ ! -z "$CFG_ENABLE_PAX_FLAGS" ]
-then
-    putvar CFG_ENABLE_PAX_FLAGS
-    putvar CFG_PAXCTL
-fi
+putvar CFG_MANDIR
 
 # Avoid spurious warnings from clang by feeding it original source on
 # ccache-miss rather than preprocessed input.
@@ -1015,7 +1052,7 @@ fi
 putvar CFG_LLVM_ROOT
 putvar CFG_LLVM_SRC_DIR
 
-for t in $CFG_HOST_TRIPLES
+for t in $CFG_HOST
 do
     CFG_LLVM_BUILD_DIR=$(echo CFG_LLVM_BUILD_DIR_${t} | tr - _)
     CFG_LLVM_INST_DIR=$(echo CFG_LLVM_INST_DIR_${t} | tr - _)
index 40a3bc12798f75e390a647171587048d46266a2e..0023e65cd83917a97cb2f5cc4855c0c979c921dd 100644 (file)
@@ -568,6 +568,7 @@ This requirement most often affects name-designator pairs when they occur at the
 * `log_syntax!` : print out the arguments at compile time
 * `trace_macros!` : supply `true` or `false` to enable or disable macro expansion logging
 * `stringify!` : turn the identifier argument into a string literal
+* `concat!` : concatenates a comma-separated list of literals
 * `concat_idents!` : create a new identifier by concatenating the arguments
 
 # Crates and source files
index 3eab4ceffec1983c3c288460b0eed73cf87d81b8..35b973ee89f7ff506859ee22c49ae2ddbfafd36a 100644 (file)
@@ -1142,7 +1142,7 @@ For a more in-depth explanation of borrowed pointers, read the
 
 ## Freezing
 
-Borrowing an immutable pointer to an object freezes it and prevents mutation.
+Lending an immutable pointer to an object freezes it and prevents mutation.
 `Owned` objects have freezing enforced statically at compile-time.
 
 ~~~~
index a46e7fa4f3ff808526950c0af5de7f6f25786b23..fc4bcf6c759f0373436ddff8967c2bf78efc19a5 100644 (file)
 
 CLEAN_STAGE_RULES =                                                            \
  $(foreach stage, $(STAGES),                                   \
-  $(foreach host, $(CFG_HOST_TRIPLES),         \
+  $(foreach host, $(CFG_HOST),         \
    clean$(stage)_H_$(host)                                             \
-   $(foreach target, $(CFG_TARGET_TRIPLES),            \
+   $(foreach target, $(CFG_TARGET),            \
     clean$(stage)_T_$(target)_H_$(host))))
 
 CLEAN_LLVM_RULES =                                                             \
- $(foreach target, $(CFG_HOST_TRIPLES),                \
+ $(foreach target, $(CFG_HOST),                \
   clean-llvm$(target))
 
 .PHONY: clean clean-all clean-misc clean-llvm
@@ -33,9 +33,9 @@ clean: clean-misc $(CLEAN_STAGE_RULES)
 
 clean-misc:
        @$(call E, cleaning)
-       $(Q)find $(CFG_BUILD_TRIPLE)/rustllvm \
-                $(CFG_BUILD_TRIPLE)/rt \
-                $(CFG_BUILD_TRIPLE)/test \
+       $(Q)find $(CFG_BUILD)/rustllvm \
+                $(CFG_BUILD)/rt \
+                $(CFG_BUILD)/test \
          -name '*.[odasS]' -o \
          -name '*.so' -o      \
          -name '*.dylib' -o   \
@@ -43,7 +43,7 @@ clean-misc:
          -name '*.def' -o     \
          -name '*.bc'         \
          | xargs rm -f
-       $(Q)find $(CFG_BUILD_TRIPLE)\
+       $(Q)find $(CFG_BUILD)\
          -name '*.dSYM'       \
          | xargs rm -Rf
        $(Q)rm -f $(RUNTIME_OBJS) $(RUNTIME_DEF)
@@ -87,7 +87,7 @@ clean$(1)_H_$(2):
 
 endef
 
-$(foreach host, $(CFG_HOST_TRIPLES), \
+$(foreach host, $(CFG_HOST), \
  $(eval $(foreach stage, $(STAGES), \
   $(eval $(call CLEAN_HOST_STAGE_N,$(stage),$(host))))))
 
@@ -121,8 +121,8 @@ clean$(1)_T_$(2)_H_$(3):
        $(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/run_pass_stage* # For windows
 endef
 
-$(foreach host, $(CFG_HOST_TRIPLES), \
- $(eval $(foreach target, $(CFG_TARGET_TRIPLES), \
+$(foreach host, $(CFG_HOST), \
+ $(eval $(foreach target, $(CFG_TARGET), \
   $(eval $(foreach stage, 0 1 2 3, \
    $(eval $(call CLEAN_TARGET_STAGE_N,$(stage),$(target),$(host))))))))
 
@@ -136,5 +136,5 @@ clean-llvm$(1): ;
 endif
 endef
 
-$(foreach host, $(CFG_HOST_TRIPLES), \
+$(foreach host, $(CFG_HOST), \
  $(eval $(call DEF_CLEAN_LLVM_HOST,$(host))))
index 13b9509e66705f9400b6042458eec800920bdcf1..264d3105839cb6850e300f8cdc457edf3729920e 100644 (file)
@@ -57,7 +57,7 @@ LICENSE.txt: $(S)COPYRIGHT $(S)LICENSE-APACHE $(S)LICENSE-MIT
        cp $< $@
 
 $(PKG_EXE): rust.iss modpath.iss LICENSE.txt rust-logo.ico \
-            $(PKG_FILES) $(CSREQ3_T_$(CFG_BUILD_TRIPLE)_H_$(CFG_BUILD_TRIPLE))
+            $(PKG_FILES) $(CSREQ3_T_$(CFG_BUILD)_H_$(CFG_BUILD))
        $(CFG_PYTHON) $(S)src/etc/copy-runtime-deps.py i686-pc-mingw32/stage3/bin
        @$(call E, ISCC: $@)
        $(Q)"$(CFG_ISCC)" $<
@@ -84,7 +84,7 @@ $(PKG_TAR): $(PKG_FILES)
 
 .PHONY: dist distcheck
 
-ifdef CFG_WINDOWSY_$(CFG_BUILD_TRIPLE)
+ifdef CFG_WINDOWSY_$(CFG_BUILD)
 
 dist: $(PKG_EXE)
 
index a335c8ef4e96ec7aa7a381d0f714ccb356e745e4..771f1511c6d9740b5804a6ed6dba12189f6a942d 100644 (file)
@@ -235,7 +235,7 @@ endif
 ######################################################################
 
 # The rustdoc executable
-RUSTDOC = $(HBIN2_H_$(CFG_BUILD_TRIPLE))/rustdoc$(X_$(CFG_BUILD_TRIPLE))
+RUSTDOC = $(HBIN2_H_$(CFG_BUILD))/rustdoc$(X_$(CFG_BUILD))
 
 # The library documenting macro
 # $(1) - The crate name (std/extra)
@@ -249,8 +249,8 @@ doc/$(1)/index.html: $$(RUSTDOC) $$(TLIB2_T_$(3)_H_$(3))/$(CFG_STDLIB_$(3))
 DOCS += doc/$(1)/index.html
 endef
 
-$(eval $(call libdoc,std,$(STDLIB_CRATE),$(CFG_BUILD_TRIPLE)))
-$(eval $(call libdoc,extra,$(EXTRALIB_CRATE),$(CFG_BUILD_TRIPLE)))
+$(eval $(call libdoc,std,$(STDLIB_CRATE),$(CFG_BUILD)))
+$(eval $(call libdoc,extra,$(EXTRALIB_CRATE),$(CFG_BUILD)))
 
 
 ifdef CFG_DISABLE_DOCS
index 537e737a29af6e10c48959eef38130e75c9f6946..9ba2b978f1075775ef028186493da62d9121536c 100644 (file)
@@ -161,7 +161,7 @@ endif
 
 endef
 
-$(foreach t,$(CFG_HOST_TRIPLES),                                       \
+$(foreach t,$(CFG_HOST),                                       \
        $(eval $(call CP_HOST_STAGE_N,0,1,$(t),$(t)))   \
        $(eval $(call CP_HOST_STAGE_N,1,2,$(t),$(t)))   \
        $(eval $(call CP_HOST_STAGE_N,2,3,$(t),$(t))))
index 16af433e57518a87df5968a9799c2cab43dd79c6..e48afc18e62944baca3445a9103f3acb621f91a7 100644 (file)
@@ -80,8 +80,8 @@ PTL$(1)$(2) = $$(PTR$(1)$(2))/$(CFG_LIBDIR)
 
 endef
 
-$(foreach target,$(CFG_TARGET_TRIPLES), \
- $(eval $(call INSTALL_PREPARE_N,$(target),$(CFG_BUILD_TRIPLE))))
+$(foreach target,$(CFG_TARGET), \
+ $(eval $(call INSTALL_PREPARE_N,$(target),$(CFG_BUILD))))
 
 define INSTALL_TARGET_N
 install-target-$(1)-host-$(2): LIB_SOURCE_DIR=$$(TL$(1)$(2))
@@ -114,21 +114,21 @@ install-target-$(1)-host-$(2): $$(CSREQ$$(ISTAGE)_T_$(1)_H_$(2))
 
 endef
 
-$(foreach target,$(CFG_TARGET_TRIPLES), \
- $(if $(findstring $(target), $(CFG_BUILD_TRIPLE)), \
-  $(eval $(call INSTALL_HOST_N,$(target),$(CFG_BUILD_TRIPLE))), \
-  $(eval $(call INSTALL_TARGET_N,$(target),$(CFG_BUILD_TRIPLE)))))
+$(foreach target,$(CFG_TARGET), \
+ $(if $(findstring $(target), $(CFG_BUILD)), \
+  $(eval $(call INSTALL_HOST_N,$(target),$(CFG_BUILD))), \
+  $(eval $(call INSTALL_TARGET_N,$(target),$(CFG_BUILD)))))
 
-INSTALL_TARGET_RULES = $(foreach target,$(CFG_TARGET_TRIPLES), \
- install-target-$(target)-host-$(CFG_BUILD_TRIPLE))
+INSTALL_TARGET_RULES = $(foreach target,$(CFG_TARGET), \
+ install-target-$(target)-host-$(CFG_BUILD))
 
 install: all install-host install-targets
 
 # Shorthand for build/stageN/bin
-HB = $(HBIN$(ISTAGE)_H_$(CFG_BUILD_TRIPLE))
-HB2 = $(HBIN2_H_$(CFG_BUILD_TRIPLE))
+HB = $(HBIN$(ISTAGE)_H_$(CFG_BUILD))
+HB2 = $(HBIN2_H_$(CFG_BUILD))
 # Shorthand for build/stageN/lib
-HL = $(HLIB$(ISTAGE)_H_$(CFG_BUILD_TRIPLE))
+HL = $(HLIB$(ISTAGE)_H_$(CFG_BUILD))
 # Shorthand for the prefix bin directory
 PHB = $(PREFIX_BIN)
 # Shorthand for the prefix bin directory
@@ -136,25 +136,25 @@ PHL = $(PREFIX_LIB)
 
 install-host: LIB_SOURCE_DIR=$(HL)
 install-host: LIB_DESTIN_DIR=$(PHL)
-install-host: $(CSREQ$(ISTAGE)_T_$(CFG_BUILD_TRIPLE)_H_$(CFG_BUILD_TRIPLE))
+install-host: $(CSREQ$(ISTAGE)_T_$(CFG_BUILD_)_H_$(CFG_BUILD_))
        $(Q)$(call MK_INSTALL_DIR,$(PREFIX_BIN))
        $(Q)$(call MK_INSTALL_DIR,$(PREFIX_LIB))
-       $(Q)$(call MK_INSTALL_DIR,$(PREFIX_ROOT)/share/man/man1)
-       $(Q)$(call INSTALL,$(HB2),$(PHB),rustc$(X_$(CFG_BUILD_TRIPLE)))
-       $(Q)$(call INSTALL,$(HB2),$(PHB),rustpkg$(X_$(CFG_BUILD_TRIPLE)))
-       $(Q)$(call INSTALL,$(HB2),$(PHB),rustdoc$(X_$(CFG_BUILD_TRIPLE)))
-       $(Q)$(call INSTALL_LIB,$(STDLIB_GLOB_$(CFG_BUILD_TRIPLE)))
-       $(Q)$(call INSTALL_LIB,$(EXTRALIB_GLOB_$(CFG_BUILD_TRIPLE)))
-       $(Q)$(call INSTALL_LIB,$(LIBRUSTUV_GLOB_$(CFG_BUILD_TRIPLE)))
-       $(Q)$(call INSTALL_LIB,$(LIBRUSTC_GLOB_$(CFG_BUILD_TRIPLE)))
-       $(Q)$(call INSTALL_LIB,$(LIBSYNTAX_GLOB_$(CFG_BUILD_TRIPLE)))
-       $(Q)$(call INSTALL_LIB,$(LIBRUSTPKG_GLOB_$(CFG_BUILD_TRIPLE)))
-       $(Q)$(call INSTALL_LIB,$(LIBRUSTDOC_GLOB_$(CFG_BUILD_TRIPLE)))
-       $(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_RUNTIME_$(CFG_BUILD_TRIPLE)))
-       $(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_RUSTLLVM_$(CFG_BUILD_TRIPLE)))
-       $(Q)$(call INSTALL,$(S)/man, $(PREFIX_ROOT)/share/man/man1,rustc.1)
-       $(Q)$(call INSTALL,$(S)/man, $(PREFIX_ROOT)/share/man/man1,rustdoc.1)
-       $(Q)$(call INSTALL,$(S)/man, $(PREFIX_ROOT)/share/man/man1,rustpkg.1)
+       $(Q)$(call MK_INSTALL_DIR,$(CFG_MANDIR)/man1)
+       $(Q)$(call INSTALL,$(HB2),$(PHB),rustc$(X_$(CFG_BUILD)))
+       $(Q)$(call INSTALL,$(HB2),$(PHB),rustpkg$(X_$(CFG_BUILD)))
+       $(Q)$(call INSTALL,$(HB2),$(PHB),rustdoc$(X_$(CFG_BUILD)))
+       $(Q)$(call INSTALL_LIB,$(STDLIB_GLOB_$(CFG_BUILD)))
+       $(Q)$(call INSTALL_LIB,$(EXTRALIB_GLOB_$(CFG_BUILD)))
+       $(Q)$(call INSTALL_LIB,$(LIBRUSTUV_GLOB_$(CFG_BUILD)))
+       $(Q)$(call INSTALL_LIB,$(LIBRUSTC_GLOB_$(CFG_BUILD)))
+       $(Q)$(call INSTALL_LIB,$(LIBSYNTAX_GLOB_$(CFG_BUILD)))
+       $(Q)$(call INSTALL_LIB,$(LIBRUSTPKG_GLOB_$(CFG_BUILD)))
+       $(Q)$(call INSTALL_LIB,$(LIBRUSTDOC_GLOB_$(CFG_BUILD)))
+       $(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_RUNTIME_$(CFG_BUILD)))
+       $(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_RUSTLLVM_$(CFG_BUILD)))
+       $(Q)$(call INSTALL,$(S)/man, $(CFG_MANDIR)/man1,rustc.1)
+       $(Q)$(call INSTALL,$(S)/man, $(CFG_MANDIR)/man1,rustdoc.1)
+       $(Q)$(call INSTALL,$(S)/man, $(CFG_MANDIR)/man1,rustpkg.1)
 
 install-targets: $(INSTALL_TARGET_RULES)
 
@@ -163,26 +163,27 @@ HOST_LIB_FROM_HL_GLOB = \
   $(patsubst $(HL)/%,$(PHL)/%,$(wildcard $(HL)/$(1)))
 
 uninstall:
-       $(Q)rm -f $(PHB)/rustc$(X_$(CFG_BUILD_TRIPLE))
-       $(Q)rm -f $(PHB)/rustpkg$(X_$(CFG_BUILD_TRIPLE))
-       $(Q)rm -f $(PHB)/rustdoc$(X_$(CFG_BUILD_TRIPLE))
-       $(Q)rm -f $(PHL)/$(CFG_RUSTLLVM_$(CFG_BUILD_TRIPLE))
-       $(Q)rm -f $(PHL)/$(CFG_RUNTIME_$(CFG_BUILD_TRIPLE))
+       $(Q)rm -f $(PHB)/rustc$(X_$(CFG_BUILD))
+       $(Q)rm -f $(PHB)/rustpkg$(X_$(CFG_BUILD))
+       $(Q)rm -f $(PHB)/rustdoc$(X_$(CFG_BUILD))
+       $(Q)rm -f $(PHL)/$(CFG_RUSTLLVM_$(CFG_BUILD))
+       $(Q)rm -f $(PHL)/$(CFG_RUNTIME_$(CFG_BUILD))
        $(Q)for i in \
-          $(call HOST_LIB_FROM_HL_GLOB,$(STDLIB_GLOB_$(CFG_BUILD_TRIPLE))) \
-          $(call HOST_LIB_FROM_HL_GLOB,$(EXTRALIB_GLOB_$(CFG_BUILD_TRIPLE))) \
-          $(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTUV_GLOB_$(CFG_BUILD_TRIPLE))) \
-          $(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTC_GLOB_$(CFG_BUILD_TRIPLE))) \
-          $(call HOST_LIB_FROM_HL_GLOB,$(LIBSYNTAX_GLOB_$(CFG_BUILD_TRIPLE))) \
-          $(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTPKG_GLOB_$(CFG_BUILD_TRIPLE))) \
-          $(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTDOC_GLOB_$(CFG_BUILD_TRIPLE))) \
+          $(call HOST_LIB_FROM_HL_GLOB,$(STDLIB_GLOB_$(CFG_BUILD))) \
+          $(call HOST_LIB_FROM_HL_GLOB,$(EXTRALIB_GLOB_$(CFG_BUILD))) \
+          $(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTUV_GLOB_$(CFG_BUILD))) \
+          $(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTC_GLOB_$(CFG_BUILD))) \
+          $(call HOST_LIB_FROM_HL_GLOB,$(LIBSYNTAX_GLOB_$(CFG_BUILD))) \
+          $(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTPKG_GLOB_$(CFG_BUILD))) \
+          $(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTDOC_GLOB_$(CFG_BUILD))) \
         ; \
         do rm -f $$i ; \
         done
        $(Q)rm -Rf $(PHL)/rustc
-       $(Q)rm -f $(PREFIX_ROOT)/share/man/man1/rustc.1
-       $(Q)rm -f $(PREFIX_ROOT)/share/man/man1/rustdoc.1
-       $(Q)rm -f $(PREFIX_ROOT)/share/man/man1/rustpkg.1
+       $(Q)rm -f $(CFG_MANDIR)/man1/rustc.1
+       $(Q)rm -f $(CFG_MANDIR)/man1/rustdoc.1
+       $(Q)rm -f $(CFG_MANDIR)/man1/rusti.1
+       $(Q)rm -f $(CFG_MANDIR)/man1/rustpkg.1
 
 # target platform specific variables
 # for arm-linux-androidabi
@@ -190,7 +191,7 @@ define DEF_ADB_DEVICE_STATUS
 CFG_ADB_DEVICE_STATUS=$(1)
 endef
 
-$(foreach target,$(CFG_TARGET_TRIPLES), \
+$(foreach target,$(CFG_TARGET), \
   $(if $(findstring $(target),"arm-linux-androideabi"), \
     $(if $(findstring adb,$(CFG_ADB)), \
       $(if $(findstring device,$(shell $(CFG_ADB) devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \
@@ -246,12 +247,12 @@ install-runtime-target-$(1)-cleanup:
        $(Q)$(call ADB_SHELL,rm,$(CFG_RUNTIME_PUSH_DIR)/$(LIBRUSTUV_GLOB_$(1)))
 endef
 
-$(eval $(call INSTALL_RUNTIME_TARGET_N,arm-linux-androideabi,$(CFG_BUILD_TRIPLE)))
+$(eval $(call INSTALL_RUNTIME_TARGET_N,arm-linux-androideabi,$(CFG_BUILD)))
 $(eval $(call INSTALL_RUNTIME_TARGET_CLEANUP_N,arm-linux-androideabi))
 
 install-runtime-target: \
        install-runtime-target-arm-linux-androideabi-cleanup \
-       install-runtime-target-arm-linux-androideabi-host-$(CFG_BUILD_TRIPLE)
+       install-runtime-target-arm-linux-androideabi-host-$(CFG_BUILD)
 else
 install-runtime-target:
        @echo "No device to install runtime library"
index 9de04bed59800d74d31ce012391ee0097543d130..53f955bd284aa80b2948223b9934cbf069cf6d0b 100644 (file)
@@ -42,5 +42,5 @@ $$(LLVM_STAMP_$(1)): $(S)src/rustllvm/llvm-auto-clean-trigger
 
 endef
 
-$(foreach host,$(CFG_HOST_TRIPLES), \
+$(foreach host,$(CFG_HOST), \
  $(eval $(call DEF_LLVM_RULES,$(host))))
index 327f2ca31e00f8fcd7bb7c37efd2f61c9122ac18..16cbaab495d8256a8dfc4feea72921c44ccd19af 100644 (file)
 
 
 ifdef CFG_PERF_TOOL
-rustc-perf$(X): $(CFG_BUILD_TRIPLE)/stage2/bin/rustc$(X_$(CFG_BUILD_TRIPLE))
+rustc-perf$(X): $(CFG_BUILD)/stage2/bin/rustc$(X_$(CFG_BUILD))
        @$(call E, perf compile: $@)
-       $(PERF_STAGE2_T_$(CFG_BUILD_TRIPLE)_H_$(CFG_BUILD_TRIPLE)) \
+       $(PERF_STAGE2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) \
                 -o $@ $(COMPILER_CRATE) >rustc-perf.err 2>&1
        $(Q)rm -f $(LIBRUSTC_GLOB)
 else
-rustc-perf$(X): $(CFG_BUILD_TRIPLE)/stage2/bin/rustc$(X_$(CFG_BUILD_TRIPLE))
+rustc-perf$(X): $(CFG_BUILD)/stage2/bin/rustc$(X_$(CFG_BUILD))
        $(Q)touch $@
 endif
 
-perf: check-stage2-perf rustc-perf$(X_$(CFG_BUILD_TRIPLE))
-       $(Q)find $(CFG_BUILD_TRIPLE)/test/perf -name \*.err | xargs cat
+perf: check-stage2-perf rustc-perf$(X_$(CFG_BUILD))
+       $(Q)find $(CFG_BUILD)/test/perf -name \*.err | xargs cat
        $(Q)cat rustc-perf.err
index 27fe373b761eafa8cfc42631c03686b3b8aba4a3..e7c9a10bc63e2e4873a79afceb61bc0acdc97bb8 100644 (file)
 define DEF_HOST_VAR
   HOST_$(1) = $(subst i686,i386,$(word 1,$(subst -, ,$(1))))
 endef
-$(foreach t,$(CFG_TARGET_TRIPLES),$(eval $(call DEF_HOST_VAR,$(t))))
-$(foreach t,$(CFG_TARGET_TRIPLES),$(info cfg: host for $(t) is $(HOST_$(t))))
+$(foreach t,$(CFG_TARGET),$(eval $(call DEF_HOST_VAR,$(t))))
+$(foreach t,$(CFG_TARGET),$(info cfg: host for $(t) is $(HOST_$(t))))
 
 # Ditto for OSTYPE
 define DEF_OSTYPE_VAR
   OSTYPE_$(1) = $(subst $(firstword $(subst -, ,$(1)))-,,$(1))
 endef
-$(foreach t,$(CFG_TARGET_TRIPLES),$(eval $(call DEF_OSTYPE_VAR,$(t))))
-$(foreach t,$(CFG_TARGET_TRIPLES),$(info cfg: os for $(t) is $(OSTYPE_$(t))))
+$(foreach t,$(CFG_TARGET),$(eval $(call DEF_OSTYPE_VAR,$(t))))
+$(foreach t,$(CFG_TARGET),$(info cfg: os for $(t) is $(OSTYPE_$(t))))
 
 # FIXME: no-omit-frame-pointer is just so that task_start_wrapper
 # has a frame pointer and the stack walker can understand it. Turning off
@@ -193,6 +193,35 @@ CFG_LDPATH_i686-unknown-linux-gnu :=
 CFG_RUN_i686-unknown-linux-gnu=$(2)
 CFG_RUN_TARG_i686-unknown-linux-gnu=$(call CFG_RUN_i686-unknown-linux-gnu,,$(2))
 
+# arm-apple-darwin configuration
+ifeq ($(CFG_OSTYPE),apple-darwin)
+CFG_IOS_SDK = $(shell xcrun --show-sdk-path -sdk iphoneos)
+CFG_IOS_FLAGS = -target arm-apple-darwin -isysroot $(CFG_IOS_SDK) -I $(CFG_IOS_SDK)/usr/include -I $(CFG_IOS_SDK)/usr/include/c++/4.2.1 -I /usr/include
+CC_arm-apple-darwin = $(shell xcrun -find -sdk iphoneos clang)
+CXX_arm-apple-darwin = $(shell xcrun -find -sdk iphoneos clang++)
+CPP_arm-apple-darwin = $(shell xcrun -find -sdk iphoneos clang++)
+AR_arm-apple-darwin = $(shell xcrun -find -sdk iphoneos ar)
+CFG_LIB_NAME_arm-apple-darwin = lib$(1).dylib
+CFG_LIB_GLOB_arm-apple-darwin = lib$(1)-*.dylib
+CFG_LIB_DSYM_GLOB_arm-apple-darwin = lib$(1)-*.dylib.dSYM
+CFG_GCCISH_CFLAGS_arm-apple-darwin := -Wall -Werror -g -fPIC $(CFG_IOS_FLAGS)
+CFG_GCCISH_CXXFLAGS_arm-apple-darwin := -fno-rtti $(CFG_IOS_FLAGS)
+CFG_GCCISH_LINK_FLAGS_arm-apple-darwin := -dynamiclib -lpthread -framework CoreServices -Wl,-no_compact_unwind 
+CFG_GCCISH_DEF_FLAG_arm-apple-darwin := -Wl,-exported_symbols_list,
+CFG_GCCISH_PRE_LIB_FLAGS_arm-apple-darwin :=
+CFG_GCCISH_POST_LIB_FLAGS_arm-apple-darwin :=
+CFG_DEF_SUFFIX_arm-apple-darwin := .darwin.def
+CFG_INSTALL_NAME_arm-apple-darwin = -Wl,-install_name,@rpath/$(1)
+CFG_LIBUV_LINK_FLAGS_arm-apple-darwin =
+CFG_EXE_SUFFIX_arm-apple-darwin :=
+CFG_WINDOWSY_arm-apple-darwin :=
+CFG_UNIXY_arm-apple-darwin := 1
+CFG_PATH_MUNGE_arm-apple-darwin := true
+CFG_LDPATH_arm-apple-darwin :=
+CFG_RUN_arm-apple-darwin = $(2)
+CFG_RUN_TARG_arm-apple-darwin = $(call CFG_RUN_arm-apple-darwin,,$(2))
+endif
+
 # x86_64-apple-darwin configuration
 CC_x86_64-apple-darwin=$(CC)
 CXX_x86_64-apple-darwin=$(CXX)
@@ -378,7 +407,7 @@ CFG_UNIXY_i686-pc-mingw32 :=
 CFG_PATH_MUNGE_i686-pc-mingw32 :=
 CFG_LDPATH_i686-pc-mingw32 :=$(CFG_LDPATH_i686-pc-mingw32):$(PATH)
 CFG_RUN_i686-pc-mingw32=PATH="$(CFG_LDPATH_i686-pc-mingw32):$(1)" $(2)
-CFG_RUN_TARG_i686-pc-mingw32=$(call CFG_RUN_i686-pc-mingw32,$(HLIB$(1)_H_$(CFG_BUILD_TRIPLE)),$(2))
+CFG_RUN_TARG_i686-pc-mingw32=$(call CFG_RUN_i686-pc-mingw32,$(HLIB$(1)_H_$(CFG_BUILD)),$(2))
 
 # i586-mingw32msvc configuration
 CC_i586-mingw32msvc=$(CFG_MINGW32_CROSS_PATH)/bin/i586-mingw32msvc-gcc
@@ -432,7 +461,7 @@ CFG_UNIXY_x86_64-w64-mingw32 :=
 CFG_PATH_MUNGE_x86_64-w64-mingw32 :=
 CFG_LDPATH_x86_64-w64-mingw32 :=$(CFG_LDPATH_x86_64-w64-mingw32):$(PATH)
 CFG_RUN_x86_64-w64-mingw32=PATH="$(CFG_LDPATH_x86_64-w64-mingw32):$(1)" $(2)
-CFG_RUN_TARG_x86_64-w64-mingw32=$(call CFG_RUN_x86_64-w64-mingw32,$(HLIB$(1)_H_$(CFG_BUILD_TRIPLE)),$(2))
+CFG_RUN_TARG_x86_64-w64-mingw32=$(call CFG_RUN_x86_64-w64-mingw32,$(HLIB$(1)_H_$(CFG_BUILD)),$(2))
 
 # x86_64-unknown-freebsd configuration
 CC_x86_64-unknown-freebsd=$(CC)
@@ -498,7 +527,7 @@ define CFG_MAKE_TOOLCHAIN
   # We're using llvm-mc as our assembler because it supports
   # .cfi pseudo-ops on mac
   CFG_ASSEMBLE_$(1)=$$(CPP_$(1)) -E $$(CFG_DEPEND_FLAGS) $$(2) | \
-                    $$(LLVM_MC_$$(CFG_BUILD_TRIPLE)) \
+                    $$(LLVM_MC_$$(CFG_BUILD)) \
                     -assemble \
                     -filetype=obj \
                     -triple=$(1) \
@@ -514,5 +543,5 @@ define CFG_MAKE_TOOLCHAIN
 
 endef
 
-$(foreach target,$(CFG_TARGET_TRIPLES),\
+$(foreach target,$(CFG_TARGET),\
   $(eval $(call CFG_MAKE_TOOLCHAIN,$(target))))
index d02733d1747b9ab6d22393c1eabe435d5cb70946..3d2af81f1c811fc5561c00aeb1d191bd049b97de 100644 (file)
--- a/mk/pp.mk
+++ b/mk/pp.mk
@@ -24,10 +24,10 @@ else
                        "no-reformat\|xfail-pretty\|xfail-test")
 endif
 
-reformat: $(SREQ1$(CFG_BUILD_TRIPLE))
+reformat: $(SREQ1$(CFG_BUILD))
        @$(call E, reformat [stage1]: $@)
        for i in $(PP_INPUTS_FILTERED);  \
-    do $(call CFG_RUN_TARG_$(CFG_BUILD_TRIPLE),1,$(CFG_BUILD_TRIPLE)/stage1/rustc$(X_$(CFG_BUILD_TRIPLE))) \
+    do $(call CFG_RUN_TARG_$(CFG_BUILD),1,$(CFG_BUILD)/stage1/rustc$(X_$(CFG_BUILD))) \
        --pretty normal $$i >$$i.tmp; \
     if [ $$? -ne 0 ]; \
         then echo failed to print $$i; rm $$i.tmp; \
index c919509cbab7284bba58b3f886fee7ce21e0b704..d8490230675b866ac815e778e078d4cfbc5a31a5 100644 (file)
--- a/mk/rt.mk
+++ b/mk/rt.mk
@@ -44,7 +44,7 @@ endif
 define DEF_LIBUV_ARCH_VAR
   LIBUV_ARCH_$(1) = $$(subst i386,ia32,$$(subst x86_64,x64,$$(HOST_$(1))))
 endef
-$(foreach t,$(CFG_TARGET_TRIPLES),$(eval $(call DEF_LIBUV_ARCH_VAR,$(t))))
+$(foreach t,$(CFG_TARGET),$(eval $(call DEF_LIBUV_ARCH_VAR,$(t))))
 
 ifdef CFG_ENABLE_FAST_MAKE
 LIBUV_DEPS := $(S)/.gitmodules
@@ -76,7 +76,7 @@ RUNTIME_CXXFLAGS_$(1)_$(2) = -D_RUST_STAGE$(2)
 # XXX: Like with --cfg stage0, pass the defines for stage1 to the stage0
 # build of non-build-triple host compilers
 ifeq ($(2),0)
-ifneq ($(strip $(CFG_BUILD_TRIPLE)),$(strip $(1)))
+ifneq ($(strip $(CFG_BUILD)),$(strip $(1)))
 RUNTIME_CFLAGS_$(1)_$(2) = -D_RUST_STAGE1
 RUNTIME_CXXFLAGS_$(1)_$(2) = -D_RUST_STAGE1
 endif
@@ -131,7 +131,7 @@ $$(RT_BUILD_DIR_$(1)_$(2))/%.o: rt/%.c $$(MKFILE_DEPS)
                  $$(SNAP_DEFINES) $$(RUNTIME_CFLAGS_$(1)_$(2))) $$<
 
 $$(RT_BUILD_DIR_$(1)_$(2))/%.o: rt/%.S  $$(MKFILE_DEPS) \
-                     $$(LLVM_CONFIG_$$(CFG_BUILD_TRIPLE))
+                     $$(LLVM_CONFIG_$$(CFG_BUILD))
        @$$(call E, compile: $$@)
        $$(Q)$$(call CFG_ASSEMBLE_$(1),$$@,$$<)
 
@@ -242,12 +242,11 @@ $$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS) $$(LIBUV_MAKEFILE_$(1))
                NO_LOAD="$$(LIBUV_NO_LOAD)" \
                V=$$(VERBOSE)
 endif
-
 endef
 
 # Instantiate template for all stages/targets
-$(foreach target,$(CFG_TARGET_TRIPLES), \
+$(foreach target,$(CFG_TARGET), \
      $(eval $(call DEF_THIRD_PARTY_TARGETS,$(target))))
 $(foreach stage,$(STAGES), \
-    $(foreach target,$(CFG_TARGET_TRIPLES), \
+    $(foreach target,$(CFG_TARGET), \
         $(eval $(call DEF_RUNTIME_TARGETS,$(target),$(stage)))))
index b543926a4f35008660fa85f9831420253bed7297..c4a9c9c4f0b14b4c49457a309a620f23d73a1c78 100644 (file)
@@ -46,5 +46,5 @@ $(1)/rustllvm/%.o: rustllvm/%.cpp $$(MKFILE_DEPS) $$(LLVM_CONFIG_$(1))
 endef
 
 # Instantiate template for all stages
-$(foreach host,$(CFG_HOST_TRIPLES), \
+$(foreach host,$(CFG_HOST), \
  $(eval $(call DEF_RUSTLLVM_TARGETS,$(host))))
index f4044c91494e75e1a97d5428f8b114854f716887..a7eb71baf6bea82e4dbb2db9374581a06100cb81 100644 (file)
@@ -17,12 +17,12 @@ snap-stage$(1)-H-$(2): $$(HSREQ$(1)_H_$(2))
 
 endef
 
-$(foreach host,$(CFG_HOST_TRIPLES),                                            \
+$(foreach host,$(CFG_HOST),                                            \
  $(eval $(foreach stage,1 2 3,                                                         \
   $(eval $(call DEF_SNAP_FOR_STAGE_H,$(stage),$(host))))))
 
-snap-stage1: snap-stage1-H-$(CFG_BUILD_TRIPLE)
+snap-stage1: snap-stage1-H-$(CFG_BUILD)
 
-snap-stage2: snap-stage2-H-$(CFG_BUILD_TRIPLE)
+snap-stage2: snap-stage2-H-$(CFG_BUILD)
 
-snap-stage3: snap-stage3-H-$(CFG_BUILD_TRIPLE)
+snap-stage3: snap-stage3-H-$(CFG_BUILD)
index e002e656d974ae392963c9106c88f8f2a5611d12..3a678cc04f1d99c7af8639d64f9baddc217cc8cc 100644 (file)
@@ -1,23 +1,23 @@
 # Extract the snapshot host compiler
 
-$(HBIN0_H_$(CFG_BUILD_TRIPLE))/:
+$(HBIN0_H_$(CFG_BUILD))/:
        mkdir -p $@
 
-$(HLIB0_H_$(CFG_BUILD_TRIPLE))/:
+$(HLIB0_H_$(CFG_BUILD))/:
        mkdir -p $@
 
 $(SNAPSHOT_RUSTC_POST_CLEANUP):                                                \
                $(S)src/snapshots.txt                                   \
                $(S)src/etc/get-snapshot.py $(MKFILE_DEPS)              \
-               | $(HBIN0_H_$(CFG_BUILD_TRIPLE))/
+               | $(HBIN0_H_$(CFG_BUILD))/
 
        @$(call E, fetch: $@)
 #   Note: the variable "SNAPSHOT_FILE" is generally not set, and so
 #   we generally only pass one argument to this script.
 ifdef CFG_ENABLE_LOCAL_RUST
-       $(Q)$(S)src/etc/local_stage0.sh $(CFG_BUILD_TRIPLE) $(CFG_LOCAL_RUST_ROOT)
+       $(Q)$(S)src/etc/local_stage0.sh $(CFG_BUILD) $(CFG_LOCAL_RUST_ROOT)
 else
-       $(Q)$(CFG_PYTHON) $(S)src/etc/get-snapshot.py $(CFG_BUILD_TRIPLE) $(SNAPSHOT_FILE)
+       $(Q)$(CFG_PYTHON) $(S)src/etc/get-snapshot.py $(CFG_BUILD) $(SNAPSHOT_FILE)
 ifdef CFG_ENABLE_PAX_FLAGS
        @$(call E, apply PaX flags: $@)
        @"$(CFG_PAXCTL)" -cm "$@"
@@ -27,34 +27,34 @@ endif
 
 # Host libs will be extracted by the above rule
 
-$(HLIB0_H_$(CFG_BUILD_TRIPLE))/$(CFG_RUNTIME_$(CFG_BUILD_TRIPLE)): \
-               $(HBIN0_H_$(CFG_BUILD_TRIPLE))/rustc$(X_$(CFG_BUILD_TRIPLE)) \
-               | $(HLIB0_H_$(CFG_BUILD_TRIPLE))/
+$(HLIB0_H_$(CFG_BUILD))/$(CFG_RUNTIME_$(CFG_BUILD)): \
+               $(HBIN0_H_$(CFG_BUILD))/rustc$(X_$(CFG_BUILD)) \
+               | $(HLIB0_H_$(CFG_BUILD))/
        $(Q)touch $@
 
-$(HLIB0_H_$(CFG_BUILD_TRIPLE))/$(CFG_STDLIB_$(CFG_BUILD_TRIPLE)): \
-               $(HBIN0_H_$(CFG_BUILD_TRIPLE))/rustc$(X_$(CFG_BUILD_TRIPLE)) \
-               | $(HLIB0_H_$(CFG_BUILD_TRIPLE))/
+$(HLIB0_H_$(CFG_BUILD))/$(CFG_STDLIB_$(CFG_BUILD)): \
+               $(HBIN0_H_$(CFG_BUILD))/rustc$(X_$(CFG_BUILD)) \
+               | $(HLIB0_H_$(CFG_BUILD))/
        $(Q)touch $@
 
-$(HLIB0_H_$(CFG_BUILD_TRIPLE))/$(CFG_EXTRALIB_$(CFG_BUILD_TRIPLE)): \
-               $(HBIN0_H_$(CFG_BUILD_TRIPLE))/rustc$(X_$(CFG_BUILD_TRIPLE)) \
-               | $(HLIB0_H_$(CFG_BUILD_TRIPLE))/
+$(HLIB0_H_$(CFG_BUILD))/$(CFG_EXTRALIB_$(CFG_BUILD)): \
+               $(HBIN0_H_$(CFG_BUILD))/rustc$(X_$(CFG_BUILD)) \
+               | $(HLIB0_H_$(CFG_BUILD))/
        $(Q)touch $@
 
-$(HLIB0_H_$(CFG_BUILD_TRIPLE))/$(CFG_LIBRUSTUV_$(CFG_BUILD_TRIPLE)): \
-               $(HBIN0_H_$(CFG_BUILD_TRIPLE))/rustc$(X_$(CFG_BUILD_TRIPLE)) \
+$(HLIB0_H_$(CFG_BUILD_TRIPLE))/$(CFG_LIBRUSTUV_$(CFG_BUILD)): \
+               $(HBIN0_H_$(CFG_BUILD_TRIPLE))/rustc$(X_$(CFG_BUILD)) \
                | $(HLIB0_H_$(CFG_BUILD_TRIPLE))/
        $(Q)touch $@
 
-$(HLIB0_H_$(CFG_BUILD_TRIPLE))/$(CFG_LIBRUSTC_$(CFG_BUILD_TRIPLE)): \
-               $(HBIN0_H_$(CFG_BUILD_TRIPLE))/rustc$(X_$(CFG_BUILD_TRIPLE)) \
+$(HLIB0_H_$(CFG_BUILD_TRIPLE))/$(CFG_LIBRUSTC_$(CFG_BUILD)): \
+               $(HBIN0_H_$(CFG_BUILD_TRIPLE))/rustc$(X_$(CFG_BUILD)) \
                | $(HLIB0_H_$(CFG_BUILD_TRIPLE))/
        $(Q)touch $@
 
-$(HLIB0_H_$(CFG_BUILD_TRIPLE))/$(CFG_RUSTLLVM_$(CFG_BUILD_TRIPLE)): \
-               $(HBIN0_H_$(CFG_BUILD_TRIPLE))/rustc$(X_$(CFG_BUILD_TRIPLE)) \
-               | $(HLIB0_H_$(CFG_BUILD_TRIPLE))/
+$(HLIB0_H_$(CFG_BUILD))/$(CFG_RUSTLLVM_$(CFG_BUILD)): \
+               $(HBIN0_H_$(CFG_BUILD))/rustc$(X_$(CFG_BUILD)) \
+               | $(HLIB0_H_$(CFG_BUILD))/
        $(Q)touch $@
 
 # For other targets, let the host build the target:
@@ -124,5 +124,5 @@ endef
 
 # Use stage1 to build other architectures: then you don't have to wait
 # for stage2, but you get the latest updates to the compiler source.
-$(foreach t,$(NON_BUILD_HOST_TRIPLES),                                                         \
- $(eval $(call BOOTSTRAP_STAGE0,$(t),1,$(CFG_BUILD_TRIPLE))))
+$(foreach t,$(NON_BUILD_HOSTS),                                                                \
+ $(eval $(call BOOTSTRAP_STAGE0,$(t),1,$(CFG_BUILD))))
index e71ca152e9a8134b53049167999dc662ef678135..ac95b2f5c66852bde307ed55218aa5745229d835 100644 (file)
@@ -11,7 +11,7 @@
 # This is the compile-time target-triple for the compiler. For the compiler at
 # runtime, this should be considered the host-triple. More explanation for why
 # this exists can be found on issue #2400
-export CFG_COMPILER_TRIPLE
+export CFG_COMPILER
 
 # The standard libraries should be held up to a higher standard than any old
 # code, make sure that these common warnings are denied by default. These can
@@ -36,7 +36,7 @@ WFLAGS_ST2 = -D warnings
 # had its chance to clean it out; otherwise the other products will be
 # inadvertantly included in the clean out.
 
-SNAPSHOT_RUSTC_POST_CLEANUP=$(HBIN0_H_$(CFG_BUILD_TRIPLE))/rustc$(X_$(CFG_BUILD_TRIPLE))
+SNAPSHOT_RUSTC_POST_CLEANUP=$(HBIN0_H_$(CFG_BUILD))/rustc$(X_$(CFG_BUILD))
 
 define TARGET_STAGE_N
 
@@ -96,7 +96,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)): \
        $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_GLOB_$(2)),$$(notdir $$@))
 
 # Only build the compiler for host triples
-ifneq ($$(findstring $(2),$$(CFG_HOST_TRIPLES)),)
+ifneq ($$(findstring $(2),$$(CFG_HOST)),)
 
 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUSTLLVM_$(3)): \
                $(2)/rustllvm/$(CFG_RUSTLLVM_$(3)) \
@@ -105,7 +105,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUSTLLVM_$(3)): \
        @$$(call E, cp: $$@)
        $$(Q)cp $$< $$@
 
-$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)): CFG_COMPILER_TRIPLE = $(2)
+$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)): CFG_COMPILER = $(2)
 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)):               \
                $$(COMPILER_CRATE) $$(COMPILER_INPUTS)          \
                $$(TSREQ$(1)_T_$(2)_H_$(3)) \
@@ -142,8 +142,8 @@ endif
 endef
 
 # In principle, each host can build each target:
-$(foreach source,$(CFG_HOST_TRIPLES),                          \
- $(foreach target,$(CFG_TARGET_TRIPLES),                       \
+$(foreach source,$(CFG_HOST),                          \
+ $(foreach target,$(CFG_TARGET),                       \
   $(eval $(call TARGET_STAGE_N,0,$(target),$(source)))         \
   $(eval $(call TARGET_STAGE_N,1,$(target),$(source)))         \
   $(eval $(call TARGET_STAGE_N,2,$(target),$(source)))         \
index bf2e878f7f5b3f185049caf5eb2b23a902577197..d228307764f0e5bffcef7ea485b5753efc971dda 100644 (file)
@@ -107,20 +107,20 @@ ifdef CFG_WINDOWSY_$(1)
                stage2/$$(CFG_LIBDIR), \
                $$(if $$(findstring stage3,$$(1)), \
                     stage3/$$(CFG_LIBDIR), \
-               )))))/rustc/$$(CFG_BUILD_TRIPLE)/$$(CFG_LIBDIR)
+               )))))/rustc/$$(CFG_BUILD)/$$(CFG_LIBDIR)
   CFG_RUN_TEST_$(1)=$$(call CFG_RUN_$(1),$$(call CFG_TESTLIB_$(1),$$(1),$$(3)),$$(1))
 endif
 
 # Run the compiletest runner itself under valgrind
 ifdef CTEST_VALGRIND
-CFG_RUN_CTEST_$(1)=$$(call CFG_RUN_TEST_$$(CFG_BUILD_TRIPLE),$$(2),$$(3))
+CFG_RUN_CTEST_$(1)=$$(call CFG_RUN_TEST_$$(CFG_BUILD),$$(2),$$(3))
 else
-CFG_RUN_CTEST_$(1)=$$(call CFG_RUN_$$(CFG_BUILD_TRIPLE),$$(TLIB$$(1)_T_$$(3)_H_$$(3)),$$(2))
+CFG_RUN_CTEST_$(1)=$$(call CFG_RUN_$$(CFG_BUILD),$$(TLIB$$(1)_T_$$(3)_H_$$(3)),$$(2))
 endif
 
 endef
 
-$(foreach target,$(CFG_TARGET_TRIPLES), \
+$(foreach target,$(CFG_TARGET), \
   $(eval $(call DEF_TARGET_COMMANDS,$(target))))
 
 # Target platform specific variables
@@ -129,7 +129,7 @@ define DEF_ADB_DEVICE_STATUS
 CFG_ADB_DEVICE_STATUS=$(1)
 endef
 
-$(foreach target,$(CFG_TARGET_TRIPLES), \
+$(foreach target,$(CFG_TARGET), \
   $(if $(findstring $(target),"arm-linux-androideabi"), \
     $(if $(findstring adb,$(CFG_ADB)), \
       $(if $(findstring device,$(shell $(CFG_ADB) devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \
@@ -158,11 +158,11 @@ $(info check: android device test dir $(CFG_ADB_TEST_DIR) ready \
  $(shell adb push $(S)src/etc/adb_run_wrapper.sh $(CFG_ADB_TEST_DIR) 1>/dev/null) \
  $(shell adb push $(CFG_ANDROID_CROSS_PATH)/arm-linux-androideabi/lib/armv7-a/libgnustl_shared.so \
                   $(CFG_ADB_TEST_DIR) 1>/dev/null) \
- $(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(CFG_RUNTIME_arm-linux-androideabi) \
+ $(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD))/$(CFG_RUNTIME_arm-linux-androideabi) \
                   $(CFG_ADB_TEST_DIR)) \
- $(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(STDLIB_GLOB_arm-linux-androideabi) \
+ $(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD))/$(STDLIB_GLOB_arm-linux-androideabi) \
                   $(CFG_ADB_TEST_DIR)) \
- $(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(EXTRALIB_GLOB_arm-linux-androideabi) \
+ $(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD))/$(EXTRALIB_GLOB_arm-linux-androideabi) \
                   $(CFG_ADB_TEST_DIR)) \
  $(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(LIBRUSTUV_GLOB_arm-linux-androideabi) \
                   $(CFG_ADB_TEST_DIR)) \
@@ -202,7 +202,7 @@ cleantmptestlogs:
        $(Q)rm -f tmp/*.log
 
 cleantestlibs:
-       $(Q)find $(CFG_BUILD_TRIPLE)/test \
+       $(Q)find $(CFG_BUILD)/test \
          -name '*.[odasS]' -o \
          -name '*.so' -o      \
          -name '*.dylib' -o   \
@@ -293,7 +293,7 @@ check-stage$(1)-T-$(2)-H-$(3)-exec:                                 \
 
 # Only test the compiler-dependent crates when the target is
 # able to build a compiler (when the target triple is in the set of host triples)
-ifneq ($$(findstring $(2),$$(CFG_HOST_TRIPLES)),)
+ifneq ($$(findstring $(2),$$(CFG_HOST)),)
 
 check-stage$(1)-T-$(2)-H-$(3)-crates-exec: \
        $$(foreach crate,$$(TEST_CRATES), \
@@ -320,8 +320,8 @@ check-stage$(1)-T-$(2)-H-$(3)-pretty-exec: \
 
 endef
 
-$(foreach host,$(CFG_HOST_TRIPLES), \
- $(foreach target,$(CFG_TARGET_TRIPLES), \
+$(foreach host,$(CFG_HOST), \
+ $(foreach target,$(CFG_TARGET), \
   $(foreach stage,$(STAGES), \
     $(eval $(call DEF_TEST_SETS,$(stage),$(target),$(host))))))
 
@@ -366,7 +366,7 @@ $(3)/stage$(1)/test/syntaxtest-$(2)$$(X_$(2)):                      \
        @$$(call E, compile_and_link: $$@)
        $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
 
-$(3)/stage$(1)/test/rustctest-$(2)$$(X_$(2)): CFG_COMPILER_TRIPLE = $(2)
+$(3)/stage$(1)/test/rustctest-$(2)$$(X_$(2)): CFG_COMPILER = $(2)
 $(3)/stage$(1)/test/rustctest-$(2)$$(X_$(2)):                                  \
                $$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
                $$(SREQ$(1)_T_$(2)_H_$(3)) \
@@ -396,8 +396,8 @@ $(3)/stage$(1)/test/rustdoctest-$(2)$$(X_$(2)):                                     \
 
 endef
 
-$(foreach host,$(CFG_HOST_TRIPLES), \
- $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
+$(foreach host,$(CFG_HOST), \
+ $(eval $(foreach target,$(CFG_TARGET), \
   $(eval $(foreach stage,$(STAGES), \
    $(eval $(call TEST_RUNNER,$(stage),$(target),$(host))))))))
 
@@ -451,11 +451,11 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
        @touch $$@
 endef
 
-$(foreach host,$(CFG_HOST_TRIPLES), \
- $(foreach target,$(CFG_TARGET_TRIPLES), \
+$(foreach host,$(CFG_HOST), \
+ $(foreach target,$(CFG_TARGET), \
   $(foreach stage,$(STAGES), \
    $(foreach crate, $(TEST_CRATES), \
-    $(if $(findstring $(target),$(CFG_BUILD_TRIPLE)), \
+    $(if $(findstring $(target),$(CFG_BUILD)), \
      $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))), \
      $(if $(findstring $(target),"arm-linux-androideabi"), \
       $(if $(findstring $(CFG_ADB_DEVICE_STATUS),"true"), \
@@ -594,7 +594,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) :=                                              \
         --run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3))                      \
         --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3))                       \
         --clang-path $(if $(CFG_CLANG),$(CFG_CLANG),clang) \
-        --llvm-bin-path $(CFG_LLVM_INST_DIR_$(CFG_BUILD_TRIPLE))/bin \
+        --llvm-bin-path $(CFG_LLVM_INST_DIR_$(CFG_BUILD))/bin \
         --aux-base $$(S)src/test/auxiliary/                 \
         --stage-id stage$(1)-$(2)                                                      \
         --target $(2)                                       \
@@ -614,8 +614,8 @@ CTEST_DEPS_codegen_$(1)-T-$(2)-H-$(3) = $$(CODEGEN_TESTS)
 
 endef
 
-$(foreach host,$(CFG_HOST_TRIPLES), \
- $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
+$(foreach host,$(CFG_HOST), \
+ $(eval $(foreach target,$(CFG_TARGET), \
   $(eval $(foreach stage,$(STAGES), \
    $(eval $(call DEF_CTEST_VARS,$(stage),$(target),$(host))))))))
 
@@ -657,8 +657,8 @@ endef
 
 CTEST_NAMES = rpass rpass-full rfail cfail bench perf debuginfo codegen
 
-$(foreach host,$(CFG_HOST_TRIPLES), \
- $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
+$(foreach host,$(CFG_HOST), \
+ $(eval $(foreach target,$(CFG_TARGET), \
   $(eval $(foreach stage,$(STAGES), \
    $(eval $(foreach name,$(CTEST_NAMES), \
    $(eval $(call DEF_RUN_COMPILETEST,$(stage),$(target),$(host),$(name))))))))))
@@ -696,8 +696,8 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
 
 endef
 
-$(foreach host,$(CFG_HOST_TRIPLES), \
- $(foreach target,$(CFG_TARGET_TRIPLES), \
+$(foreach host,$(CFG_HOST), \
+ $(foreach target,$(CFG_TARGET), \
   $(foreach stage,$(STAGES), \
    $(foreach pretty-name,$(PRETTY_NAMES), \
     $(eval $(call DEF_RUN_PRETTY_TEST,$(stage),$(target),$(host),$(pretty-name)))))))
@@ -723,8 +723,8 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): \
 
 endef
 
-$(foreach host,$(CFG_HOST_TRIPLES), \
- $(foreach target,$(CFG_TARGET_TRIPLES), \
+$(foreach host,$(CFG_HOST), \
+ $(foreach target,$(CFG_TARGET), \
   $(foreach stage,$(STAGES), \
    $(foreach docname,$(DOC_TEST_NAMES), \
     $(eval $(call DEF_RUN_DOC_TEST,$(stage),$(target),$(host),$(docname)))))))
@@ -745,7 +745,7 @@ doc-$(2)-extract$(1):
 
 endef
 
-$(foreach host,$(CFG_HOST_TRIPLES), \
+$(foreach host,$(CFG_HOST), \
  $(foreach docname,$(DOC_TEST_NAMES), \
   $(eval $(call DEF_DOC_TEST_HOST,$(host),$(docname)))))
 
@@ -780,8 +780,8 @@ check-stage$(1)-T-$(2)-H-$(3): check-stage$(1)-T-$(2)-H-$(3)-exec
 endef
 
 $(foreach stage,$(STAGES), \
- $(foreach target,$(CFG_TARGET_TRIPLES), \
-  $(foreach host,$(CFG_HOST_TRIPLES), \
+ $(foreach target,$(CFG_TARGET), \
+  $(foreach host,$(CFG_HOST), \
    $(eval $(call DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST,$(stage),$(target),$(host))))))
 
 define DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST_AND_GROUP
@@ -789,14 +789,14 @@ check-stage$(1)-T-$(2)-H-$(3)-$(4): check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec
 endef
 
 $(foreach stage,$(STAGES), \
- $(foreach target,$(CFG_TARGET_TRIPLES), \
-  $(foreach host,$(CFG_HOST_TRIPLES), \
+ $(foreach target,$(CFG_TARGET), \
+  $(foreach host,$(CFG_HOST), \
    $(foreach group,$(TEST_GROUPS), \
     $(eval $(call DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST_AND_GROUP,$(stage),$(target),$(host),$(group)))))))
 
 define DEF_CHECK_FOR_STAGE
-check-stage$(1): check-stage$(1)-H-$$(CFG_BUILD_TRIPLE)
-check-stage$(1)-H-all: $$(foreach target,$$(CFG_TARGET_TRIPLES), \
+check-stage$(1): check-stage$(1)-H-$$(CFG_BUILD)
+check-stage$(1)-H-all: $$(foreach target,$$(CFG_TARGET), \
                            check-stage$(1)-H-$$(target))
 endef
 
@@ -804,8 +804,8 @@ $(foreach stage,$(STAGES), \
  $(eval $(call DEF_CHECK_FOR_STAGE,$(stage))))
 
 define DEF_CHECK_FOR_STAGE_AND_GROUP
-check-stage$(1)-$(2): check-stage$(1)-H-$$(CFG_BUILD_TRIPLE)-$(2)
-check-stage$(1)-H-all-$(2): $$(foreach target,$$(CFG_TARGET_TRIPLES), \
+check-stage$(1)-$(2): check-stage$(1)-H-$$(CFG_BUILD)-$(2)
+check-stage$(1)-H-all-$(2): $$(foreach target,$$(CFG_TARGET), \
                                check-stage$(1)-H-$$(target)-$(2))
 endef
 
@@ -815,21 +815,21 @@ $(foreach stage,$(STAGES), \
 
 
 define DEF_CHECK_FOR_STAGE_AND_HOSTS
-check-stage$(1)-H-$(2): $$(foreach target,$$(CFG_TARGET_TRIPLES), \
+check-stage$(1)-H-$(2): $$(foreach target,$$(CFG_TARGET), \
                            check-stage$(1)-T-$$(target)-H-$(2))
 endef
 
 $(foreach stage,$(STAGES), \
- $(foreach host,$(CFG_HOST_TRIPLES), \
+ $(foreach host,$(CFG_HOST), \
   $(eval $(call DEF_CHECK_FOR_STAGE_AND_HOSTS,$(stage),$(host)))))
 
 define DEF_CHECK_FOR_STAGE_AND_HOSTS_AND_GROUP
-check-stage$(1)-H-$(2)-$(3): $$(foreach target,$$(CFG_TARGET_TRIPLES), \
+check-stage$(1)-H-$(2)-$(3): $$(foreach target,$$(CFG_TARGET), \
                                 check-stage$(1)-T-$$(target)-H-$(2)-$(3))
 endef
 
 $(foreach stage,$(STAGES), \
- $(foreach host,$(CFG_HOST_TRIPLES), \
+ $(foreach host,$(CFG_HOST), \
   $(foreach group,$(TEST_GROUPS), \
    $(eval $(call DEF_CHECK_FOR_STAGE_AND_HOSTS_AND_GROUP,$(stage),$(host),$(group))))))
 
@@ -838,7 +838,7 @@ $(foreach stage,$(STAGES), \
 ######################################################################
 
 FT := run_pass_stage2
-FT_LIB := $(call CFG_LIB_NAME_$(CFG_BUILD_TRIPLE),$(FT))
+FT_LIB := $(call CFG_LIB_NAME_$(CFG_BUILD),$(FT))
 FT_DRIVER := $(FT)_driver
 
 GENERATED += tmp/$(FT).rc tmp/$(FT_DRIVER).rs
@@ -878,11 +878,11 @@ check-fast-T-$(2)-H-$(3):                         \
 
 endef
 
-$(foreach host,$(CFG_HOST_TRIPLES), \
- $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
+$(foreach host,$(CFG_HOST), \
+ $(eval $(foreach target,$(CFG_TARGET), \
    $(eval $(call DEF_CHECK_FAST_FOR_T_H,,$(target),$(host))))))
 
-check-fast: tidy check-fast-H-$(CFG_BUILD_TRIPLE) check-stage2-std check-stage2-extra
+check-fast: tidy check-fast-H-$(CFG_BUILD) check-stage2-std check-stage2-extra
        $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
 
 define DEF_CHECK_FAST_FOR_H
@@ -891,5 +891,5 @@ check-fast-H-$(1):          check-fast-T-$(1)-H-$(1)
 
 endef
 
-$(foreach host,$(CFG_HOST_TRIPLES),                    \
+$(foreach host,$(CFG_HOST),                    \
  $(eval $(call DEF_CHECK_FAST_FOR_H,$(host))))
index a9ea12b5b24edcc2a306928ea4e662c81ad481c0..ed4ae10e3e2378564a8a51679e3468eeec6423ec 100644 (file)
@@ -127,14 +127,14 @@ $$(HBIN$(2)_H_$(4))/rustdoc$$(X_$(4)):                            \
 
 endef
 
-$(foreach host,$(CFG_HOST_TRIPLES),                            \
-$(foreach target,$(CFG_TARGET_TRIPLES),                                \
+$(foreach host,$(CFG_HOST),                            \
+$(foreach target,$(CFG_TARGET),                                \
  $(eval $(call TOOLS_STAGE_N_TARGET,0,1,$(host),$(target)))    \
  $(eval $(call TOOLS_STAGE_N_TARGET,1,2,$(host),$(target)))    \
  $(eval $(call TOOLS_STAGE_N_TARGET,2,3,$(host),$(target)))    \
  $(eval $(call TOOLS_STAGE_N_TARGET,3,bogus,$(host),$(target)))))
 
-$(foreach host,$(CFG_HOST_TRIPLES),                            \
+$(foreach host,$(CFG_HOST),                            \
  $(eval $(call TOOLS_STAGE_N_HOST,0,1,$(host),$(host)))        \
  $(eval $(call TOOLS_STAGE_N_HOST,1,2,$(host),$(host)))        \
  $(eval $(call TOOLS_STAGE_N_HOST,2,3,$(host),$(host))))
index 51c0da39bd5ac167df3222ce41c469389870b137..263c76a88ddcab885664cbe9452dcf55a6293003 100755 (executable)
@@ -19,7 +19,7 @@ from math import exp, sqrt, log, floor
 import random
 
 # The order should match the return value of `tables`
-TABLE_NAMES = ['X', 'F', 'F_DIFF']
+TABLE_NAMES = ['X', 'F']
 
 # The actual length of the table is 1 more, to stop
 # index-out-of-bounds errors. This should match the bitwise operation
@@ -43,13 +43,10 @@ def tables(r, v, f, f_inv):
 
     # cache the f's
     fvec = [0]*(TABLE_LEN+1)
-    fdiff = [0]*(TABLE_LEN+1)
     for i in range(TABLE_LEN+1):
         fvec[i] = f(xvec[i])
-        if i > 0:
-            fdiff[i] = fvec[i] - fvec[i-1]
 
-    return xvec, fvec, fdiff
+    return xvec, fvec
 
 # Distributions
 # N(0, 1)
index 90434cf0d4912ad0569ecb6d10c890d89d6801eb..c6fc41e683161ed64d4ef3e0d286cbd16709c7e2 100644 (file)
@@ -118,6 +118,8 @@ pub mod extra {
     pub use std::clone;
     pub use std::condition;
     pub use std::cmp;
+    // NOTE: Remove import after next snapshot
+    #[cfg(stage0)]
     pub use std::sys;
     pub use std::unstable;
     pub use std::str;
index 7ef9ba76b995d481e57edd6507b790457f91ac13..db5b12f021e5f3cc21efa4d3c43ee8275ed8d831 100644 (file)
@@ -145,7 +145,7 @@ pub fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool) -> bool {
     pub fn iter<'a>(&'a self) -> TreeMapIterator<'a, K, V> {
         TreeMapIterator {
             stack: ~[],
-            node: &self.root,
+            node: deref(&self.root),
             remaining_min: self.length,
             remaining_max: self.length
         }
@@ -162,7 +162,7 @@ pub fn rev_iter<'a>(&'a self) -> TreeMapRevIterator<'a, K, V> {
     fn iter_for_traversal<'a>(&'a self) -> TreeMapIterator<'a, K, V> {
         TreeMapIterator {
             stack: ~[],
-            node: &self.root,
+            node: deref(&self.root),
             remaining_min: 0,
             remaining_max: self.length
         }
@@ -173,8 +173,8 @@ fn iter_for_traversal<'a>(&'a self) -> TreeMapIterator<'a, K, V> {
     pub fn lower_bound_iter<'a>(&'a self, k: &K) -> TreeMapIterator<'a, K, V> {
         let mut iter: TreeMapIterator<'a, K, V> = self.iter_for_traversal();
         loop {
-            match *iter.node {
-              Some(ref r) => {
+            match iter.node {
+              Some(r) => {
                 match k.cmp(&r.key) {
                   Less => iter_traverse_left(&mut iter),
                   Greater => iter_traverse_right(&mut iter),
@@ -197,8 +197,8 @@ pub fn lower_bound_iter<'a>(&'a self, k: &K) -> TreeMapIterator<'a, K, V> {
     pub fn upper_bound_iter<'a>(&'a self, k: &K) -> TreeMapIterator<'a, K, V> {
         let mut iter: TreeMapIterator<'a, K, V> = self.iter_for_traversal();
         loop {
-            match *iter.node {
-              Some(ref r) => {
+            match iter.node {
+              Some(r) => {
                 match k.cmp(&r.key) {
                   Less => iter_traverse_left(&mut iter),
                   Greater => iter_traverse_right(&mut iter),
@@ -229,24 +229,34 @@ pub fn move_iter(self) -> TreeMapMoveIterator<K, V> {
 
 /// Lazy forward iterator over a map
 pub struct TreeMapIterator<'self, K, V> {
-    priv stack: ~[&'self ~TreeNode<K, V>],
-    priv node: &'self Option<~TreeNode<K, V>>,
+    priv stack: ~[&'self TreeNode<K, V>],
+    priv node: Option<&'self TreeNode<K, V>>,
     priv remaining_min: uint,
     priv remaining_max: uint
 }
 
+fn deref<'a, K, V>(node: &'a Option<~TreeNode<K, V>>) -> Option<&'a TreeNode<K, V>> {
+    match *node {
+        Some(ref n) => {
+            let n: &TreeNode<K, V> = *n;
+            Some(n)
+        }
+        None => None
+    }
+}
+
 impl<'self, K, V> TreeMapIterator<'self, K, V> {
     #[inline(always)]
     fn next_(&mut self, forward: bool) -> Option<(&'self K, &'self V)> {
         while !self.stack.is_empty() || self.node.is_some() {
-            match *self.node {
-              Some(ref x) => {
+            match self.node {
+              Some(x) => {
                 self.stack.push(x);
-                self.node = if forward { &x.left } else { &x.right };
+                self.node = deref(if forward { &x.left } else { &x.right });
               }
               None => {
                 let res = self.stack.pop();
-                self.node = if forward { &res.right } else { &res.left };
+                self.node = deref(if forward { &res.right } else { &res.left });
                 self.remaining_max -= 1;
                 if self.remaining_min > 0 {
                     self.remaining_min -= 1;
@@ -302,14 +312,14 @@ fn size_hint(&self) -> (uint, Option<uint>) {
 ///   - complete initialization with `iter_traverse_complete`
 #[inline]
 fn iter_traverse_left<'a, K, V>(it: &mut TreeMapIterator<'a, K, V>) {
-    let node = it.node.get_ref();
+    let node = it.node.unwrap();
     it.stack.push(node);
-    it.node = &node.left;
+    it.node = deref(&node.left);
 }
 
 #[inline]
 fn iter_traverse_right<'a, K, V>(it: &mut TreeMapIterator<'a, K, V>) {
-    it.node = &(it.node.get_ref().right);
+    it.node = deref(&it.node.get_ref().right);
 }
 
 /// iter_traverse_left, iter_traverse_right and iter_traverse_complete are used to
@@ -321,11 +331,10 @@ fn iter_traverse_right<'a, K, V>(it: &mut TreeMapIterator<'a, K, V>) {
 /// traversed left.
 #[inline]
 fn iter_traverse_complete<'a, K, V>(it: &mut TreeMapIterator<'a, K, V>) {
-    static none: Option<~TreeNode<K, V>> = None;
-    match *it.node {
-        Some(ref n) => {
+    match it.node {
+        Some(n) => {
             it.stack.push(n);
-            it.node = &none;
+            it.node = None;
         }
         None => ()
     }
index 8aba36370d0b8888d427efce708dc7e4eeb846af..fb593b56e15f5d73872585b8a8288e794da254df 100644 (file)
@@ -643,7 +643,7 @@ pub fn host_triple() -> ~str {
     // Instead of grabbing the host triple (for the current host), we grab (at
     // compile time) the target triple that this rustc is built with and
     // calling that (at runtime) the host triple.
-    (env!("CFG_COMPILER_TRIPLE")).to_owned()
+    (env!("CFG_COMPILER")).to_owned()
 }
 
 pub fn build_session_options(binary: @str,
index c17d6cabfed4f924f8f233e992a960596034eaca..c4337abb740927d3e7b46be3b6fb0f13a7b418e5 100644 (file)
@@ -140,12 +140,12 @@ fn visit_ty(&mut self, t: &ast::Ty, _: ()) {
 
             },
             ast::ty_box(_) => {
-                self.gate_feature("managed_boxes", t.span, "The managed box syntax may be replaced \
-                                                            by a library type, and a garbage \
-                                                            collector is not yet implemented. \
-                                                            Consider using the `std::rc` module \
-                                                            as it performs much better as a \
-                                                            reference counting implementation.");
+                self.gate_feature("managed_boxes", t.span,
+                                  "The managed box syntax will be replaced \
+                                  by a library type, and a garbage \
+                                  collector is not yet implemented. \
+                                  Consider using the `std::rc::Rc` type \
+                                  for reference counted pointers.");
             }
             _ => {}
         }
index 8c5deeb94d58ea37b7514f1777c242f6e966aedf..9f848b4c2276c335d20e8fba84dcc42d5318d691 100644 (file)
@@ -3488,10 +3488,17 @@ fn upvarify(&mut self,
                     return None;
                 }
                 ConstantItemRibKind => {
-                    // Still doesn't deal with upvars
-                    self.resolve_error(span,
-                                          "attempt to use a non-constant \
-                                           value in a constant");
+                    if is_ty_param {
+                        // see #9186
+                        self.resolve_error(span,
+                                              "cannot use an outer type \
+                                               parameter in this context");
+                    } else {
+                        // Still doesn't deal with upvars
+                        self.resolve_error(span,
+                                              "attempt to use a non-constant \
+                                               value in a constant");
+                    }
 
                 }
             }
@@ -3764,7 +3771,9 @@ fn with_label_rib(&mut self, f: &fn(&mut Resolver)) {
 
     fn with_constant_rib(&mut self, f: &fn(&mut Resolver)) {
         self.value_ribs.push(@Rib::new(ConstantItemRibKind));
+        self.type_ribs.push(@Rib::new(ConstantItemRibKind));
         f(self);
+        self.type_ribs.pop();
         self.value_ribs.pop();
     }
 
index 2f8c1f6f97d5915be098c357e13bfb66bc5326a3..ab1ca420afab15b850f6ee0bf9353688864f7de6 100644 (file)
@@ -308,10 +308,11 @@ fn bare_fn_to_str(cx: ctxt,
                       ident: Option<ast::Ident>,
                       sig: &ty::FnSig)
                       -> ~str {
-        let mut s = ~"extern ";
-
-        s.push_str(abis.to_str());
-        s.push_char(' ');
+        let mut s = if abis.is_rust() {
+            ~""
+        } else {
+            format!("extern {} ", abis.to_str())
+        };
 
         match purity {
             ast::impure_fn => {}
@@ -331,16 +332,16 @@ fn bare_fn_to_str(cx: ctxt,
           _ => { }
         }
 
-        push_sig_to_str(cx, &mut s, sig);
+        push_sig_to_str(cx, &mut s, '(', ')', sig);
 
         return s;
     }
-    fn closure_to_str(cx: ctxt, cty: &ty::ClosureTy) -> ~str
-    {
+    fn closure_to_str(cx: ctxt, cty: &ty::ClosureTy) -> ~str {
         let is_proc =
             (cty.sigil, cty.onceness) == (ast::OwnedSigil, ast::Once);
+        let is_borrowed_closure = cty.sigil == ast::BorrowedSigil;
 
-        let mut s = if is_proc {
+        let mut s = if is_proc || is_borrowed_closure {
             ~""
         } else {
             cty.sigil.to_str()
@@ -374,23 +375,42 @@ fn closure_to_str(cx: ctxt, cty: &ty::ClosureTy) -> ~str
                 }
             };
 
-            s.push_str("fn");
+            if !is_borrowed_closure {
+                s.push_str("fn");
+            }
         }
 
-        if !cty.bounds.is_empty() {
-            s.push_str(":");
-        }
-        s.push_str(cty.bounds.repr(cx));
+        if !is_borrowed_closure {
+            // Print bounds before `fn` if this is not a borrowed closure.
+            if !cty.bounds.is_empty() {
+                s.push_str(":");
+                s.push_str(cty.bounds.repr(cx));
+            }
+
+            push_sig_to_str(cx, &mut s, '(', ')', &cty.sig);
+        } else {
+            // Print bounds after the signature if this is a borrowed closure.
+            push_sig_to_str(cx, &mut s, '|', '|', &cty.sig);
 
-        push_sig_to_str(cx, &mut s, &cty.sig);
+            if is_borrowed_closure {
+                if !cty.bounds.is_empty() {
+                    s.push_str(":");
+                    s.push_str(cty.bounds.repr(cx));
+                }
+            }
+        }
 
         return s;
     }
-    fn push_sig_to_str(cx: ctxt, s: &mut ~str, sig: &ty::FnSig) {
-        s.push_char('(');
+    fn push_sig_to_str(cx: ctxt,
+                       s: &mut ~str,
+                       bra: char,
+                       ket: char,
+                       sig: &ty::FnSig) {
+        s.push_char(bra);
         let strs = sig.inputs.map(|a| fn_input_to_str(cx, *a));
         s.push_str(strs.connect(", "));
-        s.push_char(')');
+        s.push_char(ket);
         if ty::get(sig.output).sty != ty_nil {
             s.push_str(" -> ");
             if ty::type_is_bot(sig.output) {
index 8ea3e2ddcc67a8c0205fb4d2617f063bdae6a756..37910cef60eca507c83cfe218eee692acb74d2e0 100644 (file)
@@ -1653,9 +1653,6 @@ fn tell(&self) -> Result<u64, IoError> {
         let self_ = unsafe { cast::transmute::<&UvFileStream, &mut UvFileStream>(self) };
         self_.seek_common(0, SEEK_CUR)
     }
-    fn flush(&mut self) -> Result<(), IoError> {
-        Ok(())
-    }
 }
 
 pub struct UvProcess {
index e7bcf8ce5d3a71d0c0d14e41b6199cc0a1093c3a..a6fa1a2bd875fb3220d148ba36aedd15d75103b7 100644 (file)
@@ -207,7 +207,6 @@ fn ziggurat<R:Rng>(rng: &mut R,
                    symmetric: bool,
                    X: ziggurat_tables::ZigTable,
                    F: ziggurat_tables::ZigTable,
-                   F_DIFF: ziggurat_tables::ZigTable,
                    pdf: &'static fn(f64) -> f64,
                    zero_case: &'static fn(&mut R, f64) -> f64) -> f64 {
     static SCALE: f64 = (1u64 << 53) as f64;
@@ -237,7 +236,7 @@ fn ziggurat<R:Rng>(rng: &mut R,
             return zero_case(rng, u);
         }
         // algebraically equivalent to f1 + DRanU()*(f0 - f1) < 1
-        if F[i + 1] + F_DIFF[i + 1] * rng.gen() < pdf(x) {
+        if F[i + 1] + (F[i] - F[i + 1]) * rng.gen() < pdf(x) {
             return x;
         }
     }
@@ -288,7 +287,7 @@ fn zero_case<R:Rng>(rng: &mut R, u: f64) -> f64 {
             rng,
             true, // this is symmetric
             &ziggurat_tables::ZIG_NORM_X,
-            &ziggurat_tables::ZIG_NORM_F, &ziggurat_tables::ZIG_NORM_F_DIFF,
+            &ziggurat_tables::ZIG_NORM_F,
             pdf, zero_case))
     }
 }
@@ -366,7 +365,7 @@ fn zero_case<R:Rng>(rng: &mut R, _u: f64) -> f64 {
 
         Exp1(ziggurat(rng, false,
                       &ziggurat_tables::ZIG_EXP_X,
-                      &ziggurat_tables::ZIG_EXP_F, &ziggurat_tables::ZIG_EXP_F_DIFF,
+                      &ziggurat_tables::ZIG_EXP_F,
                       pdf, zero_case))
     }
 }
index aca2457cac42c282dc10355e1ba38e827a7da40f..049ef3dbb5936933b894b9dfe9891fa872affa97 100644 (file)
      0.887984660763399880, 0.898095921906304051, 0.908726440060562912, 0.919991505048360247,
      0.932060075968990209, 0.945198953453078028, 0.959879091812415930, 0.977101701282731328,
      1.000000000000000000];
-pub static ZIG_NORM_F_DIFF: [f64, .. 257] =
-    [0.000000000000000000, 0.000782818165911943, 0.001348786815607765, 0.001428899847265509,
-     0.001484430705892882, 0.001528472172127356, 0.001565707298030807, 0.001598388670308183,
-     0.001627786418212004, 0.001654692743837703, 0.001679637706201265, 0.001702994844613767,
-     0.001725038123187510, 0.001745974954326004, 0.001765966477270568, 0.001785140598493315,
-     0.001803600702759419, 0.001821431661060659, 0.001838704088536796, 0.001855477433793579,
-     0.001871802266665008, 0.001887722003144375, 0.001903274226858077, 0.001918491715965767,
-     0.001933403251421835, 0.001948034260540625, 0.001962407334827158, 0.001976542650643127,
-     0.001990458313945481, 0.002004170645086643, 0.002017694415851860, 0.002031043048104267,
-     0.002044228781321551, 0.002057262814738517, 0.002070155428613822, 0.002082916088226049,
-     0.002095553533492583, 0.002108075856553551, 0.002120490569226280, 0.002132804661891696,
-     0.002145024655099026, 0.002157156644953973, 0.002169206343177243, 0.002181179112575302,
-     0.002193079998548175, 0.002204913757158977, 0.002216684880213121, 0.002228397617726446,
-     0.002240055998106505, 0.002251663846325885, 0.002263224800326716, 0.002274742325862292,
-     0.002286219729956393, 0.002297660173134250, 0.002309066680560787, 0.002320442152205823,
-     0.002331789372137141, 0.002343111017035562, 0.002354409664009627, 0.002365687797781804,
-     0.002376947817308683, 0.002388192041889739, 0.002399422716815966, 0.002410642018598946,
-     0.002421852059823287, 0.002433054893654529, 0.002444252518034679, 0.002455446879594508,
-     0.002466639877306970, 0.002477833365903986, 0.002489029159078809, 0.002500229032490808,
-     0.002511434726590794, 0.002522647949281448, 0.002533870378427505, 0.002545103664226889,
-     0.002556349431455662, 0.002567609281597438, 0.002578884794865288, 0.002590177532127119,
-     0.002601489036740262, 0.002612820836305291, 0.002624174444343735, 0.002635551361907296,
-     0.002646953079123743, 0.002658381076686089, 0.002669836827288052, 0.002681321797012387,
-     0.002692837446676144, 0.002704385233135737, 0.002715966610556786, 0.002727583031652520,
-     0.002739235948893221, 0.002750926815690169, 0.002762657087557796, 0.002774428223256353,
-     0.002786241685917290, 0.002798098944155558, 0.002810001473169871, 0.002821950755833219,
-     0.002833948283778004, 0.002845995558475284, 0.002858094092312607, 0.002870245409671041,
-     0.002882451048004164, 0.002894712558920987, 0.002907031509275432, 0.002919409482262880,
-     0.002931848078526783, 0.002944348917277934, 0.002956913637427061, 0.002969543898733384,
-     0.002982241382970874, 0.002995007795115689, 0.003007844864553855, 0.003020754346314269,
-     0.003033738022328147, 0.003046797702715820, 0.003059935227105459, 0.003073152465984053,
-     0.003086451322084072, 0.003099833731808721, 0.003113301666695822, 0.003126857134927052,
-     0.003140502182881588, 0.003154238896738770, 0.003168069404132778, 0.003181995875862154,
-     0.003196020527657495, 0.003210145622009941, 0.003224373470066433, 0.003238706433592253,
-     0.003253146927007733, 0.003267697419501892, 0.003282360437226572, 0.003297138565578506,
-     0.003312034451571411, 0.003327050806304299, 0.003342190407532641, 0.003357456102345890,
-     0.003372850809960137, 0.003388377524629727, 0.003404039318688046, 0.003419839345721265,
-     0.003435780843885239, 0.003451867139373843, 0.003468101650046629, 0.003484487889225119,
-     0.003501029469670069, 0.003517730107746697, 0.003534593627793237, 0.003551623966702611,
-     0.003568825178730639, 0.003586201440546166, 0.003603757056536316, 0.003621496464384588,
-     0.003639424240937217, 0.003657545108379068, 0.003675863940735269, 0.003694385770723563,
-     0.003713115796977806, 0.003732059391668707, 0.003751222108547281, 0.003770609691440940,
-     0.003790228083232539, 0.003810083435355216, 0.003830182117840641, 0.003850530729957835,
-     0.003871136111486317, 0.003892005354668437, 0.003913145816891062, 0.003934565134149914,
-     0.003956271235355358, 0.003978272357543333, 0.004000577062061084, 0.004023194251800533,
-     0.004046133189565926, 0.004069403517661885, 0.004093015278800460, 0.004116978938436600,
-     0.004141305408647655, 0.004166006073685835, 0.004191092817346642, 0.004216578052307351,
-     0.004242474751606884, 0.004268796482457593, 0.004295557442594244, 0.004322772499391836,
-     0.004350457232007221, 0.004378627976825644, 0.004407301876525049, 0.004436496933105327,
-     0.004466232065271192, 0.004496527170598785, 0.004527403192966406, 0.004558882195791591,
-     0.004590987441673855, 0.004623743479123199, 0.004657176237135574, 0.004691313128472929,
-     0.004726183162616859, 0.004761817069491636, 0.004798247435199299, 0.004835508851176451,
-     0.004873638078381815, 0.004912674228345848, 0.004952658963181422, 0.004993636716962402,
-     0.005035654941235035, 0.005078764377854039, 0.005123019362831771, 0.005168478165478940,
-     0.005215203367812893, 0.005263262290042703, 0.005312727468930079, 0.005363677197016692,
-     0.005416196132139284, 0.005470375988385734, 0.005526316321746716, 0.005584125426278286,
-     0.005643921359735682, 0.005705833121505521, 0.005770002010457520, 0.005836583196307310,
-     0.005905747545561058, 0.005977683752542928, 0.006052600837980204, 0.006130731092920838,
-     0.006212333565464245, 0.006297698213369562, 0.006387150879090475, 0.006481059288027780,
-     0.006579840329791975, 0.006683968961788356, 0.006793989182803495, 0.006910527673723577,
-     0.007034310911336661, 0.007166186857056056, 0.007307152748134871, 0.007458391141830445,
-     0.007621317291194862, 0.007797642342679434, 0.007989459040836144, 0.008199360125510702,
-     0.008430605346682607, 0.008687362737884952, 0.008975066840784529, 0.009300967772353674,
-     0.009675004947253041, 0.010111261142904171, 0.010630518154258861, 0.011265064987797335,
-     0.012068570920629962, 0.013138877484087819, 0.014680138359337902, 0.017222609470315398,
-     0.022898298717268672];
 pub static ZIG_EXP_R: f64 = 7.697117470131050077;
 pub static ZIG_EXP_X: [f64, .. 257] =
     [8.697117470131052741, 7.697117470131050077, 6.941033629377212577, 6.478378493832569696,
      0.775956852040116218, 0.791527636972496285, 0.808421651523009044, 0.826993296643051101,
      0.847785500623990496, 0.871704332381204705, 0.900469929925747703, 0.938143680862176477,
      1.000000000000000000];
-pub static ZIG_EXP_F_DIFF: [f64, .. 257] =
-    [0.000000000000000000, 0.000287067661533533, 0.000513134928485678, 0.000569030497974398,
-     0.000609667963417335, 0.000642831049855169, 0.000671465984262828, 0.000697030342996893,
-     0.000720360862708599, 0.000741986223663093, 0.000762263730113694, 0.000781447246315807,
-     0.000799724254382053, 0.000817237547791934, 0.000834098656693235, 0.000850396538527769,
-     0.000866203416804620, 0.000881578828420777, 0.000896572504999613, 0.000911226471926952,
-     0.000925576608509206, 0.000939653828282008, 0.000953484986066785, 0.000967093584871414,
-     0.000980500333784669, 0.000993723593313716, 0.001006779734568374, 0.001019683431705467,
-     0.001032447902101660, 0.001045085105172934, 0.001057605908173612, 0.001070020225402434,
-     0.001082337135821582, 0.001094564983022843, 0.001106711460658764, 0.001118783685829211,
-     0.001130788262427001, 0.001142731336065933, 0.001154618641914802, 0.001166455546523074,
-     0.001178247084534012, 0.001189997991027938, 0.001201712730115490, 0.001213395520299268,
-     0.001225050357040701, 0.001236681032901414, 0.001248291155571943, 0.001259884164055092,
-     0.001271463343231895, 0.001283031837006378, 0.001294592660197942, 0.001306148709326875,
-     0.001317702772419903, 0.001329257537945404, 0.001340815602974395, 0.001352379480650950,
-     0.001363951607045839, 0.001375534347457789, 0.001387130002219621, 0.001398740812059381,
-     0.001410368963061376, 0.001422016591266340, 0.001433685786946429, 0.001445378598586011,
-     0.001457097036596827, 0.001468843076792140, 0.001480618663643060, 0.001492425713336909,
-     0.001504266116655995, 0.001516141741693663, 0.001528054436422108, 0.001540006031125918,
-     0.001551998340713470, 0.001564033166917514, 0.001576112300394977, 0.001588237522735750,
-     0.001600410608388780, 0.001612633326513305, 0.001624907442762655, 0.001637234721007311,
-     0.001649616925003372, 0.001662055820012304, 0.001674553174376953, 0.001687110761059388,
-     0.001699730359144919, 0.001712413755316500, 0.001725162745304071, 0.001737979135312442,
-     0.001750864743431488, 0.001763821401032123, 0.001776850954151601, 0.001789955264870927,
-     0.001803136212688003, 0.001816395695889220, 0.001829735632922019, 0.001843157963772116,
-     0.001856664651347151, 0.001870257682870316, 0.001883939071285826, 0.001897710856679738,
-     0.001911575107717528, 0.001925533923102574, 0.001939589433056721, 0.001953743800826108,
-     0.001967999224215228, 0.001982357937151347, 0.001996822211282223, 0.002011394357609747,
-     0.002026076728162574, 0.002040871717710169, 0.002055781765521847, 0.002070809357173103,
-     0.002085957026402963, 0.002101227357025226, 0.002116622984897121, 0.002132146599948981,
-     0.002147800948277823, 0.002163588834309782, 0.002179513123034188, 0.002195576742314159,
-     0.002211782685277469, 0.002228134012792427, 0.002244633856033434, 0.002261285419141418,
-     0.002278091981983449, 0.002295056903017983, 0.002312183622271174, 0.002329475664429648,
-     0.002346936642057179, 0.002364570258941101, 0.002382380313575932, 0.002400370702791893,
-     0.002418545425535629, 0.002436908586812392, 0.002455464401797752, 0.002474217200128692,
-     0.002493171430384328, 0.002512331664766249, 0.002531702603989994, 0.002551289082400404,
-     0.002571096073321844, 0.002591128694658967, 0.002611392214760672, 0.002631892058563845,
-     0.002652633814032662, 0.002673623238910738, 0.002694866267805934, 0.002716369019626269,
-     0.002738137805389534, 0.002760179136428037, 0.002782499733014893, 0.002805106533435520,
-     0.002828006703534697, 0.002851207646767162, 0.002874717014785921, 0.002898542718600849,
-     0.002922692940346749, 0.002947176145699226, 0.002972001096982591, 0.002997176867015228,
-     0.003022712853742948, 0.003048618795714386, 0.003074904788455568, 0.003101581301807876,
-     0.003128659198296080, 0.003156149752600867, 0.003184064672214937, 0.003212416119368622,
-     0.003241216734320596, 0.003270479660111680, 0.003300218568896729, 0.003330447689969929,
-     0.003361181839619420, 0.003392436452949343, 0.003424227617828290, 0.003456572111131984,
-     0.003489487437467131, 0.003522991870580083, 0.003557104497672658, 0.003591845266868621,
-     0.003627235038102472, 0.003663295637722386, 0.003700049917134574, 0.003737521815846301,
-     0.003775736429304177, 0.003814720081962375, 0.003854500406067995, 0.003895106426696382,
-     0.003936568653631844, 0.003978919180756157, 0.004022191793678687, 0.004066422086428989,
-     0.004111647588127876, 0.004157907900659452, 0.004205244848493050, 0.004253702641940915,
-     0.004303328055299205, 0.004354170621502118, 0.004406282845128784, 0.004459720435841752,
-     0.004514542564613699, 0.004570812145417769, 0.004628596145424491, 0.004687965927177740,
-     0.004748997626717266, 0.004811772572194672, 0.004876377748206484, 0.004942906311860507,
-     0.005011458167522187, 0.005082140608288488, 0.005155069033533799, 0.005230367753417398,
-     0.005308170893076836, 0.005388623411430704, 0.005471882252147620, 0.005558117647517014,
-     0.005647514599798176, 0.005740274569295156, 0.005836617404105682, 0.005936783553485037,
-     0.006041036615386131, 0.006149666279423593, 0.006262991739818591, 0.006381365669577810,
-     0.006505178868201678, 0.006634865721946159, 0.006770910649812723, 0.006913855752425535,
-     0.007064309938019209, 0.007222959874423007, 0.007390583214465396, 0.007568064673498798,
-     0.007756415714389786, 0.007956798835585532, 0.008170557788458321, 0.008399255510700199,
-     0.008644722212900025, 0.008909116987305010, 0.009195007664428712, 0.009505475652925033,
-     0.009844255532840629, 0.010215923852312625, 0.010626158965710175, 0.011082105722287849,
-     0.011592898788496009, 0.012170432837851575, 0.012830529553771619, 0.013594766864701180,
-     0.014493463190219380, 0.015570784932380066, 0.016894014550512759, 0.018571645120042057,
-     0.020792203980939394, 0.023918831757214210, 0.028765597544542998, 0.037673750936428774,
-     0.061856319137823523];
index 7fcd674009d88e9fe9a8807bc53493ac5eaf9252..bd528cbe61f06ce012654c5c49229fa3959dcde5 100644 (file)
@@ -65,7 +65,7 @@ unsafe fn fail_borrowed(box: *mut raw::Box<()>, file: *c_char, line: size_t) ->
         None => { // not recording borrows
             let msg = "borrowed";
             do msg.with_c_str |msg_p| {
-                task::begin_unwind(msg_p, file, line);
+                task::begin_unwind_raw(msg_p, file, line);
             }
         }
         Some(borrow_list) => { // recording borrows
@@ -81,7 +81,7 @@ unsafe fn fail_borrowed(box: *mut raw::Box<()>, file: *c_char, line: size_t) ->
                 }
             }
             do msg.with_c_str |msg_p| {
-                task::begin_unwind(msg_p, file, line)
+                task::begin_unwind_raw(msg_p, file, line)
             }
         }
     }
@@ -180,7 +180,7 @@ pub unsafe fn unrecord_borrow(a: *u8, old_ref_count: uint,
             if br.box != a || br.file != file || br.line != line {
                 let err = format!("wrong borrow found, br={:?}", br);
                 do err.with_c_str |msg_p| {
-                    task::begin_unwind(msg_p, file, line)
+                    task::begin_unwind_raw(msg_p, file, line)
                 }
             }
             borrow_list
index 47c8dbd35c61449c0074516ea17fa2b4ec06197a..fc6d43f551aa2c01b77608396655de7beffc85d3 100644 (file)
@@ -418,7 +418,6 @@ fn test_buffered_stream() {
 
         impl rt::io::Writer for S {
             fn write(&mut self, _: &[u8]) {}
-            fn flush(&mut self) {}
         }
 
         impl rt::io::Reader for S {
index 06424fee8bc121831a71eb2aeb5afd69a8240f75..98dbec27fb9612fea2dd0e7e42bc544589b794a2 100644 (file)
@@ -32,8 +32,6 @@ pub fn new(_chan: C) -> ChanWriter<C> { fail!() }
 
 impl<C: GenericChan<~[u8]>> Writer for ChanWriter<C> {
     fn write(&mut self, _buf: &[u8]) { fail!() }
-
-    fn flush(&mut self) { fail!() }
 }
 
 struct ReaderPort<R>;
index 8bbc4b62eb92320f5af8badf2c9eabab1c517e94..261792977b3a9da2118661824026e1005a5ae7bd 100644 (file)
@@ -138,11 +138,118 @@ pub fn u64_from_be_bytes(data: &[u8],
 
 #[cfg(test)]
 mod test {
-    use option::{Some, None};
-    use cell::Cell;
+    use option::{None, Option, Some};
     use rt::io::mem::{MemReader, MemWriter};
-    use rt::io::mock::MockReader;
-    use rt::io::{io_error, placeholder_error};
+    use rt::io::{Reader, io_error, placeholder_error};
+
+    struct InitialZeroByteReader {
+        count: int,
+    }
+
+    impl Reader for InitialZeroByteReader {
+        fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
+            if self.count == 0 {
+                self.count = 1;
+                Some(0)
+            } else {
+                buf[0] = 10;
+                Some(1)
+            }
+        }
+        fn eof(&mut self) -> bool {
+            false
+        }
+    }
+
+    struct EofReader;
+
+    impl Reader for EofReader {
+        fn read(&mut self, _: &mut [u8]) -> Option<uint> {
+            None
+        }
+        fn eof(&mut self) -> bool {
+            false
+        }
+    }
+
+    struct ErroringReader;
+
+    impl Reader for ErroringReader {
+        fn read(&mut self, _: &mut [u8]) -> Option<uint> {
+            io_error::cond.raise(placeholder_error());
+            None
+        }
+        fn eof(&mut self) -> bool {
+            false
+        }
+    }
+
+    struct PartialReader {
+        count: int,
+    }
+
+    impl Reader for PartialReader {
+        fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
+            if self.count == 0 {
+                self.count = 1;
+                buf[0] = 10;
+                buf[1] = 11;
+                Some(2)
+            } else {
+                buf[0] = 12;
+                buf[1] = 13;
+                Some(2)
+            }
+        }
+        fn eof(&mut self) -> bool {
+            false
+        }
+    }
+
+    struct ErroringLaterReader {
+        count: int,
+    }
+
+    impl Reader for ErroringLaterReader {
+        fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
+            if self.count == 0 {
+                self.count = 1;
+                buf[0] = 10;
+                Some(1)
+            } else {
+                io_error::cond.raise(placeholder_error());
+                None
+            }
+        }
+        fn eof(&mut self) -> bool {
+            false
+        }
+    }
+
+    struct ThreeChunkReader {
+        count: int,
+    }
+
+    impl Reader for ThreeChunkReader {
+        fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
+            if self.count == 0 {
+                self.count = 1;
+                buf[0] = 10;
+                buf[1] = 11;
+                Some(2)
+            } else if self.count == 1 {
+                self.count = 2;
+                buf[0] = 12;
+                buf[1] = 13;
+                Some(2)
+            } else {
+                None
+            }
+        }
+        fn eof(&mut self) -> bool {
+            false
+        }
+    }
 
     #[test]
     fn read_byte() {
@@ -153,18 +260,8 @@ fn read_byte() {
 
     #[test]
     fn read_byte_0_bytes() {
-        let mut reader = MockReader::new();
-        let count = Cell::new(0);
-        reader.read = |buf| {
-            do count.with_mut_ref |count| {
-                if *count == 0 {
-                    *count = 1;
-                    Some(0)
-                } else {
-                    buf[0] = 10;
-                    Some(1)
-                }
-            }
+        let mut reader = InitialZeroByteReader {
+            count: 0,
         };
         let byte = reader.read_byte();
         assert!(byte == Some(10));
@@ -172,19 +269,14 @@ fn read_byte_0_bytes() {
 
     #[test]
     fn read_byte_eof() {
-        let mut reader = MockReader::new();
-        reader.read = |_| None;
+        let mut reader = EofReader;
         let byte = reader.read_byte();
         assert!(byte == None);
     }
 
     #[test]
     fn read_byte_error() {
-        let mut reader = MockReader::new();
-        reader.read = |_| {
-            io_error::cond.raise(placeholder_error());
-            None
-        };
+        let mut reader = ErroringReader;
         do io_error::cond.trap(|_| {
         }).inside {
             let byte = reader.read_byte();
@@ -194,18 +286,8 @@ fn read_byte_error() {
 
     #[test]
     fn bytes_0_bytes() {
-        let mut reader = MockReader::new();
-        let count = Cell::new(0);
-        reader.read = |buf| {
-            do count.with_mut_ref |count| {
-                if *count == 0 {
-                    *count = 1;
-                    Some(0)
-                } else {
-                    buf[0] = 10;
-                    Some(1)
-                }
-            }
+        let reader = InitialZeroByteReader {
+            count: 0,
         };
         let byte = reader.bytes().next();
         assert!(byte == Some(10));
@@ -213,19 +295,14 @@ fn bytes_0_bytes() {
 
     #[test]
     fn bytes_eof() {
-        let mut reader = MockReader::new();
-        reader.read = |_| None;
+        let reader = EofReader;
         let byte = reader.bytes().next();
         assert!(byte == None);
     }
 
     #[test]
     fn bytes_error() {
-        let mut reader = MockReader::new();
-        reader.read = |_| {
-            io_error::cond.raise(placeholder_error());
-            None
-        };
+        let reader = ErroringReader;
         let mut it = reader.bytes();
         do io_error::cond.trap(|_| ()).inside {
             let byte = it.next();
@@ -233,7 +310,6 @@ fn bytes_error() {
         }
     }
 
-
     #[test]
     fn read_bytes() {
         let mut reader = MemReader::new(~[10, 11, 12, 13]);
@@ -243,21 +319,8 @@ fn read_bytes() {
 
     #[test]
     fn read_bytes_partial() {
-        let mut reader = MockReader::new();
-        let count = Cell::new(0);
-        reader.read = |buf| {
-            do count.with_mut_ref |count| {
-                if *count == 0 {
-                    *count = 1;
-                    buf[0] = 10;
-                    buf[1] = 11;
-                    Some(2)
-                } else {
-                    buf[0] = 12;
-                    buf[1] = 13;
-                    Some(2)
-                }
-            }
+        let mut reader = PartialReader {
+            count: 0,
         };
         let bytes = reader.read_bytes(4);
         assert!(bytes == ~[10, 11, 12, 13]);
@@ -282,21 +345,8 @@ fn push_bytes() {
 
     #[test]
     fn push_bytes_partial() {
-        let mut reader = MockReader::new();
-        let count = Cell::new(0);
-        reader.read = |buf| {
-            do count.with_mut_ref |count| {
-                if *count == 0 {
-                    *count = 1;
-                    buf[0] = 10;
-                    buf[1] = 11;
-                    Some(2)
-                } else {
-                    buf[0] = 12;
-                    buf[1] = 13;
-                    Some(2)
-                }
-            }
+        let mut reader = PartialReader {
+            count: 0,
         };
         let mut buf = ~[8, 9];
         reader.push_bytes(&mut buf, 4);
@@ -316,19 +366,8 @@ fn push_bytes_eof() {
 
     #[test]
     fn push_bytes_error() {
-        let mut reader = MockReader::new();
-        let count = Cell::new(0);
-        reader.read = |buf| {
-            do count.with_mut_ref |count| {
-                if *count == 0 {
-                    *count = 1;
-                    buf[0] = 10;
-                    Some(1)
-                } else {
-                    io_error::cond.raise(placeholder_error());
-                    None
-                }
-            }
+        let mut reader = ErroringLaterReader {
+            count: 0,
         };
         let mut buf = ~[8, 9];
         do io_error::cond.trap(|_| { } ).inside {
@@ -342,19 +381,8 @@ fn push_bytes_error() {
     fn push_bytes_fail_reset_len() {
         // push_bytes unsafely sets the vector length. This is testing that
         // upon failure the length is reset correctly.
-        let mut reader = MockReader::new();
-        let count = Cell::new(0);
-        reader.read = |buf| {
-            do count.with_mut_ref |count| {
-                if *count == 0 {
-                    *count = 1;
-                    buf[0] = 10;
-                    Some(1)
-                } else {
-                    io_error::cond.raise(placeholder_error());
-                    None
-                }
-            }
+        let mut reader = ErroringLaterReader {
+            count: 0,
         };
         let buf = @mut ~[8, 9];
         do (|| {
@@ -368,24 +396,8 @@ fn push_bytes_fail_reset_len() {
 
     #[test]
     fn read_to_end() {
-        let mut reader = MockReader::new();
-        let count = Cell::new(0);
-        reader.read = |buf| {
-            do count.with_mut_ref |count| {
-                if *count == 0 {
-                    *count = 1;
-                    buf[0] = 10;
-                    buf[1] = 11;
-                    Some(2)
-                } else if *count == 1 {
-                    *count = 2;
-                    buf[0] = 12;
-                    buf[1] = 13;
-                    Some(2)
-                } else {
-                    None
-                }
-            }
+        let mut reader = ThreeChunkReader {
+            count: 0,
         };
         let buf = reader.read_to_end();
         assert!(buf == ~[10, 11, 12, 13]);
@@ -394,20 +406,8 @@ fn read_to_end() {
     #[test]
     #[should_fail]
     fn read_to_end_error() {
-        let mut reader = MockReader::new();
-        let count = Cell::new(0);
-        reader.read = |buf| {
-            do count.with_mut_ref |count| {
-                if *count == 0 {
-                    *count = 1;
-                    buf[0] = 10;
-                    buf[1] = 11;
-                    Some(2)
-                } else {
-                    io_error::cond.raise(placeholder_error());
-                    None
-                }
-            }
+        let mut reader = ThreeChunkReader {
+            count: 0,
         };
         let buf = reader.read_to_end();
         assert!(buf == ~[10, 11]);
index d035e2f457cc2b940f10f377d91b58eb64e6e209..99a4a709504e48ef4e3692aeaf36badae8b27a45 100644 (file)
@@ -383,15 +383,6 @@ fn write(&mut self, buf: &[u8]) {
             }
         }
     }
-
-    fn flush(&mut self) {
-        match self.fd.flush() {
-            Ok(_) => (),
-            Err(ioerr) => {
-                io_error::cond.raise(ioerr);
-            }
-        }
-    }
 }
 
 /// a `std::rt::io:Seek` trait impl for file I/O.
index 0ec37cd3c07894f46906fca2bb3e069ad2d82417..6803637d7cb14dc29eaeddf122d058ead6ccf35f 100644 (file)
@@ -62,8 +62,6 @@ fn write(&mut self, buf: &[u8]) {
         // Bump us forward
         self.pos += buf.len();
     }
-
-    fn flush(&mut self) { /* no-op */ }
 }
 
 impl Seek for MemWriter {
diff --git a/src/libstd/rt/io/mock.rs b/src/libstd/rt/io/mock.rs
deleted file mode 100644 (file)
index 44709c7..0000000
+++ /dev/null
@@ -1,50 +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.
-
-use option::{Option, None};
-use rt::io::{Reader, Writer};
-
-pub struct MockReader {
-    read: ~fn(buf: &mut [u8]) -> Option<uint>,
-    priv eof: ~fn() -> bool
-}
-
-impl MockReader {
-    pub fn new() -> MockReader {
-        MockReader {
-            read: |_| None,
-            eof: || false
-        }
-    }
-}
-
-impl Reader for MockReader {
-    fn read(&mut self, buf: &mut [u8]) -> Option<uint> { (self.read)(buf) }
-    fn eof(&mut self) -> bool { (self.eof)() }
-}
-
-pub struct MockWriter {
-    priv write: ~fn(buf: &[u8]),
-    priv flush: ~fn()
-}
-
-impl MockWriter {
-    pub fn new() -> MockWriter {
-        MockWriter {
-            write: |_| (),
-            flush: || ()
-        }
-    }
-}
-
-impl Writer for MockWriter {
-    fn write(&mut self, buf: &[u8]) { (self.write)(buf) }
-    fn flush(&mut self) { (self.flush)() }
-}
index 5eba3b2b801d2c68120d5bfb96ac292bb33000bc..be205749186fb42ad33ec1b7318f22a1596aac40 100644 (file)
@@ -323,9 +323,6 @@ pub mod unix { }
     }
 }
 
-/// Mock implementations for testing
-mod mock;
-
 /// Signal handling
 pub mod signal;
 
@@ -810,8 +807,12 @@ pub trait Writer {
     /// Raises the `io_error` condition on error
     fn write(&mut self, buf: &[u8]);
 
-    /// Flush output
-    fn flush(&mut self);
+    /// Flush this output stream, ensuring that all intermediately buffered
+    /// contents reach their destination.
+    ///
+    /// This is by default a no-op and implementors of the `Writer` trait should
+    /// decide whether their stream needs to be buffered or not.
+    fn flush(&mut self) {}
 
     /// Write the result of passing n through `int::to_str_bytes`.
     fn write_int(&mut self, n: int) {
index ba819df071a97d5e37862fd8b5124ad113b039ef..9f9e7dcee9fd6178de8c616b96c626652d37c0a5 100644 (file)
@@ -132,8 +132,6 @@ fn write(&mut self, buf: &[u8]) {
             raise_error();
         }
     }
-
-    fn flush(&mut self) {}
 }
 
 impl Drop for FileDesc {
index fb7c6766fd84c420ad7895c50edabc10ce442b14..493ed6aba87d0bf84cbb47575686d5b3e4a78b14 100644 (file)
@@ -84,8 +84,6 @@ fn write(&mut self, buf: &[u8]) {
             Err(ioerr) => io_error::cond.raise(ioerr),
         }
     }
-
-    fn flush(&mut self) { /* no-op */ }
 }
 
 pub struct TcpListener {
index 2e4ae95d98eea83f656953997d9a590cb2bb3893..f9cf8f5f9ae2436479fa9a0368bc24fd113937e3 100644 (file)
@@ -100,8 +100,6 @@ fn write(&mut self, buf: &[u8]) {
             sock.sendto(buf, self.connectedTo);
         }
     }
-
-    fn flush(&mut self) { fail!() }
 }
 
 #[cfg(test)]
index d9bdb73066d3bb22de7c74420a116d16c65d93a5..f30423812ba6e41244394dfa585107d3c15bb51f 100644 (file)
@@ -78,7 +78,6 @@ fn eof(&mut self) -> bool { self.obj.eof() }
 
 impl Writer for UnixStream {
     fn write(&mut self, buf: &[u8]) { self.obj.write(buf) }
-    fn flush(&mut self) { self.obj.flush() }
 }
 
 pub struct UnixListener {
index ec9a4a0101fee27e03ebcbc89e4c10ac63490966..fbbd5a83561ff16478fac5678ab1280399974a77 100644 (file)
@@ -86,6 +86,4 @@ fn write(&mut self, buf: &[u8]) {
             }
         }
     }
-
-    fn flush(&mut self) {}
 }
index 3f34d32b350b4a2a3b9ce85cb82bf1a11dc2e2b0..eeffc20a336d50594bcbf46d4de3be0771023e27 100644 (file)
@@ -294,8 +294,6 @@ fn write(&mut self, buf: &[u8]) {
             Err(e) => io_error::cond.raise(e)
         }
     }
-
-    fn flush(&mut self) { /* nothing to do */ }
 }
 
 #[cfg(test)]
index edf6ffb820b31f1615a2c1763c0438b7329331b8..949421db9fc808a48fa3a93cde76fe68dc6c51f9 100644 (file)
@@ -155,7 +155,7 @@ fn test_something_in_another_task {
 use option::{Option, Some, None};
 use prelude::*;
 use rt::task::Task;
-use rt::task::UnwindReasonLinked;
+use rt::task::UnwindMessageLinked;
 use rt::task::{UnwindResult, Failure};
 use task::spawn::Taskgroup;
 use to_bytes::IterBytes;
@@ -597,7 +597,7 @@ pub fn collect_failure(&mut self, result: UnwindResult, group: Option<Taskgroup>
                 }
 
                 if !success {
-                    result = Cell::new(Failure(UnwindReasonLinked));
+                    result = Cell::new(Failure(UnwindMessageLinked));
                 }
             }
             on_exit(result.take());
index 366388063d4ef02c75268b4cc7851e2b1f41ca2b..82ff8071896fe07197fb7a46bebc26661882731e 100644 (file)
@@ -173,7 +173,6 @@ pub trait RtioFileStream {
     fn pwrite(&mut self, buf: &[u8], offset: u64) -> Result<(), IoError>;
     fn seek(&mut self, pos: i64, whence: SeekStyle) -> Result<u64, IoError>;
     fn tell(&self) -> Result<u64, IoError>;
-    fn flush(&mut self) -> Result<(), IoError>;
 }
 
 pub trait RtioProcess {
index 516a795a1adf10aa922781fa9cd4d450c6337049..b56dd0809dfd102e7980d07b7d58178d77232e24 100644 (file)
@@ -95,8 +95,8 @@ pub enum UnwindResult {
     /// The task is ending successfully
     Success,
 
-    /// The Task is failing with reason `UnwindReason`
-    Failure(UnwindReason),
+    /// The Task is failing with reason `UnwindMessage`
+    Failure(UnwindMessage),
 }
 
 impl UnwindResult {
@@ -121,20 +121,25 @@ pub fn is_success(&self) -> bool {
 
 /// Represents the cause of a task failure
 #[deriving(ToStr)]
-pub enum UnwindReason {
-    /// Failed with a string message
-    UnwindReasonStr(SendStr),
+pub enum UnwindMessage {
+    // FIXME: #9913 - This variant is not neccessary once Any works properly
+    /// Failed with a static string message
+    UnwindMessageStrStatic(&'static str),
+
+    // FIXME: #9913 - This variant is not neccessary once Any works properly
+    /// Failed with a owned string message
+    UnwindMessageStrOwned(~str),
 
     /// Failed with an `~Any`
-    UnwindReasonAny(~Any),
+    UnwindMessageAny(~Any),
 
     /// Failed because of linked failure
-    UnwindReasonLinked
+    UnwindMessageLinked
 }
 
 pub struct Unwinder {
     unwinding: bool,
-    cause: Option<UnwindReason>
+    cause: Option<UnwindMessage>
 }
 
 impl Unwinder {
@@ -527,7 +532,7 @@ fn rust_try(f: extern "C" fn(*c_void, *c_void),
         }
     }
 
-    pub fn begin_unwind(&mut self, cause: UnwindReason) -> ! {
+    pub fn begin_unwind(&mut self, cause: UnwindMessage) -> ! {
         #[fixed_stack_segment]; #[inline(never)];
 
         self.unwinding = true;
@@ -622,7 +627,7 @@ pub extern "C" fn rust_stack_exhausted() {
 /// This is the entry point of unwinding for things like lang items and such.
 /// The arguments are normally generated by the compiler, and need to
 /// have static lifetimes.
-pub fn begin_unwind(msg: *c_char, file: *c_char, line: size_t) -> ! {
+pub fn begin_unwind_raw(msg: *c_char, file: *c_char, line: size_t) -> ! {
     use c_str::CString;
     use cast::transmute;
 
@@ -638,11 +643,33 @@ fn static_char_ptr(p: *c_char) -> &'static str {
     let msg = static_char_ptr(msg);
     let file = static_char_ptr(file);
 
-    begin_unwind_reason(UnwindReasonStr(msg.into_send_str()), file, line as uint)
+    begin_unwind(msg, file, line as uint)
 }
 
 /// This is the entry point of unwinding for fail!() and assert!().
-pub fn begin_unwind_reason(reason: UnwindReason, file: &'static str, line: uint) -> ! {
+pub fn begin_unwind<M: Any + Send>(msg: M, file: &'static str, line: uint) -> ! {
+    // Wrap the fail message in a `Any` box for uniform representation.
+    let any = ~msg as ~Any;
+
+    // FIXME: #9913 - This can be changed to be internal to begin_unwind_internal
+    // once Any works properly.
+    // As a workaround, string types need to be special cased right now
+    // because `Any` does not support dynamically querying whether the
+    // type implements a trait yet, so without requiring that every `Any`
+    // also implements `ToStr` there is no way to get a failure message
+    // out of it again during unwinding.
+    let msg = if any.is::<&'static str>() {
+        UnwindMessageStrStatic(*any.move::<&'static str>().unwrap())
+    } else if any.is::<~str>() {
+        UnwindMessageStrOwned(*any.move::<~str>().unwrap())
+    } else {
+        UnwindMessageAny(any)
+    };
+
+    begin_unwind_internal(msg, file, line)
+}
+
+fn begin_unwind_internal(msg: UnwindMessage, file: &'static str, line: uint) -> ! {
     use rt::in_green_task_context;
     use rt::task::Task;
     use rt::local::Local;
@@ -656,15 +683,16 @@ pub fn begin_unwind_reason(reason: UnwindReason, file: &'static str, line: uint)
         let task: *mut Task;
 
         {
-            let msg = match reason {
-                UnwindReasonStr(ref s) => s.as_slice(),
-                UnwindReasonAny(_)     => "~Any",
-                UnwindReasonLinked     => "linked failure",
+            let msg_s = match msg {
+                UnwindMessageAny(_) => "~Any",
+                UnwindMessageLinked => "linked failure",
+                UnwindMessageStrOwned(ref s)  => s.as_slice(),
+                UnwindMessageStrStatic(ref s) => s.as_slice(),
             };
 
             if !in_green_task_context() {
                 rterrln!("failed in non-task context at '{}', {}:{}",
-                        msg, file, line);
+                         msg_s, file, line);
                 intrinsics::abort();
             }
 
@@ -679,19 +707,20 @@ pub fn begin_unwind_reason(reason: UnwindReason, file: &'static str, line: uint)
             //      due to mismanagment of its own kill flag, so calling our own
             //      logger in its current state is a bit of a problem.
 
-            rterrln!("task '{}' failed at '{}', {}:{}", n, msg, file, line);
+            rterrln!("task '{}' failed at '{}', {}:{}", n, msg_s, file, line);
 
             if (*task).unwinder.unwinding {
                 rtabort!("unwinding again");
             }
         }
 
-        (*task).unwinder.begin_unwind(reason);
+        (*task).unwinder.begin_unwind(msg);
     }
 }
 
 #[cfg(test)]
 mod test {
+    use super::*;
     use rt::test::*;
 
     #[test]
@@ -804,4 +833,8 @@ struct List {
             a.next = Some(b);
         }
     }
+
+    #[test]
+    #[should_fail]
+    fn test_begin_unwind() { begin_unwind("cause", file!(), line!()) }
 }
index 3a96cfb11718d24a6b961ffc28d560a6f274d314..df6c47a8492bea86078dc28589b1bb49692d4dfe 100644 (file)
@@ -184,6 +184,8 @@ pub mod linkhack {
 pub mod path;
 pub mod rand;
 pub mod run;
+// NOTE: Remove module after next snapshot
+#[cfg(stage0)]
 pub mod sys;
 pub mod cast;
 pub mod fmt;
@@ -226,7 +228,10 @@ mod std {
     pub use logging;
     pub use option;
     pub use os;
+    pub use rt;
     pub use str;
+    // NOTE: Remove import after next snapshot
+    #[cfg(stage0)]
     pub use sys;
     pub use to_bytes;
     pub use to_str;
index b35b25aeb6f727e22bc6c31bb49489f729cdf132..4216f91b60263993873861ef974220e2c61bcd1c 100644 (file)
 
 //! Misc low level stuff
 
+// NOTE: Remove this module after an snapshot
+
 #[allow(missing_doc)];
 
 use any::Any;
 use kinds::Send;
-use rt::task::{UnwindReasonStr, UnwindReasonAny};
 use rt::task;
-use send_str::{SendStr, IntoSendStr};
 
-/// Trait for initiating task failure with a sendable cause.
 pub trait FailWithCause {
-    /// Fail the current task with `cause`.
     fn fail_with(cause: Self, file: &'static str, line: uint) -> !;
 }
 
-impl FailWithCause for ~str {
-    fn fail_with(cause: ~str, file: &'static str, line: uint) -> ! {
-        task::begin_unwind_reason(UnwindReasonStr(cause.into_send_str()), file, line)
-    }
-}
-
-impl FailWithCause for &'static str {
-    fn fail_with(cause: &'static str, file: &'static str, line: uint) -> ! {
-        task::begin_unwind_reason(UnwindReasonStr(cause.into_send_str()), file, line)
-    }
-}
-
-impl FailWithCause for SendStr {
-    fn fail_with(cause: SendStr, file: &'static str, line: uint) -> ! {
-        task::begin_unwind_reason(UnwindReasonStr(cause), file, line)
-    }
-}
-
-impl FailWithCause for ~Any {
-    fn fail_with(cause: ~Any, file: &'static str, line: uint) -> ! {
-        task::begin_unwind_reason(UnwindReasonAny(cause), file, line)
-    }
-}
-
-impl<T: Any + Send + 'static> FailWithCause for ~T {
-    fn fail_with(cause: ~T, file: &'static str, line: uint) -> ! {
-        task::begin_unwind_reason(UnwindReasonAny(cause as ~Any), file, line)
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    use super::*;
-
-    use any::Any;
-    use cast;
-    use send_str::IntoSendStr;
-
-    #[test]
-    fn synthesize_closure() {
-        use unstable::raw::Closure;
-        unsafe {
-            let x = 10;
-            let f: &fn(int) -> int = |y| x + y;
-
-            assert_eq!(f(20), 30);
-
-            let original_closure: Closure = cast::transmute(f);
-
-            let actual_function_pointer = original_closure.code;
-            let environment = original_closure.env;
-
-            let new_closure = Closure {
-                code: actual_function_pointer,
-                env: environment
-            };
-
-            let new_f: &fn(int) -> int = cast::transmute(new_closure);
-            assert_eq!(new_f(20), 30);
-        }
+impl<T: Any + Send> FailWithCause for T {
+    fn fail_with(msg: T, file: &'static str, line: uint) -> ! {
+        task::begin_unwind(msg, file, line)
     }
-
-    #[test]
-    #[should_fail]
-    fn fail_static() { FailWithCause::fail_with("cause", file!(), line!()) }
-
-    #[test]
-    #[should_fail]
-    fn fail_owned() { FailWithCause::fail_with(~"cause", file!(), line!()) }
-
-    #[test]
-    #[should_fail]
-    fn fail_send() { FailWithCause::fail_with("cause".into_send_str(), file!(), line!()) }
-
-    #[test]
-    #[should_fail]
-    fn fail_any() { FailWithCause::fail_with(~612_u16 as ~Any, file!(), line!()) }
-
-    #[test]
-    #[should_fail]
-    fn fail_any_wrap() { FailWithCause::fail_with(~413_u16, file!(), line!()) }
 }
index 023ba6f7108a23a16ffd8f90e7eb2bc72e45fc5f..cdb70f00dfe57f3c22f33974d8cc5a6085303420 100644 (file)
@@ -60,7 +60,8 @@
 use result::{Result, Ok, Err};
 use rt::in_green_task_context;
 use rt::local::Local;
-use rt::task::{UnwindReasonAny, UnwindReasonLinked, UnwindReasonStr};
+use rt::task::{UnwindMessageAny, UnwindMessageLinked};
+use rt::task::{UnwindMessageStrStatic, UnwindMessageStrOwned};
 use rt::task::{UnwindResult, Success, Failure};
 use send_str::{SendStr, IntoSendStr};
 use unstable::finally::Finally;
 fn wrap_as_any(res: UnwindResult) -> TaskResult {
     match res {
         Success => Ok(()),
-        Failure(UnwindReasonStr(s)) => Err(~s as ~Any),
-        Failure(UnwindReasonAny(a)) => Err(a),
-        Failure(UnwindReasonLinked) => Err(~LinkedFailure as ~Any)
+        Failure(UnwindMessageAny(a)) => Err(a),
+        Failure(UnwindMessageLinked) => Err(~LinkedFailure as ~Any),
+        Failure(UnwindMessageStrOwned(s))  => Err(~s as ~Any),
+        Failure(UnwindMessageStrStatic(s)) => Err(~s as ~Any),
     }
 }
 
@@ -1425,38 +1427,52 @@ fn test_indestructible() {
 }
 
 #[test]
-fn test_try_fail_cause_static_str() {
+fn test_try_fail_message_static_str() {
     match do try {
         fail!("static string");
     } {
-        Err(ref e) if e.is::<SendStr>() => {}
-        Err(_) | Ok(()) => fail!()
+        Err(e) => {
+            type T = &'static str;
+            assert!(e.is::<T>());
+            assert_eq!(*e.move::<T>().unwrap(), "static string");
+        }
+        Ok(()) => fail!()
     }
 }
 
 #[test]
-fn test_try_fail_cause_owned_str() {
+fn test_try_fail_message_owned_str() {
     match do try {
         fail!(~"owned string");
     } {
-        Err(ref e) if e.is::<SendStr>() => {}
-        Err(_) | Ok(()) => fail!()
+        Err(e) => {
+            type T = ~str;
+            assert!(e.is::<T>());
+            assert_eq!(*e.move::<T>().unwrap(), ~"owned string");
+        }
+        Ok(()) => fail!()
     }
 }
 
 #[test]
-fn test_try_fail_cause_any() {
+fn test_try_fail_message_any() {
     match do try {
         fail!(~413u16 as ~Any);
     } {
-        Err(ref e) if e.is::<u16>() => {}
-        Err(_) | Ok(()) => fail!()
+        Err(e) => {
+            type T = ~Any;
+            assert!(e.is::<T>());
+            let any = e.move::<T>().unwrap();
+            assert!(any.is::<u16>());
+            assert_eq!(*any.move::<u16>().unwrap(), 413u16);
+        }
+        Ok(()) => fail!()
     }
 }
 
 #[ignore(reason = "linked failure")]
 #[test]
-fn test_try_fail_cause_linked() {
+fn test_try_fail_message_linked() {
     match do try {
         do spawn {
             fail!()
@@ -1468,11 +1484,11 @@ fn test_try_fail_cause_linked() {
 }
 
 #[test]
-fn test_try_fail_cause_any_wrapped() {
+fn test_try_fail_message_unit_struct() {
     struct Juju;
 
     match do try {
-        fail!(~Juju)
+        fail!(Juju)
     } {
         Err(ref e) if e.is::<Juju>() => {}
         Err(_) | Ok(()) => fail!()
index a08bf8f3147b86e81970791d3d32d9e5f7566059..4a98e396bbccd7bd316be338d51c2bc1fd25f846 100644 (file)
 use rt::local::Local;
 use rt::sched::{Scheduler, Shutdown, TaskFromFriend};
 use rt::task::{Task, Sched};
-use rt::task::{UnwindReasonLinked, UnwindReasonStr};
+use rt::task::{UnwindMessageLinked, UnwindMessageStrStatic};
 use rt::task::{UnwindResult, Success, Failure};
 use rt::thread::Thread;
 use rt::work_queue::WorkQueue;
 use rt::{in_green_task_context, new_event_loop, KillHandle};
-use send_str::IntoSendStr;
 use task::SingleThreaded;
 use task::TaskOpts;
 use task::unkillable;
@@ -325,7 +324,7 @@ fn drop(&mut self) {
         do RuntimeGlue::with_task_handle_and_failing |me, failing| {
             if failing {
                 for x in self.notifier.mut_iter() {
-                    x.task_result = Some(Failure(UnwindReasonLinked));
+                    x.task_result = Some(Failure(UnwindMessageLinked));
                 }
                 // Take everybody down with us. After this point, every
                 // other task in the group will see 'tg' as none, which
@@ -380,7 +379,7 @@ pub fn new(chan: Chan<UnwindResult>) -> AutoNotify {
             notify_chan: chan,
 
             // Un-set above when taskgroup successfully made.
-            task_result: Some(Failure(UnwindReasonStr("AutoNotify::new()".into_send_str())))
+            task_result: Some(Failure(UnwindMessageStrStatic("AutoNotify::new()")))
         }
     }
 }
index 89126bf9c9c8823e3396916f0c421cedbee5a221..092e9b6d348bc150dcc815b5913e8cc4345cb72a 100644 (file)
@@ -19,7 +19,7 @@
 #[cold]
 #[lang="fail_"]
 pub fn fail_(expr: *c_char, file: *c_char, line: size_t) -> ! {
-    task::begin_unwind(expr, file, line);
+    task::begin_unwind_raw(expr, file, line);
 }
 
 #[cold]
index 46e80f9f4e8b79737de7b90cccd44e7df7e6bd9f..d784c1d38c60fd7193c2c95b1bf691c5b3ee302a 100644 (file)
@@ -62,3 +62,33 @@ impl Repr<*Box<String>> for @str {}
 
 // sure would be nice to have this
 // impl<T> Repr<*Vec<T>> for ~[T] {}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    use cast;
+
+    #[test]
+    fn synthesize_closure() {
+        unsafe {
+            let x = 10;
+            let f: &fn(int) -> int = |y| x + y;
+
+            assert_eq!(f(20), 30);
+
+            let original_closure: Closure = cast::transmute(f);
+
+            let actual_function_pointer = original_closure.code;
+            let environment = original_closure.env;
+
+            let new_closure = Closure {
+                code: actual_function_pointer,
+                env: environment
+            };
+
+            let new_f: &fn(int) -> int = cast::transmute(new_closure);
+            assert_eq!(new_f(20), 30);
+        }
+    }
+}
index 1f9fe28a46d5b5088de46c10906da6774f3645af..7ce73a4afef70b04fbdfa06ab47db30a054a84c8 100644 (file)
@@ -14,6 +14,7 @@
 use codemap::{CodeMap, Span, ExpnInfo};
 use diagnostic::span_handler;
 use ext;
+use ext::expand;
 use parse;
 use parse::token;
 use parse::token::{ident_to_str, intern, str_to_ident};
@@ -246,6 +247,9 @@ fn builtin_item_tt_no_ctxt(f: SyntaxExpanderTTItemFunNoCtxt) -> @Transformer {
     syntax_expanders.insert(intern("concat_idents"),
                             builtin_normal_tt_no_ctxt(
                                     ext::concat_idents::expand_syntax_ext));
+    syntax_expanders.insert(intern("concat"),
+                            builtin_normal_tt_no_ctxt(
+                                    ext::concat::expand_syntax_ext));
     syntax_expanders.insert(intern(&"log_syntax"),
                             builtin_normal_tt_no_ctxt(
                                     ext::log_syntax::expand_syntax_ext));
@@ -338,6 +342,22 @@ pub fn new(parse_sess: @mut parse::ParseSess, cfg: ast::CrateConfig)
         }
     }
 
+    pub fn expand_expr(@self, mut e: @ast::Expr) -> @ast::Expr {
+        loop {
+            match e.node {
+                ast::ExprMac(*) => {
+                    let extsbox = @mut syntax_expander_table();
+                    let expander = expand::MacroExpander {
+                        extsbox: extsbox,
+                        cx: self,
+                    };
+                    e = expand::expand_expr(extsbox, self, e, &expander);
+                }
+                _ => return e
+            }
+        }
+    }
+
     pub fn codemap(&self) -> @CodeMap { self.parse_sess.cm }
     pub fn parse_sess(&self) -> @mut parse::ParseSess { self.parse_sess }
     pub fn cfg(&self) -> ast::CrateConfig { self.cfg.clone() }
index 273ce180a5f1dfccb33caba72a83b1fdbbac134a..76d9f755d3c9f64a86e1f929721846420be6fe21 100644 (file)
@@ -604,9 +604,9 @@ fn expr_fail(&self, span: Span, msg: @str) -> @ast::Expr {
             span,
             ~[
                 self.ident_of("std"),
-                self.ident_of("sys"),
-                self.ident_of("FailWithCause"),
-                self.ident_of("fail_with"),
+                self.ident_of("rt"),
+                self.ident_of("task"),
+                self.ident_of("begin_unwind"),
             ],
             ~[
                 self.expr_str(span, msg),
diff --git a/src/libsyntax/ext/concat.rs b/src/libsyntax/ext/concat.rs
new file mode 100644 (file)
index 0000000..a89e8d2
--- /dev/null
@@ -0,0 +1,58 @@
+// 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.
+
+use std::char;
+
+use ast;
+use codemap;
+use ext::base;
+use ext::build::AstBuilder;
+
+pub fn expand_syntax_ext(cx: @base::ExtCtxt,
+                         sp: codemap::Span,
+                         tts: &[ast::token_tree]) -> base::MacResult {
+    let es = base::get_exprs_from_tts(cx, sp, tts);
+    let mut accumulator = ~"";
+    for e in es.move_iter() {
+        let e = cx.expand_expr(e);
+        match e.node {
+            ast::ExprLit(lit) => {
+                match lit.node {
+                    ast::lit_str(s, _) |
+                    ast::lit_float(s, _) |
+                    ast::lit_float_unsuffixed(s) => {
+                        accumulator.push_str(s);
+                    }
+                    ast::lit_char(c) => {
+                        accumulator.push_char(char::from_u32(c).unwrap());
+                    }
+                    ast::lit_int(i, _) |
+                    ast::lit_int_unsuffixed(i) => {
+                        accumulator.push_str(format!("{}", i));
+                    }
+                    ast::lit_uint(u, _) => {
+                        accumulator.push_str(format!("{}", u));
+                    }
+                    ast::lit_nil => {}
+                    ast::lit_bool(b) => {
+                        accumulator.push_str(format!("{}", b));
+                    }
+                    ast::lit_binary(*) => {
+                        cx.span_err(e.span, "cannot concatenate a binary literal");
+                    }
+                }
+            }
+            _ => {
+                cx.span_err(e.span, "expected a literal");
+            }
+        }
+    }
+    return base::MRExpr(cx.expr_str(sp, accumulator.to_managed()));
+}
index 575f8bc6278c7065fc48877dffe97808d763fb6a..ba946d5fb1f1d8a48fc8eccf0ff4b02e536f1035 100644 (file)
@@ -763,8 +763,7 @@ pub fn new_span(cx: @ExtCtxt, sp: Span) -> Span {
 // syntax elements.
 
 pub fn std_macros() -> @str {
-    return
-@"mod __std_macros {
+@r#"mod __std_macros {
     #[macro_escape];
     #[doc(hidden)];
 
@@ -789,31 +788,30 @@ macro_rules! debug( ($($arg:tt)*) => (
 
     macro_rules! fail(
         () => (
-            fail!(\"explicit failure\")
+            fail!("explicit failure")
         );
-        ($fmt:expr) => (
-            ::std::sys::FailWithCause::fail_with($fmt, file!(), line!())
+        ($msg:expr) => (
+            ::std::rt::task::begin_unwind($msg, file!(), line!())
         );
         ($fmt:expr, $($arg:tt)*) => (
-            ::std::sys::FailWithCause::fail_with(format!($fmt, $($arg)*), file!(), line!())
+            ::std::rt::task::begin_unwind(format!($fmt, $($arg)*), file!(), line!())
         )
     )
 
     macro_rules! assert(
         ($cond:expr) => {
             if !$cond {
-                ::std::sys::FailWithCause::fail_with(
-                    \"assertion failed: \" + stringify!($cond), file!(), line!())
+                fail!("assertion failed: {:s}", stringify!($cond))
             }
         };
         ($cond:expr, $msg:expr) => {
             if !$cond {
-                ::std::sys::FailWithCause::fail_with($msg, file!(), line!())
+                fail!($msg)
             }
         };
         ($cond:expr, $( $arg:expr ),+) => {
             if !$cond {
-                ::std::sys::FailWithCause::fail_with(format!( $($arg),+ ), file!(), line!())
+                fail!( $($arg),+ )
             }
         }
     )
@@ -826,9 +824,8 @@ macro_rules! assert_eq (
                 // check both directions of equality....
                 if !((*given_val == *expected_val) &&
                      (*expected_val == *given_val)) {
-                    fail!(\"assertion failed: `(left == right) && (right == \
-                             left)` (left: `{:?}`, right: `{:?}`)\",
-                           *given_val, *expected_val);
+                    fail!("assertion failed: `(left == right) && (right == left)` \
+                           (left: `{:?}`, right: `{:?}`)", *given_val, *expected_val)
                 }
             }
         )
@@ -846,7 +843,7 @@ macro_rules! assert_approx_eq (
                     given_val.approx_eq(&expected_val) &&
                     expected_val.approx_eq(&given_val)
                 ) {
-                    fail!(\"left: {:?} does not approximately equal right: {:?}\",
+                    fail!("left: {:?} does not approximately equal right: {:?}",
                            given_val, expected_val);
                 }
             }
@@ -863,42 +860,37 @@ macro_rules! assert_approx_eq (
                     given_val.approx_eq_eps(&expected_val, &epsilon_val) &&
                     expected_val.approx_eq_eps(&given_val, &epsilon_val)
                 ) {
-                    fail!(\"left: {:?} does not approximately equal right: \
-                             {:?} with epsilon: {:?}\",
+                    fail!("left: {:?} does not approximately equal right: \
+                             {:?} with epsilon: {:?}",
                           given_val, expected_val, epsilon_val);
                 }
             }
         )
     )
 
-    // FIXME(#6266): change the /* to /** when attributes are supported on macros
-    // (Though even then—is it going to work according to the clear intent here?)
-    /*
-    A utility macro for indicating unreachable code. It will fail if
-    executed. This is occasionally useful to put after loops that never
-    terminate normally, but instead directly return from a function.
-
-    # Example
-
-    ```rust
-    fn choose_weighted_item(v: &[Item]) -> Item {
-        assert!(!v.is_empty());
-        let mut so_far = 0u;
-        for v.each |item| {
-            so_far += item.weight;
-            if so_far > 100 {
-                return item;
-            }
-        }
-        // The above loop always returns, so we must hint to the
-        // type checker that it isn't possible to get down here
-        unreachable!();
-    }
-    ```
-
-    */
+    /// A utility macro for indicating unreachable code. It will fail if
+    /// executed. This is occasionally useful to put after loops that never
+    /// terminate normally, but instead directly return from a function.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// fn choose_weighted_item(v: &[Item]) -> Item {
+    ///     assert!(!v.is_empty());
+    ///     let mut so_far = 0u;
+    ///     for item in v.iter() {
+    ///         so_far += item.weight;
+    ///         if so_far > 100 {
+    ///             return item;
+    ///         }
+    ///     }
+    ///     // The above loop always returns, so we must hint to the
+    ///     // type checker that it isn't possible to get down here
+    ///     unreachable!();
+    /// }
+    /// ```
     macro_rules! unreachable (() => (
-        fail!(\"internal error: entered unreachable code\");
+        fail!("internal error: entered unreachable code");
     ))
 
     macro_rules! condition (
@@ -968,18 +960,18 @@ macro_rules! local_data_key (
         )
     )
 
-    // externfn! declares a wrapper for an external function.
-    // It is intended to be used like:
-    //
-    // externfn!(#[nolink]
-    //           fn memcmp(cx: *u8, ct: *u8, n: u32) -> u32)
-    //
-    // Due to limitations in the macro parser, this pattern must be
-    // implemented with 4 distinct patterns (with attrs / without
-    // attrs CROSS with args / without ARGS).
-    //
-    // Also, this macro grammar allows for any number of return types
-    // because I couldn't figure out the syntax to specify at most one.
+    /// externfn! declares a wrapper for an external function.
+    /// It is intended to be used like:
+    ///
+    /// externfn!(#[nolink]
+    ///           fn memcmp(cx: *u8, ct: *u8, n: u32) -> u32)
+    ///
+    /// Due to limitations in the macro parser, this pattern must be
+    /// implemented with 4 distinct patterns (with attrs / without
+    /// attrs CROSS with args / without ARGS).
+    ///
+    /// Also, this macro grammar allows for any number of return types
+    /// because I couldn't figure out the syntax to specify at most one.
     macro_rules! externfn(
         (fn $name:ident () $(-> $ret_ty:ty),*) => (
             pub unsafe fn $name() $(-> $ret_ty),* {
@@ -1045,7 +1037,7 @@ pub unsafe fn $name($($arg_name : $arg_ty),*) $(-> $ret_ty),* {
         )
     )
 
-}";
+}"#
 }
 
 struct Injector {
@@ -1091,7 +1083,7 @@ struct NoOpFolder {
 
 impl ast_fold for NoOpFolder {}
 
-struct MacroExpander {
+pub struct MacroExpander {
     extsbox: @mut SyntaxEnv,
     cx: @ExtCtxt,
 }
index 31befed6c0cd4f1e195a35d80cdca81290448812..943279d2dc6831ae76661d001ba72158b8221a5c 100644 (file)
@@ -735,8 +735,10 @@ pub fn expand_args(ecx: @ExtCtxt, sp: Span,
         (_, None) => { return MRExpr(ecx.expr_uint(sp, 2)); }
     };
     cx.fmtsp = efmt.span;
-    let (fmt, _fmt_str_style) = expr_to_str(ecx, efmt,
-                                            "format argument must be a string literal.");
+    // Be sure to recursively expand macros just in case the format string uses
+    // a macro to build the format expression.
+    let (fmt, _) = expr_to_str(ecx, ecx.expand_expr(efmt),
+                               "format argument must be a string literal.");
 
     let mut err = false;
     do parse::parse_error::cond.trap(|m| {
index a8132860b9b4fe2e3eaf12bd0864dbfda3084682..9030b4394e4df5b334e5f4981748b3150df49dcf 100644 (file)
@@ -161,6 +161,16 @@ fn parse_meta_item(&self) -> @ast::MetaItem {
             token::EQ => {
                 self.bump();
                 let lit = self.parse_lit();
+                // FIXME #623 Non-string meta items are not serialized correctly;
+                // just forbid them for now
+                match lit.node {
+                    ast::lit_str(*) => (),
+                    _ => {
+                        self.span_err(
+                            lit.span,
+                            "non-string literals are not allowed in meta-items");
+                    }
+                }
                 let hi = self.span.hi;
                 @spanned(lo, hi, ast::MetaNameValue(name, lit))
             }
index 68796a39f1bceed5c73055ea35490a53c7ce872d..56254704e28d566fb7c37eccfb36267468747c59 100644 (file)
@@ -561,6 +561,45 @@ pub fn check_reserved_keywords(&self) {
         }
     }
 
+    // Expect and consume a `|`. If `||` is seen, replace it with a single
+    // `|` and continue. If a `|` is not seen, signal an error.
+    fn expect_or(&self) {
+        match *self.token {
+            token::BINOP(token::OR) => self.bump(),
+            token::OROR => {
+                self.replace_token(token::BINOP(token::OR),
+                                   self.span.lo + BytePos(1),
+                                   self.span.hi)
+            }
+            _ => {
+                let found_token = self.token_to_str(&token::BINOP(token::OR));
+                self.fatal(format!("expected `{}`, found `{}`",
+                                   found_token,
+                                   self.this_token_to_str()))
+            }
+        }
+    }
+
+    // Parse a sequence bracketed by `|` and `|`, stopping before the `|`.
+    fn parse_seq_to_before_or<T>(&self,
+                                 sep: &token::Token,
+                                 f: &fn(&Parser) -> T)
+                                 -> ~[T] {
+        let mut first = true;
+        let mut vector = ~[];
+        while *self.token != token::BINOP(token::OR) &&
+                *self.token != token::OROR {
+            if first {
+                first = false
+            } else {
+                self.expect(sep)
+            }
+
+            vector.push(f(self))
+        }
+        vector
+    }
+
     // expect and consume a GT. if a >> is seen, replace it
     // with a single > and continue. If a GT is not seen,
     // signal an error.
@@ -761,11 +800,33 @@ pub fn id_to_str(&self, id: Ident) -> @str {
         get_ident_interner().get(id.name)
     }
 
-    // is this one of the keywords that signals a closure type?
-    pub fn token_is_closure_keyword(&self, tok: &token::Token) -> bool {
-        token::is_keyword(keywords::Unsafe, tok) ||
-            token::is_keyword(keywords::Once, tok) ||
-            token::is_keyword(keywords::Fn, tok)
+    // Is the current token one of the keywords that signals a bare function
+    // type?
+    pub fn token_is_bare_fn_keyword(&self) -> bool {
+        if token::is_keyword(keywords::Fn, self.token) {
+            return true
+        }
+
+        if token::is_keyword(keywords::Unsafe, self.token) ||
+            token::is_keyword(keywords::Once, self.token) {
+            return self.look_ahead(1, |t| token::is_keyword(keywords::Fn, t))
+        }
+
+        false
+    }
+
+    // Is the current token one of the keywords that signals a closure type?
+    pub fn token_is_closure_keyword(&self) -> bool {
+        token::is_keyword(keywords::Unsafe, self.token) ||
+            token::is_keyword(keywords::Once, self.token)
+    }
+
+    // Is the current token one of the keywords that signals an old-style
+    // closure type (with explicit sigil)?
+    pub fn token_is_old_style_closure_keyword(&self) -> bool {
+        token::is_keyword(keywords::Unsafe, self.token) ||
+            token::is_keyword(keywords::Once, self.token) ||
+            token::is_keyword(keywords::Fn, self.token)
     }
 
     pub fn token_is_lifetime(&self, tok: &token::Token) -> bool {
@@ -786,15 +847,15 @@ pub fn get_lifetime(&self, tok: &token::Token) -> ast::Ident {
     pub fn parse_ty_bare_fn(&self) -> ty_ {
         /*
 
-        extern "ABI" [unsafe] fn <'lt> (S) -> T
-               ^~~~^ ^~~~~~~^    ^~~~^ ^~^    ^
-                 |     |           |    |     |
-                 |     |           |    |   Return type
-                 |     |           |  Argument types
-                 |     |       Lifetimes
-                 |     |
-                 |   Purity
-                ABI
+        [extern "ABI"] [unsafe] fn <'lt> (S) -> T
+                ^~~~^  ^~~~~~~^    ^~~~^ ^~^    ^
+                  |      |           |    |     |
+                  |      |           |    |   Return type
+                  |      |           |  Argument types
+                  |      |       Lifetimes
+                  |      |
+                  |    Purity
+                 ABI
 
         */
 
@@ -828,8 +889,8 @@ pub fn parse_proc_type(&self) -> ty_ {
 
     // parse a ty_closure type
     pub fn parse_ty_closure(&self,
-                            sigil: ast::Sigil,
-                            region: Option<ast::Lifetime>)
+                            opt_sigil: Option<ast::Sigil>,
+                            mut region: Option<ast::Lifetime>)
                             -> ty_ {
         /*
 
@@ -852,10 +913,58 @@ pub fn parse_ty_closure(&self,
 
         let purity = self.parse_unsafety();
         let onceness = parse_onceness(self);
-        self.expect_keyword(keywords::Fn);
-        let bounds = self.parse_optional_ty_param_bounds();
 
-        let (decl, lifetimes) = self.parse_ty_fn_decl();
+        let (sigil, decl, lifetimes, bounds) = match opt_sigil {
+            Some(sigil) => {
+                // Old-style closure syntax (`fn(A)->B`).
+                self.expect_keyword(keywords::Fn);
+                let bounds = self.parse_optional_ty_param_bounds();
+                let (decl, lifetimes) = self.parse_ty_fn_decl();
+                (sigil, decl, lifetimes, bounds)
+            }
+            None => {
+                // New-style closure syntax (`<'lt>|A|:K -> B`).
+                let lifetimes = if self.eat(&token::LT) {
+                    let lifetimes = self.parse_lifetimes();
+                    self.expect_gt();
+
+                    // Re-parse the region here. What a hack.
+                    if region.is_some() {
+                        self.span_err(*self.last_span,
+                                      "lifetime declarations must precede \
+                                       the lifetime associated with a \
+                                       closure");
+                    }
+                    region = self.parse_opt_lifetime();
+
+                    lifetimes
+                } else {
+                    opt_vec::Empty
+                };
+
+                let inputs = if self.eat(&token::OROR) {
+                    ~[]
+                } else {
+                    self.expect_or();
+                    let inputs = self.parse_seq_to_before_or(
+                        &token::COMMA,
+                        |p| p.parse_arg_general(false));
+                    self.expect_or();
+                    inputs
+                };
+
+                let bounds = self.parse_optional_ty_param_bounds();
+
+                let (return_style, output) = self.parse_ret_ty();
+                let decl = ast::fn_decl {
+                    inputs: inputs,
+                    output: output,
+                    cf: return_style,
+                };
+
+                (BorrowedSigil, decl, lifetimes, bounds)
+            }
+        };
 
         return ty_closure(@TyClosure {
             sigil: sigil,
@@ -1120,13 +1229,23 @@ pub fn parse_ty(&self, _: bool) -> Ty {
             // BORROWED POINTER
             self.bump();
             self.parse_borrowed_pointee()
-        } else if self.eat_keyword(keywords::Extern) {
-            // EXTERN FUNCTION
+        } else if self.is_keyword(keywords::Extern) ||
+                self.token_is_bare_fn_keyword() {
+            // BARE FUNCTION
             self.parse_ty_bare_fn()
-        } else if self.token_is_closure_keyword(self.token) {
+        } else if self.token_is_closure_keyword() ||
+                *self.token == token::BINOP(token::OR) ||
+                *self.token == token::OROR ||
+                *self.token == token::LT ||
+                self.token_is_lifetime(self.token) {
             // CLOSURE
-            let result = self.parse_ty_closure(ast::BorrowedSigil, None);
-            self.obsolete(*self.last_span, ObsoleteBareFnType);
+            //
+            // XXX(pcwalton): Eventually `token::LT` will not unambiguously
+            // introduce a closure, once procs can have lifetime bounds. We
+            // will need to refactor the grammar a little bit at that point.
+
+            let lifetime = self.parse_opt_lifetime();
+            let result = self.parse_ty_closure(None, lifetime);
             result
         } else if self.eat_keyword(keywords::Typeof) {
             // TYPEOF
@@ -1161,12 +1280,12 @@ pub fn parse_box_or_uniq_pointee(&self,
         match *self.token {
             token::LIFETIME(*) => {
                 let lifetime = self.parse_lifetime();
-                return self.parse_ty_closure(sigil, Some(lifetime));
+                return self.parse_ty_closure(Some(sigil), Some(lifetime));
             }
 
             token::IDENT(*) => {
-                if self.token_is_closure_keyword(self.token) {
-                    return self.parse_ty_closure(sigil, None);
+                if self.token_is_old_style_closure_keyword() {
+                    return self.parse_ty_closure(Some(sigil), None);
                 }
             }
             _ => {}
@@ -1187,8 +1306,8 @@ pub fn parse_borrowed_pointee(&self) -> ty_ {
         // look for `&'lt` or `&'foo ` and interpret `foo` as the region name:
         let opt_lifetime = self.parse_opt_lifetime();
 
-        if self.token_is_closure_keyword(self.token) {
-            return self.parse_ty_closure(BorrowedSigil, opt_lifetime);
+        if self.token_is_old_style_closure_keyword() {
+            return self.parse_ty_closure(Some(BorrowedSigil), opt_lifetime);
         }
 
         let mt = self.parse_mt();
@@ -4390,8 +4509,13 @@ fn fn_expr_lookahead(&self, tok: &token::Token) -> bool {
         }
     }
 
-    // parse a string as an ABI spec on an extern type or module
+    // Parses a string as an ABI spec on an extern type or module. Consumes
+    // the `extern` keyword, if one is found.
     fn parse_opt_abis(&self) -> Option<AbiSet> {
+        if !self.eat_keyword(keywords::Extern) {
+            return None
+        }
+
         match *self.token {
             token::LIT_STR(s)
             | token::LIT_STR_RAW(s, _) => {
@@ -4467,7 +4591,7 @@ fn parse_item_or_view_item(&self,
             });
         }
         // either a view item or an item:
-        if self.eat_keyword(keywords::Extern) {
+        if self.is_keyword(keywords::Extern) {
             let opt_abis = self.parse_opt_abis();
 
             if self.eat_keyword(keywords::Fn) {
index 33bdcdd1b03057df14652245d0658f31d4da35be..0eb1045efe95fd1464816db9d680e65b4f52da9d 100644 (file)
@@ -2015,20 +2015,39 @@ pub fn print_ty_fn(s: @ps,
     // function prints the sigil in the wrong place.  That should be fixed.
     if opt_sigil == Some(ast::OwnedSigil) && onceness == ast::Once {
         word(s.s, "proc");
-    } else {
+    } else if opt_sigil == Some(ast::BorrowedSigil) {
         print_extern_opt_abis(s, opt_abis);
+        for lifetime in opt_region.iter() {
+            print_lifetime(s, lifetime);
+        }
+        print_purity(s, purity);
+        print_onceness(s, onceness);
+    } else {
+        print_opt_abis_and_extern_if_nondefault(s, opt_abis);
         print_opt_sigil(s, opt_sigil);
         print_opt_lifetime(s, opt_region);
         print_purity(s, purity);
         print_onceness(s, onceness);
         word(s.s, "fn");
     }
+
     match id { Some(id) => { word(s.s, " "); print_ident(s, id); } _ => () }
-    do opt_bounds.as_ref().map |bounds| { print_bounds(s, bounds, true); };
+
+    if opt_sigil != Some(ast::BorrowedSigil) {
+        do opt_bounds.as_ref().map |bounds| {
+            print_bounds(s, bounds, true);
+        };
+    }
+
     match generics { Some(g) => print_generics(s, g), _ => () }
     zerobreak(s.s);
 
-    popen(s);
+    if opt_sigil == Some(ast::BorrowedSigil) {
+        word(s.s, "|");
+    } else {
+        popen(s);
+    }
+
     // It is unfortunate to duplicate the commasep logic, but we want the
     // self type and the args all in the same box.
     box(s, 0u, inconsistent);
@@ -2041,7 +2060,14 @@ pub fn print_ty_fn(s: @ps,
         print_arg(s, arg);
     }
     end(s);
-    pclose(s);
+
+    if opt_sigil == Some(ast::BorrowedSigil) {
+        word(s.s, "|");
+
+        opt_bounds.as_ref().map(|bounds| print_bounds(s, bounds, true));
+    } else {
+        pclose(s);
+    }
 
     maybe_print_comment(s, decl.output.span.lo);
 
@@ -2274,6 +2300,17 @@ pub fn print_opt_purity(s: @ps, opt_purity: Option<ast::purity>) {
     }
 }
 
+pub fn print_opt_abis_and_extern_if_nondefault(s: @ps,
+                                               opt_abis: Option<AbiSet>) {
+    match opt_abis {
+        Some(abis) if !abis.is_rust() => {
+            word_nbsp(s, "extern");
+            word_nbsp(s, abis.to_str());
+        }
+        Some(_) | None => {}
+    };
+}
+
 pub fn print_extern_opt_abis(s: @ps, opt_abis: Option<AbiSet>) {
     match opt_abis {
         Some(abis) => {
index 00fc676f5957106ddd282785de9ab36c4cf998de..cf2c01e92b43bd145ed38250e8e279b67fa870ae 100644 (file)
@@ -77,6 +77,7 @@ pub mod tt {
     pub mod format;
     pub mod env;
     pub mod bytes;
+    pub mod concat;
     pub mod concat_idents;
     pub mod log_syntax;
     pub mod auto_encode;
index 85ef09cc2a6318ce5f50edcf6a24f8f8f1924dbb..3e38ce9ab358bef650dce605e5f8ea43dcfefdf5 100644 (file)
@@ -19,5 +19,5 @@ fn g(f: extern fn(&fn())) {
     }
 
     f(g);
-    //~^ ERROR mismatched types: expected `extern "Rust" fn(extern "Rust" fn(extern "Rust" fn()))`
+    //~^ ERROR mismatched types: expected `fn(fn(fn()))`
 }
diff --git a/src/test/compile-fail/closure-reform-bad.rs b/src/test/compile-fail/closure-reform-bad.rs
new file mode 100644 (file)
index 0000000..3da7099
--- /dev/null
@@ -0,0 +1,13 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+fn call_bare(f: fn(&str)) {
+    f("Hello ");
+}
+
+fn main() {
+    let string = "world!";
+    let f: |&str| = |s| println(s + string);
+    call_bare(f)    //~ ERROR mismatched types
+}
+
diff --git a/src/test/compile-fail/concat.rs b/src/test/compile-fail/concat.rs
new file mode 100644 (file)
index 0000000..c34e402
--- /dev/null
@@ -0,0 +1,14 @@
+// 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.
+
+fn main() {
+    concat!(foo);   //~ ERROR: expected a literal
+    concat!(foo()); //~ ERROR: expected a literal
+}
diff --git a/src/test/compile-fail/fail-expr.rs b/src/test/compile-fail/fail-expr.rs
deleted file mode 100644 (file)
index 98270bd..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// error-pattern:failed to find an implementation of trait std::sys::FailWithCause for int
-
-fn main() { fail!(5); }
diff --git a/src/test/compile-fail/fail-type-err.rs b/src/test/compile-fail/fail-type-err.rs
deleted file mode 100644 (file)
index b675524..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// error-pattern:failed to find an implementation of trait std::sys::FailWithCause for ~[int]
-fn main() { fail!(~[0i]); }
diff --git a/src/test/compile-fail/inner-static-type-parameter.rs b/src/test/compile-fail/inner-static-type-parameter.rs
new file mode 100644 (file)
index 0000000..0ec4b62
--- /dev/null
@@ -0,0 +1,21 @@
+// 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.
+
+// see #9186
+
+enum Bar<T> { What }
+
+fn foo<T>() {
+    static a: Bar<T> = What;
+    //~^ ERROR: cannot use an outer type parameter in this context
+}
+
+fn main() {
+}
diff --git a/src/test/compile-fail/non-str-meta.rs b/src/test/compile-fail/non-str-meta.rs
new file mode 100644 (file)
index 0000000..752f72f
--- /dev/null
@@ -0,0 +1,15 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Issue #623 - non-string meta items are not serialized correctly;
+// for now just forbid them
+
+#[foo = 1] //~ ERROR: non-string literals are not allowed in meta-items
+fn main() { }
diff --git a/src/test/pretty/closure-reform-pretty.rs b/src/test/pretty/closure-reform-pretty.rs
new file mode 100644 (file)
index 0000000..5169652
--- /dev/null
@@ -0,0 +1,17 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/publicdomain/zero/1.0/
+
+// pp-exact
+
+fn call_it(f: proc(~str) -> ~str) { }
+
+fn call_this(f: |&str|: Send) { }
+
+fn call_that(f: <'a>|&'a int, &'a int|: -> int) { }
+
+fn call_extern(f: fn() -> int) { }
+
+fn call_abid_extern(f: extern "C" fn() -> int) { }
+
+pub fn main() { }
+
index f6787fa9c3d21a7aa7d67e6e0dbdabf397376cd4..d3d6f1c0e355b09f1b3309961422bdd68b77f031 100644 (file)
@@ -14,7 +14,7 @@
 // preserved.  They are needed to disambiguate `{return n+1}; - 0` from
 // `({return n+1}-0)`.
 
-fn id(f: &fn() -> int) -> int { f() }
+fn id(f: || -> int) -> int { f() }
 
 fn wsucc(_n: int) -> int { (do id || { 1 }) - 0 }
 fn main() { }
index 751aedb39a3a8a00ddb2f0cb72d538ac701f5c9d..1fb2359da53acc16a8a4a84f9cde49de9d85ac19 100644 (file)
@@ -10,6 +10,6 @@
 
 // pp-exact
 
-fn f(f: &fn(int)) { f(10) }
+fn f(f: |int|) { f(10) }
 
 fn main() { do f |i| { assert!(i == 10) } }
index b000c9f9137ae51447e544d65e1f2173aa48389b..27e56fb6074a1a6d62583e3853994e7a24c26dd4 100644 (file)
@@ -10,7 +10,7 @@
 
 // pp-exact
 
-fn from_foreign_fn(_x: extern "Rust" fn()) { }
-fn from_stack_closure(_x: &fn()) { }
+fn from_foreign_fn(_x: fn()) { }
+fn from_stack_closure(_x: ||) { }
 fn from_unique_closure(_x: ~fn()) { }
 fn main() { }
diff --git a/src/test/run-fail/fail-macro-send_str.rs b/src/test/run-fail/fail-macro-send_str.rs
deleted file mode 100644 (file)
index 2047fde..0000000
+++ /dev/null
@@ -1,15 +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.
-
-// error-pattern:failed at 'test-fail-send-str'
-
-fn main() {
-    fail!("test-fail-send-str".into_send_str());
-}
index c765ebe9643bcc830f22417406715c2f7a885778..18ca64d0f2762c94519eb4da484b91e002584c2d 100644 (file)
@@ -1,11 +1,42 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
+use std::cast;
+
 fn call_it(f: proc(~str) -> ~str) {
     println(f(~"Fred"))
 }
 
+fn call_a_thunk(f: ||) {
+    f();
+}
+
+fn call_this(f: |&str|:Send) {
+    f("Hello!");
+}
+
+fn call_that(f: <'a>|&'a int, &'a int|: -> int) {
+    let (ten, forty_two) = (10, 42);
+    println!("Your lucky number is {}", f(&ten, &forty_two));
+}
+
+fn call_cramped(f:||->uint,g:<'a>||->&'a uint) {
+    let number = f();
+    let other_number = *g();
+    println!("Ticket {} wins an all-expenses-paid trip to Mountain View", number + other_number);
+}
+
+fn call_bare(f: fn(&str)) {
+    f("Hello world!")
+}
+
+fn call_bare_again(f: extern "Rust" fn(&str)) {
+    f("Goodbye world!")
+}
+
 pub fn main() {
+    // Procs
+
     let greeting = ~"Hi ";
     do call_it |s| {
         greeting + s
@@ -23,5 +54,26 @@ pub fn main() {
     call_it(proc(s: ~str) -> ~str {
         greeting + s
     });
+
+    // Closures
+
+    call_a_thunk(|| println("Hello world!"));
+
+    call_this(|s| println(s));
+
+    call_that(|x, y| *x + *y);
+
+    let z = 100;
+    call_that(|x, y| *x + *y - z);
+
+    call_cramped(|| 1, || unsafe {
+        cast::transmute(&100)
+    });
+
+    // External functions
+
+    call_bare(println);
+
+    call_bare_again(println);
 }
 
diff --git a/src/test/run-pass/concat.rs b/src/test/run-pass/concat.rs
new file mode 100644 (file)
index 0000000..bcf1c4c
--- /dev/null
@@ -0,0 +1,19 @@
+// 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.
+
+pub fn main() {
+    assert_eq!(format!(concat!("foo", "bar", "{}"), "baz"), ~"foobarbaz");
+    assert_eq!(format!(concat!()), ~"");
+
+    assert_eq!(
+        concat!(1, 2i, 3u, 4f32, 4.0, 'a', true, ()),
+        "12344.0atrue"
+    );
+}
index 22f0f1f199f2ccc3bd592dad636dc79804ac9739..310dbea50d1020257ae28b0c1184bd8a8d4b091f 100644 (file)
@@ -174,7 +174,9 @@ pub mod rustrt {
     }
 }
 
-mod test_literals {
+
+// FIXME #623 - these aren't supported yet
+/*mod test_literals {
     #[str = "s"];
     #[char = 'c'];
     #[int = 100];
@@ -185,7 +187,7 @@ mod test_literals {
     #[nil = ()];
     #[bool = true];
     mod m {}
-}
+}*/
 
 fn test_fn_inner() {
     #[inner_fn_attr];
index 8d4680436a42311f7272a302bfacfbb4fe05b82f..5707406de146c4edf822bb23d7989fd84c3ce1fa 100644 (file)
@@ -25,6 +25,6 @@ pub fn main() {
         let _b = Foo;
     };
 
-    let s = x.unwrap_err().move::<SendStr>().unwrap();
+    let s = x.unwrap_err().move::<&'static str>().unwrap();
     assert_eq!(s.as_slice(), "This failure should happen.");
 }