]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #12937 : sinistersnare/rust/method-error-message, r=huonw
authorbors <bors@rust-lang.org>
Mon, 17 Mar 2014 00:01:54 +0000 (17:01 -0700)
committerbors <bors@rust-lang.org>
Mon, 17 Mar 2014 00:01:54 +0000 (17:01 -0700)
its a common (yet easily fixable) error to just forget parens at the end of getter-like methods without any arguments.

The current error message for that case asks for an anonymous function, this patch adds a note asking for either an anonymous function, or for trailing parens.

This is my first contribution! do i need to do anything else?

576 files changed:
mk/clean.mk
mk/crates.mk
mk/docs.mk
src/compiletest/compiletest.rs
src/doc/guide-ffi.md
src/doc/guide-tasks.md
src/doc/guide-unsafe.md [new file with mode: 0644]
src/doc/index.md
src/doc/rust.md
src/doc/tutorial.md
src/etc/combine-tests.py
src/etc/generate-deriving-span-tests.py
src/libarena/lib.rs
src/libcollections/hashmap.rs
src/libcollections/lib.rs
src/libextra/c_vec.rs [deleted file]
src/libextra/lib.rs [deleted file]
src/libextra/stats.rs [deleted file]
src/libextra/tempfile.rs [deleted file]
src/libextra/unicode.rs [deleted file]
src/libextra/url.rs [deleted file]
src/libextra/workcache.rs [deleted file]
src/libflate/lib.rs
src/libfourcc/lib.rs
src/libgetopts/lib.rs
src/libglob/lib.rs
src/libgreen/context.rs
src/libgreen/lib.rs
src/libgreen/task.rs
src/libhexfloat/lib.rs
src/liblog/directive.rs [new file with mode: 0644]
src/liblog/lib.rs [new file with mode: 0644]
src/liblog/macros.rs [new file with mode: 0644]
src/libnative/io/file_unix.rs
src/libnative/io/file_win32.rs
src/libnative/io/mod.rs
src/libnative/io/net.rs
src/libnative/io/timer_timerfd.rs
src/libnative/lib.rs
src/libnative/task.rs
src/libnum/bigint.rs
src/libnum/lib.rs
src/libnum/rational.rs
src/librand/lib.rs
src/librustc/back/archive.rs
src/librustc/back/link.rs
src/librustc/back/mips.rs
src/librustc/driver/driver.rs
src/librustc/front/test.rs
src/librustc/lib.rs
src/librustc/metadata/cstore.rs
src/librustc/middle/cfg/construct.rs
src/librustc/middle/dataflow.rs
src/librustc/middle/lint.rs
src/librustc/middle/liveness.rs
src/librustc/middle/mem_categorization.rs
src/librustc/middle/moves.rs
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/common.rs
src/librustc/middle/trans/context.rs
src/librustc/middle/trans/debuginfo.rs
src/librustc/middle/trans/expr.rs
src/librustc/middle/ty.rs
src/librustc/middle/typeck/astconv.rs
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/collect.rs
src/librustdoc/core.rs
src/librustdoc/lib.rs
src/librustdoc/test.rs
src/librustuv/lib.rs
src/librustuv/net.rs
src/librustuv/uvll.rs
src/libsemver/lib.rs
src/libserialize/lib.rs
src/libstd/c_vec.rs [new file with mode: 0644]
src/libstd/cleanup.rs
src/libstd/cmp.rs
src/libstd/io/mod.rs
src/libstd/io/net/tcp.rs
src/libstd/io/tempfile.rs [new file with mode: 0644]
src/libstd/io/test.rs
src/libstd/iter.rs
src/libstd/lib.rs
src/libstd/libc.rs
src/libstd/logging.rs [deleted file]
src/libstd/macros.rs
src/libstd/option.rs
src/libstd/os.rs
src/libstd/ptr.rs
src/libstd/rt/backtrace.rs
src/libstd/rt/crate_map.rs
src/libstd/rt/libunwind.rs
src/libstd/rt/logging.rs [deleted file]
src/libstd/rt/mod.rs
src/libstd/rt/rtio.rs
src/libstd/rt/task.rs
src/libstd/rt/unwind.rs
src/libstd/sync/atomics.rs
src/libstd/task.rs
src/libstd/unstable/mutex.rs
src/libstd/vec_ng.rs
src/libsync/lib.rs
src/libsyntax/ast.rs
src/libsyntax/ast_map.rs
src/libsyntax/attr.rs
src/libsyntax/diagnostic.rs
src/libsyntax/ext/asm.rs
src/libsyntax/ext/base.rs
src/libsyntax/ext/deriving/generic.rs
src/libsyntax/ext/expand.rs
src/libsyntax/fold.rs
src/libsyntax/lib.rs
src/libsyntax/parse/parser.rs
src/libsyntax/parse/token.rs
src/libsyntax/print/pprust.rs
src/libsyntax/visit.rs
src/libterm/lib.rs
src/libterm/terminfo/parser/compiled.rs
src/libtest/lib.rs
src/libtest/stats.rs [new file with mode: 0644]
src/libtime/lib.rs
src/liburl/lib.rs [new file with mode: 0644]
src/libuuid/lib.rs
src/libworkcache/lib.rs [new file with mode: 0644]
src/rt/arch/mips/morestack.S
src/test/auxiliary/cci_class_4.rs
src/test/auxiliary/cci_class_cast.rs
src/test/auxiliary/extern-crosscrate-source.rs
src/test/auxiliary/issue-2526.rs
src/test/auxiliary/issue-2631-a.rs
src/test/auxiliary/logging_right_crate.rs
src/test/bench/core-uint-to-str.rs
src/test/bench/msgsend-pipes-shared.rs
src/test/bench/msgsend-pipes.rs
src/test/bench/msgsend-ring-mutex-arcs.rs
src/test/bench/msgsend-ring-rw-arcs.rs
src/test/bench/rt-messaging-ping-pong.rs
src/test/bench/rt-parfib.rs
src/test/bench/rt-spawn-rate.rs
src/test/bench/shootout-ackermann.rs
src/test/bench/shootout-chameneos-redux.rs
src/test/bench/shootout-fibo.rs
src/test/bench/shootout-k-nucleotide-pipes.rs
src/test/bench/shootout-pfib.rs
src/test/bench/shootout-threadring.rs
src/test/bench/sudoku.rs
src/test/bench/task-perf-alloc-unwind.rs
src/test/bench/task-perf-one-million.rs
src/test/compile-fail/asm-in-bad-modifier.rs
src/test/compile-fail/asm-misplaced-option.rs [new file with mode: 0644]
src/test/compile-fail/asm-out-assign-imm.rs
src/test/compile-fail/asm-out-no-modifier.rs
src/test/compile-fail/asm-out-read-uninit.rs
src/test/compile-fail/assign-imm-local-twice.rs
src/test/compile-fail/assign-to-method.rs
src/test/compile-fail/attr-before-ext.rs
src/test/compile-fail/autoderef-full-lval.rs
src/test/compile-fail/bad-const-type.rs
src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-1.rs
src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs
src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs
src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs
src/test/compile-fail/bind-by-move-no-sub-bindings.rs
src/test/compile-fail/block-coerce-no.rs
src/test/compile-fail/bogus-tag.rs
src/test/compile-fail/borrowck-and-init.rs
src/test/compile-fail/borrowck-assign-comp-idx.rs
src/test/compile-fail/borrowck-block-unint.rs
src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs
src/test/compile-fail/borrowck-break-uninit-2.rs
src/test/compile-fail/borrowck-break-uninit.rs
src/test/compile-fail/borrowck-if-no-else.rs
src/test/compile-fail/borrowck-if-with-else.rs
src/test/compile-fail/borrowck-init-in-fn-expr.rs
src/test/compile-fail/borrowck-loan-blocks-move-cc.rs
src/test/compile-fail/borrowck-move-out-of-vec-tail.rs
src/test/compile-fail/borrowck-mut-addr-of-imm-var.rs
src/test/compile-fail/borrowck-or-init.rs
src/test/compile-fail/borrowck-uninit.rs
src/test/compile-fail/borrowck-while-break.rs
src/test/compile-fail/class-cast-to-trait.rs
src/test/compile-fail/class-missing-self.rs
src/test/compile-fail/copy-a-resource.rs
src/test/compile-fail/dead-code-ret.rs
src/test/compile-fail/deriving-span-Clone-enum-struct-variant.rs
src/test/compile-fail/deriving-span-Clone-enum.rs
src/test/compile-fail/deriving-span-Clone-struct.rs
src/test/compile-fail/deriving-span-Clone-tuple-struct.rs
src/test/compile-fail/deriving-span-Default-struct.rs
src/test/compile-fail/deriving-span-Default-tuple-struct.rs
src/test/compile-fail/deriving-span-Eq-enum-struct-variant.rs
src/test/compile-fail/deriving-span-Eq-enum.rs
src/test/compile-fail/deriving-span-Eq-struct.rs
src/test/compile-fail/deriving-span-Eq-tuple-struct.rs
src/test/compile-fail/deriving-span-Hash-enum-struct-variant.rs
src/test/compile-fail/deriving-span-Hash-enum.rs
src/test/compile-fail/deriving-span-Hash-struct.rs
src/test/compile-fail/deriving-span-Hash-tuple-struct.rs
src/test/compile-fail/deriving-span-Ord-enum-struct-variant.rs
src/test/compile-fail/deriving-span-Ord-enum.rs
src/test/compile-fail/deriving-span-Ord-struct.rs
src/test/compile-fail/deriving-span-Ord-tuple-struct.rs
src/test/compile-fail/deriving-span-Rand-enum-struct-variant.rs
src/test/compile-fail/deriving-span-Rand-enum.rs
src/test/compile-fail/deriving-span-Rand-struct.rs
src/test/compile-fail/deriving-span-Rand-tuple-struct.rs
src/test/compile-fail/deriving-span-Show-enum-struct-variant.rs
src/test/compile-fail/deriving-span-Show-enum.rs
src/test/compile-fail/deriving-span-Show-struct.rs
src/test/compile-fail/deriving-span-Show-tuple-struct.rs
src/test/compile-fail/deriving-span-TotalEq-enum-struct-variant.rs
src/test/compile-fail/deriving-span-TotalEq-enum.rs
src/test/compile-fail/deriving-span-TotalEq-struct.rs
src/test/compile-fail/deriving-span-TotalEq-tuple-struct.rs
src/test/compile-fail/deriving-span-TotalOrd-enum-struct-variant.rs
src/test/compile-fail/deriving-span-TotalOrd-enum.rs
src/test/compile-fail/deriving-span-TotalOrd-struct.rs
src/test/compile-fail/deriving-span-TotalOrd-tuple-struct.rs
src/test/compile-fail/deriving-span-Zero-struct.rs
src/test/compile-fail/deriving-span-Zero-tuple-struct.rs
src/test/compile-fail/disallowed-deconstructing-destructing-struct-let.rs
src/test/compile-fail/disallowed-deconstructing-destructing-struct-match.rs
src/test/compile-fail/does-nothing.rs
src/test/compile-fail/export2.rs
src/test/compile-fail/if-without-else-result.rs
src/test/compile-fail/import-glob-0.rs
src/test/compile-fail/import-glob-circular.rs
src/test/compile-fail/import.rs
src/test/compile-fail/import2.rs
src/test/compile-fail/import3.rs
src/test/compile-fail/import4.rs
src/test/compile-fail/issue-1448-2.rs
src/test/compile-fail/issue-1476.rs
src/test/compile-fail/issue-2150.rs
src/test/compile-fail/issue-2281-part1.rs
src/test/compile-fail/issue-2823.rs
src/test/compile-fail/issue-3021-b.rs
src/test/compile-fail/issue-3021-c.rs
src/test/compile-fail/issue-3021-d.rs
src/test/compile-fail/issue-3021.rs
src/test/compile-fail/issue-3038.rs
src/test/compile-fail/issue-3099.rs
src/test/compile-fail/issue-3521-2.rs
src/test/compile-fail/issue-3521.rs
src/test/compile-fail/issue-8727.rs
src/test/compile-fail/lint-deprecated-owned-vector.rs [new file with mode: 0644]
src/test/compile-fail/lint-heap-memory.rs
src/test/compile-fail/lint-unused-imports.rs
src/test/compile-fail/lint-unused-mut-variables.rs
src/test/compile-fail/lint-unused-unsafe.rs
src/test/compile-fail/liveness-bad-bang-2.rs
src/test/compile-fail/liveness-closure-require-ret.rs
src/test/compile-fail/liveness-move-in-loop.rs
src/test/compile-fail/liveness-move-in-while.rs
src/test/compile-fail/liveness-use-after-move.rs
src/test/compile-fail/liveness-use-after-send.rs
src/test/compile-fail/match-join.rs
src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs
src/test/compile-fail/no-capture-arc.rs
src/test/compile-fail/no-reuse-move-arc.rs
src/test/compile-fail/no-send-res-ports.rs
src/test/compile-fail/noncopyable-class.rs
src/test/compile-fail/nonscalar-cast.rs
src/test/compile-fail/oversized-literal.rs
src/test/compile-fail/packed-struct-generic-transmute.rs
src/test/compile-fail/packed-struct-transmute.rs
src/test/compile-fail/pattern-tyvar-2.rs
src/test/compile-fail/pattern-tyvar.rs
src/test/compile-fail/pinned-deep-copy.rs
src/test/compile-fail/qquote-1.rs
src/test/compile-fail/qquote-2.rs
src/test/compile-fail/regions-addr-of-self.rs
src/test/compile-fail/regions-freevar.rs
src/test/compile-fail/regions-glb-free-free.rs
src/test/compile-fail/regions-ret-borrowed-1.rs
src/test/compile-fail/regions-ret-borrowed.rs
src/test/compile-fail/seq-args.rs
src/test/compile-fail/spawn-non-nil-fn.rs
src/test/compile-fail/typeck_type_placeholder_item.rs [new file with mode: 0644]
src/test/compile-fail/typeck_type_placeholder_lifetime_1.rs [new file with mode: 0644]
src/test/compile-fail/typeck_type_placeholder_lifetime_2.rs [new file with mode: 0644]
src/test/compile-fail/typeck_type_placeholder_mismatch.rs [new file with mode: 0644]
src/test/compile-fail/unique-pinned-nocopy.rs
src/test/compile-fail/unique-vec-res.rs
src/test/compile-fail/unresolved-extern-mod-suggestion.rs
src/test/compile-fail/unsupported-cast.rs
src/test/compile-fail/vec-field.rs
src/test/compile-fail/vec-res-add.rs
src/test/compile-fail/view-items-at-top.rs
src/test/debug-info/limited-debuginfo.rs
src/test/run-fail/binop-fail-2.rs
src/test/run-fail/binop-fail.rs
src/test/run-fail/bug-2470-bounds-check-overflow-2.rs
src/test/run-fail/bug-2470-bounds-check-overflow-3.rs
src/test/run-fail/bug-2470-bounds-check-overflow.rs
src/test/run-fail/extern-fail.rs
src/test/run-fail/fail-arg.rs
src/test/run-fail/fail-main.rs
src/test/run-fail/fmt-fail.rs
src/test/run-fail/for-each-loop-fail.rs
src/test/run-fail/if-check-fail.rs
src/test/run-fail/if-cond-bot.rs
src/test/run-fail/match-wildcards.rs
src/test/run-fail/morestack2.rs
src/test/run-fail/morestack3.rs
src/test/run-fail/morestack4.rs
src/test/run-fail/result-get-fail.rs
src/test/run-fail/rt-set-exit-status-fail.rs
src/test/run-fail/rt-set-exit-status-fail2.rs
src/test/run-fail/rt-set-exit-status.rs
src/test/run-fail/run-unexported-tests.rs
src/test/run-fail/too-much-recursion-unwinding.rs
src/test/run-fail/unwind-box-fn-unique.rs
src/test/run-fail/unwind-box-res.rs
src/test/run-fail/unwind-box-str.rs
src/test/run-fail/unwind-box-unique-unique.rs
src/test/run-fail/unwind-box-unique.rs
src/test/run-fail/unwind-box-vec.rs
src/test/run-make/c-set-crate-map-manually/lib.rs
src/test/run-pass-fulldeps/qquote.rs
src/test/run-pass/alignment-gep-tup-like-1.rs
src/test/run-pass/arith-0.rs
src/test/run-pass/arith-1.rs
src/test/run-pass/asm-in-out-operand.rs [new file with mode: 0644]
src/test/run-pass/attr-before-view-item.rs
src/test/run-pass/attr-before-view-item2.rs
src/test/run-pass/auto-instantiate.rs
src/test/run-pass/backtrace.rs
src/test/run-pass/binops.rs
src/test/run-pass/bitwise.rs
src/test/run-pass/block-arg-call-as.rs
src/test/run-pass/block-arg.rs
src/test/run-pass/block-explicit-types.rs
src/test/run-pass/block-iter-1.rs
src/test/run-pass/block-iter-2.rs
src/test/run-pass/borrowck-mut-uniq.rs
src/test/run-pass/borrowck-preserve-box-in-field.rs
src/test/run-pass/borrowck-preserve-box-in-uniq.rs
src/test/run-pass/borrowck-preserve-box.rs
src/test/run-pass/borrowck-preserve-cond-box.rs
src/test/run-pass/borrowck-preserve-expl-deref.rs
src/test/run-pass/box-inside-if.rs
src/test/run-pass/box-inside-if2.rs
src/test/run-pass/box-unbox.rs
src/test/run-pass/capturing-logging.rs
src/test/run-pass/cast-region-to-uint.rs
src/test/run-pass/cci_borrow.rs
src/test/run-pass/cci_impl_exe.rs
src/test/run-pass/cci_iter_exe.rs
src/test/run-pass/cci_no_inline_exe.rs
src/test/run-pass/cfgs-on-items.rs
src/test/run-pass/class-attributes-1.rs
src/test/run-pass/class-attributes-2.rs
src/test/run-pass/class-cast-to-trait-cross-crate-2.rs
src/test/run-pass/class-cast-to-trait-multiple-types.rs
src/test/run-pass/class-cast-to-trait.rs
src/test/run-pass/class-impl-very-parameterized-trait.rs
src/test/run-pass/class-implement-trait-cross-crate.rs
src/test/run-pass/class-implement-traits.rs
src/test/run-pass/class-separate-impl.rs
src/test/run-pass/classes.rs
src/test/run-pass/clone-with-exterior.rs
src/test/run-pass/close-over-big-then-small-data.rs
src/test/run-pass/comm.rs
src/test/run-pass/complex.rs
src/test/run-pass/conditional-debug-macro-off.rs
src/test/run-pass/conditional-debug-macro-on.rs
src/test/run-pass/const.rs
src/test/run-pass/dead-code-one-arm-if.rs
src/test/run-pass/deref-lval.rs
src/test/run-pass/estr-slice.rs
src/test/run-pass/evec-slice.rs
src/test/run-pass/explicit-self-generic.rs
src/test/run-pass/export-non-interference2.rs
src/test/run-pass/export-non-interference3.rs
src/test/run-pass/expr-block-generic-box1.rs
src/test/run-pass/expr-block-generic-unique1.rs
src/test/run-pass/extern-call-deep.rs
src/test/run-pass/extern-call-deep2.rs
src/test/run-pass/extern-call-indirect.rs
src/test/run-pass/extern-call-scrub.rs
src/test/run-pass/extern-crosscrate.rs
src/test/run-pass/extern-foreign-crate.rs
src/test/run-pass/extern-yield.rs
src/test/run-pass/fact.rs
src/test/run-pass/fat-arrow-match.rs
src/test/run-pass/float-nan.rs
src/test/run-pass/float-signature.rs
src/test/run-pass/float.rs
src/test/run-pass/fn-bare-item.rs
src/test/run-pass/foreach-put-structured.rs
src/test/run-pass/foreach-simple-outer-slot.rs
src/test/run-pass/foreign-fn-linkname.rs
src/test/run-pass/generic-alias-box.rs
src/test/run-pass/generic-alias-unique.rs
src/test/run-pass/generic-derived-type.rs
src/test/run-pass/generic-fn-box.rs
src/test/run-pass/generic-fn-unique.rs
src/test/run-pass/generic-fn.rs
src/test/run-pass/generic-tag-match.rs
src/test/run-pass/generic-tag-values.rs
src/test/run-pass/generic-temporary.rs
src/test/run-pass/generic-tup.rs
src/test/run-pass/glob-std.rs
src/test/run-pass/hashmap-memory.rs
src/test/run-pass/if-bot.rs
src/test/run-pass/if-check.rs
src/test/run-pass/ifmt.rs
src/test/run-pass/import-glob-0.rs
src/test/run-pass/import-glob-crate.rs
src/test/run-pass/import.rs
src/test/run-pass/import2.rs
src/test/run-pass/import3.rs
src/test/run-pass/import4.rs
src/test/run-pass/import5.rs
src/test/run-pass/import6.rs
src/test/run-pass/import7.rs
src/test/run-pass/import8.rs
src/test/run-pass/infinite-loops.rs
src/test/run-pass/inner-module.rs
src/test/run-pass/integral-indexing.rs
src/test/run-pass/intrinsics-integer.rs
src/test/run-pass/issue-10626.rs
src/test/run-pass/issue-12860.rs [new file with mode: 0644]
src/test/run-pass/issue-1696.rs
src/test/run-pass/issue-2216.rs
src/test/run-pass/issue-2633.rs
src/test/run-pass/issue-2718.rs
src/test/run-pass/issue-2804-2.rs
src/test/run-pass/issue-2804.rs
src/test/run-pass/issue-2904.rs
src/test/run-pass/issue-2935.rs
src/test/run-pass/issue-2989.rs
src/test/run-pass/issue-3109.rs
src/test/run-pass/issue-3424.rs
src/test/run-pass/issue-3556.rs
src/test/run-pass/issue-3563-3.rs
src/test/run-pass/issue-3574.rs
src/test/run-pass/issue-3609.rs
src/test/run-pass/issue-4120.rs
src/test/run-pass/issue-6344-let.rs
src/test/run-pass/issue-6344-match.rs
src/test/run-pass/issue-7563.rs
src/test/run-pass/istr.rs
src/test/run-pass/item-attributes.rs
src/test/run-pass/iter-range.rs
src/test/run-pass/lambda-infer-unresolved.rs
src/test/run-pass/last-use-is-capture.rs
src/test/run-pass/lazy-and-or.rs
src/test/run-pass/lazy-init.rs
src/test/run-pass/linear-for-loop.rs
src/test/run-pass/liveness-loop-break.rs
src/test/run-pass/log-err-phi.rs
src/test/run-pass/log-poly.rs
src/test/run-pass/logging-enabled-debug.rs
src/test/run-pass/logging-enabled.rs
src/test/run-pass/logging-only-prints-once.rs
src/test/run-pass/loop-break-cont.rs
src/test/run-pass/macro-with-braces-in-expr-position.rs
src/test/run-pass/match-bot.rs
src/test/run-pass/match-join.rs
src/test/run-pass/match-pattern-drop.rs
src/test/run-pass/match-pattern-lit.rs
src/test/run-pass/match-pattern-no-type-params.rs
src/test/run-pass/match-unique-bind.rs
src/test/run-pass/match-with-ret-arm.rs
src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs
src/test/run-pass/morestack5.rs
src/test/run-pass/move-3-unique.rs
src/test/run-pass/move-3.rs
src/test/run-pass/move-4-unique.rs
src/test/run-pass/move-4.rs
src/test/run-pass/mutable-alias-vec.rs
src/test/run-pass/nested-matchs.rs
src/test/run-pass/nested-pattern.rs
src/test/run-pass/opeq.rs
src/test/run-pass/over-constrained-vregs.rs
src/test/run-pass/paren-free.rs
src/test/run-pass/parse-fail.rs
src/test/run-pass/pass-by-copy.rs
src/test/run-pass/preempt.rs
src/test/run-pass/purity-infer.rs
src/test/run-pass/rcvr-borrowed-to-region.rs
src/test/run-pass/rcvr-borrowed-to-slice.rs
src/test/run-pass/rec-align-u32.rs
src/test/run-pass/rec-align-u64.rs
src/test/run-pass/rec-auto.rs
src/test/run-pass/reflect-visit-type.rs
src/test/run-pass/regions-addr-of-ret.rs
src/test/run-pass/regions-borrow-at.rs
src/test/run-pass/regions-lifetime-static-items-enclosing-scopes.rs
src/test/run-pass/regions-self-impls.rs
src/test/run-pass/regions-self-in-enums.rs
src/test/run-pass/regions-simple.rs
src/test/run-pass/regions-static-closure.rs
src/test/run-pass/rename-directory.rs
src/test/run-pass/repeated-vector-syntax.rs
src/test/run-pass/resource-assign-is-not-copy.rs
src/test/run-pass/resource-destruct.rs
src/test/run-pass/ret-bang.rs
src/test/run-pass/sendfn-spawn-with-fn-arg.rs
src/test/run-pass/shadow.rs
src/test/run-pass/shape_intrinsic_tag_then_rec.rs
src/test/run-pass/simple-infer.rs
src/test/run-pass/simple-match-generic-tag.rs
src/test/run-pass/size-and-align.rs
src/test/run-pass/spawn-fn.rs
src/test/run-pass/spawn.rs
src/test/run-pass/spawn2.rs
src/test/run-pass/spawning-with-debug.rs
src/test/run-pass/stat.rs
src/test/run-pass/str-append.rs
src/test/run-pass/str-concat.rs
src/test/run-pass/str-idx.rs
src/test/run-pass/str-multiline.rs
src/test/run-pass/string-self-append.rs
src/test/run-pass/struct-literal-dtor.rs
src/test/run-pass/struct-return.rs
src/test/run-pass/supported-cast.rs
src/test/run-pass/tag-align-shape.rs
src/test/run-pass/tail-cps.rs
src/test/run-pass/task-comm-0.rs
src/test/run-pass/task-comm-1.rs
src/test/run-pass/task-comm-10.rs
src/test/run-pass/task-comm-11.rs
src/test/run-pass/task-comm-12.rs
src/test/run-pass/task-comm-13.rs
src/test/run-pass/task-comm-14.rs
src/test/run-pass/task-comm-15.rs
src/test/run-pass/task-comm-17.rs
src/test/run-pass/task-comm-3.rs
src/test/run-pass/task-comm-4.rs
src/test/run-pass/task-comm-5.rs
src/test/run-pass/task-comm-7.rs
src/test/run-pass/task-comm-9.rs
src/test/run-pass/task-comm-chan-nil.rs
src/test/run-pass/task-life-0.rs
src/test/run-pass/tcp-stress.rs
src/test/run-pass/tempfile.rs
src/test/run-pass/terminate-in-initializer.rs
src/test/run-pass/test-ignore-cfg.rs
src/test/run-pass/test-runner-hides-main.rs
src/test/run-pass/threads.rs
src/test/run-pass/trait-inheritance-num.rs
src/test/run-pass/trait-inheritance-num2.rs
src/test/run-pass/trivial-message.rs
src/test/run-pass/typeck_type_placeholder_1.rs [new file with mode: 0644]
src/test/run-pass/typeclasses-eq-example-static.rs
src/test/run-pass/typeclasses-eq-example.rs
src/test/run-pass/unary-minus-suffix-inference.rs
src/test/run-pass/unify-return-ty.rs
src/test/run-pass/unique-copy-box.rs
src/test/run-pass/unique-in-tag.rs
src/test/run-pass/unique-log.rs
src/test/run-pass/unique-pat-3.rs
src/test/run-pass/unwind-box.rs
src/test/run-pass/unwind-resource.rs
src/test/run-pass/unwind-resource2.rs
src/test/run-pass/unwind-unique.rs
src/test/run-pass/use-crate-name-alias.rs
src/test/run-pass/use-uninit-match.rs
src/test/run-pass/use-uninit-match2.rs
src/test/run-pass/utf8.rs
src/test/run-pass/utf8_chars.rs
src/test/run-pass/vec-concat.rs
src/test/run-pass/vec-late-init.rs
src/test/run-pass/vec-self-append.rs
src/test/run-pass/weird-exprs.rs
src/test/run-pass/while-cont.rs
src/test/run-pass/while-loop-constraints-2.rs
src/test/run-pass/while-with-break.rs
src/test/run-pass/while.rs
src/test/run-pass/x86stdcall.rs
src/test/run-pass/yield.rs
src/test/run-pass/yield1.rs
src/test/run-pass/yield2.rs

index 73813a4b7512b41a8a32e1d5f16c4b0f47f3ab1d..34fd4d06fe5e6bad35e42870759d82c171ce50f3 100644 (file)
@@ -78,6 +78,7 @@ define CLEAN_HOST_STAGE_N
 clean$(1)_H_$(2):                                                          \
            $$(foreach crate,$$(CRATES),clean$(1)_H_$(2)-lib-$$(crate))     \
            $$(foreach tool,$$(TOOLS),clean$(1)_H_$(2)-tool-$$(tool))
+       $$(Q)rm -fr $(2)/rt/libbacktrace
 
 clean$(1)_H_$(2)-tool-%:
        $$(Q)rm -f $$(HBIN$(1)_H_$(2))/$$*$$(X_$(2))
index 16485b9e6b52990d05493a7ee4f1e5d5fb3779e2..e3534b6664cbefd8880b96df40040d92a684dfc4 100644 (file)
@@ -37,7 +37,7 @@
 #
 #   DEPS_<crate>
 #      These lists are the dependencies of the <crate> that is to be built.
-#      Rust dependencies are listed bare (i.e. std, extra, green) and native
+#      Rust dependencies are listed bare (i.e. std, green) and native
 #      dependencies have a "native:" prefix (i.e. native:sundown). All deps
 #      will be built before the crate itself is built.
 #
 # automatically generated for all stage/host/target combinations.
 ################################################################################
 
-TARGET_CRATES := std extra green rustuv native flate arena glob term semver \
-                 uuid serialize sync getopts collections num test time rand
+TARGET_CRATES := std green rustuv native flate arena glob term semver \
+                 uuid serialize sync getopts collections num test time rand \
+                workcache url log
 HOST_CRATES := syntax rustc rustdoc fourcc hexfloat
 CRATES := $(TARGET_CRATES) $(HOST_CRATES)
 TOOLS := compiletest rustdoc rustc
 
 DEPS_std := native:rustrt native:compiler-rt native:backtrace
-DEPS_extra := std term sync serialize getopts collections time rand
 DEPS_green := std rand native:context_switch
 DEPS_rustuv := std native:uv native:uv_support
 DEPS_native := std
-DEPS_syntax := std term serialize collections
+DEPS_syntax := std term serialize collections log
 DEPS_rustc := syntax native:rustllvm flate arena serialize sync getopts \
-              collections time extra
+              collections time log
 DEPS_rustdoc := rustc native:sundown serialize sync getopts collections \
                 test time
-DEPS_flate := std extra native:miniz
+DEPS_flate := std native:miniz
 DEPS_arena := std collections
 DEPS_glob := std
-DEPS_serialize := std collections
+DEPS_serialize := std collections log
 DEPS_term := std collections
 DEPS_semver := std
 DEPS_uuid := std serialize rand
@@ -78,9 +78,12 @@ DEPS_collections := std rand
 DEPS_fourcc := syntax std
 DEPS_hexfloat := syntax std
 DEPS_num := std rand
-DEPS_test := std extra collections getopts serialize term
+DEPS_test := std collections getopts serialize term time
 DEPS_time := std serialize
 DEPS_rand := std
+DEPS_url := std collections
+DEPS_workcache := std serialize collections log
+DEPS_log := std sync
 
 TOOL_DEPS_compiletest := test green rustuv getopts
 TOOL_DEPS_rustdoc := rustdoc native
index 5b9e8407a582272600f65205c41eea94b02e33f5..0c23bbbe7c2d5bd93be3483581e5b17d860b5ed3 100644 (file)
@@ -29,7 +29,8 @@
 DOCS := index tutorial guide-ffi guide-macros guide-lifetimes \
        guide-tasks guide-container guide-pointers guide-testing \
        guide-runtime complement-bugreport complement-cheatsheet \
-       complement-lang-faq complement-project-faq rust rustdoc
+       complement-lang-faq complement-project-faq rust rustdoc \
+       guide-unsafe
 
 PDF_DOCS := tutorial rust
 
index 5f8c63d60715abd68a32513ce2de87de7c44de50..a1fcddcf6b351e245b84ae949735a560f9eea5c5 100644 (file)
@@ -9,12 +9,16 @@
 // except according to those terms.
 
 #[crate_type = "bin"];
+#[feature(phase)];
 
 #[allow(non_camel_case_types)];
 #[deny(warnings)];
+#[allow(deprecated_owned_vector)];
 
 extern crate test;
 extern crate getopts;
+#[phase(link, syntax)]
+extern crate log;
 
 use std::os;
 use std::io;
index b9cab358e909da0c9018a82b26329a8127a4cd23..f043d95b4735083e7ab7457c1a17c1556c6f598f 100644 (file)
@@ -170,85 +170,6 @@ Foreign libraries often hand off ownership of resources to the calling code.
 When this occurs, we must use Rust's destructors to provide safety and guarantee
 the release of these resources (especially in the case of failure).
 
-As an example, we give a reimplementation of owned boxes by wrapping `malloc`
-and `free`:
-
-~~~~
-use std::cast;
-use std::libc::{c_void, size_t, malloc, free};
-use std::mem;
-use std::ptr;
-
-// Define a wrapper around the handle returned by the foreign code.
-// Unique<T> has the same semantics as ~T
-pub struct Unique<T> {
-    // It contains a single raw, mutable pointer to the object in question.
-    priv ptr: *mut T
-}
-
-// Implement methods for creating and using the values in the box.
-// NB: For simplicity and correctness, we require that T has kind Send
-// (owned boxes relax this restriction, and can contain managed (GC) boxes).
-// This is because, as implemented, the garbage collector would not know
-// about any shared boxes stored in the malloc'd region of memory.
-impl<T: Send> Unique<T> {
-    pub fn new(value: T) -> Unique<T> {
-        unsafe {
-            let ptr = malloc(std::mem::size_of::<T>() as size_t) as *mut T;
-            assert!(!ptr.is_null());
-            // `*ptr` is uninitialized, and `*ptr = value` would attempt to destroy it
-            // move_val_init moves a value into this memory without
-            // attempting to drop the original value.
-            mem::move_val_init(&mut *ptr, value);
-            Unique{ptr: ptr}
-        }
-    }
-
-    // the 'r lifetime results in the same semantics as `&*x` with ~T
-    pub fn borrow<'r>(&'r self) -> &'r T {
-        unsafe { cast::copy_lifetime(self, &*self.ptr) }
-    }
-
-    // the 'r lifetime results in the same semantics as `&mut *x` with ~T
-    pub fn borrow_mut<'r>(&'r mut self) -> &'r mut T {
-        unsafe { cast::copy_mut_lifetime(self, &mut *self.ptr) }
-    }
-}
-
-// The key ingredient for safety, we associate a destructor with
-// Unique<T>, making the struct manage the raw pointer: when the
-// struct goes out of scope, it will automatically free the raw pointer.
-// NB: This is an unsafe destructor, because rustc will not normally
-// allow destructors to be associated with parametrized types, due to
-// bad interaction with managed boxes. (With the Send restriction,
-// we don't have this problem.)
-#[unsafe_destructor]
-impl<T: Send> Drop for Unique<T> {
-    fn drop(&mut self) {
-        unsafe {
-            let x = mem::uninit(); // dummy value to swap in
-            // We need to move the object out of the box, so that
-            // the destructor is called (at the end of this scope.)
-            ptr::replace(self.ptr, x);
-            free(self.ptr as *mut c_void)
-        }
-    }
-}
-
-// A comparison between the built-in ~ and this reimplementation
-fn main() {
-    {
-        let mut x = ~5;
-        *x = 10;
-    } // `x` is freed here
-
-    {
-        let mut y = Unique::new(5);
-        *y.borrow_mut() = 10;
-    } // `y` is freed here
-}
-~~~~
-
 # Callbacks from C code to Rust functions
 
 Some external libraries require the usage of callbacks to report back their
index da062004cf15625a1d00e5a41304c024ed9c2634..976077f70c86e6d1a65cf4e962797ea02f147a80 100644 (file)
@@ -351,8 +351,6 @@ fn pnorm(nums: &~[f64], p: uint) -> f64 {
 
 fn main() {
     let numbers = vec::from_fn(1000000, |_| rand::random::<f64>());
-    println!("Inf-norm = {}",  *numbers.iter().max().unwrap());
-
     let numbers_arc = Arc::new(numbers);
 
     for num in range(1u, 10) {
diff --git a/src/doc/guide-unsafe.md b/src/doc/guide-unsafe.md
new file mode 100644 (file)
index 0000000..b085fe2
--- /dev/null
@@ -0,0 +1,606 @@
+% Writing Safe Unsafe and Low-Level Code
+
+# Introduction
+
+Rust aims to provide safe abstractions over the low-level details of
+the CPU and operating system, but sometimes one is forced to drop down
+and write code at that level (those abstractions have to be created
+somehow). This guide aims to provide an overview of the dangers and
+power one gets with Rust's unsafe subset.
+
+Rust provides an escape hatch in the form of the `unsafe { ... }`
+block which allows the programmer to dodge some of the compilers
+checks and do a wide range of operations, such as:
+
+- dereferencing [raw pointers](#raw-pointers)
+- calling a function via FFI ([covered by the FFI guide](guide-ffi.html))
+- casting between types bitwise (`transmute`, aka "reinterpret cast")
+- [inline assembly](#inline-assembly)
+
+Note that an `unsafe` block does not relax the rules about lifetimes
+of `&` and the freezing of borrowed data, it just allows the use of
+additional techniques for skirting the compiler's watchful eye. Any
+use of `unsafe` is the programmer saying "I know more than you" to the
+compiler, and, as such, the programmer should be very sure that they
+actually do know more about why that piece of code is valid.
+
+In general, one should try to minimize the amount of unsafe code in a
+code base; preferably by using the bare minimum `unsafe` blocks to
+build safe interfaces.
+
+> **Note**: the low-level details of the Rust language are still in
+> flux, and there is no guarantee of stability or backwards
+> compatibility. In particular, there may be changes that do not cause
+> compilation errors, but do cause semantic changes (such as invoking
+> undefined behaviour). As such, extreme care is required.
+
+# Pointers
+
+## References
+
+One of Rust's biggest goals as a language is ensuring memory safety,
+achieved in part via [the lifetime system](guide-lifetimes.html) which
+every `&` references has associated with it. This system is how the
+compiler can guarantee that every `&` reference is always valid, and,
+for example, never pointing to freed memory.
+
+These restrictions on `&` have huge advantages. However, there's no
+free lunch club. For example, `&` isn't a valid replacement for C's
+pointers, and so cannot be used for FFI, in general. Additionally,
+both immutable (`&`) and mutable (`&mut`) references have some
+aliasing and freezing guarantees, required for memory safety.
+
+In particular, if you have an `&T` reference, then the `T` must not be
+modified through that reference or any other reference. There are some
+standard library types, e.g. `Cell` and `RefCell`, that provide inner
+mutability by replacing compile time guarantees with dynamic checks at
+runtime.
+
+An `&mut` reference has a stronger requirement: when a object has an
+`&mut T` pointing into it, then that `&mut` reference must be the only
+such usable path to that object in the whole program. That is, an
+`&mut` cannot alias with any other references.
+
+Using `unsafe` code to incorrectly circumvent and violate these
+restrictions is undefined behaviour. For example, the following
+creates two aliasing `&mut` pointers, and is invalid.
+
+```
+use std::cast;
+let mut x: u8 = 1;
+
+let ref_1: &mut u8 = &mut x;
+let ref_2: &mut u8 = unsafe { cast::transmute_mut_region(ref_1) };
+
+// oops, ref_1 and ref_2 point to the same piece of data (x) and are
+// both usable
+*ref_1 = 10;
+*ref_2 = 20;
+```
+
+## Raw pointers
+
+Rust offers two additional pointer types "raw pointers", written as
+`*T` and `*mut T`. They're an approximation of C's `const T*` and `T*`
+respectively; indeed, one of their most common uses is for FFI,
+interfacing with external C libraries.
+
+Raw pointers have much fewer guarantees than other pointer types
+offered by the Rust language and libraries. For example, they
+
+- are not guaranteed to point to valid memory and are not even
+  guaranteed to be non-null (unlike both `~` and `&`);
+- do not have any automatic clean-up, unlike `~`, and so require
+  manual resource management;
+- are plain-old-data, that is, they don't move ownership, again unlike
+  `~`, hence the Rust compiler cannot protect against bugs like
+  use-after-free;
+- are considered sendable (if their contents is considered sendable),
+  so the compiler offers no assistance with ensuring their use is
+  thread-safe; for example, one can concurrently access a `*mut int`
+  from two threads without synchronization.
+- lack any form of lifetimes, unlike `&`, and so the compiler cannot
+  reason about dangling pointers; and
+- have no guarantees about aliasing or mutability other than mutation
+  not being allowed directly through a `*T`.
+
+Fortunately, they come with a redeeming feature: the weaker guarantees
+mean weaker restrictions. The missing restrictions make raw pointers
+appropriate as a building block for (carefully!) implementing things
+like smart pointers and vectors inside libraries. For example, `*`
+pointers are allowed to alias, allowing them to be used to write
+shared-ownership types like reference counted and garbage collected
+pointers, and even thread-safe shared memory types (`Rc` and the `Arc`
+types are both implemented entirely in Rust).
+
+There are two things that you are required to be careful about
+(i.e. require an `unsafe { ... }` block) with raw pointers:
+
+- dereferencing: they can have any value: so possible results include
+  a crash, a read of uninitialised memory, a use-after-free, or
+  reading data as normal (and one hopes happens).
+- pointer arithmetic via the `offset` [intrinsic](#intrinsics) (or
+  `.offset` method): this intrinsic uses so-called "in-bounds"
+  arithmetic, that is, it is only defined behaviour if the result is
+  inside (or one-byte-past-the-end) of the object from which the
+  original pointer came.
+
+The latter assumption allows the compiler to optimize more
+effectively. As can be seen, actually *creating* a raw pointer is not
+unsafe, and neither is converting to an integer.
+
+### References and raw pointers
+
+At runtime, a raw pointer `*` and a reference pointing to the same
+piece of data have an identical representation. In fact, an `&T`
+reference will implicitly coerce to an `*T` raw pointer in safe code
+and similarly for the `mut` variants (both coercions can be performed
+explicitly with, respectively, `value as *T` and `value as *mut T`).
+
+Going the opposite direction, from `*` to a reference `&`, is not
+safe. A `&T` is always valid, and so, at a minimum, the raw pointer
+`*T` has to be a valid to a valid instance of type `T`. Furthermore,
+the resulting pointer must satisfy the aliasing and mutability laws of
+references. The compiler assumes these properties are true for any
+references, no matter how they are created, and so any conversion from
+raw pointers is asserting that they hold. The programmer *must*
+guarantee this.
+
+The recommended method for the conversion is
+
+```
+let i: u32 = 1;
+// explicit cast
+let p_imm: *u32 = &i as *u32;
+let mut m: u32 = 2;
+// implicit coercion
+let p_mut: *mut u32 = &mut m;
+
+unsafe {
+    let ref_imm: &u32 = &*p_imm;
+    let ref_mut: &mut u32 = &mut *p_mut;
+}
+```
+
+The `&*x` dereferencing style is preferred to using a `transmute`.
+The latter is far more powerful than necessary, and the more
+restricted operation is harder to use incorrectly; for example, it
+requires that `x` is a pointer (unlike `transmute`).
+
+
+
+## Making the unsafe safe(r)
+
+There are various ways to expose a safe interface around some unsafe
+code:
+
+- store pointers privately (i.e. not in public fields of public
+  structs), so that you can see and control all reads and writes to
+  the pointer in one place.
+- use `assert!()` a lot: once you've thrown away the protection of the
+  compiler & type-system via `unsafe { ... }` you're left with just
+  your wits and your `assert!()`s, any bug is potentially exploitable.
+- implement the `Drop` for resource clean-up via a destructor, and use
+  RAII (Resource Acquisition Is Initialization). This reduces the need
+  for any manual memory management by users, and automatically ensures
+  that clean-up is always run, even when the task fails.
+- ensure that any data stored behind a raw pointer is destroyed at the
+  appropriate time.
+
+As an example, we give a reimplementation of owned boxes by wrapping
+`malloc` and `free`. Rust's move semantics and lifetimes mean this
+reimplementation is as safe as the built-in `~` type.
+
+```
+use std::libc::{c_void, size_t, malloc, free};
+use std::mem;
+use std::ptr;
+
+// Define a wrapper around the handle returned by the foreign code.
+// Unique<T> has the same semantics as ~T
+pub struct Unique<T> {
+    // It contains a single raw, mutable pointer to the object in question.
+    priv ptr: *mut T
+}
+
+// Implement methods for creating and using the values in the box.
+// NB: For simplicity and correctness, we require that T has kind Send
+// (owned boxes relax this restriction, and can contain managed (GC) boxes).
+// This is because, as implemented, the garbage collector would not know
+// about any shared boxes stored in the malloc'd region of memory.
+impl<T: Send> Unique<T> {
+    pub fn new(value: T) -> Unique<T> {
+        unsafe {
+            let ptr = malloc(std::mem::size_of::<T>() as size_t) as *mut T;
+            // we *need* valid pointer.
+            assert!(!ptr.is_null());
+            // `*ptr` is uninitialized, and `*ptr = value` would attempt to destroy it
+            // move_val_init moves a value into this memory without
+            // attempting to drop the original value.
+            mem::move_val_init(&mut *ptr, value);
+            Unique{ptr: ptr}
+        }
+    }
+
+    // the 'r lifetime results in the same semantics as `&*x` with ~T
+    pub fn borrow<'r>(&'r self) -> &'r T {
+        // By construction, self.ptr is valid
+        unsafe { &*self.ptr }
+    }
+
+    // the 'r lifetime results in the same semantics as `&mut *x` with ~T
+    pub fn borrow_mut<'r>(&'r mut self) -> &'r mut T {
+        unsafe { &mut*self.ptr }
+    }
+}
+
+// A key ingredient for safety, we associate a destructor with
+// Unique<T>, making the struct manage the raw pointer: when the
+// struct goes out of scope, it will automatically free the raw pointer.
+// NB: This is an unsafe destructor, because rustc will not normally
+// allow destructors to be associated with parametrized types, due to
+// bad interaction with managed boxes. (With the Send restriction,
+// we don't have this problem.)
+#[unsafe_destructor]
+impl<T: Send> Drop for Unique<T> {
+    fn drop(&mut self) {
+        unsafe {
+
+            // Copy the object out from the pointer onto the stack,
+            // where it is covered by normal Rust destructor semantics
+            // and cleans itself up, if necessary
+            ptr::read(self.ptr as *T);
+
+            // clean-up our allocation
+            free(self.ptr as *mut c_void)
+        }
+    }
+}
+
+// A comparison between the built-in ~ and this reimplementation
+fn main() {
+    {
+        let mut x = ~5;
+        *x = 10;
+    } // `x` is freed here
+
+    {
+        let mut y = Unique::new(5);
+        *y.borrow_mut() = 10;
+    } // `y` is freed here
+}
+```
+
+Notably, the only way to construct a `Unique` is via the `new`
+function, and this function ensures that the internal pointer is valid
+and hidden in the private field. The two `borrow` methods are safe
+because the compiler statically guarantees that objects are never used
+before creation or after destruction (unless you use some `unsafe`
+code...).
+
+# Inline assembly
+
+For extremely low-level manipulations and performance reasons, one
+might wish to control the CPU directly. Rust supports using inline
+assembly to do this via the `asm!` macro. The syntax roughly matches
+that of GCC & Clang:
+
+```ignore
+asm!(assembly template
+   : output operands
+   : input operands
+   : clobbers
+   : options
+   );
+```
+
+Any use of `asm` is feature gated (requires `#[feature(asm)];` on the
+crate to allow) and of course requires an `unsafe` block.
+
+> **Note**: the examples here are given in x86/x86-64 assembly, but all
+> platforms are supported.
+
+## Assembly template
+
+The `assembly template` is the only required parameter and must be a
+literal string (i.e `""`)
+
+```
+#[feature(asm)];
+
+#[cfg(target_arch = "x86")]
+#[cfg(target_arch = "x86_64")]
+fn foo() {
+    unsafe {
+        asm!("NOP");
+    }
+}
+
+// other platforms
+#[cfg(not(target_arch = "x86"),
+      not(target_arch = "x86_64"))]
+fn foo() { /* ... */ }
+
+fn main() {
+    // ...
+    foo();
+    // ...
+}
+```
+
+(The `feature(asm)` and `#[cfg]`s are omitted from now on.)
+
+Output operands, input operands, clobbers and options are all optional
+but you must add the right number of `:` if you skip them:
+
+```
+# #[feature(asm)];
+# #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")]
+# fn main() { unsafe {
+asm!("xor %eax, %eax"
+    :
+    :
+    : "eax"
+   );
+# } }
+```
+
+Whitespace also doesn't matter:
+
+```
+# #[feature(asm)];
+# #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")]
+# fn main() { unsafe {
+asm!("xor %eax, %eax" ::: "eax");
+# } }
+```
+
+## Operands
+
+Input and output operands follow the same format: `:
+"constraints1"(expr1), "constraints2"(expr2), ..."`. Output operand
+expressions must be mutable lvalues:
+
+```
+# #[feature(asm)];
+# #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")]
+fn add(a: int, b: int) -> int {
+    let mut c = 0;
+    unsafe {
+        asm!("add $2, $0"
+             : "=r"(c)
+             : "0"(a), "r"(b)
+             );
+    }
+    c
+}
+# #[cfg(not(target_arch = "x86"), not(target_arch = "x86_64"))]
+# fn add(a: int, b: int) -> int { a + b }
+
+fn main() {
+    assert_eq!(add(3, 14159), 14162)
+}
+```
+
+## Clobbers
+
+Some instructions modify registers which might otherwise have held
+different values so we use the clobbers list to indicate to the
+compiler not to assume any values loaded into those registers will
+stay valid.
+
+```
+# #[feature(asm)];
+# #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")]
+# fn main() { unsafe {
+// Put the value 0x200 in eax
+asm!("mov $$0x200, %eax" : /* no outputs */ : /* no inputs */ : "eax");
+# } }
+```
+
+Input and output registers need not be listed since that information
+is already communicated by the given constraints. Otherwise, any other
+registers used either implicitly or explicitly should be listed.
+
+If the assembly changes the condition code register `cc` should be
+specified as one of the clobbers. Similarly, if the assembly modifies
+memory, `memory` should also be specified.
+
+## Options
+
+The last section, `options` is specific to Rust. The format is comma
+separated literal strings (i.e `:"foo", "bar", "baz"`). It's used to
+specify some extra info about the inline assembly:
+
+Current valid options are:
+
+1. **volatile** - specifying this is analogous to `__asm__ __volatile__ (...)` in gcc/clang.
+2. **alignstack** - certain instructions expect the stack to be
+   aligned a certain way (i.e SSE) and specifying this indicates to
+   the compiler to insert its usual stack alignment code
+3. **intel** - use intel syntax instead of the default AT&T.
+
+# Avoiding the standard library
+
+By default, `std` is linked to every Rust crate. In some contexts,
+this is undesirable, and can be avoided with the `#[no_std];`
+attribute attached to the crate.
+
+```ignore
+# // FIXME #12903: linking failures due to no_std
+// the minimal library
+#[crate_type="lib"];
+#[no_std];
+
+# // fn main() {} tricked you, rustdoc!
+```
+
+Obviously there's more to life than just libraries: one can use
+`#[no_std]` with an executable, controlling the entry point is
+possible in two ways: the `#[start]` attribute, or overriding the
+default shim for the C `main` function with your own.
+
+The function marked `#[start]` is passed the command line parameters
+in the same format as a C:
+
+```ignore
+# // FIXME #12903: linking failures due to no_std
+#[no_std];
+
+extern "rust-intrinsic" { fn abort() -> !; }
+#[no_mangle] pub extern fn rust_stack_exhausted() {
+    unsafe { abort() }
+}
+
+#[start]
+fn start(_argc: int, _argv: **u8) -> int {
+    0
+}
+
+# // fn main() {} tricked you, rustdoc!
+```
+
+To override the compiler-inserted `main` shim, one has to disable it
+with `#[no_main];` and then create the appropriate symbol with the
+correct ABI and the correct name, which requires overriding the
+compiler's name mangling too:
+
+```ignore
+# // FIXME #12903: linking failures due to no_std
+#[no_std];
+#[no_main];
+
+extern "rust-intrinsic" { fn abort() -> !; }
+#[no_mangle] pub extern fn rust_stack_exhausted() {
+    unsafe { abort() }
+}
+
+#[no_mangle] // ensure that this symbol is called `main` in the output
+extern "C" fn main(_argc: int, _argv: **u8) -> int {
+    0
+}
+
+# // fn main() {} tricked you, rustdoc!
+```
+
+
+Unfortunately the Rust compiler assumes that symbols with certain
+names exist; and these have to be defined (or linked in). This is the
+purpose of the `rust_stack_exhausted`: it is called when a function
+detects that it will overflow its stack. The example above uses the
+`abort` intrinsic which ensures that execution halts.
+
+# Interacting with the compiler internals
+
+> **Note**: this section is specific to the `rustc` compiler; these
+> parts of the language may never be full specified and so details may
+> differ wildly between implementations (and even versions of `rustc`
+> itself).
+>
+> Furthermore, this is just an overview; the best form of
+> documentation for specific instances of these features are their
+> definitions and uses in `std`.
+
+The Rust language currently has two orthogonal mechanisms for allowing
+libraries to interact directly with the compiler and vice versa:
+
+- intrinsics, functions built directly into the compiler providing
+  very basic low-level functionality,
+- lang-items, special functions, types and traits in libraries marked
+  with specific `#[lang]` attributes
+
+## Intrinsics
+
+These are imported as if they were FFI functions, with the special
+`rust-intrinsic` ABI. For example, if one was in a freestanding
+context, but wished to be able to `transmute` between types, and
+perform efficient pointer arithmetic, one would import those functions
+via a declaration like
+
+```
+extern "rust-intrinsic" {
+    fn transmute<T, U>(x: T) -> U;
+
+    fn offset<T>(dst: *T, offset: int) -> *T;
+}
+```
+
+As with any other FFI functions, these are always `unsafe` to call.
+
+## Lang items
+
+The `rustc` compiler has certain pluggable operations, that is,
+functionality that isn't hard-coded into the language, but is
+implemented in libraries, with a special marker to tell the compiler
+it exists. The marker is the attribute `#[lang="..."]` and there are
+various different values of `...`, i.e. various different "lang
+items".
+
+For example, `~` pointers require two lang items, one for allocation
+and one for deallocation. A freestanding program that uses the `~`
+sugar for dynamic allocations via `malloc` and `free`:
+
+```ignore
+# // FIXME #12903: linking failures due to no_std
+#[no_std];
+
+#[allow(ctypes)] // `uint` == `size_t` on Rust's platforms
+extern {
+    fn malloc(size: uint) -> *mut u8;
+    fn free(ptr: *mut u8);
+
+    fn abort() -> !;
+}
+
+#[no_mangle] pub extern fn rust_stack_exhausted() {
+    unsafe { abort() }
+}
+
+#[lang="exchange_malloc"]
+unsafe fn allocate(size: uint) -> *mut u8 {
+    let p = malloc(size);
+
+    // malloc failed
+    if p as uint == 0 {
+        abort();
+    }
+
+    p
+}
+#[lang="exchange_free"]
+unsafe fn deallocate(ptr: *mut u8) {
+    free(ptr)
+}
+
+#[start]
+fn main(_argc: int, _argv: **u8) -> int {
+    let _x = ~1;
+
+    0
+}
+
+# // fn main() {} tricked you, rustdoc!
+```
+
+Note the use of `abort`: the `exchange_malloc` lang item is assumed to
+return a valid pointer, and so needs to do the check
+internally.
+
+Other features provided by lang items include:
+
+- overloadable operators via traits: the traits corresponding to the
+  `==`, `<`, dereferencing (`*`) and `+` (etc.) operators are all
+  marked with lang items; those specific four are `eq`, `ord`,
+  `deref`, and `add` respectively.
+- stack unwinding and general failure; the `eh_personality`, `fail_`
+  and `fail_bounds_checks` lang items.
+- the traits in `std::kinds` used to indicate types that satisfy
+  various kinds; lang items `send`, `freeze` and `pod`.
+- the marker types and variance indicators found in
+  `std::kinds::markers`; lang items `covariant_type`,
+  `contravariant_lifetime`, `no_freeze_bound`, etc.
+
+Lang items are loaded lazily by the compiler; e.g. if one never uses
+`~` then there is no need to define functions for `exchange_malloc`
+and `exchange_free`. `rustc` will emit an error when an item is needed
+but not found in the current crate or any that it depends on.
index 748f3ffb2dc06977bdb11fc462119be2f3ec866c..5bcfd8e8305339cd82efa44bd6704303d2f3386f 100644 (file)
@@ -17,6 +17,7 @@ li {list-style-type: none; }
 * [Containers and Iterators](guide-container.html)
 * [Tasks and Communication](guide-tasks.html)
 * [Foreign Function Interface](guide-ffi.html)
+* [Writing Safe Unsafe and Low-Level Code](guide-unsafe.html)
 * [Macros](guide-macros.html)
 * [Testing](guide-testing.html)
 * [Rust's Runtime](guide-runtime.html)
@@ -29,7 +30,6 @@ li {list-style-type: none; }
 
 * [The `arena` allocation library](arena/index.html)
 * [The `collections` library](collections/index.html)
-* [The `extra` library of extra stuff](extra/index.html)
 * [The `flate` compression library](flate/index.html)
 * [The `fourcc` four-character code library](fourcc/index.html)
 * [The `getopts` argument parsing library](getopts/index.html)
@@ -49,6 +49,9 @@ li {list-style-type: none; }
 * [The `test` library containing the unit-testing & micro-benchmark framework](test/index.html)
 * [The `time` library](time/index.html)
 * [The `uuid` 128-bit universally unique identifier library](uuid/index.html)
+* [The `url` library](url/index.html)
+* [The `workcache` library](workcache/index.html)
+* [The `log` library](log/index.html)
 
 # Tooling
 
index 9e2b934d0abc4ab9080229a7db1d4bba2dfb7d68..7233288a813288f7740f2ce84366ae3b21169ef5 100644 (file)
@@ -787,9 +787,9 @@ Four examples of `extern crate` declarations:
 ~~~~ {.ignore}
 extern crate pcre;
 
-extern crate extra; // equivalent to: extern crate extra = "extra";
+extern crate std; // equivalent to: extern crate std = "std";
 
-extern crate rustextra = "extra"; // linking to 'extra' under another name
+extern crate ruststd = "std"; // linking to 'std' under another name
 
 extern crate foo = "some/where/rust-foo#foo:1.0"; // a full package ID for external tools
 ~~~~
@@ -1055,7 +1055,7 @@ output slot type would normally be. For example:
 
 ~~~~
 fn my_err(s: &str) -> ! {
-    info!("{}", s);
+    println!("{}", s);
     fail!();
 }
 ~~~~
@@ -3885,6 +3885,9 @@ Rust provides several macros to log information. Here's a simple Rust program
 that demonstrates all four of them:
 
 ~~~~
+#[feature(phase)];
+#[phase(syntax, link)] extern crate log;
+
 fn main() {
     error!("This is an error log")
     warn!("This is a warn log")
index 15fd21e9fbc079806ae067d495b6c0836185082e..cdb521b96c42f6409d8c0b73946fc24dea99083b 100644 (file)
@@ -796,7 +796,7 @@ unit, `()`, as the empty tuple if you like).
 ~~~~
 let mytup: (int, int, f64) = (10, 20, 30.0);
 match mytup {
-  (a, b, c) => info!("{}", a + b + (c as int))
+  (a, b, c) => println!("{}", a + b + (c as int))
 }
 ~~~~
 
@@ -813,7 +813,7 @@ For example:
 struct MyTup(int, int, f64);
 let mytup: MyTup = MyTup(10, 20, 30.0);
 match mytup {
-  MyTup(a, b, c) => info!("{}", a + b + (c as int))
+  MyTup(a, b, c) => println!("{}", a + b + (c as int))
 }
 ~~~~
 
@@ -1794,7 +1794,7 @@ use std::task::spawn;
 
 // proc is the closure which will be spawned.
 spawn(proc() {
-    debug!("I'm a new task")
+    println!("I'm a new task")
 });
 ~~~~
 
@@ -3228,17 +3228,6 @@ See the [API documentation][stddoc] for details.
 
 [stddoc]: std/index.html
 
-## The extra library
-
-Rust ships with crates such as the [extra library], an accumulation of useful things,
-that are however not important enough to deserve a place in the standard
-library.  You can link to a library such as `extra` with an `extern crate extra;`.
-
-[extra library]: extra/index.html
-
-Right now `extra` contains those definitions directly, but in the future it will likely just
-re-export a bunch of 'officially blessed' crates that get managed with a package manager.
-
 # What next?
 
 Now that you know the essentials, check out any of the additional
index 2590db56d0ac0c5d9e4eb4001a1c33cbfc5b5b09..a7f23405de5f70dfddf8f66650fd0c5ac9756809 100755 (executable)
@@ -56,7 +56,6 @@ c.write(
 #[feature(globs, macro_rules, struct_variant, managed_boxes)];
 #[allow(warnings)];
 extern crate collections;
-extern crate extra;
 """
 )
 for t in stage2_tests:
@@ -73,7 +72,6 @@ d.write(
 """
 // AUTO-GENERATED FILE: DO NOT EDIT
 #[feature(globs, managed_boxes)];
-extern crate extra;
 extern crate run_pass_stage2;
 use run_pass_stage2::*;
 use std::io;
index 260c1c8912475f7f7a850ae177c182100e5b73ea..05ce884dfb18655b236fada9980a55a4697ac7d7 100755 (executable)
@@ -38,7 +38,6 @@ TEMPLATE = """// Copyright {year} The Rust Project Developers. See the COPYRIGHT
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 {error_deriving}
index 2ccb8e9c4c25034ba764dd0af0228557063ded20..f2c98b8e5fc383380517d3b22d97990cbc85e7aa 100644 (file)
 #[crate_type = "rlib"];
 #[crate_type = "dylib"];
 #[license = "MIT/ASL2"];
+#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+      html_root_url = "http://static.rust-lang.org/doc/master")];
 #[allow(missing_doc)];
 #[feature(managed_boxes)];
+#[allow(deprecated_owned_vector)];
 
 extern crate collections;
 
index 85a47d0d62c128d25dc66e5f502567fbfd12acc3..46d3ab432cdf35d10a2c19c1a95e127e3010bd6d 100644 (file)
@@ -9,56 +9,6 @@
 // except according to those terms.
 
 //! Unordered containers, implemented as hash-tables (`HashSet` and `HashMap` types)
-//!
-//! The tables use a keyed hash with new random keys generated for each container, so the ordering
-//! of a set of keys in a hash table is randomized.
-//!
-//! This is currently implemented with robin hood hashing, as described in [1][2][3].
-//!
-//! # Example
-//!
-//! ```rust
-//! use collections::HashMap;
-//!
-//! // type inference lets us omit an explicit type signature (which
-//! // would be `HashMap<&str, &str>` in this example).
-//! let mut book_reviews = HashMap::new();
-//!
-//! // review some books.
-//! book_reviews.insert("Adventures of Hucklebury Fin",      "My favorite book.");
-//! book_reviews.insert("Grimms' Fairy Tales",               "Masterpiece.");
-//! book_reviews.insert("Pride and Prejudice",               "Very enjoyable.");
-//! book_reviews.insert("The Adventures of Sherlock Holmes", "Eye lyked it alot.");
-//!
-//! // check for a specific one.
-//! if !book_reviews.contains_key(& &"Les Misérables") {
-//!     println!("We've got {} reviews, but Les Misérables ain't one.",
-//!              book_reviews.len());
-//! }
-//!
-//! // oops, this review has a lot of spelling mistakes, let's delete it.
-//! book_reviews.remove(& &"The Adventures of Sherlock Holmes");
-//!
-//! // look up the values associated with some keys.
-//! let to_find = ["Pride and Prejudice", "Alice's Adventure in Wonderland"];
-//! for book in to_find.iter() {
-//!     match book_reviews.find(book) {
-//!         Some(review) => println!("{}: {}", *book, *review),
-//!         None => println!("{} is unreviewed.", *book)
-//!     }
-//! }
-//!
-//! // iterate over everything.
-//! for (book, review) in book_reviews.iter() {
-//!     println!("{}: \"{}\"", *book, *review);
-//! }
-//! ```
-//!
-//! Relevant papers/articles:
-//!
-//! [1]: Pedro Celis. ["Robin Hood Hashing"](https://cs.uwaterloo.ca/research/tr/1986/CS-86-14.pdf)
-//! [2]: (http://codecapsule.com/2013/11/11/robin-hood-hashing/)
-//! [3]: (http://codecapsule.com/2013/11/17/robin-hood-hashing-backward-shift-deletion/)
 
 use std::container::{Container, Mutable, Map, MutableMap, Set, MutableSet};
 use std::clone::Clone;
@@ -667,14 +617,64 @@ fn fraction_mul(lhs: uint, (num, den): Fraction) -> uint {
 // `table::RawTable::new`, but I'm not confident it works for all sane alignments,
 // especially if a type needs more alignment than `malloc` provides.
 
-/// A hash map implementation which uses linear probing with Robin Hood bucket
-/// stealing.
+/// A hash map implementation which uses linear probing with Robin
+/// Hood bucket stealing.
 ///
 /// The hashes are all keyed by the task-local random number generator
-/// on creation by default. This can be overriden with one of the constructors.
+/// on creation by default, this means the ordering of the keys is
+/// randomized, but makes the tables more resistant to
+/// denial-of-service attacks (Hash DoS). This behaviour can be
+/// overriden with one of the constructors.
 ///
 /// It is required that the keys implement the `Eq` and `Hash` traits, although
 /// this can frequently be achieved by using `#[deriving(Eq, Hash)]`.
+///
+/// Relevant papers/articles:
+///
+/// 1. Pedro Celis. ["Robin Hood Hashing"](https://cs.uwaterloo.ca/research/tr/1986/CS-86-14.pdf)
+/// 2. Emmanuel Goossaert. ["Robin Hood
+///    hashing"](http://codecapsule.com/2013/11/11/robin-hood-hashing/)
+/// 3. Emmanuel Goossaert. ["Robin Hood hashing: backward shift
+///    deletion"](http://codecapsule.com/2013/11/17/robin-hood-hashing-backward-shift-deletion/)
+///
+/// # Example
+///
+/// ```rust
+/// use collections::HashMap;
+///
+/// // type inference lets us omit an explicit type signature (which
+/// // would be `HashMap<&str, &str>` in this example).
+/// let mut book_reviews = HashMap::new();
+///
+/// // review some books.
+/// book_reviews.insert("Adventures of Hucklebury Fin",      "My favorite book.");
+/// book_reviews.insert("Grimms' Fairy Tales",               "Masterpiece.");
+/// book_reviews.insert("Pride and Prejudice",               "Very enjoyable.");
+/// book_reviews.insert("The Adventures of Sherlock Holmes", "Eye lyked it alot.");
+///
+/// // check for a specific one.
+/// if !book_reviews.contains_key(& &"Les Misérables") {
+///     println!("We've got {} reviews, but Les Misérables ain't one.",
+///              book_reviews.len());
+/// }
+///
+/// // oops, this review has a lot of spelling mistakes, let's delete it.
+/// book_reviews.remove(& &"The Adventures of Sherlock Holmes");
+///
+/// // look up the values associated with some keys.
+/// let to_find = ["Pride and Prejudice", "Alice's Adventure in Wonderland"];
+/// for book in to_find.iter() {
+///     match book_reviews.find(book) {
+///         Some(review) => println!("{}: {}", *book, *review),
+///         None => println!("{} is unreviewed.", *book)
+///     }
+/// }
+///
+/// // iterate over everything.
+/// for (book, review) in book_reviews.iter() {
+///     println!("{}: \"{}\"", *book, *review);
+/// }
+/// ```
 #[deriving(Clone)]
 pub struct HashMap<K, V, H = sip::SipHasher> {
     // All hashes are keyed on these values, to prevent hash collision attacks.
@@ -1069,41 +1069,49 @@ fn make_some_room(&mut self, new_size: uint) {
     /// so we have some sort of upper bound on the number of probes to do.
     ///
     /// 'hash', 'k', and 'v' are the elements to robin hood into the hashtable.
-    fn robin_hood(&mut self, index: table::FullIndex, dib_param: uint,
-                  hash: table::SafeHash, k: K, v: V) {
-        let (old_hash, old_key, old_val) = {
-            let (old_hash_ref, old_key_ref, old_val_ref) = self.table.read_all_mut(&index);
-
-            let old_hash = replace(old_hash_ref, hash);
-            let old_key  = replace(old_key_ref,  k);
-            let old_val  = replace(old_val_ref,  v);
-
-            (old_hash, old_key, old_val)
-        };
-
-        let mut probe = self.probe_next(index.raw_index());
-
-        for dib in range(dib_param + 1, self.table.size()) {
-            let full_index = match self.table.peek(probe) {
-                table::Empty(idx) => {
-                    // Finally. A hole!
-                    self.table.put(idx, old_hash, old_key, old_val);
-                    return;
-                },
-                table::Full(idx) => idx
+    fn robin_hood(&mut self, mut index: table::FullIndex, mut dib_param: uint,
+                  mut hash: table::SafeHash, mut k: K, mut v: V) {
+        'outer: loop {
+            let (old_hash, old_key, old_val) = {
+                let (old_hash_ref, old_key_ref, old_val_ref) =
+                        self.table.read_all_mut(&index);
+
+                let old_hash = replace(old_hash_ref, hash);
+                let old_key  = replace(old_key_ref,  k);
+                let old_val  = replace(old_val_ref,  v);
+
+                (old_hash, old_key, old_val)
             };
 
-            let probe_dib = self.bucket_distance(&full_index);
+            let mut probe = self.probe_next(index.raw_index());
+
+            for dib in range(dib_param + 1, self.table.size()) {
+                let full_index = match self.table.peek(probe) {
+                    table::Empty(idx) => {
+                        // Finally. A hole!
+                        self.table.put(idx, old_hash, old_key, old_val);
+                        return;
+                    },
+                    table::Full(idx) => idx
+                };
+
+                let probe_dib = self.bucket_distance(&full_index);
+
+                // Robin hood! Steal the spot.
+                if probe_dib < dib {
+                    index = full_index;
+                    dib_param = probe_dib;
+                    hash = old_hash;
+                    k = old_key;
+                    v = old_val;
+                    continue 'outer;
+                }
 
-            if probe_dib < dib {
-                // Robin hood! Steal the spot. This had better be tail call.
-                return self.robin_hood(full_index, probe_dib, old_hash, old_key, old_val);
+                probe = self.probe_next(probe);
             }
 
-            probe = self.probe_next(probe);
+            fail!("HashMap fatal error: 100% load factor?");
         }
-
-        fail!("HashMap fatal error: 100% load factor?");
     }
 
     /// Manually insert a pre-hashed key-value pair, without first checking
@@ -1948,7 +1956,6 @@ fn test_from_iter() {
 
 #[cfg(test)]
 mod test_set {
-    use super::HashMap;
     use super::HashSet;
     use std::container::Container;
     use std::vec::ImmutableEqVector;
@@ -2193,7 +2200,6 @@ fn test_show() {
 mod bench {
     extern crate test;
     use self::test::BenchHarness;
-    use std::iter;
     use std::iter::{range_inclusive};
 
     #[bench]
index a087180d9a50277f4729c550e34f83b220f6d1d5..24478ff8c5fb56a17190269e6920ed6a05190039 100644 (file)
 #[crate_type = "rlib"];
 #[crate_type = "dylib"];
 #[license = "MIT/ASL2"];
+#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+      html_root_url = "http://static.rust-lang.org/doc/master")];
 
-#[feature(macro_rules, managed_boxes, default_type_params)];
+#[feature(macro_rules, managed_boxes, default_type_params, phase)];
 
 // NOTE remove the following two attributes after the next snapshot.
 #[allow(unrecognized_lint)];
 #[allow(default_type_param_usage)];
+#[allow(deprecated_owned_vector)];
 
 extern crate rand;
 
 #[cfg(test)] extern crate test;
+#[cfg(test)] #[phase(syntax, link)] extern crate log;
 
 pub use bitv::Bitv;
 pub use btree::BTree;
diff --git a/src/libextra/c_vec.rs b/src/libextra/c_vec.rs
deleted file mode 100644 (file)
index b93ffce..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-/*!
- * Library to interface with chunks of memory allocated in C.
- *
- * It is often desirable to safely interface with memory allocated from C,
- * encapsulating the unsafety into allocation and destruction time.  Indeed,
- * allocating memory externally is currently the only way to give Rust shared
- * mut state with C programs that keep their own references; vectors are
- * unsuitable because they could be reallocated or moved at any time, and
- * importing C memory into a vector takes a one-time snapshot of the memory.
- *
- * This module simplifies the usage of such external blocks of memory.  Memory
- * is encapsulated into an opaque object after creation; the lifecycle of the
- * memory can be optionally managed by Rust, if an appropriate destructor
- * closure is provided.  Safety is ensured by bounds-checking accesses, which
- * are marshalled through get and set functions.
- *
- * There are three unsafe functions: the two constructors, and the
- * unwrap method. The constructors are unsafe for the
- * obvious reason (they act on a pointer that cannot be checked inside the
- * method), but `unwrap()` is somewhat more subtle in its unsafety.
- * It returns the contained pointer, but at the same time destroys the CVec
- * without running its destructor. This can be used to pass memory back to
- * C, but care must be taken that the ownership of underlying resources are
- * handled correctly, i.e. that allocated memory is eventually freed
- * if necessary.
- */
-
-use std::cast;
-use std::ptr;
-use std::raw;
-
-/**
- * The type representing a foreign chunk of memory
- */
-pub struct CVec<T> {
-    priv base: *mut T,
-    priv len: uint,
-    priv rsrc: DtorRes,
-}
-
-struct DtorRes {
-    dtor: Option<proc()>,
-}
-
-#[unsafe_destructor]
-impl Drop for DtorRes {
-    fn drop(&mut self) {
-        let dtor = self.dtor.take();
-        match dtor {
-            None => (),
-            Some(f) => f()
-        }
-    }
-}
-
-impl DtorRes {
-    fn new(dtor: Option<proc()>) -> DtorRes {
-        DtorRes {
-            dtor: dtor,
-        }
-    }
-}
-
-impl <T> CVec<T> {
-    /**
-     * Create a `CVec` from a raw pointer to a buffer with a given length.
-     *
-     * Fails if the given pointer is null.
-     *
-     * # Arguments
-     *
-     * * base - A raw pointer to a buffer
-     * * len - The number of elements in the buffer
-     */
-    pub unsafe fn new(base: *mut T, len: uint) -> CVec<T> {
-        assert!(base != ptr::mut_null());
-        CVec {
-            base: base,
-            len: len,
-            rsrc: DtorRes::new(None)
-        }
-    }
-
-    /**
-     * Create a `CVec` from a foreign buffer, with a given length,
-     * and a function to run upon destruction.
-     *
-     * Fails if the given pointer is null.
-     *
-     * # Arguments
-     *
-     * * base - A foreign pointer to a buffer
-     * * len - The number of elements in the buffer
-     * * dtor - A proc to run when the value is destructed, useful
-     *          for freeing the buffer, etc.
-     */
-    pub unsafe fn new_with_dtor(base: *mut T, len: uint, dtor: proc()) -> CVec<T> {
-        assert!(base != ptr::mut_null());
-        CVec {
-            base: base,
-            len: len,
-            rsrc: DtorRes::new(Some(dtor))
-        }
-    }
-
-    /// View the stored data as a slice.
-    pub fn as_slice<'a>(&'a self) -> &'a [T] {
-        unsafe {
-            cast::transmute(raw::Slice { data: self.base as *T, len: self.len })
-        }
-    }
-
-    /// View the stored data as a mutable slice.
-    pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
-        unsafe {
-            cast::transmute(raw::Slice { data: self.base as *T, len: self.len })
-        }
-    }
-
-    /**
-     * Retrieves an element at a given index
-     *
-     * Fails if `ofs` is greater or equal to the length of the vector
-     */
-    pub fn get<'a>(&'a self, ofs: uint) -> &'a T {
-        assert!(ofs < self.len);
-        unsafe {
-            &*self.base.offset(ofs as int)
-        }
-    }
-
-    /**
-     * Retrieves a mutable element at a given index
-     *
-     * Fails if `ofs` is greater or equal to the length of the vector
-     */
-    pub fn get_mut<'a>(&'a mut self, ofs: uint) -> &'a mut T {
-        assert!(ofs < self.len);
-        unsafe {
-            &mut *self.base.offset(ofs as int)
-        }
-    }
-
-    /**
-     * Unwrap the pointer without running the destructor
-     *
-     * This method retrieves the underlying pointer, and in the process
-     * destroys the CVec but without running the destructor. A use case
-     * would be transferring ownership of the buffer to a C function, as
-     * in this case you would not want to run the destructor.
-     *
-     * Note that if you want to access the underlying pointer without
-     * cancelling the destructor, you can simply call `transmute` on the return
-     * value of `get(0)`.
-     */
-    pub unsafe fn unwrap(mut self) -> *mut T {
-        self.rsrc.dtor = None;
-        self.base
-    }
-}
-
-impl <T> Container for CVec<T> {
-    /// Returns the length of the vector
-    fn len(&self) -> uint { self.len }
-}
-
-#[cfg(test)]
-mod tests {
-    use super::*;
-
-    use std::libc::*;
-    use std::libc;
-    use std::ptr;
-    use std::rt::global_heap::malloc_raw;
-
-    fn malloc(n: uint) -> CVec<u8> {
-        unsafe {
-            let mem = malloc_raw(n);
-
-            CVec::new_with_dtor(mem as *mut u8, n,
-                proc() { libc::free(mem as *mut c_void); })
-        }
-    }
-
-    #[test]
-    fn test_basic() {
-        let mut cv = malloc(16);
-
-        *cv.get_mut(3) = 8;
-        *cv.get_mut(4) = 9;
-        assert_eq!(*cv.get(3), 8);
-        assert_eq!(*cv.get(4), 9);
-        assert_eq!(cv.len(), 16);
-    }
-
-    #[test]
-    #[should_fail]
-    fn test_fail_at_null() {
-        unsafe {
-            CVec::new(ptr::mut_null::<u8>(), 9);
-        }
-    }
-
-    #[test]
-    #[should_fail]
-    fn test_overrun_get() {
-        let cv = malloc(16);
-
-        cv.get(17);
-    }
-
-    #[test]
-    #[should_fail]
-    fn test_overrun_set() {
-        let mut cv = malloc(16);
-
-        *cv.get_mut(17) =  0;
-    }
-
-    #[test]
-    fn test_unwrap() {
-        unsafe {
-            let cv = CVec::new_with_dtor(1 as *mut int, 0,
-                proc() { fail!("Don't run this destructor!") });
-            let p = cv.unwrap();
-            assert_eq!(p, 1 as *mut int);
-        }
-    }
-
-}
diff --git a/src/libextra/lib.rs b/src/libextra/lib.rs
deleted file mode 100644 (file)
index 32de7bf..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-/*!
-
-Rust extras.
-
-The `extra` crate is a set of useful modules for a variety of
-purposes, including collections, numerics, I/O, serialization,
-and concurrency.
-
-Rust extras are part of the standard Rust distribution.
-
-*/
-
-#[crate_id = "extra#0.10-pre"];
-#[comment = "Rust extras"];
-#[license = "MIT/ASL2"];
-#[crate_type = "rlib"];
-#[crate_type = "dylib"];
-#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
-      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
-      html_root_url = "http://static.rust-lang.org/doc/master")];
-
-#[feature(macro_rules, globs, managed_boxes, asm, default_type_params)];
-
-#[deny(non_camel_case_types)];
-#[deny(missing_doc)];
-
-extern crate collections;
-extern crate rand;
-extern crate serialize;
-extern crate sync;
-extern crate time;
-
-// Utility modules
-pub mod c_vec;
-pub mod url;
-pub mod tempfile;
-pub mod workcache;
-pub mod stats;
-
-#[cfg(unicode)]
-mod unicode;
diff --git a/src/libextra/stats.rs b/src/libextra/stats.rs
deleted file mode 100644 (file)
index d67e8f8..0000000
+++ /dev/null
@@ -1,1057 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[allow(missing_doc)];
-
-use std::hash::Hash;
-use std::io;
-use std::mem;
-use std::num;
-use collections::hashmap;
-
-// NB: this can probably be rewritten in terms of num::Num
-// to be less f64-specific.
-
-fn f64_cmp(x: f64, y: f64) -> Ordering {
-    // arbitrarily decide that NaNs are larger than everything.
-    if y.is_nan() {
-        Less
-    } else if x.is_nan() {
-        Greater
-    } else if x < y {
-        Less
-    } else if x == y {
-        Equal
-    } else {
-        Greater
-    }
-}
-
-fn f64_sort(v: &mut [f64]) {
-    v.sort_by(|x: &f64, y: &f64| f64_cmp(*x, *y));
-}
-
-/// Trait that provides simple descriptive statistics on a univariate set of numeric samples.
-pub trait Stats {
-
-    /// Sum of the samples.
-    ///
-    /// Note: this method sacrifices performance at the altar of accuracy
-    /// Depends on IEEE-754 arithmetic guarantees. See proof of correctness at:
-    /// ["Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates"]
-    /// (http://www.cs.cmu.edu/~quake-papers/robust-arithmetic.ps)
-    /// *Discrete & Computational Geometry 18*, 3 (Oct 1997), 305-363, Shewchuk J.R.
-    fn sum(self) -> f64;
-
-    /// Minimum value of the samples.
-    fn min(self) -> f64;
-
-    /// Maximum value of the samples.
-    fn max(self) -> f64;
-
-    /// Arithmetic mean (average) of the samples: sum divided by sample-count.
-    ///
-    /// See: https://en.wikipedia.org/wiki/Arithmetic_mean
-    fn mean(self) -> f64;
-
-    /// Median of the samples: value separating the lower half of the samples from the higher half.
-    /// Equal to `self.percentile(50.0)`.
-    ///
-    /// See: https://en.wikipedia.org/wiki/Median
-    fn median(self) -> f64;
-
-    /// Variance of the samples: bias-corrected mean of the squares of the differences of each
-    /// sample from the sample mean. Note that this calculates the _sample variance_ rather than the
-    /// population variance, which is assumed to be unknown. It therefore corrects the `(n-1)/n`
-    /// bias that would appear if we calculated a population variance, by dividing by `(n-1)` rather
-    /// than `n`.
-    ///
-    /// See: https://en.wikipedia.org/wiki/Variance
-    fn var(self) -> f64;
-
-    /// Standard deviation: the square root of the sample variance.
-    ///
-    /// Note: this is not a robust statistic for non-normal distributions. Prefer the
-    /// `median_abs_dev` for unknown distributions.
-    ///
-    /// See: https://en.wikipedia.org/wiki/Standard_deviation
-    fn std_dev(self) -> f64;
-
-    /// Standard deviation as a percent of the mean value. See `std_dev` and `mean`.
-    ///
-    /// Note: this is not a robust statistic for non-normal distributions. Prefer the
-    /// `median_abs_dev_pct` for unknown distributions.
-    fn std_dev_pct(self) -> f64;
-
-    /// Scaled median of the absolute deviations of each sample from the sample median. This is a
-    /// robust (distribution-agnostic) estimator of sample variability. Use this in preference to
-    /// `std_dev` if you cannot assume your sample is normally distributed. Note that this is scaled
-    /// by the constant `1.4826` to allow its use as a consistent estimator for the standard
-    /// deviation.
-    ///
-    /// See: http://en.wikipedia.org/wiki/Median_absolute_deviation
-    fn median_abs_dev(self) -> f64;
-
-    /// Median absolute deviation as a percent of the median. See `median_abs_dev` and `median`.
-    fn median_abs_dev_pct(self) -> f64;
-
-    /// Percentile: the value below which `pct` percent of the values in `self` fall. For example,
-    /// percentile(95.0) will return the value `v` such that 95% of the samples `s` in `self`
-    /// satisfy `s <= v`.
-    ///
-    /// Calculated by linear interpolation between closest ranks.
-    ///
-    /// See: http://en.wikipedia.org/wiki/Percentile
-    fn percentile(self, pct: f64) -> f64;
-
-    /// Quartiles of the sample: three values that divide the sample into four equal groups, each
-    /// with 1/4 of the data. The middle value is the median. See `median` and `percentile`. This
-    /// function may calculate the 3 quartiles more efficiently than 3 calls to `percentile`, but
-    /// is otherwise equivalent.
-    ///
-    /// See also: https://en.wikipedia.org/wiki/Quartile
-    fn quartiles(self) -> (f64,f64,f64);
-
-    /// Inter-quartile range: the difference between the 25th percentile (1st quartile) and the 75th
-    /// percentile (3rd quartile). See `quartiles`.
-    ///
-    /// See also: https://en.wikipedia.org/wiki/Interquartile_range
-    fn iqr(self) -> f64;
-}
-
-/// Extracted collection of all the summary statistics of a sample set.
-#[deriving(Clone, Eq)]
-#[allow(missing_doc)]
-pub struct Summary {
-    sum: f64,
-    min: f64,
-    max: f64,
-    mean: f64,
-    median: f64,
-    var: f64,
-    std_dev: f64,
-    std_dev_pct: f64,
-    median_abs_dev: f64,
-    median_abs_dev_pct: f64,
-    quartiles: (f64,f64,f64),
-    iqr: f64,
-}
-
-impl Summary {
-
-    /// Construct a new summary of a sample set.
-    pub fn new(samples: &[f64]) -> Summary {
-        Summary {
-            sum: samples.sum(),
-            min: samples.min(),
-            max: samples.max(),
-            mean: samples.mean(),
-            median: samples.median(),
-            var: samples.var(),
-            std_dev: samples.std_dev(),
-            std_dev_pct: samples.std_dev_pct(),
-            median_abs_dev: samples.median_abs_dev(),
-            median_abs_dev_pct: samples.median_abs_dev_pct(),
-            quartiles: samples.quartiles(),
-            iqr: samples.iqr()
-        }
-    }
-}
-
-impl<'a> Stats for &'a [f64] {
-
-    // FIXME #11059 handle NaN, inf and overflow
-    fn sum(self) -> f64 {
-        let mut partials : ~[f64] = ~[];
-
-        for &mut x in self.iter() {
-            let mut j = 0;
-            // This inner loop applies `hi`/`lo` summation to each
-            // partial so that the list of partial sums remains exact.
-            for i in range(0, partials.len()) {
-                let mut y = partials[i];
-                if num::abs(x) < num::abs(y) {
-                    mem::swap(&mut x, &mut y);
-                }
-                // Rounded `x+y` is stored in `hi` with round-off stored in
-                // `lo`. Together `hi+lo` are exactly equal to `x+y`.
-                let hi = x + y;
-                let lo = y - (hi - x);
-                if lo != 0f64 {
-                    partials[j] = lo;
-                    j += 1;
-                }
-                x = hi;
-            }
-            if j >= partials.len() {
-                partials.push(x);
-            } else {
-                partials[j] = x;
-                partials.truncate(j+1);
-            }
-        }
-        partials.iter().fold(0.0, |p, q| p + *q)
-    }
-
-    fn min(self) -> f64 {
-        assert!(self.len() != 0);
-        self.iter().fold(self[0], |p, q| p.min(*q))
-    }
-
-    fn max(self) -> f64 {
-        assert!(self.len() != 0);
-        self.iter().fold(self[0], |p, q| p.max(*q))
-    }
-
-    fn mean(self) -> f64 {
-        assert!(self.len() != 0);
-        self.sum() / (self.len() as f64)
-    }
-
-    fn median(self) -> f64 {
-        self.percentile(50.0)
-    }
-
-    fn var(self) -> f64 {
-        if self.len() < 2 {
-            0.0
-        } else {
-            let mean = self.mean();
-            let mut v = 0.0;
-            for s in self.iter() {
-                let x = *s - mean;
-                v += x*x;
-            }
-            // NB: this is _supposed to be_ len-1, not len. If you
-            // change it back to len, you will be calculating a
-            // population variance, not a sample variance.
-            v/((self.len()-1) as f64)
-        }
-    }
-
-    fn std_dev(self) -> f64 {
-        self.var().sqrt()
-    }
-
-    fn std_dev_pct(self) -> f64 {
-        (self.std_dev() / self.mean()) * 100.0
-    }
-
-    fn median_abs_dev(self) -> f64 {
-        let med = self.median();
-        let abs_devs = self.map(|&v| num::abs(med - v));
-        // This constant is derived by smarter statistics brains than me, but it is
-        // consistent with how R and other packages treat the MAD.
-        abs_devs.median() * 1.4826
-    }
-
-    fn median_abs_dev_pct(self) -> f64 {
-        (self.median_abs_dev() / self.median()) * 100.0
-    }
-
-    fn percentile(self, pct: f64) -> f64 {
-        let mut tmp = self.to_owned();
-        f64_sort(tmp);
-        percentile_of_sorted(tmp, pct)
-    }
-
-    fn quartiles(self) -> (f64,f64,f64) {
-        let mut tmp = self.to_owned();
-        f64_sort(tmp);
-        let a = percentile_of_sorted(tmp, 25.0);
-        let b = percentile_of_sorted(tmp, 50.0);
-        let c = percentile_of_sorted(tmp, 75.0);
-        (a,b,c)
-    }
-
-    fn iqr(self) -> f64 {
-        let (a,_,c) = self.quartiles();
-        c - a
-    }
-}
-
-
-// Helper function: extract a value representing the `pct` percentile of a sorted sample-set, using
-// linear interpolation. If samples are not sorted, return nonsensical value.
-fn percentile_of_sorted(sorted_samples: &[f64],
-                             pct: f64) -> f64 {
-    assert!(sorted_samples.len() != 0);
-    if sorted_samples.len() == 1 {
-        return sorted_samples[0];
-    }
-    assert!(0.0 <= pct);
-    assert!(pct <= 100.0);
-    if pct == 100.0 {
-        return sorted_samples[sorted_samples.len() - 1];
-    }
-    let rank = (pct / 100.0) * ((sorted_samples.len() - 1) as f64);
-    let lrank = rank.floor();
-    let d = rank - lrank;
-    let n = lrank as uint;
-    let lo = sorted_samples[n];
-    let hi = sorted_samples[n+1];
-    lo + (hi - lo) * d
-}
-
-
-/// Winsorize a set of samples, replacing values above the `100-pct` percentile and below the `pct`
-/// percentile with those percentiles themselves. This is a way of minimizing the effect of
-/// outliers, at the cost of biasing the sample. It differs from trimming in that it does not
-/// change the number of samples, just changes the values of those that are outliers.
-///
-/// See: http://en.wikipedia.org/wiki/Winsorising
-pub fn winsorize(samples: &mut [f64], pct: f64) {
-    let mut tmp = samples.to_owned();
-    f64_sort(tmp);
-    let lo = percentile_of_sorted(tmp, pct);
-    let hi = percentile_of_sorted(tmp, 100.0-pct);
-    for samp in samples.mut_iter() {
-        if *samp > hi {
-            *samp = hi
-        } else if *samp < lo {
-            *samp = lo
-        }
-    }
-}
-
-/// Render writes the min, max and quartiles of the provided `Summary` to the provided `Writer`.
-pub fn write_5_number_summary(w: &mut io::Writer,
-                              s: &Summary) -> io::IoResult<()> {
-    let (q1,q2,q3) = s.quartiles;
-    write!(w, "(min={}, q1={}, med={}, q3={}, max={})",
-                     s.min,
-                     q1,
-                     q2,
-                     q3,
-                     s.max)
-}
-
-/// Render a boxplot to the provided writer. The boxplot shows the min, max and quartiles of the
-/// provided `Summary` (thus includes the mean) and is scaled to display within the range of the
-/// nearest multiple-of-a-power-of-ten above and below the min and max of possible values, and
-/// target `width_hint` characters of display (though it will be wider if necessary).
-///
-/// As an example, the summary with 5-number-summary `(min=15, q1=17, med=20, q3=24, max=31)` might
-/// display as:
-///
-/// ~~~~ignore
-///   10 |        [--****#******----------]          | 40
-/// ~~~~
-
-pub fn write_boxplot(w: &mut io::Writer, s: &Summary,
-                     width_hint: uint) -> io::IoResult<()> {
-
-    let (q1,q2,q3) = s.quartiles;
-
-    // the .abs() handles the case where numbers are negative
-    let lomag = (10.0_f64).powf(&(s.min.abs().log10().floor()));
-    let himag = (10.0_f64).powf(&(s.max.abs().log10().floor()));
-
-    // need to consider when the limit is zero
-    let lo = if lomag == 0.0 {
-        0.0
-    } else {
-        (s.min / lomag).floor() * lomag
-    };
-
-    let hi = if himag == 0.0 {
-        0.0
-    } else {
-        (s.max / himag).ceil() * himag
-    };
-
-    let range = hi - lo;
-
-    let lostr = lo.to_str();
-    let histr = hi.to_str();
-
-    let overhead_width = lostr.len() + histr.len() + 4;
-    let range_width = width_hint - overhead_width;;
-    let char_step = range / (range_width as f64);
-
-    try!(write!(w, "{} |", lostr));
-
-    let mut c = 0;
-    let mut v = lo;
-
-    while c < range_width && v < s.min {
-        try!(write!(w, " "));
-        v += char_step;
-        c += 1;
-    }
-    try!(write!(w, "["));
-    c += 1;
-    while c < range_width && v < q1 {
-        try!(write!(w, "-"));
-        v += char_step;
-        c += 1;
-    }
-    while c < range_width && v < q2 {
-        try!(write!(w, "*"));
-        v += char_step;
-        c += 1;
-    }
-    try!(write!(w, r"\#"));
-    c += 1;
-    while c < range_width && v < q3 {
-        try!(write!(w, "*"));
-        v += char_step;
-        c += 1;
-    }
-    while c < range_width && v < s.max {
-        try!(write!(w, "-"));
-        v += char_step;
-        c += 1;
-    }
-    try!(write!(w, "]"));
-    while c < range_width {
-        try!(write!(w, " "));
-        v += char_step;
-        c += 1;
-    }
-
-    try!(write!(w, "| {}", histr));
-    Ok(())
-}
-
-/// Returns a HashMap with the number of occurrences of every element in the
-/// sequence that the iterator exposes.
-pub fn freq_count<T: Iterator<U>, U: Eq+Hash>(mut iter: T) -> hashmap::HashMap<U, uint> {
-    let mut map: hashmap::HashMap<U,uint> = hashmap::HashMap::new();
-    for elem in iter {
-        map.insert_or_update_with(elem, 1, |_, count| *count += 1);
-    }
-    map
-}
-
-// Test vectors generated from R, using the script src/etc/stat-test-vectors.r.
-
-#[cfg(test)]
-mod tests {
-    use stats::Stats;
-    use stats::Summary;
-    use stats::write_5_number_summary;
-    use stats::write_boxplot;
-    use std::io;
-    use std::str;
-    use std::f64;
-
-    macro_rules! assert_approx_eq(
-        ($a:expr, $b:expr) => ({
-            let (a, b) = (&$a, &$b);
-            assert!((*a - *b).abs() < 1.0e-6,
-                    "{} is not approximately equal to {}", *a, *b);
-        })
-    )
-
-    fn check(samples: &[f64], summ: &Summary) {
-
-        let summ2 = Summary::new(samples);
-
-        let mut w = io::stdout();
-        let w = &mut w as &mut io::Writer;
-        (write!(w, "\n")).unwrap();
-        write_5_number_summary(w, &summ2).unwrap();
-        (write!(w, "\n")).unwrap();
-        write_boxplot(w, &summ2, 50).unwrap();
-        (write!(w, "\n")).unwrap();
-
-        assert_eq!(summ.sum, summ2.sum);
-        assert_eq!(summ.min, summ2.min);
-        assert_eq!(summ.max, summ2.max);
-        assert_eq!(summ.mean, summ2.mean);
-        assert_eq!(summ.median, summ2.median);
-
-        // We needed a few more digits to get exact equality on these
-        // but they're within float epsilon, which is 1.0e-6.
-        assert_approx_eq!(summ.var, summ2.var);
-        assert_approx_eq!(summ.std_dev, summ2.std_dev);
-        assert_approx_eq!(summ.std_dev_pct, summ2.std_dev_pct);
-        assert_approx_eq!(summ.median_abs_dev, summ2.median_abs_dev);
-        assert_approx_eq!(summ.median_abs_dev_pct, summ2.median_abs_dev_pct);
-
-        assert_eq!(summ.quartiles, summ2.quartiles);
-        assert_eq!(summ.iqr, summ2.iqr);
-    }
-
-    #[test]
-    fn test_min_max_nan() {
-        let xs = &[1.0, 2.0, f64::NAN, 3.0, 4.0];
-        let summary = Summary::new(xs);
-        assert_eq!(summary.min, 1.0);
-        assert_eq!(summary.max, 4.0);
-    }
-
-    #[test]
-    fn test_norm2() {
-        let val = &[
-            958.0000000000,
-            924.0000000000,
-        ];
-        let summ = &Summary {
-            sum: 1882.0000000000,
-            min: 924.0000000000,
-            max: 958.0000000000,
-            mean: 941.0000000000,
-            median: 941.0000000000,
-            var: 578.0000000000,
-            std_dev: 24.0416305603,
-            std_dev_pct: 2.5549022912,
-            median_abs_dev: 25.2042000000,
-            median_abs_dev_pct: 2.6784484591,
-            quartiles: (932.5000000000,941.0000000000,949.5000000000),
-            iqr: 17.0000000000,
-        };
-        check(val, summ);
-    }
-    #[test]
-    fn test_norm10narrow() {
-        let val = &[
-            966.0000000000,
-            985.0000000000,
-            1110.0000000000,
-            848.0000000000,
-            821.0000000000,
-            975.0000000000,
-            962.0000000000,
-            1157.0000000000,
-            1217.0000000000,
-            955.0000000000,
-        ];
-        let summ = &Summary {
-            sum: 9996.0000000000,
-            min: 821.0000000000,
-            max: 1217.0000000000,
-            mean: 999.6000000000,
-            median: 970.5000000000,
-            var: 16050.7111111111,
-            std_dev: 126.6914010938,
-            std_dev_pct: 12.6742097933,
-            median_abs_dev: 102.2994000000,
-            median_abs_dev_pct: 10.5408964451,
-            quartiles: (956.7500000000,970.5000000000,1078.7500000000),
-            iqr: 122.0000000000,
-        };
-        check(val, summ);
-    }
-    #[test]
-    fn test_norm10medium() {
-        let val = &[
-            954.0000000000,
-            1064.0000000000,
-            855.0000000000,
-            1000.0000000000,
-            743.0000000000,
-            1084.0000000000,
-            704.0000000000,
-            1023.0000000000,
-            357.0000000000,
-            869.0000000000,
-        ];
-        let summ = &Summary {
-            sum: 8653.0000000000,
-            min: 357.0000000000,
-            max: 1084.0000000000,
-            mean: 865.3000000000,
-            median: 911.5000000000,
-            var: 48628.4555555556,
-            std_dev: 220.5186059170,
-            std_dev_pct: 25.4846418487,
-            median_abs_dev: 195.7032000000,
-            median_abs_dev_pct: 21.4704552935,
-            quartiles: (771.0000000000,911.5000000000,1017.2500000000),
-            iqr: 246.2500000000,
-        };
-        check(val, summ);
-    }
-    #[test]
-    fn test_norm10wide() {
-        let val = &[
-            505.0000000000,
-            497.0000000000,
-            1591.0000000000,
-            887.0000000000,
-            1026.0000000000,
-            136.0000000000,
-            1580.0000000000,
-            940.0000000000,
-            754.0000000000,
-            1433.0000000000,
-        ];
-        let summ = &Summary {
-            sum: 9349.0000000000,
-            min: 136.0000000000,
-            max: 1591.0000000000,
-            mean: 934.9000000000,
-            median: 913.5000000000,
-            var: 239208.9888888889,
-            std_dev: 489.0899599142,
-            std_dev_pct: 52.3146817750,
-            median_abs_dev: 611.5725000000,
-            median_abs_dev_pct: 66.9482758621,
-            quartiles: (567.2500000000,913.5000000000,1331.2500000000),
-            iqr: 764.0000000000,
-        };
-        check(val, summ);
-    }
-    #[test]
-    fn test_norm25verynarrow() {
-        let val = &[
-            991.0000000000,
-            1018.0000000000,
-            998.0000000000,
-            1013.0000000000,
-            974.0000000000,
-            1007.0000000000,
-            1014.0000000000,
-            999.0000000000,
-            1011.0000000000,
-            978.0000000000,
-            985.0000000000,
-            999.0000000000,
-            983.0000000000,
-            982.0000000000,
-            1015.0000000000,
-            1002.0000000000,
-            977.0000000000,
-            948.0000000000,
-            1040.0000000000,
-            974.0000000000,
-            996.0000000000,
-            989.0000000000,
-            1015.0000000000,
-            994.0000000000,
-            1024.0000000000,
-        ];
-        let summ = &Summary {
-            sum: 24926.0000000000,
-            min: 948.0000000000,
-            max: 1040.0000000000,
-            mean: 997.0400000000,
-            median: 998.0000000000,
-            var: 393.2066666667,
-            std_dev: 19.8294393937,
-            std_dev_pct: 1.9888308788,
-            median_abs_dev: 22.2390000000,
-            median_abs_dev_pct: 2.2283567134,
-            quartiles: (983.0000000000,998.0000000000,1013.0000000000),
-            iqr: 30.0000000000,
-        };
-        check(val, summ);
-    }
-    #[test]
-    fn test_exp10a() {
-        let val = &[
-            23.0000000000,
-            11.0000000000,
-            2.0000000000,
-            57.0000000000,
-            4.0000000000,
-            12.0000000000,
-            5.0000000000,
-            29.0000000000,
-            3.0000000000,
-            21.0000000000,
-        ];
-        let summ = &Summary {
-            sum: 167.0000000000,
-            min: 2.0000000000,
-            max: 57.0000000000,
-            mean: 16.7000000000,
-            median: 11.5000000000,
-            var: 287.7888888889,
-            std_dev: 16.9643416875,
-            std_dev_pct: 101.5828843560,
-            median_abs_dev: 13.3434000000,
-            median_abs_dev_pct: 116.0295652174,
-            quartiles: (4.2500000000,11.5000000000,22.5000000000),
-            iqr: 18.2500000000,
-        };
-        check(val, summ);
-    }
-    #[test]
-    fn test_exp10b() {
-        let val = &[
-            24.0000000000,
-            17.0000000000,
-            6.0000000000,
-            38.0000000000,
-            25.0000000000,
-            7.0000000000,
-            51.0000000000,
-            2.0000000000,
-            61.0000000000,
-            32.0000000000,
-        ];
-        let summ = &Summary {
-            sum: 263.0000000000,
-            min: 2.0000000000,
-            max: 61.0000000000,
-            mean: 26.3000000000,
-            median: 24.5000000000,
-            var: 383.5666666667,
-            std_dev: 19.5848580967,
-            std_dev_pct: 74.4671410520,
-            median_abs_dev: 22.9803000000,
-            median_abs_dev_pct: 93.7971428571,
-            quartiles: (9.5000000000,24.5000000000,36.5000000000),
-            iqr: 27.0000000000,
-        };
-        check(val, summ);
-    }
-    #[test]
-    fn test_exp10c() {
-        let val = &[
-            71.0000000000,
-            2.0000000000,
-            32.0000000000,
-            1.0000000000,
-            6.0000000000,
-            28.0000000000,
-            13.0000000000,
-            37.0000000000,
-            16.0000000000,
-            36.0000000000,
-        ];
-        let summ = &Summary {
-            sum: 242.0000000000,
-            min: 1.0000000000,
-            max: 71.0000000000,
-            mean: 24.2000000000,
-            median: 22.0000000000,
-            var: 458.1777777778,
-            std_dev: 21.4050876611,
-            std_dev_pct: 88.4507754589,
-            median_abs_dev: 21.4977000000,
-            median_abs_dev_pct: 97.7168181818,
-            quartiles: (7.7500000000,22.0000000000,35.0000000000),
-            iqr: 27.2500000000,
-        };
-        check(val, summ);
-    }
-    #[test]
-    fn test_exp25() {
-        let val = &[
-            3.0000000000,
-            24.0000000000,
-            1.0000000000,
-            19.0000000000,
-            7.0000000000,
-            5.0000000000,
-            30.0000000000,
-            39.0000000000,
-            31.0000000000,
-            13.0000000000,
-            25.0000000000,
-            48.0000000000,
-            1.0000000000,
-            6.0000000000,
-            42.0000000000,
-            63.0000000000,
-            2.0000000000,
-            12.0000000000,
-            108.0000000000,
-            26.0000000000,
-            1.0000000000,
-            7.0000000000,
-            44.0000000000,
-            25.0000000000,
-            11.0000000000,
-        ];
-        let summ = &Summary {
-            sum: 593.0000000000,
-            min: 1.0000000000,
-            max: 108.0000000000,
-            mean: 23.7200000000,
-            median: 19.0000000000,
-            var: 601.0433333333,
-            std_dev: 24.5161851301,
-            std_dev_pct: 103.3565983562,
-            median_abs_dev: 19.2738000000,
-            median_abs_dev_pct: 101.4410526316,
-            quartiles: (6.0000000000,19.0000000000,31.0000000000),
-            iqr: 25.0000000000,
-        };
-        check(val, summ);
-    }
-    #[test]
-    fn test_binom25() {
-        let val = &[
-            18.0000000000,
-            17.0000000000,
-            27.0000000000,
-            15.0000000000,
-            21.0000000000,
-            25.0000000000,
-            17.0000000000,
-            24.0000000000,
-            25.0000000000,
-            24.0000000000,
-            26.0000000000,
-            26.0000000000,
-            23.0000000000,
-            15.0000000000,
-            23.0000000000,
-            17.0000000000,
-            18.0000000000,
-            18.0000000000,
-            21.0000000000,
-            16.0000000000,
-            15.0000000000,
-            31.0000000000,
-            20.0000000000,
-            17.0000000000,
-            15.0000000000,
-        ];
-        let summ = &Summary {
-            sum: 514.0000000000,
-            min: 15.0000000000,
-            max: 31.0000000000,
-            mean: 20.5600000000,
-            median: 20.0000000000,
-            var: 20.8400000000,
-            std_dev: 4.5650848842,
-            std_dev_pct: 22.2037202539,
-            median_abs_dev: 5.9304000000,
-            median_abs_dev_pct: 29.6520000000,
-            quartiles: (17.0000000000,20.0000000000,24.0000000000),
-            iqr: 7.0000000000,
-        };
-        check(val, summ);
-    }
-    #[test]
-    fn test_pois25lambda30() {
-        let val = &[
-            27.0000000000,
-            33.0000000000,
-            34.0000000000,
-            34.0000000000,
-            24.0000000000,
-            39.0000000000,
-            28.0000000000,
-            27.0000000000,
-            31.0000000000,
-            28.0000000000,
-            38.0000000000,
-            21.0000000000,
-            33.0000000000,
-            36.0000000000,
-            29.0000000000,
-            37.0000000000,
-            32.0000000000,
-            34.0000000000,
-            31.0000000000,
-            39.0000000000,
-            25.0000000000,
-            31.0000000000,
-            32.0000000000,
-            40.0000000000,
-            24.0000000000,
-        ];
-        let summ = &Summary {
-            sum: 787.0000000000,
-            min: 21.0000000000,
-            max: 40.0000000000,
-            mean: 31.4800000000,
-            median: 32.0000000000,
-            var: 26.5933333333,
-            std_dev: 5.1568724372,
-            std_dev_pct: 16.3814245145,
-            median_abs_dev: 5.9304000000,
-            median_abs_dev_pct: 18.5325000000,
-            quartiles: (28.0000000000,32.0000000000,34.0000000000),
-            iqr: 6.0000000000,
-        };
-        check(val, summ);
-    }
-    #[test]
-    fn test_pois25lambda40() {
-        let val = &[
-            42.0000000000,
-            50.0000000000,
-            42.0000000000,
-            46.0000000000,
-            34.0000000000,
-            45.0000000000,
-            34.0000000000,
-            49.0000000000,
-            39.0000000000,
-            28.0000000000,
-            40.0000000000,
-            35.0000000000,
-            37.0000000000,
-            39.0000000000,
-            46.0000000000,
-            44.0000000000,
-            32.0000000000,
-            45.0000000000,
-            42.0000000000,
-            37.0000000000,
-            48.0000000000,
-            42.0000000000,
-            33.0000000000,
-            42.0000000000,
-            48.0000000000,
-        ];
-        let summ = &Summary {
-            sum: 1019.0000000000,
-            min: 28.0000000000,
-            max: 50.0000000000,
-            mean: 40.7600000000,
-            median: 42.0000000000,
-            var: 34.4400000000,
-            std_dev: 5.8685603004,
-            std_dev_pct: 14.3978417577,
-            median_abs_dev: 5.9304000000,
-            median_abs_dev_pct: 14.1200000000,
-            quartiles: (37.0000000000,42.0000000000,45.0000000000),
-            iqr: 8.0000000000,
-        };
-        check(val, summ);
-    }
-    #[test]
-    fn test_pois25lambda50() {
-        let val = &[
-            45.0000000000,
-            43.0000000000,
-            44.0000000000,
-            61.0000000000,
-            51.0000000000,
-            53.0000000000,
-            59.0000000000,
-            52.0000000000,
-            49.0000000000,
-            51.0000000000,
-            51.0000000000,
-            50.0000000000,
-            49.0000000000,
-            56.0000000000,
-            42.0000000000,
-            52.0000000000,
-            51.0000000000,
-            43.0000000000,
-            48.0000000000,
-            48.0000000000,
-            50.0000000000,
-            42.0000000000,
-            43.0000000000,
-            42.0000000000,
-            60.0000000000,
-        ];
-        let summ = &Summary {
-            sum: 1235.0000000000,
-            min: 42.0000000000,
-            max: 61.0000000000,
-            mean: 49.4000000000,
-            median: 50.0000000000,
-            var: 31.6666666667,
-            std_dev: 5.6273143387,
-            std_dev_pct: 11.3913245723,
-            median_abs_dev: 4.4478000000,
-            median_abs_dev_pct: 8.8956000000,
-            quartiles: (44.0000000000,50.0000000000,52.0000000000),
-            iqr: 8.0000000000,
-        };
-        check(val, summ);
-    }
-    #[test]
-    fn test_unif25() {
-        let val = &[
-            99.0000000000,
-            55.0000000000,
-            92.0000000000,
-            79.0000000000,
-            14.0000000000,
-            2.0000000000,
-            33.0000000000,
-            49.0000000000,
-            3.0000000000,
-            32.0000000000,
-            84.0000000000,
-            59.0000000000,
-            22.0000000000,
-            86.0000000000,
-            76.0000000000,
-            31.0000000000,
-            29.0000000000,
-            11.0000000000,
-            41.0000000000,
-            53.0000000000,
-            45.0000000000,
-            44.0000000000,
-            98.0000000000,
-            98.0000000000,
-            7.0000000000,
-        ];
-        let summ = &Summary {
-            sum: 1242.0000000000,
-            min: 2.0000000000,
-            max: 99.0000000000,
-            mean: 49.6800000000,
-            median: 45.0000000000,
-            var: 1015.6433333333,
-            std_dev: 31.8691595957,
-            std_dev_pct: 64.1488719719,
-            median_abs_dev: 45.9606000000,
-            median_abs_dev_pct: 102.1346666667,
-            quartiles: (29.0000000000,45.0000000000,79.0000000000),
-            iqr: 50.0000000000,
-        };
-        check(val, summ);
-    }
-
-    #[test]
-    fn test_boxplot_nonpositive() {
-        fn t(s: &Summary, expected: ~str) {
-            use std::io::MemWriter;
-            let mut m = MemWriter::new();
-            write_boxplot(&mut m as &mut io::Writer, s, 30).unwrap();
-            let out = str::from_utf8_owned(m.unwrap()).unwrap();
-            assert_eq!(out, expected);
-        }
-
-        t(&Summary::new([-2.0, -1.0]), ~"-2 |[------******#*****---]| -1");
-        t(&Summary::new([0.0, 2.0]), ~"0 |[-------*****#*******---]| 2");
-        t(&Summary::new([-2.0, 0.0]), ~"-2 |[------******#******---]| 0");
-
-    }
-    #[test]
-    fn test_sum_f64s() {
-        assert_eq!([0.5, 3.2321, 1.5678].sum(), 5.2999);
-    }
-    #[test]
-    fn test_sum_f64_between_ints_that_sum_to_0() {
-        assert_eq!([1e30, 1.2, -1e30].sum(), 1.2);
-    }
-}
-
-#[cfg(test)]
-mod bench {
-    extern crate test;
-    use self::test::BenchHarness;
-    use std::vec;
-    use stats::Stats;
-
-    #[bench]
-    fn sum_three_items(bh: &mut BenchHarness) {
-        bh.iter(|| {
-            [1e20, 1.5, -1e20].sum();
-        })
-    }
-    #[bench]
-    fn sum_many_f64(bh: &mut BenchHarness) {
-        let nums = [-1e30, 1e60, 1e30, 1.0, -1e60];
-        let v = vec::from_fn(500, |i| nums[i%5]);
-
-        bh.iter(|| {
-            v.sum();
-        })
-    }
-}
diff --git a/src/libextra/tempfile.rs b/src/libextra/tempfile.rs
deleted file mode 100644 (file)
index 9055416..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Temporary files and directories
-
-
-use std::os;
-use rand::{task_rng, Rng};
-use std::io;
-use std::io::fs;
-
-/// A wrapper for a path to temporary directory implementing automatic
-/// scope-based deletion.
-pub struct TempDir {
-    priv path: Option<Path>
-}
-
-impl TempDir {
-    /// Attempts to make a temporary directory inside of `tmpdir` whose name
-    /// will have the suffix `suffix`. The directory will be automatically
-    /// deleted once the returned wrapper is destroyed.
-    ///
-    /// If no directory can be created, None is returned.
-    pub fn new_in(tmpdir: &Path, suffix: &str) -> Option<TempDir> {
-        if !tmpdir.is_absolute() {
-            let abs_tmpdir = os::make_absolute(tmpdir);
-            return TempDir::new_in(&abs_tmpdir, suffix);
-        }
-
-        let mut r = task_rng();
-        for _ in range(0u, 1000) {
-            let p = tmpdir.join(r.gen_ascii_str(16) + suffix);
-            match fs::mkdir(&p, io::UserRWX) {
-                Err(..) => {}
-                Ok(()) => return Some(TempDir { path: Some(p) })
-            }
-        }
-        None
-    }
-
-    /// Attempts to make a temporary directory inside of `os::tmpdir()` whose
-    /// name will have the suffix `suffix`. The directory will be automatically
-    /// deleted once the returned wrapper is destroyed.
-    ///
-    /// If no directory can be created, None is returned.
-    pub fn new(suffix: &str) -> Option<TempDir> {
-        TempDir::new_in(&os::tmpdir(), suffix)
-    }
-
-    /// Unwrap the wrapped `std::path::Path` from the `TempDir` wrapper.
-    /// This discards the wrapper so that the automatic deletion of the
-    /// temporary directory is prevented.
-    pub fn unwrap(self) -> Path {
-        let mut tmpdir = self;
-        tmpdir.path.take_unwrap()
-    }
-
-    /// Access the wrapped `std::path::Path` to the temporary directory.
-    pub fn path<'a>(&'a self) -> &'a Path {
-        self.path.get_ref()
-    }
-}
-
-impl Drop for TempDir {
-    fn drop(&mut self) {
-        for path in self.path.iter() {
-            if path.exists() {
-                // FIXME: is failing the right thing to do?
-                fs::rmdir_recursive(path).unwrap();
-            }
-        }
-    }
-}
-
-// the tests for this module need to change the path using change_dir,
-// and this doesn't play nicely with other tests so these unit tests are located
-// in src/test/run-pass/tempfile.rs
diff --git a/src/libextra/unicode.rs b/src/libextra/unicode.rs
deleted file mode 100644 (file)
index 094a4b0..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[allow(missing_doc)];
-
-pub mod icu {
-    pub type UBool = u8;
-    pub type UProperty = int;
-    pub type UChar32 = char;
-
-    pub static TRUE : u8 = 1u8;
-    pub static FALSE : u8 = 0u8;
-
-    pub static UCHAR_ALPHABETIC : UProperty = 0;
-    pub static UCHAR_BINARY_START : UProperty = 0; // = UCHAR_ALPHABETIC
-    pub static UCHAR_ASCII_HEX_DIGIT : UProperty = 1;
-    pub static UCHAR_BIDI_CONTROL : UProperty = 2;
-
-    pub static UCHAR_BIDI_MIRRORED : UProperty = 3;
-    pub static UCHAR_DASH : UProperty = 4;
-    pub static UCHAR_DEFAULT_IGNORABLE_CODE_POINT : UProperty = 5;
-    pub static UCHAR_DEPRECATED : UProperty = 6;
-
-    pub static UCHAR_DIACRITIC : UProperty = 7;
-    pub static UCHAR_EXTENDER : UProperty = 8;
-    pub static UCHAR_FULL_COMPOSITION_EXCLUSION : UProperty = 9;
-    pub static UCHAR_GRAPHEME_BASE : UProperty = 10;
-
-    pub static UCHAR_GRAPHEME_EXTEND : UProperty = 11;
-    pub static UCHAR_GRAPHEME_LINK : UProperty = 12;
-    pub static UCHAR_HEX_DIGIT : UProperty = 13;
-    pub static UCHAR_HYPHEN : UProperty = 14;
-
-    pub static UCHAR_ID_CONTINUE : UProperty = 15;
-    pub static UCHAR_ID_START : UProperty = 16;
-    pub static UCHAR_IDEOGRAPHIC : UProperty = 17;
-    pub static UCHAR_IDS_BINARY_OPERATOR : UProperty = 18;
-
-    pub static UCHAR_IDS_TRINARY_OPERATOR : UProperty = 19;
-    pub static UCHAR_JOIN_CONTROL : UProperty = 20;
-    pub static UCHAR_LOGICAL_ORDER_EXCEPTION : UProperty = 21;
-    pub static UCHAR_LOWERCASE : UProperty = 22;
-
-    pub static UCHAR_MATH : UProperty = 23;
-    pub static UCHAR_NONCHARACTER_CODE_POINT : UProperty = 24;
-    pub static UCHAR_QUOTATION_MARK : UProperty = 25;
-    pub static UCHAR_RADICAL : UProperty = 26;
-
-    pub static UCHAR_SOFT_DOTTED : UProperty = 27;
-    pub static UCHAR_TERMINAL_PUNCTUATION : UProperty = 28;
-    pub static UCHAR_UNIFIED_IDEOGRAPH : UProperty = 29;
-    pub static UCHAR_UPPERCASE : UProperty = 30;
-
-    pub static UCHAR_WHITE_SPACE : UProperty = 31;
-    pub static UCHAR_XID_CONTINUE : UProperty = 32;
-    pub static UCHAR_XID_START : UProperty = 33;
-    pub static UCHAR_CASE_SENSITIVE : UProperty = 34;
-
-    pub static UCHAR_S_TERM : UProperty = 35;
-    pub static UCHAR_VARIATION_SELECTOR : UProperty = 36;
-    pub static UCHAR_NFD_INERT : UProperty = 37;
-    pub static UCHAR_NFKD_INERT : UProperty = 38;
-
-    pub static UCHAR_NFC_INERT : UProperty = 39;
-    pub static UCHAR_NFKC_INERT : UProperty = 40;
-    pub static UCHAR_SEGMENT_STARTER : UProperty = 41;
-    pub static UCHAR_PATTERN_SYNTAX : UProperty = 42;
-
-    pub static UCHAR_PATTERN_WHITE_SPACE : UProperty = 43;
-    pub static UCHAR_POSIX_ALNUM : UProperty = 44;
-    pub static UCHAR_POSIX_BLANK : UProperty = 45;
-    pub static UCHAR_POSIX_GRAPH : UProperty = 46;
-
-    pub static UCHAR_POSIX_PRINT : UProperty = 47;
-    pub static UCHAR_POSIX_XDIGIT : UProperty = 48;
-    pub static UCHAR_CASED : UProperty = 49;
-    pub static UCHAR_CASE_IGNORABLE : UProperty = 50;
-
-    pub static UCHAR_CHANGES_WHEN_LOWERCASED : UProperty = 51;
-    pub static UCHAR_CHANGES_WHEN_UPPERCASED : UProperty = 52;
-    pub static UCHAR_CHANGES_WHEN_TITLECASED : UProperty = 53;
-    pub static UCHAR_CHANGES_WHEN_CASEFOLDED : UProperty = 54;
-
-    pub static UCHAR_CHANGES_WHEN_CASEMAPPED : UProperty = 55;
-    pub static UCHAR_CHANGES_WHEN_NFKC_CASEFOLDED : UProperty = 56;
-    pub static UCHAR_BINARY_LIMIT : UProperty = 57;
-    pub static UCHAR_BIDI_CLASS : UProperty = 0x1000;
-
-    pub static UCHAR_INT_START : UProperty = 0x1000; // UCHAR_BIDI_CLASS
-    pub static UCHAR_BLOCK : UProperty = 0x1001;
-    pub static UCHAR_CANONICAL_COMBINING_CLASS : UProperty = 0x1002;
-    pub static UCHAR_DECOMPOSITION_TYPE : UProperty = 0x1003;
-
-    pub static UCHAR_EAST_ASIAN_WIDTH : UProperty = 0x1004;
-    pub static UCHAR_GENERAL_CATEGORY : UProperty = 0x1005;
-    pub static UCHAR_JOINING_GROUP : UProperty = 0x1006;
-    pub static UCHAR_JOINING_TYPE : UProperty = 0x1007;
-
-    pub static UCHAR_LINE_BREAK : UProperty = 0x1008;
-    pub static UCHAR_NUMERIC_TYPE : UProperty = 0x1009;
-    pub static UCHAR_SCRIPT : UProperty = 0x100A;
-    pub static UCHAR_HANGUL_SYLLABLE_TYPE : UProperty = 0x100B;
-
-    pub static UCHAR_NFD_QUICK_CHECK : UProperty = 0x100C;
-    pub static UCHAR_NFKD_QUICK_CHECK : UProperty = 0x100D;
-    pub static UCHAR_NFC_QUICK_CHECK : UProperty = 0x100E;
-    pub static UCHAR_NFKC_QUICK_CHECK : UProperty = 0x100F;
-
-    pub static UCHAR_LEAD_CANONICAL_COMBINING_CLASS : UProperty = 0x1010;
-    pub static UCHAR_TRAIL_CANONICAL_COMBINING_CLASS : UProperty = 0x1011;
-    pub static UCHAR_GRAPHEME_CLUSTER_BREAK : UProperty = 0x1012;
-    pub static UCHAR_SENTENCE_BREAK : UProperty = 0x1013;
-
-    pub static UCHAR_WORD_BREAK : UProperty = 0x1014;
-    pub static UCHAR_INT_LIMIT : UProperty = 0x1015;
-
-    pub static UCHAR_GENERAL_CATEGORY_MASK : UProperty = 0x2000;
-    pub static UCHAR_MASK_START : UProperty = 0x2000;
-    // = UCHAR_GENERAL_CATEGORY_MASK
-    pub static UCHAR_MASK_LIMIT : UProperty = 0x2001;
-
-    pub static UCHAR_NUMERIC_VALUE : UProperty = 0x3000;
-    pub static UCHAR_DOUBLE_START : UProperty = 0x3000;
-    // = UCHAR_NUMERIC_VALUE
-    pub static UCHAR_DOUBLE_LIMIT : UProperty = 0x3001;
-
-    pub static UCHAR_AGE : UProperty = 0x4000;
-    pub static UCHAR_STRING_START : UProperty = 0x4000; // = UCHAR_AGE
-    pub static UCHAR_BIDI_MIRRORING_GLYPH : UProperty = 0x4001;
-    pub static UCHAR_CASE_FOLDING : UProperty = 0x4002;
-
-    pub static UCHAR_ISO_COMMENT : UProperty = 0x4003;
-    pub static UCHAR_LOWERCASE_MAPPING : UProperty = 0x4004;
-    pub static UCHAR_NAME : UProperty = 0x4005;
-    pub static UCHAR_SIMPLE_CASE_FOLDING : UProperty = 0x4006;
-
-    pub static UCHAR_SIMPLE_LOWERCASE_MAPPING : UProperty = 0x4007;
-    pub static UCHAR_SIMPLE_TITLECASE_MAPPING : UProperty = 0x4008;
-    pub static UCHAR_SIMPLE_UPPERCASE_MAPPING : UProperty = 0x4009;
-    pub static UCHAR_TITLECASE_MAPPING : UProperty = 0x400A;
-
-    pub static UCHAR_UNICODE_1_NAME : UProperty = 0x400B;
-    pub static UCHAR_UPPERCASE_MAPPING : UProperty = 0x400C;
-    pub static UCHAR_STRING_LIMIT : UProperty = 0x400D;
-
-    pub static UCHAR_SCRIPT_EXTENSIONS : UProperty = 0x7000;
-    pub static UCHAR_OTHER_PROPERTY_START : UProperty = 0x7000;
-    // = UCHAR_SCRIPT_EXTENSIONS;
-    pub static UCHAR_OTHER_PROPERTY_LIMIT : UProperty = 0x7001;
-
-    pub static UCHAR_INVALID_CODE : UProperty = -1;
-
-    pub mod libicu {
-        use unicode::icu::*;
-
-        // #[link_name = "icuuc"]
-        #[link(name = "icuuc")]
-        extern {
-            pub fn u_hasBinaryProperty(c: UChar32, which: UProperty) -> UBool;
-            pub fn u_isdigit(c: UChar32) -> UBool;
-            pub fn u_islower(c: UChar32) -> UBool;
-            pub fn u_isspace(c: UChar32) -> UBool;
-            pub fn u_isupper(c: UChar32) -> UBool;
-            pub fn u_tolower(c: UChar32) -> UChar32;
-            pub fn u_toupper(c: UChar32) -> UChar32;
-        }
-    }
-}
-
-pub fn is_XID_start(c: char) -> bool {
-    unsafe {
-        return icu::libicu::u_hasBinaryProperty(c, icu::UCHAR_XID_START)
-            == icu::TRUE;
-    }
-}
-
-pub fn is_XID_continue(c: char) -> bool {
-    unsafe {
-        return icu::libicu::u_hasBinaryProperty(c, icu::UCHAR_XID_START)
-            == icu::TRUE;
-    }
-}
-
-/*
-Function: is_digit
-
-Returns true if a character is a digit.
-*/
-pub fn is_digit(c: char) -> bool {
-    unsafe {
-        return icu::libicu::u_isdigit(c) == icu::TRUE;
-    }
-}
-
-/*
-Function: is_lower
-
-Returns true if a character is a lowercase letter.
-*/
-pub fn is_lower(c: char) -> bool {
-    unsafe {
-        return icu::libicu::u_islower(c) == icu::TRUE;
-    }
-}
-
-/*
-Function: is_space
-
-Returns true if a character is space.
-*/
-pub fn is_space(c: char) -> bool {
-    unsafe {
-        return icu::libicu::u_isspace(c) == icu::TRUE;
-    }
-}
-
-/*
-Function: is_upper
-
-Returns true if a character is an uppercase letter.
-*/
-pub fn is_upper(c: char) -> bool {
-    unsafe {
-        return icu::libicu::u_isupper(c) == icu::TRUE;
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    use unicode::*;
-
-    #[test]
-    fn test_is_digit() {
-        assert!((is_digit('0')));
-        assert!((!is_digit('m')));
-    }
-
-    #[test]
-    fn test_is_lower() {
-        assert!((is_lower('m')));
-        assert!((!is_lower('M')));
-    }
-
-    #[test]
-    fn test_is_space() {
-        assert!((is_space(' ')));
-        assert!((!is_space('m')));
-    }
-
-    #[test]
-    fn test_is_upper() {
-        assert!((is_upper('M')));
-        assert!((!is_upper('m')));
-    }
-}
diff --git a/src/libextra/url.rs b/src/libextra/url.rs
deleted file mode 100644 (file)
index 6be90c0..0000000
+++ /dev/null
@@ -1,1277 +0,0 @@
-// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Types/fns concerning URLs (see RFC 3986)
-
-#[allow(missing_doc)];
-
-use std::cmp::Eq;
-use std::fmt;
-use std::hash::Hash;
-use std::io::BufReader;
-use std::from_str::FromStr;
-use std::uint;
-
-use collections::HashMap;
-
-/// A Uniform Resource Locator (URL).  A URL is a form of URI (Uniform Resource
-/// Identifier) that includes network location information, such as hostname or
-/// port number.
-///
-/// # Example
-///
-/// ```rust
-/// use extra::url::{Url, UserInfo};
-///
-/// let url = Url { scheme: ~"https",
-///                 user: Some(UserInfo { user: ~"username", pass: None }),
-///                 host: ~"example.com",
-///                 port: Some(~"8080"),
-///                 path: ~"/foo/bar",
-///                 query: ~[(~"baz", ~"qux")],
-///                 fragment: Some(~"quz") };
-/// // https://username@example.com:8080/foo/bar?baz=qux#quz
-/// ```
-#[deriving(Clone, Eq)]
-pub struct Url {
-    /// The scheme part of a URL, such as `https` in the above example.
-    scheme: ~str,
-    /// A URL subcomponent for user authentication.  `username` in the above example.
-    user: Option<UserInfo>,
-    /// A domain name or IP address.  For example, `example.com`.
-    host: ~str,
-    /// A TCP port number, for example `8080`.
-    port: Option<~str>,
-    /// The path component of a URL, for example `/foo/bar`.
-    path: ~str,
-    /// The query component of a URL.  `~[(~"baz", ~"qux")]` represents the
-    /// fragment `baz=qux` in the above example.
-    query: Query,
-    /// The fragment component, such as `quz`.  Doesn't include the leading `#` character.
-    fragment: Option<~str>
-}
-
-#[deriving(Clone, Eq)]
-pub struct Path {
-    /// The path component of a URL, for example `/foo/bar`.
-    path: ~str,
-    /// The query component of a URL.  `~[(~"baz", ~"qux")]` represents the
-    /// fragment `baz=qux` in the above example.
-    query: Query,
-    /// The fragment component, such as `quz`.  Doesn't include the leading `#` character.
-    fragment: Option<~str>
-}
-
-/// An optional subcomponent of a URI authority component.
-#[deriving(Clone, Eq)]
-pub struct UserInfo {
-    /// The user name.
-    user: ~str,
-    /// Password or other scheme-specific authentication information.
-    pass: Option<~str>
-}
-
-/// Represents the query component of a URI.
-pub type Query = ~[(~str, ~str)];
-
-impl Url {
-    pub fn new(scheme: ~str,
-               user: Option<UserInfo>,
-               host: ~str,
-               port: Option<~str>,
-               path: ~str,
-               query: Query,
-               fragment: Option<~str>)
-               -> Url {
-        Url {
-            scheme: scheme,
-            user: user,
-            host: host,
-            port: port,
-            path: path,
-            query: query,
-            fragment: fragment,
-        }
-    }
-}
-
-impl Path {
-    pub fn new(path: ~str,
-               query: Query,
-               fragment: Option<~str>)
-               -> Path {
-        Path {
-            path: path,
-            query: query,
-            fragment: fragment,
-        }
-    }
-}
-
-impl UserInfo {
-    #[inline]
-    pub fn new(user: ~str, pass: Option<~str>) -> UserInfo {
-        UserInfo { user: user, pass: pass }
-    }
-}
-
-fn encode_inner(s: &str, full_url: bool) -> ~str {
-    let mut rdr = BufReader::new(s.as_bytes());
-    let mut out = ~"";
-
-    loop {
-        let mut buf = [0];
-        let ch = match rdr.read(buf) {
-            Err(..) => break,
-            Ok(..) => buf[0] as char,
-        };
-
-        match ch {
-          // unreserved:
-          'A' .. 'Z' |
-          'a' .. 'z' |
-          '0' .. '9' |
-          '-' | '.' | '_' | '~' => {
-            out.push_char(ch);
-          }
-          _ => {
-              if full_url {
-                match ch {
-                  // gen-delims:
-                  ':' | '/' | '?' | '#' | '[' | ']' | '@' |
-
-                  // sub-delims:
-                  '!' | '$' | '&' | '"' | '(' | ')' | '*' |
-                  '+' | ',' | ';' | '=' => {
-                    out.push_char(ch);
-                  }
-
-                  _ => out.push_str(format!("%{:X}", ch as uint))
-                }
-            } else {
-                out.push_str(format!("%{:X}", ch as uint));
-            }
-          }
-        }
-    }
-
-    out
-}
-
-/**
- * Encodes a URI by replacing reserved characters with percent-encoded
- * character sequences.
- *
- * This function is compliant with RFC 3986.
- *
- * # Example
- *
- * ```rust
- * use extra::url::encode;
- *
- * let url = encode(&"https://example.com/Rust (programming language)");
- * println!("{}", url); // https://example.com/Rust%20(programming%20language)
- * ```
- */
-pub fn encode(s: &str) -> ~str {
-    encode_inner(s, true)
-}
-
-/**
- * Encodes a URI component by replacing reserved characters with percent
- * encoded character sequences.
- *
- * This function is compliant with RFC 3986.
- */
-
-pub fn encode_component(s: &str) -> ~str {
-    encode_inner(s, false)
-}
-
-fn decode_inner(s: &str, full_url: bool) -> ~str {
-    let mut rdr = BufReader::new(s.as_bytes());
-    let mut out = ~"";
-
-    loop {
-        let mut buf = [0];
-        let ch = match rdr.read(buf) {
-            Err(..) => break,
-            Ok(..) => buf[0] as char
-        };
-        match ch {
-          '%' => {
-            let mut bytes = [0, 0];
-            match rdr.read(bytes) {
-                Ok(2) => {}
-                _ => fail!() // FIXME: malformed url?
-            }
-            let ch = uint::parse_bytes(bytes, 16u).unwrap() as u8 as char;
-
-            if full_url {
-                // Only decode some characters:
-                match ch {
-                  // gen-delims:
-                  ':' | '/' | '?' | '#' | '[' | ']' | '@' |
-
-                  // sub-delims:
-                  '!' | '$' | '&' | '"' | '(' | ')' | '*' |
-                  '+' | ',' | ';' | '=' => {
-                    out.push_char('%');
-                    out.push_char(bytes[0u] as char);
-                    out.push_char(bytes[1u] as char);
-                  }
-
-                  ch => out.push_char(ch)
-                }
-            } else {
-                  out.push_char(ch);
-            }
-          }
-          ch => out.push_char(ch)
-        }
-    }
-
-    out
-}
-
-/**
- * Decodes a percent-encoded string representing a URI.
- *
- * This will only decode escape sequences generated by `encode`.
- *
- * # Example
- *
- * ```rust
- * use extra::url::decode;
- *
- * let url = decode(&"https://example.com/Rust%20(programming%20language)");
- * println!("{}", url); // https://example.com/Rust (programming language)
- * ```
- */
-pub fn decode(s: &str) -> ~str {
-    decode_inner(s, true)
-}
-
-/**
- * Decode a string encoded with percent encoding.
- */
-pub fn decode_component(s: &str) -> ~str {
-    decode_inner(s, false)
-}
-
-fn encode_plus(s: &str) -> ~str {
-    let mut rdr = BufReader::new(s.as_bytes());
-    let mut out = ~"";
-
-    loop {
-        let mut buf = [0];
-        let ch = match rdr.read(buf) {
-            Ok(..) => buf[0] as char,
-            Err(..) => break,
-        };
-        match ch {
-          'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '_' | '.' | '-' => {
-            out.push_char(ch);
-          }
-          ' ' => out.push_char('+'),
-          _ => out.push_str(format!("%{:X}", ch as uint))
-        }
-    }
-
-    out
-}
-
-/**
- * Encode a hashmap to the 'application/x-www-form-urlencoded' media type.
- */
-pub fn encode_form_urlencoded(m: &HashMap<~str, ~[~str]>) -> ~str {
-    let mut out = ~"";
-    let mut first = true;
-
-    for (key, values) in m.iter() {
-        let key = encode_plus(*key);
-
-        for value in values.iter() {
-            if first {
-                first = false;
-            } else {
-                out.push_char('&');
-                first = false;
-            }
-
-            out.push_str(format!("{}={}", key, encode_plus(*value)));
-        }
-    }
-
-    out
-}
-
-/**
- * Decode a string encoded with the 'application/x-www-form-urlencoded' media
- * type into a hashmap.
- */
-pub fn decode_form_urlencoded(s: &[u8]) -> HashMap<~str, ~[~str]> {
-    let mut rdr = BufReader::new(s);
-    let mut m = HashMap::new();
-    let mut key = ~"";
-    let mut value = ~"";
-    let mut parsing_key = true;
-
-    loop {
-        let mut buf = [0];
-        let ch = match rdr.read(buf) {
-            Ok(..) => buf[0] as char,
-            Err(..) => break,
-        };
-        match ch {
-            '&' | ';' => {
-                if key != ~"" && value != ~"" {
-                    let mut values = match m.pop(&key) {
-                        Some(values) => values,
-                        None => ~[],
-                    };
-
-                    values.push(value);
-                    m.insert(key, values);
-                }
-
-                parsing_key = true;
-                key = ~"";
-                value = ~"";
-            }
-            '=' => parsing_key = false,
-            ch => {
-                let ch = match ch {
-                    '%' => {
-                        let mut bytes = [0, 0];
-                        match rdr.read(bytes) {
-                            Ok(2) => {}
-                            _ => fail!() // FIXME: malformed?
-                        }
-                        uint::parse_bytes(bytes, 16u).unwrap() as u8 as char
-                    }
-                    '+' => ' ',
-                    ch => ch
-                };
-
-                if parsing_key {
-                    key.push_char(ch)
-                } else {
-                    value.push_char(ch)
-                }
-            }
-        }
-    }
-
-    if key != ~"" && value != ~"" {
-        let mut values = match m.pop(&key) {
-            Some(values) => values,
-            None => ~[],
-        };
-
-        values.push(value);
-        m.insert(key, values);
-    }
-
-    m
-}
-
-
-fn split_char_first(s: &str, c: char) -> (~str, ~str) {
-    let len = s.len();
-    let mut index = len;
-    let mut mat = 0;
-    let mut rdr = BufReader::new(s.as_bytes());
-    loop {
-        let mut buf = [0];
-        let ch = match rdr.read(buf) {
-            Ok(..) => buf[0] as char,
-            Err(..) => break,
-        };
-        if ch == c {
-            // found a match, adjust markers
-            index = (rdr.tell().unwrap() as uint) - 1;
-            mat = 1;
-            break;
-        }
-    }
-    if index+mat == len {
-        return (s.slice(0, index).to_owned(), ~"");
-    } else {
-        return (s.slice(0, index).to_owned(),
-             s.slice(index + mat, s.len()).to_owned());
-    }
-}
-
-impl fmt::Show for UserInfo {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        match self.pass {
-            Some(ref pass) => write!(f.buf, "{}:{}@", self.user, *pass),
-            None => write!(f.buf, "{}@", self.user),
-        }
-    }
-}
-
-fn query_from_str(rawquery: &str) -> Query {
-    let mut query: Query = ~[];
-    if !rawquery.is_empty() {
-        for p in rawquery.split('&') {
-            let (k, v) = split_char_first(p, '=');
-            query.push((decode_component(k), decode_component(v)));
-        };
-    }
-    return query;
-}
-
-/**
- * Converts an instance of a URI `Query` type to a string.
- *
- * # Example
- *
- * ```rust
- * use extra::url;
- *
- * let query = ~[(~"title", ~"The Village"), (~"north", ~"52.91"), (~"west", ~"4.10")];
- * println!("{}", url::query_to_str(&query));  // title=The%20Village&north=52.91&west=4.10
- * ```
- */
-#[allow(unused_must_use)]
-pub fn query_to_str(query: &Query) -> ~str {
-    use std::io::MemWriter;
-    use std::str;
-
-    let mut writer = MemWriter::new();
-    for (i, &(ref k, ref v)) in query.iter().enumerate() {
-        if i != 0 { write!(&mut writer, "&"); }
-        write!(&mut writer, "{}={}", encode_component(*k),
-               encode_component(*v));
-    }
-    str::from_utf8_lossy(writer.unwrap()).into_owned()
-}
-
-/**
- * Returns a tuple of the URI scheme and the rest of the URI, or a parsing error.
- *
- * Does not include the separating `:` character.
- *
- * # Example
- *
- * ```rust
- * use extra::url::get_scheme;
- *
- * let scheme = match get_scheme("https://example.com/") {
- *     Ok((sch, _)) => sch,
- *     Err(_) => ~"(None)",
- * };
- * println!("Scheme in use: {}.", scheme); // Scheme in use: https.
- * ```
- */
-pub fn get_scheme(rawurl: &str) -> Result<(~str, ~str), ~str> {
-    for (i,c) in rawurl.chars().enumerate() {
-        match c {
-          'A' .. 'Z' | 'a' .. 'z' => continue,
-          '0' .. '9' | '+' | '-' | '.' => {
-            if i == 0 {
-                return Err(~"url: Scheme must begin with a letter.");
-            }
-            continue;
-          }
-          ':' => {
-            if i == 0 {
-                return Err(~"url: Scheme cannot be empty.");
-            } else {
-                return Ok((rawurl.slice(0,i).to_owned(),
-                                rawurl.slice(i+1,rawurl.len()).to_owned()));
-            }
-          }
-          _ => {
-            return Err(~"url: Invalid character in scheme.");
-          }
-        }
-    };
-    return Err(~"url: Scheme must be terminated with a colon.");
-}
-
-#[deriving(Clone, Eq)]
-enum Input {
-    Digit, // all digits
-    Hex, // digits and letters a-f
-    Unreserved // all other legal characters
-}
-
-// returns userinfo, host, port, and unparsed part, or an error
-fn get_authority(rawurl: &str) ->
-    Result<(Option<UserInfo>, ~str, Option<~str>, ~str), ~str> {
-    if !rawurl.starts_with("//") {
-        // there is no authority.
-        return Ok((None, ~"", None, rawurl.to_str()));
-    }
-
-    enum State {
-        Start, // starting state
-        PassHostPort, // could be in user or port
-        Ip6Port, // either in ipv6 host or port
-        Ip6Host, // are in an ipv6 host
-        InHost, // are in a host - may be ipv6, but don't know yet
-        InPort // are in port
-    }
-
-    let len = rawurl.len();
-    let mut st = Start;
-    let mut input = Digit; // most restricted, start here.
-
-    let mut userinfo = None;
-    let mut host = ~"";
-    let mut port = None;
-
-    let mut colon_count = 0;
-    let mut pos = 0;
-    let mut begin = 2;
-    let mut end = len;
-
-    for (i,c) in rawurl.chars().enumerate() {
-        if i < 2 { continue; } // ignore the leading //
-
-        // deal with input class first
-        match c {
-          '0' .. '9' => (),
-          'A' .. 'F' | 'a' .. 'f' => {
-            if input == Digit {
-                input = Hex;
-            }
-          }
-          'G' .. 'Z' | 'g' .. 'z' | '-' | '.' | '_' | '~' | '%' |
-          '&' |'\'' | '(' | ')' | '+' | '!' | '*' | ',' | ';' | '=' => {
-            input = Unreserved;
-          }
-          ':' | '@' | '?' | '#' | '/' => {
-            // separators, don't change anything
-          }
-          _ => {
-            return Err(~"Illegal character in authority");
-          }
-        }
-
-        // now process states
-        match c {
-          ':' => {
-            colon_count += 1;
-            match st {
-              Start => {
-                pos = i;
-                st = PassHostPort;
-              }
-              PassHostPort => {
-                // multiple colons means ipv6 address.
-                if input == Unreserved {
-                    return Err(
-                        ~"Illegal characters in IPv6 address.");
-                }
-                st = Ip6Host;
-              }
-              InHost => {
-                pos = i;
-                if input == Unreserved {
-                    // must be port
-                    host = rawurl.slice(begin, i).to_owned();
-                    st = InPort;
-                } else {
-                    // can't be sure whether this is an ipv6 address or a port
-                    st = Ip6Port;
-                }
-              }
-              Ip6Port => {
-                if input == Unreserved {
-                    return Err(~"Illegal characters in authority.");
-                }
-                st = Ip6Host;
-              }
-              Ip6Host => {
-                if colon_count > 7 {
-                    host = rawurl.slice(begin, i).to_owned();
-                    pos = i;
-                    st = InPort;
-                }
-              }
-              _ => {
-                return Err(~"Invalid ':' in authority.");
-              }
-            }
-            input = Digit; // reset input class
-          }
-
-          '@' => {
-            input = Digit; // reset input class
-            colon_count = 0; // reset count
-            match st {
-              Start => {
-                let user = rawurl.slice(begin, i).to_owned();
-                userinfo = Some(UserInfo::new(user, None));
-                st = InHost;
-              }
-              PassHostPort => {
-                let user = rawurl.slice(begin, pos).to_owned();
-                let pass = rawurl.slice(pos+1, i).to_owned();
-                userinfo = Some(UserInfo::new(user, Some(pass)));
-                st = InHost;
-              }
-              _ => {
-                return Err(~"Invalid '@' in authority.");
-              }
-            }
-            begin = i+1;
-          }
-
-          '?' | '#' | '/' => {
-            end = i;
-            break;
-          }
-          _ => ()
-        }
-    }
-
-    // finish up
-    match st {
-      Start => {
-        host = rawurl.slice(begin, end).to_owned();
-      }
-      PassHostPort | Ip6Port => {
-        if input != Digit {
-            return Err(~"Non-digit characters in port.");
-        }
-        host = rawurl.slice(begin, pos).to_owned();
-        port = Some(rawurl.slice(pos+1, end).to_owned());
-      }
-      Ip6Host | InHost => {
-        host = rawurl.slice(begin, end).to_owned();
-      }
-      InPort => {
-        if input != Digit {
-            return Err(~"Non-digit characters in port.");
-        }
-        port = Some(rawurl.slice(pos+1, end).to_owned());
-      }
-    }
-
-    let rest = rawurl.slice(end, len).to_owned();
-    return Ok((userinfo, host, port, rest));
-}
-
-
-// returns the path and unparsed part of url, or an error
-fn get_path(rawurl: &str, authority: bool) ->
-    Result<(~str, ~str), ~str> {
-    let len = rawurl.len();
-    let mut end = len;
-    for (i,c) in rawurl.chars().enumerate() {
-        match c {
-          'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '&' |'\'' | '(' | ')' | '.'
-          | '@' | ':' | '%' | '/' | '+' | '!' | '*' | ',' | ';' | '='
-          | '_' | '-' | '~' => {
-            continue;
-          }
-          '?' | '#' => {
-            end = i;
-            break;
-          }
-          _ => return Err(~"Invalid character in path.")
-        }
-    }
-
-    if authority {
-        if end != 0 && !rawurl.starts_with("/") {
-            return Err(~"Non-empty path must begin with\
-                               '/' in presence of authority.");
-        }
-    }
-
-    return Ok((decode_component(rawurl.slice(0, end)),
-                    rawurl.slice(end, len).to_owned()));
-}
-
-// returns the parsed query and the fragment, if present
-fn get_query_fragment(rawurl: &str) ->
-    Result<(Query, Option<~str>), ~str> {
-    if !rawurl.starts_with("?") {
-        if rawurl.starts_with("#") {
-            let f = decode_component(rawurl.slice(
-                                                1,
-                                                rawurl.len()));
-            return Ok((~[], Some(f)));
-        } else {
-            return Ok((~[], None));
-        }
-    }
-    let (q, r) = split_char_first(rawurl.slice(1, rawurl.len()), '#');
-    let f = if r.len() != 0 {
-        Some(decode_component(r)) } else { None };
-    return Ok((query_from_str(q), f));
-}
-
-/**
- * Parses a URL, converting it from a string to `Url` representation.
- *
- * # Arguments
- *
- * `rawurl` - a string representing the full URL, including scheme.
- *
- * # Returns
- *
- * A `Url` struct type representing the URL.
- */
-pub fn from_str(rawurl: &str) -> Result<Url, ~str> {
-    // scheme
-    let (scheme, rest) = match get_scheme(rawurl) {
-        Ok(val) => val,
-        Err(e) => return Err(e),
-    };
-
-    // authority
-    let (userinfo, host, port, rest) = match get_authority(rest) {
-        Ok(val) => val,
-        Err(e) => return Err(e),
-    };
-
-    // path
-    let has_authority = if host == ~"" { false } else { true };
-    let (path, rest) = match get_path(rest, has_authority) {
-        Ok(val) => val,
-        Err(e) => return Err(e),
-    };
-
-    // query and fragment
-    let (query, fragment) = match get_query_fragment(rest) {
-        Ok(val) => val,
-        Err(e) => return Err(e),
-    };
-
-    Ok(Url::new(scheme, userinfo, host, port, path, query, fragment))
-}
-
-pub fn path_from_str(rawpath: &str) -> Result<Path, ~str> {
-    let (path, rest) = match get_path(rawpath, false) {
-        Ok(val) => val,
-        Err(e) => return Err(e)
-    };
-
-    // query and fragment
-    let (query, fragment) = match get_query_fragment(rest) {
-        Ok(val) => val,
-        Err(e) => return Err(e),
-    };
-
-    Ok(Path{ path: path, query: query, fragment: fragment })
-}
-
-impl FromStr for Url {
-    fn from_str(s: &str) -> Option<Url> {
-        match from_str(s) {
-            Ok(url) => Some(url),
-            Err(_) => None
-        }
-    }
-}
-
-impl FromStr for Path {
-    fn from_str(s: &str) -> Option<Path> {
-        match path_from_str(s) {
-            Ok(path) => Some(path),
-            Err(_) => None
-        }
-    }
-}
-
-impl fmt::Show for Url {
-    /**
-     * Converts a URL from `Url` to string representation.
-     *
-     * # Arguments
-     *
-     * `url` - a URL.
-     *
-     * # Returns
-     *
-     * A string that contains the formatted URL. Note that this will usually
-     * be an inverse of `from_str` but might strip out unneeded separators;
-     * for example, "http://somehost.com?", when parsed and formatted, will
-     * result in just "http://somehost.com".
-     */
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        try!(write!(f.buf, "{}:", self.scheme));
-
-        if !self.host.is_empty() {
-            try!(write!(f.buf, "//"));
-            match self.user {
-                Some(ref user) => try!(write!(f.buf, "{}", *user)),
-                None => {}
-            }
-            match self.port {
-                Some(ref port) => try!(write!(f.buf, "{}:{}", self.host,
-                                                *port)),
-                None => try!(write!(f.buf, "{}", self.host)),
-            }
-        }
-
-        try!(write!(f.buf, "{}", self.path));
-
-        if !self.query.is_empty() {
-            try!(write!(f.buf, "?{}", query_to_str(&self.query)));
-        }
-
-        match self.fragment {
-            Some(ref fragment) => write!(f.buf, "\\#{}",
-                                         encode_component(*fragment)),
-            None => Ok(()),
-        }
-    }
-}
-
-impl fmt::Show for Path {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        try!(write!(f.buf, "{}", self.path));
-        if !self.query.is_empty() {
-            try!(write!(f.buf, "?{}", self.query))
-        }
-
-        match self.fragment {
-            Some(ref fragment) => {
-                write!(f.buf, "\\#{}", encode_component(*fragment))
-            }
-            None => Ok(())
-        }
-    }
-}
-
-impl<S: Writer> Hash<S> for Url {
-    fn hash(&self, state: &mut S) {
-        self.to_str().hash(state)
-    }
-}
-
-impl<S: Writer> Hash<S> for Path {
-    fn hash(&self, state: &mut S) {
-        self.to_str().hash(state)
-    }
-}
-
-// Put a few tests outside of the 'test' module so they can test the internal
-// functions and those functions don't need 'pub'
-
-#[test]
-fn test_split_char_first() {
-    let (u,v) = split_char_first("hello, sweet world", ',');
-    assert_eq!(u, ~"hello");
-    assert_eq!(v, ~" sweet world");
-
-    let (u,v) = split_char_first("hello sweet world", ',');
-    assert_eq!(u, ~"hello sweet world");
-    assert_eq!(v, ~"");
-}
-
-#[test]
-fn test_get_authority() {
-    let (u, h, p, r) = get_authority(
-        "//user:pass@rust-lang.org/something").unwrap();
-    assert_eq!(u, Some(UserInfo::new(~"user", Some(~"pass"))));
-    assert_eq!(h, ~"rust-lang.org");
-    assert!(p.is_none());
-    assert_eq!(r, ~"/something");
-
-    let (u, h, p, r) = get_authority(
-        "//rust-lang.org:8000?something").unwrap();
-    assert!(u.is_none());
-    assert_eq!(h, ~"rust-lang.org");
-    assert_eq!(p, Some(~"8000"));
-    assert_eq!(r, ~"?something");
-
-    let (u, h, p, r) = get_authority(
-        "//rust-lang.org#blah").unwrap();
-    assert!(u.is_none());
-    assert_eq!(h, ~"rust-lang.org");
-    assert!(p.is_none());
-    assert_eq!(r, ~"#blah");
-
-    // ipv6 tests
-    let (_, h, _, _) = get_authority(
-        "//2001:0db8:85a3:0042:0000:8a2e:0370:7334#blah").unwrap();
-    assert_eq!(h, ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334");
-
-    let (_, h, p, _) = get_authority(
-        "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000#blah").unwrap();
-    assert_eq!(h, ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334");
-    assert_eq!(p, Some(~"8000"));
-
-    let (u, h, p, _) = get_authority(
-        "//us:p@2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000#blah"
-    ).unwrap();
-    assert_eq!(u, Some(UserInfo::new(~"us", Some(~"p"))));
-    assert_eq!(h, ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334");
-    assert_eq!(p, Some(~"8000"));
-
-    // invalid authorities;
-    assert!(get_authority("//user:pass@rust-lang:something").is_err());
-    assert!(get_authority("//user@rust-lang:something:/path").is_err());
-    assert!(get_authority(
-        "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:800a").is_err());
-    assert!(get_authority(
-        "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000:00").is_err());
-
-    // these parse as empty, because they don't start with '//'
-    let (_, h, _, _) = get_authority("user:pass@rust-lang").unwrap();
-    assert_eq!(h, ~"");
-    let (_, h, _, _) = get_authority("rust-lang.org").unwrap();
-    assert_eq!(h, ~"");
-}
-
-#[test]
-fn test_get_path() {
-    let (p, r) = get_path("/something+%20orother", true).unwrap();
-    assert_eq!(p, ~"/something+ orother");
-    assert_eq!(r, ~"");
-    let (p, r) = get_path("test@email.com#fragment", false).unwrap();
-    assert_eq!(p, ~"test@email.com");
-    assert_eq!(r, ~"#fragment");
-    let (p, r) = get_path("/gen/:addr=?q=v", false).unwrap();
-    assert_eq!(p, ~"/gen/:addr=");
-    assert_eq!(r, ~"?q=v");
-
-    //failure cases
-    assert!(get_path("something?q", true).is_err());
-}
-
-#[cfg(test)]
-mod tests {
-
-    use super::*;
-
-    use collections::HashMap;
-
-    #[test]
-    fn test_url_parse() {
-        let url = ~"http://user:pass@rust-lang.org:8080/doc/~u?s=v#something";
-
-        let up = from_str(url);
-        let u = up.unwrap();
-        assert_eq!(&u.scheme, &~"http");
-        assert_eq!(&u.user, &Some(UserInfo::new(~"user", Some(~"pass"))));
-        assert_eq!(&u.host, &~"rust-lang.org");
-        assert_eq!(&u.port, &Some(~"8080"));
-        assert_eq!(&u.path, &~"/doc/~u");
-        assert_eq!(&u.query, &~[(~"s", ~"v")]);
-        assert_eq!(&u.fragment, &Some(~"something"));
-    }
-
-    #[test]
-    fn test_path_parse() {
-        let path = ~"/doc/~u?s=v#something";
-
-        let up = path_from_str(path);
-        let u = up.unwrap();
-        assert_eq!(&u.path, &~"/doc/~u");
-        assert_eq!(&u.query, &~[(~"s", ~"v")]);
-        assert_eq!(&u.fragment, &Some(~"something"));
-    }
-
-    #[test]
-    fn test_url_parse_host_slash() {
-        let urlstr = ~"http://0.42.42.42/";
-        let url = from_str(urlstr).unwrap();
-        assert!(url.host == ~"0.42.42.42");
-        assert!(url.path == ~"/");
-    }
-
-    #[test]
-    fn test_path_parse_host_slash() {
-        let pathstr = ~"/";
-        let path = path_from_str(pathstr).unwrap();
-        assert!(path.path == ~"/");
-    }
-
-    #[test]
-    fn test_url_host_with_port() {
-        let urlstr = ~"scheme://host:1234";
-        let url = from_str(urlstr).unwrap();
-        assert_eq!(&url.scheme, &~"scheme");
-        assert_eq!(&url.host, &~"host");
-        assert_eq!(&url.port, &Some(~"1234"));
-        assert_eq!(&url.path, &~""); // is empty path really correct? Other tests think so
-        let urlstr = ~"scheme://host:1234/";
-        let url = from_str(urlstr).unwrap();
-        assert_eq!(&url.scheme, &~"scheme");
-        assert_eq!(&url.host, &~"host");
-        assert_eq!(&url.port, &Some(~"1234"));
-        assert_eq!(&url.path, &~"/");
-    }
-
-    #[test]
-    fn test_url_with_underscores() {
-        let urlstr = ~"http://dotcom.com/file_name.html";
-        let url = from_str(urlstr).unwrap();
-        assert!(url.path == ~"/file_name.html");
-    }
-
-    #[test]
-    fn test_path_with_underscores() {
-        let pathstr = ~"/file_name.html";
-        let path = path_from_str(pathstr).unwrap();
-        assert!(path.path == ~"/file_name.html");
-    }
-
-    #[test]
-    fn test_url_with_dashes() {
-        let urlstr = ~"http://dotcom.com/file-name.html";
-        let url = from_str(urlstr).unwrap();
-        assert!(url.path == ~"/file-name.html");
-    }
-
-    #[test]
-    fn test_path_with_dashes() {
-        let pathstr = ~"/file-name.html";
-        let path = path_from_str(pathstr).unwrap();
-        assert!(path.path == ~"/file-name.html");
-    }
-
-    #[test]
-    fn test_no_scheme() {
-        assert!(get_scheme("noschemehere.html").is_err());
-    }
-
-    #[test]
-    fn test_invalid_scheme_errors() {
-        assert!(from_str("99://something").is_err());
-        assert!(from_str("://something").is_err());
-    }
-
-    #[test]
-    fn test_full_url_parse_and_format() {
-        let url = ~"http://user:pass@rust-lang.org/doc?s=v#something";
-        assert_eq!(from_str(url).unwrap().to_str(), url);
-    }
-
-    #[test]
-    fn test_userless_url_parse_and_format() {
-        let url = ~"http://rust-lang.org/doc?s=v#something";
-        assert_eq!(from_str(url).unwrap().to_str(), url);
-    }
-
-    #[test]
-    fn test_queryless_url_parse_and_format() {
-        let url = ~"http://user:pass@rust-lang.org/doc#something";
-        assert_eq!(from_str(url).unwrap().to_str(), url);
-    }
-
-    #[test]
-    fn test_empty_query_url_parse_and_format() {
-        let url = ~"http://user:pass@rust-lang.org/doc?#something";
-        let should_be = ~"http://user:pass@rust-lang.org/doc#something";
-        assert_eq!(from_str(url).unwrap().to_str(), should_be);
-    }
-
-    #[test]
-    fn test_fragmentless_url_parse_and_format() {
-        let url = ~"http://user:pass@rust-lang.org/doc?q=v";
-        assert_eq!(from_str(url).unwrap().to_str(), url);
-    }
-
-    #[test]
-    fn test_minimal_url_parse_and_format() {
-        let url = ~"http://rust-lang.org/doc";
-        assert_eq!(from_str(url).unwrap().to_str(), url);
-    }
-
-    #[test]
-    fn test_url_with_port_parse_and_format() {
-        let url = ~"http://rust-lang.org:80/doc";
-        assert_eq!(from_str(url).unwrap().to_str(), url);
-    }
-
-    #[test]
-    fn test_scheme_host_only_url_parse_and_format() {
-        let url = ~"http://rust-lang.org";
-        assert_eq!(from_str(url).unwrap().to_str(), url);
-    }
-
-    #[test]
-    fn test_pathless_url_parse_and_format() {
-        let url = ~"http://user:pass@rust-lang.org?q=v#something";
-        assert_eq!(from_str(url).unwrap().to_str(), url);
-    }
-
-    #[test]
-    fn test_scheme_host_fragment_only_url_parse_and_format() {
-        let url = ~"http://rust-lang.org#something";
-        assert_eq!(from_str(url).unwrap().to_str(), url);
-    }
-
-    #[test]
-    fn test_url_component_encoding() {
-        let url = ~"http://rust-lang.org/doc%20uments?ba%25d%20=%23%26%2B";
-        let u = from_str(url).unwrap();
-        assert!(u.path == ~"/doc uments");
-        assert!(u.query == ~[(~"ba%d ", ~"#&+")]);
-    }
-
-    #[test]
-    fn test_path_component_encoding() {
-        let path = ~"/doc%20uments?ba%25d%20=%23%26%2B";
-        let p = path_from_str(path).unwrap();
-        assert!(p.path == ~"/doc uments");
-        assert!(p.query == ~[(~"ba%d ", ~"#&+")]);
-    }
-
-    #[test]
-    fn test_url_without_authority() {
-        let url = ~"mailto:test@email.com";
-        assert_eq!(from_str(url).unwrap().to_str(), url);
-    }
-
-    #[test]
-    fn test_encode() {
-        assert_eq!(encode(""), ~"");
-        assert_eq!(encode("http://example.com"), ~"http://example.com");
-        assert_eq!(encode("foo bar% baz"), ~"foo%20bar%25%20baz");
-        assert_eq!(encode(" "), ~"%20");
-        assert_eq!(encode("!"), ~"!");
-        assert_eq!(encode("\""), ~"\"");
-        assert_eq!(encode("#"), ~"#");
-        assert_eq!(encode("$"), ~"$");
-        assert_eq!(encode("%"), ~"%25");
-        assert_eq!(encode("&"), ~"&");
-        assert_eq!(encode("'"), ~"%27");
-        assert_eq!(encode("("), ~"(");
-        assert_eq!(encode(")"), ~")");
-        assert_eq!(encode("*"), ~"*");
-        assert_eq!(encode("+"), ~"+");
-        assert_eq!(encode(","), ~",");
-        assert_eq!(encode("/"), ~"/");
-        assert_eq!(encode(":"), ~":");
-        assert_eq!(encode(";"), ~";");
-        assert_eq!(encode("="), ~"=");
-        assert_eq!(encode("?"), ~"?");
-        assert_eq!(encode("@"), ~"@");
-        assert_eq!(encode("["), ~"[");
-        assert_eq!(encode("]"), ~"]");
-    }
-
-    #[test]
-    fn test_encode_component() {
-        assert_eq!(encode_component(""), ~"");
-        assert!(encode_component("http://example.com") ==
-            ~"http%3A%2F%2Fexample.com");
-        assert!(encode_component("foo bar% baz") ==
-            ~"foo%20bar%25%20baz");
-        assert_eq!(encode_component(" "), ~"%20");
-        assert_eq!(encode_component("!"), ~"%21");
-        assert_eq!(encode_component("#"), ~"%23");
-        assert_eq!(encode_component("$"), ~"%24");
-        assert_eq!(encode_component("%"), ~"%25");
-        assert_eq!(encode_component("&"), ~"%26");
-        assert_eq!(encode_component("'"), ~"%27");
-        assert_eq!(encode_component("("), ~"%28");
-        assert_eq!(encode_component(")"), ~"%29");
-        assert_eq!(encode_component("*"), ~"%2A");
-        assert_eq!(encode_component("+"), ~"%2B");
-        assert_eq!(encode_component(","), ~"%2C");
-        assert_eq!(encode_component("/"), ~"%2F");
-        assert_eq!(encode_component(":"), ~"%3A");
-        assert_eq!(encode_component(";"), ~"%3B");
-        assert_eq!(encode_component("="), ~"%3D");
-        assert_eq!(encode_component("?"), ~"%3F");
-        assert_eq!(encode_component("@"), ~"%40");
-        assert_eq!(encode_component("["), ~"%5B");
-        assert_eq!(encode_component("]"), ~"%5D");
-    }
-
-    #[test]
-    fn test_decode() {
-        assert_eq!(decode(""), ~"");
-        assert_eq!(decode("abc/def 123"), ~"abc/def 123");
-        assert_eq!(decode("abc%2Fdef%20123"), ~"abc%2Fdef 123");
-        assert_eq!(decode("%20"), ~" ");
-        assert_eq!(decode("%21"), ~"%21");
-        assert_eq!(decode("%22"), ~"%22");
-        assert_eq!(decode("%23"), ~"%23");
-        assert_eq!(decode("%24"), ~"%24");
-        assert_eq!(decode("%25"), ~"%");
-        assert_eq!(decode("%26"), ~"%26");
-        assert_eq!(decode("%27"), ~"'");
-        assert_eq!(decode("%28"), ~"%28");
-        assert_eq!(decode("%29"), ~"%29");
-        assert_eq!(decode("%2A"), ~"%2A");
-        assert_eq!(decode("%2B"), ~"%2B");
-        assert_eq!(decode("%2C"), ~"%2C");
-        assert_eq!(decode("%2F"), ~"%2F");
-        assert_eq!(decode("%3A"), ~"%3A");
-        assert_eq!(decode("%3B"), ~"%3B");
-        assert_eq!(decode("%3D"), ~"%3D");
-        assert_eq!(decode("%3F"), ~"%3F");
-        assert_eq!(decode("%40"), ~"%40");
-        assert_eq!(decode("%5B"), ~"%5B");
-        assert_eq!(decode("%5D"), ~"%5D");
-    }
-
-    #[test]
-    fn test_decode_component() {
-        assert_eq!(decode_component(""), ~"");
-        assert_eq!(decode_component("abc/def 123"), ~"abc/def 123");
-        assert_eq!(decode_component("abc%2Fdef%20123"), ~"abc/def 123");
-        assert_eq!(decode_component("%20"), ~" ");
-        assert_eq!(decode_component("%21"), ~"!");
-        assert_eq!(decode_component("%22"), ~"\"");
-        assert_eq!(decode_component("%23"), ~"#");
-        assert_eq!(decode_component("%24"), ~"$");
-        assert_eq!(decode_component("%25"), ~"%");
-        assert_eq!(decode_component("%26"), ~"&");
-        assert_eq!(decode_component("%27"), ~"'");
-        assert_eq!(decode_component("%28"), ~"(");
-        assert_eq!(decode_component("%29"), ~")");
-        assert_eq!(decode_component("%2A"), ~"*");
-        assert_eq!(decode_component("%2B"), ~"+");
-        assert_eq!(decode_component("%2C"), ~",");
-        assert_eq!(decode_component("%2F"), ~"/");
-        assert_eq!(decode_component("%3A"), ~":");
-        assert_eq!(decode_component("%3B"), ~";");
-        assert_eq!(decode_component("%3D"), ~"=");
-        assert_eq!(decode_component("%3F"), ~"?");
-        assert_eq!(decode_component("%40"), ~"@");
-        assert_eq!(decode_component("%5B"), ~"[");
-        assert_eq!(decode_component("%5D"), ~"]");
-    }
-
-    #[test]
-    fn test_encode_form_urlencoded() {
-        let mut m = HashMap::new();
-        assert_eq!(encode_form_urlencoded(&m), ~"");
-
-        m.insert(~"", ~[]);
-        m.insert(~"foo", ~[]);
-        assert_eq!(encode_form_urlencoded(&m), ~"");
-
-        let mut m = HashMap::new();
-        m.insert(~"foo", ~[~"bar", ~"123"]);
-        assert_eq!(encode_form_urlencoded(&m), ~"foo=bar&foo=123");
-
-        let mut m = HashMap::new();
-        m.insert(~"foo bar", ~[~"abc", ~"12 = 34"]);
-        assert!(encode_form_urlencoded(&m) ==
-            ~"foo+bar=abc&foo+bar=12+%3D+34");
-    }
-
-    #[test]
-    fn test_decode_form_urlencoded() {
-        assert_eq!(decode_form_urlencoded([]).len(), 0);
-
-        let s = "a=1&foo+bar=abc&foo+bar=12+%3D+34".as_bytes();
-        let form = decode_form_urlencoded(s);
-        assert_eq!(form.len(), 2);
-        assert_eq!(form.get(&~"a"), &~[~"1"]);
-        assert_eq!(form.get(&~"foo bar"), &~[~"abc", ~"12 = 34"]);
-    }
-}
diff --git a/src/libextra/workcache.rs b/src/libextra/workcache.rs
deleted file mode 100644 (file)
index 274258d..0000000
+++ /dev/null
@@ -1,516 +0,0 @@
-// Copyright 2012-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.
-
-#[allow(missing_doc)];
-#[allow(visible_private_types)];
-
-use serialize::json;
-use serialize::json::ToJson;
-use serialize::{Encoder, Encodable, Decoder, Decodable};
-use sync::{Arc,RWArc};
-use collections::TreeMap;
-use std::str;
-use std::io;
-use std::io::{File, MemWriter};
-
-/**
-*
-* This is a loose clone of the [fbuild build system](https://github.com/felix-lang/fbuild),
-* made a touch more generic (not wired to special cases on files) and much
-* less metaprogram-y due to rust's comparative weakness there, relative to
-* python.
-*
-* It's based around _imperative builds_ that happen to have some function
-* calls cached. That is, it's _just_ a mechanism for describing cached
-* functions. This makes it much simpler and smaller than a "build system"
-* that produces an IR and evaluates it. The evaluation order is normal
-* function calls. Some of them just return really quickly.
-*
-* A cached function consumes and produces a set of _works_. A work has a
-* name, a kind (that determines how the value is to be checked for
-* freshness) and a value. Works must also be (de)serializable. Some
-* examples of works:
-*
-*    kind   name    value
-*   ------------------------
-*    cfg    os      linux
-*    file   foo.c   <sha1>
-*    url    foo.com <etag>
-*
-* Works are conceptually single units, but we store them most of the time
-* in maps of the form (type,name) => value. These are WorkMaps.
-*
-* A cached function divides the works it's interested in into inputs and
-* outputs, and subdivides those into declared (input) works and
-* discovered (input and output) works.
-*
-* A _declared_ input or is one that is given to the workcache before
-* any work actually happens, in the "prep" phase. Even when a function's
-* work-doing part (the "exec" phase) never gets called, it has declared
-* inputs, which can be checked for freshness (and potentially
-* used to determine that the function can be skipped).
-*
-* The workcache checks _all_ works for freshness, but uses the set of
-* discovered outputs from the _previous_ exec (which it will re-discover
-* and re-record each time the exec phase runs).
-*
-* Therefore the discovered works cached in the db might be a
-* mis-approximation of the current discoverable works, but this is ok for
-* the following reason: we assume that if an artifact A changed from
-* depending on B,C,D to depending on B,C,D,E, then A itself changed (as
-* part of the change-in-dependencies), so we will be ok.
-*
-* Each function has a single discriminated output work called its _result_.
-* This is only different from other works in that it is returned, by value,
-* from a call to the cacheable function; the other output works are used in
-* passing to invalidate dependencies elsewhere in the cache, but do not
-* otherwise escape from a function invocation. Most functions only have one
-* output work anyways.
-*
-* A database (the central store of a workcache) stores a mappings:
-*
-* (fn_name,{declared_input}) => ({discovered_input},
-*                                {discovered_output},result)
-*
-* (Note: fbuild, which workcache is based on, has the concept of a declared
-* output as separate from a discovered output. This distinction exists only
-* as an artifact of how fbuild works: via annotations on function types
-* and metaprogramming, with explicit dependency declaration as a fallback.
-* Workcache is more explicit about dependencies, and as such treats all
-* outputs the same, as discovered-during-the-last-run.)
-*
-*/
-
-#[deriving(Clone, Eq, Encodable, Decodable, Ord, TotalOrd, TotalEq)]
-struct WorkKey {
-    kind: ~str,
-    name: ~str
-}
-
-impl WorkKey {
-    pub fn new(kind: &str, name: &str) -> WorkKey {
-        WorkKey {
-            kind: kind.to_owned(),
-            name: name.to_owned(),
-        }
-    }
-}
-
-// FIXME #8883: The key should be a WorkKey and not a ~str.
-// This is working around some JSON weirdness.
-#[deriving(Clone, Eq, Encodable, Decodable)]
-struct WorkMap(TreeMap<~str, KindMap>);
-
-#[deriving(Clone, Eq, Encodable, Decodable)]
-struct KindMap(TreeMap<~str, ~str>);
-
-impl WorkMap {
-    fn new() -> WorkMap { WorkMap(TreeMap::new()) }
-
-    fn insert_work_key(&mut self, k: WorkKey, val: ~str) {
-        let WorkKey { kind, name } = k;
-        let WorkMap(ref mut map) = *self;
-        match map.find_mut(&name) {
-            Some(&KindMap(ref mut m)) => { m.insert(kind, val); return; }
-            None => ()
-        }
-        let mut new_map = TreeMap::new();
-        new_map.insert(kind, val);
-        map.insert(name, KindMap(new_map));
-    }
-}
-
-pub struct Database {
-    priv db_filename: Path,
-    priv db_cache: TreeMap<~str, ~str>,
-    db_dirty: bool
-}
-
-impl Database {
-
-    pub fn new(p: Path) -> Database {
-        let mut rslt = Database {
-            db_filename: p,
-            db_cache: TreeMap::new(),
-            db_dirty: false
-        };
-        if rslt.db_filename.exists() {
-            rslt.load();
-        }
-        rslt
-    }
-
-    pub fn prepare(&self,
-                   fn_name: &str,
-                   declared_inputs: &WorkMap)
-                   -> Option<(WorkMap, WorkMap, ~str)> {
-        let k = json_encode(&(fn_name, declared_inputs));
-        match self.db_cache.find(&k) {
-            None => None,
-            Some(v) => Some(json_decode(*v))
-        }
-    }
-
-    pub fn cache(&mut self,
-                 fn_name: &str,
-                 declared_inputs: &WorkMap,
-                 discovered_inputs: &WorkMap,
-                 discovered_outputs: &WorkMap,
-                 result: &str) {
-        let k = json_encode(&(fn_name, declared_inputs));
-        let v = json_encode(&(discovered_inputs,
-                              discovered_outputs,
-                              result));
-        self.db_cache.insert(k,v);
-        self.db_dirty = true
-    }
-
-    // FIXME #4330: This should have &mut self and should set self.db_dirty to false.
-    fn save(&self) -> io::IoResult<()> {
-        let mut f = File::create(&self.db_filename);
-        self.db_cache.to_json().to_pretty_writer(&mut f)
-    }
-
-    fn load(&mut self) {
-        assert!(!self.db_dirty);
-        assert!(self.db_filename.exists());
-        match File::open(&self.db_filename) {
-            Err(e) => fail!("Couldn't load workcache database {}: {}",
-                            self.db_filename.display(),
-                            e),
-            Ok(mut stream) => {
-                match json::from_reader(&mut stream) {
-                    Err(e) => fail!("Couldn't parse workcache database (from file {}): {}",
-                                    self.db_filename.display(), e.to_str()),
-                    Ok(r) => {
-                        let mut decoder = json::Decoder::new(r);
-                        self.db_cache = Decodable::decode(&mut decoder);
-                    }
-                }
-            }
-        }
-    }
-}
-
-#[unsafe_destructor]
-impl Drop for Database {
-    fn drop(&mut self) {
-        if self.db_dirty {
-            // FIXME: is failing the right thing to do here
-            self.save().unwrap();
-        }
-    }
-}
-
-pub type FreshnessMap = TreeMap<~str,extern fn(&str,&str)->bool>;
-
-#[deriving(Clone)]
-pub struct Context {
-    db: RWArc<Database>,
-    priv cfg: Arc<json::Object>,
-    /// Map from kinds (source, exe, url, etc.) to a freshness function.
-    /// The freshness function takes a name (e.g. file path) and value
-    /// (e.g. hash of file contents) and determines whether it's up-to-date.
-    /// For example, in the file case, this would read the file off disk,
-    /// hash it, and return the result of comparing the given hash and the
-    /// read hash for equality.
-    priv freshness: Arc<FreshnessMap>
-}
-
-pub struct Prep<'a> {
-    priv ctxt: &'a Context,
-    priv fn_name: &'a str,
-    priv declared_inputs: WorkMap,
-}
-
-pub struct Exec {
-    priv discovered_inputs: WorkMap,
-    priv discovered_outputs: WorkMap
-}
-
-enum Work<'a, T> {
-    WorkValue(T),
-    WorkFromTask(&'a Prep<'a>, Receiver<(Exec, T)>),
-}
-
-fn json_encode<'a, T:Encodable<json::Encoder<'a>>>(t: &T) -> ~str {
-    let mut writer = MemWriter::new();
-    let mut encoder = json::Encoder::new(&mut writer as &mut io::Writer);
-    t.encode(&mut encoder);
-    str::from_utf8_owned(writer.unwrap()).unwrap()
-}
-
-// FIXME(#5121)
-fn json_decode<T:Decodable<json::Decoder>>(s: &str) -> T {
-    debug!("json decoding: {}", s);
-    let j = json::from_str(s).unwrap();
-    let mut decoder = json::Decoder::new(j);
-    Decodable::decode(&mut decoder)
-}
-
-impl Context {
-
-    pub fn new(db: RWArc<Database>,
-               cfg: Arc<json::Object>) -> Context {
-        Context::new_with_freshness(db, cfg, Arc::new(TreeMap::new()))
-    }
-
-    pub fn new_with_freshness(db: RWArc<Database>,
-                              cfg: Arc<json::Object>,
-                              freshness: Arc<FreshnessMap>) -> Context {
-        Context {
-            db: db,
-            cfg: cfg,
-            freshness: freshness
-        }
-    }
-
-    pub fn prep<'a>(&'a self, fn_name: &'a str) -> Prep<'a> {
-        Prep::new(self, fn_name)
-    }
-
-    pub fn with_prep<'a,
-                     T>(
-                     &'a self,
-                     fn_name: &'a str,
-                     blk: |p: &mut Prep| -> T)
-                     -> T {
-        let mut p = self.prep(fn_name);
-        blk(&mut p)
-    }
-
-}
-
-impl Exec {
-    pub fn discover_input(&mut self,
-                          dependency_kind: &str,
-                          dependency_name: &str,
-                          dependency_val: &str) {
-        debug!("Discovering input {} {} {}", dependency_kind, dependency_name, dependency_val);
-        self.discovered_inputs.insert_work_key(WorkKey::new(dependency_kind, dependency_name),
-                                 dependency_val.to_owned());
-    }
-    pub fn discover_output(&mut self,
-                           dependency_kind: &str,
-                           dependency_name: &str,
-                           dependency_val: &str) {
-        debug!("Discovering output {} {} {}", dependency_kind, dependency_name, dependency_val);
-        self.discovered_outputs.insert_work_key(WorkKey::new(dependency_kind, dependency_name),
-                                 dependency_val.to_owned());
-    }
-
-    // returns pairs of (kind, name)
-    pub fn lookup_discovered_inputs(&self) -> ~[(~str, ~str)] {
-        let mut rs = ~[];
-        let WorkMap(ref discovered_inputs) = self.discovered_inputs;
-        for (k, v) in discovered_inputs.iter() {
-            let KindMap(ref vmap) = *v;
-            for (k1, _) in vmap.iter() {
-                rs.push((k1.clone(), k.clone()));
-            }
-        }
-        rs
-    }
-}
-
-impl<'a> Prep<'a> {
-    fn new(ctxt: &'a Context, fn_name: &'a str) -> Prep<'a> {
-        Prep {
-            ctxt: ctxt,
-            fn_name: fn_name,
-            declared_inputs: WorkMap::new()
-        }
-    }
-
-    pub fn lookup_declared_inputs(&self) -> ~[~str] {
-        let mut rs = ~[];
-        let WorkMap(ref declared_inputs) = self.declared_inputs;
-        for (_, v) in declared_inputs.iter() {
-            let KindMap(ref vmap) = *v;
-            for (inp, _) in vmap.iter() {
-                rs.push(inp.clone());
-            }
-        }
-        rs
-    }
-}
-
-impl<'a> Prep<'a> {
-    pub fn declare_input(&mut self, kind: &str, name: &str, val: &str) {
-        debug!("Declaring input {} {} {}", kind, name, val);
-        self.declared_inputs.insert_work_key(WorkKey::new(kind, name),
-                                 val.to_owned());
-    }
-
-    fn is_fresh(&self, cat: &str, kind: &str,
-                name: &str, val: &str) -> bool {
-        let k = kind.to_owned();
-        let f = self.ctxt.freshness.get().find(&k);
-        debug!("freshness for: {}/{}/{}/{}", cat, kind, name, val)
-        let fresh = match f {
-            None => fail!("missing freshness-function for '{}'", kind),
-            Some(f) => (*f)(name, val)
-        };
-        if fresh {
-            info!("{} {}:{} is fresh", cat, kind, name);
-        } else {
-            info!("{} {}:{} is not fresh", cat, kind, name);
-        }
-        fresh
-    }
-
-    fn all_fresh(&self, cat: &str, map: &WorkMap) -> bool {
-        let WorkMap(ref map) = *map;
-        for (k_name, kindmap) in map.iter() {
-            let KindMap(ref kindmap_) = *kindmap;
-            for (k_kind, v) in kindmap_.iter() {
-               if ! self.is_fresh(cat, *k_kind, *k_name, *v) {
-                  return false;
-            }
-          }
-        }
-        return true;
-    }
-
-    pub fn exec<'a, T:Send +
-        Encodable<json::Encoder<'a>> +
-        Decodable<json::Decoder>>(
-            &'a self, blk: proc(&mut Exec) -> T) -> T {
-        self.exec_work(blk).unwrap()
-    }
-
-    fn exec_work<'a, T:Send +
-        Encodable<json::Encoder<'a>> +
-        Decodable<json::Decoder>>( // FIXME(#5121)
-            &'a self, blk: proc(&mut Exec) -> T) -> Work<'a, T> {
-        let mut bo = Some(blk);
-
-        debug!("exec_work: looking up {} and {:?}", self.fn_name,
-               self.declared_inputs);
-        let cached = self.ctxt.db.read(|db| {
-            db.prepare(self.fn_name, &self.declared_inputs)
-        });
-
-        match cached {
-            Some((ref disc_in, ref disc_out, ref res))
-            if self.all_fresh("declared input",&self.declared_inputs) &&
-               self.all_fresh("discovered input", disc_in) &&
-               self.all_fresh("discovered output", disc_out) => {
-                debug!("Cache hit!");
-                debug!("Trying to decode: {:?} / {:?} / {}",
-                       disc_in, disc_out, *res);
-                Work::from_value(json_decode(*res))
-            }
-
-            _ => {
-                debug!("Cache miss!");
-                let (tx, rx) = channel();
-                let blk = bo.take_unwrap();
-
-                // FIXME: What happens if the task fails?
-                spawn(proc() {
-                    let mut exe = Exec {
-                        discovered_inputs: WorkMap::new(),
-                        discovered_outputs: WorkMap::new(),
-                    };
-                    let v = blk(&mut exe);
-                    tx.send((exe, v));
-                });
-                Work::from_task(self, rx)
-            }
-        }
-    }
-}
-
-impl<'a, T:Send +
-       Encodable<json::Encoder<'a>> +
-       Decodable<json::Decoder>>
-    Work<'a, T> { // FIXME(#5121)
-
-    pub fn from_value(elt: T) -> Work<'a, T> {
-        WorkValue(elt)
-    }
-    pub fn from_task(prep: &'a Prep<'a>, port: Receiver<(Exec, T)>)
-        -> Work<'a, T> {
-        WorkFromTask(prep, port)
-    }
-
-    pub fn unwrap(self) -> T {
-        match self {
-            WorkValue(v) => v,
-            WorkFromTask(prep, port) => {
-                let (exe, v) = port.recv();
-                let s = json_encode(&v);
-                prep.ctxt.db.write(|db| {
-                    db.cache(prep.fn_name,
-                             &prep.declared_inputs,
-                             &exe.discovered_inputs,
-                             &exe.discovered_outputs,
-                             s)
-                });
-                v
-            }
-        }
-    }
-}
-
-
-#[test]
-#[cfg(not(target_os="android"))] // FIXME(#10455)
-fn test() {
-    use std::os;
-    use std::io::{fs, Process};
-    use std::str::from_utf8_owned;
-
-    // Create a path to a new file 'filename' in the directory in which
-    // this test is running.
-    fn make_path(filename: ~str) -> Path {
-        let pth = os::self_exe_path().expect("workcache::test failed").with_filename(filename);
-        if pth.exists() {
-            fs::unlink(&pth).unwrap();
-        }
-        return pth;
-    }
-
-    let pth = make_path(~"foo.c");
-    File::create(&pth).write(bytes!("int main() { return 0; }")).unwrap();
-
-    let db_path = make_path(~"db.json");
-
-    let cx = Context::new(RWArc::new(Database::new(db_path)),
-                          Arc::new(TreeMap::new()));
-
-    let s = cx.with_prep("test1", |prep| {
-
-        let subcx = cx.clone();
-        let pth = pth.clone();
-
-        let contents = File::open(&pth).read_to_end().unwrap();
-        let file_content = from_utf8_owned(contents).unwrap();
-
-        // FIXME (#9639): This needs to handle non-utf8 paths
-        prep.declare_input("file", pth.as_str().unwrap(), file_content);
-        prep.exec(proc(_exe) {
-            let out = make_path(~"foo.o");
-            // FIXME (#9639): This needs to handle non-utf8 paths
-            Process::status("gcc", [pth.as_str().unwrap().to_owned(),
-                                    ~"-o",
-                                    out.as_str().unwrap().to_owned()]).unwrap();
-
-            let _proof_of_concept = subcx.prep("subfn");
-            // Could run sub-rules inside here.
-
-            // FIXME (#9639): This needs to handle non-utf8 paths
-            out.as_str().unwrap().to_owned()
-        })
-    });
-
-    println!("{}", s);
-}
index 6bf5092bb2d515249ad3abe897e6cd90125b42c1..d9f7ae9a856ca519dc04074c9c8d3f94ae15b0ba 100644 (file)
 #[crate_type = "rlib"];
 #[crate_type = "dylib"];
 #[license = "MIT/ASL2"];
-#[allow(missing_doc)];
+#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+      html_root_url = "http://static.rust-lang.org/doc/master")];
+#[feature(phase)];
+
+#[cfg(test)] #[phase(syntax, link)] extern crate log;
 
-extern crate extra;
 use std::libc::{c_void, size_t, c_int};
 use std::libc;
-use extra::c_vec::CVec;
+use std::c_vec::CVec;
 
 pub mod rustrt {
     use std::libc::{c_int, c_void, size_t};
@@ -90,6 +94,7 @@ pub fn inflate_bytes_zlib(bytes: &[u8]) -> CVec<u8> {
 
 #[cfg(test)]
 mod tests {
+    #[allow(deprecated_owned_vector)];
     extern crate rand;
 
     use super::{inflate_bytes, deflate_bytes};
index c465c8f1e1608a7ec8801917fc1645687c26c76a..ddbd5b507efe612d499759f97090657c15b28143 100644 (file)
@@ -43,6 +43,9 @@ fn main() {
 #[crate_type = "rlib"];
 #[crate_type = "dylib"];
 #[license = "MIT/ASL2"];
+#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+      html_root_url = "http://static.rust-lang.org/doc/master")];
 
 #[feature(macro_registrar, managed_boxes)];
 
index b1b8351b040adc8900b13acd80ba2f5f21079e43..6aa064bb69a6acf8e46850e4e7150405df42557c 100644 (file)
 #[crate_type = "rlib"];
 #[crate_type = "dylib"];
 #[license = "MIT/ASL2"];
+#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+      html_root_url = "http://static.rust-lang.org/doc/master")];
 #[allow(missing_doc)];
+#[allow(deprecated_owned_vector)];
 
-#[feature(globs)];
+#[feature(globs, phase)];
+
+#[cfg(test)] #[phase(syntax, link)] extern crate log;
 
 use std::cmp::Eq;
 use std::result::{Err, Ok};
index a33d041ab20c8eb8903232c3088ba4196eb1d777..d48a7af01e8e3b6309ba5b8e038bd3d83d404716 100644 (file)
 #[crate_type = "rlib"];
 #[crate_type = "dylib"];
 #[license = "MIT/ASL2"];
+#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+      html_root_url = "http://static.rust-lang.org/doc/master")];
+#[allow(deprecated_owned_vector)];
 
 use std::cell::Cell;
 use std::{cmp, os, path};
index 779fb6815b7e92f45a993e0cb71ee36270a1bb6d..f072df733684776aea99cb73ebf31a63d10a5c9f 100644 (file)
@@ -283,6 +283,8 @@ fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint,
     unsafe { *sp = 0; }
 
     regs[4] = arg as uint;
+    regs[5] = procedure.code as uint;
+    regs[6] = procedure.env as uint;
     regs[29] = sp as uint;
     regs[25] = fptr as uint;
     regs[31] = fptr as uint;
index 93b7ec2aecf5d504988780ba892851f86fc83e13..78ea407d4eb53d19d6956eccd53331b4b7c80586 100644 (file)
       html_root_url = "http://static.rust-lang.org/doc/master")];
 
 // NB this does *not* include globs, please keep it that way.
-#[feature(macro_rules)];
+#[feature(macro_rules, phase)];
 #[allow(visible_private_types)];
+#[allow(deprecated_owned_vector)];
 
+#[cfg(test)] #[phase(syntax, link)] extern crate log;
 extern crate rand;
 
 use std::mem::replace;
index c6608f0c9db89e29df19367121a50cee5473d072..97924eca1b9fc19589e176707bb91e6080f0f508 100644 (file)
 
 use std::any::Any;
 use std::cast;
-use std::rt::env;
+use std::raw;
 use std::rt::Runtime;
+use std::rt::env;
 use std::rt::local::Local;
 use std::rt::rtio;
+use std::rt::stack;
 use std::rt::task::{Task, BlockedTask, SendMessage};
 use std::task::TaskOpts;
 use std::unstable::mutex::NativeMutex;
-use std::raw;
 
 use context::Context;
 use coroutine::Coroutine;
@@ -177,14 +178,13 @@ pub fn configure(pool: &mut StackPool,
                      f: proc()) -> ~GreenTask {
         let TaskOpts {
             notify_chan, name, stack_size,
-            stderr, stdout, logger,
+            stderr, stdout,
         } = opts;
 
         let mut green = GreenTask::new(pool, stack_size, f);
         {
             let task = green.task.get_mut_ref();
             task.name = name;
-            task.logger = logger;
             task.stderr = stderr;
             task.stdout = stdout;
             match notify_chan {
@@ -469,7 +469,9 @@ fn stack_bounds(&self) -> (uint, uint) {
         let c = self.coroutine.as_ref()
             .expect("GreenTask.stack_bounds called without a coroutine");
 
-        (c.current_stack_segment.start() as uint,
+        // Don't return the red zone as part of the usable stack of this task,
+        // it's essentially an implementation detail.
+        (c.current_stack_segment.start() as uint + stack::RED_ZONE,
          c.current_stack_segment.end() as uint)
     }
 
index f331391d35a031b3e105221bc70bc6033579a9e2..16a18f459c00d9021d29053a0ac6f2d2201472af 100644 (file)
@@ -40,6 +40,9 @@ fn main() {
 #[crate_type = "rlib"];
 #[crate_type = "dylib"];
 #[license = "MIT/ASL2"];
+#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+      html_root_url = "http://static.rust-lang.org/doc/master")];
 
 #[feature(macro_registrar, managed_boxes)];
 
diff --git a/src/liblog/directive.rs b/src/liblog/directive.rs
new file mode 100644 (file)
index 0000000..d33ad0c
--- /dev/null
@@ -0,0 +1,134 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::cmp;
+use std::vec_ng::Vec;
+
+#[deriving(Show, Clone)]
+pub struct LogDirective {
+    name: Option<~str>,
+    level: u32,
+}
+
+static LOG_LEVEL_NAMES: [&'static str, ..4] = ["error", "warn", "info",
+                                               "debug"];
+
+/// Parse an individual log level that is either a number or a symbolic log level
+fn parse_log_level(level: &str) -> Option<u32> {
+    from_str::<u32>(level).or_else(|| {
+        let pos = LOG_LEVEL_NAMES.iter().position(|&name| name == level);
+        pos.map(|p| p as u32 + 1)
+    }).map(|p| cmp::min(p, ::MAX_LOG_LEVEL))
+}
+
+/// Parse a logging specification string (e.g: "crate1,crate2::mod3,crate3::x=1")
+/// and return a vector with log directives.
+///
+/// Valid log levels are 0-255, with the most likely ones being 1-4 (defined in
+/// std::).  Also supports string log levels of error, warn, info, and debug
+pub fn parse_logging_spec(spec: &str) -> Vec<LogDirective> {
+    let mut dirs = Vec::new();
+    for s in spec.split(',') {
+        if s.len() == 0 { continue }
+        let mut parts = s.split('=');
+        let (log_level, name) = match (parts.next(), parts.next(), parts.next()) {
+            (Some(part0), None, None) => {
+                // if the single argument is a log-level string or number,
+                // treat that as a global fallback
+                match parse_log_level(part0) {
+                    Some(num) => (num, None),
+                    None => (::MAX_LOG_LEVEL, Some(part0)),
+                }
+            }
+            (Some(part0), Some(part1), None) => {
+                match parse_log_level(part1) {
+                    Some(num) => (num, Some(part0)),
+                    _ => {
+                        println!("warning: invalid logging spec '{}', \
+                                 ignoring it", part1);
+                        continue
+                    }
+                }
+            },
+            _ => {
+                println!("warning: invalid logging spec '{}', \
+                         ignoring it", s);
+                continue
+            }
+        };
+        dirs.push(LogDirective {
+            name: name.map(|s| s.to_owned()),
+            level: log_level,
+        });
+    }
+    return dirs;
+}
+
+#[cfg(test)]
+mod tests {
+    use super::parse_logging_spec;
+
+    #[test]
+    fn parse_logging_spec_valid() {
+        let dirs = parse_logging_spec("crate1::mod1=1,crate1::mod2,crate2=4");
+        let dirs = dirs.as_slice();
+        assert_eq!(dirs.len(), 3);
+        assert_eq!(dirs[0].name, Some(~"crate1::mod1"));
+        assert_eq!(dirs[0].level, 1);
+
+        assert_eq!(dirs[1].name, Some(~"crate1::mod2"));
+        assert_eq!(dirs[1].level, ::MAX_LOG_LEVEL);
+
+        assert_eq!(dirs[2].name, Some(~"crate2"));
+        assert_eq!(dirs[2].level, 4);
+    }
+
+    #[test]
+    fn parse_logging_spec_invalid_crate() {
+        // test parse_logging_spec with multiple = in specification
+        let dirs = parse_logging_spec("crate1::mod1=1=2,crate2=4");
+        let dirs = dirs.as_slice();
+        assert_eq!(dirs.len(), 1);
+        assert_eq!(dirs[0].name, Some(~"crate2"));
+        assert_eq!(dirs[0].level, 4);
+    }
+
+    #[test]
+    fn parse_logging_spec_invalid_log_level() {
+        // test parse_logging_spec with 'noNumber' as log level
+        let dirs = parse_logging_spec("crate1::mod1=noNumber,crate2=4");
+        let dirs = dirs.as_slice();
+        assert_eq!(dirs.len(), 1);
+        assert_eq!(dirs[0].name, Some(~"crate2"));
+        assert_eq!(dirs[0].level, 4);
+    }
+
+    #[test]
+    fn parse_logging_spec_string_log_level() {
+        // test parse_logging_spec with 'warn' as log level
+        let dirs = parse_logging_spec("crate1::mod1=wrong,crate2=warn");
+        let dirs = dirs.as_slice();
+        assert_eq!(dirs.len(), 1);
+        assert_eq!(dirs[0].name, Some(~"crate2"));
+        assert_eq!(dirs[0].level, ::WARN);
+    }
+
+    #[test]
+    fn parse_logging_spec_global() {
+        // test parse_logging_spec with no crate
+        let dirs = parse_logging_spec("warn,crate2=4");
+        let dirs = dirs.as_slice();
+        assert_eq!(dirs.len(), 2);
+        assert_eq!(dirs[0].name, None);
+        assert_eq!(dirs[0].level, 2);
+        assert_eq!(dirs[1].name, Some(~"crate2"));
+        assert_eq!(dirs[1].level, 4);
+    }
+}
diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs
new file mode 100644 (file)
index 0000000..3ff7ee3
--- /dev/null
@@ -0,0 +1,355 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+/*!
+
+Utilities for program-wide and customizable logging
+
+## Example
+
+```
+#[feature(phase)];
+#[phase(syntax, link)] extern crate log;
+
+fn main() {
+    debug!("this is a debug {}", "message");
+    error!("this is printed by default");
+
+    if log_enabled!(log::INFO) {
+        let x = 3 * 4; // expensive computation
+        info!("the answer was: {}", x);
+    }
+}
+```
+
+## Logging Macros
+
+There are five macros that the logging subsystem uses:
+
+* `log!(level, ...)` - the generic logging macro, takes a level as a u32 and any
+                       related `format!` arguments
+* `debug!(...)` - a macro hard-wired to the log level of `DEBUG`
+* `info!(...)` - a macro hard-wired to the log level of `INFO`
+* `warn!(...)` - a macro hard-wired to the log level of `WARN`
+* `error!(...)` - a macro hard-wired to the log level of `ERROR`
+
+All of these macros use std::the same style of syntax as the `format!` syntax
+extension. Details about the syntax can be found in the documentation of
+`std::fmt` along with the Rust tutorial/manual.
+
+If you want to check at runtime if a given logging level is enabled (e.g. if the
+information you would want to log is expensive to produce), you can use std::the
+following macro:
+
+* `log_enabled!(level)` - returns true if logging of the given level is enabled
+
+## Enabling logging
+
+Log levels are controlled on a per-module basis, and by default all logging is
+disabled except for `error!` (a log level of 1). Logging is controlled via the
+`RUST_LOG` environment variable. The value of this environment variable is a
+comma-separated list of logging directives. A logging directive is of the form:
+
+```notrust
+path::to::module=log_level
+```
+
+The path to the module is rooted in the name of the crate it was compiled for,
+so if your program is contained in a file `hello.rs`, for example, to turn on
+logging for this file you would use std::a value of `RUST_LOG=hello`.
+Furthermore, this path is a prefix-search, so all modules nested in the
+specified module will also have logging enabled.
+
+The actual `log_level` is optional to specify. If omitted, all logging will be
+enabled. If specified, the it must be either a numeric in the range of 1-255, or
+it must be one of the strings `debug`, `error`, `info`, or `warn`. If a numeric
+is specified, then all logging less than or equal to that numeral is enabled.
+For example, if logging level 3 is active, error, warn, and info logs will be
+printed, but debug will be omitted.
+
+As the log level for a module is optional, the module to enable logging for is
+also optional. If only a `log_level` is provided, then the global log level for
+all modules is set to this value.
+
+Some examples of valid values of `RUST_LOG` are:
+
+```notrust
+hello                // turns on all logging for the 'hello' module
+info                 // turns on all info logging
+hello=debug          // turns on debug logging for 'hello'
+hello=3              // turns on info logging for 'hello'
+hello,std::option    // turns on hello, and std's option logging
+error,hello=warn     // turn on global error logging and also warn for hello
+```
+
+## Performance and Side Effects
+
+Each of these macros will expand to code similar to:
+
+```rust,ignore
+if log_level <= my_module_log_level() {
+    ::log::log(log_level, format!(...));
+}
+```
+
+What this means is that each of these macros are very cheap at runtime if
+they're turned off (just a load and an integer comparison). This also means that
+if logging is disabled, none of the components of the log will be executed.
+
+*/
+
+#[crate_id = "log#0.10-pre"];
+#[license = "MIT/ASL2"];
+#[crate_type = "rlib"];
+#[crate_type = "dylib"];
+#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+      html_root_url = "http://static.rust-lang.org/doc/master")];
+
+#[feature(macro_rules)];
+#[deny(missing_doc)];
+
+extern crate sync;
+
+use std::cast;
+use std::fmt;
+use std::io::LineBufferedWriter;
+use std::io;
+use std::local_data;
+use std::os;
+use std::rt;
+use std::vec;
+use std::vec_ng::Vec;
+
+use sync::one::{Once, ONCE_INIT};
+
+pub mod macros;
+mod directive;
+
+/// Maximum logging level of a module that can be specified. Common logging
+/// levels are found in the DEBUG/INFO/WARN/ERROR constants.
+pub static MAX_LOG_LEVEL: u32 = 255;
+
+/// The default logging level of a crate if no other is specified.
+static DEFAULT_LOG_LEVEL: u32 = 1;
+
+/// An unsafe constant that is the maximum logging level of any module
+/// specified. This is the first line of defense to determining whether a
+/// logging statement should be run.
+static mut LOG_LEVEL: u32 = MAX_LOG_LEVEL;
+
+static mut DIRECTIVES: *Vec<directive::LogDirective> =
+    0 as *Vec<directive::LogDirective>;
+
+/// Debug log level
+pub static DEBUG: u32 = 4;
+/// Info log level
+pub static INFO: u32 = 3;
+/// Warn log level
+pub static WARN: u32 = 2;
+/// Error log level
+pub static ERROR: u32 = 1;
+
+local_data_key!(local_logger: ~Logger)
+
+/// A trait used to represent an interface to a task-local logger. Each task
+/// can have its own custom logger which can respond to logging messages
+/// however it likes.
+pub trait Logger {
+    /// Logs a single message described by the `args` structure. The level is
+    /// provided in case you want to do things like color the message, etc.
+    fn log(&mut self, level: u32, args: &fmt::Arguments);
+}
+
+struct DefaultLogger {
+    handle: LineBufferedWriter<io::stdio::StdWriter>,
+}
+
+impl Logger for DefaultLogger {
+    // by default, just ignore the level
+    fn log(&mut self, _level: u32, args: &fmt::Arguments) {
+        match fmt::writeln(&mut self.handle, args) {
+            Err(e) => fail!("failed to log: {}", e),
+            Ok(()) => {}
+        }
+    }
+}
+
+impl Drop for DefaultLogger {
+    fn drop(&mut self) {
+        // FIXME(#12628): is failure the right thing to do?
+        match self.handle.flush() {
+            Err(e) => fail!("failed to flush a logger: {}", e),
+            Ok(()) => {}
+        }
+    }
+}
+
+/// This function is called directly by the compiler when using the logging
+/// macros. This function does not take into account whether the log level
+/// specified is active or not, it will always log something if this method is
+/// called.
+///
+/// It is not recommended to call this function directly, rather it should be
+/// invoked through the logging family of macros.
+pub fn log(level: u32, args: &fmt::Arguments) {
+    // Completely remove the local logger from TLS in case anyone attempts to
+    // frob the slot while we're doing the logging. This will destroy any logger
+    // set during logging.
+    let mut logger = local_data::pop(local_logger).unwrap_or_else(|| {
+        ~DefaultLogger { handle: io::stderr() } as ~Logger
+    });
+    logger.log(level, args);
+    local_data::set(local_logger, logger);
+}
+
+/// Getter for the global log level. This is a function so that it can be called
+/// safely
+#[doc(hidden)]
+#[inline(always)]
+pub fn log_level() -> u32 { unsafe { LOG_LEVEL } }
+
+/// Replaces the task-local logger with the specified logger, returning the old
+/// logger.
+pub fn set_logger(logger: ~Logger) -> Option<~Logger> {
+    let prev = local_data::pop(local_logger);
+    local_data::set(local_logger, logger);
+    return prev;
+}
+
+/// Tests whether a given module's name is enabled for a particular level of
+/// logging. This is the second layer of defense about determining whether a
+/// module's log statement should be emitted or not.
+#[doc(hidden)]
+pub fn mod_enabled(level: u32, module: &str) -> bool {
+    static mut INIT: Once = ONCE_INIT;
+    unsafe { INIT.doit(init); }
+
+    // It's possible for many threads are in this function, only one of them
+    // will peform the global initialization, but all of them will need to check
+    // again to whether they should really be here or not. Hence, despite this
+    // check being expanded manually in the logging macro, this function checks
+    // the log level again.
+    if level > unsafe { LOG_LEVEL } { return false }
+
+    // This assertion should never get tripped unless we're in an at_exit
+    // handler after logging has been torn down and a logging attempt was made.
+    assert!(unsafe { !DIRECTIVES.is_null() });
+
+    enabled(level, module, unsafe { (*DIRECTIVES).iter() })
+}
+
+fn enabled(level: u32, module: &str,
+           iter: vec::Items<directive::LogDirective>) -> bool {
+    // Search for the longest match, the vector is assumed to be pre-sorted.
+    for directive in iter.rev() {
+        match directive.name {
+            Some(ref name) if !module.starts_with(*name) => {},
+            Some(..) | None => {
+                return level <= directive.level
+            }
+        }
+    }
+    level <= DEFAULT_LOG_LEVEL
+}
+
+/// Initialize logging for the current process.
+///
+/// This is not threadsafe at all, so initialization os performed through a
+/// `Once` primitive (and this function is called from that primitive).
+fn init() {
+    let mut directives = match os::getenv("RUST_LOG") {
+        Some(spec) => directive::parse_logging_spec(spec),
+        None => Vec::new(),
+    };
+
+    // Sort the provided directives by length of their name, this allows a
+    // little more efficient lookup at runtime.
+    directives.sort_by(|a, b| {
+        let alen = a.name.as_ref().map(|a| a.len()).unwrap_or(0);
+        let blen = b.name.as_ref().map(|b| b.len()).unwrap_or(0);
+        alen.cmp(&blen)
+    });
+
+    let max_level = {
+        let max = directives.iter().max_by(|d| d.level);
+        max.map(|d| d.level).unwrap_or(DEFAULT_LOG_LEVEL)
+    };
+
+    unsafe {
+        LOG_LEVEL = max_level;
+
+        assert!(DIRECTIVES.is_null());
+        DIRECTIVES = cast::transmute(~directives);
+
+        // Schedule the cleanup for this global for when the runtime exits.
+        rt::at_exit(proc() {
+            assert!(!DIRECTIVES.is_null());
+            let _directives: ~Vec<directive::LogDirective> =
+                cast::transmute(DIRECTIVES);
+            DIRECTIVES = 0 as *Vec<directive::LogDirective>;
+        });
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use super::enabled;
+    use directive::LogDirective;
+
+    #[test]
+    fn match_full_path() {
+        let dirs = [LogDirective { name: Some(~"crate2"), level: 3 },
+                    LogDirective { name: Some(~"crate1::mod1"), level: 2 }];
+        assert!(enabled(2, "crate1::mod1", dirs.iter()));
+        assert!(!enabled(3, "crate1::mod1", dirs.iter()));
+        assert!(enabled(3, "crate2", dirs.iter()));
+        assert!(!enabled(4, "crate2", dirs.iter()));
+    }
+
+    #[test]
+    fn no_match() {
+        let dirs = [LogDirective { name: Some(~"crate2"), level: 3 },
+                    LogDirective { name: Some(~"crate1::mod1"), level: 2 }];
+        assert!(!enabled(2, "crate3", dirs.iter()));
+    }
+
+    #[test]
+    fn match_beginning() {
+        let dirs = [LogDirective { name: Some(~"crate2"), level: 3 },
+                    LogDirective { name: Some(~"crate1::mod1"), level: 2 }];
+        assert!(enabled(3, "crate2::mod1", dirs.iter()));
+    }
+
+    #[test]
+    fn match_beginning_longest_match() {
+        let dirs = [LogDirective { name: Some(~"crate2"), level: 3 },
+                    LogDirective { name: Some(~"crate2::mod"), level: 4 },
+                    LogDirective { name: Some(~"crate1::mod1"), level: 2 }];
+        assert!(enabled(4, "crate2::mod1", dirs.iter()));
+        assert!(!enabled(4, "crate2", dirs.iter()));
+    }
+
+    #[test]
+    fn match_default() {
+        let dirs = [LogDirective { name: None, level: 3 },
+                    LogDirective { name: Some(~"crate1::mod1"), level: 2 }];
+        assert!(enabled(2, "crate1::mod1", dirs.iter()));
+        assert!(enabled(3, "crate2::mod2", dirs.iter()));
+    }
+
+    #[test]
+    fn zero_level() {
+        let dirs = [LogDirective { name: None, level: 3 },
+                    LogDirective { name: Some(~"crate1::mod1"), level: 0 }];
+        assert!(!enabled(1, "crate1::mod1", dirs.iter()));
+        assert!(enabled(3, "crate2::mod2", dirs.iter()));
+    }
+}
diff --git a/src/liblog/macros.rs b/src/liblog/macros.rs
new file mode 100644 (file)
index 0000000..1560eee
--- /dev/null
@@ -0,0 +1,141 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! Logging macros
+
+#[macro_escape];
+
+/// The standard logging macro
+///
+/// This macro will generically log over a provided level (of type u32) with a
+/// format!-based argument list. See documentation in `std::fmt` for details on
+/// how to use the syntax.
+///
+/// # Example
+///
+/// ```
+/// #[feature(phase)];
+/// #[phase(syntax, link)] extern crate log;
+///
+/// # fn main() {
+/// log!(log::DEBUG, "this is a debug message");
+/// log!(log::WARN, "this is a warning {}", "message");
+/// log!(6, "this is a custom logging level: {level}", level=6);
+/// # }
+/// ```
+#[macro_export]
+macro_rules! log(
+    ($lvl:expr, $($arg:tt)+) => ({
+        let lvl = $lvl;
+        if log_enabled!(lvl) {
+            format_args!(|args| { ::log::log(lvl, args) }, $($arg)+)
+        }
+    })
+)
+
+/// A convenience macro for logging at the error log level.
+///
+/// # Example
+///
+/// ```
+/// #[feature(phase)];
+/// #[phase(syntax, link)] extern crate log;
+///
+/// # fn main() {
+/// # let error = 3;
+/// error!("the build has failed with error code: {}", error);
+/// # }
+/// ```
+#[macro_export]
+macro_rules! error(
+    ($($arg:tt)*) => (log!(::log::ERROR, $($arg)*))
+)
+
+/// A convenience macro for logging at the warning log level.
+///
+/// # Example
+///
+/// ```
+/// #[feature(phase)];
+/// #[phase(syntax, link)] extern crate log;
+///
+/// # fn main() {
+/// # let code = 3;
+/// warn!("you may like to know that a process exited with: {}", code);
+/// # }
+/// ```
+#[macro_export]
+macro_rules! warn(
+    ($($arg:tt)*) => (log!(::log::WARN, $($arg)*))
+)
+
+/// A convenience macro for logging at the info log level.
+///
+/// # Example
+///
+/// ```
+/// #[feature(phase)];
+/// #[phase(syntax, link)] extern crate log;
+///
+/// # fn main() {
+/// # let ret = 3;
+/// info!("this function is about to return: {}", ret);
+/// # }
+/// ```
+#[macro_export]
+macro_rules! info(
+    ($($arg:tt)*) => (log!(::log::INFO, $($arg)*))
+)
+
+/// A convenience macro for logging at the debug log level. This macro can also
+/// be omitted at compile time by passing `--cfg ndebug` to the compiler. If
+/// this option is not passed, then debug statements will be compiled.
+///
+/// # Example
+///
+/// ```
+/// #[feature(phase)];
+/// #[phase(syntax, link)] extern crate log;
+///
+/// # fn main() {
+/// debug!("x = {x}, y = {y}", x=10, y=20);
+/// # }
+/// ```
+#[macro_export]
+macro_rules! debug(
+    ($($arg:tt)*) => (if cfg!(not(ndebug)) { log!(::log::DEBUG, $($arg)*) })
+)
+
+/// A macro to test whether a log level is enabled for the current module.
+///
+/// # Example
+///
+/// ```
+/// #[feature(phase)];
+/// #[phase(syntax, link)] extern crate log;
+///
+/// # fn main() {
+/// # struct Point { x: int, y: int }
+/// # fn some_expensive_computation() -> Point { Point { x: 1, y: 2 } }
+/// if log_enabled!(log::DEBUG) {
+///     let x = some_expensive_computation();
+///     debug!("x.x = {}, x.y = {}", x.x, x.y);
+/// }
+/// # }
+/// ```
+#[macro_export]
+macro_rules! log_enabled(
+    ($lvl:expr) => ({
+        let lvl = $lvl;
+        (lvl != ::log::DEBUG || cfg!(not(ndebug))) &&
+        lvl <= ::log::log_level() &&
+        ::log::mod_enabled(lvl, module_path!())
+    })
+)
index ff1ff9a569d85d13d1a3752f624ef89afdc6be90..1d7938be2262083485e59540277bd2ef3685016d 100644 (file)
@@ -209,7 +209,8 @@ fn drop(&mut self) {
         if self.close_on_drop && self.fd > libc::STDERR_FILENO {
             let n = unsafe { libc::close(self.fd) };
             if n != 0 {
-                warn!("error {} when closing file descriptor {}", n, self.fd);
+                println!("error {} when closing file descriptor {}", n,
+                         self.fd);
             }
         }
     }
@@ -362,13 +363,10 @@ fn prune(root: &CString, dirs: ~[Path]) -> ~[Path] {
     let mut buf = Vec::<u8>::with_capacity(size as uint);
     let ptr = buf.as_mut_slice().as_mut_ptr() as *mut dirent_t;
 
-    debug!("os::list_dir -- BEFORE OPENDIR");
-
     let dir_ptr = p.with_ref(|buf| unsafe { opendir(buf) });
 
     if dir_ptr as uint != 0 {
         let mut paths = ~[];
-        debug!("os::list_dir -- opendir() SUCCESS");
         let mut entry_ptr = 0 as *mut dirent_t;
         while unsafe { readdir_r(dir_ptr, ptr, &mut entry_ptr) == 0 } {
             if entry_ptr.is_null() { break }
index 8f4f9259ab7ac9269e6e77d6172f5ba529038b55..c5ae4f00017a9fca2f3b369fb4ef7d6472370cea 100644 (file)
@@ -238,7 +238,7 @@ fn drop(&mut self) {
         if self.close_on_drop && self.fd > libc::STDERR_FILENO {
             let n = unsafe { libc::close(self.fd) };
             if n != 0 {
-                warn!("error {} when closing file descriptor {}", n, self.fd);
+                println!("error {} when closing file descriptor {}", n, self.fd);
             }
         }
     }
index a054ee66391fa006411657a8278709eb30d2ad7c..615ed80a64866a06387ab48e57202d603d7a52a3 100644 (file)
@@ -112,10 +112,7 @@ fn get_err(errno: i32) -> (io::IoErrorKind, &'static str) {
             libc::ERROR_INVALID_FUNCTION => (io::InvalidInput,
                                              "illegal operation on a directory"),
 
-            x => {
-                debug!("ignoring {}: {}", x, os::last_os_error());
-                (io::OtherIoError, "unknown error")
-            }
+            _ => (io::OtherIoError, "unknown error")
         }
     }
 
@@ -141,10 +138,7 @@ fn get_err(errno: i32) -> (io::IoErrorKind, &'static str) {
             x if x == libc::EAGAIN || x == libc::EWOULDBLOCK =>
                 (io::ResourceUnavailable, "resource temporarily unavailable"),
 
-            x => {
-                debug!("ignoring {}: {}", x, os::last_os_error());
-                (io::OtherIoError, "unknown error")
-            }
+            _ => (io::OtherIoError, "unknown error")
         }
     }
 
index 7445e4c09926171c7b90d4c67b61db062bd62fc0..6a71107294207c9b87185aba0ce88ac18daa4c35 100644 (file)
@@ -351,6 +351,11 @@ fn letdie(&mut self) -> IoResult<()> {
     fn clone(&self) -> ~rtio::RtioTcpStream {
         ~TcpStream { inner: self.inner.clone() } as ~rtio::RtioTcpStream
     }
+    fn close_write(&mut self) -> IoResult<()> {
+        super::mkerr_libc(unsafe {
+            libc::shutdown(self.fd(), libc::SHUT_WR)
+        })
+    }
 }
 
 impl rtio::RtioSocket for TcpStream {
index 1b0e08ca6fb97883f03c8cffe52a6a182e681126..a8018bec0a6e36b844206eab85be3538b2b7554f 100644 (file)
@@ -89,10 +89,8 @@ fn del(efd: libc::c_int, fd: libc::c_int) {
         };
 
         let mut incoming = false;
-        debug!("{} events to process", n);
         for event in events.slice_to(n as uint).iter() {
             let fd = event.data as libc::c_int;
-            debug!("data on fd {} (input = {})", fd, input);
             if fd == input {
                 let mut buf = [0, ..1];
                 // drain the input file descriptor of its input
index 4b6942a1083163dcd0cdf9da9cd9e2d802c4b12b..b7a38dec1acb3a6829a46d2f5f231e287e34698d 100644 (file)
@@ -50,6 +50,7 @@
       html_root_url = "http://static.rust-lang.org/doc/master")];
 #[deny(unused_result, unused_must_use)];
 #[allow(non_camel_case_types)];
+#[allow(deprecated_owned_vector)];
 
 // NB this crate explicitly does *not* allow glob imports, please seriously
 //    consider whether they're needed before adding that feature here (the
index 8510b50777abde50d1b5740d7e9a0baa95002488..7a42d1bfee368d2e7c50f5a83ad132ff6a75437b 100644 (file)
@@ -59,12 +59,11 @@ pub fn spawn(f: proc()) {
 pub fn spawn_opts(opts: TaskOpts, f: proc()) {
     let TaskOpts {
         notify_chan, name, stack_size,
-        logger, stderr, stdout,
+        stderr, stdout,
     } = opts;
 
     let mut task = ~Task::new();
     task.name = name;
-    task.logger = logger;
     task.stderr = stderr;
     task.stdout = stdout;
     match notify_chan {
index c6203b3f234c98fbffa0a0273cbe83c65f4d170b..4fcd1a6afb82b331a924784e0d71b6cf2c21603c 100644 (file)
@@ -27,8 +27,9 @@
 use rand::Rng;
 use std::str;
 use std::uint;
-use std::vec;
 use std::{i64, u64};
+use std::vec_ng;
+use std::vec_ng::Vec;
 
 /**
 A `BigDigit` is a `BigUint`'s composing element.
@@ -47,6 +48,7 @@
 pub type BigDigit = u32;
 
 pub static ZERO_BIG_DIGIT: BigDigit = 0;
+static ZERO_VEC: [BigDigit, ..1] = [ZERO_BIG_DIGIT];
 
 pub mod BigDigit {
     use super::BigDigit;
@@ -86,7 +88,7 @@ pub fn to_uint(hi: BigDigit, lo: BigDigit) -> uint {
 */
 #[deriving(Clone)]
 pub struct BigUint {
-    priv data: ~[BigDigit]
+    priv data: Vec<BigDigit>
 }
 
 impl Eq for BigUint {
@@ -140,37 +142,28 @@ impl Num for BigUint {}
 
 impl BitAnd<BigUint, BigUint> for BigUint {
     fn bitand(&self, other: &BigUint) -> BigUint {
-        let new_len = cmp::min(self.data.len(), other.data.len());
-        let anded = vec::from_fn(new_len, |i| {
-            // i will never be less than the size of either data vector
-            let ai = self.data[i];
-            let bi = other.data[i];
-            ai & bi
-        });
-        return BigUint::new(anded);
+        BigUint::new(self.data.iter().zip(other.data.iter()).map(|(ai, bi)| *ai & *bi).collect())
     }
 }
 
 impl BitOr<BigUint, BigUint> for BigUint {
     fn bitor(&self, other: &BigUint) -> BigUint {
-        let new_len = cmp::max(self.data.len(), other.data.len());
-        let ored = vec::from_fn(new_len, |i| {
-            let ai = if i < self.data.len()  { self.data[i]  } else { 0 };
-            let bi = if i < other.data.len() { other.data[i] } else { 0 };
-            ai | bi
-        });
+        let zeros = ZERO_VEC.iter().cycle();
+        let (a, b) = if self.data.len() > other.data.len() { (self, other) } else { (other, self) };
+        let ored = a.data.iter().zip(b.data.iter().chain(zeros)).map(
+            |(ai, bi)| *ai | *bi
+        ).collect();
         return BigUint::new(ored);
     }
 }
 
 impl BitXor<BigUint, BigUint> for BigUint {
     fn bitxor(&self, other: &BigUint) -> BigUint {
-        let new_len = cmp::max(self.data.len(), other.data.len());
-        let xored = vec::from_fn(new_len, |i| {
-            let ai = if i < self.data.len()  { self.data[i]  } else { 0 };
-            let bi = if i < other.data.len() { other.data[i] } else { 0 };
-            ai ^ bi
-        });
+        let zeros = ZERO_VEC.iter().cycle();
+        let (a, b) = if self.data.len() > other.data.len() { (self, other) } else { (other, self) };
+        let xored = a.data.iter().zip(b.data.iter().chain(zeros)).map(
+            |(ai, bi)| *ai ^ *bi
+        ).collect();
         return BigUint::new(xored);
     }
 }
@@ -195,7 +188,7 @@ fn shr(&self, rhs: &uint) -> BigUint {
 
 impl Zero for BigUint {
     #[inline]
-    fn zero() -> BigUint { BigUint::new(~[]) }
+    fn zero() -> BigUint { BigUint::new(Vec::new()) }
 
     #[inline]
     fn is_zero(&self) -> bool { self.data.is_empty() }
@@ -203,25 +196,22 @@ fn is_zero(&self) -> bool { self.data.is_empty() }
 
 impl One for BigUint {
     #[inline]
-    fn one() -> BigUint { BigUint::new(~[1]) }
+    fn one() -> BigUint { BigUint::new(vec!(1)) }
 }
 
 impl Unsigned for BigUint {}
 
 impl Add<BigUint, BigUint> for BigUint {
     fn add(&self, other: &BigUint) -> BigUint {
-        let new_len = cmp::max(self.data.len(), other.data.len());
+        let zeros = ZERO_VEC.iter().cycle();
+        let (a, b) = if self.data.len() > other.data.len() { (self, other) } else { (other, self) };
 
         let mut carry = 0;
-        let mut sum = vec::from_fn(new_len, |i| {
-            let ai = if i < self.data.len()  { self.data[i]  } else { 0 };
-            let bi = if i < other.data.len() { other.data[i] } else { 0 };
-            let (hi, lo) = BigDigit::from_uint(
-                (ai as uint) + (bi as uint) + (carry as uint)
-            );
+        let mut sum: Vec<BigDigit> =  a.data.iter().zip(b.data.iter().chain(zeros)).map(|(ai, bi)| {
+            let (hi, lo) = BigDigit::from_uint((*ai as uint) + (*bi as uint) + (carry as uint));
             carry = hi;
             lo
-        });
+        }).collect();
         if carry != 0 { sum.push(carry); }
         return BigUint::new(sum);
     }
@@ -230,14 +220,13 @@ fn add(&self, other: &BigUint) -> BigUint {
 impl Sub<BigUint, BigUint> for BigUint {
     fn sub(&self, other: &BigUint) -> BigUint {
         let new_len = cmp::max(self.data.len(), other.data.len());
+        let zeros = ZERO_VEC.iter().cycle();
+        let (a, b) = (self.data.iter().chain(zeros.clone()), other.data.iter().chain(zeros));
 
         let mut borrow = 0;
-        let diff = vec::from_fn(new_len, |i| {
-            let ai = if i < self.data.len()  { self.data[i]  } else { 0 };
-            let bi = if i < other.data.len() { other.data[i] } else { 0 };
+        let diff: Vec<BigDigit> =  a.take(new_len).zip(b).map(|(ai, bi)| {
             let (hi, lo) = BigDigit::from_uint(
-                (BigDigit::base) +
-                (ai as uint) - (bi as uint) - (borrow as uint)
+                BigDigit::base + (*ai as uint) - (*bi as uint) - (borrow as uint)
             );
             /*
             hi * (base) + lo == 1*(base) + ai - bi - borrow
@@ -245,7 +234,7 @@ fn sub(&self, other: &BigUint) -> BigUint {
             */
             borrow = if hi == 0 { 1 } else { 0 };
             lo
-        });
+        }).collect();
 
         assert_eq!(borrow, 0);     // <=> assert!((self >= other));
         return BigUint::new(diff);
@@ -257,8 +246,8 @@ fn mul(&self, other: &BigUint) -> BigUint {
         if self.is_zero() || other.is_zero() { return Zero::zero(); }
 
         let (s_len, o_len) = (self.data.len(), other.data.len());
-        if s_len == 1 { return mul_digit(other, self.data[0]);  }
-        if o_len == 1 { return mul_digit(self,  other.data[0]); }
+        if s_len == 1 { return mul_digit(other, self.data.as_slice()[0]);  }
+        if o_len == 1 { return mul_digit(self,  other.data.as_slice()[0]); }
 
         // Using Karatsuba multiplication
         // (a1 * base + a0) * (b1 * base + b0)
@@ -289,13 +278,13 @@ fn mul_digit(a: &BigUint, n: BigDigit) -> BigUint {
             if n == 1 { return (*a).clone(); }
 
             let mut carry = 0;
-            let mut prod = a.data.iter().map(|ai| {
+            let mut prod: Vec<BigDigit> = a.data.iter().map(|ai| {
                 let (hi, lo) = BigDigit::from_uint(
                     (*ai as uint) * (n as uint) + (carry as uint)
                 );
                 carry = hi;
                 lo
-            }).collect::<~[BigDigit]>();
+            }).collect();
             if carry != 0 { prod.push(carry); }
             return BigUint::new(prod);
         }
@@ -451,24 +440,25 @@ fn div_estimate(a: &BigUint, b: &BigUint, n: uint)
                 return (Zero::zero(), Zero::zero(), (*a).clone());
             }
 
-            let an = a.data.slice(a.data.len() - n, a.data.len());
+            let an = a.data.tailn(a.data.len() - n);
             let bn = *b.data.last().unwrap();
-            let mut d = ~[];
+            let mut d = Vec::with_capacity(an.len());
             let mut carry = 0;
             for elt in an.rev_iter() {
                 let ai = BigDigit::to_uint(carry, *elt);
                 let di = ai / (bn as uint);
                 assert!(di < BigDigit::base);
                 carry = (ai % (bn as uint)) as BigDigit;
-                d = ~[di as BigDigit] + d;
+                d.push(di as BigDigit)
             }
+            d.reverse();
 
             let shift = (a.data.len() - an.len()) - (b.data.len() - 1);
             if shift == 0 {
                 return (BigUint::new(d), One::one(), (*b).clone());
             }
             let one: BigUint = One::one();
-            return (BigUint::from_slice(d).shl_unit(shift),
+            return (BigUint::new(d).shl_unit(shift),
                     one.shl_unit(shift),
                     b.shl_unit(shift));
         }
@@ -506,10 +496,9 @@ fn divides(&self, other: &BigUint) -> bool { (*self % *other).is_zero() }
     #[inline]
     fn is_even(&self) -> bool {
         // Considering only the last digit.
-        if self.data.is_empty() {
-            true
-        } else {
-            self.data[0].is_even()
+        match self.data.as_slice().head() {
+            Some(x) => x.is_even(),
+            None => true
         }
     }
 
@@ -536,20 +525,20 @@ fn to_i64(&self) -> Option<i64> {
     fn to_u64(&self) -> Option<u64> {
         match self.data.len() {
             0 => Some(0),
-            1 => Some(self.data[0] as u64),
+            1 => Some(self.data.as_slice()[0] as u64),
             2 => {
-                Some(BigDigit::to_uint(self.data[1], self.data[0]) as u64)
+                Some(BigDigit::to_uint(self.data.as_slice()[1], self.data.as_slice()[0]) as u64)
             }
             3 => {
-                let n_lo = BigDigit::to_uint(self.data[1], self.data[0]) as
+                let n_lo = BigDigit::to_uint(self.data.as_slice()[1], self.data.as_slice()[0]) as
                     u64;
-                let n_hi = self.data[2] as u64;
+                let n_hi = self.data.as_slice()[2] as u64;
                 Some((n_hi << 32) + n_lo)
             }
             4 => {
-                let n_lo = BigDigit::to_uint(self.data[1], self.data[0])
+                let n_lo = BigDigit::to_uint(self.data.as_slice()[1], self.data.as_slice()[0])
                     as u64;
-                let n_hi = BigDigit::to_uint(self.data[3], self.data[2])
+                let n_hi = BigDigit::to_uint(self.data.as_slice()[3], self.data.as_slice()[2])
                     as u64;
                 Some((n_hi << 32) + n_lo)
             }
@@ -562,8 +551,8 @@ fn to_u64(&self) -> Option<u64> {
     fn to_u64(&self) -> Option<u64> {
         match self.data.len() {
             0 => Some(0),
-            1 => Some(self.data[0] as u64),
-            2 => Some(BigDigit::to_uint(self.data[1], self.data[0]) as u64),
+            1 => Some(self.data.as_slice()[0] as u64),
+            2 => Some(BigDigit::to_uint(self.data.as_slice()[1], self.data.as_slice()[0]) as u64),
             _ => None
         }
     }
@@ -589,10 +578,10 @@ fn from_u64(n: u64) -> Option<BigUint> {
 
         let n = match (BigDigit::from_uint(n_hi), BigDigit::from_uint(n_lo)) {
             ((0,  0),  (0,  0))  => Zero::zero(),
-            ((0,  0),  (0,  n0)) => BigUint::new(~[n0]),
-            ((0,  0),  (n1, n0)) => BigUint::new(~[n0, n1]),
-            ((0,  n2), (n1, n0)) => BigUint::new(~[n0, n1, n2]),
-            ((n3, n2), (n1, n0)) => BigUint::new(~[n0, n1, n2, n3]),
+            ((0,  0),  (0,  n0)) => BigUint::new(vec!(n0)),
+            ((0,  0),  (n1, n0)) => BigUint::new(vec!(n0, n1)),
+            ((0,  n2), (n1, n0)) => BigUint::new(vec!(n0, n1, n2)),
+            ((n3, n2), (n1, n0)) => BigUint::new(vec!(n0, n1, n2, n3)),
         };
         Some(n)
     }
@@ -602,8 +591,8 @@ fn from_u64(n: u64) -> Option<BigUint> {
     fn from_u64(n: u64) -> Option<BigUint> {
         let n = match BigDigit::from_uint(n as uint) {
             (0,  0)  => Zero::zero(),
-            (0,  n0) => BigUint::new(~[n0]),
-            (n1, n0) => BigUint::new(~[n0, n1])
+            (0,  n0) => BigUint::new(vec!(n0)),
+            (n1, n0) => BigUint::new(vec!(n0, n1))
         };
         Some(n)
     }
@@ -662,14 +651,14 @@ fn to_str_radix(&self, radix: uint) -> ~str {
         assert!(1 < radix && radix <= 16);
         let (base, max_len) = get_radix_base(radix);
         if base == BigDigit::base {
-            return fill_concat(self.data, radix, max_len)
+            return fill_concat(self.data.as_slice(), radix, max_len)
         }
-        return fill_concat(convert_base((*self).clone(), base), radix, max_len);
+        return fill_concat(convert_base(self, base).as_slice(), radix, max_len);
 
-        fn convert_base(n: BigUint, base: uint) -> ~[BigDigit] {
+        fn convert_base(n: &BigUint, base: uint) -> Vec<BigDigit> {
             let divider    = FromPrimitive::from_uint(base).unwrap();
-            let mut result = ~[];
-            let mut m      = n;
+            let mut result = Vec::new();
+            let mut m      = n.clone();
             while m >= divider {
                 let (d, m0) = m.div_mod_floor(&divider);
                 result.push(m0.to_uint().unwrap() as BigDigit);
@@ -706,7 +695,7 @@ fn from_str_radix(s: &str, radix: uint)
 impl BigUint {
     /// Creates and initializes a `BigUint`.
     #[inline]
-    pub fn new(v: ~[BigDigit]) -> BigUint {
+    pub fn new(v: Vec<BigDigit>) -> BigUint {
         // omit trailing zeros
         let new_len = v.iter().rposition(|n| *n != 0).map_or(0, |p| p + 1);
 
@@ -719,7 +708,7 @@ pub fn new(v: ~[BigDigit]) -> BigUint {
     /// Creates and initializes a `BigUint`.
     #[inline]
     pub fn from_slice(slice: &[BigDigit]) -> BigUint {
-        return BigUint::new(slice.to_owned());
+        return BigUint::new(Vec::from_slice(slice));
     }
 
     /// Creates and initializes a `BigUint`.
@@ -764,8 +753,8 @@ pub fn parse_bytes(buf: &[u8], radix: uint) -> Option<BigUint> {
     fn shl_unit(&self, n_unit: uint) -> BigUint {
         if n_unit == 0 || self.is_zero() { return (*self).clone(); }
 
-        return BigUint::new(vec::from_elem(n_unit, ZERO_BIG_DIGIT)
-                            + self.data);
+        return BigUint::new(vec_ng::append(Vec::from_elem(n_unit, ZERO_BIG_DIGIT),
+                                           self.data.as_slice()));
     }
 
     #[inline]
@@ -773,13 +762,13 @@ fn shl_bits(&self, n_bits: uint) -> BigUint {
         if n_bits == 0 || self.is_zero() { return (*self).clone(); }
 
         let mut carry = 0;
-        let mut shifted = self.data.iter().map(|elem| {
+        let mut shifted: Vec<BigDigit> = self.data.iter().map(|elem| {
             let (hi, lo) = BigDigit::from_uint(
                 (*elem as uint) << n_bits | (carry as uint)
             );
             carry = hi;
             lo
-        }).collect::<~[BigDigit]>();
+        }).collect();
         if carry != 0 { shifted.push(carry); }
         return BigUint::new(shifted);
     }
@@ -798,7 +787,7 @@ fn shr_bits(&self, n_bits: uint) -> BigUint {
         if n_bits == 0 || self.data.is_empty() { return (*self).clone(); }
 
         let mut borrow = 0;
-        let mut shifted_rev = vec::with_capacity(self.data.len());
+        let mut shifted_rev = Vec::with_capacity(self.data.len());
         for elem in self.data.rev_iter() {
             shifted_rev.push((*elem >> n_bits) | borrow);
             borrow = *elem << (BigDigit::bits - n_bits);
@@ -1351,7 +1340,7 @@ pub trait RandBigInt {
 impl<R: Rng> RandBigInt for R {
     fn gen_biguint(&mut self, bit_size: uint) -> BigUint {
         let (digits, rem) = bit_size.div_rem(&BigDigit::bits);
-        let mut data = vec::with_capacity(digits+1);
+        let mut data = Vec::with_capacity(digits+1);
         for _ in range(0, digits) {
             data.push(self.gen());
         }
@@ -1414,7 +1403,7 @@ fn gen_bigint_range(&mut self,
 impl BigInt {
     /// Creates and initializes a BigInt.
     #[inline]
-    pub fn new(sign: Sign, v: ~[BigDigit]) -> BigInt {
+    pub fn new(sign: Sign, v: Vec<BigDigit>) -> BigInt {
         BigInt::from_biguint(sign, BigUint::new(v))
     }
 
@@ -1471,14 +1460,13 @@ mod biguint_tests {
     use std::num::{ToPrimitive, FromPrimitive};
     use std::num::CheckedDiv;
     use rand::{task_rng};
-    use std::str;
     use std::u64;
-    use std::vec;
+    use std::vec_ng::Vec;
 
     #[test]
     fn test_from_slice() {
         fn check(slice: &[BigDigit], data: &[BigDigit]) {
-            assert!(data == BigUint::from_slice(slice).data);
+            assert!(data == BigUint::from_slice(slice).data.as_slice());
         }
         check([1], [1]);
         check([0, 0, 0], []);
@@ -1490,8 +1478,8 @@ fn check(slice: &[BigDigit], data: &[BigDigit]) {
 
     #[test]
     fn test_cmp() {
-        let data: ~[BigUint] = [ &[], &[1], &[2], &[-1], &[0, 1], &[2, 1], &[1, 1, 1]  ]
-            .map(|v| BigUint::from_slice(*v));
+        let data: Vec<BigUint> = [ &[], &[1], &[2], &[-1], &[0, 1], &[2, 1], &[1, 1, 1]  ]
+            .iter().map(|v| BigUint::from_slice(*v)).collect();
         for (i, ni) in data.iter().enumerate() {
             for (j0, nj) in data.slice(i, data.len()).iter().enumerate() {
                 let j = j0 + i;
@@ -1527,44 +1515,44 @@ fn test_cmp() {
 
     #[test]
     fn test_bitand() {
-        fn check(left: ~[BigDigit],
-                 right: ~[BigDigit],
-                 expected: ~[BigDigit]) {
-            assert_eq!(BigUint::new(left) & BigUint::new(right),
-                       BigUint::new(expected));
+        fn check(left: &[BigDigit],
+                 right: &[BigDigit],
+                 expected: &[BigDigit]) {
+            assert_eq!(BigUint::from_slice(left) & BigUint::from_slice(right),
+                       BigUint::from_slice(expected));
         }
-        check(~[], ~[], ~[]);
-        check(~[268, 482, 17],
-              ~[964, 54],
-              ~[260, 34]);
+        check([], [], []);
+        check([268, 482, 17],
+              [964, 54],
+              [260, 34]);
     }
 
     #[test]
     fn test_bitor() {
-        fn check(left: ~[BigDigit],
-                 right: ~[BigDigit],
-                 expected: ~[BigDigit]) {
-            assert_eq!(BigUint::new(left) | BigUint::new(right),
-                       BigUint::new(expected));
+        fn check(left: &[BigDigit],
+                 right: &[BigDigit],
+                 expected: &[BigDigit]) {
+            assert_eq!(BigUint::from_slice(left) | BigUint::from_slice(right),
+                       BigUint::from_slice(expected));
         }
-        check(~[], ~[], ~[]);
-        check(~[268, 482, 17],
-              ~[964, 54],
-              ~[972, 502, 17]);
+        check([], [], []);
+        check([268, 482, 17],
+              [964, 54],
+              [972, 502, 17]);
     }
 
     #[test]
     fn test_bitxor() {
-        fn check(left: ~[BigDigit],
-                 right: ~[BigDigit],
-                 expected: ~[BigDigit]) {
-            assert_eq!(BigUint::new(left) ^ BigUint::new(right),
-                       BigUint::new(expected));
+        fn check(left: &[BigDigit],
+                 right: &[BigDigit],
+                 expected: &[BigDigit]) {
+            assert_eq!(BigUint::from_slice(left) ^ BigUint::from_slice(right),
+                       BigUint::from_slice(expected));
         }
-        check(~[], ~[], ~[]);
-        check(~[268, 482, 17],
-              ~[964, 54],
-              ~[712, 468, 17]);
+        check([], [], []);
+        check([268, 482, 17],
+              [964, 54],
+              [712, 468, 17]);
     }
 
     #[test]
@@ -1657,20 +1645,20 @@ fn check(b1: BigUint, i: i64) {
         check(One::one(), 1);
         check(i64::MAX.to_biguint().unwrap(), i64::MAX);
 
-        check(BigUint::new(~[                   ]), 0);
-        check(BigUint::new(~[ 1                 ]), (1 << (0*BigDigit::bits)));
-        check(BigUint::new(~[-1                 ]), (1 << (1*BigDigit::bits)) - 1);
-        check(BigUint::new(~[ 0,  1             ]), (1 << (1*BigDigit::bits)));
-        check(BigUint::new(~[-1, -1             ]), (1 << (2*BigDigit::bits)) - 1);
-        check(BigUint::new(~[ 0,  0,  1         ]), (1 << (2*BigDigit::bits)));
-        check(BigUint::new(~[-1, -1, -1         ]), (1 << (3*BigDigit::bits)) - 1);
-        check(BigUint::new(~[ 0,  0,  0,  1     ]), (1 << (3*BigDigit::bits)));
-        check(BigUint::new(~[-1, -1, -1, -1 >> 1]), i64::MAX);
+        check(BigUint::new(vec!(                   )), 0);
+        check(BigUint::new(vec!( 1                 )), (1 << (0*BigDigit::bits)));
+        check(BigUint::new(vec!(-1                 )), (1 << (1*BigDigit::bits)) - 1);
+        check(BigUint::new(vec!( 0,  1             )), (1 << (1*BigDigit::bits)));
+        check(BigUint::new(vec!(-1, -1             )), (1 << (2*BigDigit::bits)) - 1);
+        check(BigUint::new(vec!( 0,  0,  1         )), (1 << (2*BigDigit::bits)));
+        check(BigUint::new(vec!(-1, -1, -1         )), (1 << (3*BigDigit::bits)) - 1);
+        check(BigUint::new(vec!( 0,  0,  0,  1     )), (1 << (3*BigDigit::bits)));
+        check(BigUint::new(vec!(-1, -1, -1, -1 >> 1)), i64::MAX);
 
         assert_eq!(i64::MIN.to_biguint(), None);
-        assert_eq!(BigUint::new(~[-1, -1, -1, -1    ]).to_i64(), None);
-        assert_eq!(BigUint::new(~[ 0,  0,  0,  0,  1]).to_i64(), None);
-        assert_eq!(BigUint::new(~[-1, -1, -1, -1, -1]).to_i64(), None);
+        assert_eq!(BigUint::new(vec!(-1, -1, -1, -1    )).to_i64(), None);
+        assert_eq!(BigUint::new(vec!( 0,  0,  0,  0,  1)).to_i64(), None);
+        assert_eq!(BigUint::new(vec!(-1, -1, -1, -1, -1)).to_i64(), None);
     }
 
     #[cfg(target_word_size = "64")]
@@ -1686,16 +1674,16 @@ fn check(b1: BigUint, i: i64) {
         check(One::one(), 1);
         check(i64::MAX.to_biguint().unwrap(), i64::MAX);
 
-        check(BigUint::new(~[           ]), 0);
-        check(BigUint::new(~[ 1         ]), (1 << (0*BigDigit::bits)));
-        check(BigUint::new(~[-1         ]), (1 << (1*BigDigit::bits)) - 1);
-        check(BigUint::new(~[ 0,  1     ]), (1 << (1*BigDigit::bits)));
-        check(BigUint::new(~[-1, -1 >> 1]), i64::MAX);
+        check(BigUint::new(vec!(           )), 0);
+        check(BigUint::new(vec!( 1         )), (1 << (0*BigDigit::bits)));
+        check(BigUint::new(vec!(-1         )), (1 << (1*BigDigit::bits)) - 1);
+        check(BigUint::new(vec!( 0,  1     )), (1 << (1*BigDigit::bits)));
+        check(BigUint::new(vec!(-1, -1 >> 1)), i64::MAX);
 
         assert_eq!(i64::MIN.to_biguint(), None);
-        assert_eq!(BigUint::new(~[-1, -1    ]).to_i64(), None);
-        assert_eq!(BigUint::new(~[ 0,  0,  1]).to_i64(), None);
-        assert_eq!(BigUint::new(~[-1, -1, -1]).to_i64(), None);
+        assert_eq!(BigUint::new(vec!(-1, -1    )).to_i64(), None);
+        assert_eq!(BigUint::new(vec!( 0,  0,  1)).to_i64(), None);
+        assert_eq!(BigUint::new(vec!(-1, -1, -1)).to_i64(), None);
     }
 
     #[cfg(target_word_size = "32")]
@@ -1712,18 +1700,18 @@ fn check(b1: BigUint, u: u64) {
         check(u64::MIN.to_biguint().unwrap(), u64::MIN);
         check(u64::MAX.to_biguint().unwrap(), u64::MAX);
 
-        check(BigUint::new(~[              ]), 0);
-        check(BigUint::new(~[ 1            ]), (1 << (0*BigDigit::bits)));
-        check(BigUint::new(~[-1            ]), (1 << (1*BigDigit::bits)) - 1);
-        check(BigUint::new(~[ 0,  1        ]), (1 << (1*BigDigit::bits)));
-        check(BigUint::new(~[-1, -1        ]), (1 << (2*BigDigit::bits)) - 1);
-        check(BigUint::new(~[ 0,  0,  1    ]), (1 << (2*BigDigit::bits)));
-        check(BigUint::new(~[-1, -1, -1    ]), (1 << (3*BigDigit::bits)) - 1);
-        check(BigUint::new(~[ 0,  0,  0,  1]), (1 << (3*BigDigit::bits)));
-        check(BigUint::new(~[-1, -1, -1, -1]), u64::MAX);
+        check(BigUint::new(vec!(              )), 0);
+        check(BigUint::new(vec!( 1            )), (1 << (0*BigDigit::bits)));
+        check(BigUint::new(vec!(-1            )), (1 << (1*BigDigit::bits)) - 1);
+        check(BigUint::new(vec!( 0,  1        )), (1 << (1*BigDigit::bits)));
+        check(BigUint::new(vec!(-1, -1        )), (1 << (2*BigDigit::bits)) - 1);
+        check(BigUint::new(vec!( 0,  0,  1    )), (1 << (2*BigDigit::bits)));
+        check(BigUint::new(vec!(-1, -1, -1    )), (1 << (3*BigDigit::bits)) - 1);
+        check(BigUint::new(vec!( 0,  0,  0,  1)), (1 << (3*BigDigit::bits)));
+        check(BigUint::new(vec!(-1, -1, -1, -1)), u64::MAX);
 
-        assert_eq!(BigUint::new(~[ 0,  0,  0,  0,  1]).to_u64(), None);
-        assert_eq!(BigUint::new(~[-1, -1, -1, -1, -1]).to_u64(), None);
+        assert_eq!(BigUint::new(vec!( 0,  0,  0,  0,  1)).to_u64(), None);
+        assert_eq!(BigUint::new(vec!(-1, -1, -1, -1, -1)).to_u64(), None);
     }
 
     #[cfg(target_word_size = "64")]
@@ -1740,14 +1728,14 @@ fn check(b1: BigUint, u: u64) {
         check(u64::MIN.to_biguint().unwrap(), u64::MIN);
         check(u64::MAX.to_biguint().unwrap(), u64::MAX);
 
-        check(BigUint::new(~[      ]), 0);
-        check(BigUint::new(~[ 1    ]), (1 << (0*BigDigit::bits)));
-        check(BigUint::new(~[-1    ]), (1 << (1*BigDigit::bits)) - 1);
-        check(BigUint::new(~[ 0,  1]), (1 << (1*BigDigit::bits)));
-        check(BigUint::new(~[-1, -1]), u64::MAX);
+        check(BigUint::new(vec!(      )), 0);
+        check(BigUint::new(vec!( 1    )), (1 << (0*BigDigit::bits)));
+        check(BigUint::new(vec!(-1    )), (1 << (1*BigDigit::bits)) - 1);
+        check(BigUint::new(vec!( 0,  1)), (1 << (1*BigDigit::bits)));
+        check(BigUint::new(vec!(-1, -1)), u64::MAX);
 
-        assert_eq!(BigUint::new(~[ 0,  0,  1]).to_u64(), None);
-        assert_eq!(BigUint::new(~[-1, -1, -1]).to_u64(), None);
+        assert_eq!(BigUint::new(vec!( 0,  0,  1)).to_u64(), None);
+        assert_eq!(BigUint::new(vec!(-1, -1, -1)).to_u64(), None);
     }
 
     #[test]
@@ -1757,8 +1745,8 @@ fn check(n: BigUint, ans: BigInt) {
             assert_eq!(n.to_bigint().unwrap().to_biguint().unwrap(), n);
         }
         check(Zero::zero(), Zero::zero());
-        check(BigUint::new(~[1,2,3]),
-              BigInt::from_biguint(Plus, BigUint::new(~[1,2,3])));
+        check(BigUint::new(vec!(1,2,3)),
+              BigInt::from_biguint(Plus, BigUint::new(vec!(1,2,3))));
     }
 
     static sum_triples: &'static [(&'static [BigDigit],
@@ -2017,11 +2005,11 @@ fn test_is_even() {
         assert!(((one << 64) + one).is_odd());
     }
 
-    fn to_str_pairs() -> ~[ (BigUint, ~[(uint, ~str)]) ] {
+    fn to_str_pairs() -> Vec<(BigUint, Vec<(uint, ~str)>)> {
         let bits = BigDigit::bits;
-        ~[( Zero::zero(), ~[
+        vec!(( Zero::zero(), vec!(
             (2, ~"0"), (3, ~"0")
-        ]), ( BigUint::from_slice([ 0xff ]), ~[
+        )), ( BigUint::from_slice([ 0xff ]), vec!(
             (2,  ~"11111111"),
             (3,  ~"100110"),
             (4,  ~"3333"),
@@ -2037,41 +2025,41 @@ fn to_str_pairs() -> ~[ (BigUint, ~[(uint, ~str)]) ] {
             (14, ~"143"),
             (15, ~"120"),
             (16, ~"ff")
-        ]), ( BigUint::from_slice([ 0xfff ]), ~[
+        )), ( BigUint::from_slice([ 0xfff ]), vec!(
             (2,  ~"111111111111"),
             (4,  ~"333333"),
             (16, ~"fff")
-        ]), ( BigUint::from_slice([ 1, 2 ]), ~[
+        )), ( BigUint::from_slice([ 1, 2 ]), vec!(
             (2,
              ~"10" +
-             str::from_chars(vec::from_elem(bits - 1, '0')) + "1"),
+             "0".repeat(bits - 1) + "1"),
             (4,
              ~"2" +
-             str::from_chars(vec::from_elem(bits / 2 - 1, '0')) + "1"),
+             "0".repeat(bits / 2 - 1) + "1"),
             (10, match bits {
                 32 => ~"8589934593", 16 => ~"131073", _ => fail!()
             }),
             (16,
              ~"2" +
-             str::from_chars(vec::from_elem(bits / 4 - 1, '0')) + "1")
-        ]), ( BigUint::from_slice([ 1, 2, 3 ]), ~[
+             "0".repeat(bits / 4 - 1) + "1")
+        )), ( BigUint::from_slice([ 1, 2, 3 ]), vec!(
             (2,
              ~"11" +
-             str::from_chars(vec::from_elem(bits - 2, '0')) + "10" +
-             str::from_chars(vec::from_elem(bits - 1, '0')) + "1"),
+             "0".repeat(bits - 2) + "10" +
+             "0".repeat(bits - 1) + "1"),
             (4,
              ~"3" +
-             str::from_chars(vec::from_elem(bits / 2 - 1, '0')) + "2" +
-             str::from_chars(vec::from_elem(bits / 2 - 1, '0')) + "1"),
+             "0".repeat(bits / 2 - 1) + "2" +
+             "0".repeat(bits / 2 - 1) + "1"),
             (10, match bits {
                 32 => ~"55340232229718589441",
                 16 => ~"12885032961",
                 _ => fail!()
             }),
             (16, ~"3" +
-             str::from_chars(vec::from_elem(bits / 4 - 1, '0')) + "2" +
-             str::from_chars(vec::from_elem(bits / 4 - 1, '0')) + "1")
-        ]) ]
+             "0".repeat(bits / 4 - 1) + "2" +
+             "0".repeat(bits / 4 - 1) + "1")
+        )) )
     }
 
     #[test]
@@ -2134,7 +2122,7 @@ fn check(n: uint, s: &str) {
 
     #[test]
     fn test_bits() {
-        assert_eq!(BigUint::new(~[0,0,0,0]).bits(), 0);
+        assert_eq!(BigUint::new(vec!(0,0,0,0)).bits(), 0);
         let n: BigUint = FromPrimitive::from_uint(0).unwrap();
         assert_eq!(n.bits(), 0);
         let n: BigUint = FromPrimitive::from_uint(1).unwrap();
@@ -2207,6 +2195,7 @@ mod bigint_tests {
     use std::num::{ToPrimitive, FromPrimitive};
     use rand::{task_rng};
     use std::u64;
+    use std::vec_ng::Vec;
 
     #[test]
     fn test_from_biguint() {
@@ -2224,12 +2213,12 @@ fn check(inp_s: Sign, inp_n: uint, ans_s: Sign, ans_n: uint) {
     #[test]
     fn test_cmp() {
         let vs = [ &[2 as BigDigit], &[1, 1], &[2, 1], &[1, 1, 1] ];
-        let mut nums = ~[];
+        let mut nums = Vec::new();
         for s in vs.rev_iter() {
             nums.push(BigInt::from_slice(Minus, *s));
         }
         nums.push(Zero::zero());
-        nums.push_all_move(vs.map(|s| BigInt::from_slice(Plus, *s)));
+        nums.extend(&mut vs.iter().map(|s| BigInt::from_slice(Plus, *s)));
 
         for (i, ni) in nums.iter().enumerate() {
             for (j0, nj) in nums.slice(i, nums.len()).iter().enumerate() {
@@ -2282,15 +2271,15 @@ fn check(b1: BigInt, i: i64) {
             None);
 
         assert_eq!(
-            BigInt::from_biguint(Plus,  BigUint::new(~[1, 2, 3, 4, 5])).to_i64(),
+            BigInt::from_biguint(Plus,  BigUint::new(vec!(1, 2, 3, 4, 5))).to_i64(),
             None);
 
         assert_eq!(
-            BigInt::from_biguint(Minus, BigUint::new(~[1, 0, 0, 1<<(BigDigit::bits-1)])).to_i64(),
+            BigInt::from_biguint(Minus, BigUint::new(vec!(1,0,0,1<<(BigDigit::bits-1)))).to_i64(),
             None);
 
         assert_eq!(
-            BigInt::from_biguint(Minus, BigUint::new(~[1, 2, 3, 4, 5])).to_i64(),
+            BigInt::from_biguint(Minus, BigUint::new(vec!(1, 2, 3, 4, 5))).to_i64(),
             None);
     }
 
@@ -2308,12 +2297,12 @@ fn check(b1: BigInt, u: u64) {
         check(u64::MAX.to_bigint().unwrap(), u64::MAX);
 
         assert_eq!(
-            BigInt::from_biguint(Plus, BigUint::new(~[1, 2, 3, 4, 5])).to_u64(),
+            BigInt::from_biguint(Plus, BigUint::new(vec!(1, 2, 3, 4, 5))).to_u64(),
             None);
 
         let max_value: BigUint = FromPrimitive::from_u64(u64::MAX).unwrap();
         assert_eq!(BigInt::from_biguint(Minus, max_value).to_u64(), None);
-        assert_eq!(BigInt::from_biguint(Minus, BigUint::new(~[1, 2, 3, 4, 5])).to_u64(), None);
+        assert_eq!(BigInt::from_biguint(Minus, BigUint::new(vec!(1, 2, 3, 4, 5))).to_u64(), None);
     }
 
     #[test]
@@ -2325,11 +2314,11 @@ fn check(n: BigInt, ans_1: BigUint) {
         let zero: BigInt = Zero::zero();
         let unsigned_zero: BigUint = Zero::zero();
         let positive = BigInt::from_biguint(
-            Plus, BigUint::new(~[1,2,3]));
+            Plus, BigUint::new(vec!(1,2,3)));
         let negative = -positive;
 
         check(zero, unsigned_zero);
-        check(positive, BigUint::new(~[1,2,3]));
+        check(positive, BigUint::new(vec!(1,2,3)));
 
         assert_eq!(negative.to_biguint(), None);
     }
@@ -2727,10 +2716,10 @@ fn check(s: &str, ans: Option<int>) {
 
     #[test]
     fn test_neg() {
-        assert!(-BigInt::new(Plus,  ~[1, 1, 1]) ==
-            BigInt::new(Minus, ~[1, 1, 1]));
-        assert!(-BigInt::new(Minus, ~[1, 1, 1]) ==
-            BigInt::new(Plus,  ~[1, 1, 1]));
+        assert!(-BigInt::new(Plus,  vec!(1, 1, 1)) ==
+            BigInt::new(Minus, vec!(1, 1, 1)));
+        assert!(-BigInt::new(Minus, vec!(1, 1, 1)) ==
+            BigInt::new(Plus,  vec!(1, 1, 1)));
         let zero: BigInt = Zero::zero();
         assert_eq!(-zero, zero);
     }
index 8ff042ba3621ca94e3850d23349fc1f5805f9913..05b94af9b8c7fb7a3a441bb5ae2af3deb577fd9e 100644 (file)
 #[crate_type = "rlib"];
 #[crate_type = "dylib"];
 #[license = "MIT/ASL2"];
+#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+      html_root_url = "http://static.rust-lang.org/doc/master")];
+#[allow(deprecated_owned_vector)];
 
 extern crate rand;
 
index 79ff54cb90c68d9222a55b7defea793dd6a8f4f1..6d0b6128f8872b7548d155a81eb38954ee143d6c 100644 (file)
@@ -16,6 +16,7 @@
 use std::fmt;
 use std::from_str::FromStr;
 use std::num::{Zero,One,ToStrRadix,FromStrRadix,Round};
+use std::vec_ng::Vec;
 use bigint::{BigInt, BigUint, Sign, Plus, Minus};
 
 /// Represents the ratio between 2 numbers.
@@ -295,13 +296,13 @@ impl<T: FromStr + Clone + Integer + Ord>
     FromStr for Ratio<T> {
     /// Parses `numer/denom`.
     fn from_str(s: &str) -> Option<Ratio<T>> {
-        let split: ~[&str] = s.splitn('/', 1).collect();
+        let split: Vec<&str> = s.splitn('/', 1).collect();
         if split.len() < 2 {
             return None
         }
-        let a_option: Option<T> = FromStr::from_str(split[0]);
+        let a_option: Option<T> = FromStr::from_str(split.as_slice()[0]);
         a_option.and_then(|a| {
-            let b_option: Option<T> = FromStr::from_str(split[1]);
+            let b_option: Option<T> = FromStr::from_str(split.as_slice()[1]);
             b_option.and_then(|b| {
                 Some(Ratio::new(a.clone(), b.clone()))
             })
@@ -312,15 +313,15 @@ impl<T: FromStrRadix + Clone + Integer + Ord>
     FromStrRadix for Ratio<T> {
     /// Parses `numer/denom` where the numbers are in base `radix`.
     fn from_str_radix(s: &str, radix: uint) -> Option<Ratio<T>> {
-        let split: ~[&str] = s.splitn('/', 1).collect();
+        let split: Vec<&str> = s.splitn('/', 1).collect();
         if split.len() < 2 {
             None
         } else {
-            let a_option: Option<T> = FromStrRadix::from_str_radix(split[0],
+            let a_option: Option<T> = FromStrRadix::from_str_radix(split.as_slice()[0],
                                                                    radix);
             a_option.and_then(|a| {
                 let b_option: Option<T> =
-                    FromStrRadix::from_str_radix(split[1], radix);
+                    FromStrRadix::from_str_radix(split.as_slice()[1], radix);
                 b_option.and_then(|b| {
                     Some(Ratio::new(a.clone(), b.clone()))
                 })
index 87a18497b8afd77ee5e082e0f4b7d2593b46fe00..dc4e3e50b653801f0c1c2fa3239cd9f87a758426 100644 (file)
       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
       html_root_url = "http://static.rust-lang.org/doc/master")];
 
-#[feature(macro_rules, managed_boxes)];
+#[feature(macro_rules, managed_boxes, phase)];
+#[allow(deprecated_owned_vector)];
+
+#[cfg(test)]
+#[phase(syntax, link)] extern crate log;
 
 use std::cast;
 use std::kinds::marker;
index d297df1301ea7983d281b99357de447f7fc159ed..a47b68600142e8406e91bcf099b09def6088be67 100644 (file)
 
 use std::cast;
 use std::vec_ng::Vec;
-use std::io::fs;
 use std::io;
+use std::io::{fs, TempDir};
 use std::libc;
 use std::os;
 use std::io::process::{ProcessConfig, Process, ProcessOutput};
 use std::str;
 use std::raw;
-use extra::tempfile::TempDir;
 use syntax::abi;
 
 pub static METADATA_FILENAME: &'static str = "rust.metadata.bin";
index c15c55927a9c8b6e14bbb9b2c99ceb7443525244..d68fa0ca24134b24f3fde08d040b6570020b53e4 100644 (file)
 use std::ptr;
 use std::str;
 use std::io;
-use std::io::Process;
-use std::io::fs;
+use std::io::{fs, TempDir, Process};
 use std::vec_ng::Vec;
 use flate;
 use serialize::hex::ToHex;
-use extra::tempfile::TempDir;
 use syntax::abi;
 use syntax::ast;
 use syntax::ast_map::{PathElem, PathElems, PathName};
@@ -503,10 +501,9 @@ unsafe fn populate_llvm_passes(fpm: lib::llvm::PassManagerRef,
  *    system linkers understand.
  */
 
-pub fn find_crate_id(attrs: &[ast::Attribute],
-                     output: &OutputFilenames) -> CrateId {
+pub fn find_crate_id(attrs: &[ast::Attribute], out_filestem: &str) -> CrateId {
     match attr::find_crateid(attrs) {
-        None => from_str(output.out_filestem).unwrap(),
+        None => from_str(out_filestem).unwrap(),
         Some(s) => s,
     }
 }
@@ -520,10 +517,9 @@ pub fn crate_id_hash(crate_id: &CrateId) -> ~str {
     truncated_hash_result(&mut s).slice_to(8).to_owned()
 }
 
-pub fn build_link_meta(krate: &ast::Crate,
-                       output: &OutputFilenames) -> LinkMeta {
+pub fn build_link_meta(krate: &ast::Crate, out_filestem: &str) -> LinkMeta {
     let r = LinkMeta {
-        crateid: find_crate_id(krate.attrs.as_slice(), output),
+        crateid: find_crate_id(krate.attrs.as_slice(), out_filestem),
         crate_hash: Svh::calculate(krate),
     };
     info!("{}", r);
@@ -1089,6 +1085,23 @@ fn link_args(sess: Session,
         ~"-o", out_filename.as_str().unwrap().to_owned(),
         obj_filename.as_str().unwrap().to_owned()]);
 
+    // Stack growth requires statically linking a __morestack function. Note
+    // that this is listed *before* all other libraries, even though it may be
+    // used to resolve symbols in other libraries. The only case that this
+    // wouldn't be pulled in by the object file is if the object file had no
+    // functions.
+    //
+    // If we're building an executable, there must be at least one function (the
+    // main function), and if we're building a dylib then we don't need it for
+    // later libraries because they're all dylibs (not rlibs).
+    //
+    // I'm honestly not entirely sure why this needs to come first. Apparently
+    // the --as-needed flag above sometimes strips out libstd from the command
+    // line, but inserting this farther to the left makes the
+    // "rust_stack_exhausted" symbol an outstanding undefined symbol, which
+    // flags libstd as a required library (or whatever provides the symbol).
+    args.push(~"-lmorestack");
+
     // When linking a dynamic library, we put the metadata into a section of the
     // executable. This metadata is in a separate object file from the main
     // object file, so we link that in here.
@@ -1204,11 +1217,13 @@ fn link_args(sess: Session,
         args.push_all(rpath::get_rpath_flags(sess, out_filename).as_slice());
     }
 
-    // Stack growth requires statically linking a __morestack function
-    args.push(~"-lmorestack");
-    // compiler-rt contains implementations of low-level LLVM helpers
-    // It should go before platform and user libraries, so it has first dibs
-    // at resolving symbols that also appear in libgcc.
+    // compiler-rt contains implementations of low-level LLVM helpers. This is
+    // used to resolve symbols from the object file we just created, as well as
+    // any system static libraries that may be expecting gcc instead. Most
+    // symbols in libgcc also appear in compiler-rt.
+    //
+    // This is the end of the command line, so this library is used to resolve
+    // *all* undefined symbols in all other libraries, and this is intentional.
     args.push(~"-lcompiler-rt");
 
     // Finally add all the linker arguments provided on the command line along
index bc24660e306732bb5c6ae1411d1407640861a336..0de256ba8d8e6fd977aea9a64825c4ebe0c51fa5 100644 (file)
@@ -22,7 +22,7 @@ pub fn get_target_strs(target_triple: ~str, target_os: abi::Os) -> target_strs::
 
         data_layout: match target_os {
           abi::OsMacos => {
-            ~"e-p:32:32:32" +
+            ~"E-p:32:32:32" +
                 "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
                 "-f32:32:32-f64:64:64" +
                 "-v64:64:64-v128:64:128" +
@@ -30,7 +30,7 @@ pub fn get_target_strs(target_triple: ~str, target_os: abi::Os) -> target_strs::
           }
 
           abi::OsWin32 => {
-            ~"e-p:32:32:32" +
+            ~"E-p:32:32:32" +
                 "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
                 "-f32:32:32-f64:64:64" +
                 "-v64:64:64-v128:64:128" +
@@ -38,7 +38,7 @@ pub fn get_target_strs(target_triple: ~str, target_os: abi::Os) -> target_strs::
           }
 
           abi::OsLinux => {
-            ~"e-p:32:32:32" +
+            ~"E-p:32:32:32" +
                 "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
                 "-f32:32:32-f64:64:64" +
                 "-v64:64:64-v128:64:128" +
@@ -46,7 +46,7 @@ pub fn get_target_strs(target_triple: ~str, target_os: abi::Os) -> target_strs::
           }
 
           abi::OsAndroid => {
-            ~"e-p:32:32:32" +
+            ~"E-p:32:32:32" +
                 "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
                 "-f32:32:32-f64:64:64" +
                 "-v64:64:64-v128:64:128" +
@@ -54,7 +54,7 @@ pub fn get_target_strs(target_triple: ~str, target_os: abi::Os) -> target_strs::
           }
 
           abi::OsFreebsd => {
-            ~"e-p:32:32:32" +
+            ~"E-p:32:32:32" +
                 "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
                 "-f32:32:32-f64:64:64" +
                 "-v64:64:64-v128:64:128" +
index 10b209c998bc1eac94d92bbebc70429356a17282..91425b89ba66988349ea13cc8fdbeef10c9bb049 100644 (file)
@@ -46,6 +46,7 @@
 use syntax::attr;
 use syntax::attr::{AttrMetaMethods};
 use syntax::codemap;
+use syntax::crateid::CrateId;
 use syntax::diagnostic;
 use syntax::diagnostic::Emitter;
 use syntax::ext::base::CrateLoader;
@@ -160,6 +161,15 @@ pub enum Input {
     StrInput(~str)
 }
 
+impl Input {
+    fn filestem(&self) -> ~str {
+        match *self {
+            FileInput(ref ifile) => ifile.filestem_str().unwrap().to_str(),
+            StrInput(_) => ~"rust_out",
+        }
+    }
+}
+
 pub fn phase_1_parse_input(sess: Session, cfg: ast::CrateConfig, input: &Input)
     -> ast::Crate {
     let krate = time(sess.time_passes(), "parsing", (), |_| {
@@ -182,6 +192,10 @@ pub fn phase_1_parse_input(sess: Session, cfg: ast::CrateConfig, input: &Input)
         krate.encode(&mut json);
     }
 
+    if sess.show_span() {
+        front::show_span::run(sess, &krate);
+    }
+
     krate
 }
 
@@ -194,7 +208,8 @@ pub fn phase_1_parse_input(sess: Session, cfg: ast::CrateConfig, input: &Input)
 /// standard library and prelude.
 pub fn phase_2_configure_and_expand(sess: Session,
                                     loader: &mut CrateLoader,
-                                    mut krate: ast::Crate)
+                                    mut krate: ast::Crate,
+                                    crate_id: &CrateId)
                                     -> (ast::Crate, syntax::ast_map::Map) {
     let time_passes = sess.time_passes();
 
@@ -223,7 +238,8 @@ pub fn phase_2_configure_and_expand(sess: Session,
     krate = time(time_passes, "expansion", krate, |krate| {
         let cfg = syntax::ext::expand::ExpansionConfig {
             loader: loader,
-            deriving_hash_type_parameter: sess.features.default_type_params.get()
+            deriving_hash_type_parameter: sess.features.default_type_params.get(),
+            crate_id: crate_id.clone(),
         };
         syntax::ext::expand::expand_crate(sess.parse_sess,
                                           cfg,
@@ -461,6 +477,9 @@ pub fn stop_after_phase_1(sess: Session) -> bool {
         debug!("invoked with --parse-only, returning early from compile_input");
         return true;
     }
+    if sess.show_span() {
+        return true;
+    }
     return sess.opts.debugging_opts & session::AST_JSON_NOEXPAND != 0;
 }
 
@@ -484,7 +503,7 @@ fn write_out_deps(sess: Session,
                   input: &Input,
                   outputs: &OutputFilenames,
                   krate: &ast::Crate) -> io::IoResult<()> {
-    let id = link::find_crate_id(krate.attrs.as_slice(), outputs);
+    let id = link::find_crate_id(krate.attrs.as_slice(), outputs.out_filestem);
 
     let mut out_filenames = Vec::new();
     for output_type in sess.opts.output_types.iter() {
@@ -547,22 +566,21 @@ pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &Input,
     // We need nested scopes here, because the intermediate results can keep
     // large chunks of memory alive and we want to free them as soon as
     // possible to keep the peak memory usage low
-    let (outputs, trans) = {
+    let outputs;
+    let trans = {
         let (expanded_crate, ast_map) = {
             let krate = phase_1_parse_input(sess, cfg, input);
-            if sess.show_span() {
-                front::show_span::run(sess, &krate);
-                return;
-            }
             if stop_after_phase_1(sess) { return; }
-            let loader = &mut Loader::new(sess);
-            phase_2_configure_and_expand(sess, loader, krate)
-        };
-        let outputs = build_output_filenames(input,
+            outputs = build_output_filenames(input,
                                              outdir,
                                              output,
-                                             expanded_crate.attrs.as_slice(),
+                                             krate.attrs.as_slice(),
                                              sess);
+            let loader = &mut Loader::new(sess);
+            let id = link::find_crate_id(krate.attrs.as_slice(),
+                                         outputs.out_filestem);
+            phase_2_configure_and_expand(sess, loader, krate, &id)
+        };
 
         write_out_deps(sess, input, &outputs, &expanded_crate).unwrap();
 
@@ -570,9 +588,7 @@ pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &Input,
 
         let analysis = phase_3_run_analysis_passes(sess, &expanded_crate, ast_map);
         if stop_after_phase_3(sess) { return; }
-        let trans = phase_4_translate_to_llvm(sess, expanded_crate,
-                                              &analysis, &outputs);
-        (outputs, trans)
+        phase_4_translate_to_llvm(sess, expanded_crate, &analysis, &outputs)
     };
     phase_5_run_llvm_passes(sess, &trans, &outputs);
     if stop_after_phase_5(sess) { return; }
@@ -645,11 +661,13 @@ pub fn pretty_print_input(sess: Session,
                           input: &Input,
                           ppm: PpMode) {
     let krate = phase_1_parse_input(sess, cfg, input);
+    let id = link::find_crate_id(krate.attrs.as_slice(), input.filestem());
 
     let (krate, ast_map, is_expanded) = match ppm {
         PpmExpanded | PpmExpandedIdentified | PpmTyped => {
             let loader = &mut Loader::new(sess);
-            let (krate, ast_map) = phase_2_configure_and_expand(sess, loader, krate);
+            let (krate, ast_map) = phase_2_configure_and_expand(sess, loader,
+                                                                krate, &id);
             (krate, Some(ast_map), true)
         }
         _ => (krate, None, false)
@@ -1137,11 +1155,7 @@ pub fn build_output_filenames(input: &Input,
                 None => Path::new(".")
             };
 
-            let mut stem = match *input {
-                // FIXME (#9639): This needs to handle non-utf8 paths
-                FileInput(ref ifile) => ifile.filestem_str().unwrap().to_str(),
-                StrInput(_) => ~"rust_out"
-            };
+            let mut stem = input.filestem();
 
             // If a crateid is present, we use it as the link name
             let crateid = attr::find_crateid(attrs);
index d403efcf8cd2637efa6f38ac48601bfbe5e4e328..11556322ef12258fd1fc9c2a1d72def56cba5c2e 100644 (file)
@@ -170,6 +170,7 @@ fn generate_test_harness(sess: session::Session, krate: ast::Crate)
                              ExpansionConfig {
                                  loader: loader,
                                  deriving_hash_type_parameter: false,
+                                 crate_id: from_str("test").unwrap(),
                              }),
         path: RefCell::new(Vec::new()),
         testfns: RefCell::new(Vec::new()),
@@ -329,6 +330,7 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::Item {
     // with our list of tests
     let mainfn = (quote_item!(&cx.ext_cx,
         pub fn main() {
+            #[allow(deprecated_owned_vector)];
             #[main];
             test::test_main_static(::std::os::args(), TESTS);
         }
index 764eba56dae7ea43b9395d8868205b0ed29270f1..00cde129d1e403ba8d9565a3fba79585bda9e591 100644 (file)
       html_root_url = "http://static.rust-lang.org/doc/master")];
 
 #[allow(deprecated)];
+#[allow(deprecated_owned_vector)];
 #[feature(macro_rules, globs, struct_variant, managed_boxes)];
-#[feature(quote, default_type_params)];
+#[feature(quote, default_type_params, phase)];
 
-extern crate extra;
 extern crate flate;
 extern crate arena;
 extern crate syntax;
@@ -40,6 +40,8 @@
 extern crate getopts;
 extern crate collections;
 extern crate time;
+#[phase(syntax, link)]
+extern crate log;
 
 use back::link;
 use driver::session;
@@ -133,6 +135,9 @@ pub mod lib {
     pub mod llvmdeps;
 }
 
+static BUG_REPORT_URL: &'static str =
+    "http://static.rust-lang.org/doc/master/complement-bugreport.html";
+
 pub fn version(argv0: &str) {
     let vers = match option_env!("CFG_VERSION") {
         Some(vers) => vers,
@@ -315,7 +320,7 @@ pub fn run_compiler(args: &[~str]) {
         let attrs = parse_crate_attrs(sess, &input);
         let t_outputs = d::build_output_filenames(&input, &odir, &ofile,
                                                   attrs.as_slice(), sess);
-        let id = link::find_crate_id(attrs.as_slice(), &t_outputs);
+        let id = link::find_crate_id(attrs.as_slice(), t_outputs.out_filestem);
 
         if crate_id {
             println!("{}", id.to_str());
@@ -392,20 +397,31 @@ pub fn monitor(f: proc()) {
             // Task failed without emitting a fatal diagnostic
             if !value.is::<diagnostic::FatalError>() {
                 let mut emitter = diagnostic::EmitterWriter::stderr();
-                emitter.emit(
-                    None,
-                    diagnostic::ice_msg("unexpected failure"),
-                    diagnostic::Error);
+
+                // a .span_bug or .bug call has already printed what
+                // it wants to print.
+                if !value.is::<diagnostic::ExplicitBug>() {
+                    emitter.emit(
+                        None,
+                        "unexpected failure",
+                        diagnostic::Bug);
+                }
 
                 let xs = [
-                    ~"the compiler hit an unexpected failure path. \
-                     this is a bug",
+                    ~"the compiler hit an unexpected failure path. this is a bug.",
+                    "we would appreciate a bug report: " + BUG_REPORT_URL,
+                    ~"run with `RUST_BACKTRACE=1` for a backtrace",
                 ];
                 for note in xs.iter() {
                     emitter.emit(None, *note, diagnostic::Note)
                 }
 
-                println!("{}", r.read_to_str());
+                match r.read_to_str() {
+                    Ok(s) => println!("{}", s),
+                    Err(e) => emitter.emit(None,
+                                           format!("failed to read internal stderr: {}", e),
+                                           diagnostic::Error),
+                }
             }
 
             // Fail so the process returns a failure code, but don't pollute the
index 1d683ec60da0d6c164c8b1e4115204934e4c3e2f..deadfb429046a331e0ccf9204096b4f39b21c42f 100644 (file)
@@ -19,8 +19,8 @@
 
 use std::cell::RefCell;
 use std::vec_ng::Vec;
+use std::c_vec::CVec;
 use collections::HashMap;
-use extra::c_vec::CVec;
 use syntax::ast;
 use syntax::parse::token::IdentInterner;
 use syntax::crateid::CrateId;
@@ -143,16 +143,44 @@ pub fn reset(&self) {
         self.used_link_args.with_mut(|s| s.clear());
     }
 
+    // This method is used when generating the command line to pass through to
+    // system linker. The linker expects undefined symbols on the left of the
+    // command line to be defined in libraries on the right, not the other way
+    // around. For more info, see some comments in the add_used_library function
+    // below.
+    //
+    // In order to get this left-to-right dependency ordering, we perform a
+    // topological sort of all crates putting the leaves at the right-most
+    // positions.
     pub fn get_used_crates(&self, prefer: LinkagePreference)
                            -> Vec<(ast::CrateNum, Option<Path>)> {
+        let mut ordering = Vec::new();
+        fn visit(cstore: &CStore, cnum: ast::CrateNum,
+                 ordering: &mut Vec<ast::CrateNum>) {
+            if ordering.as_slice().contains(&cnum) { return }
+            let meta = cstore.get_crate_data(cnum);
+            for (_, &dep) in meta.cnum_map.borrow().get().iter() {
+                visit(cstore, dep, ordering);
+            }
+            ordering.push(cnum);
+        };
+        for (&num, _) in self.metas.borrow().get().iter() {
+            visit(self, num, &mut ordering);
+        }
+        ordering.as_mut_slice().reverse();
+        let ordering = ordering.as_slice();
         let used_crate_sources = self.used_crate_sources.borrow();
-        used_crate_sources.get()
+        let mut libs = used_crate_sources.get()
             .iter()
             .map(|src| (src.cnum, match prefer {
                 RequireDynamic => src.dylib.clone(),
                 RequireStatic => src.rlib.clone(),
             }))
-            .collect()
+            .collect::<Vec<(ast::CrateNum, Option<Path>)>>();
+        libs.sort_by(|&(a, _), &(b, _)| {
+            ordering.position_elem(&a).cmp(&ordering.position_elem(&b))
+        });
+        libs
     }
 
     pub fn add_used_library(&self, lib: ~str, kind: NativeLibaryKind) {
index 0100a82a9d5aa56aad2ce3dbf0b55e239acd8619..2306a25592bf44298d61b2910bd2584ad2bf7165 100644 (file)
@@ -408,7 +408,6 @@ fn expr(&mut self, expr: @ast::Expr, pred: CFGIndex) -> CFGIndex {
                 self.straightline(expr, pred, [e])
             }
 
-            ast::ExprLogLevel |
             ast::ExprMac(..) |
             ast::ExprInlineAsm(..) |
             ast::ExprFnBlock(..) |
index 57b5be4e96069b5742dde20c524c170cfbbf92fe..683ef11aff152b1adef41d81dc1a949de56fb88f 100644 (file)
@@ -613,7 +613,6 @@ fn walk_expr(&mut self,
                 self.walk_exprs([l, r], in_out, loop_scopes);
             }
 
-            ast::ExprLogLevel |
             ast::ExprLit(..) |
             ast::ExprPath(..) => {}
 
index 31d705dc6aa933e9330975d727a684165d870166..9a6ea297af096210d81930226b2cfa6bb8256464 100644 (file)
@@ -113,6 +113,8 @@ pub enum Lint {
     UnusedMustUse,
     UnusedResult,
 
+    DeprecatedOwnedVector,
+
     Warnings,
 }
 
@@ -397,7 +399,14 @@ enum LintSource {
         lint: UnusedResult,
         desc: "unused result of an expression in a statement",
         default: allow,
-    })
+    }),
+
+    ("deprecated_owned_vector",
+     LintSpec {
+        lint: DeprecatedOwnedVector,
+        desc: "use of a `~[T]` vector",
+        default: warn
+    }),
 ];
 
 /*
@@ -976,7 +985,7 @@ fn check_heap_item(cx: &Context, it: &ast::Item) {
     "crate_map", "cfg", "doc", "export_name", "link_section",
     "no_mangle", "static_assert", "unsafe_no_drop_flag", "packed",
     "simd", "repr", "deriving", "unsafe_destructor", "link", "phase",
-    "macro_export", "must_use",
+    "macro_export", "must_use", "automatically_derived",
 
     //mod-level
     "path", "link_name", "link_args", "macro_escape", "no_implicit_prelude",
@@ -1107,6 +1116,17 @@ fn check_unused_result(cx: &Context, s: &ast::Stmt) {
     }
 }
 
+fn check_deprecated_owned_vector(cx: &Context, e: &ast::Expr) {
+    let t = ty::expr_ty(cx.tcx, e);
+    match ty::get(t).sty {
+        ty::ty_vec(_, ty::vstore_uniq) => {
+            cx.span_lint(DeprecatedOwnedVector, e.span,
+                         "use of deprecated `~[]` vector; replaced by `std::vec_ng::Vec`")
+        }
+        _ => {}
+    }
+}
+
 fn check_item_non_camel_case_types(cx: &Context, it: &ast::Item) {
     fn is_camel_case(ident: ast::Ident) -> bool {
         let ident = token::get_ident(ident);
@@ -1634,6 +1654,7 @@ fn visit_expr(&mut self, e: &ast::Expr, _: ()) {
 
         check_type_limits(self, e);
         check_unused_casts(self, e);
+        check_deprecated_owned_vector(self, e);
 
         visit::walk_expr(self, e, ());
     }
index 48a6b5c92d4e8ed1ddeeec78e54e3f447216d8d4..38cbde70ad18bf5999e3629e1881a04c1fc2f365 100644 (file)
@@ -541,7 +541,7 @@ fn visit_expr(v: &mut LivenessVisitor, expr: &Expr, this: @IrMaps) {
 
       // otherwise, live nodes are not required:
       ExprIndex(..) | ExprField(..) | ExprVstore(..) | ExprVec(..) |
-      ExprCall(..) | ExprMethodCall(..) | ExprTup(..) | ExprLogLevel |
+      ExprCall(..) | ExprMethodCall(..) | ExprTup(..) |
       ExprBinary(..) | ExprAddrOf(..) |
       ExprCast(..) | ExprUnary(..) | ExprBreak(_) |
       ExprAgain(_) | ExprLit(_) | ExprRet(..) | ExprBlock(..) |
@@ -1259,18 +1259,18 @@ pub fn propagate_through_expr(&self, expr: @Expr, succ: LiveNode)
           }
 
           ExprInlineAsm(ref ia) => {
-            let succ = ia.inputs.rev_iter().fold(succ, |succ, &(_, expr)| {
-                self.propagate_through_expr(expr, succ)
-            });
-            ia.outputs.rev_iter().fold(succ, |succ, &(_, expr)| {
+            let succ = ia.outputs.rev_iter().fold(succ, |succ, &(_, expr)| {
                 // see comment on lvalues in
                 // propagate_through_lvalue_components()
                 let succ = self.write_lvalue(expr, succ, ACC_WRITE);
                 self.propagate_through_lvalue_components(expr, succ)
+            });
+            // Inputs are executed first. Propagate last because of rev order
+            ia.inputs.rev_iter().fold(succ, |succ, &(_, expr)| {
+                self.propagate_through_expr(expr, succ)
             })
           }
 
-          ExprLogLevel |
           ExprLit(..) => {
             succ
           }
@@ -1520,7 +1520,7 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
       // no correctness conditions related to liveness
       ExprCall(..) | ExprMethodCall(..) | ExprIf(..) | ExprMatch(..) |
       ExprWhile(..) | ExprLoop(..) | ExprIndex(..) | ExprField(..) |
-      ExprVstore(..) | ExprVec(..) | ExprTup(..) | ExprLogLevel |
+      ExprVstore(..) | ExprVec(..) | ExprTup(..) |
       ExprBinary(..) |
       ExprCast(..) | ExprUnary(..) | ExprRet(..) | ExprBreak(..) |
       ExprAgain(..) | ExprLit(_) | ExprBlock(..) |
index c07cd2570a30b3b08e4e65f234384aaddc21a06e..127f835d5f6ef369c736ba56b583d4ff41cf0be3 100644 (file)
@@ -469,7 +469,7 @@ pub fn cat_expr_unadjusted(&mut self, expr: &ast::Expr) -> McResult<cmt> {
           ast::ExprUnary(..) |
           ast::ExprMethodCall(..) | ast::ExprCast(..) | ast::ExprVstore(..) |
           ast::ExprVec(..) | ast::ExprTup(..) | ast::ExprIf(..) |
-          ast::ExprLogLevel | ast::ExprBinary(..) | ast::ExprWhile(..) |
+          ast::ExprBinary(..) | ast::ExprWhile(..) |
           ast::ExprBlock(..) | ast::ExprLoop(..) | ast::ExprMatch(..) |
           ast::ExprLit(..) | ast::ExprBreak(..) | ast::ExprMac(..) |
           ast::ExprAgain(..) | ast::ExprStruct(..) | ast::ExprRepeat(..) |
index b52ec7be631143b24e4d59a77bb1c027c1e81465..22b3fb8ad6e4f7d03952c8960ea2a02875434fbb 100644 (file)
@@ -503,7 +503,6 @@ fn has_dtor(tcx: ty::ctxt, ty: ty::t) -> bool {
                 self.use_expr(base, Read);
             }
 
-            ExprLogLevel |
             ExprInlineAsm(..) |
             ExprBreak(..) |
             ExprAgain(..) |
index 156a4f914a9093a2be1febb2b937ccc39ee7c350..a2ee57d6df1ae857c71c5c655579c0a0827b758f 100644 (file)
@@ -32,7 +32,7 @@
 use driver::driver::OutputFilenames;
 use driver::driver::{CrateAnalysis, CrateTranslation};
 use lib::llvm::{ModuleRef, ValueRef, BasicBlockRef};
-use lib::llvm::{llvm, True, Vector};
+use lib::llvm::{llvm, Vector};
 use lib;
 use metadata::common::LinkMeta;
 use metadata::{csearch, encoder};
@@ -2404,70 +2404,6 @@ pub fn trap(bcx: &Block) {
     }
 }
 
-pub fn decl_gc_metadata(ccx: &CrateContext, llmod_id: &str) {
-    if !ccx.sess.opts.gc || !ccx.uses_gc {
-        return;
-    }
-
-    let gc_metadata_name = ~"_gc_module_metadata_" + llmod_id;
-    let gc_metadata = gc_metadata_name.with_c_str(|buf| {
-        unsafe {
-            llvm::LLVMAddGlobal(ccx.llmod, Type::i32().to_ref(), buf)
-        }
-    });
-    unsafe {
-        llvm::LLVMSetGlobalConstant(gc_metadata, True);
-        lib::llvm::SetLinkage(gc_metadata, lib::llvm::ExternalLinkage);
-
-        let mut module_data = ccx.module_data.borrow_mut();
-        module_data.get().insert(~"_gc_module_metadata", gc_metadata);
-    }
-}
-
-pub fn create_module_map(ccx: &CrateContext) -> (ValueRef, uint) {
-    let str_slice_type = Type::struct_([Type::i8p(), ccx.int_type], false);
-    let elttype = Type::struct_([str_slice_type, ccx.int_type], false);
-    let maptype = {
-        let module_data = ccx.module_data.borrow();
-        Type::array(&elttype, module_data.get().len() as u64)
-    };
-    let map = "_rust_mod_map".with_c_str(|buf| {
-        unsafe {
-            llvm::LLVMAddGlobal(ccx.llmod, maptype.to_ref(), buf)
-        }
-    });
-    lib::llvm::SetLinkage(map, lib::llvm::InternalLinkage);
-    let mut elts: Vec<ValueRef> = Vec::new();
-
-    // This is not ideal, but the borrow checker doesn't
-    // like the multiple borrows. At least, it doesn't
-    // like them on the current snapshot. (2013-06-14)
-    let keys = {
-        let mut keys = Vec::new();
-        let module_data = ccx.module_data.borrow();
-        for (k, _) in module_data.get().iter() {
-            keys.push(k.clone());
-        }
-        keys
-    };
-
-    for key in keys.iter() {
-        let llstrval = C_str_slice(ccx, token::intern_and_get_ident(*key));
-        let module_data = ccx.module_data.borrow();
-        let val = *module_data.get().find_equiv(key).unwrap();
-        let v_ptr = p2i(ccx, val);
-        let elt = C_struct([
-            llstrval,
-            v_ptr
-        ], false);
-        elts.push(elt);
-    }
-    unsafe {
-        llvm::LLVMSetInitializer(map, C_array(elttype, elts.as_slice()));
-    }
-    return (map, keys.len())
-}
-
 pub fn symname(name: &str, hash: &str, vers: &str) -> ~str {
     let path = [PathName(token::intern(name))];
     link::exported_name(ast_map::Values(path.iter()).chain(None), hash, vers)
@@ -2489,11 +2425,8 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
                 mapmeta.crateid.version_or_default())
     };
 
-    let slicetype = Type::struct_([int_type, int_type], false);
     let maptype = Type::struct_([
         Type::i32(),        // version
-        slicetype,          // child modules
-        slicetype,          // sub crate-maps
         int_type.ptr_to(),  // event loop factory
     ], false);
     let map = sym_name.with_c_str(|buf| {
@@ -2513,22 +2446,6 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
 }
 
 pub fn fill_crate_map(ccx: @CrateContext, map: ValueRef) {
-    let mut subcrates: Vec<ValueRef> = Vec::new();
-    let mut i = 1;
-    let cstore = ccx.sess.cstore;
-    while cstore.have_crate_data(i) {
-        let cdata = cstore.get_crate_data(i);
-        let nm = symname(format!("_rust_crate_map_{}", cdata.name),
-                         cstore.get_crate_hash(i).as_str(),
-                         cstore.get_crate_id(i).version_or_default());
-        let cr = nm.with_c_str(|buf| {
-            unsafe {
-                llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type.to_ref(), buf)
-            }
-        });
-        subcrates.push(p2i(ccx, cr));
-        i += 1;
-    }
     let event_loop_factory = match ccx.tcx.lang_items.event_loop_factory() {
         Some(did) => unsafe {
             if is_local(did) {
@@ -2545,26 +2462,8 @@ pub fn fill_crate_map(ccx: @CrateContext, map: ValueRef) {
         None => C_null(ccx.int_type.ptr_to())
     };
     unsafe {
-        let maptype = Type::array(&ccx.int_type, subcrates.len() as u64);
-        let vec_elements = "_crate_map_child_vectors".with_c_str(|buf| {
-            llvm::LLVMAddGlobal(ccx.llmod, maptype.to_ref(), buf)
-        });
-        lib::llvm::SetLinkage(vec_elements, lib::llvm::InternalLinkage);
-
-        llvm::LLVMSetInitializer(vec_elements,
-                                 C_array(ccx.int_type, subcrates.as_slice()));
-        let (mod_map, mod_count) = create_module_map(ccx);
-
         llvm::LLVMSetInitializer(map, C_struct(
             [C_i32(2),
-             C_struct([
-                p2i(ccx, mod_map),
-                C_uint(ccx, mod_count)
-             ], false),
-             C_struct([
-                p2i(ccx, vec_elements),
-                C_uint(ccx, subcrates.len())
-             ], false),
             event_loop_factory,
         ], false));
     }
@@ -2642,7 +2541,7 @@ pub fn trans_crate(sess: session::Session,
         }
     }
 
-    let link_meta = link::build_link_meta(&krate, output);
+    let link_meta = link::build_link_meta(&krate, output.out_filestem);
 
     // Append ".rs" to crate name as LLVM module identifier.
     //
@@ -2667,7 +2566,6 @@ pub fn trans_crate(sess: session::Session,
         trans_mod(ccx, &krate.module);
     }
 
-    decl_gc_metadata(ccx, llmod_id);
     fill_crate_map(ccx, ccx.crate_map);
 
     // win32: wart with exporting crate_map symbol
index e3a996e33d392d62f3e5f5cfce730e1cb9edfcac..bfe5d5187d79da9f080d132c54fe9f842cb34884 100644 (file)
@@ -103,8 +103,13 @@ pub fn return_type_is_void(ccx: &CrateContext, ty: ty::t) -> bool {
     ty::type_is_nil(ty) || ty::type_is_bot(ty) || ty::type_is_empty(ccx.tcx, ty)
 }
 
+/// Generates a unique symbol based off the name given. This is used to create
+/// unique symbols for things like closures.
 pub fn gensym_name(name: &str) -> PathElem {
-    PathName(token::gensym(name))
+    let num = token::gensym(name);
+    // use one colon which will get translated to a period by the mangler, and
+    // we're guaranteed that `num` is globally unique for this crate.
+    PathName(token::gensym(format!("{}:{}", name, num)))
 }
 
 pub struct tydesc_info {
index 517bef52a9939f448373d31f1212e39674c007b4..80dcfc90287150de85052a874ac779056bbf3983 100644 (file)
@@ -95,7 +95,6 @@ pub struct CrateContext {
     // Cache of closure wrappers for bare fn's.
     closure_bare_wrapper_cache: RefCell<HashMap<ValueRef, ValueRef>>,
 
-    module_data: RefCell<HashMap<~str, ValueRef>>,
     lltypes: RefCell<HashMap<ty::t, Type>>,
     llsizingtypes: RefCell<HashMap<ty::t, Type>>,
     adt_reprs: RefCell<HashMap<ty::t, @adt::Repr>>,
@@ -207,7 +206,6 @@ pub fn new(sess: session::Session,
                  extern_const_values: RefCell::new(DefIdMap::new()),
                  impl_method_cache: RefCell::new(HashMap::new()),
                  closure_bare_wrapper_cache: RefCell::new(HashMap::new()),
-                 module_data: RefCell::new(HashMap::new()),
                  lltypes: RefCell::new(HashMap::new()),
                  llsizingtypes: RefCell::new(HashMap::new()),
                  adt_reprs: RefCell::new(HashMap::new()),
index 6ade20d29136df4f40abbd5e7aea753644373c48..dd6a3e61b69e78e8bf5d6b186cd8f00116987b47 100644 (file)
@@ -2539,7 +2539,6 @@ fn walk_expr(cx: &CrateContext,
         scope_map.insert(exp.id, scope_stack.last().unwrap().scope_metadata);
 
         match exp.node {
-            ast::ExprLogLevel |
             ast::ExprLit(_)   |
             ast::ExprBreak(_) |
             ast::ExprAgain(_) |
index d143d6743052cb9a5722b2665263c64c1c88e8c5..bf2d192d0de23ad99413b86d24040bc996c5a3ee 100644 (file)
@@ -34,8 +34,7 @@
 #[allow(non_camel_case_types)];
 
 use back::abi;
-use back::link;
-use lib::llvm::{ValueRef, llvm, SetLinkage, False};
+use lib::llvm::{ValueRef, llvm};
 use lib;
 use metadata::csearch;
 use middle::trans::_match;
@@ -74,9 +73,7 @@
 use std::vec;
 use std::vec_ng::Vec;
 use syntax::ast;
-use syntax::ast_map;
 use syntax::codemap;
-use syntax::parse::token;
 use syntax::print::pprust::{expr_to_str};
 
 // Destinations
@@ -455,9 +452,6 @@ fn trans_datum_unadjusted<'a>(bcx: &'a Block<'a>,
             // Datum output mode means this is a scalar cast:
             trans_imm_cast(bcx, val, expr.id)
         }
-        ast::ExprLogLevel => {
-            trans_log_level(bcx)
-        }
         _ => {
             bcx.tcx().sess.span_bug(
                 expr.span,
@@ -1671,64 +1665,6 @@ fn trans_assign_op<'a>(
     return result_datum.store_to(bcx, dst_datum.val);
 }
 
-fn trans_log_level<'a>(bcx: &'a Block<'a>) -> DatumBlock<'a, Expr> {
-    let _icx = push_ctxt("trans_log_level");
-    let ccx = bcx.ccx();
-
-    let (modpath, modname) = {
-        let srccrate = {
-            let external_srcs = ccx.external_srcs.borrow();
-            match external_srcs.get().find(&bcx.fcx.id) {
-                Some(&src) => {
-                    ccx.sess.cstore.get_crate_data(src.krate).name.clone()
-                }
-                None => ccx.link_meta.crateid.name.to_str(),
-            }
-        };
-        bcx.tcx().map.with_path(bcx.fcx.id, |path| {
-            let first = ast_map::PathMod(token::intern(srccrate));
-            let mut path = Some(first).move_iter().chain(path).filter(|e| {
-                match *e {
-                    ast_map::PathMod(_) => true,
-                    _ => false
-                }
-            });
-            let modpath: Vec<ast_map::PathElem> = path.collect();
-            let modname = ast_map::path_to_str(ast_map::Values(modpath.iter()));
-            (modpath, modname)
-        })
-    };
-
-    let module_data_exists;
-    {
-        let module_data = ccx.module_data.borrow();
-        module_data_exists = module_data.get().contains_key(&modname);
-    }
-
-    let global = if module_data_exists {
-        let mut module_data = ccx.module_data.borrow_mut();
-        module_data.get().get_copy(&modname)
-    } else {
-        let s = link::mangle_internal_name_by_path_and_seq(
-            ast_map::Values(modpath.iter()).chain(None), "loglevel");
-        let global;
-        unsafe {
-            global = s.with_c_str(|buf| {
-                llvm::LLVMAddGlobal(ccx.llmod, Type::i32().to_ref(), buf)
-            });
-            llvm::LLVMSetGlobalConstant(global, False);
-            llvm::LLVMSetInitializer(global, C_null(Type::i32()));
-            lib::llvm::SetLinkage(global, lib::llvm::InternalLinkage);
-        }
-        {
-            let mut module_data = ccx.module_data.borrow_mut();
-            module_data.get().insert(modname, global);
-            global
-        }
-    };
-
-    immediate_rvalue_bcx(bcx, Load(bcx, global), ty::mk_u32()).to_expr_datumblock()
-}
 
 fn auto_ref<'a>(bcx: &'a Block<'a>,
                 datum: Datum<Expr>,
index c0ad18d9520e3f52abecb2ae7fa85378579cc16a..e1dddda01f7e1a2bc533a23f2e868b0661f3cf8b 100644 (file)
@@ -3391,7 +3391,6 @@ pub fn expr_kind(tcx: ctxt,
 
         ast::ExprForLoop(..) => fail!("non-desugared expr_for_loop"),
 
-        ast::ExprLogLevel |
         ast::ExprLit(_) | // Note: LitStr is carved out above
         ast::ExprUnary(..) |
         ast::ExprAddrOf(..) |
index e8770f9d142cfe492d8714adfa95bf5df3615c85..8336fa2d6b5ea620d8de99baf9ad35db41fa1983 100644 (file)
@@ -640,13 +640,11 @@ fn mk_pointer<AC:AstConv,
                 tcx.sess.span_bug(ast_ty.span, "typeof is reserved but unimplemented");
             }
             ast::TyInfer => {
-                // ty_infer should only appear as the type of arguments or return
-                // values in a fn_expr, or as the type of local variables.  Both of
-                // these cases are handled specially and should not descend into this
-                // routine.
-                this.tcx().sess.span_bug(
-                    ast_ty.span,
-                    "found `ty_infer` in unexpected place");
+                // TyInfer also appears as the type of arguments or return
+                // values in a ExprFnBlock or ExprProc, or as the type of
+                // local variables. Both of these cases are handled specially
+                // and will not descend into this routine.
+                this.ty_infer(ast_ty.span)
             }
         });
 
index 38a9119604b25f50636a6fa51deeb44878abfab3..f4a04d824adfd7f98c1d72311d1bf2c992b92a14 100644 (file)
@@ -2850,9 +2850,6 @@ fn check_struct_enum_variant(fcx: @FnCtxt,
         }
         fcx.write_bot(id);
       }
-      ast::ExprLogLevel => {
-        fcx.write_ty(id, ty::mk_u32())
-      }
       ast::ExprParen(a) => {
         check_expr_with_opt_hint_and_lvalue_pref(fcx, a, expected, lvalue_pref);
         fcx.write_ty(id, fcx.expr_ty(a));
index 402f06f928ccef54637f7bd02b365c7714322de6..0c6aeda4258303cc211442f082c8b3ee11f276ea 100644 (file)
@@ -132,7 +132,9 @@ fn get_trait_def(&self, id: ast::DefId) -> @ty::TraitDef {
     }
 
     fn ty_infer(&self, span: Span) -> ty::t {
-        self.tcx.sess.span_bug(span, "found `ty_infer` in unexpected place");
+        self.tcx.sess.span_err(span, "the type placeholder `_` is not \
+                                      allowed within types on item signatures.");
+        ty::mk_err()
     }
 }
 
index 58bed8a9df993d495db52bb8163c93c960509b7f..eda24fb6dc20a2379deff94e69cf87d6a4e487a3 100644 (file)
@@ -75,7 +75,9 @@ fn get_ast_and_resolve(cpath: &Path,
 
     let krate = phase_1_parse_input(sess, cfg, &input);
     let loader = &mut Loader::new(sess);
-    let (krate, ast_map) = phase_2_configure_and_expand(sess, loader, krate);
+    let id = from_str("rustdoc").unwrap();
+    let (krate, ast_map) = phase_2_configure_and_expand(sess, loader,
+                                                        krate, &id);
     let driver::driver::CrateAnalysis {
         exported_items, public_items, ty_cx, ..
     } = phase_3_run_analysis_passes(sess, &krate, ast_map);
index e6b4e2c09430803c0cebe8fe3914058f1ed8ce91..fff6e4dafb3035f33bb92d3d641e91ea9ca747f8 100644 (file)
 #[crate_type = "dylib"];
 #[crate_type = "rlib"];
 
-#[feature(globs, struct_variant, managed_boxes, macro_rules)];
+#[allow(deprecated_owned_vector)];
+#[feature(globs, struct_variant, managed_boxes, macro_rules, phase)];
 
 extern crate syntax;
 extern crate rustc;
-extern crate extra;
 extern crate serialize;
 extern crate sync;
 extern crate getopts;
 extern crate collections;
 extern crate testing = "test";
 extern crate time;
+#[phase(syntax, link)]
+extern crate log;
 
 use std::cell::RefCell;
 use std::local_data;
index 66dc9567e7531810892b1035ab412104d6e43a63..d8b7c52553836d7b4e98e3f1dd34052f15d05086 100644 (file)
 use std::cell::RefCell;
 use std::char;
 use std::io;
-use std::io::Process;
+use std::io::{Process, TempDir};
 use std::local_data;
 use std::os;
 use std::str;
 
 use collections::HashSet;
 use testing;
-use extra::tempfile::TempDir;
 use rustc::back::link;
 use rustc::driver::driver;
 use rustc::driver::session;
@@ -62,7 +61,9 @@ pub fn run(input: &str, libs: @RefCell<HashSet<Path>>, mut test_args: ~[~str]) -
     let cfg = driver::build_configuration(sess);
     let krate = driver::phase_1_parse_input(sess, cfg, &input);
     let loader = &mut Loader::new(sess);
-    let (krate, _) = driver::phase_2_configure_and_expand(sess, loader, krate);
+    let id = from_str("rustdoc-test").unwrap();
+    let (krate, _) = driver::phase_2_configure_and_expand(sess, loader, krate,
+                                                          &id);
 
     let ctx = @core::DocContext {
         krate: krate,
@@ -166,6 +167,9 @@ fn maketest(s: &str, cratename: &str, loose_feature_gating: bool) -> ~str {
     let mut prog = ~r"
 #[deny(warnings)];
 #[allow(unused_variable, dead_assignment, unused_mut, attribute_usage, dead_code)];
+
+// FIXME: remove when ~[] disappears from tests.
+#[allow(deprecated_owned_vector)];
 ";
 
     if loose_feature_gating {
@@ -175,9 +179,6 @@ fn maketest(s: &str, cratename: &str, loose_feature_gating: bool) -> ~str {
     }
 
     if !s.contains("extern crate") {
-        if s.contains("extra") {
-            prog.push_str("extern crate extra;\n");
-        }
         if s.contains(cratename) {
             prog.push_str(format!("extern crate {};\n", cratename));
         }
index 890f44faabc0d6e0280b7e3edca56c1651107928..e2d13d65da0cb3ce3df8cd8036b98ff1e57a94e5 100644 (file)
@@ -42,6 +42,7 @@
 #[feature(macro_rules)];
 #[deny(unused_result, unused_must_use)];
 #[allow(visible_private_types)];
+#[allow(deprecated_owned_vector)];
 
 #[cfg(test)] extern crate green;
 
index 2ad40026cad985506efafe1049c4e7915bd8fbd7..08d66e7270371b9c60c9c64df134273a88490569 100644 (file)
@@ -305,6 +305,38 @@ fn clone(&self) -> ~rtio::RtioTcpStream {
             read_access: self.read_access.clone(),
         } as ~rtio::RtioTcpStream
     }
+
+    fn close_write(&mut self) -> Result<(), IoError> {
+        struct Ctx {
+            slot: Option<BlockedTask>,
+            status: c_int,
+        }
+        let mut req = Request::new(uvll::UV_SHUTDOWN);
+
+        return match unsafe {
+            uvll::uv_shutdown(req.handle, self.handle, shutdown_cb)
+        } {
+            0 => {
+                req.defuse(); // uv callback now owns this request
+                let mut cx = Ctx { slot: None, status: 0 };
+
+                wait_until_woken_after(&mut cx.slot, &self.uv_loop(), || {
+                    req.set_data(&cx);
+                });
+
+                status_to_io_result(cx.status)
+            }
+            n => Err(uv_error_to_io_error(UvError(n)))
+        };
+
+        extern fn shutdown_cb(req: *uvll::uv_shutdown_t, status: libc::c_int) {
+            let req = Request::wrap(req);
+            assert!(status != uvll::ECANCELED);
+            let cx: &mut Ctx = unsafe { req.get_data() };
+            cx.status = status;
+            wakeup(&mut cx.slot);
+        }
+    }
 }
 
 impl UvHandle<uvll::uv_tcp_t> for TcpWatcher {
index 039f2e8bc85de848eb81d33ae6815bf458529966..b9b7ed13cc1b18d18ae4bcf2c0fbe94e5395e0d6 100644 (file)
@@ -157,6 +157,7 @@ pub struct uv_stdio_container_t {
 pub type uv_pipe_t = c_void;
 pub type uv_tty_t = c_void;
 pub type uv_signal_t = c_void;
+pub type uv_shutdown_t = c_void;
 
 pub struct uv_timespec_t {
     tv_sec: libc::c_long,
@@ -248,6 +249,7 @@ pub fn is_dir(&self) -> bool {
 pub type uv_signal_cb = extern "C" fn(handle: *uv_signal_t,
                                       signum: c_int);
 pub type uv_fs_cb = extern "C" fn(req: *uv_fs_t);
+pub type uv_shutdown_cb = extern "C" fn(req: *uv_shutdown_t, status: c_int);
 
 #[cfg(unix)] pub type uv_uid_t = libc::types::os::arch::posix88::uid_t;
 #[cfg(unix)] pub type uv_gid_t = libc::types::os::arch::posix88::gid_t;
@@ -539,6 +541,8 @@ pub fn uv_read_start(stream: *uv_stream_t,
                          on_alloc: uv_alloc_cb,
                          on_read: uv_read_cb) -> c_int;
     pub fn uv_read_stop(stream: *uv_stream_t) -> c_int;
+    pub fn uv_shutdown(req: *uv_shutdown_t, handle: *uv_stream_t,
+                       cb: uv_shutdown_cb) -> c_int;
 
     // idle bindings
     pub fn uv_idle_init(l: *uv_loop_t, i: *uv_idle_t) -> c_int;
index 700dc9867940ab216bcac363a162b567ead96813..6cbfeee6aa7ad0628c72ef6f1030b2c79cf874c7 100644 (file)
 #[crate_type = "rlib"];
 #[crate_type = "dylib"];
 #[license = "MIT/ASL2"];
+#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+      html_root_url = "http://static.rust-lang.org/doc/master")];
 
 use std::char;
 use std::cmp;
 use std::fmt;
 use std::fmt::Show;
 use std::option::{Option, Some, None};
+use std::vec_ng::Vec;
 
 /// An identifier in the pre-release or build metadata. If the identifier can
 /// be parsed as a decimal value, it will be represented with `Numeric`.
@@ -83,9 +87,9 @@ pub struct Version {
     /// fixes are made.
     patch: uint,
     /// The pre-release version identifier, if one exists.
-    pre: ~[Identifier],
+    pre: Vec<Identifier>,
     /// The build metadata, ignored when determining version precedence.
-    build: ~[Identifier],
+    build: Vec<Identifier>,
 }
 
 impl fmt::Show for Version {
@@ -166,7 +170,6 @@ fn take_nonempty_prefix<T:Iterator<char>>(rdr: &mut T, pred: |char| -> bool)
             }
         }
     }
-    debug!("extracted nonempty prefix: {}", buf);
     (buf, ch)
 }
 
@@ -216,8 +219,8 @@ fn parse_iter<T: Iterator<char>>(rdr: &mut T) -> Option<Version> {
         None => return None
     };
 
-    let mut pre = ~[];
-    let mut build = ~[];
+    let mut pre = vec!();
+    let mut build = vec!();
 
     let mut ch = ch;
     if ch == Some('-') {
@@ -290,66 +293,66 @@ fn test_parse() {
         major: 1u,
         minor: 2u,
         patch: 3u,
-        pre: ~[],
-        build: ~[],
+        pre: vec!(),
+        build: vec!(),
     }));
     assert!(parse("  1.2.3  ") == Some(Version {
         major: 1u,
         minor: 2u,
         patch: 3u,
-        pre: ~[],
-        build: ~[],
+        pre: vec!(),
+        build: vec!(),
     }));
     assert!(parse("1.2.3-alpha1") == Some(Version {
         major: 1u,
         minor: 2u,
         patch: 3u,
-        pre: ~[AlphaNumeric(~"alpha1")],
-        build: ~[]
+        pre: vec!(AlphaNumeric(~"alpha1")),
+        build: vec!(),
     }));
     assert!(parse("  1.2.3-alpha1  ") == Some(Version {
         major: 1u,
         minor: 2u,
         patch: 3u,
-        pre: ~[AlphaNumeric(~"alpha1")],
-        build: ~[]
+        pre: vec!(AlphaNumeric(~"alpha1")),
+        build: vec!()
     }));
     assert!(parse("1.2.3+build5") == Some(Version {
         major: 1u,
         minor: 2u,
         patch: 3u,
-        pre: ~[],
-        build: ~[AlphaNumeric(~"build5")]
+        pre: vec!(),
+        build: vec!(AlphaNumeric(~"build5"))
     }));
     assert!(parse("  1.2.3+build5  ") == Some(Version {
         major: 1u,
         minor: 2u,
         patch: 3u,
-        pre: ~[],
-        build: ~[AlphaNumeric(~"build5")]
+        pre: vec!(),
+        build: vec!(AlphaNumeric(~"build5"))
     }));
     assert!(parse("1.2.3-alpha1+build5") == Some(Version {
         major: 1u,
         minor: 2u,
         patch: 3u,
-        pre: ~[AlphaNumeric(~"alpha1")],
-        build: ~[AlphaNumeric(~"build5")]
+        pre: vec!(AlphaNumeric(~"alpha1")),
+        build: vec!(AlphaNumeric(~"build5"))
     }));
     assert!(parse("  1.2.3-alpha1+build5  ") == Some(Version {
         major: 1u,
         minor: 2u,
         patch: 3u,
-        pre: ~[AlphaNumeric(~"alpha1")],
-        build: ~[AlphaNumeric(~"build5")]
+        pre: vec!(AlphaNumeric(~"alpha1")),
+        build: vec!(AlphaNumeric(~"build5"))
     }));
     assert!(parse("1.2.3-1.alpha1.9+build5.7.3aedf  ") == Some(Version {
         major: 1u,
         minor: 2u,
         patch: 3u,
-        pre: ~[Numeric(1),AlphaNumeric(~"alpha1"),Numeric(9)],
-        build: ~[AlphaNumeric(~"build5"),
+        pre: vec!(Numeric(1),AlphaNumeric(~"alpha1"),Numeric(9)),
+        build: vec!(AlphaNumeric(~"build5"),
                  Numeric(7),
-                 AlphaNumeric(~"3aedf")]
+                 AlphaNumeric(~"3aedf"))
     }));
 
 }
index 028e1e742c47ef249f26e7ed20d0e9850ef39ffc..c27c5542ce1e0fb3d145dd03ee8850aeba2afac5 100644 (file)
 #[crate_type = "rlib"];
 #[crate_type = "dylib"];
 #[license = "MIT/ASL2"];
+#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+      html_root_url = "http://static.rust-lang.org/doc/master")];
 #[allow(missing_doc)];
 #[forbid(non_camel_case_types)];
-#[feature(macro_rules, managed_boxes, default_type_params)];
+#[feature(macro_rules, managed_boxes, default_type_params, phase)];
 
 // NOTE remove the following two attributes after the next snapshot.
 #[allow(unrecognized_lint)];
 #[allow(default_type_param_usage)];
+#[allow(deprecated_owned_vector)];
 
 // test harness access
 #[cfg(test)]
 extern crate test;
+#[phase(syntax, link)]
+extern crate log;
 
 extern crate collections;
 
diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs
new file mode 100644 (file)
index 0000000..00d250a
--- /dev/null
@@ -0,0 +1,216 @@
+// 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.
+
+//! Library to interface with chunks of memory allocated in C.
+//!
+//! It is often desirable to safely interface with memory allocated from C,
+//! encapsulating the unsafety into allocation and destruction time.  Indeed,
+//! allocating memory externally is currently the only way to give Rust shared
+//! mut state with C programs that keep their own references; vectors are
+//! unsuitable because they could be reallocated or moved at any time, and
+//! importing C memory into a vector takes a one-time snapshot of the memory.
+//!
+//! This module simplifies the usage of such external blocks of memory.  Memory
+//! is encapsulated into an opaque object after creation; the lifecycle of the
+//! memory can be optionally managed by Rust, if an appropriate destructor
+//! closure is provided.  Safety is ensured by bounds-checking accesses, which
+//! are marshalled through get and set functions.
+//!
+//! There are three unsafe functions: the two constructors, and the
+//! unwrap method. The constructors are unsafe for the
+//! obvious reason (they act on a pointer that cannot be checked inside the
+//! method), but `unwrap()` is somewhat more subtle in its unsafety.
+//! It returns the contained pointer, but at the same time destroys the CVec
+//! without running its destructor. This can be used to pass memory back to
+//! C, but care must be taken that the ownership of underlying resources are
+//! handled correctly, i.e. that allocated memory is eventually freed
+//! if necessary.
+
+use cast;
+use container::Container;
+use ptr;
+use ptr::RawPtr;
+use raw;
+use option::{Option, Some, None};
+use ops::Drop;
+
+/// The type representing a foreign chunk of memory
+pub struct CVec<T> {
+    priv base: *mut T,
+    priv len: uint,
+    priv dtor: Option<proc()>,
+}
+
+#[unsafe_destructor]
+impl<T> Drop for CVec<T> {
+    fn drop(&mut self) {
+        match self.dtor.take() {
+            None => (),
+            Some(f) => f()
+        }
+    }
+}
+
+impl<T> CVec<T> {
+    /// Create a `CVec` from a raw pointer to a buffer with a given length.
+    ///
+    /// Fails if the given pointer is null. The returned vector will not attempt
+    /// to deallocate the vector when dropped.
+    ///
+    /// # Arguments
+    ///
+    /// * base - A raw pointer to a buffer
+    /// * len - The number of elements in the buffer
+    pub unsafe fn new(base: *mut T, len: uint) -> CVec<T> {
+        assert!(base != ptr::mut_null());
+        CVec {
+            base: base,
+            len: len,
+            dtor: None,
+        }
+    }
+
+    /// Create a `CVec` from a foreign buffer, with a given length,
+    /// and a function to run upon destruction.
+    ///
+    /// Fails if the given pointer is null.
+    ///
+    /// # Arguments
+    ///
+    /// * base - A foreign pointer to a buffer
+    /// * len - The number of elements in the buffer
+    /// * dtor - A proc to run when the value is destructed, useful
+    ///          for freeing the buffer, etc.
+    pub unsafe fn new_with_dtor(base: *mut T, len: uint,
+                                dtor: proc()) -> CVec<T> {
+        assert!(base != ptr::mut_null());
+        CVec {
+            base: base,
+            len: len,
+            dtor: Some(dtor),
+        }
+    }
+
+    /// View the stored data as a slice.
+    pub fn as_slice<'a>(&'a self) -> &'a [T] {
+        unsafe {
+            cast::transmute(raw::Slice { data: self.base as *T, len: self.len })
+        }
+    }
+
+    /// View the stored data as a mutable slice.
+    pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
+        unsafe {
+            cast::transmute(raw::Slice { data: self.base as *T, len: self.len })
+        }
+    }
+
+    /// Retrieves an element at a given index, returning `None` if the requested
+    /// index is greater than the length of the vector.
+    pub fn get<'a>(&'a self, ofs: uint) -> Option<&'a T> {
+        if ofs < self.len {
+            Some(unsafe { &*self.base.offset(ofs as int) })
+        } else {
+            None
+        }
+    }
+
+    /// Retrieves a mutable element at a given index, returning `None` if the
+    /// requested index is greater than the length of the vector.
+    pub fn get_mut<'a>(&'a mut self, ofs: uint) -> Option<&'a mut T> {
+        if ofs < self.len {
+            Some(unsafe { &mut *self.base.offset(ofs as int) })
+        } else {
+            None
+        }
+    }
+
+    /// Unwrap the pointer without running the destructor
+    ///
+    /// This method retrieves the underlying pointer, and in the process
+    /// destroys the CVec but without running the destructor. A use case
+    /// would be transferring ownership of the buffer to a C function, as
+    /// in this case you would not want to run the destructor.
+    ///
+    /// Note that if you want to access the underlying pointer without
+    /// cancelling the destructor, you can simply call `transmute` on the return
+    /// value of `get(0)`.
+    pub unsafe fn unwrap(mut self) -> *mut T {
+        self.dtor = None;
+        self.base
+    }
+}
+
+impl<T> Container for CVec<T> {
+    fn len(&self) -> uint { self.len }
+}
+
+#[cfg(test)]
+mod tests {
+    use prelude::*;
+
+    use super::CVec;
+    use libc;
+    use ptr;
+    use rt::global_heap::malloc_raw;
+
+    fn malloc(n: uint) -> CVec<u8> {
+        unsafe {
+            let mem = malloc_raw(n);
+
+            CVec::new_with_dtor(mem as *mut u8, n,
+                proc() { libc::free(mem as *mut libc::c_void); })
+        }
+    }
+
+    #[test]
+    fn test_basic() {
+        let mut cv = malloc(16);
+
+        *cv.get_mut(3).unwrap() = 8;
+        *cv.get_mut(4).unwrap() = 9;
+        assert_eq!(*cv.get(3).unwrap(), 8);
+        assert_eq!(*cv.get(4).unwrap(), 9);
+        assert_eq!(cv.len(), 16);
+    }
+
+    #[test]
+    #[should_fail]
+    fn test_fail_at_null() {
+        unsafe {
+            CVec::new(ptr::mut_null::<u8>(), 9);
+        }
+    }
+
+    #[test]
+    fn test_overrun_get() {
+        let cv = malloc(16);
+
+        assert!(cv.get(17).is_none());
+    }
+
+    #[test]
+    fn test_overrun_set() {
+        let mut cv = malloc(16);
+
+        assert!(cv.get_mut(17).is_none());
+    }
+
+    #[test]
+    fn test_unwrap() {
+        unsafe {
+            let cv = CVec::new_with_dtor(1 as *mut int, 0,
+                proc() { fail!("Don't run this destructor!") });
+            let p = cv.unwrap();
+            assert_eq!(p, 1 as *mut int);
+        }
+    }
+
+}
index 39c7932cdc8f2e53a5009db979bcae8f2b149dec..243f7b2055f397d0a95e47a60185e76cafcb6e15 100644 (file)
@@ -97,6 +97,6 @@ pub unsafe fn annihilate() {
 
     if debug_mem() {
         // We do logging here w/o allocation.
-        debug!("total boxes annihilated: {}", n_total_boxes);
+        println!("total boxes annihilated: {}", n_total_boxes);
     }
 }
index 6975c9da3f08ba150b105ae549c579cd26826955..5130da44ed5779859bd32481090d5e51a224bf5d 100644 (file)
@@ -130,18 +130,6 @@ fn cmp(&self, other: &$t) -> Ordering {
 
 totalord_impl!(char)
 
-/// Compares (a1, b1) against (a2, b2), where the a values are more significant.
-pub fn cmp2<A:TotalOrd,B:TotalOrd>(
-    a1: &A, b1: &B,
-    a2: &A, b2: &B) -> Ordering
-{
-    match a1.cmp(a2) {
-        Less => Less,
-        Greater => Greater,
-        Equal => b1.cmp(b2)
-    }
-}
-
 /**
 Return `o1` if it is not `Equal`, otherwise `o2`. Simulates the
 lexical ordering on a type `(int, int)`.
@@ -184,12 +172,12 @@ pub trait Equiv<T> {
 }
 
 #[inline]
-pub fn min<T:Ord>(v1: T, v2: T) -> T {
+pub fn min<T: TotalOrd>(v1: T, v2: T) -> T {
     if v1 < v2 { v1 } else { v2 }
 }
 
 #[inline]
-pub fn max<T:Ord>(v1: T, v2: T) -> T {
+pub fn max<T: TotalOrd>(v1: T, v2: T) -> T {
     if v1 > v2 { v1 } else { v2 }
 }
 
@@ -206,14 +194,6 @@ fn test_int_totalord() {
         assert_eq!(12.cmp(-5), Greater);
     }
 
-    #[test]
-    fn test_cmp2() {
-        assert_eq!(cmp2(1, 2, 3, 4), Less);
-        assert_eq!(cmp2(3, 2, 3, 4), Less);
-        assert_eq!(cmp2(5, 2, 3, 4), Greater);
-        assert_eq!(cmp2(5, 5, 5, 4), Greater);
-    }
-
     #[test]
     fn test_int_totaleq() {
         assert!(5.equals(&5));
index 869643336a94cd3351d6dfaac76bbe90346616a2..c18d4e273c4773c1e3cfaf7a79e06dde01eae0ee 100644 (file)
@@ -241,40 +241,31 @@ fn file_product(p: &Path) -> IoResult<u32> {
 pub use self::net::udp::UdpStream;
 pub use self::pipe::PipeStream;
 pub use self::process::{Process, ProcessConfig};
+pub use self::tempfile::TempDir;
 
 pub use self::mem::{MemReader, BufReader, MemWriter, BufWriter};
 pub use self::buffered::{BufferedReader, BufferedWriter, BufferedStream,
                          LineBufferedWriter};
 pub use self::comm_adapters::{ChanReader, ChanWriter};
 
+// this comes first to get the iotest! macro
 pub mod test;
 
+mod buffered;
+mod comm_adapters;
+mod mem;
+mod result;
+mod tempfile;
+pub mod extensions;
 pub mod fs;
-
+pub mod net;
 pub mod pipe;
-
 pub mod process;
-
-pub mod net;
-
-mod mem;
-
+pub mod signal;
 pub mod stdio;
-
-mod result;
-
-pub mod extensions;
-
 pub mod timer;
-
-mod buffered;
-
-pub mod signal;
-
 pub mod util;
 
-mod comm_adapters;
-
 /// The default buffer size for various I/O operations
 // libuv recommends 64k buffers to maximize throughput
 // https://groups.google.com/forum/#!topic/libuv/oQO1HJAIDdA
@@ -361,9 +352,7 @@ fn read_byte(&mut self) -> IoResult<u8> {
         let mut buf = [0];
         loop {
             match self.read(buf) {
-                Ok(0) => {
-                    debug!("read 0 bytes. trying again");
-                }
+                Ok(0) => {}
                 Ok(1) => return Ok(buf[0]),
                 Ok(_) => unreachable!(),
                 Err(e) => return Err(e)
index edadbc7873ac04087f526c340e9c1b7ca7def208..7b1dd114d348f716940d12b0f400806d427219ac 100644 (file)
@@ -710,5 +710,23 @@ pub fn peer_name(addr: SocketAddr) {
 
         rx.recv();
     })
+
+    iotest!(fn shutdown_smoke() {
+        use rt::rtio::RtioTcpStream;
+
+        let addr = next_test_ip4();
+        let a = TcpListener::bind(addr).unwrap().listen();
+        spawn(proc() {
+            let mut a = a;
+            let mut c = a.accept().unwrap();
+            assert_eq!(c.read_to_end(), Ok(~[]));
+            c.write([1]).unwrap();
+        });
+
+        let mut s = TcpStream::connect(addr).unwrap();
+        assert!(s.obj.close_write().is_ok());
+        assert!(s.write([1]).is_err());
+        assert_eq!(s.read_to_end(), Ok(~[1]));
+    })
 }
 
diff --git a/src/libstd/io/tempfile.rs b/src/libstd/io/tempfile.rs
new file mode 100644 (file)
index 0000000..34d6b19
--- /dev/null
@@ -0,0 +1,93 @@
+// 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.
+
+//! Temporary files and directories
+
+use io::fs;
+use io;
+use iter::{Iterator, range};
+use libc;
+use ops::Drop;
+use option::{Option, None, Some};
+use os;
+use path::{Path, GenericPath};
+use result::{Ok, Err};
+use sync::atomics;
+
+/// A wrapper for a path to temporary directory implementing automatic
+/// scope-based deletion.
+pub struct TempDir {
+    priv path: Option<Path>
+}
+
+impl TempDir {
+    /// Attempts to make a temporary directory inside of `tmpdir` whose name
+    /// will have the suffix `suffix`. The directory will be automatically
+    /// deleted once the returned wrapper is destroyed.
+    ///
+    /// If no directory can be created, None is returned.
+    pub fn new_in(tmpdir: &Path, suffix: &str) -> Option<TempDir> {
+        if !tmpdir.is_absolute() {
+            return TempDir::new_in(&os::make_absolute(tmpdir), suffix);
+        }
+
+        static mut CNT: atomics::AtomicUint = atomics::INIT_ATOMIC_UINT;
+
+        for _ in range(0u, 1000) {
+            let filename = format!("rs-{}-{}-{}",
+                                   unsafe { libc::getpid() },
+                                   unsafe { CNT.fetch_add(1, atomics::SeqCst) },
+                                   suffix);
+            let p = tmpdir.join(filename);
+            match fs::mkdir(&p, io::UserRWX) {
+                Err(..) => {}
+                Ok(()) => return Some(TempDir { path: Some(p) })
+            }
+        }
+        None
+    }
+
+    /// Attempts to make a temporary directory inside of `os::tmpdir()` whose
+    /// name will have the suffix `suffix`. The directory will be automatically
+    /// deleted once the returned wrapper is destroyed.
+    ///
+    /// If no directory can be created, None is returned.
+    pub fn new(suffix: &str) -> Option<TempDir> {
+        TempDir::new_in(&os::tmpdir(), suffix)
+    }
+
+    /// Unwrap the wrapped `std::path::Path` from the `TempDir` wrapper.
+    /// This discards the wrapper so that the automatic deletion of the
+    /// temporary directory is prevented.
+    pub fn unwrap(self) -> Path {
+        let mut tmpdir = self;
+        tmpdir.path.take_unwrap()
+    }
+
+    /// Access the wrapped `std::path::Path` to the temporary directory.
+    pub fn path<'a>(&'a self) -> &'a Path {
+        self.path.get_ref()
+    }
+}
+
+impl Drop for TempDir {
+    fn drop(&mut self) {
+        for path in self.path.iter() {
+            if path.exists() {
+                // FIXME: is failing the right thing to do?
+                fs::rmdir_recursive(path).unwrap();
+            }
+        }
+    }
+}
+
+// the tests for this module need to change the path using change_dir,
+// and this doesn't play nicely with other tests so these unit tests are located
+// in src/test/run-pass/tempfile.rs
index a3e5bac89d6deba6eebff522f4468eab8f5e76e3..9eeaf4635a482022c398c7d83bc39782d02a03a6 100644 (file)
@@ -176,16 +176,14 @@ pub unsafe fn raise_fd_limit() {
         if sysctl(&mut mib[0], 2, &mut maxfiles as *mut libc::c_int as *mut libc::c_void, &mut size,
                   mut_null(), 0) != 0 {
             let err = last_os_error();
-            error!("raise_fd_limit: error calling sysctl: {}", err);
-            return;
+            fail!("raise_fd_limit: error calling sysctl: {}", err);
         }
 
         // Fetch the current resource limits
         let mut rlim = rlimit{rlim_cur: 0, rlim_max: 0};
         if getrlimit(RLIMIT_NOFILE, &mut rlim) != 0 {
             let err = last_os_error();
-            error!("raise_fd_limit: error calling getrlimit: {}", err);
-            return;
+            fail!("raise_fd_limit: error calling getrlimit: {}", err);
         }
 
         // Bump the soft limit to the smaller of kern.maxfilesperproc and the hard limit
@@ -194,8 +192,7 @@ pub unsafe fn raise_fd_limit() {
         // Set our newly-increased resource limit
         if setrlimit(RLIMIT_NOFILE, &rlim) != 0 {
             let err = last_os_error();
-            error!("raise_fd_limit: error calling setrlimit: {}", err);
-            return;
+            fail!("raise_fd_limit: error calling setrlimit: {}", err);
         }
     }
 }
index 11d7bc6c1bf8973cf79e4b3186abbd91c42a766c..9e988eb4094eeceb2383d132a4e481b617e28aa0 100644 (file)
@@ -68,7 +68,7 @@ trait defined in this module. For loops can be viewed as a syntactical expansion
 use num::{Zero, One, CheckedAdd, CheckedSub, Saturating, ToPrimitive, Int};
 use option::{Option, Some, None};
 use ops::{Add, Mul, Sub};
-use cmp::{Eq, Ord};
+use cmp::{Eq, Ord, TotalOrd};
 use clone::Clone;
 use uint;
 use mem;
@@ -398,9 +398,9 @@ fn fuse(self) -> Fuse<Self> {
     /// let xs = [1u, 4, 2, 3, 8, 9, 6];
     /// let sum = xs.iter()
     ///             .map(|&x| x)
-    ///             .inspect(|&x| debug!("filtering {}", x))
+    ///             .inspect(|&x| println!("filtering {}", x))
     ///             .filter(|&x| x % 2 == 0)
-    ///             .inspect(|&x| debug!("{} made it through", x))
+    ///             .inspect(|&x| println!("{} made it through", x))
     ///             .sum();
     /// println!("{}", sum);
     /// ```
@@ -626,7 +626,7 @@ fn count(&mut self, predicate: |A| -> bool) -> uint {
     /// assert_eq!(*xs.iter().max_by(|x| x.abs()).unwrap(), -10);
     /// ```
     #[inline]
-    fn max_by<B: Ord>(&mut self, f: |&A| -> B) -> Option<A> {
+    fn max_by<B: TotalOrd>(&mut self, f: |&A| -> B) -> Option<A> {
         self.fold(None, |max: Option<(A, B)>, x| {
             let x_val = f(&x);
             match max {
@@ -650,7 +650,7 @@ fn max_by<B: Ord>(&mut self, f: |&A| -> B) -> Option<A> {
     /// assert_eq!(*xs.iter().min_by(|x| x.abs()).unwrap(), 0);
     /// ```
     #[inline]
-    fn min_by<B: Ord>(&mut self, f: |&A| -> B) -> Option<A> {
+    fn min_by<B: TotalOrd>(&mut self, f: |&A| -> B) -> Option<A> {
         self.fold(None, |min: Option<(A, B)>, x| {
             let x_val = f(&x);
             match min {
@@ -917,7 +917,7 @@ pub trait OrdIterator<A> {
     fn min_max(&mut self) -> MinMaxResult<A>;
 }
 
-impl<A: Ord, T: Iterator<A>> OrdIterator<A> for T {
+impl<A: TotalOrd, T: Iterator<A>> OrdIterator<A> for T {
     #[inline]
     fn max(&mut self) -> Option<A> {
         self.fold(None, |max, x| {
index a873eccfb038a756737a9af9a695c09287953b96..17c0e2235c0bf91a8d0f082211f7324f62a26126 100644 (file)
@@ -53,7 +53,7 @@
       html_root_url = "http://static.rust-lang.org/doc/master")];
 
 #[feature(macro_rules, globs, asm, managed_boxes, thread_local, link_args,
-          simd, linkage, default_type_params)];
+          simd, linkage, default_type_params, phase)];
 
 // NOTE remove the following two attributes after the next snapshot.
 #[allow(unrecognized_lint)];
@@ -65,6 +65,7 @@
 #[deny(non_camel_case_types)];
 #[deny(missing_doc)];
 #[allow(unknown_features)];
+#[allow(deprecated_owned_vector)];
 
 // When testing libstd, bring in libuv as the I/O backend so tests can print
 // things and all of the std::io tests have an I/O interface to run on top
 #[cfg(test)] extern crate rustuv;
 #[cfg(test)] extern crate native;
 #[cfg(test)] extern crate green;
+#[cfg(test)] #[phase(syntax, link)] extern crate log;
 
-// Make extra and rand accessible for benchmarking/testcases
+// Make and rand accessible for benchmarking/testcases
 #[cfg(test)] extern crate rand;
-#[cfg(test)] extern crate extra = "extra";
 
 // Make std testable by not duplicating lang items. See #2912
 #[cfg(test)] extern crate realstd = "std";
 #[unstable]
 pub mod libc;
 pub mod c_str;
+pub mod c_vec;
 pub mod os;
 pub mod io;
 pub mod path;
 pub mod cast;
 pub mod fmt;
 pub mod cleanup;
-pub mod logging;
 pub mod mem;
 
 
@@ -220,7 +221,6 @@ mod std {
     pub use io;
     pub use kinds;
     pub use local_data;
-    pub use logging;
     pub use option;
     pub use os;
     pub use rt;
index c602c2fc27f8e5da236bb5f57a5cea9a3d49746d..0fb7a5f85032cb93f7d9868573ffdcf6eec3b733 100644 (file)
@@ -1611,6 +1611,10 @@ pub mod bsd44 {
             pub static SO_KEEPALIVE: c_int = 8;
             pub static SO_BROADCAST: c_int = 32;
             pub static SO_REUSEADDR: c_int = 4;
+
+            pub static SHUT_RD: c_int = 0;
+            pub static SHUT_WR: c_int = 1;
+            pub static SHUT_RDWR: c_int = 2;
         }
         pub mod extra {
             use libc::types::os::arch::c95::c_int;
@@ -2133,7 +2137,7 @@ pub mod posix88 {
             pub static MAP_SHARED : c_int = 0x0001;
             pub static MAP_PRIVATE : c_int = 0x0002;
             pub static MAP_FIXED : c_int = 0x0010;
-            pub static MAP_ANON : c_int = 0x0020;
+            pub static MAP_ANON : c_int = 0x0800;
 
             pub static MAP_FAILED : *c_void = -1 as *c_void;
 
@@ -2391,6 +2395,10 @@ pub mod bsd44 {
             pub static SO_KEEPALIVE: c_int = 9;
             pub static SO_BROADCAST: c_int = 6;
             pub static SO_REUSEADDR: c_int = 2;
+
+            pub static SHUT_RD: c_int = 0;
+            pub static SHUT_WR: c_int = 1;
+            pub static SHUT_RDWR: c_int = 2;
         }
         #[cfg(target_arch = "x86")]
         #[cfg(target_arch = "x86_64")]
@@ -2425,20 +2433,19 @@ pub mod extra {
             pub static O_DSYNC : c_int = 16;
             pub static O_SYNC : c_int = 16400;
 
-            pub static PROT_GROWSDOWN : c_int = 0x010000000;
-            pub static PROT_GROWSUP : c_int = 0x020000000;
+            pub static PROT_GROWSDOWN : c_int = 0x01000000;
+            pub static PROT_GROWSUP : c_int = 0x02000000;
 
             pub static MAP_TYPE : c_int = 0x000f;
-            pub static MAP_ANONONYMOUS : c_int = 0x0020;
-            pub static MAP_32BIT : c_int = 0x0040;
-            pub static MAP_GROWSDOWN : c_int = 0x0100;
-            pub static MAP_DENYWRITE : c_int = 0x0800;
-            pub static MAP_EXECUTABLE : c_int = 0x01000;
-            pub static MAP_LOCKED : c_int = 0x02000;
-            pub static MAP_NONRESERVE : c_int = 0x04000;
-            pub static MAP_POPULATE : c_int = 0x08000;
-            pub static MAP_NONBLOCK : c_int = 0x010000;
-            pub static MAP_STACK : c_int = 0x020000;
+            pub static MAP_ANONONYMOUS : c_int = 0x0800;
+            pub static MAP_GROWSDOWN : c_int = 0x01000;
+            pub static MAP_DENYWRITE : c_int = 0x02000;
+            pub static MAP_EXECUTABLE : c_int = 0x04000;
+            pub static MAP_LOCKED : c_int = 0x08000;
+            pub static MAP_NONRESERVE : c_int = 0x0400;
+            pub static MAP_POPULATE : c_int = 0x010000;
+            pub static MAP_NONBLOCK : c_int = 0x020000;
+            pub static MAP_STACK : c_int = 0x040000;
         }
         #[cfg(target_os = "linux")]
         pub mod sysconf {
@@ -2842,6 +2849,10 @@ pub mod bsd44 {
             pub static SO_KEEPALIVE: c_int = 0x0008;
             pub static SO_BROADCAST: c_int = 0x0020;
             pub static SO_REUSEADDR: c_int = 0x0004;
+
+            pub static SHUT_RD: c_int = 0;
+            pub static SHUT_WR: c_int = 1;
+            pub static SHUT_RDWR: c_int = 2;
         }
         pub mod extra {
             use libc::types::os::arch::c95::c_int;
@@ -3221,6 +3232,10 @@ pub mod bsd44 {
             pub static SO_KEEPALIVE: c_int = 0x0008;
             pub static SO_BROADCAST: c_int = 0x0020;
             pub static SO_REUSEADDR: c_int = 0x0004;
+
+            pub static SHUT_RD: c_int = 0;
+            pub static SHUT_WR: c_int = 1;
+            pub static SHUT_RDWR: c_int = 2;
         }
         pub mod extra {
             use libc::types::os::arch::c95::c_int;
@@ -3918,6 +3933,7 @@ pub fn recvfrom(socket: c_int, buf: *mut c_void, len: size_t,
             pub fn sendto(socket: c_int, buf: *c_void, len: size_t,
                           flags: c_int, addr: *sockaddr,
                           addrlen: socklen_t) -> ssize_t;
+            pub fn shutdown(socket: c_int, how: c_int) -> c_int;
         }
     }
 
@@ -3954,6 +3970,7 @@ pub fn recvfrom(socket: SOCKET, buf: *mut c_void, len: c_int,
             pub fn sendto(socket: SOCKET, buf: *c_void, len: c_int,
                           flags: c_int, addr: *sockaddr,
                           addrlen: c_int) -> c_int;
+            pub fn shutdown(socket: SOCKET, how: c_int) -> c_int;
         }
     }
 
diff --git a/src/libstd/logging.rs b/src/libstd/logging.rs
deleted file mode 100644 (file)
index 2271a7c..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-/*!
-
-Utilities for program-wide and customizable logging
-
-This module is used by the compiler when emitting output for the logging family
-of macros. The methods of this module shouldn't necessarily be used directly,
-but rather through the logging macros defined.
-
-There are five macros that the logging subsystem uses:
-
-* `log!(level, ...)` - the generic logging macro, takes a level as a u32 and any
-                       related `format!` arguments
-* `debug!(...)` - a macro hard-wired to the log level of `DEBUG`
-* `info!(...)` - a macro hard-wired to the log level of `INFO`
-* `warn!(...)` - a macro hard-wired to the log level of `WARN`
-* `error!(...)` - a macro hard-wired to the log level of `ERROR`
-
-All of these macros use the same style of syntax as the `format!` syntax
-extension. Details about the syntax can be found in the documentation of
-`std::fmt` along with the Rust tutorial/manual.
-
-If you want to check at runtime if a given logging level is enabled (e.g. if the
-information you would want to log is expensive to produce), you can use the
-following macro:
-
-* `log_enabled!(level)` - returns true if logging of the given level is enabled
-
-## Enabling logging
-
-Log levels are controlled on a per-module basis, and by default all logging is
-disabled except for `error!` (a log level of 1). Logging is controlled via the
-`RUST_LOG` environment variable. The value of this environment variable is a
-comma-separated list of logging directives. A logging directive is of the form:
-
-```ignore
-path::to::module=log_level
-```
-
-The path to the module is rooted in the name of the crate it was compiled for,
-so if your program is contained in a file `hello.rs`, for example, to turn on
-logging for this file you would use a value of `RUST_LOG=hello`. Furthermore,
-this path is a prefix-search, so all modules nested in the specified module will
-also have logging enabled.
-
-The actual `log_level` is optional to specify. If omitted, all logging will be
-enabled. If specified, the it must be either a numeric in the range of 1-255, or
-it must be one of the strings `debug`, `error`, `info`, or `warn`. If a numeric
-is specified, then all logging less than or equal to that numeral is enabled.
-For example, if logging level 3 is active, error, warn, and info logs will be
-printed, but debug will be omitted.
-
-As the log level for a module is optional, the module to enable logging for is
-also optional. If only a `log_level` is provided, then the global log level for
-all modules is set to this value.
-
-Some examples of valid values of `RUST_LOG` are:
-
-```ignore
-hello                // turns on all logging for the 'hello' module
-info                 // turns on all info logging
-hello=debug          // turns on debug logging for 'hello'
-hello=3              // turns on info logging for 'hello'
-hello,std::option    // turns on hello, and std's option logging
-error,hello=warn     // turn on global error logging and also warn for hello
-```
-
-## Performance and Side Effects
-
-Each of these macros will expand to code similar to:
-
-```rust,ignore
-if log_level <= my_module_log_level() {
-    ::std::logging::log(log_level, format!(...));
-}
-```
-
-What this means is that each of these macros are very cheap at runtime if
-they're turned off (just a load and an integer comparison). This also means that
-if logging is disabled, none of the components of the log will be executed.
-
-## Useful Values
-
-For convenience, if a value of `::help` is set for `RUST_LOG`, a program will
-start, print out all modules registered for logging, and then exit.
-
-*/
-
-use fmt;
-use io::LineBufferedWriter;
-use io;
-use io::Writer;
-use mem::replace;
-use ops::Drop;
-use option::{Some, None, Option};
-use prelude::drop;
-use result::{Ok, Err};
-use rt::local::Local;
-use rt::task::Task;
-
-/// Debug log level
-pub static DEBUG: u32 = 4;
-/// Info log level
-pub static INFO: u32 = 3;
-/// Warn log level
-pub static WARN: u32 = 2;
-/// Error log level
-pub static ERROR: u32 = 1;
-
-/// A trait used to represent an interface to a task-local logger. Each task
-/// can have its own custom logger which can respond to logging messages
-/// however it likes.
-pub trait Logger {
-    /// Logs a single message described by the `args` structure. The level is
-    /// provided in case you want to do things like color the message, etc.
-    fn log(&mut self, level: u32, args: &fmt::Arguments);
-}
-
-struct DefaultLogger {
-    handle: LineBufferedWriter<io::stdio::StdWriter>,
-}
-
-impl Logger for DefaultLogger {
-    // by default, just ignore the level
-    fn log(&mut self, _level: u32, args: &fmt::Arguments) {
-        match fmt::writeln(&mut self.handle, args) {
-            Err(e) => fail!("failed to log: {}", e),
-            Ok(()) => {}
-        }
-    }
-}
-
-impl Drop for DefaultLogger {
-    fn drop(&mut self) {
-        match self.handle.flush() {
-            Err(e) => fail!("failed to flush a logger: {}", e),
-            Ok(()) => {}
-        }
-    }
-}
-
-/// This function is called directly by the compiler when using the logging
-/// macros. This function does not take into account whether the log level
-/// specified is active or not, it will always log something if this method is
-/// called.
-///
-/// It is not recommended to call this function directly, rather it should be
-/// invoked through the logging family of macros.
-pub fn log(level: u32, args: &fmt::Arguments) {
-    // See io::stdio::with_task_stdout for why there's a few dances here. The
-    // gist of it is that arbitrary code can run during logging (and set an
-    // arbitrary logging handle into the task) so we need to be careful that the
-    // local task is in TLS while we're running arbitrary code.
-    let mut logger = {
-        let mut task = Local::borrow(None::<Task>);
-        task.get().logger.take()
-    };
-
-    if logger.is_none() {
-        logger = Some(~DefaultLogger { handle: io::stderr(), } as ~Logger);
-    }
-    logger.get_mut_ref().log(level, args);
-
-    let mut task = Local::borrow(None::<Task>);
-    let prev = replace(&mut task.get().logger, logger);
-    drop(task);
-    drop(prev);
-}
-
-/// Replaces the task-local logger with the specified logger, returning the old
-/// logger.
-pub fn set_logger(logger: ~Logger) -> Option<~Logger> {
-    let mut task = Local::borrow(None::<Task>);
-    replace(&mut task.get().logger, Some(logger))
-}
index ece9c1bfd20bd4ef3003d9d8e3056b877fdb60ef..6d96ea94d3115bfe220366db293cfcb20e3a56ac 100644 (file)
 
 #[macro_escape];
 
-/// The standard logging macro
-///
-/// This macro will generically log over a provided level (of type u32) with a
-/// format!-based argument list. See documentation in `std::fmt` for details on
-/// how to use the syntax, and documentation in `std::logging` for info about
-/// logging macros.
-///
-/// # Example
-///
-/// ```
-/// log!(::std::logging::DEBUG, "this is a debug message");
-/// log!(::std::logging::WARN, "this is a warning {}", "message");
-/// log!(6, "this is a custom logging level: {level}", level=6);
-/// ```
-#[macro_export]
-macro_rules! log(
-    ($lvl:expr, $($arg:tt)+) => ({
-        let lvl = $lvl;
-        if lvl <= __log_level() {
-            format_args!(|args| {
-                ::std::logging::log(lvl, args)
-            }, $($arg)+)
-        }
-    })
-)
-
-/// A convenience macro for logging at the error log level. See `std::logging`
-/// for more information. about logging.
-///
-/// # Example
-///
-/// ```
-/// # let error = 3;
-/// error!("the build has failed with error code: {}", error);
-/// ```
-#[macro_export]
-macro_rules! error(
-    ($($arg:tt)*) => (log!(1u32, $($arg)*))
-)
-
-/// A convenience macro for logging at the warning log level. See `std::logging`
-/// for more information. about logging.
-///
-/// # Example
-///
-/// ```
-/// # let code = 3;
-/// warn!("you may like to know that a process exited with: {}", code);
-/// ```
-#[macro_export]
-macro_rules! warn(
-    ($($arg:tt)*) => (log!(2u32, $($arg)*))
-)
-
-/// A convenience macro for logging at the info log level. See `std::logging`
-/// for more information. about logging.
-///
-/// # Example
-///
-/// ```
-/// # let ret = 3;
-/// info!("this function is about to return: {}", ret);
-/// ```
-#[macro_export]
-macro_rules! info(
-    ($($arg:tt)*) => (log!(3u32, $($arg)*))
-)
-
-/// A convenience macro for logging at the debug log level. See `std::logging`
-/// for more information. about logging.
-///
-/// # Example
-///
-/// ```
-/// debug!("x = {x}, y = {y}", x=10, y=20);
-/// ```
-#[macro_export]
-macro_rules! debug(
-    ($($arg:tt)*) => (if cfg!(not(ndebug)) { log!(4u32, $($arg)*) })
-)
-
-/// A macro to test whether a log level is enabled for the current module.
-///
-/// # Example
-///
-/// ```
-/// # struct Point { x: int, y: int }
-/// # fn some_expensive_computation() -> Point { Point { x: 1, y: 2 } }
-/// if log_enabled!(std::logging::DEBUG) {
-///     let x = some_expensive_computation();
-///     debug!("x.x = {}, x.y = {}", x.x, x.y);
-/// }
-/// ```
-#[macro_export]
-macro_rules! log_enabled(
-    ($lvl:expr) => ({
-        let lvl = $lvl;
-        lvl <= __log_level() && (lvl != 4 || cfg!(not(ndebug)))
-    })
-)
-
 /// The entry point for failure of rust tasks.
 ///
 /// This macro is used to inject failure into a rust task, causing the task to
@@ -421,3 +320,15 @@ macro_rules! select {
         { unreachable!() }
     })
 }
+
+// When testing the standard library, we link to the liblog crate to get the
+// logging macros. In doing so, the liblog crate was linked against the real
+// version of libstd, and uses a different std::fmt module than the test crate
+// uses. To get around this difference, we redefine the log!() macro here to be
+// just a dumb version of what it should be.
+#[cfg(test)]
+macro_rules! log (
+    ($lvl:expr, $($args:tt)*) => (
+        if log_enabled!($lvl) { println!($($args)*) }
+    )
+)
index 31605ca961e6ac1de5b761dc2642fa688dee84cb..e4d843d88824d381a9aaa518725994e2ae0c2170 100644 (file)
@@ -104,7 +104,7 @@ pub fn as_slice<'r>(&'r self) -> &'r [T] {
         }
     }
 
-    /// Convert from `Option<T>` to `&[T]` (without copying)
+    /// Convert from `Option<T>` to `&mut [T]` (without copying)
     #[inline]
     pub fn as_mut_slice<'r>(&'r mut self) -> &'r mut [T] {
         match *self {
@@ -211,19 +211,13 @@ pub fn mutate_or_set(&mut self, def: T, f: |T| -> T) -> bool {
     /// Return an iterator over the possibly contained value
     #[inline]
     pub fn iter<'r>(&'r self) -> Item<&'r T> {
-        match *self {
-            Some(ref x) => Item{opt: Some(x)},
-            None => Item{opt: None}
-        }
+        Item{opt: self.as_ref()}
     }
 
     /// Return a mutable iterator over the possibly contained value
     #[inline]
     pub fn mut_iter<'r>(&'r mut self) -> Item<&'r mut T> {
-        match *self {
-            Some(ref mut x) => Item{opt: Some(x)},
-            None => Item{opt: None}
-        }
+        Item{opt: self.as_mut()}
     }
 
     /// Return a consuming iterator over the possibly contained value
@@ -295,10 +289,13 @@ pub fn filtered(self, f: |t: &T| -> bool) -> Option<T> {
 
     /// Applies a function zero or more times until the result is `None`.
     #[inline]
-    pub fn while_some(self, blk: |v: T| -> Option<T>) {
+    pub fn while_some(self, f: |v: T| -> Option<T>) {
         let mut opt = self;
-        while opt.is_some() {
-            opt = blk(opt.unwrap());
+        loop {
+            match opt {
+                Some(x) => opt = f(x),
+                None => break
+            }
         }
     }
 
@@ -314,10 +311,10 @@ pub fn while_some(self, blk: |v: T| -> Option<T>) {
     /// Fails if the value equals `None`.
     #[inline]
     pub fn take_unwrap(&mut self) -> T {
-        if self.is_none() {
-            fail!("called `Option::take_unwrap()` on a `None` value")
+        match self.take() {
+            Some(x) => x,
+            None => fail!("called `Option::take_unwrap()` on a `None` value")
         }
-        self.take().unwrap()
     }
 
     /// Gets an immutable reference to the value inside an option.
index 3a86aa3d6b68943860a30c8480a9e8a2d3d661fa..040d5c0e175fb0cc827dcc69b72f359b428e6bd4 100644 (file)
@@ -1127,14 +1127,8 @@ fn drop(&mut self) {
         if self.len == 0 { /* workaround for dummy_stack */ return; }
 
         unsafe {
-            match libc::munmap(self.data as *c_void, self.len as libc::size_t) {
-                0 => (),
-                -1 => match errno() as c_int {
-                    libc::EINVAL => error!("invalid addr or len"),
-                    e => error!("unknown errno={}", e)
-                },
-                r => error!("Unexpected result {}", r)
-            }
+            // FIXME: what to do if this fails?
+            let _ = libc::munmap(self.data as *c_void, self.len as libc::size_t);
         }
     }
 }
@@ -1161,10 +1155,7 @@ pub fn new(min_len: uint, options: &[MapOption]) -> Result<MemoryMap, MapError>
                 MapAddr(addr_) => { lpAddress = addr_ as LPVOID; },
                 MapFd(fd_) => { fd = fd_; },
                 MapOffset(offset_) => { offset = offset_; },
-                MapNonStandardFlags(f) => {
-                    info!("MemoryMap::new: MapNonStandardFlags used on \
-                           Windows: {}", f)
-                }
+                MapNonStandardFlags(..) => {}
             }
         }
 
@@ -1262,15 +1253,15 @@ fn drop(&mut self) {
                 MapVirtual => {
                     if libc::VirtualFree(self.data as *mut c_void, 0,
                                          libc::MEM_RELEASE) == 0 {
-                        error!("VirtualFree failed: {}", errno());
+                        println!("VirtualFree failed: {}", errno());
                     }
                 },
                 MapFile(mapping) => {
                     if libc::UnmapViewOfFile(self.data as LPCVOID) == FALSE {
-                        error!("UnmapViewOfFile failed: {}", errno());
+                        println!("UnmapViewOfFile failed: {}", errno());
                     }
                     if libc::CloseHandle(mapping as HANDLE) == FALSE {
-                        error!("CloseHandle failed: {}", errno());
+                        println!("CloseHandle failed: {}", errno());
                     }
                 }
             }
@@ -1392,7 +1383,6 @@ mod tests {
     use rand::Rng;
     use rand;
 
-
     #[test]
     pub fn last_os_error() {
         debug!("{}", os::last_os_error());
index 95eda1cecc09ebbc01dd15be78dd03968b0d36ed..bf5ba6db5c3efde334884a7228e1c4e4f2e39434 100644 (file)
@@ -163,7 +163,6 @@ pub unsafe fn read_and_zero<T>(dest: *mut T) -> T {
   SAFETY NOTE: Pointer-arithmetic. Dragons be here.
 */
 pub unsafe fn array_each_with_len<T>(arr: **T, len: uint, cb: |*T|) {
-    debug!("array_each_with_len: before iterate");
     if arr.is_null() {
         fail!("ptr::array_each_with_len failure: arr input is null pointer");
     }
@@ -172,7 +171,6 @@ pub unsafe fn array_each_with_len<T>(arr: **T, len: uint, cb: |*T|) {
         let n = arr.offset(e as int);
         cb(*n);
     }
-    debug!("array_each_with_len: after iterate");
 }
 
 /**
@@ -189,7 +187,6 @@ pub unsafe fn array_each<T>(arr: **T, cb: |*T|) {
         fail!("ptr::array_each_with_len failure: arr input is null pointer");
     }
     let len = buf_len(arr);
-    debug!("array_each inferred len: {}", len);
     array_each_with_len(arr, len, cb);
 }
 
index fc91d8189f017baba88d08338fe5938a1e2513d8..bc75a98e0856597eca04a20782e716de17e2b836 100644 (file)
 use io::{IoResult, Writer};
 use iter::Iterator;
 use option::{Some, None};
+use os;
 use result::{Ok, Err};
 use str::StrSlice;
+use sync::atomics;
 
 pub use self::imp::write;
 
-// This function is defined in this module so that the way to enable logging of
-// backtraces has the word 'backtrace' in it: std::rt::backtrace.
+// For now logging is turned off by default, and this function checks to see
+// whether the magical environment variable is present to see if it's turned on.
 pub fn log_enabled() -> bool {
-    log_enabled!(::logging::DEBUG)
+    static mut ENABLED: atomics::AtomicInt = atomics::INIT_ATOMIC_INT;
+    unsafe {
+        match ENABLED.load(atomics::SeqCst) {
+            1 => return false,
+            2 => return true,
+            _ => {}
+        }
+    }
+
+    let val = match os::getenv("RUST_BACKTRACE") {
+        Some(..) => 2,
+        None => 1,
+    };
+    unsafe { ENABLED.store(val, atomics::SeqCst); }
+    val == 2
 }
 
 #[cfg(target_word_size = "64")] static HEX_WIDTH: uint = 18;
@@ -91,8 +107,47 @@ fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
                 rest = rest.slice_from(1);
             }
             let i: uint = from_str(s.slice_to(s.len() - rest.len())).unwrap();
-            try!(writer.write_str(rest.slice_to(i)));
             s = rest.slice_from(i);
+            rest = rest.slice_to(i);
+            loop {
+                if rest.starts_with("$") {
+                    macro_rules! demangle(
+                        ($($pat:expr => $demangled:expr),*) => ({
+                            $(if rest.starts_with($pat) {
+                                try!(writer.write_str($demangled));
+                                rest = rest.slice_from($pat.len());
+                              } else)*
+                            {
+                                try!(writer.write_str(rest));
+                                break;
+                            }
+
+                        })
+                    )
+                    // see src/librustc/back/link.rs for these mappings
+                    demangle! (
+                        "$SP$" => "@",
+                        "$UP$" => "~",
+                        "$RP$" => "*",
+                        "$BP$" => "&",
+                        "$LT$" => "<",
+                        "$GT$" => ">",
+                        "$LP$" => "(",
+                        "$RP$" => ")",
+                        "$C$"  => ",",
+
+                        // in theory we can demangle any unicode code point, but
+                        // for simplicity we just catch the common ones.
+                        "$x20" => " ",
+                        "$x27" => "'",
+                        "$x5b" => "[",
+                        "$x5d" => "]"
+                    )
+                } else {
+                    try!(writer.write_str(rest));
+                    break;
+                }
+            }
         }
     }
 
@@ -698,17 +753,25 @@ mod test {
     use io::MemWriter;
     use str;
 
+    macro_rules! t( ($a:expr, $b:expr) => ({
+        let mut m = MemWriter::new();
+        super::demangle(&mut m, $a).unwrap();
+        assert_eq!(str::from_utf8_owned(m.unwrap()).unwrap(), $b.to_owned());
+    }) )
+
     #[test]
     fn demangle() {
-        macro_rules! t( ($a:expr, $b:expr) => ({
-            let mut m = MemWriter::new();
-            super::demangle(&mut m, $a);
-            assert_eq!(str::from_utf8_owned(m.unwrap()).unwrap(), $b.to_owned());
-        }) )
-
         t!("test", "test");
         t!("_ZN4testE", "test");
         t!("_ZN4test", "_ZN4test");
         t!("_ZN4test1a2bcE", "test::a::bc");
     }
+
+    #[test]
+    fn demangle_dollars() {
+        t!("_ZN4$UP$E", "~");
+        t!("_ZN8$UP$testE", "~test");
+        t!("_ZN8$UP$test4foobE", "~test::foob");
+        t!("_ZN8$x20test4foobE", " test::foob");
+    }
 }
index ff54a80ce997f9900bc9959a8be32729802ea534..c6d5a80208b1f98359dd4896448478558001beda 100644 (file)
@@ -9,13 +9,14 @@
 // except according to those terms.
 
 use cast;
-use cmp::TotalOrd;
-use container::MutableSet;
-use iter::Iterator;
 use option::{Some, None, Option};
 use ptr::RawPtr;
 use rt::rtio::EventLoop;
-use vec::{ImmutableVector, OwnedVector};
+
+#[cfg(stage0)] use cmp::TotalOrd;
+#[cfg(stage0)] use container::MutableSet;
+#[cfg(stage0)] use iter::Iterator;
+#[cfg(stage0)] use vec::{ImmutableVector, OwnedVector};
 
 // Need to tell the linker on OS X to not barf on undefined symbols
 // and instead look them up at runtime, which we need to resolve
 #[link_args = "-Wl,-U,__rust_crate_map_toplevel"]
 extern {}
 
+#[cfg(stage0)]
 pub struct ModEntry<'a> {
     name: &'a str,
     log_level: *mut u32
 }
 
+#[cfg(stage0)]
 pub struct CrateMap<'a> {
     version: i32,
     entries: &'a [ModEntry<'a>],
     children: &'a [&'a CrateMap<'a>],
     event_loop_factory: Option<fn() -> ~EventLoop>,
 }
+#[cfg(not(stage0))]
+pub struct CrateMap<'a> {
+    version: i32,
+    event_loop_factory: Option<fn() -> ~EventLoop>,
+}
 
 // When working on android, apparently weak symbols don't work so well for
 // finding the crate map, and neither does dlopen + dlsym. This is mainly a
@@ -114,6 +122,7 @@ pub fn get_crate_map() -> Option<&'static CrateMap<'static>> {
     }
 }
 
+#[cfg(stage0)]
 fn version(crate_map: &CrateMap) -> i32 {
     match crate_map.version {
         2 => return 2,
@@ -121,6 +130,7 @@ fn version(crate_map: &CrateMap) -> i32 {
     }
 }
 
+#[cfg(stage0)]
 fn do_iter_crate_map<'a>(
                      crate_map: &'a CrateMap<'a>,
                      f: |&'a ModEntry<'a>|,
@@ -149,87 +159,8 @@ fn do_iter_crate_map<'a>(
 }
 
 /// Iterates recursively over `crate_map` and all child crate maps
+#[cfg(stage0)]
 pub fn iter_crate_map<'a>(crate_map: &'a CrateMap<'a>, f: |&'a ModEntry<'a>|) {
     let mut v = ~[];
     do_iter_crate_map(crate_map, f, &mut v);
 }
-
-#[cfg(test)]
-mod tests {
-    use option::None;
-    use rt::crate_map::{CrateMap, ModEntry, iter_crate_map};
-
-    #[test]
-    fn iter_crate_map_duplicates() {
-        let mut level3: u32 = 3;
-
-        let entries = [
-            ModEntry { name: "c::m1", log_level: &mut level3},
-        ];
-
-        let child_crate = CrateMap {
-            version: 2,
-            entries: entries,
-            children: &[],
-            event_loop_factory: None,
-        };
-
-        let root_crate = CrateMap {
-            version: 2,
-            entries: &[],
-            children: &[&child_crate, &child_crate],
-            event_loop_factory: None,
-        };
-
-        let mut cnt = 0;
-        unsafe {
-            iter_crate_map(&root_crate, |entry| {
-                assert!(*entry.log_level == 3);
-                cnt += 1;
-            });
-            assert!(cnt == 1);
-        }
-    }
-
-    #[test]
-    fn iter_crate_map_follow_children() {
-        let mut level2: u32 = 2;
-        let mut level3: u32 = 3;
-        let child_crate2 = CrateMap {
-            version: 2,
-            entries: &[
-                ModEntry { name: "c::m1", log_level: &mut level2},
-                ModEntry { name: "c::m2", log_level: &mut level3},
-            ],
-            children: &[],
-            event_loop_factory: None,
-        };
-
-        let child_crate1 = CrateMap {
-            version: 2,
-            entries: &[
-                ModEntry { name: "t::f1", log_level: &mut 1},
-            ],
-            children: &[&child_crate2],
-            event_loop_factory: None,
-        };
-
-        let root_crate = CrateMap {
-            version: 2,
-            entries: &[
-                ModEntry { name: "t::f2", log_level: &mut 0},
-            ],
-            children: &[&child_crate1],
-            event_loop_factory: None,
-        };
-
-        let mut cnt = 0;
-        unsafe {
-            iter_crate_map(&root_crate, |entry| {
-                assert!(*entry.log_level == cnt);
-                cnt += 1;
-            });
-            assert!(cnt == 4);
-        }
-    }
-}
index bdb049fbb5f7fe30b4a8c6a646785e4d60580252..2528a22be9a003e5a5a66c75b5ec688cef4ef8c5 100644 (file)
@@ -65,6 +65,9 @@ pub enum _Unwind_Reason_Code {
 #[cfg(target_arch = "arm")]
 pub static unwinder_private_data_size: int = 20;
 
+#[cfg(target_arch = "mips")]
+pub static unwinder_private_data_size: int = 2;
+
 pub struct _Unwind_Exception {
     exception_class: _Unwind_Exception_Class,
     exception_cleanup: _Unwind_Exception_Cleanup_Fn,
@@ -98,9 +101,18 @@ pub fn _Unwind_RaiseException(exception: *_Unwind_Exception)
     pub fn _Unwind_Backtrace(trace: _Unwind_Trace_Fn,
                              trace_argument: *libc::c_void)
                 -> _Unwind_Reason_Code;
-    #[cfg(not(target_os = "android"))]
+    #[cfg(stage0, not(target_os = "android"))]
+    pub fn _Unwind_GetIP(ctx: *_Unwind_Context) -> libc::uintptr_t;
+    #[cfg(stage0, not(target_os = "android"))]
+    pub fn _Unwind_FindEnclosingFunction(pc: *libc::c_void) -> *libc::c_void;
+
+    #[cfg(not(stage0),
+          not(target_os = "android"),
+          not(target_os = "linux", target_arch = "arm"))]
     pub fn _Unwind_GetIP(ctx: *_Unwind_Context) -> libc::uintptr_t;
-    #[cfg(not(target_os = "android"))]
+    #[cfg(not(stage0),
+          not(target_os = "android"),
+          not(target_os = "linux", target_arch = "arm"))]
     pub fn _Unwind_FindEnclosingFunction(pc: *libc::c_void) -> *libc::c_void;
 }
 
@@ -108,6 +120,7 @@ pub fn _Unwind_Backtrace(trace: _Unwind_Trace_Fn,
 // of the macro. This is all copy/pasted directly from the header file with the
 // definition of _Unwind_GetIP.
 #[cfg(target_os = "android")]
+#[cfg(target_os = "linux", target_arch = "arm")]
 pub unsafe fn _Unwind_GetIP(ctx: *_Unwind_Context) -> libc::uintptr_t {
     #[repr(C)]
     enum _Unwind_VRS_Result {
@@ -149,8 +162,9 @@ fn _Unwind_VRS_Get(ctx: *_Unwind_Context,
     (val & !1) as libc::uintptr_t
 }
 
-// This function also doesn't exist on android, so make it a no-op
+// This function also doesn't exist on android or arm/linux, so make it a no-op
 #[cfg(target_os = "android")]
-pub unsafe fn _Unwind_FindEnclosingFunction(pc: *libc::c_void) -> *libc::c_void{
+#[cfg(target_os = "linux", target_arch = "arm")]
+pub unsafe fn _Unwind_FindEnclosingFunction(pc: *libc::c_void) -> *libc::c_void {
     pc
 }
diff --git a/src/libstd/rt/logging.rs b/src/libstd/rt/logging.rs
deleted file mode 100644 (file)
index aa024a5..0000000
+++ /dev/null
@@ -1,314 +0,0 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use container::Container;
-use from_str::from_str;
-use iter::Iterator;
-use libc::exit;
-use option::{Some, None, Option};
-use os;
-use rt::crate_map::{ModEntry, CrateMap, iter_crate_map, get_crate_map};
-use str::{Str, StrSlice};
-use vec::{ImmutableVector, MutableTotalOrdVector, OwnedVector};
-use vec_ng::Vec;
-
-struct LogDirective<'a> {
-    name: Option<&'a str>,
-    level: u32
-}
-
-static MAX_LOG_LEVEL: u32 = 255;
-static DEFAULT_LOG_LEVEL: u32 = 1;
-static log_level_names : &'static[&'static str] = &'static["error", "warn", "info", "debug"];
-
-/// Parse an individual log level that is either a number or a symbolic log level
-fn parse_log_level(level: &str) -> Option<u32> {
-    let num = from_str::<u32>(level);
-    let mut log_level;
-    match num {
-        Some(num) => {
-            if num < MAX_LOG_LEVEL {
-                log_level = Some(num);
-            } else {
-                log_level = Some(MAX_LOG_LEVEL);
-            }
-        }
-        _ => {
-            let position = log_level_names.iter().position(|&name| name == level);
-            match position {
-                Some(position) => {
-                    log_level = Some(::cmp::min(MAX_LOG_LEVEL, (position + 1) as u32))
-                },
-                _ => {
-                    log_level = None;
-                }
-            }
-        }
-    }
-    log_level
-}
-
-/// Parse a logging specification string (e.g: "crate1,crate2::mod3,crate3::x=1")
-/// and return a vector with log directives.
-/// Valid log levels are 0-255, with the most likely ones being 1-4 (defined in std::).
-/// Also supports string log levels of error, warn, info, and debug
-fn parse_logging_spec<'a>(spec: &'a str) -> Vec<LogDirective<'a>> {
-    let mut dirs = Vec::new();
-    for s in spec.split(',') {
-        if s.len() == 0 { continue }
-        let mut parts = s.split('=');
-        let log_level;
-        let name;
-        match (parts.next(), parts.next(), parts.next()) {
-            (Some(part0), None, None) => {
-                //if the single argument is a log-level string or number,
-                //treat that as a global fallback
-                let possible_log_level = parse_log_level(part0);
-                match possible_log_level {
-                    Some(num) => {
-                        name = None;
-                        log_level = num;
-                    },
-                    None => {
-                        log_level = MAX_LOG_LEVEL;
-                        name = Some(part0);
-                    }
-                }
-            }
-            (Some(part0), Some(part1), None) => {
-                let possible_log_level = parse_log_level(part1);
-                match possible_log_level {
-                    Some(num) => {
-                        name = Some(part0);
-                        log_level = num;
-                    },
-                    _ => {
-                        rterrln!("warning: invalid logging spec '{}', \
-                                  ignoring it", part1);
-                        continue
-                    }
-                }
-            },
-            _ => {
-                rterrln!("warning: invalid logging spec '{}', \
-                          ignoring it", s);
-                continue
-            }
-        }
-        dirs.push(LogDirective { name: name, level: log_level });
-    }
-    return dirs;
-}
-
-/// Set the log level of an entry in the crate map depending on the vector
-/// of log directives
-fn update_entry(dirs: &[LogDirective], entry: &ModEntry) -> u32 {
-    let mut new_lvl: u32 = DEFAULT_LOG_LEVEL;
-    let mut longest_match = -1i;
-    for dir in dirs.iter() {
-        match dir.name {
-            None => {
-                if longest_match == -1 {
-                    longest_match = 0;
-                    new_lvl = dir.level;
-                }
-            }
-            Some(ref dir_name) => {
-                let name = entry.name;
-                let len = dir_name.len() as int;
-                if name.starts_with(*dir_name) &&
-                    len >= longest_match {
-                    longest_match = len;
-                    new_lvl = dir.level;
-                }
-            }
-        };
-    }
-    unsafe { *entry.log_level = new_lvl; }
-    if longest_match >= 0 { return 1; } else { return 0; }
-}
-
-/// Set log level for every entry in crate_map according to the sepecification
-/// in settings
-fn update_log_settings(crate_map: &CrateMap, settings: &str) {
-    if settings == "::help" || settings == "?" {
-        rterrln!("\nCrate log map:\n");
-
-        let mut entries = Vec::new();
-        iter_crate_map(crate_map, |entry| entries.push(entry.name));
-        entries.as_mut_slice().sort();
-
-        for name in entries.iter() {
-            rterrln!(" {}", *name);
-        }
-        unsafe { exit(1); }
-    }
-    let dirs = parse_logging_spec(settings);
-
-    let mut n_matches: u32 = 0;
-    iter_crate_map(crate_map, |entry| {
-        let m = update_entry(dirs.as_slice(), entry);
-        n_matches += m;
-    });
-
-    if n_matches < (dirs.len() as u32) {
-        rterrln!("warning: got {} RUST_LOG specs but only matched\n\
-                  {} of them. You may have mistyped a RUST_LOG spec. \n\
-                  Use RUST_LOG=::help to see the list of crates and modules.\n",
-                 dirs.len(), n_matches);
-    }
-}
-
-/// Configure logging by traversing the crate map and setting the
-/// per-module global logging flags based on the logging spec
-pub fn init() {
-    let log_spec = os::getenv("RUST_LOG");
-    match get_crate_map() {
-        Some(crate_map) => {
-            match log_spec {
-                Some(spec) => update_log_settings(crate_map, spec.as_slice()),
-                None => update_log_settings(crate_map, ""),
-            }
-        },
-        _ => {
-            match log_spec {
-                Some(_) => {
-                    rterrln!("warning: RUST_LOG set, but no crate map found.");
-                },
-                None => {}
-            }
-        }
-    }
-}
-
-// Tests for parse_logging_spec()
-#[test]
-fn parse_logging_spec_valid() {
-    let dirs = parse_logging_spec("crate1::mod1=1,crate1::mod2,crate2=4");
-    let dirs = dirs.as_slice();
-    assert_eq!(dirs.len(), 3);
-    assert_eq!(dirs[0].name, Some("crate1::mod1"));
-    assert_eq!(dirs[0].level, 1);
-
-    assert_eq!(dirs[1].name, Some("crate1::mod2"));
-    assert_eq!(dirs[1].level, MAX_LOG_LEVEL);
-
-    assert_eq!(dirs[2].name, Some("crate2"));
-    assert_eq!(dirs[2].level, 4);
-}
-
-#[test]
-fn parse_logging_spec_invalid_crate() {
-    // test parse_logging_spec with multiple = in specification
-    let dirs = parse_logging_spec("crate1::mod1=1=2,crate2=4");
-    let dirs = dirs.as_slice();
-    assert_eq!(dirs.len(), 1);
-    assert_eq!(dirs[0].name, Some("crate2"));
-    assert_eq!(dirs[0].level, 4);
-}
-
-#[test]
-fn parse_logging_spec_invalid_log_level() {
-    // test parse_logging_spec with 'noNumber' as log level
-    let dirs = parse_logging_spec("crate1::mod1=noNumber,crate2=4");
-    let dirs = dirs.as_slice();
-    assert_eq!(dirs.len(), 1);
-    assert_eq!(dirs[0].name, Some("crate2"));
-    assert_eq!(dirs[0].level, 4);
-}
-
-#[test]
-fn parse_logging_spec_string_log_level() {
-    // test parse_logging_spec with 'warn' as log level
-    let dirs = parse_logging_spec("crate1::mod1=wrong,crate2=warn");
-    let dirs = dirs.as_slice();
-    assert_eq!(dirs.len(), 1);
-    assert_eq!(dirs[0].name, Some("crate2"));
-    assert_eq!(dirs[0].level, 2);
-}
-
-#[test]
-fn parse_logging_spec_global() {
-    // test parse_logging_spec with no crate
-    let dirs = parse_logging_spec("warn,crate2=4");
-    let dirs = dirs.as_slice();
-    assert_eq!(dirs.len(), 2);
-    assert_eq!(dirs[0].name, None);
-    assert_eq!(dirs[0].level, 2);
-    assert_eq!(dirs[1].name, Some("crate2"));
-    assert_eq!(dirs[1].level, 4);
-}
-
-// Tests for update_entry
-#[test]
-fn update_entry_match_full_path() {
-    let dirs = [LogDirective { name: Some("crate1::mod1"), level: 2 },
-                LogDirective { name: Some("crate2"), level: 3 }];
-    let mut level = 0;
-    {
-        let entry = &ModEntry { name: "crate1::mod1", log_level: &mut level };
-        assert_eq!(update_entry(dirs, entry), 1);
-    }
-    assert_eq!(level, 2);
-}
-
-#[test]
-fn update_entry_no_match() {
-    let dirs = [LogDirective { name: Some("crate1::mod1"), level: 2 },
-                LogDirective { name: Some("crate2"), level: 3 }];
-    let mut level = 0;
-    {
-        let entry = &ModEntry { name: "crate3::mod1", log_level: &mut level };
-        assert_eq!(update_entry(dirs, entry), 0);
-    }
-    assert_eq!(level, DEFAULT_LOG_LEVEL);
-}
-
-#[test]
-fn update_entry_match_beginning() {
-    let dirs = [LogDirective { name: Some("crate1::mod1"), level: 2 },
-                LogDirective { name: Some("crate2"), level: 3 }];
-    let mut level = 0;
-    {
-        let entry= &ModEntry {name: "crate2::mod1", log_level: &mut level};
-        assert_eq!(update_entry(dirs, entry), 1);
-    }
-    assert_eq!(level, 3);
-}
-
-#[test]
-fn update_entry_match_beginning_longest_match() {
-    let dirs = [LogDirective { name: Some("crate1::mod1"), level: 2 },
-                LogDirective { name: Some("crate2"), level: 3 },
-                LogDirective { name: Some("crate2::mod"), level: 4 }];
-    let mut level = 0;
-    {
-        let entry = &ModEntry { name: "crate2::mod1", log_level: &mut level };
-        assert_eq!(update_entry(dirs, entry), 1);
-    }
-    assert_eq!(level, 4);
-}
-
-#[test]
-fn update_entry_match_default() {
-    let dirs = [LogDirective { name: Some("crate1::mod1"), level: 2 },
-                LogDirective { name: None, level: 3 }];
-    let mut level = 0;
-    {
-        let entry = &ModEntry { name: "crate1::mod1", log_level: &mut level };
-        assert_eq!(update_entry(dirs, entry), 1);
-    }
-    assert_eq!(level, 2);
-    {
-        let entry = &ModEntry { name: "crate2::mod2", log_level: &mut level };
-        assert_eq!(update_entry(dirs, entry), 1);
-    }
-    assert_eq!(level, 3);
-}
index a58826daa494e24f4d385cbd428ae9cf88e39ca8..84e547619df5abbaea7224757e24eebdae8cb89a 100644 (file)
@@ -104,9 +104,6 @@ pub mod shouldnt_be_public {
 /// The local, managed heap
 pub mod local_heap;
 
-/// The Logger trait and implementations
-pub mod logging;
-
 /// Crate map
 pub mod crate_map;
 
@@ -183,7 +180,6 @@ pub fn init(argc: int, argv: **u8) {
     unsafe {
         args::init(argc, argv);
         env::init();
-        logging::init();
         local_ptr::init();
         at_exit_imp::init();
     }
index cd557f01834e935410566eb13dfeabec9aef71c8..60933aeb38b7a9d965b883854178d20513f6e0d2 100644 (file)
@@ -206,6 +206,7 @@ pub trait RtioTcpStream : RtioSocket {
     fn keepalive(&mut self, delay_in_seconds: uint) -> Result<(), IoError>;
     fn letdie(&mut self) -> Result<(), IoError>;
     fn clone(&self) -> ~RtioTcpStream;
+    fn close_write(&mut self) -> Result<(), IoError>;
 }
 
 pub trait RtioSocket {
index 86e69560e9d8b409c83c975f6a04afbdaa583f1f..8c617c1b59b18c6af5c081f5c0f6c1335706d7f6 100644 (file)
@@ -21,7 +21,6 @@
 use io::Writer;
 use iter::{Iterator, Take};
 use local_data;
-use logging::Logger;
 use ops::Drop;
 use option::{Option, Some, None};
 use prelude::drop;
@@ -51,7 +50,6 @@ pub struct Task {
     destroyed: bool,
     name: Option<SendStr>,
 
-    logger: Option<~Logger>,
     stdout: Option<~Writer>,
     stderr: Option<~Writer>,
 
@@ -95,7 +93,6 @@ pub fn new() -> Task {
             death: Death::new(),
             destroyed: false,
             name: None,
-            logger: None,
             stdout: None,
             stderr: None,
             imp: None,
@@ -129,11 +126,9 @@ pub fn run(~self, f: ||) -> ~Task {
                 #[allow(unused_must_use)]
                 fn close_outputs() {
                     let mut task = Local::borrow(None::<Task>);
-                    let logger = task.get().logger.take();
                     let stderr = task.get().stderr.take();
                     let stdout = task.get().stdout.take();
                     drop(task);
-                    drop(logger); // loggers are responsible for flushing
                     match stdout { Some(mut w) => { w.flush(); }, None => {} }
                     match stderr { Some(mut w) => { w.flush(); }, None => {} }
                 }
index 3a06075ce484568faee7200188128fb396cc2168..7f54b8b332067355612943ae7bdf6c404c0bbff9 100644 (file)
@@ -398,6 +398,8 @@ fn begin_unwind_inner(msg: ~Any, file: &'static str, line: uint) -> ! {
                 if backtrace::log_enabled() {
                     let mut err = ::rt::util::Stderr;
                     let _err = backtrace::write(&mut err);
+                } else {
+                    rterrln!("run with `RUST_BACKTRACE=1` to see a backtrace");
                 }
                 unsafe { intrinsics::abort() }
             }
index b4d465c0397de4d87090e19d506d703167c163e3..b38a5aed16f0e103c57fc316e8969034ffb3708d 100644 (file)
@@ -225,6 +225,10 @@ pub fn fetch_sub(&mut self, val: int, order: Ordering) -> int {
     }
 }
 
+// temporary workaround
+// it causes link failure on MIPS target
+// libgcc doesn't implement 64-bit atomic operations for MIPS32
+#[cfg(not(target_arch = "mips"))]
 impl AtomicU64 {
     pub fn new(v: u64) -> AtomicU64 {
         AtomicU64 { v:v, nopod: marker::NoPod }
index 19f41c6fa1cb16b23180aa25357b54543e8d39a5..9c88db6beb5f876e8422d4d2aee616d1fa53a009 100644 (file)
@@ -40,7 +40,6 @@
 use comm::{Sender, Receiver, channel};
 use io::Writer;
 use kinds::{Send, marker};
-use logging::Logger;
 use option::{None, Some, Option};
 use result::{Result, Ok, Err};
 use rt::local::Local;
@@ -66,8 +65,6 @@ pub struct TaskOpts {
     name: Option<SendStr>,
     /// The size of the stack for the spawned task
     stack_size: Option<uint>,
-    /// Task-local logger (see std::logging)
-    logger: Option<~Logger>,
     /// Task-local stdout
     stdout: Option<~Writer>,
     /// Task-local stderr
@@ -230,7 +227,6 @@ pub fn new() -> TaskOpts {
             notify_chan: None,
             name: None,
             stack_size: None,
-            logger: None,
             stdout: None,
             stderr: None,
         }
index 34ddee46d350e1e48ef16eebb57b816d8f666764..2a3c89639805ec35ad32b96d0dd67ceacc12238d 100644 (file)
@@ -324,12 +324,16 @@ mod os {
         static __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
         #[cfg(target_arch = "arm")]
         static __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
+        #[cfg(target_arch = "mips")]
+        static __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
         #[cfg(target_arch = "x86_64")]
         static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
         #[cfg(target_arch = "x86")]
         static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
         #[cfg(target_arch = "arm")]
         static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
+        #[cfg(target_arch = "mips")]
+        static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
 
         pub struct pthread_mutex_t {
             __align: libc::c_longlong,
index 199fc68be4793d3b5efae973f878df7ff3e6a439..7b77a4b60fbd53c333d3d240739984a1547a1394 100644 (file)
@@ -8,8 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// Migrate documentation over from `std::vec` when it is removed.
-#[doc(hidden)];
+// Migrate documentation over from `std::vec` progressively.  (This is
+// shown in docs so that people have something to refer too, even if
+// the page is rather empty.)
+#[allow(missing_doc)];
 
 use cast::{forget, transmute};
 use clone::Clone;
index dd6ae7c77f5d2a696aea7a700e237799a6e38a11..d4593318eafb5853e06f543fed4f117d6056b7be 100644 (file)
 #[crate_type = "rlib"];
 #[crate_type = "dylib"];
 #[license = "MIT/ASL2"];
+#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+      html_root_url = "http://static.rust-lang.org/doc/master")];
+#[feature(phase)];
+
+#[allow(deprecated_owned_vector)];
+
+#[cfg(test)] #[phase(syntax, link)] extern crate log;
 
 pub use arc::{Arc, MutexArc, RWArc, RWWriteMode, RWReadMode, ArcCondvar, CowArc};
 pub use sync::{Mutex, RWLock, Condvar, Semaphore, RWLockWriteMode,
index 7fef6da560783c3b5327e3888b9e99d5d28c4982..4ef46573e23a5d0240c3179d4ab13efcd3a8c195 100644 (file)
@@ -529,9 +529,6 @@ pub enum Expr_ {
     ExprAgain(Option<Ident>),
     ExprRet(Option<@Expr>),
 
-    /// Gets the log level for the enclosing module
-    ExprLogLevel,
-
     ExprInlineAsm(InlineAsm),
 
     ExprMac(Mac),
@@ -830,8 +827,7 @@ pub enum Ty_ {
     TyPath(Path, Option<OptVec<TyParamBound>>, NodeId), // for #7264; see above
     TyTypeof(@Expr),
     // TyInfer means the type should be inferred instead of it having been
-    // specified. This should only appear at the "top level" of a type and not
-    // nested in one.
+    // specified. This can appear anywhere in a type.
     TyInfer,
 }
 
index 56a99736866f6a037fdc48413c36ad3ac702d48a..f7983933990459a1c3dcb60e4c5720bc7fb8ab15 100644 (file)
@@ -18,7 +18,6 @@
 use print::pprust;
 use util::small_vector::SmallVector;
 
-use std::logging;
 use std::cell::RefCell;
 use std::iter;
 use std::vec;
@@ -538,7 +537,7 @@ pub fn map_crate<F: FoldOps>(krate: Crate, fold_ops: F) -> (Crate, Map) {
         cx.fold_crate(krate)
     };
 
-    if log_enabled!(logging::DEBUG) {
+    if log_enabled!(::log::DEBUG) {
         let map = map.map.borrow();
         // This only makes sense for ordered stores; note the
         // enumerate to count the number of entries.
index ed56ef15a1c8b7ceee5846d4c275189924ff6208..7ff9a73f29d9b4e412ed8fcbcaaf63f670aa93cc 100644 (file)
@@ -317,9 +317,9 @@ pub fn test_cfg<AM: AttrMetaMethods, It: Iterator<AM>>
                                 debug!("not!");
                                 // inside #[cfg(not(...))], so these need to all
                                 // not match.
-                                not_cfgs.iter().all(|mi| {
+                                !not_cfgs.iter().all(|mi| {
                                     debug!("cfg(not({}[...]))", mi.name());
-                                    !contains(cfg, *mi)
+                                    contains(cfg, *mi)
                                 })
                             }
                             _ => contains(cfg, *cfg_mi)
index 0cf13cfaba5a13fe1c2f40f683d0ee78198640ab..2da8b7868053a7d25045093815bc95e4b2bd6006 100644 (file)
@@ -17,8 +17,6 @@
 use std::iter::range;
 use term;
 
-static BUG_REPORT_URL: &'static str =
-    "http://static.rust-lang.org/doc/master/complement-bugreport.html";
 // maximum number of lines we will print for each error; arbitrary.
 static MAX_LINES: uint = 6u;
 
@@ -34,6 +32,10 @@ fn custom_emit(&mut self, cm: &codemap::CodeMap,
 /// how a rustc task died (if so desired).
 pub struct FatalError;
 
+/// Signifies that the compiler died with an explicit call to `.bug`
+/// or `.span_bug` rather than a failed assertion, etc.
+pub struct ExplicitBug;
+
 // a span-handler is like a handler but also
 // accepts span information for source-location
 // reporting.
@@ -61,7 +63,8 @@ pub fn span_end_note(&self, sp: Span, msg: &str) {
         self.handler.custom_emit(&*self.cm, sp, msg, Note);
     }
     pub fn span_bug(&self, sp: Span, msg: &str) -> ! {
-        self.span_fatal(sp, ice_msg(msg));
+        self.handler.emit(Some((&*self.cm, sp)), msg, Bug);
+        fail!(ExplicitBug);
     }
     pub fn span_unimpl(&self, sp: Span, msg: &str) -> ! {
         self.span_bug(sp, ~"unimplemented " + msg);
@@ -116,7 +119,8 @@ pub fn note(&self, msg: &str) {
         self.emit.borrow_mut().get().emit(None, msg, Note);
     }
     pub fn bug(&self, msg: &str) -> ! {
-        self.fatal(ice_msg(msg));
+        self.emit.borrow_mut().get().emit(None, msg, Bug);
+        fail!(ExplicitBug);
     }
     pub fn unimpl(&self, msg: &str) -> ! {
         self.bug(~"unimplemented " + msg);
@@ -133,11 +137,6 @@ pub fn custom_emit(&self, cm: &codemap::CodeMap,
     }
 }
 
-pub fn ice_msg(msg: &str) -> ~str {
-    format!("internal compiler error: {}\nThis message reflects a bug in the Rust compiler. \
-            \nWe would appreciate a bug report: {}", msg, BUG_REPORT_URL)
-}
-
 pub fn mk_span_handler(handler: @Handler, cm: @codemap::CodeMap)
                        -> @SpanHandler {
     @SpanHandler {
@@ -159,6 +158,7 @@ pub fn mk_handler(e: ~Emitter) -> @Handler {
 
 #[deriving(Eq)]
 pub enum Level {
+    Bug,
     Fatal,
     Error,
     Warning,
@@ -170,6 +170,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         use std::fmt::Show;
 
         match *self {
+            Bug => "error: internal compiler error".fmt(f),
             Fatal | Error => "error".fmt(f),
             Warning => "warning".fmt(f),
             Note => "note".fmt(f),
@@ -180,7 +181,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 impl Level {
     fn color(self) -> term::color::Color {
         match self {
-            Fatal | Error => term::color::BRIGHT_RED,
+            Bug | Fatal | Error => term::color::BRIGHT_RED,
             Warning => term::color::BRIGHT_YELLOW,
             Note => term::color::BRIGHT_GREEN
         }
index 6080613460da219c0e3976de88bb1df44677bfd3..8c1e27d8b019a6218dc2da05b00fb7c499034ee1 100644 (file)
@@ -27,19 +27,25 @@ enum State {
     Outputs,
     Inputs,
     Clobbers,
-    Options
+    Options,
+    StateNone
 }
 
-fn next_state(s: State) -> Option<State> {
-    match s {
-        Asm      => Some(Outputs),
-        Outputs  => Some(Inputs),
-        Inputs   => Some(Clobbers),
-        Clobbers => Some(Options),
-        Options  => None
+impl State {
+    fn next(&self) -> State {
+        match *self {
+            Asm       => Outputs,
+            Outputs   => Inputs,
+            Inputs    => Clobbers,
+            Clobbers  => Options,
+            Options   => StateNone,
+            StateNone => StateNone
+        }
     }
 }
 
+static OPTIONS: &'static [&'static str] = &["volatile", "alignstack", "intel"];
+
 pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
                -> base::MacResult {
     let mut p = parse::new_parser_from_tts(cx.parse_sess(),
@@ -59,9 +65,9 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
 
     let mut state = Asm;
 
-    // Not using labeled break to get us through one round of bootstrapping.
-    let mut continue_ = true;
-    while continue_ {
+    let mut read_write_operands = Vec::new();
+
+    'statement: loop {
         match state {
             Asm => {
                 let (s, style) = match expr_to_str(cx, p.parse_expr(),
@@ -84,18 +90,33 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
 
                     let (constraint, _str_style) = p.parse_str();
 
-                    if constraint.get().starts_with("+") {
-                        cx.span_unimpl(p.last_span,
-                                       "'+' (read+write) output operand constraint modifier");
-                    } else if !constraint.get().starts_with("=") {
-                        cx.span_err(p.last_span, "output operand constraint lacks '='");
-                    }
+                    let span = p.last_span;
 
                     p.expect(&token::LPAREN);
                     let out = p.parse_expr();
                     p.expect(&token::RPAREN);
 
-                    outputs.push((constraint, out));
+                    // Expands a read+write operand into two operands.
+                    //
+                    // Use '+' modifier when you want the same expression
+                    // to be both an input and an output at the same time.
+                    // It's the opposite of '=&' which means that the memory
+                    // cannot be shared with any other operand (usually when
+                    // a register is clobbered early.)
+                    let output = match constraint.get().slice_shift_char() {
+                        (Some('='), _) => None,
+                        (Some('+'), operand) => {
+                            // Save a reference to the output
+                            read_write_operands.push((outputs.len(), out));
+                            Some(token::intern_and_get_ident("=" + operand))
+                        }
+                        _ => {
+                            cx.span_err(span, "output operand constraint lacks '=' or '+'");
+                            None
+                        }
+                    };
+
+                    outputs.push((output.unwrap_or(constraint), out));
                 }
             }
             Inputs => {
@@ -135,6 +156,10 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
                     let (s, _str_style) = p.parse_str();
                     let clob = format!("~\\{{}\\}", s);
                     clobs.push(clob);
+
+                    if OPTIONS.iter().any(|opt| s.equiv(opt)) {
+                        cx.span_warn(p.last_span, "expected a clobber, but found an option");
+                    }
                 }
 
                 cons = clobs.connect(",");
@@ -143,56 +168,50 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
                 let (option, _str_style) = p.parse_str();
 
                 if option.equiv(&("volatile")) {
+                    // Indicates that the inline assembly has side effects
+                    // and must not be optimized out along with its outputs.
                     volatile = true;
                 } else if option.equiv(&("alignstack")) {
                     alignstack = true;
                 } else if option.equiv(&("intel")) {
                     dialect = ast::AsmIntel;
+                } else {
+                    cx.span_warn(p.last_span, "unrecognized option");
                 }
 
                 if p.token == token::COMMA {
                     p.eat(&token::COMMA);
                 }
             }
+            StateNone => ()
         }
 
-        while p.token == token::COLON   ||
-              p.token == token::MOD_SEP ||
-              p.token == token::EOF {
-            state = if p.token == token::COLON {
-                p.bump();
-                match next_state(state) {
-                    Some(x) => x,
-                    None    => {
-                        continue_ = false;
-                        break
-                    }
+        loop {
+            // MOD_SEP is a double colon '::' without space in between.
+            // When encountered, the state must be advanced twice.
+            match (&p.token, state.next(), state.next().next()) {
+                (&token::COLON, StateNone, _)   |
+                (&token::MOD_SEP, _, StateNone) => {
+                    p.bump();
+                    break 'statement;
                 }
-            } else if p.token == token::MOD_SEP {
-                p.bump();
-                let s = match next_state(state) {
-                    Some(x) => x,
-                    None    => {
-                        continue_ = false;
-                        break
-                    }
-                };
-                match next_state(s) {
-                    Some(x) => x,
-                    None    => {
-                        continue_ = false;
-                        break
-                    }
+                (&token::COLON, st, _)   |
+                (&token::MOD_SEP, _, st) => {
+                    p.bump();
+                    state = st;
                 }
-            } else if p.token == token::EOF {
-                continue_ = false;
-                break;
-            } else {
-               state
-            };
+                (&token::EOF, _, _) => break 'statement,
+                _ => break
+            }
         }
     }
 
+    // Append an input operand, with the form of ("0", expr)
+    // that links to an output operand.
+    for &(i, out) in read_write_operands.iter() {
+        inputs.push((token::intern_and_get_ident(i.to_str()), out));
+    }
+
     MRExpr(@ast::Expr {
         id: ast::DUMMY_NODE_ID,
         node: ast::ExprInlineAsm(ast::InlineAsm {
index ae8c13a5f98705a3f27354b81c6f0b9f484dea70..997bfcc2e94dafceb525701e6c080faec8c5d25b 100644 (file)
@@ -120,7 +120,7 @@ impl MacResult {
     pub fn raw_dummy_expr(sp: codemap::Span) -> @ast::Expr {
         @ast::Expr {
             id: ast::DUMMY_NODE_ID,
-            node: ast::ExprLogLevel,
+            node: ast::ExprTup(Vec::new()),
             span: sp
         }
     }
@@ -339,7 +339,12 @@ pub fn print_backtrace(&self) { }
     pub fn backtrace(&self) -> Option<@ExpnInfo> { self.backtrace }
     pub fn mod_push(&mut self, i: ast::Ident) { self.mod_path.push(i); }
     pub fn mod_pop(&mut self) { self.mod_path.pop().unwrap(); }
-    pub fn mod_path(&self) -> Vec<ast::Ident> { self.mod_path.clone() }
+    pub fn mod_path(&self) -> Vec<ast::Ident> {
+        let mut v = Vec::new();
+        v.push(token::str_to_ident(self.ecfg.crate_id.name));
+        v.extend(&mut self.mod_path.iter().map(|a| *a));
+        return v;
+    }
     pub fn bt_push(&mut self, ei: codemap::ExpnInfo) {
         match ei {
             ExpnInfo {call_site: cs, callee: ref callee} => {
index bc314bc204bec9e08046890ac68722bda271af2f..2a828cd58003c0cf4fe2f4fd4c2d149323738caa 100644 (file)
@@ -186,7 +186,6 @@ fn eq(&self, other: &int) -> bool {
 use codemap::Span;
 use opt_vec;
 use parse::token::InternedString;
-use parse::token;
 
 use std::vec_ng::Vec;
 use std::vec_ng;
@@ -399,19 +398,16 @@ fn create_derived_impl(&self,
             cx.path_all(self.span, false, vec!( type_ident ), self_lifetimes,
                         opt_vec::take_vec(self_ty_params)), None);
 
-        let doc_attr = cx.attribute(
+        let attr = cx.attribute(
             self.span,
-            cx.meta_name_value(self.span,
-                               InternedString::new("doc"),
-                               ast::LitStr(token::intern_and_get_ident(
-                                               "Automatically derived."),
-                                           ast::CookedStr)));
+            cx.meta_word(self.span,
+                         InternedString::new("automatically_derived")));
         let opt_trait_ref = Some(trait_ref);
         let ident = ast_util::impl_pretty_name(&opt_trait_ref, self_type);
         cx.item(
             self.span,
             ident,
-            vec_ng::append(vec!(doc_attr), self.attributes.as_slice()),
+            vec_ng::append(vec!(attr), self.attributes.as_slice()),
             ast::ItemImpl(trait_generics, opt_trait_ref,
                           self_type, methods.map(|x| *x)))
     }
index dc79ceb4daae230a089394cd1264eb8e3d26ea85..c24894af3be46307c4c8b96187ba337c08130735 100644 (file)
@@ -19,6 +19,7 @@
 use attr::AttrMetaMethods;
 use codemap;
 use codemap::{Span, Spanned, ExpnInfo, NameAndSpan, MacroBang, MacroAttribute};
+use crateid::CrateId;
 use ext::base::*;
 use fold::*;
 use parse;
@@ -871,6 +872,7 @@ fn new_span(&mut self, span: Span) -> Span {
 pub struct ExpansionConfig<'a> {
     loader: &'a mut CrateLoader,
     deriving_hash_type_parameter: bool,
+    crate_id: CrateId,
 }
 
 pub fn expand_crate(parse_sess: @parse::ParseSess,
@@ -1048,6 +1050,7 @@ fn get_registrar_symbol(&mut self, _: ast::CrateNum) -> Option<~str> {
         let cfg = ::syntax::ext::expand::ExpansionConfig {
             loader: &mut loader,
             deriving_hash_type_parameter: false,
+            crate_id: from_str("test").unwrap(),
         };
         expand_crate(sess,cfg,crate_ast);
     }
@@ -1067,6 +1070,7 @@ fn get_registrar_symbol(&mut self, _: ast::CrateNum) -> Option<~str> {
         let cfg = ::syntax::ext::expand::ExpansionConfig {
             loader: &mut loader,
             deriving_hash_type_parameter: false,
+            crate_id: from_str("test").unwrap(),
         };
         expand_crate(sess,cfg,crate_ast);
     }
@@ -1085,6 +1089,7 @@ fn get_registrar_symbol(&mut self, _: ast::CrateNum) -> Option<~str> {
         let cfg = ::syntax::ext::expand::ExpansionConfig {
             loader: &mut loader,
             deriving_hash_type_parameter: false,
+            crate_id: from_str("test").unwrap(),
         };
         expand_crate(sess, cfg, crate_ast);
     }
@@ -1127,6 +1132,7 @@ fn expand_crate_str(crate_str: ~str) -> ast::Crate {
         let cfg = ::syntax::ext::expand::ExpansionConfig {
             loader: &mut loader,
             deriving_hash_type_parameter: false,
+            crate_id: from_str("test").unwrap(),
         };
         expand_crate(ps,cfg,crate_ast)
     }
index 0b56cd07c887ffdb17a3f6e5b2ea557d578a5ba7..8cc74641db85f37b8ad717dbc9b26e9e6894107d 100644 (file)
@@ -816,7 +816,6 @@ pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr {
             ExprIndex(folder.fold_expr(el), folder.fold_expr(er))
         }
         ExprPath(ref pth) => ExprPath(folder.fold_path(pth)),
-        ExprLogLevel => ExprLogLevel,
         ExprBreak(opt_ident) => ExprBreak(opt_ident.map(|x| folder.fold_ident(x))),
         ExprAgain(opt_ident) => ExprAgain(opt_ident.map(|x| folder.fold_ident(x))),
         ExprRet(ref e) => {
index 0d465e8475c9ce5a1dc50e3e51f52898558ed5a4..08b4fa7b44450620c898d7de7296e54aeb3538ea 100644 (file)
       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
       html_root_url = "http://static.rust-lang.org/doc/master")];
 
-#[feature(macro_rules, globs, managed_boxes, default_type_params)];
-#[allow(unknown_features)];// Note: remove it after a snapshot.
-#[feature(quote)];
+#[feature(macro_rules, globs, managed_boxes, default_type_params, phase, quote)];
 
 #[allow(deprecated)];
 #[deny(non_camel_case_types)];
+#[allow(deprecated_owned_vector)];
 
 extern crate serialize;
 extern crate term;
 extern crate collections;
+#[phase(syntax, link)]
+extern crate log;
 
 pub mod util {
     pub mod interner;
index a48774919905032894f69da8c93a464e1c1ad29b..f52effb8c81d7a29484a815e50a43d2582dfcee3 100644 (file)
@@ -25,7 +25,7 @@
 use ast::{ExprAssign, ExprAssignOp, ExprBinary, ExprBlock, ExprBox};
 use ast::{ExprBreak, ExprCall, ExprCast};
 use ast::{ExprField, ExprFnBlock, ExprIf, ExprIndex};
-use ast::{ExprLit, ExprLogLevel, ExprLoop, ExprMac};
+use ast::{ExprLit, ExprLoop, ExprMac};
 use ast::{ExprMethodCall, ExprParen, ExprPath, ExprProc};
 use ast::{ExprRepeat, ExprRet, ExprStruct, ExprTup, ExprUnary};
 use ast::{ExprVec, ExprVstore, ExprVstoreSlice};
@@ -1274,6 +1274,9 @@ pub fn parse_ty(&mut self, _: bool) -> P<Ty> {
                 bounds
             } = self.parse_path(LifetimeAndTypesAndBounds);
             TyPath(path, bounds, ast::DUMMY_NODE_ID)
+        } else if self.eat(&token::UNDERSCORE) {
+            // TYPE TO BE INFERRED
+            TyInfer
         } else {
             let msg = format!("expected type, found token {:?}", self.token);
             self.fatal(msg);
@@ -1883,12 +1886,6 @@ pub fn parse_bottom_expr(&mut self) -> @Expr {
                 }
             }
             hi = self.last_span.hi;
-        } else if self.eat_keyword(keywords::__LogLevel) {
-            // LOG LEVEL expression
-            self.expect(&token::LPAREN);
-            ex = ExprLogLevel;
-            hi = self.span.hi;
-            self.expect(&token::RPAREN);
         } else if self.eat_keyword(keywords::Return) {
             // RETURN expression
             if can_begin_expr(&self.token) {
@@ -4317,7 +4314,7 @@ fn parse_foreign_mod_items(&mut self,
     ///
     /// # Example
     ///
-    /// extern crate extra;
+    /// extern crate url;
     /// extern crate foo = "bar";
     fn parse_item_extern_crate(&mut self,
                                 lo: BytePos,
index cd52ff4b0ac71ac328ffadc0a10a140c489591f8..efadea16fe2f26eeb7a241f1907903bb82badc19 100644 (file)
@@ -462,41 +462,40 @@ pub mod keywords {
         (20,                         Impl,       "impl");
         (21,                         In,         "in");
         (22,                         Let,        "let");
-        (23,                         __LogLevel, "__log_level");
-        (24,                         Loop,       "loop");
-        (25,                         Match,      "match");
-        (26,                         Mod,        "mod");
-        (27,                         Mut,        "mut");
-        (28,                         Once,       "once");
-        (29,                         Priv,       "priv");
-        (30,                         Pub,        "pub");
-        (31,                         Ref,        "ref");
-        (32,                         Return,     "return");
+        (23,                         Loop,       "loop");
+        (24,                         Match,      "match");
+        (25,                         Mod,        "mod");
+        (26,                         Mut,        "mut");
+        (27,                         Once,       "once");
+        (28,                         Priv,       "priv");
+        (29,                         Pub,        "pub");
+        (30,                         Ref,        "ref");
+        (31,                         Return,     "return");
         // Static and Self are also special idents (prefill de-dupes)
         (super::STATIC_KEYWORD_NAME, Static,     "static");
         (super::SELF_KEYWORD_NAME,   Self,       "self");
-        (33,                         Struct,     "struct");
-        (34,                         Super,      "super");
-        (35,                         True,       "true");
-        (36,                         Trait,      "trait");
-        (37,                         Type,       "type");
-        (38,                         Unsafe,     "unsafe");
-        (39,                         Use,        "use");
-        (40,                         While,      "while");
-        (41,                         Continue,   "continue");
-        (42,                         Proc,       "proc");
-        (43,                         Box,        "box");
+        (32,                         Struct,     "struct");
+        (33,                         Super,      "super");
+        (34,                         True,       "true");
+        (35,                         Trait,      "trait");
+        (36,                         Type,       "type");
+        (37,                         Unsafe,     "unsafe");
+        (38,                         Use,        "use");
+        (39,                         While,      "while");
+        (40,                         Continue,   "continue");
+        (41,                         Proc,       "proc");
+        (42,                         Box,        "box");
 
         'reserved:
-        (44,                         Alignof,    "alignof");
-        (45,                         Be,         "be");
-        (46,                         Offsetof,   "offsetof");
-        (47,                         Pure,       "pure");
-        (48,                         Sizeof,     "sizeof");
-        (49,                         Typeof,     "typeof");
-        (50,                         Unsized,    "unsized");
-        (51,                         Yield,      "yield");
-        (52,                         Do,         "do");
+        (43,                         Alignof,    "alignof");
+        (44,                         Be,         "be");
+        (45,                         Offsetof,   "offsetof");
+        (46,                         Pure,       "pure");
+        (47,                         Sizeof,     "sizeof");
+        (48,                         Typeof,     "typeof");
+        (49,                         Unsized,    "unsized");
+        (50,                         Yield,      "yield");
+        (51,                         Do,         "do");
     }
 }
 
index 6894d6a2b053736a764a9ee2fe38df9db4d25eef..b1990476094936c4af4c9fdb793511b3cf823c09 100644 (file)
@@ -504,7 +504,7 @@ pub fn print_type(s: &mut State, ty: &ast::Ty) -> io::IoResult<()> {
             try!(word(&mut s.s, ")"));
         }
         ast::TyInfer => {
-            fail!("print_type shouldn't see a ty_infer");
+            try!(word(&mut s.s, "_"));
         }
     }
     end(s)
@@ -1490,11 +1490,6 @@ fn print_field(s: &mut State, field: &ast::Field) -> io::IoResult<()> {
           _ => ()
         }
       }
-      ast::ExprLogLevel => {
-        try!(word(&mut s.s, "__log_level"));
-        try!(popen(s));
-        try!(pclose(s));
-      }
       ast::ExprInlineAsm(ref a) => {
         if a.volatile {
             try!(word(&mut s.s, "__volatile__ asm!"));
index 538528fb1484a79aa4f91447577cdf414bd22d91..880fce580831b36d58f215511b0e57b9d0de1ceb 100644 (file)
@@ -743,7 +743,6 @@ pub fn walk_expr<E: Clone, V: Visitor<E>>(visitor: &mut V, expression: &Expr, en
         ExprRet(optional_expression) => {
             walk_expr_opt(visitor, optional_expression, env.clone())
         }
-        ExprLogLevel => {}
         ExprMac(ref macro) => visitor.visit_mac(macro, env.clone()),
         ExprParen(subexpression) => {
             visitor.visit_expr(subexpression, env.clone())
index 903fede5faa8e9194010ed29878f07e88d85ba43..089c1668bf39ba25a0b884551d7b44e09a4b2ccb 100644 (file)
@@ -22,6 +22,7 @@
 #[feature(macro_rules)];
 #[deny(non_camel_case_types)];
 #[allow(missing_doc)];
+#[allow(deprecated_owned_vector)];
 
 extern crate collections;
 
@@ -155,8 +156,6 @@ pub fn fg(&mut self, color: color::Color) -> io::IoResult<bool> {
             if s.is_ok() {
                 try!(self.out.write(s.unwrap()));
                 return Ok(true)
-            } else {
-                warn!("{}", s.unwrap_err());
             }
         }
         Ok(false)
@@ -176,8 +175,6 @@ pub fn bg(&mut self, color: color::Color) -> io::IoResult<bool> {
             if s.is_ok() {
                 try!(self.out.write(s.unwrap()));
                 return Ok(true)
-            } else {
-                warn!("{}", s.unwrap_err());
             }
         }
         Ok(false)
@@ -198,8 +195,6 @@ pub fn attr(&mut self, attr: attr::Attr) -> io::IoResult<bool> {
                     if s.is_ok() {
                         try!(self.out.write(s.unwrap()));
                         return Ok(true)
-                    } else {
-                        warn!("{}", s.unwrap_err());
                     }
                 }
                 Ok(false)
@@ -236,12 +231,6 @@ pub fn reset(&mut self) -> io::IoResult<()> {
         });
         if s.is_ok() {
             return self.out.write(s.unwrap())
-        } else if self.num_colors > 0 {
-            warn!("{}", s.unwrap_err());
-        } else {
-            // if we support attributes but not color, it would be nice to still warn!()
-            // but it's not worth testing all known attributes just for this.
-            debug!("{}", s.unwrap_err());
         }
         Ok(())
     }
index e9d71d1c2f7a384478f9471e4f3780e8af31a7aa..8ba3ad53121aee97158a7c160ddf5ba3e648e3c6 100644 (file)
@@ -195,27 +195,15 @@ macro_rules! try( ($e:expr) => (
 
     assert!(names_bytes          > 0);
 
-    debug!("names_bytes = {}", names_bytes);
-    debug!("bools_bytes = {}", bools_bytes);
-    debug!("numbers_count = {}", numbers_count);
-    debug!("string_offsets_count = {}", string_offsets_count);
-    debug!("string_table_bytes = {}", string_table_bytes);
-
     if (bools_bytes as uint) > boolnames.len() {
-        error!("expected bools_bytes to be less than {} but found {}", boolnames.len(),
-               bools_bytes);
         return Err(~"incompatible file: more booleans than expected");
     }
 
     if (numbers_count as uint) > numnames.len() {
-        error!("expected numbers_count to be less than {} but found {}", numnames.len(),
-               numbers_count);
         return Err(~"incompatible file: more numbers than expected");
     }
 
     if (string_offsets_count as uint) > stringnames.len() {
-        error!("expected string_offsets_count to be less than {} but found {}", stringnames.len(),
-               string_offsets_count);
         return Err(~"incompatible file: more string offsets than expected");
     }
 
@@ -229,26 +217,19 @@ macro_rules! try( ($e:expr) => (
 
     try!(file.read_byte()); // consume NUL
 
-    debug!("term names: {:?}", term_names);
-
     let mut bools_map = HashMap::new();
     if bools_bytes != 0 {
         for i in range(0, bools_bytes) {
             let b = try!(file.read_byte());
             if b < 0 {
-                error!("EOF reading bools after {} entries", i);
                 return Err(~"error: expected more bools but hit EOF");
             } else if b == 1 {
-                debug!("{} set", bnames[i]);
                 bools_map.insert(bnames[i].to_owned(), true);
             }
         }
     }
 
-    debug!("bools: {:?}", bools_map);
-
     if (bools_bytes + names_bytes) % 2 == 1 {
-        debug!("adjusting for padding between bools and numbers");
         try!(file.read_byte()); // compensate for padding
     }
 
@@ -257,14 +238,11 @@ macro_rules! try( ($e:expr) => (
         for i in range(0, numbers_count) {
             let n = try!(file.read_le_u16());
             if n != 0xFFFF {
-                debug!("{}\\#{}", nnames[i], n);
                 numbers_map.insert(nnames[i].to_owned(), n);
             }
         }
     }
 
-    debug!("numbers: {:?}", numbers_map);
-
     let mut string_map = HashMap::new();
 
     if string_offsets_count != 0 {
@@ -273,13 +251,9 @@ macro_rules! try( ($e:expr) => (
             string_offsets.push(try!(file.read_le_u16()));
         }
 
-        debug!("offsets: {:?}", string_offsets);
-
         let string_table = try!(file.read_bytes(string_table_bytes as uint));
 
         if string_table.len() != string_table_bytes as uint {
-            error!("EOF reading string table after {} bytes, wanted {}", string_table.len(),
-                   string_table_bytes);
             return Err(~"error: hit EOF before end of string table");
         }
 
index 44488f86ae4e42aee6c3babb46d32e4baae9edbc..efd1fbcd1ac511c06d612bda6c62142f6b642e9d 100644 (file)
 #[license = "MIT/ASL2"];
 #[crate_type = "rlib"];
 #[crate_type = "dylib"];
+#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+      html_root_url = "http://static.rust-lang.org/doc/master")];
 
-#[feature(asm)];
+#[feature(asm, macro_rules)];
+#[allow(deprecated_owned_vector)];
 
 extern crate collections;
-extern crate extra;
 extern crate getopts;
 extern crate serialize;
 extern crate term;
 extern crate time;
 
 use collections::TreeMap;
-use extra::stats::Stats;
-use extra::stats;
+use stats::Stats;
 use time::precise_time_ns;
 use getopts::{OptGroup, optflag, optopt};
 use serialize::{json, Decodable};
@@ -67,9 +69,11 @@ pub mod test {
              MetricChange, Improvement, Regression, LikelyNoise,
              StaticTestFn, StaticTestName, DynTestName, DynTestFn,
              run_test, test_main, test_main_static, filter_tests,
-             parse_opts};
+             parse_opts, StaticBenchFn};
 }
 
+pub mod stats;
+
 // The name of a test. By convention this follows the rules for rust
 // paths; i.e. it should be a series of identifiers separated by double
 // colons. This way if some test runner wants to arrange the tests
@@ -688,7 +692,6 @@ pub fn run_tests_console(opts: &TestOpts,
                          tests: ~[TestDescAndFn]) -> io::IoResult<bool> {
     fn callback<T: Writer>(event: &TestEvent,
                            st: &mut ConsoleTestState<T>) -> io::IoResult<()> {
-        debug!("callback(event={:?})", event);
         match (*event).clone() {
             TeFiltered(ref filtered_tests) => st.write_run_start(filtered_tests.len()),
             TeWait(ref test, padding) => st.write_test_start(test, padding),
@@ -732,7 +735,6 @@ fn len_if_padded(t: &TestDescAndFn) -> uint {
     match tests.iter().max_by(|t|len_if_padded(*t)) {
         Some(t) => {
             let n = t.desc.name.to_str();
-            debug!("Setting max_name_len from: {}", n);
             st.max_name_len = n.len();
         },
         None => {}
@@ -821,7 +823,6 @@ fn run_tests(opts: &TestOpts,
     // It's tempting to just spawn all the tests at once, but since we have
     // many tests that run in other processes we would be making a big mess.
     let concurrency = get_concurrency();
-    debug!("using {} test tasks", concurrency);
 
     let mut remaining = filtered_tests;
     remaining.reverse();
@@ -1069,7 +1070,7 @@ pub fn compare_to_old(&self, old: &MetricMap,
                     if delta.abs() <= noise {
                         LikelyNoise
                     } else {
-                        let pct = delta.abs() / cmp::max(vold.value, f64::EPSILON) * 100.0;
+                        let pct = delta.abs() / vold.value.max(f64::EPSILON) * 100.0;
                         if vold.noise < 0.0 {
                             // When 'noise' is negative, it means we want
                             // to see deltas that go up over time, and can
@@ -1147,7 +1148,6 @@ pub fn ratchet(&self, p: &Path, pct: Option<f64>) -> (MetricDiff, bool) {
         });
 
         if ok {
-            debug!("rewriting file '{:?}' with updated metrics", p);
             self.save(p).unwrap();
         }
         return (diff, ok)
@@ -1198,8 +1198,6 @@ pub fn ns_per_iter(&mut self) -> u64 {
 
     pub fn bench_n(&mut self, n: u64, f: |&mut BenchHarness|) {
         self.iterations = n;
-        debug!("running benchmark for {} iterations",
-               n as uint);
         f(self);
     }
 
@@ -1224,9 +1222,6 @@ pub fn auto_bench(&mut self, f: |&mut BenchHarness|) -> stats::Summary {
         // (i.e. larger error bars).
         if n == 0 { n = 1; }
 
-        debug!("Initial run took {} ns, iter count that takes 1ms estimated as {}",
-               self.ns_per_iter(), n);
-
         let mut total_run = 0;
         let samples : &mut [f64] = [0.0_f64, ..50];
         loop {
@@ -1248,12 +1243,6 @@ pub fn auto_bench(&mut self, f: |&mut BenchHarness|) -> stats::Summary {
             stats::winsorize(samples, 5.0);
             let summ5 = stats::Summary::new(samples);
 
-            debug!("{} samples, median {}, MAD={}, MADP={}",
-                   samples.len(),
-                   summ.median as f64,
-                   summ.median_abs_dev as f64,
-                   summ.median_abs_dev_pct as f64);
-
             let now = precise_time_ns();
             let loop_run = now - loop_start;
 
@@ -1308,7 +1297,7 @@ mod tests {
                Metric, MetricMap, MetricAdded, MetricRemoved,
                Improvement, Regression, LikelyNoise,
                StaticTestName, DynTestName, DynTestFn};
-    use extra::tempfile::TempDir;
+    use std::io::TempDir;
 
     #[test]
     pub fn do_not_run_ignored_tests() {
diff --git a/src/libtest/stats.rs b/src/libtest/stats.rs
new file mode 100644 (file)
index 0000000..b3fd06b
--- /dev/null
@@ -0,0 +1,1056 @@
+// 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.
+
+#[allow(missing_doc)];
+
+use std::hash::Hash;
+use std::io;
+use std::mem;
+use std::num;
+use collections::hashmap;
+
+// NB: this can probably be rewritten in terms of num::Num
+// to be less f64-specific.
+
+fn f64_cmp(x: f64, y: f64) -> Ordering {
+    // arbitrarily decide that NaNs are larger than everything.
+    if y.is_nan() {
+        Less
+    } else if x.is_nan() {
+        Greater
+    } else if x < y {
+        Less
+    } else if x == y {
+        Equal
+    } else {
+        Greater
+    }
+}
+
+fn f64_sort(v: &mut [f64]) {
+    v.sort_by(|x: &f64, y: &f64| f64_cmp(*x, *y));
+}
+
+/// Trait that provides simple descriptive statistics on a univariate set of numeric samples.
+pub trait Stats {
+
+    /// Sum of the samples.
+    ///
+    /// Note: this method sacrifices performance at the altar of accuracy
+    /// Depends on IEEE-754 arithmetic guarantees. See proof of correctness at:
+    /// ["Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates"]
+    /// (http://www.cs.cmu.edu/~quake-papers/robust-arithmetic.ps)
+    /// *Discrete & Computational Geometry 18*, 3 (Oct 1997), 305-363, Shewchuk J.R.
+    fn sum(self) -> f64;
+
+    /// Minimum value of the samples.
+    fn min(self) -> f64;
+
+    /// Maximum value of the samples.
+    fn max(self) -> f64;
+
+    /// Arithmetic mean (average) of the samples: sum divided by sample-count.
+    ///
+    /// See: https://en.wikipedia.org/wiki/Arithmetic_mean
+    fn mean(self) -> f64;
+
+    /// Median of the samples: value separating the lower half of the samples from the higher half.
+    /// Equal to `self.percentile(50.0)`.
+    ///
+    /// See: https://en.wikipedia.org/wiki/Median
+    fn median(self) -> f64;
+
+    /// Variance of the samples: bias-corrected mean of the squares of the differences of each
+    /// sample from the sample mean. Note that this calculates the _sample variance_ rather than the
+    /// population variance, which is assumed to be unknown. It therefore corrects the `(n-1)/n`
+    /// bias that would appear if we calculated a population variance, by dividing by `(n-1)` rather
+    /// than `n`.
+    ///
+    /// See: https://en.wikipedia.org/wiki/Variance
+    fn var(self) -> f64;
+
+    /// Standard deviation: the square root of the sample variance.
+    ///
+    /// Note: this is not a robust statistic for non-normal distributions. Prefer the
+    /// `median_abs_dev` for unknown distributions.
+    ///
+    /// See: https://en.wikipedia.org/wiki/Standard_deviation
+    fn std_dev(self) -> f64;
+
+    /// Standard deviation as a percent of the mean value. See `std_dev` and `mean`.
+    ///
+    /// Note: this is not a robust statistic for non-normal distributions. Prefer the
+    /// `median_abs_dev_pct` for unknown distributions.
+    fn std_dev_pct(self) -> f64;
+
+    /// Scaled median of the absolute deviations of each sample from the sample median. This is a
+    /// robust (distribution-agnostic) estimator of sample variability. Use this in preference to
+    /// `std_dev` if you cannot assume your sample is normally distributed. Note that this is scaled
+    /// by the constant `1.4826` to allow its use as a consistent estimator for the standard
+    /// deviation.
+    ///
+    /// See: http://en.wikipedia.org/wiki/Median_absolute_deviation
+    fn median_abs_dev(self) -> f64;
+
+    /// Median absolute deviation as a percent of the median. See `median_abs_dev` and `median`.
+    fn median_abs_dev_pct(self) -> f64;
+
+    /// Percentile: the value below which `pct` percent of the values in `self` fall. For example,
+    /// percentile(95.0) will return the value `v` such that 95% of the samples `s` in `self`
+    /// satisfy `s <= v`.
+    ///
+    /// Calculated by linear interpolation between closest ranks.
+    ///
+    /// See: http://en.wikipedia.org/wiki/Percentile
+    fn percentile(self, pct: f64) -> f64;
+
+    /// Quartiles of the sample: three values that divide the sample into four equal groups, each
+    /// with 1/4 of the data. The middle value is the median. See `median` and `percentile`. This
+    /// function may calculate the 3 quartiles more efficiently than 3 calls to `percentile`, but
+    /// is otherwise equivalent.
+    ///
+    /// See also: https://en.wikipedia.org/wiki/Quartile
+    fn quartiles(self) -> (f64,f64,f64);
+
+    /// Inter-quartile range: the difference between the 25th percentile (1st quartile) and the 75th
+    /// percentile (3rd quartile). See `quartiles`.
+    ///
+    /// See also: https://en.wikipedia.org/wiki/Interquartile_range
+    fn iqr(self) -> f64;
+}
+
+/// Extracted collection of all the summary statistics of a sample set.
+#[deriving(Clone, Eq)]
+#[allow(missing_doc)]
+pub struct Summary {
+    sum: f64,
+    min: f64,
+    max: f64,
+    mean: f64,
+    median: f64,
+    var: f64,
+    std_dev: f64,
+    std_dev_pct: f64,
+    median_abs_dev: f64,
+    median_abs_dev_pct: f64,
+    quartiles: (f64,f64,f64),
+    iqr: f64,
+}
+
+impl Summary {
+
+    /// Construct a new summary of a sample set.
+    pub fn new(samples: &[f64]) -> Summary {
+        Summary {
+            sum: samples.sum(),
+            min: samples.min(),
+            max: samples.max(),
+            mean: samples.mean(),
+            median: samples.median(),
+            var: samples.var(),
+            std_dev: samples.std_dev(),
+            std_dev_pct: samples.std_dev_pct(),
+            median_abs_dev: samples.median_abs_dev(),
+            median_abs_dev_pct: samples.median_abs_dev_pct(),
+            quartiles: samples.quartiles(),
+            iqr: samples.iqr()
+        }
+    }
+}
+
+impl<'a> Stats for &'a [f64] {
+
+    // FIXME #11059 handle NaN, inf and overflow
+    fn sum(self) -> f64 {
+        let mut partials : ~[f64] = ~[];
+
+        for &mut x in self.iter() {
+            let mut j = 0;
+            // This inner loop applies `hi`/`lo` summation to each
+            // partial so that the list of partial sums remains exact.
+            for i in range(0, partials.len()) {
+                let mut y = partials[i];
+                if num::abs(x) < num::abs(y) {
+                    mem::swap(&mut x, &mut y);
+                }
+                // Rounded `x+y` is stored in `hi` with round-off stored in
+                // `lo`. Together `hi+lo` are exactly equal to `x+y`.
+                let hi = x + y;
+                let lo = y - (hi - x);
+                if lo != 0f64 {
+                    partials[j] = lo;
+                    j += 1;
+                }
+                x = hi;
+            }
+            if j >= partials.len() {
+                partials.push(x);
+            } else {
+                partials[j] = x;
+                partials.truncate(j+1);
+            }
+        }
+        partials.iter().fold(0.0, |p, q| p + *q)
+    }
+
+    fn min(self) -> f64 {
+        assert!(self.len() != 0);
+        self.iter().fold(self[0], |p, q| p.min(*q))
+    }
+
+    fn max(self) -> f64 {
+        assert!(self.len() != 0);
+        self.iter().fold(self[0], |p, q| p.max(*q))
+    }
+
+    fn mean(self) -> f64 {
+        assert!(self.len() != 0);
+        self.sum() / (self.len() as f64)
+    }
+
+    fn median(self) -> f64 {
+        self.percentile(50.0)
+    }
+
+    fn var(self) -> f64 {
+        if self.len() < 2 {
+            0.0
+        } else {
+            let mean = self.mean();
+            let mut v = 0.0;
+            for s in self.iter() {
+                let x = *s - mean;
+                v += x*x;
+            }
+            // NB: this is _supposed to be_ len-1, not len. If you
+            // change it back to len, you will be calculating a
+            // population variance, not a sample variance.
+            v/((self.len()-1) as f64)
+        }
+    }
+
+    fn std_dev(self) -> f64 {
+        self.var().sqrt()
+    }
+
+    fn std_dev_pct(self) -> f64 {
+        (self.std_dev() / self.mean()) * 100.0
+    }
+
+    fn median_abs_dev(self) -> f64 {
+        let med = self.median();
+        let abs_devs = self.map(|&v| num::abs(med - v));
+        // This constant is derived by smarter statistics brains than me, but it is
+        // consistent with how R and other packages treat the MAD.
+        abs_devs.median() * 1.4826
+    }
+
+    fn median_abs_dev_pct(self) -> f64 {
+        (self.median_abs_dev() / self.median()) * 100.0
+    }
+
+    fn percentile(self, pct: f64) -> f64 {
+        let mut tmp = self.to_owned();
+        f64_sort(tmp);
+        percentile_of_sorted(tmp, pct)
+    }
+
+    fn quartiles(self) -> (f64,f64,f64) {
+        let mut tmp = self.to_owned();
+        f64_sort(tmp);
+        let a = percentile_of_sorted(tmp, 25.0);
+        let b = percentile_of_sorted(tmp, 50.0);
+        let c = percentile_of_sorted(tmp, 75.0);
+        (a,b,c)
+    }
+
+    fn iqr(self) -> f64 {
+        let (a,_,c) = self.quartiles();
+        c - a
+    }
+}
+
+
+// Helper function: extract a value representing the `pct` percentile of a sorted sample-set, using
+// linear interpolation. If samples are not sorted, return nonsensical value.
+fn percentile_of_sorted(sorted_samples: &[f64],
+                             pct: f64) -> f64 {
+    assert!(sorted_samples.len() != 0);
+    if sorted_samples.len() == 1 {
+        return sorted_samples[0];
+    }
+    assert!(0.0 <= pct);
+    assert!(pct <= 100.0);
+    if pct == 100.0 {
+        return sorted_samples[sorted_samples.len() - 1];
+    }
+    let rank = (pct / 100.0) * ((sorted_samples.len() - 1) as f64);
+    let lrank = rank.floor();
+    let d = rank - lrank;
+    let n = lrank as uint;
+    let lo = sorted_samples[n];
+    let hi = sorted_samples[n+1];
+    lo + (hi - lo) * d
+}
+
+
+/// Winsorize a set of samples, replacing values above the `100-pct` percentile and below the `pct`
+/// percentile with those percentiles themselves. This is a way of minimizing the effect of
+/// outliers, at the cost of biasing the sample. It differs from trimming in that it does not
+/// change the number of samples, just changes the values of those that are outliers.
+///
+/// See: http://en.wikipedia.org/wiki/Winsorising
+pub fn winsorize(samples: &mut [f64], pct: f64) {
+    let mut tmp = samples.to_owned();
+    f64_sort(tmp);
+    let lo = percentile_of_sorted(tmp, pct);
+    let hi = percentile_of_sorted(tmp, 100.0-pct);
+    for samp in samples.mut_iter() {
+        if *samp > hi {
+            *samp = hi
+        } else if *samp < lo {
+            *samp = lo
+        }
+    }
+}
+
+/// Render writes the min, max and quartiles of the provided `Summary` to the provided `Writer`.
+pub fn write_5_number_summary(w: &mut io::Writer,
+                              s: &Summary) -> io::IoResult<()> {
+    let (q1,q2,q3) = s.quartiles;
+    write!(w, "(min={}, q1={}, med={}, q3={}, max={})",
+                     s.min,
+                     q1,
+                     q2,
+                     q3,
+                     s.max)
+}
+
+/// Render a boxplot to the provided writer. The boxplot shows the min, max and quartiles of the
+/// provided `Summary` (thus includes the mean) and is scaled to display within the range of the
+/// nearest multiple-of-a-power-of-ten above and below the min and max of possible values, and
+/// target `width_hint` characters of display (though it will be wider if necessary).
+///
+/// As an example, the summary with 5-number-summary `(min=15, q1=17, med=20, q3=24, max=31)` might
+/// display as:
+///
+/// ~~~~ignore
+///   10 |        [--****#******----------]          | 40
+/// ~~~~
+
+pub fn write_boxplot(w: &mut io::Writer, s: &Summary,
+                     width_hint: uint) -> io::IoResult<()> {
+
+    let (q1,q2,q3) = s.quartiles;
+
+    // the .abs() handles the case where numbers are negative
+    let lomag = (10.0_f64).powf(&(s.min.abs().log10().floor()));
+    let himag = (10.0_f64).powf(&(s.max.abs().log10().floor()));
+
+    // need to consider when the limit is zero
+    let lo = if lomag == 0.0 {
+        0.0
+    } else {
+        (s.min / lomag).floor() * lomag
+    };
+
+    let hi = if himag == 0.0 {
+        0.0
+    } else {
+        (s.max / himag).ceil() * himag
+    };
+
+    let range = hi - lo;
+
+    let lostr = lo.to_str();
+    let histr = hi.to_str();
+
+    let overhead_width = lostr.len() + histr.len() + 4;
+    let range_width = width_hint - overhead_width;;
+    let char_step = range / (range_width as f64);
+
+    try!(write!(w, "{} |", lostr));
+
+    let mut c = 0;
+    let mut v = lo;
+
+    while c < range_width && v < s.min {
+        try!(write!(w, " "));
+        v += char_step;
+        c += 1;
+    }
+    try!(write!(w, "["));
+    c += 1;
+    while c < range_width && v < q1 {
+        try!(write!(w, "-"));
+        v += char_step;
+        c += 1;
+    }
+    while c < range_width && v < q2 {
+        try!(write!(w, "*"));
+        v += char_step;
+        c += 1;
+    }
+    try!(write!(w, r"\#"));
+    c += 1;
+    while c < range_width && v < q3 {
+        try!(write!(w, "*"));
+        v += char_step;
+        c += 1;
+    }
+    while c < range_width && v < s.max {
+        try!(write!(w, "-"));
+        v += char_step;
+        c += 1;
+    }
+    try!(write!(w, "]"));
+    while c < range_width {
+        try!(write!(w, " "));
+        v += char_step;
+        c += 1;
+    }
+
+    try!(write!(w, "| {}", histr));
+    Ok(())
+}
+
+/// Returns a HashMap with the number of occurrences of every element in the
+/// sequence that the iterator exposes.
+pub fn freq_count<T: Iterator<U>, U: Eq+Hash>(mut iter: T) -> hashmap::HashMap<U, uint> {
+    let mut map: hashmap::HashMap<U,uint> = hashmap::HashMap::new();
+    for elem in iter {
+        map.insert_or_update_with(elem, 1, |_, count| *count += 1);
+    }
+    map
+}
+
+// Test vectors generated from R, using the script src/etc/stat-test-vectors.r.
+
+#[cfg(test)]
+mod tests {
+    use stats::Stats;
+    use stats::Summary;
+    use stats::write_5_number_summary;
+    use stats::write_boxplot;
+    use std::io;
+    use std::str;
+    use std::f64;
+
+    macro_rules! assert_approx_eq(
+        ($a:expr, $b:expr) => ({
+            let (a, b) = (&$a, &$b);
+            assert!((*a - *b).abs() < 1.0e-6,
+                    "{} is not approximately equal to {}", *a, *b);
+        })
+    )
+
+    fn check(samples: &[f64], summ: &Summary) {
+
+        let summ2 = Summary::new(samples);
+
+        let mut w = io::stdout();
+        let w = &mut w as &mut io::Writer;
+        (write!(w, "\n")).unwrap();
+        write_5_number_summary(w, &summ2).unwrap();
+        (write!(w, "\n")).unwrap();
+        write_boxplot(w, &summ2, 50).unwrap();
+        (write!(w, "\n")).unwrap();
+
+        assert_eq!(summ.sum, summ2.sum);
+        assert_eq!(summ.min, summ2.min);
+        assert_eq!(summ.max, summ2.max);
+        assert_eq!(summ.mean, summ2.mean);
+        assert_eq!(summ.median, summ2.median);
+
+        // We needed a few more digits to get exact equality on these
+        // but they're within float epsilon, which is 1.0e-6.
+        assert_approx_eq!(summ.var, summ2.var);
+        assert_approx_eq!(summ.std_dev, summ2.std_dev);
+        assert_approx_eq!(summ.std_dev_pct, summ2.std_dev_pct);
+        assert_approx_eq!(summ.median_abs_dev, summ2.median_abs_dev);
+        assert_approx_eq!(summ.median_abs_dev_pct, summ2.median_abs_dev_pct);
+
+        assert_eq!(summ.quartiles, summ2.quartiles);
+        assert_eq!(summ.iqr, summ2.iqr);
+    }
+
+    #[test]
+    fn test_min_max_nan() {
+        let xs = &[1.0, 2.0, f64::NAN, 3.0, 4.0];
+        let summary = Summary::new(xs);
+        assert_eq!(summary.min, 1.0);
+        assert_eq!(summary.max, 4.0);
+    }
+
+    #[test]
+    fn test_norm2() {
+        let val = &[
+            958.0000000000,
+            924.0000000000,
+        ];
+        let summ = &Summary {
+            sum: 1882.0000000000,
+            min: 924.0000000000,
+            max: 958.0000000000,
+            mean: 941.0000000000,
+            median: 941.0000000000,
+            var: 578.0000000000,
+            std_dev: 24.0416305603,
+            std_dev_pct: 2.5549022912,
+            median_abs_dev: 25.2042000000,
+            median_abs_dev_pct: 2.6784484591,
+            quartiles: (932.5000000000,941.0000000000,949.5000000000),
+            iqr: 17.0000000000,
+        };
+        check(val, summ);
+    }
+    #[test]
+    fn test_norm10narrow() {
+        let val = &[
+            966.0000000000,
+            985.0000000000,
+            1110.0000000000,
+            848.0000000000,
+            821.0000000000,
+            975.0000000000,
+            962.0000000000,
+            1157.0000000000,
+            1217.0000000000,
+            955.0000000000,
+        ];
+        let summ = &Summary {
+            sum: 9996.0000000000,
+            min: 821.0000000000,
+            max: 1217.0000000000,
+            mean: 999.6000000000,
+            median: 970.5000000000,
+            var: 16050.7111111111,
+            std_dev: 126.6914010938,
+            std_dev_pct: 12.6742097933,
+            median_abs_dev: 102.2994000000,
+            median_abs_dev_pct: 10.5408964451,
+            quartiles: (956.7500000000,970.5000000000,1078.7500000000),
+            iqr: 122.0000000000,
+        };
+        check(val, summ);
+    }
+    #[test]
+    fn test_norm10medium() {
+        let val = &[
+            954.0000000000,
+            1064.0000000000,
+            855.0000000000,
+            1000.0000000000,
+            743.0000000000,
+            1084.0000000000,
+            704.0000000000,
+            1023.0000000000,
+            357.0000000000,
+            869.0000000000,
+        ];
+        let summ = &Summary {
+            sum: 8653.0000000000,
+            min: 357.0000000000,
+            max: 1084.0000000000,
+            mean: 865.3000000000,
+            median: 911.5000000000,
+            var: 48628.4555555556,
+            std_dev: 220.5186059170,
+            std_dev_pct: 25.4846418487,
+            median_abs_dev: 195.7032000000,
+            median_abs_dev_pct: 21.4704552935,
+            quartiles: (771.0000000000,911.5000000000,1017.2500000000),
+            iqr: 246.2500000000,
+        };
+        check(val, summ);
+    }
+    #[test]
+    fn test_norm10wide() {
+        let val = &[
+            505.0000000000,
+            497.0000000000,
+            1591.0000000000,
+            887.0000000000,
+            1026.0000000000,
+            136.0000000000,
+            1580.0000000000,
+            940.0000000000,
+            754.0000000000,
+            1433.0000000000,
+        ];
+        let summ = &Summary {
+            sum: 9349.0000000000,
+            min: 136.0000000000,
+            max: 1591.0000000000,
+            mean: 934.9000000000,
+            median: 913.5000000000,
+            var: 239208.9888888889,
+            std_dev: 489.0899599142,
+            std_dev_pct: 52.3146817750,
+            median_abs_dev: 611.5725000000,
+            median_abs_dev_pct: 66.9482758621,
+            quartiles: (567.2500000000,913.5000000000,1331.2500000000),
+            iqr: 764.0000000000,
+        };
+        check(val, summ);
+    }
+    #[test]
+    fn test_norm25verynarrow() {
+        let val = &[
+            991.0000000000,
+            1018.0000000000,
+            998.0000000000,
+            1013.0000000000,
+            974.0000000000,
+            1007.0000000000,
+            1014.0000000000,
+            999.0000000000,
+            1011.0000000000,
+            978.0000000000,
+            985.0000000000,
+            999.0000000000,
+            983.0000000000,
+            982.0000000000,
+            1015.0000000000,
+            1002.0000000000,
+            977.0000000000,
+            948.0000000000,
+            1040.0000000000,
+            974.0000000000,
+            996.0000000000,
+            989.0000000000,
+            1015.0000000000,
+            994.0000000000,
+            1024.0000000000,
+        ];
+        let summ = &Summary {
+            sum: 24926.0000000000,
+            min: 948.0000000000,
+            max: 1040.0000000000,
+            mean: 997.0400000000,
+            median: 998.0000000000,
+            var: 393.2066666667,
+            std_dev: 19.8294393937,
+            std_dev_pct: 1.9888308788,
+            median_abs_dev: 22.2390000000,
+            median_abs_dev_pct: 2.2283567134,
+            quartiles: (983.0000000000,998.0000000000,1013.0000000000),
+            iqr: 30.0000000000,
+        };
+        check(val, summ);
+    }
+    #[test]
+    fn test_exp10a() {
+        let val = &[
+            23.0000000000,
+            11.0000000000,
+            2.0000000000,
+            57.0000000000,
+            4.0000000000,
+            12.0000000000,
+            5.0000000000,
+            29.0000000000,
+            3.0000000000,
+            21.0000000000,
+        ];
+        let summ = &Summary {
+            sum: 167.0000000000,
+            min: 2.0000000000,
+            max: 57.0000000000,
+            mean: 16.7000000000,
+            median: 11.5000000000,
+            var: 287.7888888889,
+            std_dev: 16.9643416875,
+            std_dev_pct: 101.5828843560,
+            median_abs_dev: 13.3434000000,
+            median_abs_dev_pct: 116.0295652174,
+            quartiles: (4.2500000000,11.5000000000,22.5000000000),
+            iqr: 18.2500000000,
+        };
+        check(val, summ);
+    }
+    #[test]
+    fn test_exp10b() {
+        let val = &[
+            24.0000000000,
+            17.0000000000,
+            6.0000000000,
+            38.0000000000,
+            25.0000000000,
+            7.0000000000,
+            51.0000000000,
+            2.0000000000,
+            61.0000000000,
+            32.0000000000,
+        ];
+        let summ = &Summary {
+            sum: 263.0000000000,
+            min: 2.0000000000,
+            max: 61.0000000000,
+            mean: 26.3000000000,
+            median: 24.5000000000,
+            var: 383.5666666667,
+            std_dev: 19.5848580967,
+            std_dev_pct: 74.4671410520,
+            median_abs_dev: 22.9803000000,
+            median_abs_dev_pct: 93.7971428571,
+            quartiles: (9.5000000000,24.5000000000,36.5000000000),
+            iqr: 27.0000000000,
+        };
+        check(val, summ);
+    }
+    #[test]
+    fn test_exp10c() {
+        let val = &[
+            71.0000000000,
+            2.0000000000,
+            32.0000000000,
+            1.0000000000,
+            6.0000000000,
+            28.0000000000,
+            13.0000000000,
+            37.0000000000,
+            16.0000000000,
+            36.0000000000,
+        ];
+        let summ = &Summary {
+            sum: 242.0000000000,
+            min: 1.0000000000,
+            max: 71.0000000000,
+            mean: 24.2000000000,
+            median: 22.0000000000,
+            var: 458.1777777778,
+            std_dev: 21.4050876611,
+            std_dev_pct: 88.4507754589,
+            median_abs_dev: 21.4977000000,
+            median_abs_dev_pct: 97.7168181818,
+            quartiles: (7.7500000000,22.0000000000,35.0000000000),
+            iqr: 27.2500000000,
+        };
+        check(val, summ);
+    }
+    #[test]
+    fn test_exp25() {
+        let val = &[
+            3.0000000000,
+            24.0000000000,
+            1.0000000000,
+            19.0000000000,
+            7.0000000000,
+            5.0000000000,
+            30.0000000000,
+            39.0000000000,
+            31.0000000000,
+            13.0000000000,
+            25.0000000000,
+            48.0000000000,
+            1.0000000000,
+            6.0000000000,
+            42.0000000000,
+            63.0000000000,
+            2.0000000000,
+            12.0000000000,
+            108.0000000000,
+            26.0000000000,
+            1.0000000000,
+            7.0000000000,
+            44.0000000000,
+            25.0000000000,
+            11.0000000000,
+        ];
+        let summ = &Summary {
+            sum: 593.0000000000,
+            min: 1.0000000000,
+            max: 108.0000000000,
+            mean: 23.7200000000,
+            median: 19.0000000000,
+            var: 601.0433333333,
+            std_dev: 24.5161851301,
+            std_dev_pct: 103.3565983562,
+            median_abs_dev: 19.2738000000,
+            median_abs_dev_pct: 101.4410526316,
+            quartiles: (6.0000000000,19.0000000000,31.0000000000),
+            iqr: 25.0000000000,
+        };
+        check(val, summ);
+    }
+    #[test]
+    fn test_binom25() {
+        let val = &[
+            18.0000000000,
+            17.0000000000,
+            27.0000000000,
+            15.0000000000,
+            21.0000000000,
+            25.0000000000,
+            17.0000000000,
+            24.0000000000,
+            25.0000000000,
+            24.0000000000,
+            26.0000000000,
+            26.0000000000,
+            23.0000000000,
+            15.0000000000,
+            23.0000000000,
+            17.0000000000,
+            18.0000000000,
+            18.0000000000,
+            21.0000000000,
+            16.0000000000,
+            15.0000000000,
+            31.0000000000,
+            20.0000000000,
+            17.0000000000,
+            15.0000000000,
+        ];
+        let summ = &Summary {
+            sum: 514.0000000000,
+            min: 15.0000000000,
+            max: 31.0000000000,
+            mean: 20.5600000000,
+            median: 20.0000000000,
+            var: 20.8400000000,
+            std_dev: 4.5650848842,
+            std_dev_pct: 22.2037202539,
+            median_abs_dev: 5.9304000000,
+            median_abs_dev_pct: 29.6520000000,
+            quartiles: (17.0000000000,20.0000000000,24.0000000000),
+            iqr: 7.0000000000,
+        };
+        check(val, summ);
+    }
+    #[test]
+    fn test_pois25lambda30() {
+        let val = &[
+            27.0000000000,
+            33.0000000000,
+            34.0000000000,
+            34.0000000000,
+            24.0000000000,
+            39.0000000000,
+            28.0000000000,
+            27.0000000000,
+            31.0000000000,
+            28.0000000000,
+            38.0000000000,
+            21.0000000000,
+            33.0000000000,
+            36.0000000000,
+            29.0000000000,
+            37.0000000000,
+            32.0000000000,
+            34.0000000000,
+            31.0000000000,
+            39.0000000000,
+            25.0000000000,
+            31.0000000000,
+            32.0000000000,
+            40.0000000000,
+            24.0000000000,
+        ];
+        let summ = &Summary {
+            sum: 787.0000000000,
+            min: 21.0000000000,
+            max: 40.0000000000,
+            mean: 31.4800000000,
+            median: 32.0000000000,
+            var: 26.5933333333,
+            std_dev: 5.1568724372,
+            std_dev_pct: 16.3814245145,
+            median_abs_dev: 5.9304000000,
+            median_abs_dev_pct: 18.5325000000,
+            quartiles: (28.0000000000,32.0000000000,34.0000000000),
+            iqr: 6.0000000000,
+        };
+        check(val, summ);
+    }
+    #[test]
+    fn test_pois25lambda40() {
+        let val = &[
+            42.0000000000,
+            50.0000000000,
+            42.0000000000,
+            46.0000000000,
+            34.0000000000,
+            45.0000000000,
+            34.0000000000,
+            49.0000000000,
+            39.0000000000,
+            28.0000000000,
+            40.0000000000,
+            35.0000000000,
+            37.0000000000,
+            39.0000000000,
+            46.0000000000,
+            44.0000000000,
+            32.0000000000,
+            45.0000000000,
+            42.0000000000,
+            37.0000000000,
+            48.0000000000,
+            42.0000000000,
+            33.0000000000,
+            42.0000000000,
+            48.0000000000,
+        ];
+        let summ = &Summary {
+            sum: 1019.0000000000,
+            min: 28.0000000000,
+            max: 50.0000000000,
+            mean: 40.7600000000,
+            median: 42.0000000000,
+            var: 34.4400000000,
+            std_dev: 5.8685603004,
+            std_dev_pct: 14.3978417577,
+            median_abs_dev: 5.9304000000,
+            median_abs_dev_pct: 14.1200000000,
+            quartiles: (37.0000000000,42.0000000000,45.0000000000),
+            iqr: 8.0000000000,
+        };
+        check(val, summ);
+    }
+    #[test]
+    fn test_pois25lambda50() {
+        let val = &[
+            45.0000000000,
+            43.0000000000,
+            44.0000000000,
+            61.0000000000,
+            51.0000000000,
+            53.0000000000,
+            59.0000000000,
+            52.0000000000,
+            49.0000000000,
+            51.0000000000,
+            51.0000000000,
+            50.0000000000,
+            49.0000000000,
+            56.0000000000,
+            42.0000000000,
+            52.0000000000,
+            51.0000000000,
+            43.0000000000,
+            48.0000000000,
+            48.0000000000,
+            50.0000000000,
+            42.0000000000,
+            43.0000000000,
+            42.0000000000,
+            60.0000000000,
+        ];
+        let summ = &Summary {
+            sum: 1235.0000000000,
+            min: 42.0000000000,
+            max: 61.0000000000,
+            mean: 49.4000000000,
+            median: 50.0000000000,
+            var: 31.6666666667,
+            std_dev: 5.6273143387,
+            std_dev_pct: 11.3913245723,
+            median_abs_dev: 4.4478000000,
+            median_abs_dev_pct: 8.8956000000,
+            quartiles: (44.0000000000,50.0000000000,52.0000000000),
+            iqr: 8.0000000000,
+        };
+        check(val, summ);
+    }
+    #[test]
+    fn test_unif25() {
+        let val = &[
+            99.0000000000,
+            55.0000000000,
+            92.0000000000,
+            79.0000000000,
+            14.0000000000,
+            2.0000000000,
+            33.0000000000,
+            49.0000000000,
+            3.0000000000,
+            32.0000000000,
+            84.0000000000,
+            59.0000000000,
+            22.0000000000,
+            86.0000000000,
+            76.0000000000,
+            31.0000000000,
+            29.0000000000,
+            11.0000000000,
+            41.0000000000,
+            53.0000000000,
+            45.0000000000,
+            44.0000000000,
+            98.0000000000,
+            98.0000000000,
+            7.0000000000,
+        ];
+        let summ = &Summary {
+            sum: 1242.0000000000,
+            min: 2.0000000000,
+            max: 99.0000000000,
+            mean: 49.6800000000,
+            median: 45.0000000000,
+            var: 1015.6433333333,
+            std_dev: 31.8691595957,
+            std_dev_pct: 64.1488719719,
+            median_abs_dev: 45.9606000000,
+            median_abs_dev_pct: 102.1346666667,
+            quartiles: (29.0000000000,45.0000000000,79.0000000000),
+            iqr: 50.0000000000,
+        };
+        check(val, summ);
+    }
+
+    #[test]
+    fn test_boxplot_nonpositive() {
+        fn t(s: &Summary, expected: ~str) {
+            use std::io::MemWriter;
+            let mut m = MemWriter::new();
+            write_boxplot(&mut m as &mut io::Writer, s, 30).unwrap();
+            let out = str::from_utf8_owned(m.unwrap()).unwrap();
+            assert_eq!(out, expected);
+        }
+
+        t(&Summary::new([-2.0, -1.0]), ~"-2 |[------******#*****---]| -1");
+        t(&Summary::new([0.0, 2.0]), ~"0 |[-------*****#*******---]| 2");
+        t(&Summary::new([-2.0, 0.0]), ~"-2 |[------******#******---]| 0");
+
+    }
+    #[test]
+    fn test_sum_f64s() {
+        assert_eq!([0.5, 3.2321, 1.5678].sum(), 5.2999);
+    }
+    #[test]
+    fn test_sum_f64_between_ints_that_sum_to_0() {
+        assert_eq!([1e30, 1.2, -1e30].sum(), 1.2);
+    }
+}
+
+#[cfg(test)]
+mod bench {
+    use BenchHarness;
+    use std::vec;
+    use stats::Stats;
+
+    #[bench]
+    pub fn sum_three_items(bh: &mut BenchHarness) {
+        bh.iter(|| {
+            [1e20, 1.5, -1e20].sum();
+        })
+    }
+    #[bench]
+    pub fn sum_many_f64(bh: &mut BenchHarness) {
+        let nums = [-1e30, 1e60, 1e30, 1.0, -1e60];
+        let v = vec::from_fn(500, |i| nums[i%5]);
+
+        bh.iter(|| {
+            v.sum();
+        })
+    }
+}
index 7ac338a92a4c08f63812f42c26a18fe114f66622..eb2b72cb630726dd885362164d76638088d3c721 100644 (file)
 #[crate_type = "rlib"];
 #[crate_type = "dylib"];
 #[license = "MIT/ASL2"];
+#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+      html_root_url = "http://static.rust-lang.org/doc/master")];
 
-#[allow(missing_doc)];
+#[feature(phase)];
+#[allow(deprecated_owned_vector)];
 
+#[cfg(test)] #[phase(syntax, link)] extern crate log;
 extern crate serialize;
 
 use std::io::BufReader;
@@ -62,9 +67,7 @@ mod imp {
 }
 
 /// A record specifying a time value in seconds and nanoseconds.
-
-
-#[deriving(Clone, Eq, Encodable, Decodable, Show)]
+#[deriving(Clone, Eq, TotalEq, Ord, TotalOrd, Encodable, Decodable, Show)]
 pub struct Timespec { sec: i64, nsec: i32 }
 /*
  * Timespec assumes that pre-epoch Timespecs have negative sec and positive
@@ -81,13 +84,6 @@ pub fn new(sec: i64, nsec: i32) -> Timespec {
     }
 }
 
-impl Ord for Timespec {
-    fn lt(&self, other: &Timespec) -> bool {
-        self.sec < other.sec ||
-            (self.sec == other.sec && self.nsec < other.nsec)
-    }
-}
-
 /**
  * Returns the current time as a `timespec` containing the seconds and
  * nanoseconds since 1970-01-01T00:00:00Z.
diff --git a/src/liburl/lib.rs b/src/liburl/lib.rs
new file mode 100644 (file)
index 0000000..0674797
--- /dev/null
@@ -0,0 +1,1287 @@
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! Types/fns concerning URLs (see RFC 3986)
+
+#[crate_id = "url#0.10-pre"];
+#[crate_type = "rlib"];
+#[crate_type = "dylib"];
+#[license = "MIT/ASL2"];
+#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+      html_root_url = "http://static.rust-lang.org/doc/master")];
+#[feature(default_type_params)];
+#[allow(deprecated_owned_vector)];
+
+extern crate collections;
+
+use std::cmp::Eq;
+use std::fmt;
+use std::hash::Hash;
+use std::io::BufReader;
+use std::from_str::FromStr;
+use std::uint;
+use std::vec_ng::Vec;
+
+use collections::HashMap;
+
+/// A Uniform Resource Locator (URL).  A URL is a form of URI (Uniform Resource
+/// Identifier) that includes network location information, such as hostname or
+/// port number.
+///
+/// # Example
+///
+/// ```rust
+/// use url::{Url, UserInfo};
+///
+/// let url = Url { scheme: ~"https",
+///                 user: Some(UserInfo { user: ~"username", pass: None }),
+///                 host: ~"example.com",
+///                 port: Some(~"8080"),
+///                 path: ~"/foo/bar",
+///                 query: vec!((~"baz", ~"qux")),
+///                 fragment: Some(~"quz") };
+/// // https://username@example.com:8080/foo/bar?baz=qux#quz
+/// ```
+#[deriving(Clone, Eq)]
+pub struct Url {
+    /// The scheme part of a URL, such as `https` in the above example.
+    scheme: ~str,
+    /// A URL subcomponent for user authentication.  `username` in the above example.
+    user: Option<UserInfo>,
+    /// A domain name or IP address.  For example, `example.com`.
+    host: ~str,
+    /// A TCP port number, for example `8080`.
+    port: Option<~str>,
+    /// The path component of a URL, for example `/foo/bar`.
+    path: ~str,
+    /// The query component of a URL.  `vec!((~"baz", ~"qux"))` represents the
+    /// fragment `baz=qux` in the above example.
+    query: Query,
+    /// The fragment component, such as `quz`.  Doesn't include the leading `#` character.
+    fragment: Option<~str>
+}
+
+#[deriving(Clone, Eq)]
+pub struct Path {
+    /// The path component of a URL, for example `/foo/bar`.
+    path: ~str,
+    /// The query component of a URL.  `vec!((~"baz", ~"qux"))` represents the
+    /// fragment `baz=qux` in the above example.
+    query: Query,
+    /// The fragment component, such as `quz`.  Doesn't include the leading `#` character.
+    fragment: Option<~str>
+}
+
+/// An optional subcomponent of a URI authority component.
+#[deriving(Clone, Eq)]
+pub struct UserInfo {
+    /// The user name.
+    user: ~str,
+    /// Password or other scheme-specific authentication information.
+    pass: Option<~str>
+}
+
+/// Represents the query component of a URI.
+pub type Query = Vec<(~str, ~str)>;
+
+impl Url {
+    pub fn new(scheme: ~str,
+               user: Option<UserInfo>,
+               host: ~str,
+               port: Option<~str>,
+               path: ~str,
+               query: Query,
+               fragment: Option<~str>)
+               -> Url {
+        Url {
+            scheme: scheme,
+            user: user,
+            host: host,
+            port: port,
+            path: path,
+            query: query,
+            fragment: fragment,
+        }
+    }
+}
+
+impl Path {
+    pub fn new(path: ~str,
+               query: Query,
+               fragment: Option<~str>)
+               -> Path {
+        Path {
+            path: path,
+            query: query,
+            fragment: fragment,
+        }
+    }
+}
+
+impl UserInfo {
+    #[inline]
+    pub fn new(user: ~str, pass: Option<~str>) -> UserInfo {
+        UserInfo { user: user, pass: pass }
+    }
+}
+
+fn encode_inner(s: &str, full_url: bool) -> ~str {
+    let mut rdr = BufReader::new(s.as_bytes());
+    let mut out = ~"";
+
+    loop {
+        let mut buf = [0];
+        let ch = match rdr.read(buf) {
+            Err(..) => break,
+            Ok(..) => buf[0] as char,
+        };
+
+        match ch {
+          // unreserved:
+          'A' .. 'Z' |
+          'a' .. 'z' |
+          '0' .. '9' |
+          '-' | '.' | '_' | '~' => {
+            out.push_char(ch);
+          }
+          _ => {
+              if full_url {
+                match ch {
+                  // gen-delims:
+                  ':' | '/' | '?' | '#' | '[' | ']' | '@' |
+
+                  // sub-delims:
+                  '!' | '$' | '&' | '"' | '(' | ')' | '*' |
+                  '+' | ',' | ';' | '=' => {
+                    out.push_char(ch);
+                  }
+
+                  _ => out.push_str(format!("%{:X}", ch as uint))
+                }
+            } else {
+                out.push_str(format!("%{:X}", ch as uint));
+            }
+          }
+        }
+    }
+
+    out
+}
+
+/**
+ * Encodes a URI by replacing reserved characters with percent-encoded
+ * character sequences.
+ *
+ * This function is compliant with RFC 3986.
+ *
+ * # Example
+ *
+ * ```rust
+ * use url::encode;
+ *
+ * let url = encode(&"https://example.com/Rust (programming language)");
+ * println!("{}", url); // https://example.com/Rust%20(programming%20language)
+ * ```
+ */
+pub fn encode(s: &str) -> ~str {
+    encode_inner(s, true)
+}
+
+/**
+ * Encodes a URI component by replacing reserved characters with percent
+ * encoded character sequences.
+ *
+ * This function is compliant with RFC 3986.
+ */
+
+pub fn encode_component(s: &str) -> ~str {
+    encode_inner(s, false)
+}
+
+fn decode_inner(s: &str, full_url: bool) -> ~str {
+    let mut rdr = BufReader::new(s.as_bytes());
+    let mut out = ~"";
+
+    loop {
+        let mut buf = [0];
+        let ch = match rdr.read(buf) {
+            Err(..) => break,
+            Ok(..) => buf[0] as char
+        };
+        match ch {
+          '%' => {
+            let mut bytes = [0, 0];
+            match rdr.read(bytes) {
+                Ok(2) => {}
+                _ => fail!() // FIXME: malformed url?
+            }
+            let ch = uint::parse_bytes(bytes, 16u).unwrap() as u8 as char;
+
+            if full_url {
+                // Only decode some characters:
+                match ch {
+                  // gen-delims:
+                  ':' | '/' | '?' | '#' | '[' | ']' | '@' |
+
+                  // sub-delims:
+                  '!' | '$' | '&' | '"' | '(' | ')' | '*' |
+                  '+' | ',' | ';' | '=' => {
+                    out.push_char('%');
+                    out.push_char(bytes[0u] as char);
+                    out.push_char(bytes[1u] as char);
+                  }
+
+                  ch => out.push_char(ch)
+                }
+            } else {
+                  out.push_char(ch);
+            }
+          }
+          ch => out.push_char(ch)
+        }
+    }
+
+    out
+}
+
+/**
+ * Decodes a percent-encoded string representing a URI.
+ *
+ * This will only decode escape sequences generated by `encode`.
+ *
+ * # Example
+ *
+ * ```rust
+ * use url::decode;
+ *
+ * let url = decode(&"https://example.com/Rust%20(programming%20language)");
+ * println!("{}", url); // https://example.com/Rust (programming language)
+ * ```
+ */
+pub fn decode(s: &str) -> ~str {
+    decode_inner(s, true)
+}
+
+/**
+ * Decode a string encoded with percent encoding.
+ */
+pub fn decode_component(s: &str) -> ~str {
+    decode_inner(s, false)
+}
+
+fn encode_plus(s: &str) -> ~str {
+    let mut rdr = BufReader::new(s.as_bytes());
+    let mut out = ~"";
+
+    loop {
+        let mut buf = [0];
+        let ch = match rdr.read(buf) {
+            Ok(..) => buf[0] as char,
+            Err(..) => break,
+        };
+        match ch {
+          'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '_' | '.' | '-' => {
+            out.push_char(ch);
+          }
+          ' ' => out.push_char('+'),
+          _ => out.push_str(format!("%{:X}", ch as uint))
+        }
+    }
+
+    out
+}
+
+/**
+ * Encode a hashmap to the 'application/x-www-form-urlencoded' media type.
+ */
+pub fn encode_form_urlencoded(m: &HashMap<~str, Vec<~str>>) -> ~str {
+    let mut out = ~"";
+    let mut first = true;
+
+    for (key, values) in m.iter() {
+        let key = encode_plus(*key);
+
+        for value in values.iter() {
+            if first {
+                first = false;
+            } else {
+                out.push_char('&');
+                first = false;
+            }
+
+            out.push_str(format!("{}={}", key, encode_plus(*value)));
+        }
+    }
+
+    out
+}
+
+/**
+ * Decode a string encoded with the 'application/x-www-form-urlencoded' media
+ * type into a hashmap.
+ */
+pub fn decode_form_urlencoded(s: &[u8]) -> HashMap<~str, Vec<~str>> {
+    let mut rdr = BufReader::new(s);
+    let mut m = HashMap::new();
+    let mut key = ~"";
+    let mut value = ~"";
+    let mut parsing_key = true;
+
+    loop {
+        let mut buf = [0];
+        let ch = match rdr.read(buf) {
+            Ok(..) => buf[0] as char,
+            Err(..) => break,
+        };
+        match ch {
+            '&' | ';' => {
+                if key != ~"" && value != ~"" {
+                    let mut values = match m.pop(&key) {
+                        Some(values) => values,
+                        None => vec!(),
+                    };
+
+                    values.push(value);
+                    m.insert(key, values);
+                }
+
+                parsing_key = true;
+                key = ~"";
+                value = ~"";
+            }
+            '=' => parsing_key = false,
+            ch => {
+                let ch = match ch {
+                    '%' => {
+                        let mut bytes = [0, 0];
+                        match rdr.read(bytes) {
+                            Ok(2) => {}
+                            _ => fail!() // FIXME: malformed?
+                        }
+                        uint::parse_bytes(bytes, 16u).unwrap() as u8 as char
+                    }
+                    '+' => ' ',
+                    ch => ch
+                };
+
+                if parsing_key {
+                    key.push_char(ch)
+                } else {
+                    value.push_char(ch)
+                }
+            }
+        }
+    }
+
+    if key != ~"" && value != ~"" {
+        let mut values = match m.pop(&key) {
+            Some(values) => values,
+            None => vec!(),
+        };
+
+        values.push(value);
+        m.insert(key, values);
+    }
+
+    m
+}
+
+
+fn split_char_first(s: &str, c: char) -> (~str, ~str) {
+    let len = s.len();
+    let mut index = len;
+    let mut mat = 0;
+    let mut rdr = BufReader::new(s.as_bytes());
+    loop {
+        let mut buf = [0];
+        let ch = match rdr.read(buf) {
+            Ok(..) => buf[0] as char,
+            Err(..) => break,
+        };
+        if ch == c {
+            // found a match, adjust markers
+            index = (rdr.tell().unwrap() as uint) - 1;
+            mat = 1;
+            break;
+        }
+    }
+    if index+mat == len {
+        return (s.slice(0, index).to_owned(), ~"");
+    } else {
+        return (s.slice(0, index).to_owned(),
+             s.slice(index + mat, s.len()).to_owned());
+    }
+}
+
+impl fmt::Show for UserInfo {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        match self.pass {
+            Some(ref pass) => write!(f.buf, "{}:{}@", self.user, *pass),
+            None => write!(f.buf, "{}@", self.user),
+        }
+    }
+}
+
+fn query_from_str(rawquery: &str) -> Query {
+    let mut query: Query = vec!();
+    if !rawquery.is_empty() {
+        for p in rawquery.split('&') {
+            let (k, v) = split_char_first(p, '=');
+            query.push((decode_component(k), decode_component(v)));
+        };
+    }
+    return query;
+}
+
+/**
+ * Converts an instance of a URI `Query` type to a string.
+ *
+ * # Example
+ *
+ * ```rust
+ * let query = vec!((~"title", ~"The Village"), (~"north", ~"52.91"), (~"west", ~"4.10"));
+ * println!("{}", url::query_to_str(&query));  // title=The%20Village&north=52.91&west=4.10
+ * ```
+ */
+#[allow(unused_must_use)]
+pub fn query_to_str(query: &Query) -> ~str {
+    use std::io::MemWriter;
+    use std::str;
+
+    let mut writer = MemWriter::new();
+    for (i, &(ref k, ref v)) in query.iter().enumerate() {
+        if i != 0 { write!(&mut writer, "&"); }
+        write!(&mut writer, "{}={}", encode_component(*k),
+               encode_component(*v));
+    }
+    str::from_utf8_lossy(writer.unwrap()).into_owned()
+}
+
+/**
+ * Returns a tuple of the URI scheme and the rest of the URI, or a parsing error.
+ *
+ * Does not include the separating `:` character.
+ *
+ * # Example
+ *
+ * ```rust
+ * use url::get_scheme;
+ *
+ * let scheme = match get_scheme("https://example.com/") {
+ *     Ok((sch, _)) => sch,
+ *     Err(_) => ~"(None)",
+ * };
+ * println!("Scheme in use: {}.", scheme); // Scheme in use: https.
+ * ```
+ */
+pub fn get_scheme(rawurl: &str) -> Result<(~str, ~str), ~str> {
+    for (i,c) in rawurl.chars().enumerate() {
+        match c {
+          'A' .. 'Z' | 'a' .. 'z' => continue,
+          '0' .. '9' | '+' | '-' | '.' => {
+            if i == 0 {
+                return Err(~"url: Scheme must begin with a letter.");
+            }
+            continue;
+          }
+          ':' => {
+            if i == 0 {
+                return Err(~"url: Scheme cannot be empty.");
+            } else {
+                return Ok((rawurl.slice(0,i).to_owned(),
+                                rawurl.slice(i+1,rawurl.len()).to_owned()));
+            }
+          }
+          _ => {
+            return Err(~"url: Invalid character in scheme.");
+          }
+        }
+    };
+    return Err(~"url: Scheme must be terminated with a colon.");
+}
+
+#[deriving(Clone, Eq)]
+enum Input {
+    Digit, // all digits
+    Hex, // digits and letters a-f
+    Unreserved // all other legal characters
+}
+
+// returns userinfo, host, port, and unparsed part, or an error
+fn get_authority(rawurl: &str) ->
+    Result<(Option<UserInfo>, ~str, Option<~str>, ~str), ~str> {
+    if !rawurl.starts_with("//") {
+        // there is no authority.
+        return Ok((None, ~"", None, rawurl.to_str()));
+    }
+
+    enum State {
+        Start, // starting state
+        PassHostPort, // could be in user or port
+        Ip6Port, // either in ipv6 host or port
+        Ip6Host, // are in an ipv6 host
+        InHost, // are in a host - may be ipv6, but don't know yet
+        InPort // are in port
+    }
+
+    let len = rawurl.len();
+    let mut st = Start;
+    let mut input = Digit; // most restricted, start here.
+
+    let mut userinfo = None;
+    let mut host = ~"";
+    let mut port = None;
+
+    let mut colon_count = 0;
+    let mut pos = 0;
+    let mut begin = 2;
+    let mut end = len;
+
+    for (i,c) in rawurl.chars().enumerate() {
+        if i < 2 { continue; } // ignore the leading //
+
+        // deal with input class first
+        match c {
+          '0' .. '9' => (),
+          'A' .. 'F' | 'a' .. 'f' => {
+            if input == Digit {
+                input = Hex;
+            }
+          }
+          'G' .. 'Z' | 'g' .. 'z' | '-' | '.' | '_' | '~' | '%' |
+          '&' |'\'' | '(' | ')' | '+' | '!' | '*' | ',' | ';' | '=' => {
+            input = Unreserved;
+          }
+          ':' | '@' | '?' | '#' | '/' => {
+            // separators, don't change anything
+          }
+          _ => {
+            return Err(~"Illegal character in authority");
+          }
+        }
+
+        // now process states
+        match c {
+          ':' => {
+            colon_count += 1;
+            match st {
+              Start => {
+                pos = i;
+                st = PassHostPort;
+              }
+              PassHostPort => {
+                // multiple colons means ipv6 address.
+                if input == Unreserved {
+                    return Err(
+                        ~"Illegal characters in IPv6 address.");
+                }
+                st = Ip6Host;
+              }
+              InHost => {
+                pos = i;
+                if input == Unreserved {
+                    // must be port
+                    host = rawurl.slice(begin, i).to_owned();
+                    st = InPort;
+                } else {
+                    // can't be sure whether this is an ipv6 address or a port
+                    st = Ip6Port;
+                }
+              }
+              Ip6Port => {
+                if input == Unreserved {
+                    return Err(~"Illegal characters in authority.");
+                }
+                st = Ip6Host;
+              }
+              Ip6Host => {
+                if colon_count > 7 {
+                    host = rawurl.slice(begin, i).to_owned();
+                    pos = i;
+                    st = InPort;
+                }
+              }
+              _ => {
+                return Err(~"Invalid ':' in authority.");
+              }
+            }
+            input = Digit; // reset input class
+          }
+
+          '@' => {
+            input = Digit; // reset input class
+            colon_count = 0; // reset count
+            match st {
+              Start => {
+                let user = rawurl.slice(begin, i).to_owned();
+                userinfo = Some(UserInfo::new(user, None));
+                st = InHost;
+              }
+              PassHostPort => {
+                let user = rawurl.slice(begin, pos).to_owned();
+                let pass = rawurl.slice(pos+1, i).to_owned();
+                userinfo = Some(UserInfo::new(user, Some(pass)));
+                st = InHost;
+              }
+              _ => {
+                return Err(~"Invalid '@' in authority.");
+              }
+            }
+            begin = i+1;
+          }
+
+          '?' | '#' | '/' => {
+            end = i;
+            break;
+          }
+          _ => ()
+        }
+    }
+
+    // finish up
+    match st {
+      Start => {
+        host = rawurl.slice(begin, end).to_owned();
+      }
+      PassHostPort | Ip6Port => {
+        if input != Digit {
+            return Err(~"Non-digit characters in port.");
+        }
+        host = rawurl.slice(begin, pos).to_owned();
+        port = Some(rawurl.slice(pos+1, end).to_owned());
+      }
+      Ip6Host | InHost => {
+        host = rawurl.slice(begin, end).to_owned();
+      }
+      InPort => {
+        if input != Digit {
+            return Err(~"Non-digit characters in port.");
+        }
+        port = Some(rawurl.slice(pos+1, end).to_owned());
+      }
+    }
+
+    let rest = rawurl.slice(end, len).to_owned();
+    return Ok((userinfo, host, port, rest));
+}
+
+
+// returns the path and unparsed part of url, or an error
+fn get_path(rawurl: &str, authority: bool) ->
+    Result<(~str, ~str), ~str> {
+    let len = rawurl.len();
+    let mut end = len;
+    for (i,c) in rawurl.chars().enumerate() {
+        match c {
+          'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '&' |'\'' | '(' | ')' | '.'
+          | '@' | ':' | '%' | '/' | '+' | '!' | '*' | ',' | ';' | '='
+          | '_' | '-' | '~' => {
+            continue;
+          }
+          '?' | '#' => {
+            end = i;
+            break;
+          }
+          _ => return Err(~"Invalid character in path.")
+        }
+    }
+
+    if authority {
+        if end != 0 && !rawurl.starts_with("/") {
+            return Err(~"Non-empty path must begin with\
+                               '/' in presence of authority.");
+        }
+    }
+
+    return Ok((decode_component(rawurl.slice(0, end)),
+                    rawurl.slice(end, len).to_owned()));
+}
+
+// returns the parsed query and the fragment, if present
+fn get_query_fragment(rawurl: &str) ->
+    Result<(Query, Option<~str>), ~str> {
+    if !rawurl.starts_with("?") {
+        if rawurl.starts_with("#") {
+            let f = decode_component(rawurl.slice(
+                                                1,
+                                                rawurl.len()));
+            return Ok((vec!(), Some(f)));
+        } else {
+            return Ok((vec!(), None));
+        }
+    }
+    let (q, r) = split_char_first(rawurl.slice(1, rawurl.len()), '#');
+    let f = if r.len() != 0 {
+        Some(decode_component(r)) } else { None };
+    return Ok((query_from_str(q), f));
+}
+
+/**
+ * Parses a URL, converting it from a string to `Url` representation.
+ *
+ * # Arguments
+ *
+ * `rawurl` - a string representing the full URL, including scheme.
+ *
+ * # Returns
+ *
+ * A `Url` struct type representing the URL.
+ */
+pub fn from_str(rawurl: &str) -> Result<Url, ~str> {
+    // scheme
+    let (scheme, rest) = match get_scheme(rawurl) {
+        Ok(val) => val,
+        Err(e) => return Err(e),
+    };
+
+    // authority
+    let (userinfo, host, port, rest) = match get_authority(rest) {
+        Ok(val) => val,
+        Err(e) => return Err(e),
+    };
+
+    // path
+    let has_authority = if host == ~"" { false } else { true };
+    let (path, rest) = match get_path(rest, has_authority) {
+        Ok(val) => val,
+        Err(e) => return Err(e),
+    };
+
+    // query and fragment
+    let (query, fragment) = match get_query_fragment(rest) {
+        Ok(val) => val,
+        Err(e) => return Err(e),
+    };
+
+    Ok(Url::new(scheme, userinfo, host, port, path, query, fragment))
+}
+
+pub fn path_from_str(rawpath: &str) -> Result<Path, ~str> {
+    let (path, rest) = match get_path(rawpath, false) {
+        Ok(val) => val,
+        Err(e) => return Err(e)
+    };
+
+    // query and fragment
+    let (query, fragment) = match get_query_fragment(rest) {
+        Ok(val) => val,
+        Err(e) => return Err(e),
+    };
+
+    Ok(Path{ path: path, query: query, fragment: fragment })
+}
+
+impl FromStr for Url {
+    fn from_str(s: &str) -> Option<Url> {
+        match from_str(s) {
+            Ok(url) => Some(url),
+            Err(_) => None
+        }
+    }
+}
+
+impl FromStr for Path {
+    fn from_str(s: &str) -> Option<Path> {
+        match path_from_str(s) {
+            Ok(path) => Some(path),
+            Err(_) => None
+        }
+    }
+}
+
+impl fmt::Show for Url {
+    /**
+     * Converts a URL from `Url` to string representation.
+     *
+     * # Arguments
+     *
+     * `url` - a URL.
+     *
+     * # Returns
+     *
+     * A string that contains the formatted URL. Note that this will usually
+     * be an inverse of `from_str` but might strip out unneeded separators;
+     * for example, "http://somehost.com?", when parsed and formatted, will
+     * result in just "http://somehost.com".
+     */
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        try!(write!(f.buf, "{}:", self.scheme));
+
+        if !self.host.is_empty() {
+            try!(write!(f.buf, "//"));
+            match self.user {
+                Some(ref user) => try!(write!(f.buf, "{}", *user)),
+                None => {}
+            }
+            match self.port {
+                Some(ref port) => try!(write!(f.buf, "{}:{}", self.host,
+                                                *port)),
+                None => try!(write!(f.buf, "{}", self.host)),
+            }
+        }
+
+        try!(write!(f.buf, "{}", self.path));
+
+        if !self.query.is_empty() {
+            try!(write!(f.buf, "?{}", query_to_str(&self.query)));
+        }
+
+        match self.fragment {
+            Some(ref fragment) => write!(f.buf, "\\#{}",
+                                         encode_component(*fragment)),
+            None => Ok(()),
+        }
+    }
+}
+
+impl fmt::Show for Path {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        try!(write!(f.buf, "{}", self.path));
+        if !self.query.is_empty() {
+            try!(write!(f.buf, "?{}", self.query))
+        }
+
+        match self.fragment {
+            Some(ref fragment) => {
+                write!(f.buf, "\\#{}", encode_component(*fragment))
+            }
+            None => Ok(())
+        }
+    }
+}
+
+impl<S: Writer> Hash<S> for Url {
+    fn hash(&self, state: &mut S) {
+        self.to_str().hash(state)
+    }
+}
+
+impl<S: Writer> Hash<S> for Path {
+    fn hash(&self, state: &mut S) {
+        self.to_str().hash(state)
+    }
+}
+
+// Put a few tests outside of the 'test' module so they can test the internal
+// functions and those functions don't need 'pub'
+
+#[test]
+fn test_split_char_first() {
+    let (u,v) = split_char_first("hello, sweet world", ',');
+    assert_eq!(u, ~"hello");
+    assert_eq!(v, ~" sweet world");
+
+    let (u,v) = split_char_first("hello sweet world", ',');
+    assert_eq!(u, ~"hello sweet world");
+    assert_eq!(v, ~"");
+}
+
+#[test]
+fn test_get_authority() {
+    let (u, h, p, r) = get_authority(
+        "//user:pass@rust-lang.org/something").unwrap();
+    assert_eq!(u, Some(UserInfo::new(~"user", Some(~"pass"))));
+    assert_eq!(h, ~"rust-lang.org");
+    assert!(p.is_none());
+    assert_eq!(r, ~"/something");
+
+    let (u, h, p, r) = get_authority(
+        "//rust-lang.org:8000?something").unwrap();
+    assert!(u.is_none());
+    assert_eq!(h, ~"rust-lang.org");
+    assert_eq!(p, Some(~"8000"));
+    assert_eq!(r, ~"?something");
+
+    let (u, h, p, r) = get_authority(
+        "//rust-lang.org#blah").unwrap();
+    assert!(u.is_none());
+    assert_eq!(h, ~"rust-lang.org");
+    assert!(p.is_none());
+    assert_eq!(r, ~"#blah");
+
+    // ipv6 tests
+    let (_, h, _, _) = get_authority(
+        "//2001:0db8:85a3:0042:0000:8a2e:0370:7334#blah").unwrap();
+    assert_eq!(h, ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334");
+
+    let (_, h, p, _) = get_authority(
+        "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000#blah").unwrap();
+    assert_eq!(h, ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334");
+    assert_eq!(p, Some(~"8000"));
+
+    let (u, h, p, _) = get_authority(
+        "//us:p@2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000#blah"
+    ).unwrap();
+    assert_eq!(u, Some(UserInfo::new(~"us", Some(~"p"))));
+    assert_eq!(h, ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334");
+    assert_eq!(p, Some(~"8000"));
+
+    // invalid authorities;
+    assert!(get_authority("//user:pass@rust-lang:something").is_err());
+    assert!(get_authority("//user@rust-lang:something:/path").is_err());
+    assert!(get_authority(
+        "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:800a").is_err());
+    assert!(get_authority(
+        "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000:00").is_err());
+
+    // these parse as empty, because they don't start with '//'
+    let (_, h, _, _) = get_authority("user:pass@rust-lang").unwrap();
+    assert_eq!(h, ~"");
+    let (_, h, _, _) = get_authority("rust-lang.org").unwrap();
+    assert_eq!(h, ~"");
+}
+
+#[test]
+fn test_get_path() {
+    let (p, r) = get_path("/something+%20orother", true).unwrap();
+    assert_eq!(p, ~"/something+ orother");
+    assert_eq!(r, ~"");
+    let (p, r) = get_path("test@email.com#fragment", false).unwrap();
+    assert_eq!(p, ~"test@email.com");
+    assert_eq!(r, ~"#fragment");
+    let (p, r) = get_path("/gen/:addr=?q=v", false).unwrap();
+    assert_eq!(p, ~"/gen/:addr=");
+    assert_eq!(r, ~"?q=v");
+
+    //failure cases
+    assert!(get_path("something?q", true).is_err());
+}
+
+#[cfg(test)]
+mod tests {
+    use {encode_form_urlencoded, decode_form_urlencoded,
+         decode, encode, from_str, encode_component, decode_component,
+         path_from_str, UserInfo, get_scheme};
+
+    use collections::HashMap;
+
+    #[test]
+    fn test_url_parse() {
+        let url = ~"http://user:pass@rust-lang.org:8080/doc/~u?s=v#something";
+
+        let up = from_str(url);
+        let u = up.unwrap();
+        assert_eq!(&u.scheme, &~"http");
+        assert_eq!(&u.user, &Some(UserInfo::new(~"user", Some(~"pass"))));
+        assert_eq!(&u.host, &~"rust-lang.org");
+        assert_eq!(&u.port, &Some(~"8080"));
+        assert_eq!(&u.path, &~"/doc/~u");
+        assert_eq!(&u.query, &vec!((~"s", ~"v")));
+        assert_eq!(&u.fragment, &Some(~"something"));
+    }
+
+    #[test]
+    fn test_path_parse() {
+        let path = ~"/doc/~u?s=v#something";
+
+        let up = path_from_str(path);
+        let u = up.unwrap();
+        assert_eq!(&u.path, &~"/doc/~u");
+        assert_eq!(&u.query, &vec!((~"s", ~"v")));
+        assert_eq!(&u.fragment, &Some(~"something"));
+    }
+
+    #[test]
+    fn test_url_parse_host_slash() {
+        let urlstr = ~"http://0.42.42.42/";
+        let url = from_str(urlstr).unwrap();
+        assert!(url.host == ~"0.42.42.42");
+        assert!(url.path == ~"/");
+    }
+
+    #[test]
+    fn test_path_parse_host_slash() {
+        let pathstr = ~"/";
+        let path = path_from_str(pathstr).unwrap();
+        assert!(path.path == ~"/");
+    }
+
+    #[test]
+    fn test_url_host_with_port() {
+        let urlstr = ~"scheme://host:1234";
+        let url = from_str(urlstr).unwrap();
+        assert_eq!(&url.scheme, &~"scheme");
+        assert_eq!(&url.host, &~"host");
+        assert_eq!(&url.port, &Some(~"1234"));
+        assert_eq!(&url.path, &~""); // is empty path really correct? Other tests think so
+        let urlstr = ~"scheme://host:1234/";
+        let url = from_str(urlstr).unwrap();
+        assert_eq!(&url.scheme, &~"scheme");
+        assert_eq!(&url.host, &~"host");
+        assert_eq!(&url.port, &Some(~"1234"));
+        assert_eq!(&url.path, &~"/");
+    }
+
+    #[test]
+    fn test_url_with_underscores() {
+        let urlstr = ~"http://dotcom.com/file_name.html";
+        let url = from_str(urlstr).unwrap();
+        assert!(url.path == ~"/file_name.html");
+    }
+
+    #[test]
+    fn test_path_with_underscores() {
+        let pathstr = ~"/file_name.html";
+        let path = path_from_str(pathstr).unwrap();
+        assert!(path.path == ~"/file_name.html");
+    }
+
+    #[test]
+    fn test_url_with_dashes() {
+        let urlstr = ~"http://dotcom.com/file-name.html";
+        let url = from_str(urlstr).unwrap();
+        assert!(url.path == ~"/file-name.html");
+    }
+
+    #[test]
+    fn test_path_with_dashes() {
+        let pathstr = ~"/file-name.html";
+        let path = path_from_str(pathstr).unwrap();
+        assert!(path.path == ~"/file-name.html");
+    }
+
+    #[test]
+    fn test_no_scheme() {
+        assert!(get_scheme("noschemehere.html").is_err());
+    }
+
+    #[test]
+    fn test_invalid_scheme_errors() {
+        assert!(from_str("99://something").is_err());
+        assert!(from_str("://something").is_err());
+    }
+
+    #[test]
+    fn test_full_url_parse_and_format() {
+        let url = ~"http://user:pass@rust-lang.org/doc?s=v#something";
+        assert_eq!(from_str(url).unwrap().to_str(), url);
+    }
+
+    #[test]
+    fn test_userless_url_parse_and_format() {
+        let url = ~"http://rust-lang.org/doc?s=v#something";
+        assert_eq!(from_str(url).unwrap().to_str(), url);
+    }
+
+    #[test]
+    fn test_queryless_url_parse_and_format() {
+        let url = ~"http://user:pass@rust-lang.org/doc#something";
+        assert_eq!(from_str(url).unwrap().to_str(), url);
+    }
+
+    #[test]
+    fn test_empty_query_url_parse_and_format() {
+        let url = ~"http://user:pass@rust-lang.org/doc?#something";
+        let should_be = ~"http://user:pass@rust-lang.org/doc#something";
+        assert_eq!(from_str(url).unwrap().to_str(), should_be);
+    }
+
+    #[test]
+    fn test_fragmentless_url_parse_and_format() {
+        let url = ~"http://user:pass@rust-lang.org/doc?q=v";
+        assert_eq!(from_str(url).unwrap().to_str(), url);
+    }
+
+    #[test]
+    fn test_minimal_url_parse_and_format() {
+        let url = ~"http://rust-lang.org/doc";
+        assert_eq!(from_str(url).unwrap().to_str(), url);
+    }
+
+    #[test]
+    fn test_url_with_port_parse_and_format() {
+        let url = ~"http://rust-lang.org:80/doc";
+        assert_eq!(from_str(url).unwrap().to_str(), url);
+    }
+
+    #[test]
+    fn test_scheme_host_only_url_parse_and_format() {
+        let url = ~"http://rust-lang.org";
+        assert_eq!(from_str(url).unwrap().to_str(), url);
+    }
+
+    #[test]
+    fn test_pathless_url_parse_and_format() {
+        let url = ~"http://user:pass@rust-lang.org?q=v#something";
+        assert_eq!(from_str(url).unwrap().to_str(), url);
+    }
+
+    #[test]
+    fn test_scheme_host_fragment_only_url_parse_and_format() {
+        let url = ~"http://rust-lang.org#something";
+        assert_eq!(from_str(url).unwrap().to_str(), url);
+    }
+
+    #[test]
+    fn test_url_component_encoding() {
+        let url = ~"http://rust-lang.org/doc%20uments?ba%25d%20=%23%26%2B";
+        let u = from_str(url).unwrap();
+        assert!(u.path == ~"/doc uments");
+        assert!(u.query == vec!((~"ba%d ", ~"#&+")));
+    }
+
+    #[test]
+    fn test_path_component_encoding() {
+        let path = ~"/doc%20uments?ba%25d%20=%23%26%2B";
+        let p = path_from_str(path).unwrap();
+        assert!(p.path == ~"/doc uments");
+        assert!(p.query == vec!((~"ba%d ", ~"#&+")));
+    }
+
+    #[test]
+    fn test_url_without_authority() {
+        let url = ~"mailto:test@email.com";
+        assert_eq!(from_str(url).unwrap().to_str(), url);
+    }
+
+    #[test]
+    fn test_encode() {
+        assert_eq!(encode(""), ~"");
+        assert_eq!(encode("http://example.com"), ~"http://example.com");
+        assert_eq!(encode("foo bar% baz"), ~"foo%20bar%25%20baz");
+        assert_eq!(encode(" "), ~"%20");
+        assert_eq!(encode("!"), ~"!");
+        assert_eq!(encode("\""), ~"\"");
+        assert_eq!(encode("#"), ~"#");
+        assert_eq!(encode("$"), ~"$");
+        assert_eq!(encode("%"), ~"%25");
+        assert_eq!(encode("&"), ~"&");
+        assert_eq!(encode("'"), ~"%27");
+        assert_eq!(encode("("), ~"(");
+        assert_eq!(encode(")"), ~")");
+        assert_eq!(encode("*"), ~"*");
+        assert_eq!(encode("+"), ~"+");
+        assert_eq!(encode(","), ~",");
+        assert_eq!(encode("/"), ~"/");
+        assert_eq!(encode(":"), ~":");
+        assert_eq!(encode(";"), ~";");
+        assert_eq!(encode("="), ~"=");
+        assert_eq!(encode("?"), ~"?");
+        assert_eq!(encode("@"), ~"@");
+        assert_eq!(encode("["), ~"[");
+        assert_eq!(encode("]"), ~"]");
+    }
+
+    #[test]
+    fn test_encode_component() {
+        assert_eq!(encode_component(""), ~"");
+        assert!(encode_component("http://example.com") ==
+            ~"http%3A%2F%2Fexample.com");
+        assert!(encode_component("foo bar% baz") ==
+            ~"foo%20bar%25%20baz");
+        assert_eq!(encode_component(" "), ~"%20");
+        assert_eq!(encode_component("!"), ~"%21");
+        assert_eq!(encode_component("#"), ~"%23");
+        assert_eq!(encode_component("$"), ~"%24");
+        assert_eq!(encode_component("%"), ~"%25");
+        assert_eq!(encode_component("&"), ~"%26");
+        assert_eq!(encode_component("'"), ~"%27");
+        assert_eq!(encode_component("("), ~"%28");
+        assert_eq!(encode_component(")"), ~"%29");
+        assert_eq!(encode_component("*"), ~"%2A");
+        assert_eq!(encode_component("+"), ~"%2B");
+        assert_eq!(encode_component(","), ~"%2C");
+        assert_eq!(encode_component("/"), ~"%2F");
+        assert_eq!(encode_component(":"), ~"%3A");
+        assert_eq!(encode_component(";"), ~"%3B");
+        assert_eq!(encode_component("="), ~"%3D");
+        assert_eq!(encode_component("?"), ~"%3F");
+        assert_eq!(encode_component("@"), ~"%40");
+        assert_eq!(encode_component("["), ~"%5B");
+        assert_eq!(encode_component("]"), ~"%5D");
+    }
+
+    #[test]
+    fn test_decode() {
+        assert_eq!(decode(""), ~"");
+        assert_eq!(decode("abc/def 123"), ~"abc/def 123");
+        assert_eq!(decode("abc%2Fdef%20123"), ~"abc%2Fdef 123");
+        assert_eq!(decode("%20"), ~" ");
+        assert_eq!(decode("%21"), ~"%21");
+        assert_eq!(decode("%22"), ~"%22");
+        assert_eq!(decode("%23"), ~"%23");
+        assert_eq!(decode("%24"), ~"%24");
+        assert_eq!(decode("%25"), ~"%");
+        assert_eq!(decode("%26"), ~"%26");
+        assert_eq!(decode("%27"), ~"'");
+        assert_eq!(decode("%28"), ~"%28");
+        assert_eq!(decode("%29"), ~"%29");
+        assert_eq!(decode("%2A"), ~"%2A");
+        assert_eq!(decode("%2B"), ~"%2B");
+        assert_eq!(decode("%2C"), ~"%2C");
+        assert_eq!(decode("%2F"), ~"%2F");
+        assert_eq!(decode("%3A"), ~"%3A");
+        assert_eq!(decode("%3B"), ~"%3B");
+        assert_eq!(decode("%3D"), ~"%3D");
+        assert_eq!(decode("%3F"), ~"%3F");
+        assert_eq!(decode("%40"), ~"%40");
+        assert_eq!(decode("%5B"), ~"%5B");
+        assert_eq!(decode("%5D"), ~"%5D");
+    }
+
+    #[test]
+    fn test_decode_component() {
+        assert_eq!(decode_component(""), ~"");
+        assert_eq!(decode_component("abc/def 123"), ~"abc/def 123");
+        assert_eq!(decode_component("abc%2Fdef%20123"), ~"abc/def 123");
+        assert_eq!(decode_component("%20"), ~" ");
+        assert_eq!(decode_component("%21"), ~"!");
+        assert_eq!(decode_component("%22"), ~"\"");
+        assert_eq!(decode_component("%23"), ~"#");
+        assert_eq!(decode_component("%24"), ~"$");
+        assert_eq!(decode_component("%25"), ~"%");
+        assert_eq!(decode_component("%26"), ~"&");
+        assert_eq!(decode_component("%27"), ~"'");
+        assert_eq!(decode_component("%28"), ~"(");
+        assert_eq!(decode_component("%29"), ~")");
+        assert_eq!(decode_component("%2A"), ~"*");
+        assert_eq!(decode_component("%2B"), ~"+");
+        assert_eq!(decode_component("%2C"), ~",");
+        assert_eq!(decode_component("%2F"), ~"/");
+        assert_eq!(decode_component("%3A"), ~":");
+        assert_eq!(decode_component("%3B"), ~";");
+        assert_eq!(decode_component("%3D"), ~"=");
+        assert_eq!(decode_component("%3F"), ~"?");
+        assert_eq!(decode_component("%40"), ~"@");
+        assert_eq!(decode_component("%5B"), ~"[");
+        assert_eq!(decode_component("%5D"), ~"]");
+    }
+
+    #[test]
+    fn test_encode_form_urlencoded() {
+        let mut m = HashMap::new();
+        assert_eq!(encode_form_urlencoded(&m), ~"");
+
+        m.insert(~"", vec!());
+        m.insert(~"foo", vec!());
+        assert_eq!(encode_form_urlencoded(&m), ~"");
+
+        let mut m = HashMap::new();
+        m.insert(~"foo", vec!(~"bar", ~"123"));
+        assert_eq!(encode_form_urlencoded(&m), ~"foo=bar&foo=123");
+
+        let mut m = HashMap::new();
+        m.insert(~"foo bar", vec!(~"abc", ~"12 = 34"));
+        assert!(encode_form_urlencoded(&m) ==
+            ~"foo+bar=abc&foo+bar=12+%3D+34");
+    }
+
+    #[test]
+    fn test_decode_form_urlencoded() {
+        assert_eq!(decode_form_urlencoded([]).len(), 0);
+
+        let s = "a=1&foo+bar=abc&foo+bar=12+%3D+34".as_bytes();
+        let form = decode_form_urlencoded(s);
+        assert_eq!(form.len(), 2);
+        assert_eq!(form.get(&~"a"), &vec!(~"1"));
+        assert_eq!(form.get(&~"foo bar"), &vec!(~"abc", ~"12 = 34"));
+    }
+}
index 922393d8bb3af09a44a7d64773a696ff2d3101e3..98c5f4139734de418ac7e0cf04070319a0477547 100644 (file)
@@ -58,6 +58,11 @@ fn main() {
 #[crate_type = "rlib"];
 #[crate_type = "dylib"];
 #[license = "MIT/ASL2"];
+#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+      html_root_url = "http://static.rust-lang.org/doc/master")];
+
+#[allow(deprecated_owned_vector)];
 
 #[feature(default_type_params)];
 
diff --git a/src/libworkcache/lib.rs b/src/libworkcache/lib.rs
new file mode 100644 (file)
index 0000000..219bb38
--- /dev/null
@@ -0,0 +1,528 @@
+// Copyright 2012-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.
+
+#[crate_id = "workcache#0.10-pre"];
+#[crate_type = "rlib"];
+#[crate_type = "dylib"];
+#[license = "MIT/ASL2"];
+#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+      html_root_url = "http://static.rust-lang.org/doc/master")];
+#[feature(phase)];
+#[allow(deprecated_owned_vector, visible_private_types)];
+
+#[phase(syntax, link)] extern crate log;
+extern crate serialize;
+extern crate collections;
+extern crate sync;
+
+use serialize::json;
+use serialize::json::ToJson;
+use serialize::{Encoder, Encodable, Decoder, Decodable};
+use sync::{Arc,RWArc};
+use collections::TreeMap;
+use std::str;
+use std::io;
+use std::io::{File, MemWriter};
+
+/**
+*
+* This is a loose clone of the [fbuild build system](https://github.com/felix-lang/fbuild),
+* made a touch more generic (not wired to special cases on files) and much
+* less metaprogram-y due to rust's comparative weakness there, relative to
+* python.
+*
+* It's based around _imperative builds_ that happen to have some function
+* calls cached. That is, it's _just_ a mechanism for describing cached
+* functions. This makes it much simpler and smaller than a "build system"
+* that produces an IR and evaluates it. The evaluation order is normal
+* function calls. Some of them just return really quickly.
+*
+* A cached function consumes and produces a set of _works_. A work has a
+* name, a kind (that determines how the value is to be checked for
+* freshness) and a value. Works must also be (de)serializable. Some
+* examples of works:
+*
+*    kind   name    value
+*   ------------------------
+*    cfg    os      linux
+*    file   foo.c   <sha1>
+*    url    foo.com <etag>
+*
+* Works are conceptually single units, but we store them most of the time
+* in maps of the form (type,name) => value. These are WorkMaps.
+*
+* A cached function divides the works it's interested in into inputs and
+* outputs, and subdivides those into declared (input) works and
+* discovered (input and output) works.
+*
+* A _declared_ input or is one that is given to the workcache before
+* any work actually happens, in the "prep" phase. Even when a function's
+* work-doing part (the "exec" phase) never gets called, it has declared
+* inputs, which can be checked for freshness (and potentially
+* used to determine that the function can be skipped).
+*
+* The workcache checks _all_ works for freshness, but uses the set of
+* discovered outputs from the _previous_ exec (which it will re-discover
+* and re-record each time the exec phase runs).
+*
+* Therefore the discovered works cached in the db might be a
+* mis-approximation of the current discoverable works, but this is ok for
+* the following reason: we assume that if an artifact A changed from
+* depending on B,C,D to depending on B,C,D,E, then A itself changed (as
+* part of the change-in-dependencies), so we will be ok.
+*
+* Each function has a single discriminated output work called its _result_.
+* This is only different from other works in that it is returned, by value,
+* from a call to the cacheable function; the other output works are used in
+* passing to invalidate dependencies elsewhere in the cache, but do not
+* otherwise escape from a function invocation. Most functions only have one
+* output work anyways.
+*
+* A database (the central store of a workcache) stores a mappings:
+*
+* (fn_name,{declared_input}) => ({discovered_input},
+*                                {discovered_output},result)
+*
+* (Note: fbuild, which workcache is based on, has the concept of a declared
+* output as separate from a discovered output. This distinction exists only
+* as an artifact of how fbuild works: via annotations on function types
+* and metaprogramming, with explicit dependency declaration as a fallback.
+* Workcache is more explicit about dependencies, and as such treats all
+* outputs the same, as discovered-during-the-last-run.)
+*
+*/
+
+#[deriving(Clone, Eq, Encodable, Decodable, Ord, TotalOrd, TotalEq)]
+struct WorkKey {
+    kind: ~str,
+    name: ~str
+}
+
+impl WorkKey {
+    pub fn new(kind: &str, name: &str) -> WorkKey {
+        WorkKey {
+            kind: kind.to_owned(),
+            name: name.to_owned(),
+        }
+    }
+}
+
+// FIXME #8883: The key should be a WorkKey and not a ~str.
+// This is working around some JSON weirdness.
+#[deriving(Clone, Eq, Encodable, Decodable)]
+struct WorkMap(TreeMap<~str, KindMap>);
+
+#[deriving(Clone, Eq, Encodable, Decodable)]
+struct KindMap(TreeMap<~str, ~str>);
+
+impl WorkMap {
+    fn new() -> WorkMap { WorkMap(TreeMap::new()) }
+
+    fn insert_work_key(&mut self, k: WorkKey, val: ~str) {
+        let WorkKey { kind, name } = k;
+        let WorkMap(ref mut map) = *self;
+        match map.find_mut(&name) {
+            Some(&KindMap(ref mut m)) => { m.insert(kind, val); return; }
+            None => ()
+        }
+        let mut new_map = TreeMap::new();
+        new_map.insert(kind, val);
+        map.insert(name, KindMap(new_map));
+    }
+}
+
+pub struct Database {
+    priv db_filename: Path,
+    priv db_cache: TreeMap<~str, ~str>,
+    db_dirty: bool
+}
+
+impl Database {
+
+    pub fn new(p: Path) -> Database {
+        let mut rslt = Database {
+            db_filename: p,
+            db_cache: TreeMap::new(),
+            db_dirty: false
+        };
+        if rslt.db_filename.exists() {
+            rslt.load();
+        }
+        rslt
+    }
+
+    pub fn prepare(&self,
+                   fn_name: &str,
+                   declared_inputs: &WorkMap)
+                   -> Option<(WorkMap, WorkMap, ~str)> {
+        let k = json_encode(&(fn_name, declared_inputs));
+        match self.db_cache.find(&k) {
+            None => None,
+            Some(v) => Some(json_decode(*v))
+        }
+    }
+
+    pub fn cache(&mut self,
+                 fn_name: &str,
+                 declared_inputs: &WorkMap,
+                 discovered_inputs: &WorkMap,
+                 discovered_outputs: &WorkMap,
+                 result: &str) {
+        let k = json_encode(&(fn_name, declared_inputs));
+        let v = json_encode(&(discovered_inputs,
+                              discovered_outputs,
+                              result));
+        self.db_cache.insert(k,v);
+        self.db_dirty = true
+    }
+
+    // FIXME #4330: This should have &mut self and should set self.db_dirty to false.
+    fn save(&self) -> io::IoResult<()> {
+        let mut f = File::create(&self.db_filename);
+        self.db_cache.to_json().to_pretty_writer(&mut f)
+    }
+
+    fn load(&mut self) {
+        assert!(!self.db_dirty);
+        assert!(self.db_filename.exists());
+        match File::open(&self.db_filename) {
+            Err(e) => fail!("Couldn't load workcache database {}: {}",
+                            self.db_filename.display(),
+                            e),
+            Ok(mut stream) => {
+                match json::from_reader(&mut stream) {
+                    Err(e) => fail!("Couldn't parse workcache database (from file {}): {}",
+                                    self.db_filename.display(), e.to_str()),
+                    Ok(r) => {
+                        let mut decoder = json::Decoder::new(r);
+                        self.db_cache = Decodable::decode(&mut decoder);
+                    }
+                }
+            }
+        }
+    }
+}
+
+#[unsafe_destructor]
+impl Drop for Database {
+    fn drop(&mut self) {
+        if self.db_dirty {
+            // FIXME: is failing the right thing to do here
+            self.save().unwrap();
+        }
+    }
+}
+
+pub type FreshnessMap = TreeMap<~str,extern fn(&str,&str)->bool>;
+
+#[deriving(Clone)]
+pub struct Context {
+    db: RWArc<Database>,
+    priv cfg: Arc<json::Object>,
+    /// Map from kinds (source, exe, url, etc.) to a freshness function.
+    /// The freshness function takes a name (e.g. file path) and value
+    /// (e.g. hash of file contents) and determines whether it's up-to-date.
+    /// For example, in the file case, this would read the file off disk,
+    /// hash it, and return the result of comparing the given hash and the
+    /// read hash for equality.
+    priv freshness: Arc<FreshnessMap>
+}
+
+pub struct Prep<'a> {
+    priv ctxt: &'a Context,
+    priv fn_name: &'a str,
+    priv declared_inputs: WorkMap,
+}
+
+pub struct Exec {
+    priv discovered_inputs: WorkMap,
+    priv discovered_outputs: WorkMap
+}
+
+enum Work<'a, T> {
+    WorkValue(T),
+    WorkFromTask(&'a Prep<'a>, Receiver<(Exec, T)>),
+}
+
+fn json_encode<'a, T:Encodable<json::Encoder<'a>>>(t: &T) -> ~str {
+    let mut writer = MemWriter::new();
+    let mut encoder = json::Encoder::new(&mut writer as &mut io::Writer);
+    t.encode(&mut encoder);
+    str::from_utf8_owned(writer.unwrap()).unwrap()
+}
+
+// FIXME(#5121)
+fn json_decode<T:Decodable<json::Decoder>>(s: &str) -> T {
+    debug!("json decoding: {}", s);
+    let j = json::from_str(s).unwrap();
+    let mut decoder = json::Decoder::new(j);
+    Decodable::decode(&mut decoder)
+}
+
+impl Context {
+
+    pub fn new(db: RWArc<Database>,
+               cfg: Arc<json::Object>) -> Context {
+        Context::new_with_freshness(db, cfg, Arc::new(TreeMap::new()))
+    }
+
+    pub fn new_with_freshness(db: RWArc<Database>,
+                              cfg: Arc<json::Object>,
+                              freshness: Arc<FreshnessMap>) -> Context {
+        Context {
+            db: db,
+            cfg: cfg,
+            freshness: freshness
+        }
+    }
+
+    pub fn prep<'a>(&'a self, fn_name: &'a str) -> Prep<'a> {
+        Prep::new(self, fn_name)
+    }
+
+    pub fn with_prep<'a,
+                     T>(
+                     &'a self,
+                     fn_name: &'a str,
+                     blk: |p: &mut Prep| -> T)
+                     -> T {
+        let mut p = self.prep(fn_name);
+        blk(&mut p)
+    }
+
+}
+
+impl Exec {
+    pub fn discover_input(&mut self,
+                          dependency_kind: &str,
+                          dependency_name: &str,
+                          dependency_val: &str) {
+        debug!("Discovering input {} {} {}", dependency_kind, dependency_name, dependency_val);
+        self.discovered_inputs.insert_work_key(WorkKey::new(dependency_kind, dependency_name),
+                                 dependency_val.to_owned());
+    }
+    pub fn discover_output(&mut self,
+                           dependency_kind: &str,
+                           dependency_name: &str,
+                           dependency_val: &str) {
+        debug!("Discovering output {} {} {}", dependency_kind, dependency_name, dependency_val);
+        self.discovered_outputs.insert_work_key(WorkKey::new(dependency_kind, dependency_name),
+                                 dependency_val.to_owned());
+    }
+
+    // returns pairs of (kind, name)
+    pub fn lookup_discovered_inputs(&self) -> ~[(~str, ~str)] {
+        let mut rs = ~[];
+        let WorkMap(ref discovered_inputs) = self.discovered_inputs;
+        for (k, v) in discovered_inputs.iter() {
+            let KindMap(ref vmap) = *v;
+            for (k1, _) in vmap.iter() {
+                rs.push((k1.clone(), k.clone()));
+            }
+        }
+        rs
+    }
+}
+
+impl<'a> Prep<'a> {
+    fn new(ctxt: &'a Context, fn_name: &'a str) -> Prep<'a> {
+        Prep {
+            ctxt: ctxt,
+            fn_name: fn_name,
+            declared_inputs: WorkMap::new()
+        }
+    }
+
+    pub fn lookup_declared_inputs(&self) -> ~[~str] {
+        let mut rs = ~[];
+        let WorkMap(ref declared_inputs) = self.declared_inputs;
+        for (_, v) in declared_inputs.iter() {
+            let KindMap(ref vmap) = *v;
+            for (inp, _) in vmap.iter() {
+                rs.push(inp.clone());
+            }
+        }
+        rs
+    }
+}
+
+impl<'a> Prep<'a> {
+    pub fn declare_input(&mut self, kind: &str, name: &str, val: &str) {
+        debug!("Declaring input {} {} {}", kind, name, val);
+        self.declared_inputs.insert_work_key(WorkKey::new(kind, name),
+                                 val.to_owned());
+    }
+
+    fn is_fresh(&self, cat: &str, kind: &str,
+                name: &str, val: &str) -> bool {
+        let k = kind.to_owned();
+        let f = self.ctxt.freshness.get().find(&k);
+        debug!("freshness for: {}/{}/{}/{}", cat, kind, name, val)
+        let fresh = match f {
+            None => fail!("missing freshness-function for '{}'", kind),
+            Some(f) => (*f)(name, val)
+        };
+        if fresh {
+            info!("{} {}:{} is fresh", cat, kind, name);
+        } else {
+            info!("{} {}:{} is not fresh", cat, kind, name);
+        }
+        fresh
+    }
+
+    fn all_fresh(&self, cat: &str, map: &WorkMap) -> bool {
+        let WorkMap(ref map) = *map;
+        for (k_name, kindmap) in map.iter() {
+            let KindMap(ref kindmap_) = *kindmap;
+            for (k_kind, v) in kindmap_.iter() {
+               if ! self.is_fresh(cat, *k_kind, *k_name, *v) {
+                  return false;
+            }
+          }
+        }
+        return true;
+    }
+
+    pub fn exec<'a, T:Send +
+        Encodable<json::Encoder<'a>> +
+        Decodable<json::Decoder>>(
+            &'a self, blk: proc(&mut Exec) -> T) -> T {
+        self.exec_work(blk).unwrap()
+    }
+
+    fn exec_work<'a, T:Send +
+        Encodable<json::Encoder<'a>> +
+        Decodable<json::Decoder>>( // FIXME(#5121)
+            &'a self, blk: proc(&mut Exec) -> T) -> Work<'a, T> {
+        let mut bo = Some(blk);
+
+        debug!("exec_work: looking up {} and {:?}", self.fn_name,
+               self.declared_inputs);
+        let cached = self.ctxt.db.read(|db| {
+            db.prepare(self.fn_name, &self.declared_inputs)
+        });
+
+        match cached {
+            Some((ref disc_in, ref disc_out, ref res))
+            if self.all_fresh("declared input",&self.declared_inputs) &&
+               self.all_fresh("discovered input", disc_in) &&
+               self.all_fresh("discovered output", disc_out) => {
+                debug!("Cache hit!");
+                debug!("Trying to decode: {:?} / {:?} / {}",
+                       disc_in, disc_out, *res);
+                Work::from_value(json_decode(*res))
+            }
+
+            _ => {
+                debug!("Cache miss!");
+                let (tx, rx) = channel();
+                let blk = bo.take_unwrap();
+
+                // FIXME: What happens if the task fails?
+                spawn(proc() {
+                    let mut exe = Exec {
+                        discovered_inputs: WorkMap::new(),
+                        discovered_outputs: WorkMap::new(),
+                    };
+                    let v = blk(&mut exe);
+                    tx.send((exe, v));
+                });
+                Work::from_task(self, rx)
+            }
+        }
+    }
+}
+
+impl<'a, T:Send +
+       Encodable<json::Encoder<'a>> +
+       Decodable<json::Decoder>>
+    Work<'a, T> { // FIXME(#5121)
+
+    pub fn from_value(elt: T) -> Work<'a, T> {
+        WorkValue(elt)
+    }
+    pub fn from_task(prep: &'a Prep<'a>, port: Receiver<(Exec, T)>)
+        -> Work<'a, T> {
+        WorkFromTask(prep, port)
+    }
+
+    pub fn unwrap(self) -> T {
+        match self {
+            WorkValue(v) => v,
+            WorkFromTask(prep, port) => {
+                let (exe, v) = port.recv();
+                let s = json_encode(&v);
+                prep.ctxt.db.write(|db| {
+                    db.cache(prep.fn_name,
+                             &prep.declared_inputs,
+                             &exe.discovered_inputs,
+                             &exe.discovered_outputs,
+                             s)
+                });
+                v
+            }
+        }
+    }
+}
+
+
+#[test]
+#[cfg(not(target_os="android"))] // FIXME(#10455)
+fn test() {
+    use std::os;
+    use std::io::{fs, Process};
+    use std::str::from_utf8_owned;
+
+    // Create a path to a new file 'filename' in the directory in which
+    // this test is running.
+    fn make_path(filename: ~str) -> Path {
+        let pth = os::self_exe_path().expect("workcache::test failed").with_filename(filename);
+        if pth.exists() {
+            fs::unlink(&pth).unwrap();
+        }
+        return pth;
+    }
+
+    let pth = make_path(~"foo.c");
+    File::create(&pth).write(bytes!("int main() { return 0; }")).unwrap();
+
+    let db_path = make_path(~"db.json");
+
+    let cx = Context::new(RWArc::new(Database::new(db_path)),
+                          Arc::new(TreeMap::new()));
+
+    let s = cx.with_prep("test1", |prep| {
+
+        let subcx = cx.clone();
+        let pth = pth.clone();
+
+        let contents = File::open(&pth).read_to_end().unwrap();
+        let file_content = from_utf8_owned(contents).unwrap();
+
+        // FIXME (#9639): This needs to handle non-utf8 paths
+        prep.declare_input("file", pth.as_str().unwrap(), file_content);
+        prep.exec(proc(_exe) {
+            let out = make_path(~"foo.o");
+            // FIXME (#9639): This needs to handle non-utf8 paths
+            Process::status("gcc", [pth.as_str().unwrap().to_owned(),
+                                    ~"-o",
+                                    out.as_str().unwrap().to_owned()]).unwrap();
+
+            let _proof_of_concept = subcx.prep("subfn");
+            // Could run sub-rules inside here.
+
+            // FIXME (#9639): This needs to handle non-utf8 paths
+            out.as_str().unwrap().to_owned()
+        })
+    });
+
+    println!("{}", s);
+}
index 9cb6ece80ce31e2f1440488d48c283df23ee2d5c..266933df8c51c94d595ec935c00ea746b1c1204e 100644 (file)
@@ -19,38 +19,21 @@ __morestack:
         .set noreorder
         .set nomacro
 
-        // n.b. most of this is probably unnecessary. I know very little mips
-        //      assembly, and I didn't have anything to test on, so I wasn't
-        //      brave enough to try to trim this down.
+        addiu $29, $29, -4
+        sw $30, 0($29)
 
-        addiu $29, $29, -12
-        sw $31, 8($29)
-        sw $30, 4($29)
-        sw $23, 0($29)
-
-        // 24 = 12 (current) + 12 (previous)
-        .cfi_def_cfa_offset 24
+        // 16 = 4 (current) + 12 (previous)
+        .cfi_def_cfa_offset 16
         .cfi_offset 31, -4
-        .cfi_offset 30, -20
-        .cfi_offset 23, -24
+        .cfi_offset 30, -16
 
-        move $23, $28
         move $30, $29
         .cfi_def_cfa_register 30
 
-        // Save argument registers of the original function
-        addiu $29, $29, -32
-        sw $4, 16($29)
-        sw $5, 20($29)
-        sw $6, 24($29)
-        sw $7, 28($29)
-
-        move $4, $14     // Size of stack arguments
-        addu $5, $30, 24 // Address of stack arguments
-        move $6, $15     // The amount of stack needed
+        // O32 ABI always reserves 16 bytes for arguments
+        addiu $29, $29, -16
 
-        move $28, $23
-        lw $25, %call16(rust_stack_exhausted)($23)
+        lw $25, %call16(rust_stack_exhausted)($28)
         jalr $25
         nop
 
index 98e5c8c2b5bbd59316a209d5c1e41673bbe95388..7479ddc3e57d39555f965dd799b4075899f40708 100644 (file)
@@ -21,11 +21,11 @@ impl cat {
 
         pub fn eat(&mut self) -> bool {
             if self.how_hungry > 0 {
-                error!("OM NOM NOM");
+                println!("OM NOM NOM");
                 self.how_hungry -= 2;
                 return true;
             } else {
-                error!("Not hungry!");
+                println!("Not hungry!");
                 return false;
             }
         }
@@ -33,7 +33,7 @@ pub fn eat(&mut self) -> bool {
 
     impl cat {
         pub fn meow(&mut self) {
-            error!("Meow");
+            println!("Meow");
             self.meows += 1u;
             if self.meows % 5u == 0u {
                 self.how_hungry += 1;
index 79bb5aef764b32e0d4615ed7859ab6735fc05e38..e7e0e6d450a7e7745b8d9767b84b1d0d7efea735 100644 (file)
@@ -25,7 +25,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 
     impl cat {
         fn meow(&mut self) {
-            error!("Meow");
+            println!("Meow");
             self.meows += 1u;
             if self.meows % 5u == 0u {
                 self.how_hungry += 1;
@@ -39,12 +39,12 @@ impl cat {
 
         pub fn eat(&mut self) -> bool {
             if self.how_hungry > 0 {
-                error!("OM NOM NOM");
+                println!("OM NOM NOM");
                 self.how_hungry -= 2;
                 return true;
             }
             else {
-                error!("Not hungry!");
+                println!("Not hungry!");
                 return false;
             }
         }
index 72345022282bfb42bf04f66ec8d86986ca8777e2..d2c79bbe9cb2dc44ede7f153a1e0373b00d2c280 100644 (file)
@@ -26,7 +26,7 @@ pub fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t,
 
 pub fn fact(n: uint) -> uint {
     unsafe {
-        info!("n = {}", n);
+        println!("n = {}", n);
         rustrt::rust_dbg_call(cb, n)
     }
 }
index 701c9f643ff4796cc8205529a3618de4918129c2..ef5c141a3d5082a0f9f9cf2e0624309c6b324057 100644 (file)
@@ -11,8 +11,6 @@
 #[crate_id="issue_2526#0.2"];
 #[crate_type = "lib"];
 
-extern crate extra;
-
 struct arc_destruct<T> {
   _data: int,
 }
index 1a287b5e625cf70f4cf0bf97e3d5b3780fb16a1a..448d545ee229447c1e1d3f08542006dbd87b6349 100644 (file)
@@ -12,7 +12,6 @@
 #[crate_id="req"];
 #[crate_type = "lib"];
 
-extern crate extra;
 extern crate collections;
 
 use std::cell::RefCell;
index 4fc7de9f7d2f5556cee26d9495fbc73fbf972388..10725981a063d2f3574a6ab62da5ce4876379f2a 100644 (file)
@@ -8,6 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#[feature(phase)];
+#[phase(syntax, link)] extern crate log;
+
 pub fn foo<T>() {
     fn death() -> int { fail!() }
     debug!("{:?}", (||{ death() })());
index aec0bfb1e657cc7e17f13085c520a38f97eb1327..db86be1dfd442d38fc1284f24fd3b0bd3595cea5 100644 (file)
@@ -25,6 +25,6 @@ fn main() {
 
     for i in range(0u, n) {
         let x = i.to_str();
-        info!("{}", x);
+        println!("{}", x);
     }
 }
index bc729acbdf58b8f725dff526630d05ca1c2e6e60..be081afc39e8052083904a69087145769278b28c 100644 (file)
@@ -40,7 +40,7 @@ fn server(requests: &Receiver<request>, responses: &Sender<uint>) {
         match requests.recv_opt() {
           Some(get_count) => { responses.send(count.clone()); }
           Some(bytes(b)) => {
-            //error!("server: received {:?} bytes", b);
+            //println!("server: received {:?} bytes", b);
             count += b;
           }
           None => { done = true; }
@@ -48,7 +48,7 @@ fn server(requests: &Receiver<request>, responses: &Sender<uint>) {
         }
     }
     responses.send(count);
-    //error!("server exiting");
+    //println!("server exiting");
 }
 
 fn run(args: &[~str]) {
@@ -66,10 +66,10 @@ fn run(args: &[~str]) {
         worker_results.push(builder.future_result());
         builder.spawn(proc() {
             for _ in range(0u, size / workers) {
-                //error!("worker {:?}: sending {:?} bytes", i, num_bytes);
+                //println!("worker {:?}: sending {:?} bytes", i, num_bytes);
                 to_child.send(bytes(num_bytes));
             }
-            //error!("worker {:?} exiting", i);
+            //println!("worker {:?} exiting", i);
         });
     }
     task::spawn(proc() {
@@ -80,7 +80,7 @@ fn run(args: &[~str]) {
         r.recv();
     }
 
-    //error!("sending stop message");
+    //println!("sending stop message");
     to_child.send(stop);
     move_out(to_child);
     let result = from_child.recv();
@@ -103,6 +103,6 @@ fn main() {
         args.clone()
     };
 
-    info!("{:?}", args);
+    println!("{:?}", args);
     run(args);
 }
index a24e830a98748a1b3af903825505e38622d97f73..518b2d4c9ef1d2498cd1a8bd111e41cb53d80045 100644 (file)
@@ -35,7 +35,7 @@ fn server(requests: &Receiver<request>, responses: &Sender<uint>) {
         match requests.recv_opt() {
           Some(get_count) => { responses.send(count.clone()); }
           Some(bytes(b)) => {
-            //error!("server: received {:?} bytes", b);
+            //println!("server: received {:?} bytes", b);
             count += b;
           }
           None => { done = true; }
@@ -43,7 +43,7 @@ fn server(requests: &Receiver<request>, responses: &Sender<uint>) {
         }
     }
     responses.send(count);
-    //error!("server exiting");
+    //println!("server exiting");
 }
 
 fn run(args: &[~str]) {
@@ -60,10 +60,10 @@ fn run(args: &[~str]) {
         worker_results.push(builder.future_result());
         builder.spawn(proc() {
             for _ in range(0u, size / workers) {
-                //error!("worker {:?}: sending {:?} bytes", i, num_bytes);
+                //println!("worker {:?}: sending {:?} bytes", i, num_bytes);
                 to_child.send(bytes(num_bytes));
             }
-            //error!("worker {:?} exiting", i);
+            //println!("worker {:?} exiting", i);
         });
         from_parent
     } else {
@@ -74,10 +74,10 @@ fn run(args: &[~str]) {
             worker_results.push(builder.future_result());
             builder.spawn(proc() {
                 for _ in range(0u, size / workers) {
-                    //error!("worker {:?}: sending {:?} bytes", i, num_bytes);
+                    //println!("worker {:?}: sending {:?} bytes", i, num_bytes);
                     to_child.send(bytes(num_bytes));
                 }
-                //error!("worker {:?} exiting", i);
+                //println!("worker {:?} exiting", i);
             });
         }
         from_parent
@@ -90,7 +90,7 @@ fn run(args: &[~str]) {
         r.recv();
     }
 
-    //error!("sending stop message");
+    //println!("sending stop message");
     //to_child.send(stop);
     //move_out(to_child);
     let result = from_child.recv();
@@ -113,6 +113,6 @@ fn main() {
         args.clone()
     };
 
-    info!("{:?}", args);
+    println!("{:?}", args);
     run(args);
 }
index 6b91d1d534b624bee1cdc5e527c76a32c2d05cde..6bf25f2149ce8e1c908b4ba3d682739a488844b5 100644 (file)
@@ -57,7 +57,7 @@ fn thread_ring(i: uint, count: uint, num_chan: pipe, num_port: pipe) {
     let mut num_port = Some(num_port);
     // Send/Receive lots of messages.
     for j in range(0u, count) {
-        //error!("task %?, iter %?", i, j);
+        //println!("task %?, iter %?", i, j);
         let num_chan2 = num_chan.take_unwrap();
         let num_port2 = num_port.take_unwrap();
         send(&num_chan2, i * j);
@@ -89,7 +89,7 @@ fn main() {
     let mut futures = ~[];
 
     for i in range(1u, num_tasks) {
-        //error!("spawning %?", i);
+        //println!("spawning %?", i);
         let (new_chan, num_port) = init();
         let num_chan_2 = num_chan.clone();
         let new_future = Future::spawn(proc() {
index 2d52f125747e842be12951d4d36f46ae7cc9cf85..90d7da65e1f8f0201c5fd3967b7eca710755295f 100644 (file)
@@ -52,7 +52,7 @@ fn thread_ring(i: uint, count: uint, num_chan: pipe, num_port: pipe) {
     let mut num_port = Some(num_port);
     // Send/Receive lots of messages.
     for j in range(0u, count) {
-        //error!("task %?, iter %?", i, j);
+        //println!("task %?, iter %?", i, j);
         let num_chan2 = num_chan.take_unwrap();
         let num_port2 = num_port.take_unwrap();
         send(&num_chan2, i * j);
@@ -84,7 +84,7 @@ fn main() {
     let mut futures = ~[];
 
     for i in range(1u, num_tasks) {
-        //error!("spawning %?", i);
+        //println!("spawning %?", i);
         let (new_chan, num_port) = init();
         let num_chan_2 = num_chan.clone();
         let new_future = Future::spawn(proc() {
index 1e00915e3f594d82b8d7d489c1c58bcf4123e4b5..044c4b07d443e5a896e7a65e98fa11cd5c634e7a 100644 (file)
@@ -17,8 +17,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 use std::os;
 use std::uint;
 
index b636554cffb65e85a35c8ba287720768d201d360..1a7302207d968857a30e34ece9624c669915fe82 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 use std::os;
 use std::uint;
 
index 40e6a0a7beda2fe0150f2a203c80525023830636..5f445de069ca208aa1cdb3c628dbe5bb74ad36ba 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 use std::task::spawn;
 use std::os;
 use std::uint;
index d308ed6a7d1d70ea21c2d5a3c2edb578476f3f22..889d663fb5b82d4bc65f96e80d750e07d3754528 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 use std::os;
 
 fn ack(m: int, n: int) -> int {
index 0dead2ca376ef2de7d5a1bd1fc01438373cfb030..51aff9699960fe1a9f82a5c367733f60e4b02340 100644 (file)
@@ -10,8 +10,6 @@
 
 // chameneos
 
-extern crate extra;
-
 use std::option;
 use std::os;
 use std::task;
index 4a4b2e8e875caf909920b0927572530ee68e1939..785481819aa1c91090b16463b01c2bde91f5fb8e 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 use std::os;
 
 fn fib(n: int) -> int {
index 767559664a45725cbb9aade6f9d7afcfa5ba00c2..2ddcd2b5bfd2824317ac6d11f2708e953aec022b 100644 (file)
@@ -13,7 +13,6 @@
 // ignore-pretty the `let to_child` line gets an extra newline
 // multi tasking k-nucleotide
 
-extern crate extra;
 extern crate collections;
 
 use std::cmp::Ord;
index 318bd16a8b22177ed79ed17d3ef0ce4f7498e063..78cd5f4c30a36e6d019f859a2cc2ae5eb6ea4f96 100644 (file)
@@ -70,7 +70,7 @@ fn stress_task(id: int) {
         let n = 15;
         assert_eq!(fib(n), fib(n));
         i += 1;
-        error!("{}: Completed {} iterations", id, i);
+        println!("{}: Completed {} iterations", id, i);
     }
 }
 
index 839ffe99e164995eaef4e7930fa03f547585da25..7f2cd368219d392eaa075073e2d54b2463fbe3ae 100644 (file)
@@ -41,7 +41,7 @@ fn roundtrip(id: int, n_tasks: int, p: &Receiver<int>, ch: &Sender<int>) {
             return;
           }
           token => {
-            info!("thread: {}   got token: {}", id, token);
+            println!("thread: {}   got token: {}", id, token);
             ch.send(token - 1);
             if token <= n_tasks {
                 return;
index d2ce61ee7556e166058c765344033109e814cef1..e69ede619de74e1094fa46d6c11732a1e78b19c9 100644 (file)
@@ -12,8 +12,6 @@
 
 #[feature(managed_boxes)];
 
-extern crate extra;
-
 use std::io;
 use std::io::stdio::StdReader;
 use std::io::BufferedReader;
index d4f9d0572b0fe7bd71cb8771c39d8899aa6bbc81..e0938a8ae03106ce700ab561a7896b6d82ee62de 100644 (file)
@@ -34,11 +34,11 @@ fn main() {
 
 fn run(repeat: int, depth: int) {
     for _ in range(0, repeat) {
-        info!("starting {:.4f}", precise_time_s());
+        println!("starting {:.4f}", precise_time_s());
         task::try(proc() {
             recurse_or_fail(depth, None)
         });
-        info!("stopping {:.4f}", precise_time_s());
+        println!("stopping {:.4f}", precise_time_s());
     }
 }
 
@@ -71,7 +71,7 @@ fn r(l: @nillist) -> r {
 
 fn recurse_or_fail(depth: int, st: Option<State>) {
     if depth == 0 {
-        info!("unwinding {:.4f}", precise_time_s());
+        println!("unwinding {:.4f}", precise_time_s());
         fail!();
     } else {
         let depth = depth - 1;
index ff70dac2dde8cfd3e1bec2622995c2037b259f14..c3c255b2dc8ab191b40831760978f1c592ded823 100644 (file)
@@ -66,5 +66,5 @@ fn main() {
     let (sum_port, sum_chan) = stream::<int>();
     start_chan.send(sum_chan);
     let sum = sum_port.recv();
-    error!("How many tasks? {} tasks.", sum);
+    println!("How many tasks? {} tasks.", sum);
 }
index 963a674b5b1ddab6a5448fe64de325e5d400beb9..da4b0677f8f355f27eb1a7e3c944d1b081e079c2 100644 (file)
@@ -11,7 +11,7 @@
 // ignore-fast #[feature] doesn't work with check-fast
 #[feature(asm)];
 
-fn foo(x: int) { info!("{}", x); }
+fn foo(x: int) { println!("{}", x); }
 
 #[cfg(target_arch = "x86")]
 #[cfg(target_arch = "x86_64")]
diff --git a/src/test/compile-fail/asm-misplaced-option.rs b/src/test/compile-fail/asm-misplaced-option.rs
new file mode 100644 (file)
index 0000000..5952471
--- /dev/null
@@ -0,0 +1,41 @@
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-fast #[feature] doesn't work with check-fast
+#[feature(asm)];
+
+#[allow(dead_code)];
+
+#[cfg(target_arch = "x86")]
+#[cfg(target_arch = "x86_64")]
+pub fn main() {
+    // assignment not dead
+    let mut x: int = 0;
+    unsafe {
+        // extra colon
+        asm!("mov $1, $0" : "=r"(x) : "r"(5u), "0"(x) : : "cc");
+        //~^ WARNING unrecognized option
+    }
+    assert_eq!(x, 5);
+
+    unsafe {
+        // comma in place of a colon
+        asm!("add $2, $1; mov $1, $0" : "=r"(x) : "r"(x), "r"(8u) : "cc", "volatile");
+        //~^ WARNING expected a clobber, but found an option
+    }
+    assert_eq!(x, 13);
+}
+
+// #[cfg(not(target_arch = "x86"), not(target_arch = "x86_64"))]
+// pub fn main() {}
+
+// At least one error is needed so that compilation fails
+#[static_assert]
+static b: bool = false; //~ ERROR static assertion failed
index 5b6f6ce73a89a4884424a9ea620802068e488b6a..f183975ffe07862dc6d0077dc7ea9f2c665517a6 100644 (file)
@@ -11,7 +11,7 @@
 // ignore-fast #[feature] doesn't work with check-fast
 #[feature(asm)];
 
-fn foo(x: int) { info!("{}", x); }
+fn foo(x: int) { println!("{}", x); }
 
 #[cfg(target_arch = "x86")]
 #[cfg(target_arch = "x86_64")]
index 56f0710dc3ba65bdd4b319013e4bd1aa1e65ac7c..475052b637eab1d68c10a530a182b067deb2b2e6 100644 (file)
@@ -11,7 +11,7 @@
 // ignore-fast #[feature] doesn't work with check-fast
 #[feature(asm)];
 
-fn foo(x: int) { info!("{}", x); }
+fn foo(x: int) { println!("{}", x); }
 
 #[cfg(target_arch = "x86")]
 #[cfg(target_arch = "x86_64")]
index 65750eb926b450674d8385c03e785d795e787cd8..664db071f828d083875712ca884e43d18ffd5fd2 100644 (file)
@@ -11,7 +11,7 @@
 // ignore-fast #[feature] doesn't work with check-fast
 #[feature(asm)];
 
-fn foo(x: int) { info!("{}", x); }
+fn foo(x: int) { println!("{}", x); }
 
 #[cfg(target_arch = "x86")]
 #[cfg(target_arch = "x86_64")]
index e11b47a1b582c527725ce4ea0b9d05870eac96af..77f47a028d698988a6d7a161f2b424ebd5f0e164 100644 (file)
@@ -11,9 +11,9 @@
 fn test() {
     let v: int;
     v = 1; //~ NOTE prior assignment occurs here
-    info!("v={}", v);
+    println!("v={}", v);
     v = 2; //~ ERROR re-assignment of immutable variable
-    info!("v={}", v);
+    println!("v={}", v);
 }
 
 fn main() {
index f300bd51b24eca1582df34ca467bfdaf8e6e1242..4a392960a6533d42a5c789916dd4e06e77082ec0 100644 (file)
@@ -27,5 +27,5 @@ fn cat(in_x : uint, in_y : int) -> cat {
 
 fn main() {
   let nyan : cat = cat(52u, 99);
-  nyan.speak = || info!("meow"); //~ ERROR attempted to take value of method
+  nyan.speak = || println!("meow"); //~ ERROR attempted to take value of method
 }
index 3102a1a9d99480a9328abe2eeb614402ecd8222d..098c5aaec545c82385b7ff196df7bcdee0ade148 100644 (file)
@@ -10,5 +10,5 @@
 
 fn main() {
     #[attr] //~ ERROR expected item after attributes
-    info!("hi");
+    println!("hi");
 }
index 1741210f9ed50fa780eee59f06f53a6f63a64e3b..8ccf2a9e67585b61b351e5dc251f3aff386aac8f 100644 (file)
@@ -23,12 +23,12 @@ fn main() {
     let a: clam = clam{x: @1, y: @2};
     let b: clam = clam{x: @10, y: @20};
     let z: int = a.x + b.y; //~ ERROR binary operation `+` cannot be applied to type `@int`
-    info!("{:?}", z);
+    println!("{:?}", z);
     assert_eq!(z, 21);
     let forty: fish = fish{a: @40};
     let two: fish = fish{a: @2};
     let answer: int = forty.a + two.a;
     //~^ ERROR binary operation `+` cannot be applied to type `@int`
-    info!("{:?}", answer);
+    println!("{:?}", answer);
     assert_eq!(answer, 42);
 }
index 08ced2b002da614816579b5776e2e563077fd55d..92643eca3c83b2be0aa1155b89ff26dc61e40c3a 100644 (file)
@@ -11,4 +11,4 @@
 // error-pattern:expected `~str` but found `int`
 
 static i: ~str = 10i;
-fn main() { info!("{:?}", i); }
+fn main() { println!("{:?}", i); }
index 3d1cca46085dbf06f8d9f95a890360b85d309391..a60348c4a3a675f261d91325821866df4af5ad46 100644 (file)
@@ -12,7 +12,7 @@ struct X { x: () }
 
 impl Drop for X {
     fn drop(&mut self) {
-        error!("destructor runs");
+        println!("destructor runs");
     }
 }
 
index a1803a621a53fc2996f4ddea13508ddcc58a5d0d..87904399e032fca326f83f5ee3eedeff52e9ad3e 100644 (file)
@@ -12,7 +12,7 @@ struct X { x: (), }
 
 impl Drop for X {
     fn drop(&mut self) {
-        error!("destructor runs");
+        println!("destructor runs");
     }
 }
 
index 34a9c0b8fc26d01fdcdbcc6ead782b013377ef62..ba011d289255f7b47bb89400d3b68e5d1ee7fb7f 100644 (file)
@@ -12,7 +12,7 @@ struct X { x: (), }
 
 impl Drop for X {
     fn drop(&mut self) {
-        error!("destructor runs");
+        println!("destructor runs");
     }
 }
 
index 2aa3379993b7abaf195f247baa57c9707d592a04..6858b7200db6ce8527bcda458fd35ab1f02a57b4 100644 (file)
@@ -12,7 +12,7 @@ struct X { x: (), }
 
 impl Drop for X {
     fn drop(&mut self) {
-        error!("destructor runs");
+        println!("destructor runs");
     }
 }
 
index 7143ce0252b733c4b5683f3d2453fe753d16a317..34b83af1d2ece4a1e7e70c0ed7d96789280d1d90 100644 (file)
@@ -12,7 +12,7 @@ struct X { x: (), }
 
 impl Drop for X {
     fn drop(&mut self) {
-        error!("destructor runs");
+        println!("destructor runs");
     }
 }
 
index d07c3feb1942372dfe95db9cf08e4a29c4364bc4..98d81db8261141e5825a7f017b0b2ef4015f77cb 100644 (file)
@@ -21,6 +21,6 @@ fn fn_id(f: extern fn()) -> extern fn() { return f }
 
 fn main() {
     let i = 8;
-    let f = coerce(|| error!("{:?}", i) );
+    let f = coerce(|| println!("{:?}", i) );
     f();
 }
index 1bd40ce24bcd7b7c6048b18fe19cf5dcf4f9b9a8..cc0ed21410323265924c614f8f954ca06f9388e5 100644 (file)
@@ -16,7 +16,7 @@ enum color { rgb(int, int, int), rgba(int, int, int, int), }
 fn main() {
     let red: color = rgb(255, 0, 0);
     match red {
-      rgb(r, g, b) => { info!("rgb"); }
-      hsl(h, s, l) => { info!("hsl"); }
+      rgb(r, g, b) => { println!("rgb"); }
+      hsl(h, s, l) => { println!("hsl"); }
     }
 }
index 134390d0b59272206b66c585a213b3828ddf6e4f..0f07cab3acc1b14f87962bdcff40bd0d60af11f3 100644 (file)
@@ -11,6 +11,6 @@
 fn main() {
     let i: int;
 
-    info!("{}", false && { i = 5; true });
-    info!("{}", i); //~ ERROR use of possibly uninitialized variable: `i`
+    println!("{}", false && { i = 5; true });
+    println!("{}", i); //~ ERROR use of possibly uninitialized variable: `i`
 }
index dec248a3015d58f2cc175e22a90326e369c72bd4..64afb4861c34c22d7afb50183ca9c6d1033e19ea 100644 (file)
@@ -21,7 +21,7 @@ fn a() {
 
     p[0] = 5; //~ ERROR cannot assign
 
-    info!("{}", *q);
+    println!("{}", *q);
 }
 
 fn borrow(_x: &[int], _f: ||) {}
index fc865e271e39c62a35e3e6bc55a37587dcc4cd5a..a37717ed5d99897d99e26165b6a65b55e5f3eee0 100644 (file)
@@ -12,6 +12,6 @@
 fn main() {
     let x: int;
     force(|| {  //~ ERROR capture of possibly uninitialized variable: `x`
-        info!("{}", x);
+        println!("{}", x);
     });
 }
index 646ec6928630445ccadc6b0a4d89963dde1a3cf4..4fccb5c3bca2ae5a76e5c95001976ef5bd503323 100644 (file)
@@ -16,7 +16,7 @@ struct defer<'a> {
 impl<'a> Drop for defer<'a> {
     fn drop(&mut self) {
         unsafe {
-            error!("{:?}", self.x);
+            println!("{:?}", self.x);
         }
     }
 }
index accb907697430e70588615c4aa56d52960d6e1bf..de18759e30a4cedb60913c4698b14b35b0dc5fe6 100644 (file)
@@ -16,9 +16,9 @@ fn foo() -> int {
         x = 0;
     }
 
-    info!("{}", x); //~ ERROR use of possibly uninitialized variable: `x`
+    println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x`
 
     return 17;
 }
 
-fn main() { info!("{}", foo()); }
+fn main() { println!("{}", foo()); }
index d49e79d2c64c39bf2846c975672c2d1c8b290804..aa7ce4fa34788a61b5a8487f55517219c375ecd0 100644 (file)
@@ -16,9 +16,9 @@ fn foo() -> int {
         x = 0;
     }
 
-    info!("{}", x); //~ ERROR use of possibly uninitialized variable: `x`
+    println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x`
 
     return 17;
 }
 
-fn main() { info!("{}", foo()); }
+fn main() { println!("{}", foo()); }
index 8dc590b47f0c61d9306af8f0cde0f9a00a6b87b2..a35b36fd78ca8e6d10256f1bd132ca74807cb254 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn foo(x: int) { info!("{}", x); }
+fn foo(x: int) { println!("{}", x); }
 
 fn main() {
     let x: int; if 1 > 2 { x = 10; }
index 55fb8222634ccc61a04aa440222a146925df933d..dabe0a594299795a99304b883e155ac99cb22897 100644 (file)
@@ -8,12 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn foo(x: int) { info!("{:?}", x); }
+fn foo(x: int) { println!("{:?}", x); }
 
 fn main() {
     let x: int;
     if 1 > 2 {
-        info!("whoops");
+        println!("whoops");
     } else {
         x = 10;
     }
index f6bb2f5428370893c8394bb9a2ee1a56b4eb6790..c44e2bee0520c0eb39589e4968f60687bd564567 100644 (file)
@@ -13,5 +13,5 @@ fn main() {
         let i: int;
         i //~ ERROR use of possibly uninitialized variable: `i`
     };
-    error!("{:?}", f());
+    println!("{:?}", f());
 }
index 18fd411101834bb9598c3bd562850176289b32e0..0fa2ee5be17b70bee58b5ffc4b7aefca50450b63 100644 (file)
@@ -18,7 +18,7 @@ fn box_imm() {
     let v = ~3;
     let _w = &v;
     task::spawn(proc() {
-        info!("v={}", *v);
+        println!("v={}", *v);
         //~^ ERROR cannot move `v` into closure
     });
 }
@@ -27,7 +27,7 @@ fn box_imm_explicit() {
     let v = ~3;
     let _w = &v;
     task::spawn(proc() {
-        info!("v={}", *v);
+        println!("v={}", *v);
         //~^ ERROR cannot move
     });
 }
index 67b83ee84e4062cc7316dd7f281c8f2f849d2a66..e1e0bb4ceca8efa0eaa1fb7b1f0f9b3a71766577 100644 (file)
@@ -34,7 +34,7 @@ pub fn main() {
                 }
             }
             let z = tail[0].clone();
-            info!("{:?}", z);
+            println!("{:?}", z);
         }
         _ => {
             unreachable!();
index cab2a5565f4ec671a85abfa295d7df87c22169d4..738652dddb32aa928215ce8a9d4ee85bc7fdb03b 100644 (file)
@@ -12,5 +12,5 @@ fn main() {
     let x: int = 3;
     let y: &mut int = &mut x; //~ ERROR cannot borrow
     *y = 5;
-    info!("{:?}", *y);
+    println!("{:?}", *y);
 }
index f878afce9691670aa83bd1ef4d863dafc7010f54..270eeca4c4b6e3bde1bc65bbacc01c6fccf3f195 100644 (file)
@@ -11,6 +11,6 @@
 fn main() {
     let i: int;
 
-    info!("{}", false || { i = 5; true });
-    info!("{}", i); //~ ERROR use of possibly uninitialized variable: `i`
+    println!("{}", false || { i = 5; true });
+    println!("{}", i); //~ ERROR use of possibly uninitialized variable: `i`
 }
index a6ce736c89be6a98e76a7a1622a5b08f976c020a..a64216df6c7fe1218c93509969bb753d6322aaef 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn foo(x: int) { info!("{}", x); }
+fn foo(x: int) { println!("{}", x); }
 
 fn main() {
     let x: int;
index e5d4b6ef48cd61f2ea86d574f6326aa8144e83eb..8cdf1da5c934ce9dd4d7a1e09ded446f794e5ab9 100644 (file)
@@ -14,7 +14,7 @@ fn test(cond: bool) {
         v = 3;
         break;
     }
-    info!("{}", v); //~ ERROR use of possibly uninitialized variable: `v`
+    println!("{}", v); //~ ERROR use of possibly uninitialized variable: `v`
 }
 
 fn main() {
index 18f6fc25149bf89da3dadce114ec1b9595d492d5..5d8932c6e6fa8fbd677b6288f438610ea48108d3 100644 (file)
@@ -22,12 +22,12 @@ struct cat {
 impl cat {
   pub fn eat(&self) -> bool {
     if self.how_hungry > 0 {
-        error!("OM NOM NOM");
+        println!("OM NOM NOM");
         self.how_hungry -= 2;
         return true;
     }
     else {
-        error!("Not hungry!");
+        println!("Not hungry!");
         return false;
     }
   }
@@ -40,7 +40,7 @@ impl noisy for cat {
 
 impl cat {
     fn meow(&self) {
-      error!("Meow");
+      println!("Meow");
       self.meows += 1;
       if self.meows % 5 == 0 {
           self.how_hungry += 1;
index c27c27b5942e1b3276e86c410a94a21883c57b8b..b9e7004bd7ca42b4fc8992df980a0e5e8ea79bc5 100644 (file)
@@ -15,7 +15,7 @@ struct cat {
 impl cat {
     fn sleep(&self) { loop{} }
     fn meow(&self) {
-      error!("Meow");
+      println!("Meow");
       meows += 1u; //~ ERROR unresolved name
       sleep();     //~ ERROR unresolved name
     }
index 7e928e190a327e748fab93ef51b67b8f32558d47..ac893277749e1dc0e09b3d19d7ea8d13768169eb 100644 (file)
@@ -26,5 +26,5 @@ fn main() {
     let x = foo(10);
     let _y = x.clone();
     //~^ ERROR does not implement any method in scope
-    error!("{:?}", x);
+    println!("{:?}", x);
 }
index 70e76b9fde11c7fb8c8236a0025d06b823b8311c..c09938b2f7ddf8c08580c4e412d190880206d1eb 100644 (file)
@@ -14,5 +14,5 @@
 
 fn main() {
     return;
-    info!("Paul is dead");
+    println!("Paul is dead");
 }
index 6f3ce6abe1a765c332a167f3d8633baf961fbedc..37560444af695cdf8bc8abb4a66cbf5bd15d98bd 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index c138c259a0f123b79a578e7bbd8809d85d4b07ad..89acf95f1563e38ab96eed3c1f020311c513d1e4 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index 9226c4a79603bc3d09dd5f1fad8fb54af2742414..0afcfa18c73fbff49f6008b4b692192ca9cb9c7f 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index e49bd45f4d0751f622f29a388069c784aba872ad..d116a791620ce2dfc1d09eb50a13037823346802 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index 5da4ae5ca4242d3be630df4f68031680ff6682ef..09afd9730fb0a94e164c13b9390485b796da0f6a 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index 3f44ea926b5c94a78ccd01c00362f0627a3e9468..4dbcc3de1fa5adaecb4dda8e6981492481f723ad 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index 482954b39f7f2f72496f20b32e1d41f52f51b5cb..4e9dfd96c631ce74095f4c1e60c6d378642db578 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index 5221869a2850323416c60f8153deababd8710560..794c36b43d84ac051e56597635039da0f413d186 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index a063628993e5ace4e3507ce41a552c500b376d19..4488e74d851f1a935c1413cd6b89bca4f24083f6 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index efa92c0a29a14c08b21276e8934ff7f4fb007893..949e1cee37a0c4298aa55f652f62e137a1cbc15d 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index b08f7305cfc48205f9b324deed5f2dc80328ea80..1323c4daf94fee0a3d134b558f9c2d3fb8a5bd03 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index 6fe0094c8d21090f5db7754c3c6c44e425d42f2c..af78a1ace70ff2046eac374e3b0df934fa84f5c4 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index 0ae28d084ec04f2ca0e9cd57d71d92bf2f157885..c8fdb0f19a5e94dc77882802025b94e7e4e08546 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index 1b69abb3e16e7cf01fe28023d3aa8ec1ffc52cb8..897483c8ada401c63e5ebbc16e5469f91cb519df 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index edfc949970f2ed92f551cb918f958b17c741c7d5..a99191fd0dcbe083fb7ec950c3bcd42e61258016 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 #[deriving(Eq)]
index 13da4454c3e276170b0370a278190b574c10a5be..2be3d5c83af151c013bfec025de946febd3f9748 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 #[deriving(Eq)]
index bab38983dfb1916ebd440eb77d484adc2549461b..5848bda1750ba2f36b8f1707a4b6d3b291c84d4a 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 #[deriving(Eq)]
index bb211d7781e425171f385f06a1301f22280a3239..198721e9b75b17359bc49a322c2eba1498086d98 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 #[deriving(Eq)]
index 9338e23fbb475c1f1cc1339ec8e8a5bd3ab6b6e4..4fee8aa84e677df79b1b1464dd4814555133f13b 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index 1a978176d7983967547282ae325f3118b062415b..58f8a2b44b27b913de003f3024f77185f86e96c2 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index 7f62850398071527df391711cacd4d23f91b2cca..7350f94e76b6920f90bc972d5879467777e336d9 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index 9b11c02784654c4db82d00699675d0901cf9f1da..0d7631e8e2077fd412884e548f991cc4616860bb 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index 972f60bf2c9ab363d8dcbf81fb38c0a6ad0d1bfb..b3f94ff606d20fa6e94ac2f53dfe7268108d123b 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index ba3fd1766b2f8841471d8cd5ccfc47269bacd1e5..f3ff502c6e237bffac9c5a34a3500e7c8ceb373e 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index 1e38c9dda5bd7a56fae2b26f0ce50de58c2bd7f0..258efaaba0c74b7b916b41011afdbcd7eb8b231c 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index 7347b324a235b61992cb382ecf4c707620e7cba1..002495389f3914b9002a7fde84d35de7afcff42e 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index 4d362678283d3590bd344e7e734b4d05d97d8df9..5d6d4531b40cd7c883d7c4a202bc88d13299b0ed 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 #[deriving(Eq)]
index 66f84612f81150d674c4a13c80d1c963c7a900f3..b80aa2646d2721f402ca3902c9c4c6f1bdaa1d1c 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 #[deriving(Eq)]
index ba29180e5e68ba4add28c36f729950fdaeb7d39a..878316c4b036cd05cc094683893d96b3973fef44 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 #[deriving(Eq)]
index 6dbd1e3cee94645d20a23db10b8510a3e33b257e..c590a1f216498e541d76f3a354735c32c41f6aff 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 #[deriving(Eq)]
index 54f7667be30a73e2a39878587ae3cbb6641902ec..d6ca5f726753129c0363ca298929e754d94feb32 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 #[deriving(Eq, Ord, TotalEq)]
index 6f51522d1a60f69627a1c0c0cd5d5f87bf1fe0a3..e53c849591412216c061332f59dd5e822c0271d1 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 #[deriving(Eq, Ord, TotalEq)]
index b659e4cee220110e33f387e9c5c420a4e6a2ccd0..8b7a9d3bea6822042103d2da18175570faa8b03a 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 #[deriving(Eq, Ord, TotalEq)]
index d4f30946d8ec8ce35bbccfa219bafcfb158d5a5a..ff13923721707c51d5b4e4de1f9cd23b80ec9ddb 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 #[deriving(Eq, Ord, TotalEq)]
index 2e00c92f469e6a65c651cdd91c9c5b0c1841632a..acebdff28ff05cdbe59696f842abf61d68c9bc30 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index 9487c6ced629fb6fe9c689d241c80ea7c17dc913..64600fef2c5699b642961cc2e62b666035dd4cc9 100644 (file)
@@ -11,7 +11,6 @@
 // This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
 
 #[feature(struct_variant)];
-extern crate extra;
 extern crate rand;
 
 
index 945c3d6295277435469d1ad75d7ed00912334615..af543b8d7823a626e2a792498c61e38079251cca 100644 (file)
@@ -14,7 +14,7 @@ struct X {
 
 impl Drop for X {
     fn drop(&mut self) {
-        error!("value: {}", self.x);
+        println!("value: {}", self.x);
     }
 }
 
@@ -26,5 +26,5 @@ fn unwrap(x: X) -> ~str {
 fn main() {
     let x = X { x: ~"hello" };
     let y = unwrap(x);
-    error!("contents: {}", y);
+    println!("contents: {}", y);
 }
index 0432920c1a6fe1a49c4fcf4111ef35390627c465..b716a7dd023ffb7ad39b73b96673c7adfaca6ece 100644 (file)
@@ -14,7 +14,7 @@ struct X {
 
 impl Drop for X {
     fn drop(&mut self) {
-        error!("value: {}", self.x);
+        println!("value: {}", self.x);
     }
 }
 
@@ -22,7 +22,7 @@ fn main() {
     let x = X { x: ~"hello" };
 
     match x {
-        X { x: y } => error!("contents: {}", y)
+        X { x: y } => println!("contents: {}", y)
         //~^ ERROR cannot move out of type `X`, which defines the `Drop` trait
     }
 }
index 23b9f0482424796ed9b8b2fc6ad8be3c0c24616d..9b82ead04285994e571fb9296471aca5c29d98c7 100644 (file)
@@ -9,4 +9,4 @@
 // except according to those terms.
 
 // error-pattern: unresolved name `this_does_nothing_what_the`.
-fn main() { info!("doing"); this_does_nothing_what_the; info!("boing"); }
+fn main() { println!("doing"); this_does_nothing_what_the; println!("boing"); }
index 22762eb4a7eb514d54cbe8c37b38422abbce6ef8..6104c02c90a03332145a30a132a4822675ee5e8a 100644 (file)
@@ -15,7 +15,7 @@ mod foo {
 }
 
 mod bar {
-    fn x() { info!("x"); }
+    fn x() { println!("x"); }
 
     pub fn y() { }
 }
index dcda6afa6ca1e366b2364b5d6a734495800e94ec..38cae6323203481078d8198957c52ae4b8e69f5d 100644 (file)
@@ -12,5 +12,5 @@
 
 fn main() {
     let a = if true { true };
-    info!("{:?}", a);
+    println!("{:?}", a);
 }
index 124d4631601d6d34c9e8d0f3d7e29f318d3d6364..973e36e494ca6af2552cf07dd7f54518323a4e83 100644 (file)
 use module_of_many_things::*;
 
 mod module_of_many_things {
-    pub fn f1() { info!("f1"); }
-    pub fn f2() { info!("f2"); }
-    fn f3() { info!("f3"); }
-    pub fn f4() { info!("f4"); }
+    pub fn f1() { println!("f1"); }
+    pub fn f2() { println!("f2"); }
+    fn f3() { println!("f3"); }
+    pub fn f4() { println!("f4"); }
 }
 
 
index ae5a0f04e2c043d45b15058fae613f8df176c302..3f5127a55b8bfdf892457e1451710c381ca302e7 100644 (file)
 
 mod circ1 {
     pub use circ2::f2;
-    pub fn f1() { info!("f1"); }
+    pub fn f1() { println!("f1"); }
     pub fn common() -> uint { return 0u; }
 }
 
 mod circ2 {
     pub use circ1::f1;
-    pub fn f2() { info!("f2"); }
+    pub fn f2() { println!("f2"); }
     pub fn common() -> uint { return 1u; }
 }
 
index 5177dc4e47570caa711ee236b52fed63724dddf0..7f3319e6d90e668a4aa60e00b57998c2d0adeb1c 100644 (file)
@@ -12,6 +12,6 @@
 use zed::bar;
 use zed::baz;
 mod zed {
-    pub fn bar() { info!("bar"); }
+    pub fn bar() { println!("bar"); }
 }
 fn main(args: ~[str]) { bar(); }
index e67a79130b1f9a6e0529088136cf7aa14a2166e7..721176e2e886014e569c3739fc4c75530fa9cf2f 100644 (file)
@@ -13,6 +13,6 @@
 
 mod baz {}
 mod zed {
-    pub fn bar() { info!("bar3"); }
+    pub fn bar() { println!("bar3"); }
 }
 fn main(args: ~[str]) { bar(); }
index 7a7f4f20aea07f1b4dc57eba1a17d144120c92df..bd07433eeb095c40ab736c7c1b0c8b34fc0436ed 100644 (file)
@@ -11,4 +11,4 @@
 // error-pattern: unresolved
 use main::bar;
 
-fn main(args: ~[str]) { info!("foo"); }
+fn main(args: ~[str]) { println!("foo"); }
index 087842d78c709f6910011c49886675be479cf420..af4d0ebe6bafa7dcb0e8e5c196b5de432290b844 100644 (file)
@@ -13,4 +13,4 @@
 mod a { pub use b::foo; }
 mod b { pub use a::foo; }
 
-fn main(args: ~[str]) { info!("loop"); }
+fn main(args: ~[str]) { println!("loop"); }
index e2ca7641500c3014f11aa2e05dcfaffc64005b46..3daced7a5ac1895ba15904664393df1d81ce5437 100644 (file)
@@ -13,5 +13,5 @@
 fn foo(a: uint) -> uint { a }
 
 fn main() {
-    info!("{:u}", foo(10i)); //~ ERROR mismatched types
+    println!("{:u}", foo(10i)); //~ ERROR mismatched types
 }
index ed2e75c4fa602fff2e726bc9edad452f711d2b9c..80e0d037f7c5130e0efcba9319ed6b6ea278c5a0 100644 (file)
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 fn main() {
-    error!("{:?}", x); //~ ERROR unresolved name `x`.
+    println!("{:?}", x); //~ ERROR unresolved name `x`.
 }
index 2c54b622021153c44ebf5878a54a0d4655f0f44d..b5269519bb785aaa3dca39bb7366417fd4f3aa02 100644 (file)
@@ -11,6 +11,7 @@
 #[deny(unreachable_code)];
 #[allow(unused_variable)];
 #[allow(dead_code)];
+#[allow(deprecated_owned_vector)];
 
 fn fail_len(v: ~[int]) -> uint {
     let mut i = 3;
index 7896d91443dadd6cbfdc7afb758e650ca9dcf57b..bb24192445e84406be2404ee81a56df4795cdcba 100644 (file)
@@ -10,4 +10,4 @@
 
 // error-pattern: unresolved name `foobar`.
 
-fn main(args: ~[str]) { info!("{:?}", foobar); }
+fn main(args: ~[str]) { println!("{:?}", foobar); }
index 790a5fac18305106cec096e3ca185e0caacde9bb..4106a77524845f85b68a150af39fee75ea8221ae 100644 (file)
@@ -14,7 +14,7 @@ struct C {
 
 impl Drop for C {
     fn drop(&mut self) {
-        error!("dropping: {:?}", self.x);
+        println!("dropping: {:?}", self.x);
     }
 }
 
index 038b2b0d87624a680a803ade94f98b21c0c7e130..daef77f63141eaedc64d5f88ab6be75291db8f5b 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 fn siphash(k0 : u64) {
 
     struct siphash {
index 392cc2f3c9006a3f40ca08ab8693f4163a4e0bc5..1fb71f01d06d32367ae76c831a72253818d57b6e 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 fn siphash<T>() {
 
     trait t {
index 95c0eb711e8f72fdc17a99341c4457c38c2e5ea0..ddb33f1e61a811f9c7ad634584de2605770525ef 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 trait siphash {
     fn result(&self) -> u64;
     fn reset(&self);
index 7bb1faf514a04f50b5feec83687e29090cac36f5..d44d81b7fe01d1d7a399c901461cacb8ff2ad4ef 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 trait SipHash {
     fn reset(&self);
 }
index 691bd3b4211cc2dbef9c9018714780b1ba038ef7..684318bafc685097de76cef984253e59950d58e3 100644 (file)
@@ -19,13 +19,13 @@ fn main()
 {
 
     let _z = match g(1, 2) {
-      g(x, x) => { info!("{:?}", x + x); }
+      g(x, x) => { println!("{:?}", x + x); }
       //~^ ERROR identifier `x` is bound more than once in the same pattern
     };
 
     let _z = match i(l(1, 2), m(3, 4)) {
       i(l(x, _), m(_, x))  //~ ERROR identifier `x` is bound more than once in the same pattern
-        => { error!("{:?}", x + x); }
+        => { println!("{:?}", x + x); }
     };
 
     let _z = match (1, 2) {
index bb220091a13149d025c2c0c9f926467286614383..85989c4a40a6b65b09cb58243863059a27d2a43a 100644 (file)
@@ -17,5 +17,5 @@ fn a(x: ~str, y: ~str) -> ~str { //~ ERROR duplicate definition of value `a`
 }
 
 fn main() {
-    info!("Result: ");
+    println!("Result: ");
 }
index db07d9a94e84d67dbc96adc3b592f3a9c4376a6a..cdfc990677657b00e71296e72fa3d8e2afce2cdb 100644 (file)
@@ -13,5 +13,5 @@ fn main() {
 
     static y: int = foo + 1; //~ ERROR: attempt to use a non-constant value in a constant
 
-    error!("{}", y);
+    println!("{}", y);
 }
index 94ca74d2b6a79d4d9d9d139be7079988666060a8..f9fb2daaf58a2ddbf5d3b0447ae05062cabd9692 100644 (file)
@@ -15,5 +15,5 @@ enum Stuff {
         Bar = foo //~ ERROR attempt to use a non-constant value in a constant
     }
 
-    error!("{:?}", Bar);
+    println!("{:?}", Bar);
 }
index fca59ed74ee8d5135a86bf77a5fb6fdd11eeedaf..be676becd5acc73485e06e5242c031d9e598f10c 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#[allow(deprecated_owned_vector)];
 
 // Verify the compiler fails with an error on infinite function
 // recursions.
diff --git a/src/test/compile-fail/lint-deprecated-owned-vector.rs b/src/test/compile-fail/lint-deprecated-owned-vector.rs
new file mode 100644 (file)
index 0000000..c21ca87
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[deny(deprecated_owned_vector)];
+
+fn main() {
+    ~[1]; //~ ERROR use of deprecated `~[]`
+    //~^ ERROR use of deprecated `~[]`
+    std::vec::with_capacity::<int>(10); //~ ERROR use of deprecated `~[]`
+}
index fa359dcd538f7f4c7e7834f8fab11a1d25f3025c..4c178cdf65c0f0c91ac74faf7a604d0cf82a6f17 100644 (file)
@@ -11,6 +11,7 @@
 #[feature(managed_boxes)];
 #[forbid(heap_memory)];
 #[allow(dead_code)];
+#[allow(deprecated_owned_vector)];
 
 struct Foo {
     x: @int //~ ERROR type uses managed
index 8d294af3e3eb90fdbbcfce8e289fac9e36e54098..c20546d8590489d4c217271df7260a2dc7ea21d8 100644 (file)
@@ -11,6 +11,7 @@
 #[feature(globs)];
 #[deny(unused_imports)];
 #[allow(dead_code)];
+#[allow(deprecated_owned_vector)];
 
 use cal = bar::c::cc;
 
index 271aedd3f6a6ba001814e618c278e2ffe5bb350d..6b6311739f05c095ccd1231b083105485585b444 100644 (file)
@@ -13,6 +13,7 @@
 #[allow(dead_assignment)];
 #[allow(unused_variable)];
 #[allow(dead_code)];
+#[allow(deprecated_owned_vector)];
 #[deny(unused_mut)];
 
 fn main() {
index 96a4c2adca32c93df98dbd3bce38d07664adaa61..de01a711a3e53ba4938baad0d2471a42006bcc52 100644 (file)
@@ -12,6 +12,7 @@
 
 #[allow(dead_code)];
 #[deny(unused_unsafe)];
+#[allow(deprecated_owned_vector)];
 
 mod foo {
     extern {
index eeb07c71e9bd3591f2373f050506456abed64e46..24a02821ee2a979973991cae23e34a007ec44e59 100644 (file)
@@ -11,6 +11,6 @@
 // Tests that a function with a ! annotation always actually fails
 // error-pattern: some control paths may return
 
-fn bad_bang(i: uint) -> ! { info!("{}", 3); }
+fn bad_bang(i: uint) -> ! { println!("{}", 3); }
 
 fn main() { bad_bang(5u); }
index 9d46202d64e21143a62f5e1d62fe8b20c2734255..676d5212e998090617e721ff7f137f7705786e89 100644 (file)
@@ -9,4 +9,4 @@
 // except according to those terms.
 
 fn force(f: || -> int) -> int { f() }
-fn main() { info!("{:?}", force(|| {})); } //~ ERROR mismatched types
+fn main() { println!("{:?}", force(|| {})); } //~ ERROR mismatched types
index 6ba7d57ef88e9612a81fc918e6f3bd9fca5b75af..a64d7578af319d7c9b2f1d13a0b651a1775a441f 100644 (file)
@@ -12,7 +12,7 @@ fn main() {
     let y: ~int = ~42;
     let mut x: ~int;
     loop {
-        info!("{:?}", y);
+        println!("{:?}", y);
         loop {
             loop {
                 loop {
index ad0cdc5451fbe7792a0dc1a0f7e50528db068ed5..8aa85c03ad4ad5957f54ee7b658be37967da58b6 100644 (file)
@@ -13,7 +13,7 @@ fn main() {
     let y: ~int = ~42;
     let mut x: ~int;
     loop {
-        info!("{:?}", y); //~ ERROR use of moved value: `y`
+        println!("{:?}", y); //~ ERROR use of moved value: `y`
         while true { while true { while true { x = y; x.clone(); } } }
         //~^ ERROR use of moved value: `y`
     }
index 83b8d79756ff7cb1a4994d3d4130046ee302d885..eccb3784325d9746c68a6cb19a17970770ce2e9a 100644 (file)
@@ -11,6 +11,6 @@
 fn main() {
     let x = ~5;
     let y = x;
-    info!("{:?}", *x); //~ ERROR use of moved value: `x`
+    println!("{:?}", *x); //~ ERROR use of moved value: `x`
     y.clone();
 }
index 7bc277c2eac1e478b5f44afb54e2f6c443496cfc..8747d055ff945d7203038d3917d8278a0ba9b23e 100644 (file)
@@ -9,8 +9,8 @@
 // except according to those terms.
 
 fn send<T:Send>(ch: _chan<T>, data: T) {
-    info!("{:?}", ch);
-    info!("{:?}", data);
+    println!("{:?}", ch);
+    println!("{:?}", data);
     fail!();
 }
 
@@ -20,7 +20,7 @@ fn send<T:Send>(ch: _chan<T>, data: T) {
 // message after the send deinitializes it
 fn test00_start(ch: _chan<~int>, message: ~int, _count: ~int) {
     send(ch, message);
-    info!("{:?}", message); //~ ERROR use of moved value: `message`
+    println!("{:?}", message); //~ ERROR use of moved value: `message`
 }
 
 fn main() { fail!(); }
index 8155a2fbda3e2ff0ad436992ced73992e889793f..3e1c9e850fa9e4b6926fefb45d06e0fb2fa33b5f 100644 (file)
@@ -16,6 +16,6 @@
 fn main() {
     match true { false => { my_fail(); } true => { } }
 
-    info!("{:?}", x); //~ ERROR unresolved name `x`.
+    println!("{:?}", x); //~ ERROR unresolved name `x`.
     let x: int;
 }
index 97a2b00ba424c0ce0d747ab303d2db22a8929099..cf82cf087a3fba5e7f27c3560ffca349ce8d8587 100644 (file)
@@ -12,8 +12,6 @@
 // temporary kinds wound up being stored in a cache and used later.
 // See middle::ty::type_contents() for more information.
 
-extern crate extra;
-
 struct List { key: int, next: Option<~List> }
 
 fn foo(node: ~List) -> int {
index 8df156d8332fed3a341757f0770fa45734fb78fd..02e1f82e709e6e36cc907c43362b6cedf1454c54 100644 (file)
@@ -26,5 +26,5 @@ fn main() {
 
     assert_eq!((arc_v.get())[2], 3);
 
-    info!("{:?}", arc_v);
+    println!("{:?}", arc_v);
 }
index b387d3a1719e9f2bd4f2d83db8dfa9a0acddbb71..5fed317fb09e3e4967566d137e3528ef194039f2 100644 (file)
@@ -24,5 +24,5 @@ fn main() {
 
     assert_eq!((arc_v.get())[2], 3); //~ ERROR use of moved value: `arc_v`
 
-    info!("{:?}", arc_v); //~ ERROR use of moved value: `arc_v`
+    println!("{:?}", arc_v); //~ ERROR use of moved value: `arc_v`
 }
index 9e564e997e6739c91245e0f775d78f3f68be3788..68077d61c9f81643c2843546626aca65d202f1d1 100644 (file)
@@ -34,6 +34,6 @@ fn foo(x: Port<()>) -> foo {
 
     task::spawn(proc() {
         let y = x;   //~ ERROR does not fulfill `Send`
-        error!("{:?}", y);
+        println!("{:?}", y);
     });
 }
index e57ac5726fbba546fc7170b7ffe4d1c87ef85e54..778f3a3b997845b84f4fa487d425b4e080307699 100644 (file)
@@ -39,5 +39,5 @@ fn foo(i:int) -> foo {
 fn main() {
     let x = foo(10);
     let _y = x.clone(); //~ ERROR does not implement any method in scope
-    error!("{:?}", x);
+    println!("{:?}", x);
 }
index 5c7a85a03237ca9372ddef3eab31ceaade14af3e..c0749984cc9e38a064409884e9eea4ea9e8e6a68 100644 (file)
@@ -15,5 +15,5 @@ struct foo {
 }
 
 fn main() {
-    info!("{:?}", foo{ x: 1 } as int);
+    println!("{:?}", foo{ x: 1 } as int);
 }
index 1c4316672f3fb1ed4f4b573ef7725cc4369e7090..0b5c6ac4fb3e2c64581582a57bd21bacc37af8bd 100644 (file)
@@ -10,4 +10,4 @@
 
 // compile-flags: -D type-overflow
 
-fn main() { info!("{}", 300u8); } //~ error: literal out of range for its type
+fn main() { println!("{}", 300u8); } //~ error: literal out of range for its type
index 991a4ed9e0900310f809158faa5135bca9e10f57..c74d80df5dc271a7bc7250db3b68f76ac201eb2e 100644 (file)
@@ -32,6 +32,6 @@ fn main() {
     let foo = Foo { bar: [1u8, 2, 3, 4, 5], baz: 10i32 };
     unsafe {
         let oof: Oof<[u8, .. 5], i32> = cast::transmute(foo);
-        info!("{:?}", oof);
+        println!("{:?}", oof);
     }
 }
index 58c5aabba1267d830722822abbdfc27843ad6159..b9a8a53469d5a8a5f7c23acb43f1e4bdcadd7bac 100644 (file)
@@ -32,6 +32,6 @@ fn main() {
     let foo = Foo { bar: 1, baz: 10 };
     unsafe {
         let oof: Oof = cast::transmute(foo);
-        info!("{:?}", oof);
+        println!("{:?}", oof);
     }
 }
index e58c4b146858835faa860d4910c183b653ab865a..3e4b2502fd002efa0d5c128918855a13e5e57d62 100644 (file)
@@ -9,8 +9,6 @@
 // except according to those terms.
 
 
-extern crate extra;
-
 enum bar { t1((), Option<~[int]>), t2, }
 
 // n.b. my change changes this error message, but I think it's right -- tjc
index b687a225754e03da2ff36a19f30692e0755d36d1..22cc9fd283163aebc8fab61a5ffc272df88056e0 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 // error-pattern: mismatched types
 
 enum bar { t1((), Option<~[int]>), t2, }
@@ -17,7 +15,7 @@ enum bar { t1((), Option<~[int]>), t2, }
 fn foo(t: bar) {
     match t {
       t1(_, Some::<int>(x)) => {
-        info!("{:?}", x);
+        println!("{:?}", x);
       }
       _ => { fail!(); }
     }
index 9c9b4a9f4d5b0babeca2348808ead932e4938684..6479a9404e2d560ba141e73b99a221b96d473b6c 100644 (file)
@@ -41,7 +41,7 @@ fn main() {
         // Can't do this copy
         let x = ~~~A {y: r(i)};
         let _z = x.clone(); //~ ERROR failed to find an implementation
-        info!("{:?}", x);
+        println!("{:?}", x);
     }
-    error!("{:?}", *i);
+    println!("{:?}", *i);
 }
index d45759e38d99e4e5085f841209166fd8a59fe6e0..09cac75baa0fbd9b4de0ffe6cc4dc109464a1ec5 100644 (file)
@@ -12,7 +12,6 @@
 
 #[feature(quote)];
 
-extern crate extra;
 extern crate syntax;
 
 use io::*;
index b5c2dee61c73699d95e5d5d9de8cf05e59da02c5..82d0cb2e198a210b64646b081bf93c2a8d551549 100644 (file)
 
 #[feature(quote)];
 
-extern crate extra;
 extern crate syntax;
 
-use extra::io::*;
-
 use syntax::diagnostic;
 use syntax::ast;
 use syntax::codemap;
index ce89b66cd5b944b76a3021c8842b914adf28bbe8..fb2dbacef84e72e9f28cab7800cbdb4859abf8da 100644 (file)
@@ -33,5 +33,5 @@ fn dog() -> dog {
 fn main() {
     let mut d = dog();
     d.chase_cat();
-    info!("cats_chased: {}", d.cats_chased);
+    println!("cats_chased: {}", d.cats_chased);
 }
index af460dbdd7868cab621b2a21b6a130e1e1d271fa..68920065d1967597eec36b09a94d5557e6e328af 100644 (file)
@@ -13,6 +13,6 @@ fn wants_static_fn(_x: 'static ||) {}
 fn main() {
     let i = 3;
     wants_static_fn(|| { //~ ERROR cannot infer
-        info!("i={}", i);
+        println!("i={}", i);
     })
 }
index 8453ace2b51d9eb2e703e1152f4001967ef2fbb9..8531a1a71c7ea5c3ce904ad7d71eb2e4d7dcc9b6 100644 (file)
@@ -9,8 +9,6 @@
 // except according to those terms.
 
 mod argparse {
-    extern crate extra;
-
     pub struct Flag<'a> {
         name: &'a str,
         desc: &'a str,
index 0c335b9d5575fa5a6d0351c5bc8474c306d5abbc..068ecb7118fc2859efb1d7e241b8276f622461d3 100644 (file)
@@ -24,5 +24,5 @@ fn return_it<'a>() -> &'a int {
 
 fn main() {
     let x = return_it();
-    info!("foo={}", *x);
+    println!("foo={}", *x);
 }
index 469421751df2b69c4bca156b1725f7d735704c58..c20764e0728d129747811b652869bbadc6654d7d 100644 (file)
@@ -27,5 +27,5 @@ fn return_it() -> &int {
 
 fn main() {
     let x = return_it();
-    info!("foo={}", *x);
+    println!("foo={}", *x);
 }
index f543d442a23914e4ce2e88fcdeae796e4a020cdd..35c18c495471c9b5872e55fe5e11442bb25de3f0 100644 (file)
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
 fn main() {
 trait seq { }
 
index e82c49d977f67ba3e98f54f90c6a6438061aea36..3a35d9cc309ab2f653e38b697e33abefce09d687 100644 (file)
@@ -10,8 +10,6 @@
 
 // error-pattern: mismatched types
 
-extern crate extra;
-
 use std::task;
 
 fn main() { task::spawn(|| -> int { 10 }); }
diff --git a/src/test/compile-fail/typeck_type_placeholder_item.rs b/src/test/compile-fail/typeck_type_placeholder_item.rs
new file mode 100644 (file)
index 0000000..67300f9
--- /dev/null
@@ -0,0 +1,119 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// This test checks that it is not possible to enable global type
+// inference by using the `_` type placeholder.
+
+fn test() -> _ { 5 }
+//~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+
+fn test2() -> (_, _) { (5u, 5u) }
+//~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+//~^^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+
+static TEST3: _ = "test";
+//~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+
+static TEST4: _ = 145u16;
+//~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+
+static TEST5: (_, _) = (1, 2);
+//~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+//~^^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+
+fn test6(_: _) { }
+//~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+
+fn test7(x: _) { let _x: uint = x; }
+//~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+
+fn test8(_f: fn() -> _) { }
+//~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+
+struct Test9;
+
+impl Test9 {
+    fn test9(&self) -> _ { () }
+    //~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+
+    fn test10(&self, _x : _) { }
+    //~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+}
+
+impl Clone for Test9 {
+    fn clone(&self) -> _ { Test9 }
+    //~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+
+    fn clone_from(&mut self, other: _) { *self = Test9; }
+    //~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+}
+
+struct Test10 {
+    a: _,
+    //~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+    b: (_, _),
+    //~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+    //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+}
+
+pub fn main() {
+    fn fn_test() -> _ { 5 }
+    //~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+
+    fn fn_test2() -> (_, _) { (5u, 5u) }
+    //~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+    //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+
+    static FN_TEST3: _ = "test";
+    //~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+
+    static FN_TEST4: _ = 145u16;
+    //~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+
+    static FN_TEST5: (_, _) = (1, 2);
+    //~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+    //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+
+    fn fn_test6(_: _) { }
+    //~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+
+    fn fn_test7(x: _) { let _x: uint = x; }
+    //~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+
+    fn fn_test8(_f: fn() -> _) { }
+    //~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+
+    struct FnTest9;
+
+    impl FnTest9 {
+        fn fn_test9(&self) -> _ { () }
+        //~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+
+        fn fn_test10(&self, _x : _) { }
+        //~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+    }
+
+    impl Clone for FnTest9 {
+        fn clone(&self) -> _ { FnTest9 }
+        //~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+
+        fn clone_from(&mut self, other: _) { *self = FnTest9; }
+        //~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+    }
+
+    struct FnTest10 {
+        a: _,
+        //~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+        b: (_, _),
+        //~^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+        //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures.
+    }
+
+}
diff --git a/src/test/compile-fail/typeck_type_placeholder_lifetime_1.rs b/src/test/compile-fail/typeck_type_placeholder_lifetime_1.rs
new file mode 100644 (file)
index 0000000..fae4f54
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// This test checks that the `_` type placeholder does not react
+// badly if put as a lifetime parameter.
+
+struct Foo<'a, T> {
+    r: &'a T
+}
+
+pub fn main() {
+    let c: Foo<_, _> = Foo { r: &5u };
+    //~^ ERROR wrong number of type arguments: expected 1 but found 2
+}
diff --git a/src/test/compile-fail/typeck_type_placeholder_lifetime_2.rs b/src/test/compile-fail/typeck_type_placeholder_lifetime_2.rs
new file mode 100644 (file)
index 0000000..e879ddb
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// This test checks that the `_` type placeholder does not react
+// badly if put as a lifetime parameter.
+
+struct Foo<'a, T> {
+    r: &'a T
+}
+
+pub fn main() {
+    let c: Foo<_, uint> = Foo { r: &5 };
+    //~^ ERROR wrong number of type arguments: expected 1 but found 2
+}
diff --git a/src/test/compile-fail/typeck_type_placeholder_mismatch.rs b/src/test/compile-fail/typeck_type_placeholder_mismatch.rs
new file mode 100644 (file)
index 0000000..492a0af
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// This test checks that genuine type errors with partial
+// type hints are understandable.
+
+struct Foo<T>;
+struct Bar<U>;
+
+pub fn main() {
+}
+
+fn test1() {
+    let x: Foo<_> = Bar::<uint>;
+    //~^ ERROR mismatched types: expected `Foo<<generic #0>>` but found `Bar<uint>`
+    let y: Foo<uint> = x;
+}
+
+fn test2() {
+    let x: Foo<_> = Bar::<uint>;
+    //~^ ERROR mismatched types: expected `Foo<<generic #0>>` but found `Bar<uint>`
+    //~^^ ERROR cannot determine a type for this local variable: unconstrained type
+}
index bf62247e7e785c1daccb732f159fa110fd5561e2..da9e24b73143410dbd612f6e41b688be31439105 100644 (file)
@@ -19,5 +19,5 @@ fn drop(&mut self) {}
 fn main() {
     let i = ~r { b: true };
     let _j = i.clone(); //~ ERROR failed to find an implementation
-    info!("{:?}", i);
+    println!("{:?}", i);
 }
index c604e66507e0a32e89a981b36177dba2b68db060..a77d1b06f176dbe4565e1fd2764cb1b16af1ae35 100644 (file)
@@ -35,6 +35,6 @@ fn main() {
     let r2 = ~[~r { i: i2 }];
     f(r1.clone(), r2.clone());
     //~^ ERROR failed to find an implementation of
-    info!("{:?}", (r2, i1.get()));
-    info!("{:?}", (r1, i2.get()));
+    println!("{:?}", (r2, i1.get()));
+    println!("{:?}", (r1, i2.get()));
 }
index a39ffa64dfd769fb537afff5d2e622258512828a..c5b061caf6e78863512ab4125496930953c5a6a8 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-use extra; //~ ERROR unresolved import (maybe you meant `extra::*`?)
+extern crate collections;
+use collections; //~ ERROR unresolved import (maybe you meant `collections::*`?)
 
 fn main() {}
index dc3895d0190cd15014880b045760bf71ce0af98b..be3f5ba7da86de9745b8f1690c5269e4a51b971e 100644 (file)
@@ -13,5 +13,5 @@
 use std::libc;
 
 fn main() {
-  info!("{:?}", 1.0 as *libc::FILE); // Can't cast float to foreign.
+  println!("{:?}", 1.0 as *libc::FILE); // Can't cast float to foreign.
 }
index d97c32a64a47cc6ce70b5e9b607a3f9af1b2a871..19052d923e9f26dbd2206d24ca24343f744f8712 100644 (file)
@@ -13,7 +13,7 @@
 
 fn f() {
     let v = ~[1i];
-    info!("{}", v.some_field_name); //type error
+    println!("{}", v.some_field_name); //type error
 }
 
 fn main() { }
index 3545392d5d9f73259165919df6de0d2d41508628..d93fe4f48d004af54779184f5b569f9f321d8b0e 100644 (file)
@@ -25,5 +25,5 @@ fn main() {
     let i = ~[r(0)];
     let j = ~[r(1)];
     let k = i + j;
-    info!("{}", j);
+    println!("{}", j);
 }
index d4b25b6baeb41950d47e254aed3867f0bbf60c62..7b78a8d932b33c7dd3cd47d71bbe1a54327ef300 100644 (file)
@@ -8,12 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
+extern crate test;
 
 fn f() {
 }
 
-use extra::net;    //~ ERROR `use` and `extern crate` declarations must precede items
+use test::net;    //~ ERROR `use` and `extern crate` declarations must precede items
 
 fn main() {
 }
index 3102d9967178b008cace4a86720f513a4f06ae5d..9fb86881ab53f2e89f5523afdd0cbae8a79e67dc 100644 (file)
 
 // Make sure functions have proper names
 // debugger:info functions
-// check:static void [...]main();
-// check:static void [...]some_function();
-// check:static void [...]some_other_function();
-// check:static void [...]zzz();
+// check:[...]void[...]main([...]);
+// check:[...]void[...]some_function([...]);
+// check:[...]void[...]some_other_function([...]);
+// check:[...]void[...]zzz([...]);
 
 // debugger:rbreak zzz
 // debugger:run
index ef2a4e5335f45dbd63298721ec01e115c4508b80..96918cfc6f7d3001e5ccb453dfc14daa467400e1 100644 (file)
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 // error-pattern:quux
-fn my_err(s: ~str) -> ! { error!("{}", s); fail!("quux"); }
+fn my_err(s: ~str) -> ! { println!("{}", s); fail!("quux"); }
 fn main() { 3u == my_err(~"bye"); }
index ef2a4e5335f45dbd63298721ec01e115c4508b80..96918cfc6f7d3001e5ccb453dfc14daa467400e1 100644 (file)
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 // error-pattern:quux
-fn my_err(s: ~str) -> ! { error!("{}", s); fail!("quux"); }
+fn my_err(s: ~str) -> ! { println!("{}", s); fail!("quux"); }
 fn main() { 3u == my_err(~"bye"); }
index 0541dcca64d4d96ac43e2ca794f7afe1490cb899..daec43ea99352806b5372d8620e5dc109586916c 100644 (file)
@@ -22,8 +22,8 @@ fn main() {
     // wrap around to a small number.
 
     let idx = uint::MAX & !(uint::MAX >> 1u);
-    error!("ov2 idx = 0x%x", idx);
+    println!("ov2 idx = 0x%x", idx);
 
     // This should fail.
-    error!("ov2 0x%x",  x[idx]);
+    println!("ov2 0x%x",  x[idx]);
 }
index c95d128c085619c444bd718707ad55f76f68314d..e262d088ba018477c9f6b2b79192f66c7255cd4b 100644 (file)
@@ -24,17 +24,17 @@ fn main() {
     // This test is only meaningful on 32-bit hosts.
 
     let idx = u64::MAX & !(u64::MAX >> 1u);
-    error!("ov3 idx = 0x%8.8x%8.8x",
+    println!("ov3 idx = 0x%8.8x%8.8x",
            (idx >> 32) as uint,
            idx as uint);
 
     // This should fail.
-    error!("ov3 0x%x",  x[idx]);
+    println!("ov3 0x%x",  x[idx]);
 }
 
 #[cfg(target_arch="x86_64")]
 fn main() {
     // This version just fails anyways, for symmetry on 64-bit hosts.
     let x = ~[1u,2u,3u];
-    error!("ov3 0x%x",  x[200]);
+    println!("ov3 0x%x",  x[200]);
 }
index 932b9a0d4510656d042b309ee12b34cac45c5abf..152f90f974079358a138d5921ca6fbdc80d03609 100644 (file)
@@ -24,12 +24,12 @@ fn main() {
 
     let base = x.as_ptr() as uint;
     let idx = base / mem::size_of::<uint>();
-    error!("ov1 base = 0x{:x}", base);
-    error!("ov1 idx = 0x{:x}", idx);
-    error!("ov1 sizeof::<uint>() = 0x{:x}", mem::size_of::<uint>());
-    error!("ov1 idx * sizeof::<uint>() = 0x{:x}",
+    println!("ov1 base = 0x{:x}", base);
+    println!("ov1 idx = 0x{:x}", idx);
+    println!("ov1 sizeof::<uint>() = 0x{:x}", mem::size_of::<uint>());
+    println!("ov1 idx * sizeof::<uint>() = 0x{:x}",
            idx * mem::size_of::<uint>());
 
     // This should fail.
-    error!("ov1 0x{:x}",  x[idx]);
+    println!("ov1 0x{:x}",  x[idx]);
 }
index 06369ba805de439ba8fd999963e76006c529c5ed..93f55261574ead6259bcf71de6d4af4e56e9ce41 100644 (file)
@@ -44,7 +44,7 @@ fn main() {
     for _ in range(0, 10u) {
         task::spawn(proc() {
             let result = count(5u);
-            info!("result = %?", result);
+            println!("result = %?", result);
             fail!();
         });
     }
index 705b7f4028c2714aae2a675ace5a2cbfc999f2ff..e23145ec2535798c676df3b5bb918e2624932b7d 100644 (file)
@@ -9,6 +9,6 @@
 // except according to those terms.
 
 // error-pattern:woe
-fn f(a: int) { info!("{}", a); }
+fn f(a: int) { println!("{}", a); }
 
 fn main() { f(fail!("woe")); }
index d51a2728d3aa32d5f9ea2ee2a0c5a9e9a9246626..f90530a4435b1770da42f8cd9a30e38e1e18853f 100644 (file)
@@ -9,5 +9,4 @@
 // except according to those terms.
 
 // error-pattern:moop
-extern crate extra;
 fn main() { fail!("moop"); }
index ada9e698e657ed023a860336946b6407ca73f478..e54c754f53bc18c3506b4492cba55c6a53041bc5 100644 (file)
@@ -9,6 +9,5 @@
 // except according to those terms.
 
 // error-pattern:meh
-extern crate extra;
 
 fn main() { let str_var: ~str = ~"meh"; fail!("{}", str_var); }
index f3e8c9d298ce46da6c876ff0562e221282e83885..508463599a32fe36c2551dd958014c84365e6840 100644 (file)
@@ -9,6 +9,5 @@
 // except according to those terms.
 
 // error-pattern:moop
-extern crate extra;
 
 fn main() { for _ in range(0u, 10u) { fail!("moop"); } }
index d9e64fecfd49f618ce0cbd97c14b3303e6227884..b5f39e73fcb1a3bda1968b9c6a6d7a5d4dc53e7d 100644 (file)
@@ -17,7 +17,7 @@ fn even(x: uint) -> bool {
 
 fn foo(x: uint) {
     if even(x) {
-        info!("{}", x);
+        println!("{}", x);
     } else {
         fail!("Number is odd");
     }
index 97c4279b18837f28eed93927d803dd481b177a03..583a5c2010a3736940b1f3274a121257bdcb87ac 100644 (file)
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 // error-pattern:quux
-fn my_err(s: ~str) -> ! { error!("{}", s); fail!("quux"); }
+fn my_err(s: ~str) -> ! { println!("{}", s); fail!("quux"); }
 fn main() { if my_err(~"bye") { } }
index 0d1aebc82e90342aa54982d6c0ccb2785873f2e4..a4a6739bfc1d49a858e5b9a1b7744e648b1e92ee 100644 (file)
@@ -17,4 +17,4 @@ fn cmp() -> int {
     }
 }
 
-fn main() { error!("{}", cmp()); }
+fn main() { println!("{}", cmp()); }
index 08ab065598de4fe90e9166dd7561c3d1eb9a1465..2430c5bb666b5de07b56df2ff2c73e9e5fc96244 100644 (file)
@@ -16,8 +16,6 @@
 // See the hack in upcall_call_shim_on_c_stack where it messes
 // with the stack limit.
 
-extern crate extra;
-
 use std::libc;
 use std::task;
 
index b15be7402312e063cc7423d5653ca12428f9b2cc..2e4aafb9b0d19d0b72c4ebb59daead410e627b7f 100644 (file)
@@ -13,8 +13,6 @@
 
 // Just testing unwinding
 
-extern crate extra;
-
 use std::task;
 
 fn getbig_and_fail(i: int) {
index 7cd19410bfc49e0e2b05853349e15f579fa0f5d3..6d326779ca2ed71bf6427d4527dd7c097ca44ab3 100644 (file)
@@ -13,8 +13,6 @@
 
 // Just testing unwinding
 
-extern crate extra;
-
 use std::task;
 
 fn getbig_and_fail(i: int) {
index a41ab53964bec49e690e1196040aa3a883460ee4..06cba673b34c060fd7b5069db5c4b4718e0d9aab 100644 (file)
@@ -13,5 +13,5 @@
 use std::result;
 
 fn main() {
-    error!("{:?}", result::Err::<int,~str>(~"kitty").unwrap());
+    println!("{:?}", result::Err::<int,~str>(~"kitty").unwrap());
 }
index 7bc5c87c866c03c78696e5e3b2675eeefc59b448..98d7d5cf43704bac80320a88c2860e1db71ba786 100644 (file)
@@ -10,6 +10,8 @@
 
 // error-pattern:whatever
 
+#[feature(phase)];
+#[phase(syntax, link)] extern crate log;
 use std::os;
 
 fn main() {
index d19788d8b5b84f72fa9faf00e7f2b5e2f7f3796b..67f9f5a168fba2e918f6400852b4482cf51d71db 100644 (file)
@@ -10,6 +10,8 @@
 
 // error-pattern:whatever
 
+#[feature(phase)];
+#[phase(syntax, link)] extern crate log;
 use std::os;
 use std::task;
 
index 915e9010b3e0fdf1a6d4c8119ad90b3cadf86856..352e0f65644703b0ef1b49f379129638fff2a2e1 100644 (file)
@@ -10,6 +10,8 @@
 
 // error-pattern:whatever
 
+#[feature(phase)];
+#[phase(syntax, link)] extern crate log;
 use std::os;
 
 fn main() {
index c25eef44683c3e0a56d38c0a928d20e155eb3b95..b8941275591613ee28c12433df1124316102d31e 100644 (file)
@@ -12,8 +12,6 @@
 // compile-flags:--test
 // check-stdout
 
-extern crate extra;
-
 mod m {
     pub fn exported() { }
 
index f9383b9964be058bfaa809f2ee64c819e4b60d09..04733552969c510e3f8d2db016de554509337bd5 100644 (file)
@@ -15,7 +15,7 @@
 // during unwinding
 
 fn recurse() {
-    info!("don't optimize me out");
+    println!("don't optimize me out");
     recurse();
 }
 
index 190d3f17543b416d399887bb224ed5346a9ff60c..a49760f3c58cbd112e905a591210eff24779aaaa 100644 (file)
@@ -19,8 +19,8 @@ fn failfn() {
 fn main() {
     let y = ~0;
     let x: @proc() = @(proc() {
-        error!("{:?}", y.clone());
+        println!("{:?}", y.clone());
     });
     failfn();
-    error!("{:?}", x);
+    println!("{:?}", x);
 }
index 6740331d2f048d846a5f9a9664557c7ab5b77dba..49bcde75594dd09f1583a401cdf0873c170d703d 100644 (file)
@@ -43,6 +43,6 @@ fn main() {
         cast::forget(i1);
         let x = @r(i1p);
         failfn();
-        error!("{:?}", x);
+        println!("{:?}", x);
     }
 }
index 410b86d57146b48bc52b1ccfce70a789e8b97503..6343b81fd2a8009bdbc8ed54d1fa589f85c19cc5 100644 (file)
@@ -19,5 +19,5 @@ fn failfn() {
 fn main() {
     let x = @~"hi";
     failfn();
-    error!("{:?}", x);
+    println!("{:?}", x);
 }
index c4747c6089ef5f3b156ef080f9e5bed94f8f300b..d9f425403eb07ae74b22648453b8e902ea8cb0bb 100644 (file)
@@ -19,5 +19,5 @@ fn failfn() {
 fn main() {
     let x = @~~0;
     failfn();
-    error!("{:?}", x);
+    println!("{:?}", x);
 }
index e99c050d16a2045831d3d32faacca94668a64aec..045ffea0fcd4ca5a43f8f63b48c9e7042e69d8d8 100644 (file)
@@ -19,5 +19,5 @@ fn failfn() {
 fn main() {
     let x = @~0;
     failfn();
-    error!("{:?}", x);
+    println!("{:?}", x);
 }
index 4a5cd270116051569e91b3ff6958f97af5d90f8a..957b631abd39ae89386b496f16d053193b0f81ed 100644 (file)
@@ -19,5 +19,5 @@ fn failfn() {
 fn main() {
     let x = @~[0, 1, 2, 3, 4, 5];
     failfn();
-    error!("{:?}", x);
+    println!("{:?}", x);
 }
index 15b0a9140cf51c12ef1453f94554c68002fe2238..d5bada4a127f902ba503dd9b532f2834d7458130 100644 (file)
 #[crate_id="boot#0.1"];
 #[crate_type="dylib"];
 #[no_uv];
+#[feature(phase)];
 
 extern crate rustuv;
 extern crate green;
+#[phase(syntax, link)] extern crate log;
 
 use std::rt::crate_map::{CrateMap, rust_set_crate_map};
 
@@ -24,7 +26,7 @@
 #[no_mangle] // this needs to get called from C
 pub extern "C" fn foo(argc: int, argv: **u8) -> int {
     green::start(argc, argv, proc() {
-        if log_enabled!(std::logging::DEBUG) { return }
+        if log_enabled!(log::DEBUG) { return }
         fail!()
     })
 }
index 0e31cbd2e955ce83200951192a04ef9144bfadfb..1c797d8369f6af84abc3a92c6560ca929cf9f6a5 100644 (file)
@@ -13,7 +13,6 @@
 
 #[feature(quote)];
 
-extern crate extra;
 extern crate syntax;
 
 use std::io::*;
@@ -84,7 +83,7 @@ fn check_pp<T>(cx: fake_ext_ctxt,
     });
     stdout().write_line(s);
     if expect != ~"" {
-        error!("expect: '%s', got: '%s'", expect, s);
+        println!("expect: '%s', got: '%s'", expect, s);
         assert_eq!(s, expect);
     }
 }
index 5683a2b66986118b7613260cd0494559a57bda24..a0233360a7ccf1f36567120122a1f9e00599f51c 100644 (file)
@@ -36,7 +36,7 @@ fn f<A:Clone + 'static>(a: A, b: u16) -> ~Invokable:<A> {
 
 pub fn main() {
     let (a, b) = f(22_u64, 44u16).f();
-    info!("a={:?} b={:?}", a, b);
+    println!("a={:?} b={:?}", a, b);
     assert_eq!(a, 22u64);
     assert_eq!(b, 44u16);
 }
index 5cbd0da23cf7f26536f8abf7fd66638fe087a412..24c63e5affc0dc36bcffd4398162900ac6d56792 100644 (file)
@@ -12,6 +12,6 @@
 
 pub fn main() {
     let a: int = 10;
-    info!("{}", a);
+    println!("{}", a);
     assert_eq!(a * (a - 1), 90);
 }
index 0b3492784c871111cfc9479438c158422e0454ed..e834aa5aa099dff1ba67a8ac966e18b87c3a68ca 100644 (file)
@@ -28,6 +28,6 @@ pub fn main() {
     assert_eq!(i32_b << 1, i32_b << 1);
     assert_eq!(i32_b >> 1, i32_b >> 1);
     assert_eq!(i32_b & i32_b << 1, 0);
-    info!("{}", i32_b | i32_b << 1);
+    println!("{}", i32_b | i32_b << 1);
     assert_eq!(i32_b | i32_b << 1, 0x30303030);
 }
diff --git a/src/test/run-pass/asm-in-out-operand.rs b/src/test/run-pass/asm-in-out-operand.rs
new file mode 100644 (file)
index 0000000..11d4321
--- /dev/null
@@ -0,0 +1,67 @@
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-fast #[feature] doesn't work with check-fast
+#[feature(asm)];
+
+#[cfg(target_arch = "x86")]
+#[cfg(target_arch = "x86_64")]
+unsafe fn next_power_of_2(n: u32) -> u32 {
+    let mut tmp = n;
+    asm!("dec $0" : "+rm"(tmp) :: "cc");
+    let mut shift = 1u;
+    while shift <= 16 {
+        asm!(
+            "shr %cl, $2
+            or $2, $0
+            shl $$1, $1"
+            : "+&rm"(tmp), "+{ecx}"(shift) : "r"(tmp) : "cc"
+        );
+    }
+    asm!("inc $0" : "+rm"(tmp) :: "cc");
+    return tmp;
+}
+
+#[cfg(target_arch = "x86")]
+#[cfg(target_arch = "x86_64")]
+pub fn main() {
+    unsafe {
+        assert_eq!(64, next_power_of_2(37));
+        assert_eq!(2147483648, next_power_of_2(2147483647));
+    }
+
+    let mut y: int = 5;
+    let x: int;
+    unsafe {
+        // Treat the output as initialization.
+        asm!(
+            "shl $2, $1
+            add $3, $1
+            mov $1, $0"
+            : "=r"(x), "+r"(y) : "i"(3u), "ir"(7u) : "cc"
+        );
+    }
+    assert_eq!(x, 47);
+    assert_eq!(y, 47);
+
+    let mut x = x + 1;
+    assert_eq!(x, 48);
+
+    unsafe {
+        // Assignment to mutable.
+        // Early clobber "&":
+        // Forbids the use of a single register by both operands.
+        asm!("shr $$2, $1; add $1, $0" : "+&r"(x) : "r"(x) : "cc");
+    }
+    assert_eq!(x, 60);
+}
+
+#[cfg(not(target_arch = "x86"), not(target_arch = "x86_64"))]
+pub fn main() {}
index 30d4315f081ac10e9b1a40e34a5f7cb22e7cd0aa..2a65fd9d8a655deed16e76b4998094b4845acc89 100644 (file)
@@ -11,7 +11,7 @@
 // error-pattern:expected item
 
 #[foo = "bar"]
-extern crate extra;
+extern crate test;
 
 pub fn main() {
 }
index 0d099841c0b3934798c3f02b8be59a6d5cb448ac..5b8e62de6bd820a0d16831458bef2e01c7186f59 100644 (file)
@@ -12,7 +12,7 @@
 
 mod m {
     #[foo = "bar"]
-    extern crate extra;
+    extern crate test;
 }
 
 pub fn main() {
index a4b6d33fb798666eaf3a1dc8b86ae9086cbe7cfe..c2b276aac095b9e14b51ffb4979cfac895a439da 100644 (file)
@@ -18,6 +18,6 @@ struct Triple { x: int, y: int, z: int }
 fn f<T,U>(x: T, y: U) -> Pair<T, U> { return Pair {a: x, b: y}; }
 
 pub fn main() {
-    info!("{:?}", f(Triple {x: 3, y: 4, z: 5}, 4).a.x);
-    info!("{:?}", f(5, 6).a);
+    println!("{:?}", f(Triple {x: 3, y: 4, z: 5}, 4).a.x);
+    println!("{:?}", f(5, 6).a);
 }
index 0e3b33a91d4dc3e99422b8d514fa8a1c5550adc5..7252e319372e6dab385c4fdb6f26bf751daa5f7e 100644 (file)
@@ -37,11 +37,11 @@ fn double() {
 
 fn runtest(me: &str) {
     let mut env = os::env();
-    match env.iter().position(|&(ref s, _)| "RUST_LOG" == *s) {
+    match env.iter().position(|&(ref s, _)| "RUST_BACKTRACE" == *s) {
         Some(i) => { env.remove(i); }
         None => {}
     }
-    env.push((~"RUST_LOG", ~"std::rt::backtrace"));
+    env.push((~"RUST_BACKTRACE", ~"1"));
 
     // Make sure that the stack trace is printed
     let mut p = Process::configure(ProcessConfig {
index 233509a8cd2a87ff9b7140afffdf39ddb064c5c8..3e3d9aab84e89dd584f7ae6ca376a6d228632f29 100644 (file)
@@ -81,7 +81,7 @@ fn test_class() {
   let mut r = p(1, 2);
 
   unsafe {
-  error!("q = {:x}, r = {:x}",
+  println!("q = {:x}, r = {:x}",
          (::std::cast::transmute::<*p, uint>(&q)),
          (::std::cast::transmute::<*p, uint>(&r)));
   }
index 61e36d2d720e764a38ff21a1fa7cd9e3fa115af6..d359f488ca5ec261c0de4f0e4ce25d307e87a2e8 100644 (file)
@@ -26,8 +26,8 @@ fn general() {
     a ^= b;
     b ^= a;
     a = a ^ b;
-    info!("{}", a);
-    info!("{}", b);
+    println!("{}", a);
+    println!("{}", b);
     assert_eq!(b, 1);
     assert_eq!(a, 2);
     assert_eq!(!0xf0 & 0xff, 0xf);
index c149afb87822c8ef8972bedbb7613703486d04cd..fd40f0b4b800299111d457e953788160d00a8668 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 fn asSendfn(f: proc() -> uint) -> uint {
    return f();
 }
index d59804b23954e17fa380451779e55eef48c7cf51..1957992e03d15074546673c967acf1849f1de609 100644 (file)
@@ -22,7 +22,7 @@ pub fn main() {
 
     // Statement form does not require parentheses:
     for i in v.iter() {
-        info!("{:?}", *i);
+        println!("{:?}", *i);
     }
 
 }
index 82e563ae41ced32dd91533988bf6313ec0fc2440..2fb9bb9edfc911215f051518a8c0ffab74cf6603 100644 (file)
@@ -10,5 +10,5 @@
 
 pub fn main() {
     fn as_buf<T>(s: ~str, f: |~str| -> T) -> T { f(s) }
-    as_buf(~"foo", |foo: ~str| -> () error!("{}", foo) );
+    as_buf(~"foo", |foo: ~str| -> () println!("{}", foo) );
 }
index 4aebcd6aa24c9cf0d3645591e97c43cca981cee5..f14d42e17f3f3cbc2c2ef88144ddd0eb0f570563 100644 (file)
@@ -20,6 +20,6 @@ pub fn main() {
             odds += 1;
         }
     });
-    error!("{:?}", odds);
+    println!("{:?}", odds);
     assert_eq!(odds, 4);
 }
index 2e149f88478c1863ddab5e96e202f4d8a2ae33bb..deabead4876b3bbfacd88ebb6fa8e88412d6972d 100644 (file)
@@ -20,6 +20,6 @@ pub fn main() {
             sum += *i * *j;
         });
     });
-    error!("{:?}", sum);
+    println!("{:?}", sum);
     assert_eq!(sum, 225);
 }
index 10760236e6dc3215d5097446e031ea289a973fab..d90087ebdea7858fd416aafe4e70d070a4520d56 100644 (file)
@@ -31,9 +31,9 @@ pub fn main() {
     add_int(ints, 44);
 
     iter_ints(ints, |i| {
-        error!("int = {}", *i);
+        println!("int = {}", *i);
         true
     });
 
-    error!("ints={:?}", ints);
+    println!("ints={:?}", ints);
 }
index 5cdda81c43604d436c5ff20dd0edf0205392b502..e9248864c02ad97d747e759110204708b5f3c01d 100644 (file)
@@ -30,7 +30,7 @@ pub fn main() {
         assert_eq!(&(*x.f) as *int, &(*b_x) as *int);
         x = @F {f: ~4};
 
-        info!("&*b_x = {:p}", &(*b_x));
+        println!("&*b_x = {:p}", &(*b_x));
         assert_eq!(*b_x, 3);
         assert!(&(*x.f) as *int != &(*b_x) as *int);
     })
index 3050d6fa0113005172c991a250f4ed45877a0240..6f6d8eba9c0c46cd16619a5e6618b529e95ba56a 100644 (file)
@@ -30,7 +30,7 @@ pub fn main() {
         assert_eq!(&(*x.f) as *int, &(*b_x) as *int);
         *x = @F{f: ~4};
 
-        info!("&*b_x = {:p}", &(*b_x));
+        println!("&*b_x = {:p}", &(*b_x));
         assert_eq!(*b_x, 3);
         assert!(&(*x.f) as *int != &(*b_x) as *int);
     })
index 76dfbffc09c0667d61df085d755fe1291766e791..cd2bfee700aa56b9296a30a36f030e7bdea97e50 100644 (file)
@@ -28,7 +28,7 @@ pub fn main() {
         assert_eq!(&(*x) as *int, &(*b_x) as *int);
         x = @22;
 
-        info!("&*b_x = {:p}", &(*b_x));
+        println!("&*b_x = {:p}", &(*b_x));
         assert_eq!(*b_x, 3);
         assert!(&(*x) as *int != &(*b_x) as *int);
     })
index 57365e98f97e9885468c9e822999388a1d49ee90..7c8008b1b3fc56b96f858da5a27d2fb8f0578571 100644 (file)
@@ -27,13 +27,13 @@ fn testfn(cond: bool) {
         exp = 4;
     }
 
-    info!("*r = {}, exp = {}", *r, exp);
+    println!("*r = {}, exp = {}", *r, exp);
     assert_eq!(*r, exp);
 
     x = @5;
     y = @6;
 
-    info!("*r = {}, exp = {}", *r, exp);
+    println!("*r = {}, exp = {}", *r, exp);
     assert_eq!(*r, exp);
     assert_eq!(x, @5);
     assert_eq!(y, @6);
index 00e59f5132db7eac0901b4ae8266fddc95a7f264..fda6bcc90c991e60ed29fcc3ba64cb7e19be3a39 100644 (file)
@@ -30,7 +30,7 @@ pub fn main() {
         assert_eq!(&(*x.f) as *int, &(*b_x) as *int);
         x = @F {f: ~4};
 
-        info!("&*b_x = {:p}", &(*b_x));
+        println!("&*b_x = {:p}", &(*b_x));
         assert_eq!(*b_x, 3);
         assert!(&(*x.f) as *int != &(*b_x) as *int);
     })
index baec382f3ca3aca4d4d121bbb2f96d39bc3b40a9..1e003e1cb9eb008631dc715db21157735a386cde 100644 (file)
@@ -17,7 +17,7 @@
 fn length_is_even(_vs: @int) -> bool { return true; }
 
 fn foo(_acc: int, n: int) {
-    if is_odd(n) && length_is_even(some_box(1)) { error!("bloop"); }
+    if is_odd(n) && length_is_even(some_box(1)) { println!("bloop"); }
 }
 
 pub fn main() { foo(67, 5); }
index acc494a5665f4b1a36fd1c4ceee5727ca33cf715..8f3f254dfe97a62f65e91bf984e415d63e0a6984 100644 (file)
@@ -17,7 +17,7 @@
 fn length_is_even(_vs: @int) -> bool { return true; }
 
 fn foo(_acc: int, n: int) {
-    if is_odd(n) || length_is_even(some_box(1)) { error!("bloop"); }
+    if is_odd(n) || length_is_even(some_box(1)) { println!("bloop"); }
 }
 
 pub fn main() { foo(67, 5); }
index a5ba89271c4eb07a1b420904c0335ff0dc186ae4..59050a64f68f9e623eb273951da07860fd34ae5f 100644 (file)
@@ -17,6 +17,6 @@ struct Box<T> {c: @T}
 pub fn main() {
     let foo: int = 17;
     let bfoo: Box<int> = Box {c: @foo};
-    info!("see what's in our box");
+    println!("see what's in our box");
     assert_eq!(unbox::<int>(bfoo), foo);
 }
index ae98695cf7500a7815993724fedd4c00824926f6..b1db8ad922332d0564ec31719ec37176c1d0218a 100644 (file)
 // ignore-android (FIXME #11419)
 // exec-env:RUST_LOG=info
 
+#[feature(phase)];
+
 #[no_uv];
 extern crate native;
+#[phase(syntax, link)]
+extern crate log;
 
 use std::fmt;
 use std::io::{ChanReader, ChanWriter};
-use std::logging::{set_logger, Logger};
+use log::{set_logger, Logger};
 
 struct MyWriter(ChanWriter);
 
index a831cd1da69d52d3f04d01b14291e2e5d027f3cd..eacdd8f3978f6c80947c0cb507d7cef4ba462d31 100644 (file)
@@ -10,5 +10,5 @@
 
 pub fn main() {
     let x = 3;
-    info!("&x={:x}", (&x as *int as uint));
+    println!("&x={:x}", (&x as *int as uint));
 }
index cb77c63d4511a740f8cddbd5cd1656f7632867c5..b276c8a8b07068b307b45752566f08a69facea51 100644 (file)
@@ -19,6 +19,6 @@
 pub fn main() {
     let p = @22u;
     let r = foo(p);
-    info!("r={}", r);
+    println!("r={}", r);
     assert_eq!(r, 22u);
 }
index e5e1736044c5db738765f58b443ac6d0f3e307d1..ee01849e7e7948f57f3297f3db1d61b13b589df3 100644 (file)
 
 pub fn main() {
     //let bt0 = sys::frame_address();
-    //info!("%?", bt0);
+    //println!("%?", bt0);
 
     3u.to(10u, |i| {
         println!("{}", i);
 
         //let bt1 = sys::frame_address();
-        //info!("%?", bt1);
+        //println!("%?", bt1);
         //assert!(bt0 == bt1);
     })
 }
index 41717177f75bc8b7b6b1158c0c18e17825b64d3a..4a5770b3c6c246fa62ff42d25ec43ba50a194a84 100644 (file)
@@ -15,7 +15,7 @@
 
 pub fn main() {
     //let bt0 = sys::rusti::frame_address(1u32);
-    //info!("%?", bt0);
+    //println!("%?", bt0);
     cci_iter_lib::iter([1, 2, 3], |i| {
         println!("{}", *i);
         //assert!(bt0 == sys::rusti::frame_address(2u32));
index faa2a350117043241a73b214922ccc680b9df3da..bd18acedbff4f401eff56bd5676769b6bd0eb2ac 100644 (file)
@@ -21,12 +21,12 @@ pub fn main() {
     // sys::frame_address() to determine if we are inlining is
     // actually working.
     //let bt0 = sys::frame_address();
-    //info!("%?", bt0);
+    //println!("%?", bt0);
     iter(~[1u, 2u, 3u], |i| {
         println!("{}", i);
 
         //let bt1 = sys::frame_address();
-        //info!("%?", bt1);
+        //println!("%?", bt1);
 
         //assert!(bt0 != bt1);
     })
index 72d12b56c5c98dbf61182b39fe6b2c7ad9b90606..f1c91dbaf3549cc97d73c0b1a0d2a6060abf3cd9 100644 (file)
@@ -16,7 +16,7 @@
 fn foo1() -> int { 1 }
 
 // !fooA AND !bar
-#[cfg(not(fooAbar))]
+#[cfg(not(fooA), not(bar))]
 fn foo2() -> int { 2 }
 
 // fooC OR (fooB AND !bar)
@@ -24,8 +24,16 @@ fn foo2() -> int { 2 }
 #[cfg(fooB, not(bar))]
 fn foo2() -> int { 3 }
 
+// fooA AND bar
+#[cfg(fooA, bar)]
+fn foo3() -> int { 2 }
+
+// !(fooA AND bar)
+#[cfg(not(fooA, bar))]
+fn foo3() -> int { 3 }
 
 pub fn main() {
     assert_eq!(1, foo1());
     assert_eq!(3, foo2());
+    assert_eq!(3, foo3());
 }
index 97b3eda5eff63b99af289666036970945119ecfb..f4c95c5b232e0e0606dcf20ddc9d2585e836273c 100644 (file)
@@ -16,7 +16,7 @@ struct cat {
 
 impl Drop for cat {
     #[cat_dropper]
-    fn drop(&mut self) { error!("{} landed on hir feet" , self . name); }
+    fn drop(&mut self) { println!("{} landed on hir feet" , self . name); }
 }
 
 
index fa498e90503e88078ac51d11d23a8b6825bcf099..c4dc0ac7412fd831d687ec0e72b053c57b8be885 100644 (file)
@@ -18,7 +18,7 @@ impl Drop for cat {
        Actually, cats don't always land on their feet when you drop them.
     */
     fn drop(&mut self) {
-        error!("{} landed on hir feet", self.name);
+        println!("{} landed on hir feet", self.name);
     }
 }
 
index 746342ae97345272dda99c6043960cc6eaaf0438..a9a11361f9b0ea2b136ae4f9f5f460f0b79d2cc0 100644 (file)
@@ -16,7 +16,7 @@
 
 fn print_out(thing: ~ToStr, expected: ~str) {
   let actual = thing.to_str();
-  info!("{}", actual);
+  println!("{}", actual);
   assert_eq!(actual, expected);
 }
 
index 10b0ac375a95d79732b7d6a1b6499819fd32ead5..cdf235b113ee5291f24861b3801bfe1cb1864d15 100644 (file)
@@ -22,7 +22,7 @@ struct dog {
 
 impl dog {
     fn bark(&mut self) -> int {
-      info!("Woof {} {}", self.barks, self.volume);
+      println!("Woof {} {}", self.barks, self.volume);
       self.barks += 1u;
       if self.barks % 3u == 0u {
           self.volume += 1;
@@ -30,7 +30,7 @@ fn bark(&mut self) -> int {
       if self.barks % 10u == 0u {
           self.volume -= 2;
       }
-      info!("Grrr {} {}", self.barks, self.volume);
+      println!("Grrr {} {}", self.barks, self.volume);
       self.volume
     }
 }
@@ -70,7 +70,7 @@ pub fn meow_count(&self) -> uint {
 
 impl cat {
     fn meow(&mut self) -> uint {
-        info!("Meow");
+        println!("Meow");
         self.meows += 1u;
         if self.meows % 5u == 0u {
             self.how_hungry += 1;
index 56b61dc5691df6b20d71839896ce0fa21635526b..b57851ea3cfb995c0a469744e01be15f4b583ad4 100644 (file)
@@ -27,12 +27,12 @@ impl noisy for cat {
 impl cat {
   pub fn eat(&mut self) -> bool {
     if self.how_hungry > 0 {
-        error!("OM NOM NOM");
+        println!("OM NOM NOM");
         self.how_hungry -= 2;
         return true;
     }
     else {
-        error!("Not hungry!");
+        println!("Not hungry!");
         return false;
     }
   }
@@ -40,7 +40,7 @@ pub fn eat(&mut self) -> bool {
 
 impl cat {
     fn meow(&mut self) {
-      error!("Meow");
+      println!("Meow");
       self.meows += 1u;
       if self.meows % 5u == 0u {
           self.how_hungry += 1;
index b9288a67f969f6d46c6e7ce35a54f512983cba37..e70341612df2a64468ce1f4564e4456580a10c7e 100644 (file)
@@ -39,11 +39,11 @@ impl<T> cat<T> {
 
     pub fn eat(&mut self) -> bool {
         if self.how_hungry > 0 {
-            error!("OM NOM NOM");
+            println!("OM NOM NOM");
             self.how_hungry -= 2;
             return true;
         } else {
-            error!("Not hungry!");
+            println!("Not hungry!");
             return false;
         }
     }
@@ -107,7 +107,7 @@ pub fn new(in_x: int, in_y: int, in_name: T) -> cat<T> {
 impl<T> cat<T> {
     fn meow(&mut self) {
         self.meows += 1;
-        error!("Meow {}", self.meows);
+        println!("Meow {}", self.meows);
         if self.meows % 5 == 0 {
             self.how_hungry += 1;
         }
index caa4a3b2feb6f9e349f2942039cd96695ea43cbc..1b4a9fbd099f5eb441cbe5f857bd00e02f4b2f55 100644 (file)
@@ -23,12 +23,12 @@ struct cat {
 impl cat {
     pub fn eat(&mut self) -> bool {
         if self.how_hungry > 0 {
-            error!("OM NOM NOM");
+            println!("OM NOM NOM");
             self.how_hungry -= 2;
             return true;
         }
         else {
-            error!("Not hungry!");
+            println!("Not hungry!");
             return false;
         }
     }
@@ -40,7 +40,7 @@ impl noisy for cat {
 
 impl cat {
     fn meow(&mut self) {
-        error!("Meow");
+        println!("Meow");
         self.meows += 1u;
         if self.meows % 5u == 0u {
             self.how_hungry += 1;
index dbd34f35e27409c98b079cf622f9c99631159a2f..d967310b907c4730955363d1953b63a5e0c8a99b 100644 (file)
@@ -24,7 +24,7 @@ struct cat {
 
 impl cat {
     fn meow(&mut self) {
-        error!("Meow");
+        println!("Meow");
         self.meows += 1u;
         if self.meows % 5u == 0u {
             self.how_hungry += 1;
@@ -35,11 +35,11 @@ fn meow(&mut self) {
 impl cat {
     pub fn eat(&mut self) -> bool {
         if self.how_hungry > 0 {
-            error!("OM NOM NOM");
+            println!("OM NOM NOM");
             self.how_hungry -= 2;
             return true;
         } else {
-            error!("Not hungry!");
+            println!("Not hungry!");
             return false;
         }
     }
index 55fa783391ad953e51c3a7aea3746a43261f88b2..a93f7c9d73b3e4f928f359993c80d8b1115fc178 100644 (file)
@@ -24,12 +24,12 @@ impl cat {
 
     pub fn eat(&mut self) -> bool {
         if self.how_hungry > 0 {
-            error!("OM NOM NOM");
+            println!("OM NOM NOM");
             self.how_hungry -= 2;
             return true;
         }
         else {
-            error!("Not hungry!");
+            println!("Not hungry!");
             return false;
         }
     }
@@ -37,7 +37,7 @@ pub fn eat(&mut self) -> bool {
 
 impl cat {
     fn meow(&mut self) {
-        error!("Meow");
+        println!("Meow");
         self.meows += 1u;
         if self.meows % 5u == 0u {
             self.how_hungry += 1;
@@ -61,7 +61,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 
 fn print_out(thing: ~ToStr, expected: ~str) {
   let actual = thing.to_str();
-  info!("{}", actual);
+  println!("{}", actual);
   assert_eq!(actual, expected);
 }
 
index f65bf329823c2c9fe3a7420a61aabc22c0572f7d..26708e8f8a235464a1f34b7955bf26cfecc2dacf 100644 (file)
@@ -20,11 +20,11 @@ impl cat {
 
     pub fn eat(&mut self) -> bool {
         if self.how_hungry > 0 {
-            error!("OM NOM NOM");
+            println!("OM NOM NOM");
             self.how_hungry -= 2;
             return true;
         } else {
-            error!("Not hungry!");
+            println!("Not hungry!");
             return false;
         }
     }
@@ -32,7 +32,7 @@ pub fn eat(&mut self) -> bool {
 
 impl cat {
     fn meow(&mut self) {
-        error!("Meow");
+        println!("Meow");
         self.meows += 1u;
         if self.meows % 5u == 0u {
             self.how_hungry += 1;
index 091cebcc0633bac955bcc2c2611a46445caebfdc..6db42c1e2eef226360b4e014229397103e9f9843 100644 (file)
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
 use std::task::spawn;
 
 struct Pair {
index 6ba665e4005f556aae1a5003e0e4af085b6f09fb..ea75ae2fc5c55a765444fb2578be6747c6d6c4a7 100644 (file)
@@ -40,7 +40,7 @@ fn f<A:Clone + 'static>(a: A, b: u16) -> ~Invokable:<A> {
 
 pub fn main() {
     let (a, b) = f(22_u64, 44u16).f();
-    info!("a={:?} b={:?}", a, b);
+    println!("a={:?} b={:?}", a, b);
     assert_eq!(a, 22u64);
     assert_eq!(b, 44u16);
 }
index ad6c92c4925fb21e1d7b0d55c05a56ae0ec2b19c..03617537c49bba0ae704029ad17fbb409649240d 100644 (file)
@@ -14,13 +14,13 @@ pub fn main() {
     let (tx, rx) = channel();
     let _t = task::spawn(proc() { child(&tx) });
     let y = rx.recv();
-    error!("received");
-    error!("{:?}", y);
+    println!("received");
+    println!("{:?}", y);
     assert_eq!(y, 10);
 }
 
 fn child(c: &Sender<int>) {
-    error!("sending");
+    println!("sending");
     c.send(10);
-    error!("value sent");
+    println!("value sent");
 }
index 8ce7cb140423d653e1d09524203ecf5d6e476ce8..cad7f05171ad08c9f35b384f26f91736d294ebbe 100644 (file)
@@ -36,7 +36,7 @@ fn foo(x: int) -> int {
 
 pub fn main() {
     let x: int = 2 + 2;
-    info!("{}", x);
-    info!("hello, world");
-    info!("{}", 10);
+    println!("{}", x);
+    println!("hello, world");
+    println!("{}", 10);
 }
index 562629053cb33047d24abadba6de27f9131dc62c..8a2a00f56385d203fac3641d436d77e49cf1989e 100644 (file)
 // compile-flags: --cfg ndebug
 // exec-env:RUST_LOG=conditional-debug-macro-off=4
 
+#[feature(phase)];
+#[phase(syntax, link)]
+extern crate log;
+
 pub fn main() {
-    // only fails if debug! evaluates its argument.
+    // only fails if println! evaluates its argument.
     debug!("{:?}", { if true { fail!() } });
 }
index a934a0f668841e8a7ba0f876068dfe9e82863d8d..324f1aade04a4da9de7430b59c5de8c071cf6c60 100644 (file)
@@ -12,9 +12,9 @@
 // exec-env:RUST_LOG=conditional-debug-macro-on=4
 
 pub fn main() {
-    // exits early if debug! evaluates its arguments, otherwise it
+    // exits early if println! evaluates its arguments, otherwise it
     // will hit the fail.
-    debug!("{:?}", { if true { return; } });
+    println!("{:?}", { if true { return; } });
 
     fail!();
 }
index fe060ff482e710d09165fc72cf4840eb516effee..8f78d54c7013714c202f879be5989afbe90bdbfe 100644 (file)
@@ -12,4 +12,4 @@
 
 static i: int = 10;
 
-pub fn main() { info!("{}", i); }
+pub fn main() { println!("{}", i); }
index da5c692d2126c5330aaaef2363745c09d7f91201..197032b3315d33d5feb12f9b82433f50d7768105 100644 (file)
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-test #12920
 
-
-
-pub fn main() { if 1 == 1 { return; } info!("Paul is dead"); }
+pub fn main() { if 1 == 1 { return; } println!("Paul is dead"); }
index 914805c126f376fe442fddcdf519f0c95861eb54..6bac1511d55992875291778ea3034907d811c38d 100644 (file)
@@ -15,5 +15,5 @@
 pub fn main() {
     let x = @Cell::new(5);
     x.set(1000);
-    info!("{:?}", x.get());
+    println!("{:?}", x.get());
 }
index f579e7a3d20acc0a3aac7c656ad1726f8f506ce4..2d33ac4e5dea0162c8638141f864809bbf9234fd 100644 (file)
@@ -14,8 +14,8 @@ pub fn main() {
     let v = &"hello";
     let y : &str = &"there";
 
-    info!("{}", x);
-    info!("{}", y);
+    println!("{}", x);
+    println!("{}", y);
 
     assert_eq!(x[0], 'h' as u8);
     assert_eq!(x[4], 'o' as u8);
@@ -30,7 +30,7 @@ pub fn main() {
     let c = &"cccc";
     let cc = &"ccccc";
 
-    info!("{}", a);
+    println!("{}", a);
 
     assert!(a < b);
     assert!(a <= b);
@@ -38,7 +38,7 @@ pub fn main() {
     assert!(b >= a);
     assert!(b > a);
 
-    info!("{}", b);
+    println!("{}", b);
 
     assert!(a < c);
     assert!(a <= c);
@@ -46,7 +46,7 @@ pub fn main() {
     assert!(c >= a);
     assert!(c > a);
 
-    info!("{}", c);
+    println!("{}", c);
 
     assert!(c < cc);
     assert!(c <= cc);
@@ -54,5 +54,5 @@ pub fn main() {
     assert!(cc >= c);
     assert!(cc > c);
 
-    info!("{}", cc);
+    println!("{}", cc);
 }
index a0af5e5a9e001fa066f479db8b6c71420f3a9b2d..aaa3e3529d416e341506275396e76fb284f0767c 100644 (file)
@@ -22,7 +22,7 @@ pub fn main() {
     let c : &[int] = &[2,2,2,2,3];
     let cc : &[int] = &[2,2,2,2,2,2];
 
-    info!("{:?}", a);
+    println!("{:?}", a);
 
     assert!(a < b);
     assert!(a <= b);
@@ -30,7 +30,7 @@ pub fn main() {
     assert!(b >= a);
     assert!(b > a);
 
-    info!("{:?}", b);
+    println!("{:?}", b);
 
     assert!(b < c);
     assert!(b <= c);
@@ -44,7 +44,7 @@ pub fn main() {
     assert!(c >= a);
     assert!(c > a);
 
-    info!("{:?}", c);
+    println!("{:?}", c);
 
     assert!(a < cc);
     assert!(a <= cc);
@@ -52,5 +52,5 @@ pub fn main() {
     assert!(cc >= a);
     assert!(cc > a);
 
-    info!("{:?}", cc);
+    println!("{:?}", cc);
 }
index a3c5256c2d3651fa94867df3b6158d80cfc00b72..30b716f75d8dffa5361004250f0a7099d05e9c0f 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 /**
  * A function that returns a hash of a value
  *
index 13b21fbe1afe84a702af5ee1257a023d0f510958..0b9b8fbcfd33a98c4a78b5492e43cc171a5a2e39 100644 (file)
@@ -13,7 +13,7 @@ pub mod bar {
         pub fn y() { super::super::foo::x(); }
     }
 
-    pub fn x() { info!("x"); }
+    pub fn x() { println!("x"); }
 }
 
 pub fn main() { self::foo::bar::y(); }
index 85e5534fcf52a1d53ae7c2e18961857c346af83a..a0d97383f0a3d9dbbe17d7ea285745564222cde1 100644 (file)
@@ -15,7 +15,7 @@ pub mod foo {
 }
 
 pub mod bar {
-    pub fn x() { info!("x"); }
+    pub fn x() { println!("x"); }
 }
 
 pub fn main() { foo::x(); }
index f081d13a5b0b13eb330982a08d8e018a70b96f51..eaead09a2f7a94dba73abe34212468836d14e0e0 100644 (file)
@@ -19,8 +19,8 @@ fn test_generic<T>(expected: @T, eq: compare<T>) {
 
 fn test_box() {
     fn compare_box(b1: @bool, b2: @bool) -> bool {
-        info!("{}", *b1);
-        info!("{}", *b2);
+        println!("{}", *b1);
+        println!("{}", *b2);
         return *b1 == *b2;
     }
     test_generic::<bool>(@true, compare_box);
index 43ddfe6d58f3c5ef840496579dd17154b113a77e..b3fbd8c765809003597fb69e97c23f5a54f1b838 100644 (file)
@@ -19,8 +19,8 @@ fn test_generic<T:Clone>(expected: ~T, eq: compare<T>) {
 
 fn test_box() {
     fn compare_box(b1: ~bool, b2: ~bool) -> bool {
-        info!("{}", *b1);
-        info!("{}", *b2);
+        println!("{}", *b1);
+        println!("{}", *b2);
         return *b1 == *b2;
     }
     test_generic::<bool>(~true, compare_box);
index e3b727fafd3c823c43c07f7848f70dc4ce5fbdc3..67f2d750cc024d98fc46c0293c4aab53327b3f03 100644 (file)
@@ -31,13 +31,13 @@ pub fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t,
 
 fn count(n: uint) -> uint {
     unsafe {
-        info!("n = {}", n);
+        println!("n = {}", n);
         rustrt::rust_dbg_call(cb, n)
     }
 }
 
 pub fn main() {
     let result = count(1000u);
-    info!("result = {}", result);
+    println!("result = {}", result);
     assert_eq!(result, 1000u);
 }
index 500ae8951ec4aa72459d3f84f251f2e03808b92d..701ae33132dc38b60f4f3d53636eee7216b07577 100644 (file)
@@ -32,7 +32,7 @@ pub fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t,
 
 fn count(n: uint) -> uint {
     unsafe {
-        info!("n = {}", n);
+        println!("n = {}", n);
         rustrt::rust_dbg_call(cb, n)
     }
 }
@@ -42,7 +42,7 @@ pub fn main() {
     // has a large stack)
     task::spawn(proc() {
         let result = count(1000u);
-        info!("result = {}", result);
+        println!("result = {}", result);
         assert_eq!(result, 1000u);
     });
 }
index c49d589572cbedacd5897151d9ab262d851f2037..16142b2f8967cc5c4d9568ae68d0e6e8fef81d1e 100644 (file)
@@ -31,13 +31,13 @@ pub fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t,
 
 fn fact(n: uint) -> uint {
     unsafe {
-        info!("n = {}", n);
+        println!("n = {}", n);
         rustrt::rust_dbg_call(cb, n)
     }
 }
 
 pub fn main() {
     let result = fact(10u);
-    info!("result = {}", result);
+    println!("result = {}", result);
     assert_eq!(result, 3628800u);
 }
index c35e84154d80ba48bc9eede4d36fab66ce068a64..c67810bb17a8d05a35275d0c6f15faddc3a4847e 100644 (file)
@@ -36,7 +36,7 @@ pub fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t,
 
 fn count(n: uint) -> uint {
     unsafe {
-        info!("n = {}", n);
+        println!("n = {}", n);
         rustrt::rust_dbg_call(cb, n)
     }
 }
@@ -46,7 +46,7 @@ pub fn main() {
     // has a large stack)
     task::spawn(proc() {
         let result = count(12u);
-        info!("result = {}", result);
+        println!("result = {}", result);
         assert_eq!(result, 2048u);
     });
 }
index ccd79600a15a71edf6876d8e18f21fda6bc159be..43c7887d3ef6cca30511aef207d8bec7ec210ca7 100644 (file)
 
 fn fact(n: uint) -> uint {
     unsafe {
-        info!("n = {}", n);
+        println!("n = {}", n);
         externcallback::rustrt::rust_dbg_call(externcallback::cb, n)
     }
 }
 
 pub fn main() {
     let result = fact(10u);
-    info!("result = {}", result);
+    println!("result = {}", result);
     assert_eq!(result, 3628800u);
 }
index 1c5df4acf73c755e1cc9f5c8cdacb399ad5130fc..434b684756b6965788bcb18f32cf0d4d0eab4be9 100644 (file)
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
 extern crate mystd = "std";
 
 pub fn main() {}
index d7b8ed583a5184821ece5b4b6ec1926bfff60589..ba4f0ccfe648569b5808a93e05dd7952776c722e 100644 (file)
@@ -41,7 +41,7 @@ pub fn main() {
     for _ in range(0, 10u) {
         task::spawn(proc() {
             let result = count(5u);
-            info!("result = {}", result);
+            println!("result = {}", result);
             assert_eq!(result, 16u);
         });
     }
index 2f79784ce54097aed7b298244c2ec70d57ede3d9..172ec2f09050ca8e5bf03a33e386292bba5d06a1 100644 (file)
 
 
 fn f(x: int) -> int {
-    // info!("in f:");
+    // println!("in f:");
 
-    info!("{}", x);
+    println!("{}", x);
     if x == 1 {
-        // info!("bottoming out");
+        // println!("bottoming out");
 
         return 1;
     } else {
-        // info!("recurring");
+        // println!("recurring");
 
         let y: int = x * f(x - 1);
-        // info!("returned");
+        // println!("returned");
 
-        info!("{}", y);
+        println!("{}", y);
         return y;
     }
 }
 
 pub fn main() {
     assert_eq!(f(5), 120);
-    // info!("all done");
+    // println!("all done");
 
 }
index 973da6eab8d62c9bf6ec192c73fcda2560c9bfe1..e29cad9c2a3fceab7dd95f538a7061b8cfdbd420 100644 (file)
@@ -16,7 +16,7 @@ enum color {
 }
 
 pub fn main() {
-    error!("{}", match red {
+    println!("{}", match red {
         red => { 1 }
         green => { 2 }
         blue => { 3 }
index 66c84d52745cdbf7c9c62e4847689f4052d79ab5..4d9f7d507f0a50f316d729e9a5d2f0c6dcbb7b19 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 use std::num::Float;
 
 pub fn main() {
index 26974bbcecef76d3fc9eb2433d15a077bd602ff7..08daf1bd80e423ca2f86dfa55df998c40c33d327 100644 (file)
@@ -14,5 +14,5 @@ pub fn main() {
     fn foo(n: f64) -> f64 { return n + 0.12345; }
     let n: f64 = 0.1;
     let m: f64 = foo(n);
-    info!("{}", m);
+    println!("{}", m);
 }
index 987ee233810f7d743171750faf97a38906ab2655..277f0011c1cfb7a719b3d22059f794b4173799dd 100644 (file)
@@ -12,9 +12,9 @@
 
 pub fn main() {
     let pi = 3.1415927;
-    info!("{:?}", -pi * (pi + 2.0 / pi) - pi * 5.0);
+    println!("{:?}", -pi * (pi + 2.0 / pi) - pi * 5.0);
     if pi == 5.0 || pi < 10.0 || pi <= 2.0 || pi != 22.0 / 7.0 || pi >= 10.0
            || pi > 1.0 {
-        info!("yes");
+        println!("yes");
     }
 }
index e01c7ee998c3140843eb519c06d88a3764e355e3..455b71aff877a981c902871535c21f67636414e5 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 fn f() {
-    info!("This is a bare function");
+    println!("This is a bare function");
 }
 
 pub fn main() {
index 7011088fa5d44f69582e55040a02cef3eb7b7174..7a728e18a290143a34181084f5612ca14bdfad08 100644 (file)
@@ -21,8 +21,8 @@ pub fn main() {
     let mut j: int = 0;
     pairs(|p| {
         let (_0, _1) = p;
-        info!("{}", _0);
-        info!("{}", _1);
+        println!("{}", _0);
+        println!("{}", _1);
         assert_eq!(_0 + 10, i);
         i += 1;
         j = _1;
index 81e9ac1b80876b97c39768d84d9d5708c0eb1958..bb726773bb5dbe64936e9e6cef6bd48b71d2c145 100644 (file)
 
 pub fn main() {
     let mut sum: int = 0;
-    first_ten(|i| { info!("main"); info!("{}", i); sum = sum + i; });
-    info!("sum");
-    info!("{}", sum);
+    first_ten(|i| { println!("main"); println!("{}", i); sum = sum + i; });
+    println!("sum");
+    println!("{}", sum);
     assert_eq!(sum, 45);
 }
 
 fn first_ten(it: |int|) {
     let mut i: int = 0;
-    while i < 10 { info!("first_ten"); it(i); i = i + 1; }
+    while i < 10 { println!("first_ten"); it(i); i = i + 1; }
 }
index 7e480f1c32b50f0598ee62365fddd697ffa4d688..7e6a362cabebbed65326552c514bf640142c3ecf 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 mod libc {
     use std::libc::{c_char, size_t};
 
index 72427b6c53906055cedb3bb456ccb944d0919883..9e7344a8dfc05966b38b5668f9cc22f833e6c349 100644 (file)
@@ -15,6 +15,6 @@
 pub fn main() {
     let expected = @100;
     let actual = id::<@int>(expected);
-    info!("{:?}", *actual);
+    println!("{:?}", *actual);
     assert_eq!(*expected, *actual);
 }
index a54c68a907b9b2eb59ddf9bfbda1ef34bc8527e4..898d0c0ec2317f53aa350371866c51713d4a4674 100644 (file)
@@ -15,6 +15,6 @@
 pub fn main() {
     let expected = ~100;
     let actual = id::<~int>(expected.clone());
-    info!("{:?}", *actual);
+    println!("{:?}", *actual);
     assert_eq!(*expected, *actual);
 }
index 396ac88bd06de088756343e85be696b7aa632e8d..80f64d8df3d8fabb382006e987aa9711d7dc86b7 100644 (file)
@@ -25,8 +25,8 @@ fn f<T:Clone>(t: T) -> Pair<T> {
 
 pub fn main() {
     let b = f::<int>(10);
-    info!("{:?}" ,b.a);
-    info!("{:?}", b.b);
+    println!("{:?}" ,b.a);
+    println!("{:?}", b.b);
     assert_eq!(b.a, 10);
     assert_eq!(b.b, 10);
 }
index 6eccdb93d8c88f62eaf914007d600faf98cc0c05..9ee237e97f0e48076c35f0a668ca8dc5c60d4243 100644 (file)
@@ -12,4 +12,4 @@
 
 fn f<T>(x: @T) -> @T { return x; }
 
-pub fn main() { let x = f(@3); info!("{:?}", *x); }
+pub fn main() { let x = f(@3); println!("{:?}", *x); }
index 64e7d0101b875469cc448bc3220669176bd73235..c27aff53b6797a7cfc1e204d96c9e5e6c59376a1 100644 (file)
@@ -11,4 +11,4 @@
 
 fn f<T>(x: ~T) -> ~T { return x; }
 
-pub fn main() { let x = f(~3); info!("{:?}", *x); }
+pub fn main() { let x = f(~3); println!("{:?}", *x); }
index 27dc4ad8069b1f4598831286e121359fb5fe09b8..13a9d57e578d82dc4343d37301bfdba1d247a054 100644 (file)
@@ -22,14 +22,14 @@ pub fn main() {
     let p: Triple = Triple {x: 65, y: 66, z: 67};
     let mut q: Triple = Triple {x: 68, y: 69, z: 70};
     y = id::<int>(x);
-    info!("{}", y);
+    println!("{}", y);
     assert_eq!(x, y);
     b = id::<char>(a);
-    info!("{}", b);
+    println!("{}", b);
     assert_eq!(a, b);
     q = id::<Triple>(p);
     x = p.z;
     y = q.z;
-    info!("{}", y);
+    println!("{}", y);
     assert_eq!(x, y);
 }
index f740d8cb2d1591ef73233d5b392bd22d1efde466..c20de257315f49f5682fd0b03c1a43e74f7bfb33 100644 (file)
@@ -14,7 +14,7 @@ enum foo<T> { arm(T), }
 
 fn altfoo<T>(f: foo<T>) {
     let mut hit = false;
-    match f { arm::<T>(_x) => { info!("in arm"); hit = true; } }
+    match f { arm::<T>(_x) => { println!("in arm"); hit = true; } }
     assert!((hit));
 }
 
index 7c4139664afa4a0b93bd03a1202101e76e4c1cba..e9848960180961df381341cfd2f92bd971fac9b4 100644 (file)
@@ -17,12 +17,12 @@ struct Pair { x: int, y: int }
 
 pub fn main() {
     let nop: noption<int> = some::<int>(5);
-    match nop { some::<int>(n) => { info!("{:?}", n); assert!((n == 5)); } }
+    match nop { some::<int>(n) => { println!("{:?}", n); assert!((n == 5)); } }
     let nop2: noption<Pair> = some(Pair{x: 17, y: 42});
     match nop2 {
       some(t) => {
-        info!("{:?}", t.x);
-        info!("{:?}", t.y);
+        println!("{:?}", t.x);
+        println!("{:?}", t.y);
         assert_eq!(t.x, 17);
         assert_eq!(t.y, 42);
       }
index f2dbc5a0d319a5a679302df43a0fada2436014be..99be8a5478c21b7efb7b9b77ff213ee855a56848 100644 (file)
@@ -12,7 +12,7 @@
 
 fn mk() -> int { return 1; }
 
-fn chk(a: int) { info!("{}", a); assert!((a == 1)); }
+fn chk(a: int) { println!("{}", a); assert!((a == 1)); }
 
 fn apply<T>(produce: fn() -> T,
             consume: fn(T)) {
index 9626884be9dd95c75ad97e5a8eba4d3a59cada86..2e9bd371e29ccbfaae98f4286cc94a3f6f28ec31 100644 (file)
@@ -11,7 +11,7 @@
 fn get_third<T>(t: (T, T, T)) -> T { let (_, _, x) = t; return x; }
 
 pub fn main() {
-    info!("{:?}", get_third((1, 2, 3)));
+    println!("{:?}", get_third((1, 2, 3)));
     assert_eq!(get_third((1, 2, 3)), 3);
     assert_eq!(get_third((5u8, 6u8, 7u8)), 7u8);
 }
index 39261094911c1737202216bf63b9c6b5b274c291..03c83bb24c89228c8a6e55cd4feaf07fac76a5c0 100644 (file)
 
 #[feature(macro_rules)];
 
-extern crate extra;
 extern crate glob;
 
 use glob::glob;
-use extra::tempfile::TempDir;
 use std::unstable::finally::Finally;
 use std::{os, unstable};
 use std::io;
+use std::io::TempDir;
 
 macro_rules! assert_eq ( ($e1:expr, $e2:expr) => (
     if $e1 != $e2 {
index fe27eca773037a58a3e6955ba8149000e2214f26..20d33a09f79e5dc1833a4870f0673ed4c383cc3c 100644 (file)
@@ -51,11 +51,11 @@ fn emit(im: &mut HashMap<~str, int>,
                 return;
             }
             let (tx, rx) = channel();
-            error!("sending find_reducer");
+            println!("sending find_reducer");
             ctrl.send(find_reducer(key.as_bytes().to_owned(), tx));
-            error!("receiving");
+            println!("receiving");
             let c = rx.recv();
-            error!("{:?}", c);
+            println!("{:?}", c);
             im.insert(key, c);
         }
 
index 6ac169fed9b09e62f1b27d33733eefa27e6f95a0..97429131a7c3261b26aac2b96991153ded3f81aa 100644 (file)
@@ -12,5 +12,5 @@
 
 pub fn main() {
     let i: int = if false { fail!() } else { 5 };
-    info!("{:?}", i);
+    println!("{:?}", i);
 }
index 50a1b4345dc7ea3734896cd7e31c7026bfc14ec4..22b5281ef38f04b07d7617e70f77bed03edb29ec 100644 (file)
@@ -16,7 +16,7 @@ fn even(x: uint) -> bool {
 
 fn foo(x: uint) {
     if even(x) {
-        info!("{}", x);
+        println!("{}", x);
     } else {
         fail!();
     }
index 564f7b43426395d756c2a23b730c8290ac6236b2..753e98422b3d4823cd344422020df9a5117fa491 100644 (file)
@@ -13,6 +13,7 @@
 #[feature(macro_rules)];
 #[deny(warnings)];
 #[allow(unused_must_use)];
+#[allow(deprecated_owned_vector)];
 
 use std::fmt;
 use std::io::MemWriter;
index 2d9390245272cf821f44f741c0bde7ae8f755db8..dc5c7d11769b87c489f0d125015f8c6777b23b11 100644 (file)
 use dug::too::greedily::and::too::deep::*;
 
 mod module_of_many_things {
-    pub fn f1() { info!("f1"); }
-    pub fn f2() { info!("f2"); }
-    fn f3() { info!("f3"); }
-    pub fn f4() { info!("f4"); }
+    pub fn f1() { println!("f1"); }
+    pub fn f2() { println!("f2"); }
+    fn f3() { println!("f3"); }
+    pub fn f4() { println!("f4"); }
 }
 
 mod dug {
@@ -28,8 +28,8 @@ pub mod greedily {
             pub mod and {
                 pub mod too {
                     pub mod deep {
-                        pub fn nameless_fear() { info!("Boo!"); }
-                        pub fn also_redstone() { info!("Whatever."); }
+                        pub fn nameless_fear() { println!("Boo!"); }
+                        pub fn also_redstone() { println!("Whatever."); }
                     }
                 }
             }
index f2117efb0bbe66c6490815d3c3867059f9b952f2..3ba8f5eace5b18adff1e3321039093feb3602acb 100644 (file)
@@ -13,7 +13,6 @@
 #[feature(globs)];
 #[allow(dead_assignment)];
 
-extern crate extra;
 use std::vec::*;
 
 pub fn main() {
index 176a7ba0047358d09307c55a5deeadf6e63f4caa..5765df4dafad9d7a2a7eeea95aa606ffbd85dbe2 100644 (file)
@@ -11,7 +11,7 @@
 // except according to those terms.
 
 mod foo {
-    pub fn x(y: int) { info!("{:?}", y); }
+    pub fn x(y: int) { println!("{:?}", y); }
 }
 
 mod bar {
index 756fa7d45630cf08037183d799648bde85167bf7..7a3c6a1387798adde23b4f5e0b8674ebcedd78fe 100644 (file)
@@ -14,7 +14,7 @@
 use zed::bar;
 
 mod zed {
-    pub fn bar() { info!("bar"); }
+    pub fn bar() { println!("bar"); }
 }
 
 pub fn main() { bar(); }
index 261283991059c725b96d05e479a8e9b40a276aa8..651f86e5898048bdfb63c6127286231520364fc0 100644 (file)
@@ -17,7 +17,7 @@
 
 mod baz {
     pub mod zed {
-        pub fn bar() { info!("bar2"); }
+        pub fn bar() { println!("bar2"); }
     }
 }
 
index 73b3f4e34830b9bad2ae70ffafa8adbe3bc1ffd3..ff858e81bb8dc05a356f6a8e9c95a12dc954d389 100644 (file)
@@ -14,7 +14,7 @@
 use zed::bar;
 
 mod zed {
-    pub fn bar() { info!("bar"); }
+    pub fn bar() { println!("bar"); }
 }
 
 pub fn main() { let _zed = 42; bar(); }
index 157ae16c5e7d8e487f60a5a44747f59f1e2c402f..f41e4d7d373f0f255684893c2d628f465970387d 100644 (file)
@@ -14,7 +14,7 @@
 mod foo {
     pub use foo::zed::bar;
     pub mod zed {
-        pub fn bar() { info!("foo"); }
+        pub fn bar() { println!("foo"); }
     }
 }
 
index ed5ac89145c31e2aab721079150f8f13b71b7807..cf8dfd5469c9fcd1c73e45d071955f5c98033689 100644 (file)
@@ -17,7 +17,7 @@
 
 mod foo {
     pub mod zed {
-        pub fn baz() { info!("baz"); }
+        pub fn baz() { println!("baz"); }
     }
 }
 mod bar {
index 63b6cd3b42fea074b2394149d93e57c4b944ad7f..fadbc53451905848789c82b580d80062ff4f5e83 100644 (file)
@@ -17,7 +17,7 @@
 
 mod foo {
     pub mod zed {
-        pub fn baz() { info!("baz"); }
+        pub fn baz() { println!("baz"); }
     }
 }
 mod bar {
index e3d9a68afccbc9e7a6f74aa267899bdf5c5c0553..69706a324b63b08dc5cd6cd788a966674663e974 100644 (file)
@@ -15,7 +15,7 @@
 use z = foo::x;
 
 mod foo {
-    pub fn x(y: int) { info!("{}", y); }
+    pub fn x(y: int) { println!("{}", y); }
 }
 
 pub fn main() { x(10); z(10); }
index 50091c94a76b613844b04bb107c25f5bc113c922..f4de938c66e7d9b0ee2a4d042ad03d13fc402625 100644 (file)
@@ -14,8 +14,6 @@
 */
 // ignore-test
 
-extern crate extra;
-
 fn loopy(n: int) {
     if n > 0 { spawn(proc() { loopy(n - 1) }); spawn(proc() { loopy(n - 1) }); }
     loop { }
index 6dbc80c6a459af8dc7b52b45dbddfe1244272509..95a10df5f81286cea27e8c545aec3ec3308389fc 100644 (file)
@@ -13,7 +13,7 @@
 
 mod inner {
     pub mod inner2 {
-        pub fn hello() { info!("hello, modular world"); }
+        pub fn hello() { println!("hello, modular world"); }
     }
     pub fn hello() { inner2::hello(); }
 }
index edc71b524e337d8d0f8e057bf3273b0840ff0473..18ff6fe18963800abf9d9cfaae008557df959dcf 100644 (file)
@@ -20,11 +20,11 @@ pub fn main() {
     assert_eq!(v[3i8], 3);
     assert_eq!(v[3u32], 3);
     assert_eq!(v[3i32], 3);
-    info!("{}", v[3u8]);
+    println!("{}", v[3u8]);
     assert_eq!(s[3u], 'd' as u8);
     assert_eq!(s[3u8], 'd' as u8);
     assert_eq!(s[3i8], 'd' as u8);
     assert_eq!(s[3u32], 'd' as u8);
     assert_eq!(s[3i32], 'd' as u8);
-    info!("{}", s[3u8]);
+    println!("{}", s[3u8]);
 }
index 9c62f5052b2a6df45962ab09f9d7268e5f4943e2..88c964462e835bfdf51881de68c717251fe4c096 100644 (file)
@@ -12,8 +12,6 @@
 
 #[feature(globs)];
 
-extern crate extra;
-
 mod rusti {
     extern "rust-intrinsic" {
         pub fn ctpop8(x: i8) -> i8;
index 14115fa52daa272bf418502b4974dca1e15aa678..3f2c3f4fbd7ab41caac7e4b4b2b6ba43b4761e05 100644 (file)
@@ -20,7 +20,7 @@ pub fn main () {
     let args = os::args();
     if args.len() > 1 && args[1] == ~"child" {
         for _ in range(0, 1000) {
-            error!("hello?");
+            println!("hello?");
         }
         for _ in range(0, 1000) {
             println!("hello?");
diff --git a/src/test/run-pass/issue-12860.rs b/src/test/run-pass/issue-12860.rs
new file mode 100644 (file)
index 0000000..52eafaa
--- /dev/null
@@ -0,0 +1,62 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-fast
+
+extern crate collections;
+
+use collections::HashSet;
+
+#[deriving(Eq, Hash)]
+struct XYZ {
+    x: int,
+    y: int,
+    z: int
+}
+
+fn main() {
+    let mut connected = HashSet::new();
+    let mut border = HashSet::new();
+
+    let middle = XYZ{x: 0, y: 0, z: 0};
+    border.insert(middle);
+
+    while border.len() > 0 && connected.len() < 10000 {
+        let choice = *(border.iter().next().unwrap());
+        border.remove(&choice);
+        connected.insert(choice);
+
+        let cxp = XYZ{x: choice.x + 1, y: choice.y, z: choice.z};
+        let cxm = XYZ{x: choice.x - 1, y: choice.y, z: choice.z};
+        let cyp = XYZ{x: choice.x, y: choice.y + 1, z: choice.z};
+        let cym = XYZ{x: choice.x, y: choice.y - 1, z: choice.z};
+        let czp = XYZ{x: choice.x, y: choice.y, z: choice.z + 1};
+        let czm = XYZ{x: choice.x, y: choice.y, z: choice.z - 1};
+
+        if !connected.contains(&cxp) {
+            border.insert(cxp);
+        }
+        if  !connected.contains(&cxm){
+            border.insert(cxm);
+        }
+        if !connected.contains(&cyp){
+            border.insert(cyp);
+        }
+        if !connected.contains(&cym) {
+            border.insert(cym);
+        }
+        if !connected.contains(&czp){
+            border.insert(czp);
+        }
+        if !connected.contains(&czm) {
+            border.insert(czm);
+        }
+    }
+}
index 2dbed23677f7ce709d43783abd03b2fafe655f77..48a1fd3f78327ddebbdf09b4c180160ca6013ebe 100644 (file)
@@ -17,5 +17,5 @@
 pub fn main() {
     let mut m = HashMap::new();
     m.insert("foo".as_bytes().to_owned(), "bar".as_bytes().to_owned());
-    error!("{:?}", m);
+    println!("{:?}", m);
 }
index 4a1bb2ea8776c296266b9346df6e1457055928b4..311ce2d64b20dc9feeef6cde53395ceb22e6175b 100644 (file)
@@ -27,6 +27,6 @@ pub fn main() {
         break;
     }
 
-    error!("{:?}", x);
+    println!("{:?}", x);
     assert_eq!(x, 42);
 }
index bde18d77b9add6edf023e34e56a14b11f636ff50..a9ebfbcbf3322855036626d69e1da7f883b4c99a 100644 (file)
@@ -13,7 +13,7 @@ struct cat {
 }
 
 fn meow() {
-    error!("meow")
+    println!("meow")
 }
 
 fn cat() -> cat {
index 7c2c1eab87bbb531c30f5ef4d04c575eba17cf83..2e294c30a3f76d3d0cb7bf13cb0ad84d70832662 100644 (file)
@@ -296,16 +296,16 @@ pub fn do_pong(c: pong) -> ping {
 
 fn client(chan: pingpong::client::ping) {
     let chan = pingpong::client::do_ping(chan);
-    error!("Sent ping");
+    println!("Sent ping");
     let (_chan, _data) = pingpong::client::do_pong(chan);
-    error!("Received pong");
+    println!("Received pong");
 }
 
 fn server(chan: pingpong::server::ping) {
     let (chan, _data) = pingpong::server::do_ping(chan);
-    error!("Received ping");
+    println!("Received ping");
     let _chan = pingpong::server::do_pong(chan);
-    error!("Sent pong");
+    println!("Sent pong");
 }
 
 pub fn main() {
index 5e6ea5f6d44e4e77a54f73de322b448bbf7a0a7a..fccd9f3da0b9ec208bb5fa2c4600269f46364381 100644 (file)
@@ -18,7 +18,7 @@
 use collections::HashMap;
 
 fn add_interfaces(managed_ip: ~str, device: HashMap<~str, int>)  {
-     error!("{}, {:?}", managed_ip, device.get(&~"interfaces"));
+     println!("{}, {:?}", managed_ip, device.get(&~"interfaces"));
 }
 
 pub fn main() {}
index 8370e0f7f9c86b78c06b8ca63ad7a36dc7dc741b..ca48f3ffd50d17893020906ef558ef209116dfec 100644 (file)
@@ -29,7 +29,7 @@ fn lookup(table: ~json::Object, key: ~str, default: ~str) -> ~str
             (*s).clone()
         }
         option::Some(value) => {
-            error!("{} was expected to be a string but is a {:?}", key, value);
+            println!("{} was expected to be a string but is a {:?}", key, value);
             default
         }
         option::None => {
@@ -48,7 +48,7 @@ fn add_interface(_store: int, managed_ip: ~str, data: json::Json) -> (~str, obje
             (label, bool_value(false))
         }
         _ => {
-            error!("Expected dict for {} interfaces but found {:?}", managed_ip, data);
+            println!("Expected dict for {} interfaces but found {:?}", managed_ip, data);
             (~"gnos:missing-interface", bool_value(true))
         }
     }
@@ -67,7 +67,7 @@ fn add_interfaces(store: int, managed_ip: ~str, device: HashMap<~str, json::Json
         }
         _ =>
         {
-            error!("Expected list for {} interfaces but found {:?}", managed_ip,
+            println!("Expected list for {} interfaces but found {:?}", managed_ip,
                    device.get(&~"interfaces"));
             ~[]
         }
index 45f59fe9cd43dab4ecbe566a8119e3c7ee984dee..0fa93f37840a18240910e8be8c9427cd52a39da8 100644 (file)
@@ -14,8 +14,6 @@
 
 /// Map representation
 
-extern crate extra;
-
 use std::io;
 use std::fmt;
 
@@ -56,7 +54,7 @@ fn square_from_char(c: char) -> square {
       '.'  => { earth }
       ' '  => { empty }
       _ => {
-        error!("invalid square: {:?}", c);
+        println!("invalid square: {:?}", c);
         fail!()
       }
     }
index 8cf9436ef5134ec4c406de8d2be7a0ca8c0cd1ad..aeef29acd0eafde0268a26967598504111bcd89c 100644 (file)
@@ -29,6 +29,6 @@ pub fn main() {
     //  x.f();
     // y.f();
     // (*z).f();
-    error!("ok so far...");
+    println!("ok so far...");
     z.f(); //segfault
 }
index 94e7297f179931f4d6eddf0e842bb03038e99472..b603759380e3aca8d993f95794e751f2baa74932 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 use std::vec;
 
 trait methods {
index 15580a01f7add8309928d92fe98398e2d92c373b..dc22ebce804e643d6fea7c1482c61dadb5acb820 100644 (file)
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 pub fn main() {
-    error!("{:?}", ("hi there!", "you"));
+    println!("{:?}", ("hi there!", "you"));
 }
index 374607326dfef3080e083d722e430b02892d540c..7cd995f18f446daf5ec280fafca56afb28cee01d 100644 (file)
@@ -11,7 +11,6 @@
 // except according to those terms.
 
 // rustc --test ignores2.rs && ./ignores2
-extern crate extra;
 
 use std::path::{Path};
 use std::path;
index e7089a6a21e5f0110632f00be290a486d9ba5da1..5a787f8c0eea4a44d7c0e7418278eb4d0246302a 100644 (file)
@@ -10,8 +10,6 @@
 
 #[feature(managed_boxes)];
 
-extern crate extra;
-
 enum Token {
     Text(@~str),
     ETag(@~[~str], @~str),
index ae65c46ce71af2f7f1847db5a61243815d1cd84b..7d051e378ab06f2230a53769e338df204f4d9fac 100644 (file)
@@ -16,7 +16,6 @@
 // However the extra library is designed to be optional (for code that must run on constrained
 //  environments like embedded devices or special environments like kernel code) so it must
 // be explicitly linked in.
-extern crate extra;
 
 // Extern mod controls linkage. Use controls the visibility of names to modules that are
 // already linked in. Using WriterUtil allows us to use the write_line method.
index b216ca9a1ca30ba146a85774b5ba1237ed94b2ec..b3b610b91a799a90a274babeefd22fc11e356b55 100644 (file)
@@ -11,7 +11,6 @@
 #[allow(unnecessary_allocation)];
 
 // rustc --test match_borrowed_str.rs.rs && ./match_borrowed_str.rs
-extern crate extra;
 
 fn compare(x: &str, y: &str) -> bool
 {
index 611af3cb36d02aa37e90693dd42e2f1cd63b25a0..424f4648d8e58e0d9e41eb2bb55b28230fc3f393 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 use std::task;
 
 type RingBuffer = ~[f64];
@@ -25,7 +23,7 @@ fn foo(name: ~str, samples_chan: Sender<Msg>) {
         let mut samples_chan = samples_chan;
         let callback: SamplesFn = proc(buffer) {
             for i in range(0u, buffer.len()) {
-                error!("{}: {}", i, buffer[i])
+                println!("{}: {}", i, buffer[i])
             }
         };
         samples_chan.send(GetSamples(name.clone(), callback));
index 0e51da7dae175f4fa7281d8af9f5e62430b48ebc..8722376ab59e917e15dd4a113c7e938127671704 100644 (file)
@@ -17,5 +17,5 @@ pub fn main()
     unsafe {
         libc::exit(0);
     }
-    error!("ack");
+    println!("ack");
 }
index 05404b16f16a9401ac86c64b7ff2a01b73b45d2a..99d943a2f6bdcfc693813101babded1631902b64 100644 (file)
@@ -17,5 +17,5 @@ pub fn main() {
     let a = A { x: 0 };
 
     let A { x: ref x } = a;
-    info!("{:?}", x)
+    println!("{:?}", x)
 }
index ddac18235469331b5ccf03ae03ca586d51662c16..f51221c419ef070a86e6049adf13323afd1ea8f2 100644 (file)
@@ -18,7 +18,7 @@ pub fn main() {
 
     match a {
         A { x : ref x } => {
-            info!("{:?}", x)
+            println!("{:?}", x)
         }
     }
 }
index 11d392f1fb1b358e6d2515a162474e46f641bce5..538699512a3afe01fd0c3d4750e14bffe8d168c7 100644 (file)
@@ -29,7 +29,7 @@ pub fn main() {
     let sa = A { a: 100 };
     let sb = B { b: 200, pa: &sa };
 
-    debug!("sa is {:?}", sa);
-    debug!("sb is {:?}", sb);
-    debug!("sb.pa is {:?}", sb.get_pa());
+    println!("sa is {:?}", sa);
+    println!("sb is {:?}", sb);
+    println!("sb.pa is {:?}", sb.get_pa());
 }
index 9b3db58ea9b293c951a79aca6ef182b24ecf08b4..b8d56f761b8df2e05ab2602e03d60b3b8ee7ab47 100644 (file)
@@ -10,7 +10,7 @@
 
 fn test_stack_assign() {
     let s: ~str = ~"a";
-    info!("{}", s.clone());
+    println!("{}", s.clone());
     let t: ~str = ~"a";
     assert!(s == t);
     let u: ~str = ~"b";
@@ -27,7 +27,7 @@ fn test_heap_assign() {
     assert!((s != u));
 }
 
-fn test_heap_log() { let s = ~"a big ol' string"; info!("{}", s); }
+fn test_heap_log() { let s = ~"a big ol' string"; println!("{}", s); }
 
 fn test_stack_add() {
     assert_eq!(~"a" + "b", ~"ab");
@@ -49,7 +49,7 @@ fn test_append() {
 
     let mut s = ~"a";
     s.push_str("b");
-    info!("{}", s.clone());
+    println!("{}", s.clone());
     assert_eq!(s, ~"ab");
 
     let mut s = ~"c";
index 8ea06e510803dc03bc232d6a609fd05463bb17e3..2235676441047eeccb28f5ae04824fab82d1ae3e 100644 (file)
@@ -16,7 +16,7 @@
 #[attr3];
 #[attr4(attr5)];
 
-#[crate_id="extra#0.1"];
+#[crate_id="foobar#0.1"];
 
 // These are attributes of the following mod
 #[attr1 = "val"]
@@ -140,8 +140,6 @@ fn f() { }
 }
 
 mod test_distinguish_syntax_ext {
-    extern crate extra;
-
     pub fn f() {
         format!("test{}", "s");
         #[attr = "val"]
index c44b7389666f9fe0a42a9c78352c605cda050c45..794c4f4016e62729770e8674a292c4fe5c20499c 100644 (file)
@@ -19,5 +19,5 @@ fn range_(a: int, b: int, it: |int|) {
 pub fn main() {
     let mut sum: int = 0;
     range_(0, 100, |x| sum += x );
-    info!("{}", sum);
+    println!("{}", sum);
 }
index 59baf63d28400403a044653a80bf5b553a40562c..a664daeb7f8cb0748b25c4577569edd605dab3ab 100644 (file)
@@ -15,7 +15,7 @@ struct Refs { refs: ~[int], n: int }
 
 pub fn main() {
     let mut e = Refs{refs: ~[], n: 0};
-    let _f: || = || error!("{}", e.n);
+    let _f: || = || println!("{}", e.n);
     let x: &[int] = e.refs;
     assert_eq!(x.len(), 0);
 }
index c34e65b2b421388de2f71f4ffda6deaaa4be9c1d..f0149c811f0d87f95065e15f864a5c7dc8c3d35d 100644 (file)
@@ -16,5 +16,5 @@ pub fn main() {
     fn invoke(f: ||) { f(); }
     let k = ~22;
     let _u = A {a: k.clone()};
-    invoke(|| error!("{:?}", k.clone()) )
+    invoke(|| println!("{:?}", k.clone()) )
 }
index a3dc848344c4f7f9962a5c66874d13a62cbe102f..aa303aa3b817058014720d9f8e090fb588eaf32b 100644 (file)
@@ -16,7 +16,7 @@ pub fn main() {
     let x = 1 == 2 || 3 == 3;
     assert!((x));
     let mut y: int = 10;
-    info!("{:?}", x || incr(&mut y));
+    println!("{:?}", x || incr(&mut y));
     assert_eq!(y, 10);
     if true && x { assert!((true)); } else { assert!((false)); }
 }
index d58e7f2a28738e7ff612ed706fff5c464d738b46..60f7689ecfa638b536111516e8ae9972d7ff1567 100644 (file)
@@ -10,6 +10,6 @@
 
 
 
-fn foo(x: int) { info!("{}", x); }
+fn foo(x: int) { println!("{}", x); }
 
 pub fn main() { let mut x: int; if 1 > 2 { x = 12; } else { x = 10; } foo(x); }
index 67bbd0967206bad20951c2177185ffe9801b3f3b..2e788737e4d71eb067ceff0ec4de17faaad304f1 100644 (file)
@@ -11,8 +11,8 @@
 pub fn main() {
     let x = ~[1, 2, 3];
     let mut y = 0;
-    for i in x.iter() { info!("{:?}", *i); y += *i; }
-    info!("{:?}", y);
+    for i in x.iter() { println!("{:?}", *i); y += *i; }
+    println!("{:?}", y);
     assert_eq!(y, 6);
     let s = ~"hello there";
     let mut i: int = 0;
@@ -25,8 +25,8 @@ pub fn main() {
         // ...
 
         i += 1;
-        info!("{:?}", i);
-        info!("{:?}", c);
+        println!("{:?}", i);
+        println!("{:?}", c);
     }
     assert_eq!(i, 11);
 }
index 3e11f74f04abbfb00c11c221e29323338c901f71..0dba1830cbd2eaf2098363bf5642535969508b22 100644 (file)
@@ -14,7 +14,7 @@ fn test() {
         v = 3;
         break;
     }
-    info!("{}", v);
+    println!("{}", v);
 }
 
 pub fn main() {
index 57aeac9fcf87c670332a09e08cf964ce2fe83752..01eabad1596a95d7aba92affda999bb1dba4965b 100644 (file)
@@ -10,4 +10,4 @@
 
 
 
-pub fn main() { if false { error!("{}", ~"foo" + "bar"); } }
+pub fn main() { if false { println!("{}", ~"foo" + "bar"); } }
index c5221cd73d7efbbffd37931baecd85caa02216d8..b4a673284811a10c84cb5836a2b95a5bcd631d6e 100644 (file)
@@ -13,8 +13,8 @@ enum Numbers {
 }
 
 pub fn main() {
-    info!("{}", 1);
-    info!("{}", 2.0);
-    warn!("{:?}", Three);
-    error!("{:?}", ~[4]);
+    println!("{}", 1);
+    println!("{}", 2.0);
+    println!("{:?}", Three);
+    println!("{:?}", ~[4]);
 }
index c5ff2bc46cd96bcc5a8d44109b0b234c643b3c61..b3a77aa96752f1f0de6a7dae3555d0cf3fc58321 100644 (file)
 // compile-flags:--cfg ndebug
 // exec-env:RUST_LOG=logging-enabled-debug=debug
 
-use std::logging;
+#[feature(phase)];
+#[phase(syntax, link)]
+extern crate log;
 
 pub fn main() {
-    if log_enabled!(logging::DEBUG) {
+    if log_enabled!(log::DEBUG) {
         fail!("what?! debugging?");
     }
 }
index ba85db6f38bd4a836c2a95c3e0e8e496b829f7f9..587e0b9d4c5fa92b1d69f369429c4854a649e94b 100644 (file)
 // ignore-fast
 // exec-env:RUST_LOG=logging-enabled=info
 
-use std::logging;
+#[feature(phase)];
+#[phase(syntax, link)]
+extern crate log;
 
 pub fn main() {
-    if log_enabled!(logging::DEBUG) {
+    if log_enabled!(log::DEBUG) {
         fail!("what?! debugging?");
     }
-    if !log_enabled!(logging::INFO) {
+    if !log_enabled!(log::INFO) {
         fail!("what?! no info?");
     }
 }
index 4913df823b4df0e6fc90d23c00c72eb990b476e8..d582b770602369b1a38b5c850655118a35abea94 100644 (file)
@@ -29,7 +29,7 @@ pub fn main() {
     let (tx, rx) = channel();
     spawn(proc() {
         let mut f = Foo(Cell::new(0));
-        debug!("{}", f);
+        println!("{}", f);
         let Foo(ref mut f) = f;
         assert!(f.get() == 1);
         tx.send(());
index d6f148f559dbaa879f965a5f35d27815e1bf8d50..b9b16d10b8c3c26d21ff95e96cab4241167dc9fd 100644 (file)
@@ -11,7 +11,7 @@
 pub fn main() {
   let mut i = 0u;
   loop {
-    error!("a");
+    println!("a");
     i += 1u;
     if i == 10u {
       break;
@@ -23,7 +23,7 @@ pub fn main() {
     if i == 21u {
         break;
     }
-    error!("b");
+    println!("b");
     is_even = false;
     i += 1u;
     if i % 2u != 0u {
@@ -33,7 +33,7 @@ pub fn main() {
   }
   assert!(!is_even);
   loop {
-    error!("c");
+    println!("c");
     if i == 22u {
         break;
     }
index 2a368568f8ca5de53b3d6ff32fafb430f15a2c36..fe1ef4817c6a9caa3f2580dfc58c843968a39251 100644 (file)
@@ -20,9 +20,9 @@ macro_rules! spawn {
 
 pub fn main() {
     spawn! {
-        info!("stmt");
+        println!("stmt");
     };
     let _ = spawn! {
-        info!("expr");
+        println!("expr");
     };
 }
index 861d72ea228a23225fe69e0a038b844c89a95916..7e55e227cc07b660dadcf1e0896c90687cae503d 100644 (file)
@@ -12,5 +12,5 @@
 pub fn main() {
     let i: int =
         match Some::<int>(3) { None::<int> => { fail!() } Some::<int>(_) => { 5 } };
-    info!("{}", i);
+    println!("{}", i);
 }
index 90768fdc6c90366fc136d0c815f44786ec3252d7..47b2ddd5022de7a87574ed2a0334b847b88d8161 100644 (file)
@@ -8,9 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
-extern crate extra;
-
 fn foo<T>(y: Option<T>) {
     let mut x: int;
     let mut rs: ~[int] = ~[];
@@ -28,4 +25,4 @@ fn foo<T>(y: Option<T>) {
     return;
 }
 
-pub fn main() { info!("hello"); foo::<int>(Some::<int>(5)); }
+pub fn main() { println!("hello"); foo::<int>(Some::<int>(5)); }
index e0735e7ad24d7372f334ad194924e5004144a504..e00ee11829547c0b8e4eb0611d8402e0a3fb0dad 100644 (file)
 enum t { make_t(@int), clam, }
 
 fn foo(s: @int) {
-    info!("{:?}", ::std::managed::refcount(s));
+    println!("{:?}", ::std::managed::refcount(s));
     let count = ::std::managed::refcount(s);
     let x: t = make_t(s); // ref up
     assert_eq!(::std::managed::refcount(s), count + 1u);
-    info!("{:?}", ::std::managed::refcount(s));
+    println!("{:?}", ::std::managed::refcount(s));
 
     match x {
       make_t(y) => {
-        info!("{:?}", y); // ref up then down
+        println!("{:?}", y); // ref up then down
 
       }
-      _ => { info!("?"); fail!(); }
+      _ => { println!("?"); fail!(); }
     }
-    info!("{:?}", ::std::managed::refcount(s));
+    println!("{:?}", ::std::managed::refcount(s));
     assert_eq!(::std::managed::refcount(s), count + 1u);
     let _ = ::std::managed::refcount(s); // don't get bitten by last-use.
 }
@@ -38,7 +38,7 @@ pub fn main() {
 
     foo(s); // ref up then down
 
-    info!("{}", ::std::managed::refcount(s));
+    println!("{}", ::std::managed::refcount(s));
     let count2 = ::std::managed::refcount(s);
     assert_eq!(count, count2);
 }
index 84e9012be4e24a13221a496a2d7232694fb601d6..9d59b197d3ab755ccf70beaaa32cf8090a70eaed 100644 (file)
@@ -12,8 +12,8 @@
 
 fn altlit(f: int) -> int {
     match f {
-      10 => { info!("case 10"); return 20; }
-      11 => { info!("case 11"); return 22; }
+      10 => { println!("case 10"); return 20; }
+      11 => { println!("case 11"); return 22; }
       _  => fail!("the impossible happened")
     }
 }
index 2076f46e8ab7bbeab01b9732fff7513dd6a1849d..e5be0e52b94976fb639955d3fdbed934b0d77a1a 100644 (file)
@@ -12,8 +12,8 @@ enum maybe<T> { nothing, just(T), }
 
 fn foo(x: maybe<int>) {
     match x {
-        nothing => { error!("A"); }
-        just(_a) => { error!("B"); }
+        nothing => { println!("A"); }
+        just(_a) => { println!("B"); }
     }
 }
 
index 50aa840e6d748513cc1b19736b4adf41d7f7856e..9fc3a7acf7179b04dd0bca83980e00eaf3c6554c 100644 (file)
@@ -11,7 +11,7 @@
 pub fn main() {
     match ~100 {
       ~x => {
-        info!("{:?}", x);
+        println!("{:?}", x);
         assert_eq!(x, 100);
       }
     }
index 4257442ea33c82b1579e02599fcc620387471836..2109f7ef1eafc3f0fcd4b4c2cf9dc73291c91163 100644 (file)
@@ -19,5 +19,5 @@ pub fn main() {
         Some(num) => num as u32
     };
     assert_eq!(f, 1234u32);
-    error!("{}", f)
+    println!("{}", f)
 }
index 3bedd340fea25e71316c2045cddfbdd70236879c..60cd2941becab396135508fb45ab3fb1cc573dc6 100644 (file)
@@ -10,8 +10,6 @@
 
 #[feature(managed_boxes)];
 
-extern crate extra;
-
 trait Serializer {
 }
 
index ba1128978d38b662c1284c0ce69aa7711adfb55a..65dabba191bc820f845e36a41a63ef1419e78896 100644 (file)
@@ -12,8 +12,6 @@
 
 // This test will call __morestack with various minimum stack sizes
 
-extern crate extra;
-
 use std::task;
 
 fn getbig(i: int) {
index 2bd1eb7fd4bff3df8a9974eee2cc4ff57794aabc..867f00aff530e654ff838c33d9d2ff17afc71b94 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 #[deriving(Clone)]
 struct Triple {
     x: int,
index 2819d9bd76e40981bec676288f18cbdf57f22795..b065b612be5b572339d9f50481ee209206f51411 100644 (file)
@@ -10,8 +10,6 @@
 
 #[feature(managed_boxes)];
 
-extern crate extra;
-
 struct Triple { x: int, y: int, z: int }
 
 fn test(x: bool, foo: @Triple) -> int {
index 660fb447bb0e5401890ec727c927b65d179efba7..60537d99d84e5ccda3509f63bb9761ff68a5e048 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 struct Triple {a: int, b: int, c: int}
 
 fn test(foo: ~Triple) -> ~Triple {
index 67b071af0a27ed3ea2e7c44f3c4dba30c8b23c47..a7ff1bfb23e10abf71cd03eb35433dc140b725bf 100644 (file)
@@ -10,8 +10,6 @@
 
 #[feature(managed_boxes)];
 
-extern crate extra;
-
 struct Triple { a: int, b: int, c: int }
 
 fn test(foo: @Triple) -> @Triple {
index f512a4659853a9a21306f95ea98f93debf40cfd5..e01128554c72613582438900a0b1fc47aa26599a 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 fn grow(v: &mut ~[int]) {
     v.push(1);
 }
@@ -20,6 +18,6 @@ pub fn main() {
     grow(&mut v);
     grow(&mut v);
     let len = v.len();
-    info!("{}", len);
+    println!("{}", len);
     assert_eq!(len, 3 as uint);
 }
index a516e2bf9bc09c2ec8c5964d3dbf6659764580fd..5f86cde261c5ce484a5f9527d56fcf66883049ab 100644 (file)
@@ -16,9 +16,9 @@ fn foo() {
       Some::<int>(_x) => {
         let mut bar;
         match None::<int> { None::<int> => { bar = 5; } _ => { baz(); } }
-        info!("{:?}", bar);
+        println!("{:?}", bar);
       }
-      None::<int> => { info!("hello"); }
+      None::<int> => { println!("hello"); }
     }
 }
 
index 0bc6280393cff82e85bf474c8591207dd68a9945..bc03b0d27ca8dcc201bdb3371319d6de756a5aee 100644 (file)
@@ -16,8 +16,8 @@ enum t { foo(int, uint), bar(int, Option<int>), }
 
 fn nested(o: t) {
     match o {
-        bar(_i, Some::<int>(_)) => { error!("wrong pattern matched"); fail!(); }
-        _ => { error!("succeeded"); }
+        bar(_i, Some::<int>(_)) => { println!("wrong pattern matched"); fail!(); }
+        _ => { println!("succeeded"); }
     }
 }
 
index 1fda2c80608867dcb509f7d5d15d818f4b2efa3c..3f00cf7d18400e6b783a98b54b9e29972571cd27 100644 (file)
 pub fn main() {
     let mut x: int = 1;
     x *= 2;
-    info!("{}", x);
+    println!("{}", x);
     assert_eq!(x, 2);
     x += 3;
-    info!("{}", x);
+    println!("{}", x);
     assert_eq!(x, 5);
     x *= x;
-    info!("{}", x);
+    println!("{}", x);
     assert_eq!(x, 25);
     x /= 5;
-    info!("{}", x);
+    println!("{}", x);
     assert_eq!(x, 5);
 }
index cbd0416cb69b8678117439485c08c3beea65ea72..9a2e83ef2d07c129d8883123ccd5f31da8743a60 100644 (file)
@@ -17,6 +17,6 @@ pub fn main() {
     while b <= 32u {
         0u << b;
         b <<= 1u;
-        info!("{:?}", b);
+        println!("{:?}", b);
     }
 }
index 751ba78b2820fcfd9c3add03a545bf4ceea6711c..d9669812d2ad37711eb4388981fd2fdf54b3d8f3 100644 (file)
@@ -11,5 +11,5 @@
 pub fn main() {
     let x = true;
     if x { let mut i = 10; while i > 0 { i -= 1; } }
-    match x { true => { info!("right"); } false => { info!("wrong"); } }
+    match x { true => { println!("right"); } false => { println!("wrong"); } }
 }
index 087c04e0ff01d66f44ed48c2070a7e5e6a57fc15..03f45900238663ff3c0fe8c4ebf6717dcd67ccc7 100644 (file)
@@ -10,6 +10,8 @@
 
 #[allow(unreachable_code)];
 
-fn dont_call_me() { fail!(); info!("{}", 1); }
+// ignore-test #12920
+
+fn dont_call_me() { fail!(); println!("{}", 1); }
 
 pub fn main() { }
index 0f7e33ce340bb4faa31da2fa47de5b6f8a4ca26b..fed766b23d96c6650d772a652fe0e50e040c944f 100644 (file)
@@ -10,8 +10,8 @@
 
 #[feature(managed_boxes)];
 
-fn magic(x: A) { info!("{:?}", x); }
-fn magic2(x: @int) { info!("{:?}", x); }
+fn magic(x: A) { println!("{:?}", x); }
+fn magic2(x: @int) { println!("{:?}", x); }
 
 struct A { a: @int }
 
index 64dfd3fdefc262b09e7398cbabf54e397078c489..53d2a47863b9d226b6d65223f64edd0ca638e50f 100644 (file)
 // This checks that preemption works.
 
 // note: halfway done porting to modern rust
-extern crate extra;
-
 use std::comm;
-use extra::comm;
 
 fn starve_main(alive: Receiver<int>) {
-    info!("signalling main");
+    println!("signalling main");
     alive.recv();
-    info!("starving main");
+    println!("starving main");
     let mut i: int = 0;
     loop { i += 1; }
 }
@@ -28,14 +25,14 @@ fn starve_main(alive: Receiver<int>) {
 pub fn main() {
     let (port, chan) = stream();
 
-    info!("main started");
+    println!("main started");
     spawn(proc() {
         starve_main(port);
     });
     let mut i: int = 0;
-    info!("main waiting for alive signal");
+    println!("main waiting for alive signal");
     chan.send(i);
-    info!("main got alive signal");
-    while i < 50 { info!("main iterated"); i += 1; }
-    info!("main completed");
+    println!("main got alive signal");
+    while i < 50 { println!("main iterated"); i += 1; }
+    println!("main completed");
 }
index bbb312842ce14587aacf1b3a46174a9852648aca..3bceefb831851ce1a0535cbc35470e0792772a33 100644 (file)
@@ -11,5 +11,5 @@
 
 fn something(f: ||) { f(); }
 pub fn main() {
-    something(|| error!("hi!") );
+    something(|| println!("hi!") );
 }
index 8c1be0a6219756a89d31cd0a0b5c60c5bc9d1bd1..26e6f568ce20c8964046095c68061522e9830df3 100644 (file)
@@ -30,16 +30,16 @@ pub fn main() {
 
     let x = @6;
     let y = x.get();
-    info!("y={}", y);
+    println!("y={}", y);
     assert_eq!(y, 6);
 
     let x = ~6;
     let y = x.get();
-    info!("y={}", y);
+    println!("y={}", y);
     assert_eq!(y, 6);
 
     let x = &6;
     let y = x.get();
-    info!("y={}", y);
+    println!("y={}", y);
     assert_eq!(y, 6);
 }
index 050a51c958d57d4ad74997aaa47c910868f14a63..b958588622fb465ac9fac5903b67c1e60f775579 100644 (file)
@@ -24,16 +24,16 @@ fn call_sum(x: &[int]) -> int { x.sum_() }
 pub fn main() {
     let x = ~[1, 2, 3];
     let y = call_sum(x);
-    info!("y=={}", y);
+    println!("y=={}", y);
     assert_eq!(y, 6);
 
     let x = ~[1, 2, 3];
     let y = x.sum_();
-    info!("y=={}", y);
+    println!("y=={}", y);
     assert_eq!(y, 6);
 
     let x = ~[1, 2, 3];
     let y = x.sum_();
-    info!("y=={}", y);
+    println!("y=={}", y);
     assert_eq!(y, 6);
 }
index 86745deaad8bef4e4fa9db1c51ab925f3d53f158..49e0faf469320c3a7da826e7c42e6a05bc6efac1 100644 (file)
@@ -54,9 +54,9 @@ pub fn main() {
         // Send it through the shape code
         let y = format!("{:?}", x);
 
-        info!("align inner = {:?}", rusti::min_align_of::<Inner>());
-        info!("size outer = {:?}", mem::size_of::<Outer>());
-        info!("y = {}", y);
+        println!("align inner = {:?}", rusti::min_align_of::<Inner>());
+        println!("size outer = {:?}", mem::size_of::<Outer>());
+        println!("y = {}", y);
 
         // per clang/gcc the alignment of `inner` is 4 on x86.
         assert_eq!(rusti::min_align_of::<Inner>(), m::align());
index 560425dcb21b8e815421b6ce1e0740503d3b9270..16d1a0c464c7d0ead93b99dd81245d1bc58b39d6 100644 (file)
@@ -76,9 +76,9 @@ pub fn main() {
         // Send it through the shape code
         let y = format!("{:?}", x);
 
-        info!("align inner = {}", rusti::min_align_of::<Inner>());
-        info!("size outer = {}", mem::size_of::<Outer>());
-        info!("y = {}", y);
+        println!("align inner = {}", rusti::min_align_of::<Inner>());
+        println!("size outer = {}", mem::size_of::<Outer>());
+        println!("y = {}", y);
 
         // per clang/gcc the alignment of `Inner` is 4 on x86.
         assert_eq!(rusti::min_align_of::<Inner>(), m::m::align());
index 57da2e038325a77c0bf1d1fcf74e4561fa9c7703..a1d57241e07049009ec3c5903693d74004aefbf7 100644 (file)
@@ -18,6 +18,6 @@ struct X { foo: ~str, bar: ~str }
 
 pub fn main() {
     let x = X {foo: ~"hello", bar: ~"world"};
-    info!("{}", x.foo.clone());
-    info!("{}", x.bar.clone());
+    println!("{}", x.foo.clone());
+    println!("{}", x.bar.clone());
 }
index f81ddabf77c7ff1dded1e1d3518acb6a05273cd1..6f91497a81c979e8c6c410f72d15f5b166079d62 100644 (file)
@@ -19,32 +19,32 @@ struct MyVisitor {
 impl TyVisitor for MyVisitor {
     fn visit_bot(&mut self) -> bool {
         self.types.push(~"bot");
-        error!("visited bot type");
+        println!("visited bot type");
         true
     }
     fn visit_nil(&mut self) -> bool {
         self.types.push(~"nil");
-        error!("visited nil type");
+        println!("visited nil type");
         true
     }
     fn visit_bool(&mut self) -> bool {
         self.types.push(~"bool");
-        error!("visited bool type");
+        println!("visited bool type");
         true
     }
     fn visit_int(&mut self) -> bool {
         self.types.push(~"int");
-        error!("visited int type");
+        println!("visited int type");
         true
     }
     fn visit_i8(&mut self) -> bool {
         self.types.push(~"i8");
-        error!("visited i8 type");
+        println!("visited i8 type");
         true
     }
     fn visit_i16(&mut self) -> bool {
         self.types.push(~"i16");
-        error!("visited i16 type");
+        println!("visited i16 type");
         true
     }
     fn visit_i32(&mut self) -> bool { true }
index 898759f67d24ab99733a67926b2f5620cc570f74..357d829627da0f898964653ba2f6276ee6327eee 100644 (file)
@@ -14,5 +14,5 @@ fn f<'a>(x : &'a int) -> &'a int {
 
 pub fn main() {
     let three = &3;
-    error!("{}", *f(three));
+    println!("{}", *f(three));
 }
index 5b1b1dd8ec3b481873bca2d3b6c5fe35121a73e0..994140ee1445d389816181f819cb1a94757d93e0 100644 (file)
@@ -17,6 +17,6 @@ fn foo(x: &uint) -> uint {
 pub fn main() {
     let p = @22u;
     let r = foo(p);
-    info!("r={}", r);
+    println!("r={}", r);
     assert_eq!(r, 22u);
 }
index 975dcab1902513d15e16913de5c30b12a36927b8..9e0ca203698313e15091344e29cd0de93cdb0f88 100644 (file)
@@ -11,7 +11,6 @@
 // This test verifies that temporary lifetime is correctly computed
 // for static objects in enclosing scopes.
 
-extern crate extra;
 use std::cmp::Eq;
 
 fn f<T:Eq>(o: &mut Option<T>) {
index cc8174d0d320379ed7a451bdb651c967050d54b7..f1e6c6a0e2fe57e1d3dc0c32a261d35780185065 100644 (file)
@@ -22,6 +22,6 @@ impl<'a> get_chowder<'a> for Clam<'a> {
 
 pub fn main() {
     let clam = Clam { chowder: &3 };
-    info!("{:?}", *clam.get_chowder());
+    println!("{:?}", *clam.get_chowder());
     clam.get_chowder();
 }
index 6e2d62cce927660f8998dcdf5bc2e8b6cdfb54e1..c4037a70d96963cc81f6fbb8466d1ffbd681d32d 100644 (file)
@@ -19,5 +19,5 @@ pub fn main() {
     match y {
         int_wrapper_ctor(zz) => { z = zz; }
     }
-    info!("{:?}", *z);
+    println!("{:?}", *z);
 }
index bb612c5b0df202d6e0f95deb81f61449b73c21a0..62be58605084bb2979c916f7f40860cfefb3f1f8 100644 (file)
@@ -12,5 +12,5 @@ pub fn main() {
     let mut x: int = 3;
     let y: &mut int = &mut x;
     *y = 5;
-    info!("{:?}", *y);
+    println!("{:?}", *y);
 }
index 9d994c423c9a0034df5555453d569173fac49009..ff4b43cb6b5fadf6cab71c01eeecaa952e527237 100644 (file)
@@ -21,6 +21,6 @@ fn call_static_closure(cl: closure_box<'static>) {
 }
 
 pub fn main() {
-    let cl_box = box_it(|| info!("Hello, world!"));
+    let cl_box = box_it(|| println!("Hello, world!"));
     call_static_closure(cl_box);
 }
index 3f14d7befac2791bd0ce146c77997ae3b1350a17..ef43dad2c68ea3fcd641ab40a8f6ea0717a2c9e9 100644 (file)
@@ -12,9 +12,8 @@
 // because it needs TempDir, which is in extra
 
 // ignore-fast
-extern crate extra;
 
-use extra::tempfile::TempDir;
+use std::io::TempDir;
 use std::os;
 use std::libc;
 use std::io;
index 9f2069908437b96e7cf30b2e02c6d0b21ffecb42..e091092b653a86ff002eccd41b5d20f785fe38f9 100644 (file)
@@ -19,6 +19,6 @@ pub fn main() {
     let x = [ [true], ..512 ];
     let y = [ 0, ..1 ];
 
-    error!("{:?}", x);
-    error!("{:?}", y);
+    println!("{:?}", x);
+    println!("{:?}", y);
 }
index bec101a6d45a93c9f14b2c9ae79f8205e9cc0bcb..55d9a8bc63a39909956e237f3b10c924d49f5d41 100644 (file)
@@ -36,7 +36,7 @@ pub fn main() {
         let a = r(i);
         let b = (a, 10);
         let (c, _d) = b;
-        info!("{:?}", c);
+        println!("{:?}", c);
     }
     assert_eq!(i.get(), 1);
 }
index 93183f8dba47582b86a057c1fbdd310dabb58410..af0e9572f38d2b1cf57c6bb7c72beaa3e9aa27f3 100644 (file)
@@ -19,7 +19,7 @@ struct shrinky_pointer {
 #[unsafe_destructor]
 impl Drop for shrinky_pointer {
     fn drop(&mut self) {
-        error!("Hello!"); self.i.set(self.i.get() - 1);
+        println!("Hello!"); self.i.set(self.i.get() - 1);
     }
 }
 
@@ -36,6 +36,6 @@ fn shrinky_pointer(i: @@Cell<int>) -> shrinky_pointer {
 pub fn main() {
     let my_total = @@Cell::new(10);
     { let pt = shrinky_pointer(my_total); assert!((pt.look_at() == 10)); }
-    error!("my_total = {}", my_total.get());
+    println!("my_total = {}", my_total.get());
     assert_eq!(my_total.get(), 9);
 }
index 4f9e3c2c1f644823ea901d9a557bfb485bdb2631..468b6ca51a03cd5c735c6ccfe4ed3152cb47918b 100644 (file)
@@ -11,7 +11,7 @@
 
 
 
-fn my_err(s: ~str) -> ! { error!("{:?}", s); fail!(); }
+fn my_err(s: ~str) -> ! { println!("{:?}", s); fail!(); }
 
 fn okay(i: uint) -> int {
     if i == 3u { my_err(~"I don't like three"); } else { return 42; }
index a39907d5c7ede0890c3f33b67443aba19e27e089..835b5990ac2d5c445de672097a475d11bcf15a51 100644 (file)
@@ -19,7 +19,7 @@ fn test05_start(f: proc(int)) {
 fn test05() {
     let three = ~3;
     let fn_to_send: proc(int) = proc(n) {
-        error!("{}", *three + n); // will copy x into the closure
+        println!("{}", *three + n); // will copy x into the closure
         assert_eq!(*three, 3);
     };
     task::spawn(proc() {
index c5211889f3f0c0e9e93376e770921a5dc3282b9b..b277c16dc4a95e20e9f7a7eec461c7586400e9cb 100644 (file)
@@ -16,7 +16,7 @@ fn foo(c: ~[int]) {
     match none::<int> {
         some::<int>(_) => {
             for _i in c.iter() {
-                info!("{:?}", a);
+                println!("{:?}", a);
                 let a = 17;
                 b.push(a);
             }
index cb8d73108748bc85ecc54252700d1eaf2915756d..b74f080ede730eba3beab6c77ce7f2278a6ec4c9 100644 (file)
@@ -59,6 +59,6 @@ pub fn main() {
     let p_: Path_ = Path_ { global: true, idents: ~[~"hi"], types: ~[t] };
     let p: path = Spanned { data: p_, span: sp };
     let x = X { sp: sp, path: p };
-    error!("{:?}", x.path.clone());
-    error!("{:?}", x.clone());
+    println!("{:?}", x.path.clone());
+    println!("{:?}", x.clone());
 }
index e3d3b3389ba14c569e3c657f72c12059f94c8f4f..04c1af4326bbd2a067d8dcf2213f9587d7f2fd35 100644 (file)
@@ -10,4 +10,4 @@
 
 
 
-pub fn main() { let mut n; n = 1; info!("{}", n); }
+pub fn main() { let mut n; n = 1; println!("{}", n); }
index d8b7c99d000aa30e52f15ad5514eb25ac8afda6b..c0c1135b6d52cb186e59f03ae80fb3ef78e901aa 100644 (file)
@@ -14,5 +14,5 @@ enum opt<T> { none, }
 
 pub fn main() {
     let x = none::<int>;
-    match x { none::<int> => { info!("hello world"); } }
+    match x { none::<int> => { println!("hello world"); } }
 }
index 2caef2d1b9e134f18e14148141ee16c574427f53..5731b8de52942e6d83b2e0b26e4d7c839d683675 100644 (file)
@@ -16,11 +16,11 @@ enum clam<T> { a(T, int), b, }
 fn uhoh<T>(v: ~[clam<T>]) {
     match v[1] {
       a::<T>(ref _t, ref u) => {
-          info!("incorrect");
-          info!("{:?}", u);
+          println!("incorrect");
+          println!("{:?}", u);
           fail!();
       }
-      b::<T> => { info!("correct"); }
+      b::<T> => { println!("correct"); }
     }
 }
 
index 8c9de64687e2738bdcfa93867a41d83046b49553..fe4e38ee879bc91d92eaef6190db0cc07bdf4ab4 100644 (file)
@@ -11,8 +11,8 @@
 use std::task;
 
 fn x(s: ~str, n: int) {
-    info!("{:?}", s);
-    info!("{:?}", n);
+    println!("{:?}", s);
+    println!("{:?}", n);
 }
 
 pub fn main() {
@@ -20,5 +20,5 @@ pub fn main() {
     task::spawn(proc() x(~"hello from second spawned fn", 66) );
     task::spawn(proc() x(~"hello from third spawned fn", 67) );
     let mut i: int = 30;
-    while i > 0 { i = i - 1; info!("parent sleeping"); task::deschedule(); }
+    while i > 0 { i = i - 1; println!("parent sleeping"); task::deschedule(); }
 }
index 002736693788a808b1810c925a53e83cab7940f3..741e20d42db8dc0eab007f8d8c49537c38c3ca95 100644 (file)
@@ -8,12 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 use std::task;
 
 pub fn main() {
     task::spawn(proc() child(10) );
 }
 
-fn child(i: int) { error!("{}", i); assert!((i == 10)); }
+fn child(i: int) { println!("{}", i); assert!((i == 10)); }
index 8530c583b165475e97ab4522d600b2c7d915c25c..6bac7f2a06e76264659f6ecfa3c80d68d490480f 100644 (file)
 
 fn child(args: (int, int, int, int, int, int, int, int, int)) {
     let (i1, i2, i3, i4, i5, i6, i7, i8, i9) = args;
-    error!("{}", i1);
-    error!("{}", i2);
-    error!("{}", i3);
-    error!("{}", i4);
-    error!("{}", i5);
-    error!("{}", i6);
-    error!("{}", i7);
-    error!("{}", i8);
-    error!("{}", i9);
+    println!("{}", i1);
+    println!("{}", i2);
+    println!("{}", i3);
+    println!("{}", i4);
+    println!("{}", i5);
+    println!("{}", i6);
+    println!("{}", i7);
+    println!("{}", i8);
+    println!("{}", i9);
     assert_eq!(i1, 10);
     assert_eq!(i2, 20);
     assert_eq!(i3, 30);
index 714dddf4ab6d32ba4a2daf6ea2b0714b04c56781..db8dc0f64c47e9de5472cdad498f85134db0cf26 100644 (file)
@@ -11,7 +11,7 @@
 // exec-env:RUST_LOG=debug
 // ignore-fast
 
-// regression test for issue #10405, make sure we don't call debug! too soon.
+// regression test for issue #10405, make sure we don't call println! too soon.
 
 use std::task;
 
index 33f4c9d9a982a3f61e70d6e2da93a2d42b19cc78..96e76c798ff43cfddefdf08c636d37b96b5a7d68 100644 (file)
 
 // ignore-fast
 
-extern crate extra;
-
-use extra::tempfile;
-use std::io::File;
+use std::io::{File, TempDir};
 
 pub fn main() {
-    let dir = tempfile::TempDir::new_in(&Path::new("."), "").unwrap();
+    let dir = TempDir::new_in(&Path::new("."), "").unwrap();
     let path = dir.path().join("file");
 
     {
index c6ff57ac4e80418f2aa76584925616ddab558d39..ad6e668524cb2e003b3066bba15f2f8e28581ca5 100644 (file)
@@ -8,14 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
-
-extern crate extra;
-
 fn test1() {
     let mut s: ~str = ~"hello";
     s.push_str("world");
-    info!("{}", s.clone());
+    println!("{}", s.clone());
     assert_eq!(s[9], 'd' as u8);
 }
 
@@ -25,8 +21,8 @@ fn test2() {
     let ff: ~str = ~"abc";
     let a: ~str = ff + "ABC" + ff;
     let b: ~str = ~"ABC" + ff + "ABC";
-    info!("{}", a.clone());
-    info!("{}", b.clone());
+    println!("{}", a.clone());
+    println!("{}", b.clone());
     assert_eq!(a, ~"abcABCabc");
     assert_eq!(b, ~"ABCabcABC");
 }
index 8b87682384b682c2125a5156c1c6e9278a400b18..627bb54dad3968327b846b0428d619552e2d136f 100644 (file)
@@ -15,6 +15,6 @@ pub fn main() {
     let a: ~str = ~"hello";
     let b: ~str = ~"world";
     let s: ~str = a + b;
-    info!("{}", s.clone());
+    println!("{}", s.clone());
     assert_eq!(s[9], 'd' as u8);
 }
index ebed8e24a484187b5058081ed2df7612ed53da13..37abb4be87f2d64f677d7adc976f855ec5445766 100644 (file)
@@ -13,6 +13,6 @@
 pub fn main() {
     let s = ~"hello";
     let c: u8 = s[4];
-    info!("{:?}", c);
+    println!("{:?}", c);
     assert_eq!(c, 0x6f as u8);
 }
index 3c5a860d6c83273aad8ed96700a9463aa04ef744..2331ca64dee591edcf7d526ea063ba2b6e882a6d 100644 (file)
@@ -8,10 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
-
-extern crate extra;
-
 pub fn main() {
     let a: ~str = ~"this \
 is a test";
index 34a818879d0b6dc2212c4fb6f084e1e130425302..f2fa8a06bfd80ae3b8bbb0ccc20442663cd4f682 100644 (file)
@@ -8,15 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 pub fn main() {
     // Make sure we properly handle repeated self-appends.
     let mut a: ~str = ~"A";
     let mut i = 20;
     let mut expected_len = 1u;
     while i > 0 {
-        error!("{}", a.len());
+        println!("{}", a.len());
         assert_eq!(a.len(), expected_len);
         a = a + a; // FIXME(#3387)---can't write a += a
         i -= 1;
index c5f8d0410d81a8816ef75c11fe794aea15c26ed1..0657f1a8faec919de5d3a2834f3af8bfc18de849 100644 (file)
@@ -14,7 +14,7 @@ struct foo {
 
 impl Drop for foo {
     fn drop(&mut self) {
-        error!("{}", self.x);
+        println!("{}", self.x);
     }
 }
 
index c668981b40a7bea729827b6df9b0425d4e8ccb5a..f9a5de40f494505b3847d9a1c0ec8970eee12cba 100644 (file)
@@ -30,10 +30,10 @@ fn test1() {
                  c: 0xcccc_cccc_cccc_cccc_u64,
                  d: 0xdddd_dddd_dddd_dddd_u64 };
         let qq = rustrt::rust_dbg_abi_1(q);
-        error!("a: {:x}", qq.a as uint);
-        error!("b: {:x}", qq.b as uint);
-        error!("c: {:x}", qq.c as uint);
-        error!("d: {:x}", qq.d as uint);
+        println!("a: {:x}", qq.a as uint);
+        println!("b: {:x}", qq.b as uint);
+        println!("c: {:x}", qq.c as uint);
+        println!("d: {:x}", qq.d as uint);
         assert_eq!(qq.a, q.c + 1u64);
         assert_eq!(qq.b, q.d - 1u64);
         assert_eq!(qq.c, q.a + 1u64);
@@ -48,9 +48,9 @@ fn test2() {
                  b: 0b_1010_1010_u8,
                  c: 1.0987654321e-15_f64 };
         let ff = rustrt::rust_dbg_abi_2(f);
-        error!("a: {}", ff.a as f64);
-        error!("b: {}", ff.b as uint);
-        error!("c: {}", ff.c as f64);
+        println!("a: {}", ff.a as f64);
+        println!("b: {}", ff.b as uint);
+        println!("c: {}", ff.c as f64);
         assert_eq!(ff.a, f.c + 1.0f64);
         assert_eq!(ff.b, 0xff_u8);
         assert_eq!(ff.c, f.a - 1.0f64);
index 60e5a157bfc42e5dd84b608ab388999cf9d01c79..e3f2456c4c44248ebdfbb133c7b4a52f43101c43 100644 (file)
 
 pub fn main() {
   let f = 1 as *libc::FILE;
-  info!("{}", f as int);
-  info!("{}", f as uint);
-  info!("{}", f as i8);
-  info!("{}", f as i16);
-  info!("{}", f as i32);
-  info!("{}", f as i64);
-  info!("{}", f as u8);
-  info!("{}", f as u16);
-  info!("{}", f as u32);
-  info!("{}", f as u64);
-
-  info!("{}", 1 as int);
-  info!("{}", 1 as uint);
-  info!("{}", 1 as *libc::FILE);
-  info!("{}", 1 as i8);
-  info!("{}", 1 as i16);
-  info!("{}", 1 as i32);
-  info!("{}", 1 as i64);
-  info!("{}", 1 as u8);
-  info!("{}", 1 as u16);
-  info!("{}", 1 as u32);
-  info!("{}", 1 as u64);
-  info!("{}", 1 as f32);
-  info!("{}", 1 as f64);
-
-  info!("{}", 1u as int);
-  info!("{}", 1u as uint);
-  info!("{}", 1u as *libc::FILE);
-  info!("{}", 1u as i8);
-  info!("{}", 1u as i16);
-  info!("{}", 1u as i32);
-  info!("{}", 1u as i64);
-  info!("{}", 1u as u8);
-  info!("{}", 1u as u16);
-  info!("{}", 1u as u32);
-  info!("{}", 1u as u64);
-  info!("{}", 1u as f32);
-  info!("{}", 1u as f64);
-
-  info!("{}", 1i8 as int);
-  info!("{}", 1i8 as uint);
-  info!("{}", 1i8 as *libc::FILE);
-  info!("{}", 1i8 as i8);
-  info!("{}", 1i8 as i16);
-  info!("{}", 1i8 as i32);
-  info!("{}", 1i8 as i64);
-  info!("{}", 1i8 as u8);
-  info!("{}", 1i8 as u16);
-  info!("{}", 1i8 as u32);
-  info!("{}", 1i8 as u64);
-  info!("{}", 1i8 as f32);
-  info!("{}", 1i8 as f64);
-
-  info!("{}", 1u8 as int);
-  info!("{}", 1u8 as uint);
-  info!("{}", 1u8 as *libc::FILE);
-  info!("{}", 1u8 as i8);
-  info!("{}", 1u8 as i16);
-  info!("{}", 1u8 as i32);
-  info!("{}", 1u8 as i64);
-  info!("{}", 1u8 as u8);
-  info!("{}", 1u8 as u16);
-  info!("{}", 1u8 as u32);
-  info!("{}", 1u8 as u64);
-  info!("{}", 1u8 as f32);
-  info!("{}", 1u8 as f64);
-
-  info!("{}", 1i16 as int);
-  info!("{}", 1i16 as uint);
-  info!("{}", 1i16 as *libc::FILE);
-  info!("{}", 1i16 as i8);
-  info!("{}", 1i16 as i16);
-  info!("{}", 1i16 as i32);
-  info!("{}", 1i16 as i64);
-  info!("{}", 1i16 as u8);
-  info!("{}", 1i16 as u16);
-  info!("{}", 1i16 as u32);
-  info!("{}", 1i16 as u64);
-  info!("{}", 1i16 as f32);
-  info!("{}", 1i16 as f64);
-
-  info!("{}", 1u16 as int);
-  info!("{}", 1u16 as uint);
-  info!("{}", 1u16 as *libc::FILE);
-  info!("{}", 1u16 as i8);
-  info!("{}", 1u16 as i16);
-  info!("{}", 1u16 as i32);
-  info!("{}", 1u16 as i64);
-  info!("{}", 1u16 as u8);
-  info!("{}", 1u16 as u16);
-  info!("{}", 1u16 as u32);
-  info!("{}", 1u16 as u64);
-  info!("{}", 1u16 as f32);
-  info!("{}", 1u16 as f64);
-
-  info!("{}", 1i32 as int);
-  info!("{}", 1i32 as uint);
-  info!("{}", 1i32 as *libc::FILE);
-  info!("{}", 1i32 as i8);
-  info!("{}", 1i32 as i16);
-  info!("{}", 1i32 as i32);
-  info!("{}", 1i32 as i64);
-  info!("{}", 1i32 as u8);
-  info!("{}", 1i32 as u16);
-  info!("{}", 1i32 as u32);
-  info!("{}", 1i32 as u64);
-  info!("{}", 1i32 as f32);
-  info!("{}", 1i32 as f64);
-
-  info!("{}", 1u32 as int);
-  info!("{}", 1u32 as uint);
-  info!("{}", 1u32 as *libc::FILE);
-  info!("{}", 1u32 as i8);
-  info!("{}", 1u32 as i16);
-  info!("{}", 1u32 as i32);
-  info!("{}", 1u32 as i64);
-  info!("{}", 1u32 as u8);
-  info!("{}", 1u32 as u16);
-  info!("{}", 1u32 as u32);
-  info!("{}", 1u32 as u64);
-  info!("{}", 1u32 as f32);
-  info!("{}", 1u32 as f64);
-
-  info!("{}", 1i64 as int);
-  info!("{}", 1i64 as uint);
-  info!("{}", 1i64 as *libc::FILE);
-  info!("{}", 1i64 as i8);
-  info!("{}", 1i64 as i16);
-  info!("{}", 1i64 as i32);
-  info!("{}", 1i64 as i64);
-  info!("{}", 1i64 as u8);
-  info!("{}", 1i64 as u16);
-  info!("{}", 1i64 as u32);
-  info!("{}", 1i64 as u64);
-  info!("{}", 1i64 as f32);
-  info!("{}", 1i64 as f64);
-
-  info!("{}", 1u64 as int);
-  info!("{}", 1u64 as uint);
-  info!("{}", 1u64 as *libc::FILE);
-  info!("{}", 1u64 as i8);
-  info!("{}", 1u64 as i16);
-  info!("{}", 1u64 as i32);
-  info!("{}", 1u64 as i64);
-  info!("{}", 1u64 as u8);
-  info!("{}", 1u64 as u16);
-  info!("{}", 1u64 as u32);
-  info!("{}", 1u64 as u64);
-  info!("{}", 1u64 as f32);
-  info!("{}", 1u64 as f64);
-
-  info!("{}", 1u64 as int);
-  info!("{}", 1u64 as uint);
-  info!("{}", 1u64 as *libc::FILE);
-  info!("{}", 1u64 as i8);
-  info!("{}", 1u64 as i16);
-  info!("{}", 1u64 as i32);
-  info!("{}", 1u64 as i64);
-  info!("{}", 1u64 as u8);
-  info!("{}", 1u64 as u16);
-  info!("{}", 1u64 as u32);
-  info!("{}", 1u64 as u64);
-  info!("{}", 1u64 as f32);
-  info!("{}", 1u64 as f64);
-
-  info!("{}", true as int);
-  info!("{}", true as uint);
-  info!("{}", true as *libc::FILE);
-  info!("{}", true as i8);
-  info!("{}", true as i16);
-  info!("{}", true as i32);
-  info!("{}", true as i64);
-  info!("{}", true as u8);
-  info!("{}", true as u16);
-  info!("{}", true as u32);
-  info!("{}", true as u64);
-  info!("{}", true as f32);
-  info!("{}", true as f64);
-
-  info!("{}", 1. as int);
-  info!("{}", 1. as uint);
-  info!("{}", 1. as i8);
-  info!("{}", 1. as i16);
-  info!("{}", 1. as i32);
-  info!("{}", 1. as i64);
-  info!("{}", 1. as u8);
-  info!("{}", 1. as u16);
-  info!("{}", 1. as u32);
-  info!("{}", 1. as u64);
-  info!("{}", 1. as f32);
-  info!("{}", 1. as f64);
-
-  info!("{}", 1f32 as int);
-  info!("{}", 1f32 as uint);
-  info!("{}", 1f32 as i8);
-  info!("{}", 1f32 as i16);
-  info!("{}", 1f32 as i32);
-  info!("{}", 1f32 as i64);
-  info!("{}", 1f32 as u8);
-  info!("{}", 1f32 as u16);
-  info!("{}", 1f32 as u32);
-  info!("{}", 1f32 as u64);
-  info!("{}", 1f32 as f32);
-  info!("{}", 1f32 as f64);
-
-  info!("{}", 1f64 as int);
-  info!("{}", 1f64 as uint);
-  info!("{}", 1f64 as i8);
-  info!("{}", 1f64 as i16);
-  info!("{}", 1f64 as i32);
-  info!("{}", 1f64 as i64);
-  info!("{}", 1f64 as u8);
-  info!("{}", 1f64 as u16);
-  info!("{}", 1f64 as u32);
-  info!("{}", 1f64 as u64);
-  info!("{}", 1f64 as f32);
-  info!("{}", 1f64 as f64);
+  println!("{}", f as int);
+  println!("{}", f as uint);
+  println!("{}", f as i8);
+  println!("{}", f as i16);
+  println!("{}", f as i32);
+  println!("{}", f as i64);
+  println!("{}", f as u8);
+  println!("{}", f as u16);
+  println!("{}", f as u32);
+  println!("{}", f as u64);
+
+  println!("{}", 1 as int);
+  println!("{}", 1 as uint);
+  println!("{}", 1 as *libc::FILE);
+  println!("{}", 1 as i8);
+  println!("{}", 1 as i16);
+  println!("{}", 1 as i32);
+  println!("{}", 1 as i64);
+  println!("{}", 1 as u8);
+  println!("{}", 1 as u16);
+  println!("{}", 1 as u32);
+  println!("{}", 1 as u64);
+  println!("{}", 1 as f32);
+  println!("{}", 1 as f64);
+
+  println!("{}", 1u as int);
+  println!("{}", 1u as uint);
+  println!("{}", 1u as *libc::FILE);
+  println!("{}", 1u as i8);
+  println!("{}", 1u as i16);
+  println!("{}", 1u as i32);
+  println!("{}", 1u as i64);
+  println!("{}", 1u as u8);
+  println!("{}", 1u as u16);
+  println!("{}", 1u as u32);
+  println!("{}", 1u as u64);
+  println!("{}", 1u as f32);
+  println!("{}", 1u as f64);
+
+  println!("{}", 1i8 as int);
+  println!("{}", 1i8 as uint);
+  println!("{}", 1i8 as *libc::FILE);
+  println!("{}", 1i8 as i8);
+  println!("{}", 1i8 as i16);
+  println!("{}", 1i8 as i32);
+  println!("{}", 1i8 as i64);
+  println!("{}", 1i8 as u8);
+  println!("{}", 1i8 as u16);
+  println!("{}", 1i8 as u32);
+  println!("{}", 1i8 as u64);
+  println!("{}", 1i8 as f32);
+  println!("{}", 1i8 as f64);
+
+  println!("{}", 1u8 as int);
+  println!("{}", 1u8 as uint);
+  println!("{}", 1u8 as *libc::FILE);
+  println!("{}", 1u8 as i8);
+  println!("{}", 1u8 as i16);
+  println!("{}", 1u8 as i32);
+  println!("{}", 1u8 as i64);
+  println!("{}", 1u8 as u8);
+  println!("{}", 1u8 as u16);
+  println!("{}", 1u8 as u32);
+  println!("{}", 1u8 as u64);
+  println!("{}", 1u8 as f32);
+  println!("{}", 1u8 as f64);
+
+  println!("{}", 1i16 as int);
+  println!("{}", 1i16 as uint);
+  println!("{}", 1i16 as *libc::FILE);
+  println!("{}", 1i16 as i8);
+  println!("{}", 1i16 as i16);
+  println!("{}", 1i16 as i32);
+  println!("{}", 1i16 as i64);
+  println!("{}", 1i16 as u8);
+  println!("{}", 1i16 as u16);
+  println!("{}", 1i16 as u32);
+  println!("{}", 1i16 as u64);
+  println!("{}", 1i16 as f32);
+  println!("{}", 1i16 as f64);
+
+  println!("{}", 1u16 as int);
+  println!("{}", 1u16 as uint);
+  println!("{}", 1u16 as *libc::FILE);
+  println!("{}", 1u16 as i8);
+  println!("{}", 1u16 as i16);
+  println!("{}", 1u16 as i32);
+  println!("{}", 1u16 as i64);
+  println!("{}", 1u16 as u8);
+  println!("{}", 1u16 as u16);
+  println!("{}", 1u16 as u32);
+  println!("{}", 1u16 as u64);
+  println!("{}", 1u16 as f32);
+  println!("{}", 1u16 as f64);
+
+  println!("{}", 1i32 as int);
+  println!("{}", 1i32 as uint);
+  println!("{}", 1i32 as *libc::FILE);
+  println!("{}", 1i32 as i8);
+  println!("{}", 1i32 as i16);
+  println!("{}", 1i32 as i32);
+  println!("{}", 1i32 as i64);
+  println!("{}", 1i32 as u8);
+  println!("{}", 1i32 as u16);
+  println!("{}", 1i32 as u32);
+  println!("{}", 1i32 as u64);
+  println!("{}", 1i32 as f32);
+  println!("{}", 1i32 as f64);
+
+  println!("{}", 1u32 as int);
+  println!("{}", 1u32 as uint);
+  println!("{}", 1u32 as *libc::FILE);
+  println!("{}", 1u32 as i8);
+  println!("{}", 1u32 as i16);
+  println!("{}", 1u32 as i32);
+  println!("{}", 1u32 as i64);
+  println!("{}", 1u32 as u8);
+  println!("{}", 1u32 as u16);
+  println!("{}", 1u32 as u32);
+  println!("{}", 1u32 as u64);
+  println!("{}", 1u32 as f32);
+  println!("{}", 1u32 as f64);
+
+  println!("{}", 1i64 as int);
+  println!("{}", 1i64 as uint);
+  println!("{}", 1i64 as *libc::FILE);
+  println!("{}", 1i64 as i8);
+  println!("{}", 1i64 as i16);
+  println!("{}", 1i64 as i32);
+  println!("{}", 1i64 as i64);
+  println!("{}", 1i64 as u8);
+  println!("{}", 1i64 as u16);
+  println!("{}", 1i64 as u32);
+  println!("{}", 1i64 as u64);
+  println!("{}", 1i64 as f32);
+  println!("{}", 1i64 as f64);
+
+  println!("{}", 1u64 as int);
+  println!("{}", 1u64 as uint);
+  println!("{}", 1u64 as *libc::FILE);
+  println!("{}", 1u64 as i8);
+  println!("{}", 1u64 as i16);
+  println!("{}", 1u64 as i32);
+  println!("{}", 1u64 as i64);
+  println!("{}", 1u64 as u8);
+  println!("{}", 1u64 as u16);
+  println!("{}", 1u64 as u32);
+  println!("{}", 1u64 as u64);
+  println!("{}", 1u64 as f32);
+  println!("{}", 1u64 as f64);
+
+  println!("{}", 1u64 as int);
+  println!("{}", 1u64 as uint);
+  println!("{}", 1u64 as *libc::FILE);
+  println!("{}", 1u64 as i8);
+  println!("{}", 1u64 as i16);
+  println!("{}", 1u64 as i32);
+  println!("{}", 1u64 as i64);
+  println!("{}", 1u64 as u8);
+  println!("{}", 1u64 as u16);
+  println!("{}", 1u64 as u32);
+  println!("{}", 1u64 as u64);
+  println!("{}", 1u64 as f32);
+  println!("{}", 1u64 as f64);
+
+  println!("{}", true as int);
+  println!("{}", true as uint);
+  println!("{}", true as *libc::FILE);
+  println!("{}", true as i8);
+  println!("{}", true as i16);
+  println!("{}", true as i32);
+  println!("{}", true as i64);
+  println!("{}", true as u8);
+  println!("{}", true as u16);
+  println!("{}", true as u32);
+  println!("{}", true as u64);
+  println!("{}", true as f32);
+  println!("{}", true as f64);
+
+  println!("{}", 1. as int);
+  println!("{}", 1. as uint);
+  println!("{}", 1. as i8);
+  println!("{}", 1. as i16);
+  println!("{}", 1. as i32);
+  println!("{}", 1. as i64);
+  println!("{}", 1. as u8);
+  println!("{}", 1. as u16);
+  println!("{}", 1. as u32);
+  println!("{}", 1. as u64);
+  println!("{}", 1. as f32);
+  println!("{}", 1. as f64);
+
+  println!("{}", 1f32 as int);
+  println!("{}", 1f32 as uint);
+  println!("{}", 1f32 as i8);
+  println!("{}", 1f32 as i16);
+  println!("{}", 1f32 as i32);
+  println!("{}", 1f32 as i64);
+  println!("{}", 1f32 as u8);
+  println!("{}", 1f32 as u16);
+  println!("{}", 1f32 as u32);
+  println!("{}", 1f32 as u64);
+  println!("{}", 1f32 as f32);
+  println!("{}", 1f32 as f64);
+
+  println!("{}", 1f64 as int);
+  println!("{}", 1f64 as uint);
+  println!("{}", 1f64 as i8);
+  println!("{}", 1f64 as i16);
+  println!("{}", 1f64 as i32);
+  println!("{}", 1f64 as i64);
+  println!("{}", 1f64 as u8);
+  println!("{}", 1f64 as u16);
+  println!("{}", 1f64 as u32);
+  println!("{}", 1f64 as u64);
+  println!("{}", 1f64 as f32);
+  println!("{}", 1f64 as f64);
 }
index 78cc48e4ed4b34db544f9031f5ff8bcc1071365f..781a50b87a7dda03dedd7f3535476b2c068a32b5 100644 (file)
@@ -22,6 +22,6 @@ struct t_rec {
 pub fn main() {
     let x = t_rec {c8: 22u8, t: a_tag(44u64)};
     let y = format!("{:?}", x);
-    info!("y = {}", y);
+    println!("y = {}", y);
     assert_eq!(y, ~"t_rec{c8: 22u8, t: a_tag(44u64)}");
 }
index 05b3f98ea08cd27244c325a18ea4dc3f8abcae82..5cf6c2af12b85322f81a81bc7291c76a7389ad4e 100644 (file)
 pub fn main() { let k = checktrue; evenk(42, k); oddk(45, k); }
 
 fn evenk(n: int, k: fn(bool) -> bool) -> bool {
-    info!("evenk");
-    info!("{:?}", n);
+    println!("evenk");
+    println!("{:?}", n);
     if n == 0 { return k(true); } else { return oddk(n - 1, k); }
 }
 
 fn oddk(n: int, k: fn(bool) -> bool) -> bool {
-    info!("oddk");
-    info!("{:?}", n);
+    println!("oddk");
+    println!("{:?}", n);
     if n == 0 { return k(false); } else { return evenk(n - 1, k); }
 }
index 9e5c6ba8e970b3883d2adc84410ae96e60976147..55235974e130734ae2be5c7fc48b881593e61ab9 100644 (file)
 
 // ignore-fast
 
-extern crate extra;
-
 use std::task;
 
 pub fn main() { test05(); }
 
 fn test05_start(tx : &Sender<int>) {
     tx.send(10);
-    error!("sent 10");
+    println!("sent 10");
     tx.send(20);
-    error!("sent 20");
+    println!("sent 20");
     tx.send(30);
-    error!("sent 30");
+    println!("sent 30");
 }
 
 fn test05() {
     let (tx, rx) = channel();
     task::spawn(proc() { test05_start(&tx) });
     let mut value: int = rx.recv();
-    error!("{}", value);
+    println!("{}", value);
     value = rx.recv();
-    error!("{}", value);
+    println!("{}", value);
     value = rx.recv();
-    error!("{}", value);
+    println!("{}", value);
     assert_eq!(value, 30);
 }
index 830aecfa86cc98a4dbd73cb9abd0d45b7d0baf6d..8eaa7f2e31d95a0f3d5f2b8ac45af4c83ced6d94 100644 (file)
@@ -12,9 +12,9 @@
 
 pub fn main() { test00(); }
 
-fn start() { info!("Started / Finished task."); }
+fn start() { println!("Started / Finished task."); }
 
 fn test00() {
     task::try(proc() start() );
-    info!("Completing.");
+    println!("Completing.");
 }
index 5ea21422cd027819db6c04b3a092bb0a7d89a9bd..6299cfdee202c51887d0de1989054a8194721f20 100644 (file)
@@ -10,8 +10,6 @@
 
 // ignore-fast
 
-extern crate extra;
-
 use std::task;
 
 fn start(tx: &Sender<Sender<~str>>) {
@@ -22,10 +20,10 @@ fn start(tx: &Sender<Sender<~str>>) {
     let mut b;
     a = rx.recv();
     assert!(a == ~"A");
-    error!("{:?}", a);
+    println!("{:?}", a);
     b = rx.recv();
     assert!(b == ~"B");
-    error!("{:?}", b);
+    println!("{:?}", b);
 }
 
 pub fn main() {
index d39d688a478c16e882413fb256f93c50b53cbaf2..254988c8b0ed46d696d32147475c937f02a21d4d 100644 (file)
@@ -10,8 +10,6 @@
 
 // ignore-fast
 
-extern crate extra;
-
 use std::task;
 
 fn start(tx: &Sender<Sender<int>>) {
index 8092fb6d4ad2d271c22d1351457ac43a5e4491a4..275c99f99a95d8725b196f204c7c79e9ce59efc5 100644 (file)
@@ -8,13 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 use std::task;
 
 pub fn main() { test00(); }
 
-fn start(_task_number: int) { info!("Started / Finished task."); }
+fn start(_task_number: int) { println!("Started / Finished task."); }
 
 fn test00() {
     let i: int = 0;
@@ -34,5 +32,5 @@ fn test00() {
     // Try joining tasks that have already finished.
     result.recv();
 
-    info!("Joined task.");
+    println!("Joined task.");
 }
index bad03e8792efe34b4e9adbbbf6aa459829747b7d..6d06578c6cd1d225235560aa7f6b2f5650089ef8 100644 (file)
@@ -10,8 +10,6 @@
 
 // ignore-fast
 
-extern crate extra;
-
 use std::task;
 
 fn start(tx: &Sender<int>, start: int, number_of_messages: int) {
@@ -20,8 +18,8 @@ fn start(tx: &Sender<int>, start: int, number_of_messages: int) {
 }
 
 pub fn main() {
-    info!("Check that we don't deadlock.");
+    println!("Check that we don't deadlock.");
     let (tx, rx) = channel();
     task::try(proc() { start(&tx, 0, 10) });
-    info!("Joined task");
+    println!("Joined task");
 }
index 799ee6093008bed925e8e3751f1f71c3752cf1d0..9559e5c84afbb50bfaed73f525678b66e6a2786e 100644 (file)
@@ -18,7 +18,7 @@ pub fn main() {
     // Spawn 10 tasks each sending us back one int.
     let mut i = 10;
     while (i > 0) {
-        info!("{}", i);
+        println!("{}", i);
         let tx = tx.clone();
         task::spawn({let i = i; proc() { child(i, &tx) }});
         i = i - 1;
@@ -29,15 +29,15 @@ pub fn main() {
 
     i = 10;
     while (i > 0) {
-        info!("{}", i);
+        println!("{}", i);
         rx.recv();
         i = i - 1;
     }
 
-    info!("main thread exiting");
+    println!("main thread exiting");
 }
 
 fn child(x: int, tx: &Sender<int>) {
-    info!("{}", x);
+    println!("{}", x);
     tx.send(x);
 }
index 6855a32ceb02c5d62a88d5a73ad119ad48ba87d7..355f179ad17947c43a8ce4900b085a4ba095a2a6 100644 (file)
@@ -10,8 +10,6 @@
 
 // ignore-fast
 
-extern crate extra;
-
 use std::task;
 
 fn start(tx: &Sender<int>, i0: int) {
index 70a59c5b85dc46564599babc825337c1abc125a5..4f4d365901e7903cd48969cf48cb42473bcfb0c3 100644 (file)
@@ -12,8 +12,6 @@
 
 // This test is specifically about spawning temporary closures.
 
-extern crate extra;
-
 use std::task;
 
 fn f() {
index c27e199b3778901b73fe3cf41357ec9597b40fce..176b64e41d00fcf2874e9f51c31b1f30cd90de2d 100644 (file)
 
 // ignore-fast
 
-extern crate extra;
-
 use std::task;
 
-pub fn main() { info!("===== WITHOUT THREADS ====="); test00(); }
+pub fn main() { println!("===== WITHOUT THREADS ====="); test00(); }
 
 fn test00_start(ch: &Sender<int>, message: int, count: int) {
-    info!("Starting test00_start");
+    println!("Starting test00_start");
     let mut i: int = 0;
     while i < count {
-        info!("Sending Message");
+        println!("Sending Message");
         ch.send(message + 0);
         i = i + 1;
     }
-    info!("Ending test00_start");
+    println!("Ending test00_start");
 }
 
 fn test00() {
     let number_of_tasks: int = 16;
     let number_of_messages: int = 4;
 
-    info!("Creating tasks");
+    println!("Creating tasks");
 
     let (tx, rx) = channel();
 
@@ -66,8 +64,8 @@ fn test00() {
     // Join spawned tasks...
     for r in results.iter() { r.recv(); }
 
-    info!("Completed: Final number is: ");
-    error!("{:?}", sum);
+    println!("Completed: Final number is: ");
+    println!("{:?}", sum);
     // assert (sum == (((number_of_tasks * (number_of_tasks - 1)) / 2) *
     //       number_of_messages));
     assert_eq!(sum, 480);
index 411730dac7859fae7f9ca3fe3d3752486b448157..6418921172a36ad56563eff20cb3b02af4c225d8 100644 (file)
@@ -22,31 +22,31 @@ fn test00() {
     tx.send(4);
     r = rx.recv();
     sum += r;
-    info!("{}", r);
+    println!("{}", r);
     r = rx.recv();
     sum += r;
-    info!("{}", r);
+    println!("{}", r);
     r = rx.recv();
     sum += r;
-    info!("{}", r);
+    println!("{}", r);
     r = rx.recv();
     sum += r;
-    info!("{}", r);
+    println!("{}", r);
     tx.send(5);
     tx.send(6);
     tx.send(7);
     tx.send(8);
     r = rx.recv();
     sum += r;
-    info!("{}", r);
+    println!("{}", r);
     r = rx.recv();
     sum += r;
-    info!("{}", r);
+    println!("{}", r);
     r = rx.recv();
     sum += r;
-    info!("{}", r);
+    println!("{}", r);
     r = rx.recv();
     sum += r;
-    info!("{}", r);
+    println!("{}", r);
     assert_eq!(sum, 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8);
 }
index 64970bcd3feae0d964705a4cc1e6e90d2daf21c7..e51e14f7fbe82eabefb6eacfa13dfd1296604246 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 pub fn main() { test00(); }
 
 fn test00() {
index f61547ff688bae493ccd02071fe19046a4a817f2..5d918a4c88fb1b6e8823679138135bafab525db1 100644 (file)
@@ -12,8 +12,6 @@
 
 #[allow(dead_assignment)];
 
-extern crate extra;
-
 use std::task;
 
 pub fn main() { test00(); }
index f4fee47fa744de0180a3149ca815e9d04803797d..a4e6be4f2d528222f661d80e69db1fd6faf8d313 100644 (file)
@@ -10,8 +10,6 @@
 
 // ignore-fast
 
-extern crate extra;
-
 use std::task;
 
 pub fn main() { test00(); }
@@ -36,7 +34,7 @@ fn test00() {
     let mut i: int = 0;
     while i < number_of_messages {
         sum += rx.recv();
-        info!("{:?}", r);
+        println!("{:?}", r);
         i += 1;
     }
 
index 713105df602c8c80623458b7454e6729bb39f1ac..3ea17898eada213886d38449085f3e9e7aa0602d 100644 (file)
@@ -8,9 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
-extern crate extra;
-
 // rustboot can't transmit nils across channels because they don't have
 // any size, but rustc currently can because they do have size. Whether
 // or not this is desirable I don't know, but here's a regression test.
index 54aac31c7dee58ef0f6c3f0a398fe791458fc69b..dfcebbaaee058a43f9b2300907960bc25c9dd185 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 use std::task;
 
 pub fn main() {
index d1fc90cf007f0fb0c7705571b5d61444df52f378..61478e3fdb49ade8f49218c9b33a9a858510088c 100644 (file)
 // ignore-android needs extra network permissions
 // exec-env:RUST_LOG=debug
 
+#[feature(phase)];
+#[phase(syntax, link)]
+extern crate log;
+
 use std::libc;
 use std::io::net::ip::{Ipv4Addr, SocketAddr};
 use std::io::net::tcp::{TcpListener, TcpStream};
@@ -28,10 +32,10 @@ fn main() {
     });
 
     let addr = SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 0 };
-    let (p, c) = Chan::new();
+    let (tx, rx) = channel();
     spawn(proc() {
         let mut listener = TcpListener::bind(addr).unwrap();
-        c.send(listener.socket_name().unwrap());
+        tx.send(listener.socket_name().unwrap());
         let mut acceptor = listener.listen();
         loop {
             let mut stream = match acceptor.accept() {
@@ -45,11 +49,11 @@ fn main() {
             stream.write([2]);
         }
     });
-    let addr = p.recv();
+    let addr = rx.recv();
 
-    let (p, c) = Chan::new();
+    let (tx, rx) = channel();
     for _ in range(0, 1000) {
-        let c = c.clone();
+        let tx = tx.clone();
         spawn(proc() {
             match TcpStream::connect(addr) {
                 Ok(stream) => {
@@ -60,15 +64,15 @@ fn main() {
                 },
                 Err(e) => debug!("{:?}", e)
             }
-            c.send(());
+            tx.send(());
         });
     }
 
     // Wait for all clients to exit, but don't wait for the server to exit. The
     // server just runs infinitely.
-    drop(c);
+    drop(tx);
     for _ in range(0, 1000) {
-        p.recv();
+        rx.recv();
     }
     unsafe { libc::exit(0) }
 }
index 2f3bbbd744d4b2e524be71fac03cf8e4ca9148f6..873269190c527e26a6b715677a6e6fdf6c6f2a3b 100644 (file)
 // they're in a different location than before. Hence, these tests are all run
 // serially here.
 
-extern crate extra;
-
-use extra::tempfile::TempDir;
-use std::io::fs;
+use std::io::{fs, TempDir};
 use std::io;
 use std::os;
 use std::task;
@@ -83,7 +80,7 @@ fn test_rm_tempdir() {
 fn recursive_mkdir_rel() {
     let path = Path::new("frob");
     let cwd = os::getcwd();
-    debug!("recursive_mkdir_rel: Making: {} in cwd {} [{:?}]", path.display(),
+    println!("recursive_mkdir_rel: Making: {} in cwd {} [{:?}]", path.display(),
            cwd.display(), path.exists());
     fs::mkdir_recursive(&path, io::UserRWX);
     assert!(path.is_dir());
@@ -101,13 +98,13 @@ fn recursive_mkdir_dot() {
 fn recursive_mkdir_rel_2() {
     let path = Path::new("./frob/baz");
     let cwd = os::getcwd();
-    debug!("recursive_mkdir_rel_2: Making: {} in cwd {} [{:?}]", path.display(),
+    println!("recursive_mkdir_rel_2: Making: {} in cwd {} [{:?}]", path.display(),
            cwd.display(), path.exists());
     fs::mkdir_recursive(&path, io::UserRWX);
     assert!(path.is_dir());
     assert!(path.dir_path().is_dir());
     let path2 = Path::new("quux/blat");
-    debug!("recursive_mkdir_rel_2: Making: {} in cwd {}", path2.display(),
+    println!("recursive_mkdir_rel_2: Making: {} in cwd {}", path2.display(),
            cwd.display());
     fs::mkdir_recursive(&path2, io::UserRWX);
     assert!(path2.is_dir());
@@ -123,7 +120,7 @@ pub fn test_rmdir_recursive_ok() {
     let tmpdir = tmpdir.path();
     let root = tmpdir.join("foo");
 
-    debug!("making {}", root.display());
+    println!("making {}", root.display());
     fs::mkdir(&root, rwx);
     fs::mkdir(&root.join("foo"), rwx);
     fs::mkdir(&root.join("foo").join("bar"), rwx);
index b63573f6103bad3689d114ad5c96e39ad3f8e5cb..9f648b9a4739c5508a512d952426b93c33994177 100644 (file)
@@ -13,8 +13,6 @@
 // Issue #787
 // Don't try to clean up uninitialized locals
 
-extern crate extra;
-
 use std::task;
 
 fn test_break() { loop { let _x: @int = break; } }
index eee667fdb04110d2d1b5314c772d3af5cb172d6f..ba131569bc49294ccc2fd04dbe753599818d9a27 100644 (file)
@@ -11,8 +11,6 @@
 // compile-flags: --test --cfg ignorecfg
 // ignore-fast
 
-extern crate extra;
-
 #[test]
 #[ignore(cfg(ignorecfg))]
 fn shouldignore() {
index cdef159b3996d81a7764bee6385a290c940abb75..3781a60fcfe0678ea95ba694b13781d1ced1354a 100644 (file)
@@ -12,8 +12,6 @@
 // ignore-fast
 // ignore-win32 #10872
 
-extern crate extra;
-
 // Building as a test runner means that a synthetic main will be run,
 // not ours
 pub fn main() { fail!(); }
index 3e1d5b3684dc320147c4e9c7c535fb755a3c4840..dc862f201c244850214a508c7358a04072539238 100644 (file)
@@ -8,14 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 use std::task;
 
 pub fn main() {
     let mut i = 10;
     while i > 0 { task::spawn({let i = i; proc() child(i)}); i = i - 1; }
-    info!("main thread exiting");
+    println!("main thread exiting");
 }
 
-fn child(x: int) { info!("{}", x); }
+fn child(x: int) { println!("{}", x); }
index b7d5f9c6fd68de076c6a09ce8fbb73a3fbce9c4e..3c3198379be24605c20ff34be633c669926ad477 100644 (file)
@@ -10,8 +10,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 use std::cmp::{Eq, Ord};
 use std::num::NumCast;
 
index 5e6dc7c67c8e6bb76d5cc281411f4642fd08fde3..2bfe11d23a3c6edfcae14f419d408b6951e3d1c9 100644 (file)
@@ -12,8 +12,6 @@
 
 // A more complex example of numeric extensions
 
-extern crate extra;
-
 use std::cmp::{Eq, Ord};
 
 pub trait TypeExt {}
index a9e2979f7dbcc04be8ed8f46196894de6c5b6ecf..840ab18dafa3d9a690a72cc80534041c5e282547 100644 (file)
@@ -17,5 +17,5 @@ pub fn main() {
     let (tx, rx) = channel();
     tx.send(42);
     let r = rx.recv();
-    error!("{:?}", r);
+    println!("{:?}", r);
 }
diff --git a/src/test/run-pass/typeck_type_placeholder_1.rs b/src/test/run-pass/typeck_type_placeholder_1.rs
new file mode 100644 (file)
index 0000000..789a95d
--- /dev/null
@@ -0,0 +1,32 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// This test checks that the `_` type placeholder works
+// correctly for enabling type inference.
+
+static CONSTEXPR: *int = &'static 413 as *_;
+
+pub fn main() {
+    use std::vec_ng::Vec;
+
+    let x: Vec<_> = range(0u, 5).collect();
+    assert_eq!(x.as_slice(), &[0u,1,2,3,4]);
+
+    let x = range(0u, 5).collect::<Vec<_>>();
+    assert_eq!(x.as_slice(), &[0u,1,2,3,4]);
+
+    let y: _ = "hello";
+    assert_eq!(y.len(), 5);
+
+    let ptr = &5u;
+    let ptr2 = ptr as *_;
+
+    assert_eq!(ptr as *uint as uint, ptr2 as uint);
+}
index a0c2a489bf64a18be4fa844c27684581d25b9cfd..11d1b9ecbfe3a1e3c8b3abfd18a59f41cfc3a559 100644 (file)
@@ -63,5 +63,5 @@ pub fn main() {
     assert!(!Equal::isEq(branch(@leaf(magenta), @leaf(cyan)),
                  branch(@leaf(magenta), @leaf(magenta))));
 
-    error!("Assertions all succeeded!");
+    println!("Assertions all succeeded!");
 }
index 50af6cb71c1f44d53a9d68e3f72741bd7fefb77c..ed72a758c78b838cce1e8294abf5f883b1400180 100644 (file)
@@ -62,5 +62,5 @@ pub fn main() {
     assert!(!branch(@leaf(magenta), @leaf(cyan))
         .isEq(branch(@leaf(magenta), @leaf(magenta))));
 
-    error!("Assertions all succeeded!");
+    println!("Assertions all succeeded!");
 }
index 4898ef1cd0ae2160ad687dd4314c670b88324ce1..adbbf1aec9afc1204f15cf58d0c0c96b1fba8c6a 100644 (file)
 pub fn main() {
     let a = 1;
     let a_neg: i8 = -a;
-    error!("{}", a_neg);
+    println!("{}", a_neg);
 
     let b = 1;
     let b_neg: i16 = -b;
-    error!("{}", b_neg);
+    println!("{}", b_neg);
 
     let c = 1;
     let c_neg: i32 = -c;
-    error!("{}", c_neg);
+    println!("{}", c_neg);
 
     let d = 1;
     let d_neg: i64 = -d;
-    error!("{}", d_neg);
+    println!("{}", d_neg);
 
     let e = 1;
     let e_neg: int = -e;
-    error!("{}", e_neg);
+    println!("{}", e_neg);
 
     // intentional overflows
 
     let f = 1;
     let f_neg: u8 = -f;
-    error!("{}", f_neg);
+    println!("{}", f_neg);
 
     let g = 1;
     let g_neg: u16 = -g;
-    error!("{}", g_neg);
+    println!("{}", g_neg);
 
     let h = 1;
     let h_neg: u32 = -h;
-    error!("{}", h_neg);
+    println!("{}", h_neg);
 
     let i = 1;
     let i_neg: u64 = -i;
-    error!("{}", i_neg);
+    println!("{}", i_neg);
 
     let j = 1;
     let j_neg: uint = -j;
-    error!("{}", j_neg);
+    println!("{}", j_neg);
 }
index fc0d4ce4b897b10c5364c714bec62f4b998fd1ab..953140fcfef928a2af87dd9ab9e6adcbc5229912 100644 (file)
@@ -11,7 +11,6 @@
 // Tests that the tail expr in null() has its type
 // unified with the type *T, and so the type variable
 // in that type gets resolved.
-extern crate extra;
 
 use std::cast;
 
index 48a49996aeebb963123473f4d0c5f15b5c603867..7bb0fe5faa184b358cf9a17ca7a19e95942d71d2 100644 (file)
@@ -19,6 +19,6 @@ pub fn main() {
     let rc1 = managed::refcount(*i);
     let j = i.clone();
     let rc2 = managed::refcount(*i);
-    error!("rc1: {} rc2: {}", rc1, rc2);
+    println!("rc1: {} rc2: {}", rc1, rc2);
     assert_eq!(rc1 + 1u, rc2);
 }
index b1fc4e76ea084bafd22b6008130117b295aae9cc..c5d55ff0386ec40312cb1549c82c07954d36db36 100644 (file)
@@ -14,7 +14,7 @@ enum bar { u(~int), w(int), }
     let x = u(~10);
     assert!(match x {
       u(a) => {
-        error!("{:?}", a);
+        println!("{:?}", a);
         *a
       }
       _ => { 66 }
index 96d61b377af5c8047ea8cc4b141b40da615b1067..06f73777032d97905b027d48f6ada952c68ac9d8 100644 (file)
@@ -10,5 +10,5 @@
 
 pub fn main() {
     let i = ~100;
-    error!("{:?}", i);
+    println!("{:?}", i);
 }
index 077bbdfb0baa4b7127a2e12680df13a3a79621ac..7f11e7b7df5c8ee3a7f207cbb331d4cc29bcb7e3 100644 (file)
@@ -14,7 +14,7 @@ enum bar { u(~int), w(int), }
 pub fn main() {
     assert!(match u(~10) {
       u(a) => {
-        error!("{:?}", a);
+        println!("{:?}", a);
         *a
       }
       _ => { 66 }
index beaf76cafbcde717336ea3c8e93b454e93522257..53e92fc4abb5880bd37c8f671164c8d09d4b0a8c 100644 (file)
@@ -10,8 +10,6 @@
 
 #[feature(managed_boxes)];
 
-extern crate extra;
-
 use std::task;
 
 fn f() {
index 30bbca89905f053ec6a3413e01138a940e9bf408..2d05eb221967156ddbb5793cf8686984702b0136 100644 (file)
@@ -10,8 +10,6 @@
 
 // ignore-fast
 
-extern crate extra;
-
 use std::task;
 
 struct complainer {
@@ -20,14 +18,14 @@ struct complainer {
 
 impl Drop for complainer {
     fn drop(&mut self) {
-        error!("About to send!");
+        println!("About to send!");
         self.tx.send(true);
-        error!("Sent!");
+        println!("Sent!");
     }
 }
 
 fn complainer(tx: Sender<bool>) -> complainer {
-    error!("Hello!");
+    println!("Hello!");
     complainer {
         tx: tx
     }
@@ -41,6 +39,6 @@ fn f(tx: Sender<bool>) {
 pub fn main() {
     let (tx, rx) = channel();
     task::spawn(proc() f(tx.clone()));
-    error!("hiiiiiiiii");
+    println!("hiiiiiiiii");
     assert!(rx.recv());
 }
index 176eb02105f72115620d4407191a0fadb4933e6e..3331ee2181450f482c86178b4f8b2a4b8828d5e8 100644 (file)
@@ -10,8 +10,6 @@
 
 #[feature(managed_boxes)];
 
-extern crate extra;
-
 use std::task;
 
 struct complainer {
index dabe8c3450b8637324da1a9f20e00c6403ffae51..8bc95b233f1cda7738ffa9349cc0249142a55f90 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 use std::task;
 
 fn f() {
index 9c53dde21ddbbefcc254862a343731de868c1586..bf9c5838de8fd795c3dd9cd62248fd8314bf5fa1 100644 (file)
@@ -9,6 +9,6 @@
 // except according to those terms.
 
 // Issue #1706
-extern crate stdlib = "extra";
+extern crate stdlib = "std";
 
 pub fn main() {}
index 69e28e30d09202c6ad4f2ea1fc737ad98d537e71..a5659a4648e03ade8ab6594cc3dd167e023693ce 100644 (file)
@@ -21,4 +21,4 @@ fn foo<T>(o: myoption<T>) -> int {
 
 enum myoption<T> { none, some(T), }
 
-pub fn main() { info!("{}", 5); }
+pub fn main() { println!("{}", 5); }
index a85861d2aa5d4732752dafc52649365214b84cbd..9bf98baa303bc72d66c5b6bc5dd3ac0da3d0e579 100644 (file)
@@ -21,4 +21,4 @@ fn foo<T>(o: myoption<T>) -> int {
 
 enum myoption<T> { none, some(T), }
 
-pub fn main() { info!("{}", 5); }
+pub fn main() { println!("{}", 5); }
index 1520a8b7e611c577257e60a35ff55c4e7bdc4ae0..9531563fcbef2506ef041f2b06f56676ecd4b912 100644 (file)
@@ -42,10 +42,10 @@ pub fn main() {
     fn check_str_eq(a: ~str, b: ~str) {
         let mut i: int = 0;
         for ab in a.bytes() {
-            info!("{}", i);
-            info!("{}", ab);
+            println!("{}", i);
+            println!("{}", ab);
             let bb: u8 = b[i];
-            info!("{}", bb);
+            println!("{}", bb);
             assert_eq!(ab, bb);
             i += 1;
         }
index 34ee0933d2ad09e44cdfa05a6150ec35aacb4b7c..0e85c67edb7846a086ac2f21b41c4e4daa1afda2 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 use std::str;
 
 pub fn main() {
index 7014ad5df141d82d208a4aeab31613894866b957..9b42a25956ee90482e66a38623267f1ffd71424e 100644 (file)
@@ -12,7 +12,7 @@ pub fn main() {
     let a: ~[int] = ~[1, 2, 3, 4, 5];
     let b: ~[int] = ~[6, 7, 8, 9, 0];
     let v: ~[int] = a + b;
-    info!("{}", v[9]);
+    println!("{}", v[9]);
     assert_eq!(v[0], 1);
     assert_eq!(v[7], 8);
     assert_eq!(v[9], 0);
index 7ffbade05c1cce4f3b7d88d521642873ae0d535e..c15a7fcdf29da58db5852b204b28483c46f454d9 100644 (file)
@@ -13,5 +13,5 @@
 pub fn main() {
     let mut later: ~[int];
     if true { later = ~[1]; } else { later = ~[2]; }
-    info!("{}", later[0]);
+    println!("{}", later[0]);
 }
index e9fcfaaf2837fca86141828639fa901c4128086b..cd20917a17909e526e180d134e28213c88e5af9c 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern crate extra;
-
 fn test_heap_to_heap() {
     // a spills onto the heap
     let mut a = ~[0, 1, 2, 3, 4];
@@ -47,7 +45,7 @@ fn test_loop() {
     let mut i = 20;
     let mut expected_len = 1u;
     while i > 0 {
-        error!("{}", a.len());
+        println!("{}", a.len());
         assert_eq!(a.len(), expected_len);
         a = a + a; // FIXME(#3387)---can't write a += a
         i -= 1;
index 10726a9c396b39b8a5553e8e1eb779bee5fe7797..0e4f4194a549ddab0d5d99c6d81bc541af70c4f1 100644 (file)
@@ -66,7 +66,7 @@ fn canttouchthis() -> uint {
     fn p() -> bool { true }
     let _a = (assert!((true)) == (assert!(p())));
     let _c = (assert!((p())) == ());
-    let _b: bool = (info!("{}", 0) == (return 0u));
+    let _b: bool = (println!("{}", 0) == (return 0u));
 }
 
 fn angrydome() {
@@ -76,7 +76,7 @@ fn angrydome() {
       break; }
 }
 
-fn evil_lincoln() { let _evil = info!("lincoln"); }
+fn evil_lincoln() { let _evil = println!("lincoln"); }
 
 pub fn main() {
     strange();
index ed7ba12ea0f2fd1f2f9464a612ce4ed31d6bfad7..3e1a232115f7d286d391a51bb6b9b2a56daf0c0a 100644 (file)
@@ -13,7 +13,7 @@ pub fn main() {
     let mut i = 1;
     while i > 0 {
         assert!((i > 0));
-        info!("{}", i);
+        println!("{}", i);
         i -= 1;
         continue;
     }
index a21aa4a9a6246dbbc46ade93556e5092ea37dd2c..8ef98901e9f06af55e6ff8561e7fc439766713f9 100644 (file)
@@ -18,7 +18,7 @@ pub fn main() {
     while z < 50 {
         z += 1;
         while false { x = y; y = z; }
-        info!("{}", y);
+        println!("{}", y);
     }
     assert!((y == 42 && z == 50));
 }
index 57bc3bda9636aac2b0414207c4c8f3f59003e701..1f16b5fdb5c67055c81392458ab11805caeae88b 100644 (file)
 pub fn main() {
     let mut i: int = 90;
     while i < 100 {
-        info!("{}", i);
+        println!("{}", i);
         i = i + 1;
         if i == 95 {
             let _v: ~[int] =
                 ~[1, 2, 3, 4, 5]; // we check that it is freed by break
 
-            info!("breaking");
+            println!("breaking");
             break;
         }
     }
index fe2506ad686ab89549ef7d9bae5b977b013d0e3d..bd8b1f0f088ab231465e0132d08171fc7b917993 100644 (file)
 pub fn main() {
     let mut x: int = 10;
     let mut y: int = 0;
-    while y < x { info!("{}", y); info!("hello"); y = y + 1; }
+    while y < x { println!("{}", y); println!("hello"); y = y + 1; }
     while x > 0 {
-        info!("goodbye");
+        println!("goodbye");
         x = x - 1;
-        info!("{}", x);
+        println!("{}", x);
     }
 }
index 01370ed12b4433d272ef772e49e0a8a11c9f9709..b2cf771faee3cea213c4a42b91f25531a90118e4 100644 (file)
@@ -25,7 +25,7 @@ pub fn main() {
         let expected = 1234u;
         kernel32::SetLastError(expected);
         let actual = kernel32::GetLastError();
-        info!("actual = {}", actual);
+        println!("actual = {}", actual);
         assert_eq!(expected, actual);
     }
 }
index 4ec30d6e02a0bbde441183e5c2bf64e915abcc30..bd44bdd51cd85bfe3513b5ec0a7ce4761270f42c 100644 (file)
@@ -14,14 +14,14 @@ pub fn main() {
     let mut builder = task::task();
     let mut result = builder.future_result();
     builder.spawn(child);
-    error!("1");
+    println!("1");
     task::deschedule();
-    error!("2");
+    println!("2");
     task::deschedule();
-    error!("3");
+    println!("3");
     result.recv();
 }
 
 fn child() {
-    error!("4"); task::deschedule(); error!("5"); task::deschedule(); error!("6");
+    println!("4"); task::deschedule(); println!("5"); task::deschedule(); println!("6");
 }
index c08c62b47a2258558961eebc0a86b921a7bca6ed..14ba368bdfad6231438d420a35f9a4cb3541565c 100644 (file)
@@ -14,9 +14,9 @@ pub fn main() {
     let mut builder = task::task();
     let mut result = builder.future_result();
     builder.spawn(child);
-    error!("1");
+    println!("1");
     task::deschedule();
     result.recv();
 }
 
-fn child() { error!("2"); }
+fn child() { println!("2"); }
index 7bc3c1fc1f4dc6486286bfd7c9196cf2eeb4c5ff..c6cb0dd65e7726582dc5799b19469c2b118fe78a 100644 (file)
@@ -12,5 +12,5 @@
 
 pub fn main() {
     let mut i: int = 0;
-    while i < 100 { i = i + 1; error!("{}", i); task::deschedule(); }
+    while i < 100 { i = i + 1; println!("{}", i); task::deschedule(); }
 }