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)
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.
endef
endif
-$(foreach target,$(CFG_TARGET_TRIPLES),\
+$(foreach target,$(CFG_TARGET),\
$(eval $(call DEF_LIBS,$(target))))
######################################################################
endef
-$(foreach host,$(CFG_HOST_TRIPLES), \
+$(foreach host,$(CFG_HOST), \
$(eval $(call DEF_LLVM_VARS,$(host))))
######################################################################
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
# 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
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))))))))
# $(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
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
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
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
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)/"
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
# 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
fi
;;
+ arm-apple-darwin)
+ if [ $CFG_OSTYPE != apple-darwin ]
+ then
+ err "The iOS target is only supported on Mac OS X"
+ fi
+ ;;
+
*)
;;
esac
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
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
# 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
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.
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 - _)
* `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
## 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.
~~~~
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
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 \
-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)
endef
-$(foreach host, $(CFG_HOST_TRIPLES), \
+$(foreach host, $(CFG_HOST), \
$(eval $(foreach stage, $(STAGES), \
$(eval $(call CLEAN_HOST_STAGE_N,$(stage),$(host))))))
$(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))))))))
endif
endef
-$(foreach host, $(CFG_HOST_TRIPLES), \
+$(foreach host, $(CFG_HOST), \
$(eval $(call DEF_CLEAN_LLVM_HOST,$(host))))
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)" $<
.PHONY: dist distcheck
-ifdef CFG_WINDOWSY_$(CFG_BUILD_TRIPLE)
+ifdef CFG_WINDOWSY_$(CFG_BUILD)
dist: $(PKG_EXE)
######################################################################
# 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)
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
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))))
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))
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
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)
$(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
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')), \
$(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"
endef
-$(foreach host,$(CFG_HOST_TRIPLES), \
+$(foreach host,$(CFG_HOST), \
$(eval $(call DEF_LLVM_RULES,$(host))))
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
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
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)
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
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)
# 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) \
endef
-$(foreach target,$(CFG_TARGET_TRIPLES),\
+$(foreach target,$(CFG_TARGET),\
$(eval $(call CFG_MAKE_TOOLCHAIN,$(target))))
"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; \
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
# 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
$$(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),$$@,$$<)
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)))))
endef
# Instantiate template for all stages
-$(foreach host,$(CFG_HOST_TRIPLES), \
+$(foreach host,$(CFG_HOST), \
$(eval $(call DEF_RUSTLLVM_TARGETS,$(host))))
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)
# 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 "$@"
# 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:
# 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))))
# 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
# 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
$$(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)) \
@$$(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)) \
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))) \
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
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')), \
$(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)) \
$(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 \
# 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), \
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))))))
@$$(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)) \
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))))))))
@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"), \
--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) \
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))))))))
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))))))))))
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)))))))
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)))))))
endef
-$(foreach host,$(CFG_HOST_TRIPLES), \
+$(foreach host,$(CFG_HOST), \
$(foreach docname,$(DOC_TEST_NAMES), \
$(eval $(call DEF_DOC_TEST_HOST,$(host),$(docname)))))
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
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
$(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
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))))))
######################################################################
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
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
endef
-$(foreach host,$(CFG_HOST_TRIPLES), \
+$(foreach host,$(CFG_HOST), \
$(eval $(call DEF_CHECK_FAST_FOR_H,$(host))))
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))))
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
# 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)
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;
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
}
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
}
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),
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),
/// 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;
/// - 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
/// 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 => ()
}
// 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,
},
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.");
}
_ => {}
}
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");
+ }
}
}
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();
}
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 => {}
_ => { }
}
- 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()
}
};
- 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) {
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 {
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;
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;
}
}
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))
}
}
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))
}
}
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];
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
}
}
do msg.with_c_str |msg_p| {
- task::begin_unwind(msg_p, file, line)
+ task::begin_unwind_raw(msg_p, file, line)
}
}
}
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
impl rt::io::Writer for S {
fn write(&mut self, _: &[u8]) {}
- fn flush(&mut self) {}
}
impl rt::io::Reader for S {
impl<C: GenericChan<~[u8]>> Writer for ChanWriter<C> {
fn write(&mut self, _buf: &[u8]) { fail!() }
-
- fn flush(&mut self) { fail!() }
}
struct ReaderPort<R>;
#[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() {
#[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));
#[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();
#[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));
#[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();
}
}
-
#[test]
fn read_bytes() {
let mut reader = MemReader::new(~[10, 11, 12, 13]);
#[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]);
#[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);
#[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 {
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 (|| {
#[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]);
#[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]);
}
}
}
-
- 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.
// Bump us forward
self.pos += buf.len();
}
-
- fn flush(&mut self) { /* no-op */ }
}
impl Seek for MemWriter {
+++ /dev/null
-// 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)() }
-}
}
}
-/// Mock implementations for testing
-mod mock;
-
/// Signal handling
pub mod signal;
/// 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) {
raise_error();
}
}
-
- fn flush(&mut self) {}
}
impl Drop for FileDesc {
Err(ioerr) => io_error::cond.raise(ioerr),
}
}
-
- fn flush(&mut self) { /* no-op */ }
}
pub struct TcpListener {
sock.sendto(buf, self.connectedTo);
}
}
-
- fn flush(&mut self) { fail!() }
}
#[cfg(test)]
impl Writer for UnixStream {
fn write(&mut self, buf: &[u8]) { self.obj.write(buf) }
- fn flush(&mut self) { self.obj.flush() }
}
pub struct UnixListener {
}
}
}
-
- fn flush(&mut self) {}
}
Err(e) => io_error::cond.raise(e)
}
}
-
- fn flush(&mut self) { /* nothing to do */ }
}
#[cfg(test)]
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;
}
if !success {
- result = Cell::new(Failure(UnwindReasonLinked));
+ result = Cell::new(Failure(UnwindMessageLinked));
}
}
on_exit(result.take());
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 {
/// 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 {
/// 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 {
}
}
- pub fn begin_unwind(&mut self, cause: UnwindReason) -> ! {
+ pub fn begin_unwind(&mut self, cause: UnwindMessage) -> ! {
#[fixed_stack_segment]; #[inline(never)];
self.unwinding = true;
/// 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;
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;
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();
}
// 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]
a.next = Some(b);
}
}
+
+ #[test]
+ #[should_fail]
+ fn test_begin_unwind() { begin_unwind("cause", file!(), line!()) }
}
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;
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;
//! 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!()) }
}
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),
}
}
}
#[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!()
}
#[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!()
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;
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
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()")))
}
}
}
#[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]
// 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);
+ }
+ }
+}
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};
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));
}
}
+ 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() }
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),
--- /dev/null
+// 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()));
+}
// syntax elements.
pub fn std_macros() -> @str {
- return
-@"mod __std_macros {
+@r#"mod __std_macros {
#[macro_escape];
#[doc(hidden)];
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),+ )
}
}
)
// 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)
}
}
)
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);
}
}
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 (
)
)
- // 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),* {
)
)
-}";
+}"#
}
struct Injector {
impl ast_fold for NoOpFolder {}
-struct MacroExpander {
+pub struct MacroExpander {
extsbox: @mut SyntaxEnv,
cx: @ExtCtxt,
}
(_, 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| {
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))
}
}
}
+ // 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.
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 {
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
*/
// 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_ {
/*
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,
// 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
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);
}
}
_ => {}
// 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();
}
}
- // 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, _) => {
});
}
// 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) {
// 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);
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);
}
}
+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) => {
pub mod format;
pub mod env;
pub mod bytes;
+ pub mod concat;
pub mod concat_idents;
pub mod log_syntax;
pub mod auto_encode;
}
f(g);
- //~^ ERROR mismatched types: expected `extern "Rust" fn(extern "Rust" fn(extern "Rust" fn()))`
+ //~^ ERROR mismatched types: expected `fn(fn(fn()))`
}
--- /dev/null
+/* 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
+}
+
--- /dev/null
+// 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
+}
+++ /dev/null
-// 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); }
+++ /dev/null
-// 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]); }
--- /dev/null
+// 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() {
+}
--- /dev/null
+// 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() { }
--- /dev/null
+// 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() { }
+
// 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() { }
// pp-exact
-fn f(f: &fn(int)) { f(10) }
+fn f(f: |int|) { f(10) }
fn main() { do f |i| { assert!(i == 10) } }
// 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() { }
+++ /dev/null
-// 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());
-}
/* 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
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);
}
--- /dev/null
+// 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"
+ );
+}
}
}
-mod test_literals {
+
+// FIXME #623 - these aren't supported yet
+/*mod test_literals {
#[str = "s"];
#[char = 'c'];
#[int = 100];
#[nil = ()];
#[bool = true];
mod m {}
-}
+}*/
fn test_fn_inner() {
#[inner_fn_attr];
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.");
}