]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #15247 : smenardpw/rust/patch-1, r=alexcrichton
authorbors <bors@rust-lang.org>
Mon, 30 Jun 2014 23:06:35 +0000 (23:06 +0000)
committerbors <bors@rust-lang.org>
Mon, 30 Jun 2014 23:06:35 +0000 (23:06 +0000)
./hello_world is not recognized on Windows.
We can type either hello_world or hello_world.exe to run the executable. I chose "hello_world.exe", which seems more conventional on Windows.

447 files changed:
README.md
man/rustdoc.1
mk/dist.mk
mk/docs.mk
mk/tests.mk
src/doc/guide-unsafe.md
src/doc/guide.md
src/doc/intro.md
src/doc/rust.md
src/doc/rustdoc.md
src/doc/tutorial.md
src/liballoc/arc.rs
src/liballoc/heap.rs
src/liballoc/owned.rs
src/liballoc/rc.rs
src/libcollections/btree.rs
src/libcollections/dlist.rs
src/libcollections/hash/mod.rs
src/libcollections/hash/sip.rs
src/libcollections/ringbuf.rs
src/libcollections/slice.rs
src/libcollections/str.rs
src/libcollections/treemap.rs
src/libcollections/vec.rs
src/libcore/any.rs
src/libcore/atomics.rs
src/libcore/cell.rs
src/libcore/char.rs
src/libcore/clone.rs
src/libcore/cmp.rs
src/libcore/failure.rs
src/libcore/finally.rs
src/libcore/fmt/mod.rs
src/libcore/fmt/num.rs
src/libcore/intrinsics.rs
src/libcore/iter.rs
src/libcore/lib.rs
src/libcore/macros.rs
src/libcore/mem.rs
src/libcore/num/int_macros.rs
src/libcore/num/mod.rs
src/libcore/num/uint_macros.rs
src/libcore/ops.rs
src/libcore/option.rs
src/libcore/ptr.rs
src/libcore/raw.rs
src/libcore/result.rs
src/libcore/slice.rs
src/libcore/str.rs
src/libcore/tuple.rs
src/libcoretest/any.rs [new file with mode: 0644]
src/libcoretest/atomics.rs [new file with mode: 0644]
src/libcoretest/cell.rs [new file with mode: 0644]
src/libcoretest/char.rs [new file with mode: 0644]
src/libcoretest/clone.rs [new file with mode: 0644]
src/libcoretest/cmp.rs [new file with mode: 0644]
src/libcoretest/finally.rs [new file with mode: 0644]
src/libcoretest/fmt/mod.rs [new file with mode: 0644]
src/libcoretest/fmt/num.rs [new file with mode: 0644]
src/libcoretest/iter.rs [new file with mode: 0644]
src/libcoretest/lib.rs [new file with mode: 0644]
src/libcoretest/mem.rs [new file with mode: 0644]
src/libcoretest/num/i16.rs [new file with mode: 0644]
src/libcoretest/num/i32.rs [new file with mode: 0644]
src/libcoretest/num/i64.rs [new file with mode: 0644]
src/libcoretest/num/i8.rs [new file with mode: 0644]
src/libcoretest/num/int.rs [new file with mode: 0644]
src/libcoretest/num/int_macros.rs [new file with mode: 0644]
src/libcoretest/num/mod.rs [new file with mode: 0644]
src/libcoretest/num/u16.rs [new file with mode: 0644]
src/libcoretest/num/u32.rs [new file with mode: 0644]
src/libcoretest/num/u64.rs [new file with mode: 0644]
src/libcoretest/num/u8.rs [new file with mode: 0644]
src/libcoretest/num/uint.rs [new file with mode: 0644]
src/libcoretest/num/uint_macros.rs [new file with mode: 0644]
src/libcoretest/ops.rs [new file with mode: 0644]
src/libcoretest/option.rs [new file with mode: 0644]
src/libcoretest/ptr.rs [new file with mode: 0644]
src/libcoretest/raw.rs [new file with mode: 0644]
src/libcoretest/result.rs [new file with mode: 0644]
src/libcoretest/tuple.rs [new file with mode: 0644]
src/libdebug/repr.rs
src/libgraphviz/maybe_owned_vec.rs
src/libgreen/sched.rs
src/libhexfloat/lib.rs
src/libnative/io/addrinfo.rs
src/libnative/io/c_win32.rs
src/libnative/io/file_unix.rs
src/libnative/io/file_win32.rs
src/libnative/io/pipe_unix.rs
src/libnative/io/process.rs
src/libnum/bigint.rs
src/libnum/rational.rs
src/librand/isaac.rs
src/librand/lib.rs
src/librand/rand_impls.rs
src/libregex/parse/mod.rs
src/librustc/back/link.rs
src/librustc/back/lto.rs
src/librustc/lint/builtin.rs
src/librustc/middle/save/span_utils.rs
src/librustc/middle/trans/debuginfo.rs
src/librustc/middle/trans/foreign.rs
src/librustc/middle/typeck/check/_match.rs
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/infer/mod.rs
src/librustc/middle/typeck/infer/resolve.rs
src/librustdoc/externalfiles.rs [new file with mode: 0644]
src/librustdoc/flock.rs
src/librustdoc/html/format.rs
src/librustdoc/html/layout.rs
src/librustdoc/html/markdown.rs
src/librustdoc/html/render.rs
src/librustdoc/lib.rs
src/librustdoc/markdown.rs
src/librustrt/c_str.rs
src/librustrt/local_heap.rs
src/librustrt/local_ptr.rs
src/librustrt/task.rs
src/librustrt/thread_local_storage.rs
src/librustuv/addrinfo.rs
src/librustuv/file.rs
src/librustuv/net.rs
src/librustuv/pipe.rs
src/librustuv/process.rs
src/librustuv/queue.rs
src/librustuv/stream.rs
src/librustuv/tty.rs
src/libsemver/lib.rs
src/libserialize/base64.rs
src/libserialize/hex.rs
src/libserialize/json.rs
src/libstd/dynamic_lib.rs
src/libstd/gc.rs
src/libstd/io/fs.rs
src/libstd/io/net/tcp.rs
src/libstd/os.rs
src/libstd/path/mod.rs
src/libstd/rand/mod.rs
src/libstd/task.rs
src/libsync/atomics.rs
src/libsync/comm/duplex.rs
src/libsync/comm/mod.rs
src/libsync/deque.rs
src/libsync/lock.rs
src/libsync/mpsc_queue.rs
src/libsync/spsc_queue.rs
src/libsyntax/ext/deriving/cmp/ord.rs
src/libsyntax/print/pprust.rs
src/libsyntax/util/small_vector.rs
src/libtest/lib.rs
src/liburl/lib.rs
src/test/auxiliary/issue-8044.rs
src/test/auxiliary/issue-9906.rs
src/test/compile-fail/borrowck-anon-fields-tuple.rs
src/test/compile-fail/borrowck-array-double-move.rs
src/test/compile-fail/borrowck-break-uninit-2.rs
src/test/compile-fail/borrowck-closures-mut-and-imm.rs
src/test/compile-fail/borrowck-closures-two-mut.rs
src/test/compile-fail/borrowck-if-no-else.rs
src/test/compile-fail/borrowck-if-with-else.rs
src/test/compile-fail/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs
src/test/compile-fail/borrowck-issue-2657-1.rs
src/test/compile-fail/borrowck-issue-2657-2.rs
src/test/compile-fail/borrowck-lend-flow-match.rs
src/test/compile-fail/borrowck-let-suggestion.rs
src/test/compile-fail/borrowck-managed-pointer-deref-scope.rs
src/test/compile-fail/borrowck-match-binding-is-assignment.rs
src/test/compile-fail/borrowck-move-from-subpath-of-borrowed-path.rs
src/test/compile-fail/borrowck-move-out-of-overloaded-auto-deref.rs
src/test/compile-fail/borrowck-multiple-captures.rs
src/test/compile-fail/borrowck-uniq-via-lend.rs
src/test/compile-fail/borrowck-vec-pattern-move-tail.rs
src/test/compile-fail/borrowck-vec-pattern-nesting.rs
src/test/compile-fail/borrowck-while.rs
src/test/compile-fail/builtin-superkinds-self-type.rs
src/test/compile-fail/const-block-non-item-statement.rs
src/test/compile-fail/deriving-span-PartialOrd-enum-struct-variant.rs
src/test/compile-fail/deriving-span-PartialOrd-enum.rs
src/test/compile-fail/deriving-span-PartialOrd-struct.rs
src/test/compile-fail/deriving-span-PartialOrd-tuple-struct.rs
src/test/compile-fail/for-loop-refutable-pattern-error-message.rs
src/test/compile-fail/integer-literal-suffix-inference-2.rs [new file with mode: 0644]
src/test/compile-fail/integer-literal-suffix-inference-3.rs [new file with mode: 0644]
src/test/compile-fail/issue-10398.rs
src/test/compile-fail/issue-11493.rs
src/test/compile-fail/issue-11873.rs
src/test/compile-fail/issue-11925.rs
src/test/compile-fail/issue-12041.rs
src/test/compile-fail/issue-15260.rs [new file with mode: 0644]
src/test/compile-fail/issue-1962.rs
src/test/compile-fail/issue-3344.rs
src/test/compile-fail/issue-3707.rs
src/test/compile-fail/lint-dead-code-1.rs
src/test/compile-fail/lint-heap-memory.rs
src/test/compile-fail/lint-unnecessary-parens.rs
src/test/compile-fail/lint-unused-imports.rs
src/test/compile-fail/lint-unused-mut-variables.rs
src/test/compile-fail/liveness-unused.rs
src/test/compile-fail/match-ill-type2.rs
src/test/compile-fail/match-non-exhaustive.rs
src/test/compile-fail/match-range-fail-dominate.rs
src/test/compile-fail/match-vec-fixed.rs
src/test/compile-fail/moves-based-on-type-exprs.rs
src/test/compile-fail/mut-cant-alias.rs
src/test/compile-fail/mut-not-freeze.rs
src/test/compile-fail/mut-ptr-cant-outlive-ref.rs
src/test/compile-fail/no_send-rc.rs
src/test/compile-fail/no_share-rc.rs
src/test/compile-fail/non-exhaustive-match.rs
src/test/compile-fail/refutable-pattern-errors.rs
src/test/compile-fail/regionck-closure-lifetimes.rs
src/test/compile-fail/regions-escape-loop-via-variable.rs
src/test/compile-fail/regions-escape-loop-via-vec.rs
src/test/compile-fail/static-assert2.rs
src/test/compile-fail/static-mut-not-pat.rs
src/test/compile-fail/static-region-bound.rs
src/test/compile-fail/typeck-unsafe-always-share.rs
src/test/compile-fail/unique-unique-kind.rs
src/test/compile-fail/unreachable-code.rs
src/test/compile-fail/unsized3.rs
src/test/compile-fail/unsized6.rs
src/test/compile-fail/vec-mut-iter-borrow.rs
src/test/compile-fail/warn-path-statement.rs
src/test/debuginfo/basic-types-metadata.rs
src/test/debuginfo/box.rs
src/test/debuginfo/closure-in-generic-function.rs
src/test/debuginfo/destructured-local.rs
src/test/debuginfo/function-arg-initialization.rs
src/test/debuginfo/function-prologue-stepping-no-split-stack.rs
src/test/debuginfo/generic-functions-nested.rs
src/test/debuginfo/generic-method-on-generic-struct.rs
src/test/debuginfo/generic-static-method-on-struct-and-enum.rs
src/test/debuginfo/generic-struct-style-enum.rs
src/test/debuginfo/generic-struct.rs
src/test/debuginfo/lexical-scope-in-for-loop.rs
src/test/debuginfo/lexical-scope-in-if.rs
src/test/debuginfo/lexical-scope-in-match.rs
src/test/debuginfo/lexical-scope-in-parameterless-closure.rs
src/test/debuginfo/lexical-scope-in-stack-closure.rs
src/test/debuginfo/lexical-scope-in-unconditional-loop.rs
src/test/debuginfo/lexical-scope-in-unique-closure.rs
src/test/debuginfo/lexical-scope-in-while.rs
src/test/debuginfo/lexical-scope-with-macro.rs
src/test/debuginfo/lexical-scopes-in-block-expression.rs
src/test/debuginfo/limited-debuginfo.rs
src/test/debuginfo/managed-pointer-within-unique.rs
src/test/debuginfo/method-on-generic-struct.rs
src/test/debuginfo/multiple-functions-equal-var-names.rs
src/test/debuginfo/multiple-functions.rs
src/test/debuginfo/name-shadowing-and-scope-nesting.rs
src/test/debuginfo/option-like-enum.rs
src/test/debuginfo/shadowed-argument.rs
src/test/debuginfo/shadowed-variable.rs
src/test/debuginfo/simple-lexical-scope.rs
src/test/debuginfo/vec.rs
src/test/pretty/block-disambig.rs
src/test/pretty/issue-929.rs
src/test/pretty/match-naked-expr-medium.rs
src/test/pretty/match-naked-expr.rs
src/test/pretty/unary-op-disambig.rs
src/test/pretty/vec-comments.pp
src/test/pretty/vec-comments.rs
src/test/run-fail/assert-as-macro.rs
src/test/run-fail/bounds-check-no-overflow.rs
src/test/run-fail/divide-by-zero.rs
src/test/run-fail/explicit-fail-msg.rs
src/test/run-fail/expr-if-fail.rs
src/test/run-fail/expr-match-fail.rs
src/test/run-fail/fail-task-name-owned.rs
src/test/run-fail/fail-task-name-send-str.rs
src/test/run-fail/fail.rs
src/test/run-fail/issue-3029.rs
src/test/run-fail/mod-zero.rs
src/test/run-fail/unwind-assert.rs
src/test/run-fail/unwind-box-res.rs
src/test/run-fail/unwind-box.rs
src/test/run-fail/unwind-fail.rs
src/test/run-fail/unwind-interleaved.rs
src/test/run-fail/unwind-iter.rs
src/test/run-fail/unwind-iter2.rs
src/test/run-fail/unwind-match.rs
src/test/run-fail/unwind-nested.rs
src/test/run-fail/unwind-partial-box.rs
src/test/run-fail/unwind-partial-unique.rs
src/test/run-fail/unwind-partial-vec.rs
src/test/run-fail/unwind-resource-fail.rs
src/test/run-fail/unwind-stacked.rs
src/test/run-fail/unwind-tup.rs
src/test/run-fail/unwind-uninitialized.rs
src/test/run-fail/unwind-unique.rs
src/test/run-make/graphviz-flowgraph/f01.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f01.rs
src/test/run-make/graphviz-flowgraph/f03.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f03.rs
src/test/run-make/graphviz-flowgraph/f04.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f04.rs
src/test/run-make/graphviz-flowgraph/f05.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f05.rs
src/test/run-make/graphviz-flowgraph/f07.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f07.rs
src/test/run-make/graphviz-flowgraph/f08.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f08.rs
src/test/run-make/graphviz-flowgraph/f09.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f09.rs
src/test/run-make/graphviz-flowgraph/f10.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f10.rs
src/test/run-make/graphviz-flowgraph/f11.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f11.rs
src/test/run-make/graphviz-flowgraph/f12.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f12.rs
src/test/run-make/graphviz-flowgraph/f14.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f14.rs
src/test/run-make/graphviz-flowgraph/f15.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f15.rs
src/test/run-make/graphviz-flowgraph/f16.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f16.rs
src/test/run-make/graphviz-flowgraph/f17.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f17.rs
src/test/run-make/graphviz-flowgraph/f20.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f20.rs
src/test/run-make/graphviz-flowgraph/f21.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f21.rs
src/test/run-make/graphviz-flowgraph/f22.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f22.rs
src/test/run-make/graphviz-flowgraph/f23.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f23.rs
src/test/run-make/graphviz-flowgraph/f24.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f24.rs
src/test/run-make/graphviz-flowgraph/f25.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f25.rs
src/test/run-make/static-unwinding/main.rs
src/test/run-pass/auto-instantiate.rs
src/test/run-pass/builtin-superkinds-self-type.rs
src/test/run-pass/class-poly-methods.rs
src/test/run-pass/cleanup-rvalue-scopes.rs
src/test/run-pass/cmp-default.rs
src/test/run-pass/const-binops.rs
src/test/run-pass/const-bound.rs
src/test/run-pass/const-str-ptr.rs
src/test/run-pass/deriving-cmp-shortcircuit.rs
src/test/run-pass/drop-trait-generic.rs
src/test/run-pass/early-ret-binop-add.rs
src/test/run-pass/else-if.rs
src/test/run-pass/enum-discr.rs
src/test/run-pass/enum-discrim-width-stuff.rs
src/test/run-pass/enum-nullable-simplifycfg-misopt.rs
src/test/run-pass/enum-vec-initializer.rs
src/test/run-pass/expr-block-box.rs
src/test/run-pass/expr-block-ref.rs
src/test/run-pass/expr-block-unique.rs
src/test/run-pass/expr-empty-ret.rs
src/test/run-pass/expr-if-fail-all.rs
src/test/run-pass/expr-if-fail.rs
src/test/run-pass/expr-match-fail-all.rs
src/test/run-pass/floatlits.rs
src/test/run-pass/fn-type-infer.rs
src/test/run-pass/foreach-external-iterators-break.rs
src/test/run-pass/foreach-external-iterators-nested.rs
src/test/run-pass/foreach-external-iterators.rs
src/test/run-pass/foreign-call-no-runtime.rs
src/test/run-pass/generic-ivec-leak.rs
src/test/run-pass/generic-ivec.rs
src/test/run-pass/generic-tag-local.rs
src/test/run-pass/guards.rs
src/test/run-pass/hygiene-dodging-1.rs
src/test/run-pass/ignore-all-the-things.rs
src/test/run-pass/import-in-block.rs
src/test/run-pass/import4.rs
src/test/run-pass/inferred-suffix-in-pattern-range.rs
src/test/run-pass/init-res-into-things.rs
src/test/run-pass/issue-10638.rs
src/test/run-pass/issue-1257.rs
src/test/run-pass/issue-13027.rs
src/test/run-pass/issue-13494.rs
src/test/run-pass/issue-1460.rs
src/test/run-pass/issue-15221.rs
src/test/run-pass/issue-2216.rs
src/test/run-pass/issue-2383.rs
src/test/run-pass/issue-2428.rs
src/test/run-pass/issue-2734.rs
src/test/run-pass/issue-2735.rs
src/test/run-pass/issue-2804.rs
src/test/run-pass/issue-333.rs
src/test/run-pass/issue-3500.rs
src/test/run-pass/issue-3878.rs
src/test/run-pass/issue-4387.rs
src/test/run-pass/issue-6117.rs
src/test/run-pass/issue-6318.rs
src/test/run-pass/issue-8044.rs
src/test/run-pass/issue-8498.rs
src/test/run-pass/issue-868.rs
src/test/run-pass/issue-8898.rs
src/test/run-pass/issue-8983.rs
src/test/run-pass/issue-9906.rs
src/test/run-pass/issue-9942.rs
src/test/run-pass/keyword-changes-2012-07-31.rs
src/test/run-pass/lazy-and-or.rs
src/test/run-pass/lazy-init.rs
src/test/run-pass/long-while.rs
src/test/run-pass/loop-diverges.rs
src/test/run-pass/loop-label-shadowing.rs
src/test/run-pass/loop-no-reinit-needed-post-bot.rs
src/test/run-pass/match-bot-2.rs
src/test/run-pass/match-naked-record-expr.rs
src/test/run-pass/match-naked-record.rs
src/test/run-pass/match-pipe-binding.rs
src/test/run-pass/match-range.rs
src/test/run-pass/multi-let.rs
src/test/run-pass/negative.rs
src/test/run-pass/new-box-syntax.rs
src/test/run-pass/operator-associativity.rs
src/test/run-pass/out-of-stack.rs
src/test/run-pass/owned-implies-static.rs
src/test/run-pass/paren-free.rs
src/test/run-pass/pub-extern-privacy.rs
src/test/run-pass/regions-infer-borrow-scope-view.rs
src/test/run-pass/resource-assign-is-not-copy.rs
src/test/run-pass/self-re-assign.rs
src/test/run-pass/shadow.rs
src/test/run-pass/static-assert.rs
src/test/run-pass/string-self-append.rs
src/test/run-pass/supported-cast.rs
src/test/run-pass/swap-1.rs
src/test/run-pass/tag-variant-disr-type-mismatch.rs
src/test/run-pass/task-comm-12.rs
src/test/run-pass/terminate-in-initializer.rs
src/test/run-pass/trailing-comma.rs
src/test/run-pass/trait-default-method-xc-2.rs
src/test/run-pass/type-param-constraints.rs
src/test/run-pass/typestate-cfg-nesting.rs
src/test/run-pass/typestate-multi-decl.rs
src/test/run-pass/unify-return-ty.rs
src/test/run-pass/unique-create.rs
src/test/run-pass/unique-drop-complex.rs
src/test/run-pass/unique-init.rs
src/test/run-pass/unreachable-code.rs
src/test/run-pass/unused-move-capture.rs
src/test/run-pass/unused-move.rs
src/test/run-pass/unwind-box.rs
src/test/run-pass/unwind-unique.rs
src/test/run-pass/vec-macro-with-brackets.rs
src/test/run-pass/vec-matching.rs
src/test/run-pass/vec-push.rs
src/test/run-pass/vec-repeat-with-cast.rs
src/test/run-pass/weird-exprs.rs
src/test/run-pass/while-flow-graph.rs

index 5927fb292d8b964a99c9ce4f4108423659272e1b..a94c154b67d03f92ed255c9afeb40804e88a8a11 100644 (file)
--- a/README.md
+++ b/README.md
@@ -54,10 +54,26 @@ documentation.
     When complete, `make install` will place several programs into
     `/usr/local/bin`: `rustc`, the Rust compiler, and `rustdoc`, the
     API-documentation tool.
-    system.
 3. Read the [tutorial].
 4. Enjoy!
 
+### Building on Windows
+
+To easily build on windows we can use [MSYS2](http://sourceforge.net/projects/msys2/):
+
+1. Grab the latest MSYS2 installer and go through the installer.
+2. Now from the MSYS2 terminal we want to install the mingw64 toolchain and the other
+   tools we need.
+
+        $ pacman -S mingw-w64-i686-toolchain
+        $ pacman -S base-devel
+
+3. With that now start `mingw32_shell.bat` from where you installed MSYS2 (i.e. `C:\msys`).
+4. From there just navigate to where you have Rust's source code, configure and build it:
+
+        $ ./configure --build=i686-pc-mingw32
+        $ make && make install
+
 [repo]: https://github.com/rust-lang/rust
 [tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz
 [tutorial]: http://doc.rust-lang.org/tutorial.html
index 82b7ee27b94879dbe59d61d75083c17da52d32e8..d5795c328e7d52d8bf4ef7382d355fb2862f0d8a 100644 (file)
@@ -38,6 +38,15 @@ directory to load plugins from (default: /tmp/rustdoc_ng/plugins)
 -L --library-path <val>
 directory to add to crate search path
 .TP
+--html-in-header <val>
+file to add to <head>
+.TP
+--html-before-content <val>
+file to add in <body>, before content
+.TP
+--html-after-content <val>
+file to add in <body>, after content
+.TP
 -h, --help
 Print help
 
index 6a89897c292778572a3f71d9114c767ba632fca9..76ebfe9b49fd64929ce5b07b49b2faba38ece8e9 100644 (file)
@@ -54,6 +54,7 @@ PKG_FILES := \
       driver                                   \
       etc                                      \
       $(foreach crate,$(CRATES),lib$(crate))   \
+      libcoretest                              \
       libbacktrace                             \
       rt                                       \
       rustllvm                                 \
index 8098a0682a5d0f719d31f4d5b07cab8182382db9..213565b09ac27d0633a81cbdb6fde4cc5cf61b5d 100644 (file)
@@ -35,16 +35,16 @@ DOCS := index intro tutorial guide guide-ffi guide-macros guide-lifetimes \
 PDF_DOCS := tutorial rust
 
 RUSTDOC_DEPS_rust := doc/full-toc.inc
-RUSTDOC_FLAGS_rust := --markdown-in-header=doc/full-toc.inc
+RUSTDOC_FLAGS_rust := --html-in-header=doc/full-toc.inc
 
 L10N_LANGS := ja
 
 # Generally no need to edit below here.
 
 # The options are passed to the documentation generators.
-RUSTDOC_HTML_OPTS_NO_CSS = --markdown-before-content=doc/version_info.html \
-       --markdown-in-header=doc/favicon.inc \
-       --markdown-after-content=doc/footer.inc \
+RUSTDOC_HTML_OPTS_NO_CSS = --html-before-content=doc/version_info.html \
+       --html-in-header=doc/favicon.inc \
+       --html-after-content=doc/footer.inc \
        --markdown-playground-url='http://play.rust-lang.org/'
 
 RUSTDOC_HTML_OPTS = $(RUSTDOC_HTML_OPTS_NO_CSS) --markdown-css rust.css
index 1989d6ef86797855d1f738fb2d2dfccb3f0dfb1f..44bedde99ccffdba2a1571000adc371b601da523 100644 (file)
 ######################################################################
 
 # The names of crates that must be tested
-TEST_TARGET_CRATES = $(TARGET_CRATES)
+
+# libcore tests are in a separate crate
+DEPS_coretest :=
+$(eval $(call RUST_CRATE,coretest))
+
+TEST_TARGET_CRATES = $(filter-out core,$(TARGET_CRATES)) coretest
 TEST_DOC_CRATES = $(DOC_CRATES)
 TEST_HOST_CRATES = $(HOST_CRATES)
 TEST_CRATES = $(TEST_TARGET_CRATES) $(TEST_HOST_CRATES)
@@ -172,7 +177,7 @@ check-notidy: cleantmptestlogs cleantestlibs all check-stage2
        $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
 
 check-lite: cleantestlibs cleantmptestlogs \
-       $(foreach crate,$(TARGET_CRATES),check-stage2-$(crate)) \
+       $(foreach crate,$(TEST_TARGET_CRATES),check-stage2-$(crate)) \
        check-stage2-rpass \
        check-stage2-rfail check-stage2-cfail check-stage2-rmake
        $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
index ffaabbb04ab680bbfbae1ebdc34b2cb5a8247eaa..3852591da5ba2e4a4c0b40447251b727b5bd9792 100644 (file)
@@ -267,12 +267,12 @@ impl<T: Send> Drop for Unique<T> {
 // A comparison between the built-in `Box` and this reimplementation
 fn main() {
     {
-        let mut x = box 5;
+        let mut x = box 5i;
         *x = 10;
     } // `x` is freed here
 
     {
-        let mut y = Unique::new(5);
+        let mut y = Unique::new(5i);
         *y.borrow_mut() = 10;
     } // `y` is freed here
 }
@@ -678,7 +678,7 @@ unsafe fn deallocate(ptr: *mut u8, _size: uint, _align: uint) {
 
 #[start]
 fn main(argc: int, argv: *const *const u8) -> int {
-    let x = box 1;
+    let x = box 1i;
 
     0
 }
index 3cbe83718d4aed83c2d1c32b9b967733bb64b8b6..4577c5a86d77582d18c8f9bf19e243d1a6ddb439 100644 (file)
@@ -285,8 +285,9 @@ At first, your program doesn't have any dependencies, so we'll only be using
 the first part of its functionality. Eventually, we'll add more. Since we
 started off by using Cargo, it'll be easy to add later.
 
-Let's convert Hello World to Cargo. The first thing we need to do is install
-it. To do this, we need to build it from source. There are no binaries yet.
+Let's convert Hello World to Cargo. The first thing we need to do to begin using Cargo
+is to install Cargo. To do this, we need to build it from source. There are no binaries
+yet.
 
 First, let's go back to our projects directory. We don't want Cargo to
 live in our project!
index 1e577a91131607d12d1bab1e2d0112a8a79ac5c2..10fd39c841bd658e12062378e33883945b1637ac 100644 (file)
@@ -133,7 +133,7 @@ Check it out:
 ```
 
 fn dangling() -> Box<int> {
-    let i = box 1234;
+    let i = box 1234i;
     return i;
 }
 
@@ -143,8 +143,8 @@ fn add_one() -> int {
 }
 ```
 
-Now instead of a stack allocated `1234`,
-we have a heap allocated `box 1234`.
+Now instead of a stack allocated `1234i`,
+we have a heap allocated `box 1234i`.
 Whereas `&` borrows a pointer to existing memory,
 creating an owned box allocates memory on the heap and places a value in it,
 giving you the sole pointer to that memory.
@@ -152,7 +152,7 @@ You can roughly compare these two lines:
 
 ```
 // Rust
-let i = box 1234;
+let i = box 1234i;
 ```
 
 ```cpp
index c5a6a01f48355aeb5e95d75afbaa88a67f11c134..58819a3cf48ee2454d9958f85cc7aac28ebb7af1 100644 (file)
@@ -442,17 +442,14 @@ of integer literal suffix:
 The type of an _unsuffixed_ integer literal is determined by type inference.
 If an integer type can be _uniquely_ determined from the surrounding program
 context, the unsuffixed integer literal has that type.  If the program context
-underconstrains the type, the unsuffixed integer literal's type is `int`; if
-the program context overconstrains the type, it is considered a static type
-error.
+underconstrains the type, it is considered a static type error;
+if the program context overconstrains the type,
+it is also considered a static type error.
 
 Examples of integer literals of various forms:
 
 ~~~~
-123; 0xff00;                       // type determined by program context
-                                   // defaults to int in absence of type
-                                   // information
-
+123i;                              // type int
 123u;                              // type uint
 123_u;                             // type uint
 0xff_u8;                           // type u8
@@ -469,8 +466,10 @@ A _floating-point literal_ has one of two forms:
   second decimal literal.
 * A single _decimal literal_ followed by an _exponent_.
 
-By default, a floating-point literal has a generic type, but will fall back to
-`f64`. A floating-point literal may be followed (immediately, without any
+By default, a floating-point literal has a generic type,
+and, like integer literals, the type must be uniquely determined
+from the context.
+A floating-point literal may be followed (immediately, without any
 spaces) by a _floating-point suffix_, which changes the type of the literal.
 There are two floating-point suffixes: `f32`, and `f64` (the 32-bit and 64-bit
 floating point types).
@@ -478,8 +477,8 @@ floating point types).
 Examples of floating-point literals of various forms:
 
 ~~~~
-123.0;                             // type f64
-0.1;                               // type f64
+123.0f64;                          // type f64
+0.1f64;                            // type f64
 0.1f32;                            // type f32
 12E+99_f64;                        // type f64
 ~~~~
@@ -2700,9 +2699,9 @@ must be a constant expression that can be evaluated at compile time, such
 as a [literal](#literals) or a [static item](#static-items).
 
 ~~~~
-[1, 2, 3, 4];
+[1i, 2, 3, 4];
 ["a", "b", "c", "d"];
-[0, ..128];             // vector with 128 zeros
+[0i, ..128];             // vector with 128 zeros
 [0u8, 0u8, 0u8, 0u8];
 ~~~~
 
@@ -2881,7 +2880,7 @@ equals sign (`=`) and an [rvalue](#lvalues-rvalues-and-temporaries) expression.
 Evaluating an assignment expression [either copies or moves](#moved-and-copied-types) its right-hand operand to its left-hand operand.
 
 ~~~~
-# let mut x = 0;
+# let mut x = 0i;
 # let y = 0;
 
 x = y;
@@ -2932,7 +2931,7 @@ paren_expr : '(' expr ')' ;
 An example of a parenthesized expression:
 
 ~~~~
-let x = (2 + 3) * 4;
+let x: int = (2 + 3) * 4;
 ~~~~
 
 
@@ -3016,7 +3015,7 @@ conditional expression evaluates to `false`, the `while` expression completes.
 An example:
 
 ~~~~
-let mut i = 0;
+let mut i = 0u;
 
 while i < 10 {
     println!("hello");
@@ -3262,7 +3261,7 @@ Patterns can also dereference pointers by using the `&`,
 on `x: &int` are equivalent:
 
 ~~~~
-# let x = &3;
+# let x = &3i;
 let y = match *x { 0 => "zero", _ => "some" };
 let z = match x { &0 => "zero", _ => "some" };
 
@@ -3285,7 +3284,7 @@ A range of values may be specified with `..`.
 For example:
 
 ~~~~
-# let x = 2;
+# let x = 2i;
 
 let message = match x {
   0 | 1  => "not many",
index 2287bcabff7625ef60863837170fddec3fa5d745..8199eaea82c683b7cc29489b682e11fa8d9d89db 100644 (file)
@@ -103,6 +103,17 @@ rustdoc can also generate JSON, for consumption by other tools, with
 `rustdoc --output-format json`, and also consume already-generated JSON with
 `rustdoc --input-format json`.
 
+rustdoc also supports personalizing the output from crates' documentation,
+similar to markdown options.
+
+- `--html-in-header FILE`: includes the contents of `FILE` at the
+  end of the `<head>...</head>` section.
+- `--html-before-content FILE`: includes the contents of `FILE`
+  directly after `<body>`, before the rendered content (including the
+  search bar).
+- `--html-after-content FILE`: includes the contents of `FILE`
+  after all the rendered content.
+
 # Using the Documentation
 
 The web pages generated by rustdoc present the same logical hierarchy that one
@@ -238,16 +249,16 @@ detected by a `.md` or `.markdown` extension.
 There are 4 options to modify the output that Rustdoc creates.
 
 - `--markdown-css PATH`: adds a `<link rel="stylesheet">` tag pointing to `PATH`.
-- `--markdown-in-header FILE`: includes the contents of `FILE` at the
+- `--html-in-header FILE`: includes the contents of `FILE` at the
   end of the `<head>...</head>` section.
-- `--markdown-before-content FILE`: includes the contents of `FILE`
+- `--html-before-content FILE`: includes the contents of `FILE`
   directly after `<body>`, before the rendered content (including the
   title).
-- `--markdown-after-content FILE`: includes the contents of `FILE`
+- `--html-after-content FILE`: includes the contents of `FILE`
   directly before `</body>`, after all the rendered content.
 
 All of these can be specified multiple times, and they are output in
-the order in which they are specified. The first line of the file must
+the order in which they are specified. The first line of the file being rendered must
 be the title, prefixed with `%` (e.g. this page has `% Rust
 Documentation` on the first line).
 
index 456726984bc04f6461a9853510df722e5ebe94b6..5fe6a5f14c2b426d55d112a6083dbc0889ddab6e 100644 (file)
@@ -262,7 +262,7 @@ write function, variable, and module names with lowercase letters, using
 underscores where they help readability, while writing types in camel case.
 
 ~~~
-let my_variable = 100;
+let my_variable = 100i;
 type MyType = int;     // primitive types are _not_ camel case
 ~~~
 
@@ -276,7 +276,7 @@ write a piece of code like this:
 
 ~~~~
 # let item = "salad";
-let price;
+let price: f64;
 if item == "salad" {
     price = 3.50;
 } else if item == "muffin" {
@@ -290,7 +290,7 @@ But, in Rust, you don't have to repeat the name `price`:
 
 ~~~~
 # let item = "salad";
-let price =
+let price: f64 =
     if item == "salad" {
         3.50
     } else if item == "muffin" {
@@ -337,11 +337,10 @@ suffix that can be used to indicate the type of a literal: `i` for `int`,
 In the absence of an integer literal suffix, Rust will infer the
 integer type based on type annotations and function signatures in the
 surrounding program. In the absence of any type information at all,
-Rust will assume that an unsuffixed integer literal has type
-`int`.
+Rust will report an error and request that the type be specified explicitly.
 
 ~~~~
-let a = 1;       // `a` is an `int`
+let a: int = 1;  // `a` is an `int`
 let b = 10i;     // `b` is an `int`, due to the `i` suffix
 let c = 100u;    // `c` is a `uint`
 let d = 1000i32; // `d` is an `i32`
@@ -475,7 +474,7 @@ against each pattern in order until one matches. The matching pattern
 executes its corresponding arm.
 
 ~~~~
-let my_number = 1;
+let my_number = 1i;
 match my_number {
   0     => println!("zero"),
   1 | 2 => println!("one or two"),
@@ -501,7 +500,7 @@ matches any single value. (`..`) is a different wildcard that can match
 one or more fields in an `enum` variant.
 
 ~~~
-# let my_number = 1;
+# let my_number = 1i;
 match my_number {
   0 => { println!("zero") }
   _ => { println!("something else") }
@@ -584,7 +583,7 @@ keyword `break` aborts the loop, and `continue` aborts the current
 iteration and continues with the next.
 
 ~~~~
-let mut cake_amount = 8;
+let mut cake_amount = 8i;
 while cake_amount > 0 {
     cake_amount -= 1;
 }
@@ -944,7 +943,7 @@ The `box` operator performs memory allocation on the heap:
 ~~~~
 {
     // an integer allocated on the heap
-    let y = box 10;
+    let y = box 10i;
 }
 // the destructor frees the heap memory as soon as `y` goes out of scope
 ~~~~
@@ -1165,7 +1164,7 @@ let z = x;
 The mutability of a value may be changed by moving it to a new owner:
 
 ~~~~
-let r = box 13;
+let r = box 13i;
 let mut s = r; // box becomes mutable
 *s += 1;
 let t = s; // box becomes immutable
@@ -1285,9 +1284,9 @@ Using the generic `List<T>` works much like before, thanks to type inference:
 #     Cons(value, box xs)
 # }
 let mut xs = Nil; // Unknown type! This is a `List<T>`, but `T` can be anything.
-xs = prepend(xs, 10); // Here the compiler infers `xs`'s type as `List<int>`.
-xs = prepend(xs, 15);
-xs = prepend(xs, 20);
+xs = prepend(xs, 10i); // Here the compiler infers `xs`'s type as `List<int>`.
+xs = prepend(xs, 15i);
+xs = prepend(xs, 20i);
 ~~~
 
 The code sample above demonstrates type inference making most type annotations optional. It is
@@ -1410,12 +1409,12 @@ Beyond the properties granted by the size, an owned box behaves as a regular
 value by inheriting the mutability and lifetime of the owner:
 
 ~~~~
-let x = 5; // immutable
-let mut y = 5; // mutable
+let x = 5i; // immutable
+let mut y = 5i; // mutable
 y += 2;
 
-let x = box 5; // immutable
-let mut y = box 5; // mutable
+let x = box 5i; // immutable
+let mut y = box 5i; // mutable
 *y += 2; // the `*` operator is needed to access the contained value
 ~~~~
 
@@ -1507,7 +1506,7 @@ freezing enforced statically at compile-time. An example of a non-`Freeze` type
 is [`RefCell<T>`][refcell].
 
 ~~~~
-let mut x = 5;
+let mut x = 5i;
 {
     let y = &x; // `x` is now frozen. It cannot be modified or re-assigned.
 }
@@ -1523,8 +1522,8 @@ Rust uses the unary star operator (`*`) to access the contents of a
 box or pointer, similarly to C.
 
 ~~~
-let owned = box 10;
-let borrowed = &20;
+let owned = box 10i;
+let borrowed = &20i;
 
 let sum = *owned + *borrowed;
 ~~~
@@ -1534,9 +1533,9 @@ assignments. Such an assignment modifies the value that the pointer
 points to.
 
 ~~~
-let mut owned = box 10;
+let mut owned = box 10i;
 
-let mut value = 20;
+let mut value = 20i;
 let borrowed = &mut value;
 
 *owned = *borrowed + 100;
@@ -1654,12 +1653,12 @@ Unicode code points, so they cannot be freely mutated without the ability to
 alter the length.
 
 ~~~
-let mut xs = [1, 2, 3];
+let mut xs = [1i, 2i, 3i];
 let view = xs.mut_slice(0, 2);
 view[0] = 5;
 
 // The type of a mutable slice is written as `&mut [T]`
-let ys: &mut [int] = &mut [1, 2, 3];
+let ys: &mut [int] = &mut [1i, 2i, 3i];
 ~~~
 
 Square brackets denote indexing into a slice or fixed-size vector:
index 6af4083edb2cefe224bbb375c6f1a4c6e6b01744..38ed511c4589a5004a12b6510fff04bde660d845 100644 (file)
@@ -376,14 +376,14 @@ fn test_cowarc_clone_weak() {
 
     #[test]
     fn test_live() {
-        let x = Arc::new(5);
+        let x = Arc::new(5i);
         let y = x.downgrade();
         assert!(y.upgrade().is_some());
     }
 
     #[test]
     fn test_dead() {
-        let x = Arc::new(5);
+        let x = Arc::new(5i);
         let y = x.downgrade();
         drop(x);
         assert!(y.upgrade().is_none());
index 589ff8c1de9fe357c820ae57d58f71727c049c3a..dc8280e9b8361844aa2cf0e1fd71a5790bde4cd9 100644 (file)
@@ -329,7 +329,7 @@ mod bench {
     #[bench]
     fn alloc_owned_small(b: &mut Bencher) {
         b.iter(|| {
-            box 10
+            box 10i
         })
     }
 }
index 589adbd41d04e74e1ccaf3df57a4a937a187f060..addec396bbef8715d14e88ea237671424b1621b2 100644 (file)
@@ -18,6 +18,7 @@
 use core::intrinsics;
 use core::kinds::Send;
 use core::mem;
+use core::option::Option;
 use core::raw::TraitObject;
 use core::result::{Ok, Err, Result};
 
@@ -64,6 +65,10 @@ fn eq(&self, other: &Box<T>) -> bool { *(*self) == *(*other) }
     fn ne(&self, other: &Box<T>) -> bool { *(*self) != *(*other) }
 }
 impl<T:PartialOrd> PartialOrd for Box<T> {
+    #[inline]
+    fn partial_cmp(&self, other: &Box<T>) -> Option<Ordering> {
+        (**self).partial_cmp(*other)
+    }
     #[inline]
     fn lt(&self, other: &Box<T>) -> bool { *(*self) < *(*other) }
     #[inline]
@@ -146,3 +151,51 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         f.pad("Box<Any>")
     }
 }
+
+#[cfg(test)]
+mod test {
+    #[test]
+    fn test_owned_clone() {
+        let a = box 5i;
+        let b: Box<int> = a.clone();
+        assert!(a == b);
+    }
+
+    #[test]
+    fn any_move() {
+        let a = box 8u as Box<Any>;
+        let b = box Test as Box<Any>;
+
+        match a.move::<uint>() {
+            Ok(a) => { assert!(a == box 8u); }
+            Err(..) => fail!()
+        }
+        match b.move::<Test>() {
+            Ok(a) => { assert!(a == box Test); }
+            Err(..) => fail!()
+        }
+
+        let a = box 8u as Box<Any>;
+        let b = box Test as Box<Any>;
+
+        assert!(a.move::<Box<Test>>().is_err());
+        assert!(b.move::<Box<uint>>().is_err());
+    }
+
+    #[test]
+    fn test_show() {
+        let a = box 8u as Box<Any>;
+        let b = box Test as Box<Any>;
+        let a_str = a.to_str();
+        let b_str = b.to_str();
+        assert_eq!(a_str.as_slice(), "Box<Any>");
+        assert_eq!(b_str.as_slice(), "Box<Any>");
+
+        let a = &8u as &Any;
+        let b = &Test as &Any;
+        let s = format!("{}", a);
+        assert_eq!(s.as_slice(), "&Any");
+        let s = format!("{}", b);
+        assert_eq!(s.as_slice(), "&Any");
+    }
+}
index a3ca72f1547eda84a9146b906e1882436e9aa854..83cc4a0b6620df31d0a83f73a03b7ba2ff92b9b4 100644 (file)
@@ -27,6 +27,7 @@
 use core::cell::Cell;
 use core::clone::Clone;
 use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering};
+use core::default::Default;
 use core::kinds::marker;
 use core::ops::{Deref, Drop};
 use core::option::{Option, Some, None};
@@ -152,6 +153,13 @@ fn clone(&self) -> Rc<T> {
     }
 }
 
+impl<T: Default> Default for Rc<T> {
+    #[inline]
+    fn default() -> Rc<T> {
+        Rc::new(Default::default())
+    }
+}
+
 impl<T: PartialEq> PartialEq for Rc<T> {
     #[inline(always)]
     fn eq(&self, other: &Rc<T>) -> bool { **self == **other }
@@ -162,6 +170,11 @@ fn ne(&self, other: &Rc<T>) -> bool { **self != **other }
 impl<T: Eq> Eq for Rc<T> {}
 
 impl<T: PartialOrd> PartialOrd for Rc<T> {
+    #[inline(always)]
+    fn partial_cmp(&self, other: &Rc<T>) -> Option<Ordering> {
+        (**self).partial_cmp(&**other)
+    }
+
     #[inline(always)]
     fn lt(&self, other: &Rc<T>) -> bool { **self < **other }
 
index 64bee05a379a72321a34898880da39dc45bac83d..92abfaad3483301016fa4449e51221967446f2c9 100644 (file)
@@ -107,8 +107,8 @@ fn eq(&self, other: &BTree<K, V>) -> bool {
 impl<K: Ord, V: Eq> Eq for BTree<K, V> {}
 
 impl<K: Ord, V: Eq> PartialOrd for BTree<K, V> {
-    fn lt(&self, other: &BTree<K, V>) -> bool {
-        self.cmp(other) == Less
+    fn partial_cmp(&self, other: &BTree<K, V>) -> Option<Ordering> {
+        Some(self.cmp(other))
     }
 }
 
@@ -229,8 +229,8 @@ fn eq(&self, other: &Node<K, V>) -> bool {
 impl<K: Ord, V: Eq> Eq for Node<K, V> {}
 
 impl<K: Ord, V: Eq> PartialOrd for Node<K, V> {
-    fn lt(&self, other: &Node<K, V>) -> bool {
-        self.cmp(other) == Less
+    fn partial_cmp(&self, other: &Node<K, V>) -> Option<Ordering> {
+        Some(self.cmp(other))
     }
 }
 
@@ -408,8 +408,8 @@ fn eq(&self, other: &Leaf<K, V>) -> bool {
 impl<K: Ord, V: Eq> Eq for Leaf<K, V> {}
 
 impl<K: Ord, V: Eq> PartialOrd for Leaf<K, V> {
-    fn lt(&self, other: &Leaf<K, V>) -> bool {
-        self.cmp(other) == Less
+    fn partial_cmp(&self, other: &Leaf<K, V>) -> Option<Ordering> {
+        Some(self.cmp(other))
     }
 }
 
@@ -638,8 +638,8 @@ fn eq(&self, other: &Branch<K, V>) -> bool {
 impl<K: Ord, V: Eq> Eq for Branch<K, V> {}
 
 impl<K: Ord, V: Eq> PartialOrd for Branch<K, V> {
-    fn lt(&self, other: &Branch<K, V>) -> bool {
-        self.cmp(other) == Less
+    fn partial_cmp(&self, other: &Branch<K, V>) -> Option<Ordering> {
+        Some(self.cmp(other))
     }
 }
 
@@ -706,8 +706,8 @@ fn eq(&self, other: &LeafElt<K, V>) -> bool {
 impl<K: Ord, V: Eq> Eq for LeafElt<K, V> {}
 
 impl<K: Ord, V: Eq> PartialOrd for LeafElt<K, V> {
-    fn lt(&self, other: &LeafElt<K, V>) -> bool {
-        self.cmp(other) == Less
+    fn partial_cmp(&self, other: &LeafElt<K, V>) -> Option<Ordering> {
+        Some(self.cmp(other))
     }
 }
 
@@ -755,8 +755,8 @@ fn eq(&self, other: &BranchElt<K, V>) -> bool {
 impl<K: Ord, V: Eq> Eq for BranchElt<K, V>{}
 
 impl<K: Ord, V: Eq> PartialOrd for BranchElt<K, V> {
-    fn lt(&self, other: &BranchElt<K, V>) -> bool {
-        self.cmp(other) == Less
+    fn partial_cmp(&self, other: &BranchElt<K, V>) -> Option<Ordering> {
+        Some(self.cmp(other))
     }
 }
 
index 7ea5c482e61f206b6b466b33dd4654362aac5ec8..4114c8cb1c4ddc8b7a5a489de9ea5ee1f7a8c518 100644 (file)
@@ -595,17 +595,8 @@ fn ne(&self, other: &DList<A>) -> bool {
 }
 
 impl<A: PartialOrd> PartialOrd for DList<A> {
-    fn lt(&self, other: &DList<A>) -> bool {
-        iter::order::lt(self.iter(), other.iter())
-    }
-    fn le(&self, other: &DList<A>) -> bool {
-        iter::order::le(self.iter(), other.iter())
-    }
-    fn gt(&self, other: &DList<A>) -> bool {
-        iter::order::gt(self.iter(), other.iter())
-    }
-    fn ge(&self, other: &DList<A>) -> bool {
-        iter::order::ge(self.iter(), other.iter())
+    fn partial_cmp(&self, other: &DList<A>) -> Option<Ordering> {
+        iter::order::partial_cmp(self.iter(), other.iter())
     }
 }
 
index 976f726244121f527e053a980042fe5b491e078a..e3d1c9a3216bc8252c7110d079b5b6b6f7ff2799 100644 (file)
@@ -342,12 +342,12 @@ fn test_writer_hasher() {
         assert_eq!(hasher.hash(& &[1u8, 2u8, 3u8]), 9);
 
         unsafe {
-            let ptr: *const int = mem::transmute(5);
+            let ptr: *const int = mem::transmute(5i);
             assert_eq!(hasher.hash(&ptr), 5);
         }
 
         unsafe {
-            let ptr: *mut int = mem::transmute(5);
+            let ptr: *mut int = mem::transmute(5i);
             assert_eq!(hasher.hash(&ptr), 5);
         }
     }
index 887b0fb0b8abe22b51facc05e4721fc023c24d66..4fd98538af7ddc93068901d28b657698a6d20f05 100644 (file)
@@ -265,8 +265,6 @@ pub fn hash_with_keys<T: Hash<SipState>>(k0: u64, k1: u64, value: &T) -> u64 {
     state.result()
 }
 
-
-
 #[cfg(test)]
 mod tests {
     use test::Bencher;
index be0d603696bec9f08486560aaf586b258c99e566..5e19accdd67152854d0bc355e3da11555b33ddb1 100644 (file)
@@ -572,7 +572,7 @@ fn bench_new(b: &mut test::Bencher) {
     fn bench_push_back(b: &mut test::Bencher) {
         let mut deq = RingBuf::new();
         b.iter(|| {
-            deq.push_back(0);
+            deq.push_back(0i);
         })
     }
 
@@ -580,7 +580,7 @@ fn bench_push_back(b: &mut test::Bencher) {
     fn bench_push_front(b: &mut test::Bencher) {
         let mut deq = RingBuf::new();
         b.iter(|| {
-            deq.push_front(0);
+            deq.push_front(0i);
         })
     }
 
@@ -589,7 +589,7 @@ fn bench_grow(b: &mut test::Bencher) {
         let mut deq = RingBuf::new();
         b.iter(|| {
             for _ in range(0i, 65) {
-                deq.push_front(1);
+                deq.push_front(1i);
             }
         })
     }
@@ -651,10 +651,10 @@ fn test_param_reccy() {
     #[test]
     fn test_with_capacity() {
         let mut d = RingBuf::with_capacity(0);
-        d.push_back(1);
+        d.push_back(1i);
         assert_eq!(d.len(), 1);
         let mut d = RingBuf::with_capacity(50);
-        d.push_back(1);
+        d.push_back(1i);
         assert_eq!(d.len(), 1);
     }
 
index ac32d93edbe83710aa4c689e81804c81f1061c60..40cf8495a40593996e7f259d13f9fda43ef91ed8 100644 (file)
@@ -17,7 +17,7 @@
 homogeneous types:
 
 ```rust
-let int_vector = [1,2,3];
+let int_vector = [1i, 2i, 3i];
 let str_vector = ["one", "two", "three"];
 ```
 
@@ -41,9 +41,9 @@
 a vector or a vector slice from the index interval `[a, b)`:
 
 ```rust
-let numbers = [0, 1, 2];
+let numbers = [0i, 1i, 2i];
 let last_numbers = numbers.slice(1, 3);
-// last_numbers is now &[1, 2]
+// last_numbers is now &[1i, 2i]
 ```
 
 Traits defined for the `~[T]` type, like `OwnedVector`, can only be called
@@ -54,9 +54,9 @@
 of the vector:
 
 ```rust
-let mut numbers = vec![0, 1, 2];
+let mut numbers = vec![0i, 1i, 2i];
 numbers.push(7);
-// numbers is now vec![0, 1, 2, 7];
+// numbers is now vec![0i, 1i, 2i, 7i];
 ```
 
 ## Implementations of other traits
@@ -779,7 +779,7 @@ fn test_from_elem() {
     fn test_is_empty() {
         let xs: [int, ..0] = [];
         assert!(xs.is_empty());
-        assert!(![0].is_empty());
+        assert!(![0i].is_empty());
     }
 
     #[test]
@@ -1528,7 +1528,7 @@ fn test_grow_fn_fail() {
     fn test_permute_fail() {
         let v = [(box 0i, Rc::new(0i)), (box 0i, Rc::new(0i)),
                  (box 0i, Rc::new(0i)), (box 0i, Rc::new(0i))];
-        let mut i = 0;
+        let mut i = 0u;
         for _ in v.permutations() {
             if i == 2 {
                 fail!()
@@ -1870,16 +1870,16 @@ fn test_bytes_set_memory() {
     fn test_overflow_does_not_cause_segfault() {
         let mut v = vec![];
         v.reserve_exact(-1);
-        v.push(1);
+        v.push(1i);
         v.push(2);
     }
 
     #[test]
     #[should_fail]
     fn test_overflow_does_not_cause_segfault_managed() {
-        let mut v = vec![Rc::new(1)];
+        let mut v = vec![Rc::new(1i)];
         v.reserve_exact(-1);
-        v.push(Rc::new(2));
+        v.push(Rc::new(2i));
     }
 
     #[test]
@@ -2279,7 +2279,7 @@ fn zero_1kb_mut_iter(b: &mut Bencher) {
                 v.set_len(1024);
             }
             for x in v.mut_iter() {
-                *x = 0;
+                *x = 0i;
             }
             v
         });
index 72c5aff675bfb4dbf94518f32acab03badc5a0d5..10309adef20d9faafa8c8de2d610b66e30eeef9e 100644 (file)
@@ -572,8 +572,8 @@ impl<'a> Eq for MaybeOwned<'a> {}
 
 impl<'a> PartialOrd for MaybeOwned<'a> {
     #[inline]
-    fn lt(&self, other: &MaybeOwned) -> bool {
-        self.as_slice().lt(&other.as_slice())
+    fn partial_cmp(&self, other: &MaybeOwned) -> Option<Ordering> {
+        Some(self.cmp(other))
     }
 }
 
@@ -803,15 +803,9 @@ fn to_owned(&self) -> String {
     }
 
     /// Converts to a vector of `u16` encoded as UTF-16.
+    #[deprecated = "use `utf16_units` instead"]
     fn to_utf16(&self) -> Vec<u16> {
-        let me = self.as_slice();
-        let mut u = Vec::new();
-        for ch in me.chars() {
-            let mut buf = [0u16, ..2];
-            let n = ch.encode_utf16(buf /* as mut slice! */);
-            u.push_all(buf.slice_to(n));
-        }
-        u
+        self.as_slice().utf16_units().collect::<Vec<u16>>()
     }
 
     /// Given a string, make a new string with repeated copies of it.
@@ -1103,7 +1097,7 @@ fn test_unsafe_slice() {
         assert_eq!("bc", unsafe {raw::slice_bytes("abc", 1, 3)});
         assert_eq!("", unsafe {raw::slice_bytes("abc", 1, 1)});
         fn a_million_letter_a() -> String {
-            let mut i = 0;
+            let mut i = 0u;
             let mut rs = String::new();
             while i < 100000 {
                 rs.push_str("aaaaaaaaaa");
@@ -1112,7 +1106,7 @@ fn a_million_letter_a() -> String {
             rs
         }
         fn half_a_million_letter_a() -> String {
-            let mut i = 0;
+            let mut i = 0u;
             let mut rs = String::new();
             while i < 100000 {
                 rs.push_str("aaaaa");
@@ -1220,7 +1214,7 @@ fn test_slice() {
         assert_eq!("华", data.slice(30, 33));
 
         fn a_million_letter_x() -> String {
-            let mut i = 0;
+            let mut i = 0u;
             let mut rs = String::new();
             while i < 100000 {
                 rs.push_str("华华华华华华华华华华");
@@ -1229,7 +1223,7 @@ fn a_million_letter_x() -> String {
             rs
         }
         fn half_a_million_letter_x() -> String {
-            let mut i = 0;
+            let mut i = 0u;
             let mut rs = String::new();
             while i < 100000 {
                 rs.push_str("华华华华华");
@@ -1619,14 +1613,17 @@ fn test_utf16() {
 
         for p in pairs.iter() {
             let (s, u) = (*p).clone();
+            let s_as_utf16 = s.as_slice().utf16_units().collect::<Vec<u16>>();
+            let u_as_string = from_utf16(u.as_slice()).unwrap();
+
             assert!(is_utf16(u.as_slice()));
-            assert_eq!(s.to_utf16(), u);
+            assert_eq!(s_as_utf16, u);
 
-            assert_eq!(from_utf16(u.as_slice()).unwrap(), s);
+            assert_eq!(u_as_string, s);
             assert_eq!(from_utf16_lossy(u.as_slice()), s);
 
-            assert_eq!(from_utf16(s.to_utf16().as_slice()).unwrap(), s);
-            assert_eq!(from_utf16(u.as_slice()).unwrap().to_utf16(), u);
+            assert_eq!(from_utf16(s_as_utf16.as_slice()).unwrap(), s);
+            assert_eq!(u_as_string.as_slice().utf16_units().collect::<Vec<u16>>(), u);
         }
     }
 
index 568baa6fc405236465060b8273edf52cd2deeb05..becceffe6d0270254fe0017f0c3be5e4cee6abb9 100644 (file)
@@ -56,23 +56,11 @@ fn eq(&self, other: &TreeMap<K, V>) -> bool {
     }
 }
 
-// Lexicographical comparison
-fn lt<K: PartialOrd + Ord, V: PartialOrd>(a: &TreeMap<K, V>,
-                                 b: &TreeMap<K, V>) -> bool {
-    // the Zip iterator is as long as the shortest of a and b.
-    for ((key_a, value_a), (key_b, value_b)) in a.iter().zip(b.iter()) {
-        if *key_a < *key_b { return true; }
-        if *key_a > *key_b { return false; }
-        if *value_a < *value_b { return true; }
-        if *value_a > *value_b { return false; }
-    }
-
-    a.len() < b.len()
-}
-
-impl<K: PartialOrd + Ord, V: PartialOrd> PartialOrd for TreeMap<K, V> {
+impl<K: Ord, V: PartialOrd> PartialOrd for TreeMap<K, V> {
     #[inline]
-    fn lt(&self, other: &TreeMap<K, V>) -> bool { lt(self, other) }
+    fn partial_cmp(&self, other: &TreeMap<K, V>) -> Option<Ordering> {
+        iter::order::partial_cmp(self.iter(), other.iter())
+    }
 }
 
 impl<K: Ord + Show, V: Show> Show for TreeMap<K, V> {
@@ -568,9 +556,11 @@ impl<T: PartialEq + Ord> PartialEq for TreeSet<T> {
     fn eq(&self, other: &TreeSet<T>) -> bool { self.map == other.map }
 }
 
-impl<T: PartialOrd + Ord> PartialOrd for TreeSet<T> {
+impl<T: Ord> PartialOrd for TreeSet<T> {
     #[inline]
-    fn lt(&self, other: &TreeSet<T>) -> bool { self.map < other.map }
+    fn partial_cmp(&self, other: &TreeSet<T>) -> Option<Ordering> {
+        self.map.partial_cmp(&other.map)
+    }
 }
 
 impl<T: Ord + Show> Show for TreeSet<T> {
index 8e6e86ce36ecd6a3e34d48e23868ab087ae9bef3..2ffc168f82c0eef4b4d77244a873ed3cd327d1a6 100644 (file)
@@ -389,8 +389,8 @@ fn eq(&self, other: &Vec<T>) -> bool {
 
 impl<T: PartialOrd> PartialOrd for Vec<T> {
     #[inline]
-    fn lt(&self, other: &Vec<T>) -> bool {
-        self.as_slice() < other.as_slice()
+    fn partial_cmp(&self, other: &Vec<T>) -> Option<Ordering> {
+        self.as_slice().partial_cmp(&other.as_slice())
     }
 }
 
index 4a35dde08eb5c6913d2f9ff7a681feed2d4887f7..8021fa50d8f4647ac3155d8050f9d329c6aff435 100644 (file)
@@ -115,179 +115,3 @@ fn as_mut<T: 'static>(self) -> Option<&'a mut T> {
         }
     }
 }
-
-#[cfg(test)]
-mod tests {
-    use prelude::*;
-    use super::*;
-    use realstd::owned::{Box, AnyOwnExt};
-    use realstd::str::Str;
-
-    #[deriving(PartialEq, Show)]
-    struct Test;
-
-    static TEST: &'static str = "Test";
-
-    #[test]
-    fn any_referenced() {
-        let (a, b, c) = (&5u as &Any, &TEST as &Any, &Test as &Any);
-
-        assert!(a.is::<uint>());
-        assert!(!b.is::<uint>());
-        assert!(!c.is::<uint>());
-
-        assert!(!a.is::<&'static str>());
-        assert!(b.is::<&'static str>());
-        assert!(!c.is::<&'static str>());
-
-        assert!(!a.is::<Test>());
-        assert!(!b.is::<Test>());
-        assert!(c.is::<Test>());
-    }
-
-    #[test]
-    fn any_owning() {
-        let (a, b, c) = (box 5u as Box<Any>, box TEST as Box<Any>, box Test as Box<Any>);
-
-        assert!(a.is::<uint>());
-        assert!(!b.is::<uint>());
-        assert!(!c.is::<uint>());
-
-        assert!(!a.is::<&'static str>());
-        assert!(b.is::<&'static str>());
-        assert!(!c.is::<&'static str>());
-
-        assert!(!a.is::<Test>());
-        assert!(!b.is::<Test>());
-        assert!(c.is::<Test>());
-    }
-
-    #[test]
-    fn any_as_ref() {
-        let a = &5u as &Any;
-
-        match a.as_ref::<uint>() {
-            Some(&5) => {}
-            x => fail!("Unexpected value {}", x)
-        }
-
-        match a.as_ref::<Test>() {
-            None => {}
-            x => fail!("Unexpected value {}", x)
-        }
-    }
-
-    #[test]
-    fn any_as_mut() {
-        let mut a = 5u;
-        let mut b = box 7u;
-
-        let a_r = &mut a as &mut Any;
-        let tmp: &mut uint = &mut *b;
-        let b_r = tmp as &mut Any;
-
-        match a_r.as_mut::<uint>() {
-            Some(x) => {
-                assert_eq!(*x, 5u);
-                *x = 612;
-            }
-            x => fail!("Unexpected value {}", x)
-        }
-
-        match b_r.as_mut::<uint>() {
-            Some(x) => {
-                assert_eq!(*x, 7u);
-                *x = 413;
-            }
-            x => fail!("Unexpected value {}", x)
-        }
-
-        match a_r.as_mut::<Test>() {
-            None => (),
-            x => fail!("Unexpected value {}", x)
-        }
-
-        match b_r.as_mut::<Test>() {
-            None => (),
-            x => fail!("Unexpected value {}", x)
-        }
-
-        match a_r.as_mut::<uint>() {
-            Some(&612) => {}
-            x => fail!("Unexpected value {}", x)
-        }
-
-        match b_r.as_mut::<uint>() {
-            Some(&413) => {}
-            x => fail!("Unexpected value {}", x)
-        }
-    }
-
-    #[test]
-    fn any_move() {
-        use realstd::any::Any;
-        use realstd::result::{Ok, Err};
-        let a = box 8u as Box<Any>;
-        let b = box Test as Box<Any>;
-
-        match a.move::<uint>() {
-            Ok(a) => { assert!(a == box 8u); }
-            Err(..) => fail!()
-        }
-        match b.move::<Test>() {
-            Ok(a) => { assert!(a == box Test); }
-            Err(..) => fail!()
-        }
-
-        let a = box 8u as Box<Any>;
-        let b = box Test as Box<Any>;
-
-        assert!(a.move::<Box<Test>>().is_err());
-        assert!(b.move::<Box<uint>>().is_err());
-    }
-
-    #[test]
-    fn test_show() {
-        use realstd::to_str::ToStr;
-        let a = box 8u as Box<::realstd::any::Any>;
-        let b = box Test as Box<::realstd::any::Any>;
-        let a_str = a.to_str();
-        let b_str = b.to_str();
-        assert_eq!(a_str.as_slice(), "Box<Any>");
-        assert_eq!(b_str.as_slice(), "Box<Any>");
-
-        let a = &8u as &Any;
-        let b = &Test as &Any;
-        let s = format!("{}", a);
-        assert_eq!(s.as_slice(), "&Any");
-        let s = format!("{}", b);
-        assert_eq!(s.as_slice(), "&Any");
-    }
-
-    #[test]
-    fn any_fixed_vec() {
-        let test = [0u, ..8];
-        let test = &test as &Any;
-        assert!(test.is::<[uint, ..8]>());
-        assert!(!test.is::<[uint, ..10]>());
-    }
-}
-
-#[cfg(test)]
-mod bench {
-    extern crate test;
-
-    use any::{Any, AnyRefExt};
-    use option::Some;
-    use self::test::Bencher;
-
-    #[bench]
-    fn bench_as_ref(b: &mut Bencher) {
-        b.iter(|| {
-            let mut x = 0i;
-            let mut y = &mut x as &mut Any;
-            test::black_box(&mut y);
-            test::black_box(y.as_ref::<int>() == Some(&0));
-        });
-    }
-}
index 13979bb648fdaa6702fd6aa655f191c22a8baac2..971799acc7862e61efb2112990ddf8fa045a5bef 100644 (file)
@@ -693,97 +693,3 @@ pub fn fence(order: Ordering) {
         }
     }
 }
-
-#[cfg(test)]
-mod test {
-    use super::*;
-
-    #[test]
-    fn bool_() {
-        let a = AtomicBool::new(false);
-        assert_eq!(a.compare_and_swap(false, true, SeqCst), false);
-        assert_eq!(a.compare_and_swap(false, true, SeqCst), true);
-
-        a.store(false, SeqCst);
-        assert_eq!(a.compare_and_swap(false, true, SeqCst), false);
-    }
-
-    #[test]
-    fn bool_and() {
-        let a = AtomicBool::new(true);
-        assert_eq!(a.fetch_and(false, SeqCst),true);
-        assert_eq!(a.load(SeqCst),false);
-    }
-
-    #[test]
-    fn uint_and() {
-        let x = AtomicUint::new(0xf731);
-        assert_eq!(x.fetch_and(0x137f, SeqCst), 0xf731);
-        assert_eq!(x.load(SeqCst), 0xf731 & 0x137f);
-    }
-
-    #[test]
-    fn uint_or() {
-        let x = AtomicUint::new(0xf731);
-        assert_eq!(x.fetch_or(0x137f, SeqCst), 0xf731);
-        assert_eq!(x.load(SeqCst), 0xf731 | 0x137f);
-    }
-
-    #[test]
-    fn uint_xor() {
-        let x = AtomicUint::new(0xf731);
-        assert_eq!(x.fetch_xor(0x137f, SeqCst), 0xf731);
-        assert_eq!(x.load(SeqCst), 0xf731 ^ 0x137f);
-    }
-
-    #[test]
-    fn int_and() {
-        let x = AtomicInt::new(0xf731);
-        assert_eq!(x.fetch_and(0x137f, SeqCst), 0xf731);
-        assert_eq!(x.load(SeqCst), 0xf731 & 0x137f);
-    }
-
-    #[test]
-    fn int_or() {
-        let x = AtomicInt::new(0xf731);
-        assert_eq!(x.fetch_or(0x137f, SeqCst), 0xf731);
-        assert_eq!(x.load(SeqCst), 0xf731 | 0x137f);
-    }
-
-    #[test]
-    fn int_xor() {
-        let x = AtomicInt::new(0xf731);
-        assert_eq!(x.fetch_xor(0x137f, SeqCst), 0xf731);
-        assert_eq!(x.load(SeqCst), 0xf731 ^ 0x137f);
-    }
-
-    static mut S_BOOL : AtomicBool = INIT_ATOMIC_BOOL;
-    static mut S_INT  : AtomicInt  = INIT_ATOMIC_INT;
-    static mut S_UINT : AtomicUint = INIT_ATOMIC_UINT;
-
-    #[test]
-    fn static_init() {
-        unsafe {
-            assert!(!S_BOOL.load(SeqCst));
-            assert!(S_INT.load(SeqCst) == 0);
-            assert!(S_UINT.load(SeqCst) == 0);
-        }
-    }
-
-    #[test]
-    fn different_sizes() {
-        unsafe {
-            let mut slot = 0u16;
-            assert_eq!(super::atomic_swap(&mut slot, 1, SeqCst), 0);
-
-            let mut slot = 0u8;
-            assert_eq!(super::atomic_compare_and_swap(&mut slot, 1, 2, SeqCst), 0);
-
-            let slot = 0u32;
-            assert_eq!(super::atomic_load(&slot, SeqCst), 0);
-
-            let mut slot = 0u64;
-            super::atomic_store(&mut slot, 2, SeqCst);
-        }
-    }
-}
index ab701b76026f432a3fb81bf24aa9774169e43099..355ee7c7a16f010c48b2f954b4d58eef7e2adbcb 100644 (file)
 //!
 //! fn main() {
 //!     let shared_map: Rc<RefCell<_>> = Rc::new(RefCell::new(HashMap::new()));
-//!     shared_map.borrow_mut().insert("africa", 92388);
-//!     shared_map.borrow_mut().insert("kyoto", 11837);
-//!     shared_map.borrow_mut().insert("piccadilly", 11826);
-//!     shared_map.borrow_mut().insert("marbles", 38);
+//!     shared_map.borrow_mut().insert("africa", 92388i);
+//!     shared_map.borrow_mut().insert("kyoto", 11837i);
+//!     shared_map.borrow_mut().insert("piccadilly", 11826i);
+//!     shared_map.borrow_mut().insert("marbles", 38i);
 //! }
 //! ```
 //!
@@ -383,132 +383,3 @@ fn deref_mut<'a>(&'a mut self) -> &'a mut T {
         unsafe { &mut *self._parent.value.get() }
     }
 }
-
-#[cfg(test)]
-mod test {
-    use super::*;
-    use mem::drop;
-
-    #[test]
-    fn smoketest_cell() {
-        let x = Cell::new(10i);
-        assert!(x == Cell::new(10));
-        assert!(x.get() == 10);
-        x.set(20);
-        assert!(x == Cell::new(20));
-        assert!(x.get() == 20);
-
-        let y = Cell::new((30i, 40i));
-        assert!(y == Cell::new((30, 40)));
-        assert!(y.get() == (30, 40));
-    }
-
-    #[test]
-    fn cell_has_sensible_show() {
-        use str::StrSlice;
-        use realstd::str::Str;
-
-        let x = Cell::new("foo bar");
-        assert!(format!("{}", x).as_slice().contains(x.get()));
-
-        x.set("baz qux");
-        assert!(format!("{}", x).as_slice().contains(x.get()));
-    }
-
-    #[test]
-    fn ref_and_refmut_have_sensible_show() {
-        use str::StrSlice;
-        use realstd::str::Str;
-
-        let refcell = RefCell::new("foo");
-
-        let refcell_refmut = refcell.borrow_mut();
-        assert!(format!("{}", refcell_refmut).as_slice().contains("foo"));
-        drop(refcell_refmut);
-
-        let refcell_ref = refcell.borrow();
-        assert!(format!("{}", refcell_ref).as_slice().contains("foo"));
-        drop(refcell_ref);
-    }
-
-    #[test]
-    fn double_imm_borrow() {
-        let x = RefCell::new(0);
-        let _b1 = x.borrow();
-        x.borrow();
-    }
-
-    #[test]
-    fn no_mut_then_imm_borrow() {
-        let x = RefCell::new(0);
-        let _b1 = x.borrow_mut();
-        assert!(x.try_borrow().is_none());
-    }
-
-    #[test]
-    fn no_imm_then_borrow_mut() {
-        let x = RefCell::new(0);
-        let _b1 = x.borrow();
-        assert!(x.try_borrow_mut().is_none());
-    }
-
-    #[test]
-    fn no_double_borrow_mut() {
-        let x = RefCell::new(0);
-        let _b1 = x.borrow_mut();
-        assert!(x.try_borrow_mut().is_none());
-    }
-
-    #[test]
-    fn imm_release_borrow_mut() {
-        let x = RefCell::new(0);
-        {
-            let _b1 = x.borrow();
-        }
-        x.borrow_mut();
-    }
-
-    #[test]
-    fn mut_release_borrow_mut() {
-        let x = RefCell::new(0);
-        {
-            let _b1 = x.borrow_mut();
-        }
-        x.borrow();
-    }
-
-    #[test]
-    fn double_borrow_single_release_no_borrow_mut() {
-        let x = RefCell::new(0);
-        let _b1 = x.borrow();
-        {
-            let _b2 = x.borrow();
-        }
-        assert!(x.try_borrow_mut().is_none());
-    }
-
-    #[test]
-    #[should_fail]
-    fn discard_doesnt_unborrow() {
-        let x = RefCell::new(0);
-        let _b = x.borrow();
-        let _ = _b;
-        let _b = x.borrow_mut();
-    }
-
-    #[test]
-    #[allow(experimental)]
-    fn clone_ref_updates_flag() {
-        let x = RefCell::new(0);
-        {
-            let b1 = x.borrow();
-            assert!(x.try_borrow_mut().is_none());
-            {
-                let _b2 = clone_ref(&b1);
-                assert!(x.try_borrow_mut().is_none());
-            }
-            assert!(x.try_borrow_mut().is_none());
-        }
-        assert!(x.try_borrow_mut().is_some());
-    }
-}
index c188ec75ddd09c3f9bc07b6bc9b341ee1f9657c3..da67772d0f1229c3a311bfeaf2166c549c6f1037 100644 (file)
@@ -602,205 +602,3 @@ fn encode_utf16(&self, dst: &mut [u16]) -> uint {
 }
 
 
-#[cfg(test)]
-mod test {
-    use super::{escape_unicode, escape_default};
-
-    use char::Char;
-    use slice::ImmutableVector;
-    use option::{Some, None};
-    use realstd::string::String;
-    use realstd::str::Str;
-
-    #[test]
-    fn test_is_lowercase() {
-        assert!('a'.is_lowercase());
-        assert!('ö'.is_lowercase());
-        assert!('ß'.is_lowercase());
-        assert!(!'Ü'.is_lowercase());
-        assert!(!'P'.is_lowercase());
-    }
-
-    #[test]
-    fn test_is_uppercase() {
-        assert!(!'h'.is_uppercase());
-        assert!(!'ä'.is_uppercase());
-        assert!(!'ß'.is_uppercase());
-        assert!('Ö'.is_uppercase());
-        assert!('T'.is_uppercase());
-    }
-
-    #[test]
-    fn test_is_whitespace() {
-        assert!(' '.is_whitespace());
-        assert!('\u2007'.is_whitespace());
-        assert!('\t'.is_whitespace());
-        assert!('\n'.is_whitespace());
-        assert!(!'a'.is_whitespace());
-        assert!(!'_'.is_whitespace());
-        assert!(!'\u0000'.is_whitespace());
-    }
-
-    #[test]
-    fn test_to_digit() {
-        assert_eq!('0'.to_digit(10u), Some(0u));
-        assert_eq!('1'.to_digit(2u), Some(1u));
-        assert_eq!('2'.to_digit(3u), Some(2u));
-        assert_eq!('9'.to_digit(10u), Some(9u));
-        assert_eq!('a'.to_digit(16u), Some(10u));
-        assert_eq!('A'.to_digit(16u), Some(10u));
-        assert_eq!('b'.to_digit(16u), Some(11u));
-        assert_eq!('B'.to_digit(16u), Some(11u));
-        assert_eq!('z'.to_digit(36u), Some(35u));
-        assert_eq!('Z'.to_digit(36u), Some(35u));
-        assert_eq!(' '.to_digit(10u), None);
-        assert_eq!('$'.to_digit(36u), None);
-    }
-
-    #[test]
-    fn test_to_lowercase() {
-        assert_eq!('A'.to_lowercase(), 'a');
-        assert_eq!('Ö'.to_lowercase(), 'ö');
-        assert_eq!('ß'.to_lowercase(), 'ß');
-        assert_eq!('Ü'.to_lowercase(), 'ü');
-        assert_eq!('💩'.to_lowercase(), '💩');
-        assert_eq!('Σ'.to_lowercase(), 'σ');
-        assert_eq!('Τ'.to_lowercase(), 'τ');
-        assert_eq!('Ι'.to_lowercase(), 'ι');
-        assert_eq!('Γ'.to_lowercase(), 'γ');
-        assert_eq!('Μ'.to_lowercase(), 'μ');
-        assert_eq!('Α'.to_lowercase(), 'α');
-        assert_eq!('Σ'.to_lowercase(), 'σ');
-    }
-
-    #[test]
-    fn test_to_uppercase() {
-        assert_eq!('a'.to_uppercase(), 'A');
-        assert_eq!('ö'.to_uppercase(), 'Ö');
-        assert_eq!('ß'.to_uppercase(), 'ß'); // not ẞ: Latin capital letter sharp s
-        assert_eq!('ü'.to_uppercase(), 'Ü');
-        assert_eq!('💩'.to_uppercase(), '💩');
-
-        assert_eq!('σ'.to_uppercase(), 'Σ');
-        assert_eq!('τ'.to_uppercase(), 'Τ');
-        assert_eq!('ι'.to_uppercase(), 'Ι');
-        assert_eq!('γ'.to_uppercase(), 'Γ');
-        assert_eq!('μ'.to_uppercase(), 'Μ');
-        assert_eq!('α'.to_uppercase(), 'Α');
-        assert_eq!('ς'.to_uppercase(), 'Σ');
-    }
-
-    #[test]
-    fn test_is_control() {
-        assert!('\u0000'.is_control());
-        assert!('\u0003'.is_control());
-        assert!('\u0006'.is_control());
-        assert!('\u0009'.is_control());
-        assert!('\u007f'.is_control());
-        assert!('\u0092'.is_control());
-        assert!(!'\u0020'.is_control());
-        assert!(!'\u0055'.is_control());
-        assert!(!'\u0068'.is_control());
-    }
-
-    #[test]
-    fn test_is_digit() {
-       assert!('2'.is_digit());
-       assert!('7'.is_digit());
-       assert!(!'c'.is_digit());
-       assert!(!'i'.is_digit());
-       assert!(!'z'.is_digit());
-       assert!(!'Q'.is_digit());
-    }
-
-    #[test]
-    fn test_escape_default() {
-        fn string(c: char) -> String {
-            let mut result = String::new();
-            escape_default(c, |c| { result.push_char(c); });
-            return result;
-        }
-        let s = string('\n');
-        assert_eq!(s.as_slice(), "\\n");
-        let s = string('\r');
-        assert_eq!(s.as_slice(), "\\r");
-        let s = string('\'');
-        assert_eq!(s.as_slice(), "\\'");
-        let s = string('"');
-        assert_eq!(s.as_slice(), "\\\"");
-        let s = string(' ');
-        assert_eq!(s.as_slice(), " ");
-        let s = string('a');
-        assert_eq!(s.as_slice(), "a");
-        let s = string('~');
-        assert_eq!(s.as_slice(), "~");
-        let s = string('\x00');
-        assert_eq!(s.as_slice(), "\\x00");
-        let s = string('\x1f');
-        assert_eq!(s.as_slice(), "\\x1f");
-        let s = string('\x7f');
-        assert_eq!(s.as_slice(), "\\x7f");
-        let s = string('\xff');
-        assert_eq!(s.as_slice(), "\\xff");
-        let s = string('\u011b');
-        assert_eq!(s.as_slice(), "\\u011b");
-        let s = string('\U0001d4b6');
-        assert_eq!(s.as_slice(), "\\U0001d4b6");
-    }
-
-    #[test]
-    fn test_escape_unicode() {
-        fn string(c: char) -> String {
-            let mut result = String::new();
-            escape_unicode(c, |c| { result.push_char(c); });
-            return result;
-        }
-        let s = string('\x00');
-        assert_eq!(s.as_slice(), "\\x00");
-        let s = string('\n');
-        assert_eq!(s.as_slice(), "\\x0a");
-        let s = string(' ');
-        assert_eq!(s.as_slice(), "\\x20");
-        let s = string('a');
-        assert_eq!(s.as_slice(), "\\x61");
-        let s = string('\u011b');
-        assert_eq!(s.as_slice(), "\\u011b");
-        let s = string('\U0001d4b6');
-        assert_eq!(s.as_slice(), "\\U0001d4b6");
-    }
-
-    #[test]
-    fn test_to_str() {
-        use realstd::to_str::ToStr;
-        let s = 't'.to_str();
-        assert_eq!(s.as_slice(), "t");
-    }
-
-    #[test]
-    fn test_encode_utf8() {
-        fn check(input: char, expect: &[u8]) {
-            let mut buf = [0u8, ..4];
-            let n = input.encode_utf8(buf /* as mut slice! */);
-            assert_eq!(buf.slice_to(n), expect);
-        }
-
-        check('x', [0x78]);
-        check('\u00e9', [0xc3, 0xa9]);
-        check('\ua66e', [0xea, 0x99, 0xae]);
-        check('\U0001f4a9', [0xf0, 0x9f, 0x92, 0xa9]);
-    }
-
-    #[test]
-    fn test_encode_utf16() {
-        fn check(input: char, expect: &[u16]) {
-            let mut buf = [0u16, ..2];
-            let n = input.encode_utf16(buf /* as mut slice! */);
-            assert_eq!(buf.slice_to(n), expect);
-        }
-
-        check('x', [0x0078]);
-        check('\u00e9', [0x00e9]);
-        check('\ua66e', [0xa66e]);
-        check('\U0001f4a9', [0xd83d, 0xdca9]);
-    }
-}
index 04f01db314797a33e45fe32ac110458a99e8e75d..247f63115a783be9dba296ec49c69a7f8b816bd4 100644 (file)
@@ -110,63 +110,3 @@ fn clone(&self) -> extern "Rust" fn($($A),*) -> ReturnType { *self }
 extern_fn_clone!(A, B, C, D, E, F, G)
 extern_fn_clone!(A, B, C, D, E, F, G, H)
 
-#[cfg(test)]
-mod test {
-    use prelude::*;
-    use realstd::owned::Box;
-    use realstd::gc::{Gc, GC};
-
-    fn realclone<T: ::realstd::clone::Clone>(t: &T) -> T {
-        use realstd::clone::Clone;
-        t.clone()
-    }
-
-    fn realclone_from<T: ::realstd::clone::Clone>(t1: &mut T, t2: &T) {
-        use realstd::clone::Clone;
-        t1.clone_from(t2)
-    }
-
-    #[test]
-    fn test_owned_clone() {
-        let a = box 5i;
-        let b: Box<int> = realclone(&a);
-        assert!(a == b);
-    }
-
-    #[test]
-    fn test_managed_clone() {
-        let a = box(GC) 5i;
-        let b: Gc<int> = realclone(&a);
-        assert!(a == b);
-    }
-
-    #[test]
-    fn test_borrowed_clone() {
-        let x = 5i;
-        let y: &int = &x;
-        let z: &int = (&y).clone();
-        assert_eq!(*z, 5);
-    }
-
-    #[test]
-    fn test_clone_from() {
-        let a = box 5i;
-        let mut b = box 10i;
-        realclone_from(&mut b, &a);
-        assert_eq!(*b, 5);
-    }
-
-    #[test]
-    fn test_extern_fn_clone() {
-        trait Empty {}
-        impl Empty for int {}
-
-        fn test_fn_a() -> f64 { 1.0 }
-        fn test_fn_b<T: Empty>(x: T) -> T { x }
-        fn test_fn_c(_: int, _: f64, _: int, _: int, _: int) {}
-
-        let _ = test_fn_a.clone();
-        let _ = test_fn_b::<int>.clone();
-        let _ = test_fn_c.clone();
-    }
-}
index d7a3edccfd822115c5f9ec55f8466061fb5ab285..8696d385c44884d6d257b03818de2360e7f574c3 100644 (file)
 //! assert!(SketchyNum {num: 25} != SketchyNum {num: 57});
 //! ```
 
+use option::{Option, Some};
+#[cfg(stage0)]
+use option::None;
+
 /// Trait for values that can be compared for equality and inequality.
 ///
 /// This trait allows for partial equality, for types that do not have an
@@ -86,11 +90,11 @@ fn assert_receiver_is_total_eq(&self) {}
 #[deriving(Clone, PartialEq, Show)]
 pub enum Ordering {
    /// An ordering where a compared value is less [than another].
-   Less = -1,
+   Less = -1i,
    /// An ordering where a compared value is equal [to another].
-   Equal = 0,
+   Equal = 0i,
    /// An ordering where a compared value is greater [than another].
-   Greater = 1
+   Greater = 1i,
 }
 
 /// Trait for types that form a [total order](
@@ -127,7 +131,9 @@ fn cmp(&self, other: &Ordering) -> Ordering {
 
 impl PartialOrd for Ordering {
     #[inline]
-    fn lt(&self, other: &Ordering) -> bool { (*self as int) < (*other as int) }
+    fn partial_cmp(&self, other: &Ordering) -> Option<Ordering> {
+        (*self as int).partial_cmp(&(*other as int))
+    }
 }
 
 /// Combine orderings, lexically.
@@ -145,7 +151,7 @@ pub fn lexical_ordering(o1: Ordering, o2: Ordering) -> Ordering {
 
 /// Trait for values that can be compared for a sort-order.
 ///
-/// PartialOrd only requires implementation of the `lt` method,
+/// PartialOrd only requires implementation of the `partial_cmp` method,
 /// with the others generated from default implementations.
 ///
 /// However it remains possible to implement the others separately for types
@@ -154,20 +160,57 @@ pub fn lexical_ordering(o1: Ordering, o2: Ordering) -> Ordering {
 /// 5.11).
 #[lang="ord"]
 pub trait PartialOrd: PartialEq {
+    /// This method returns an ordering between `self` and `other` values
+    /// if one exists.
+    #[cfg(stage0)]
+    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
+        match (!self.lt(other), !other.lt(self)) {
+            (false, false) => None,
+            (false, true) => Some(Less),
+            (true, false) => Some(Greater),
+            (true, true) => Some(Equal),
+        }
+    }
+
+    /// This method returns an ordering between `self` and `other` values
+    /// if one exists.
+    #[cfg(not(stage0))]
+    fn partial_cmp(&self, other: &Self) -> Option<Ordering>;
+
     /// This method tests less than (for `self` and `other`) and is used by the `<` operator.
-    fn lt(&self, other: &Self) -> bool;
+    fn lt(&self, other: &Self) -> bool {
+        match self.partial_cmp(other) {
+            Some(Less) => true,
+            _ => false,
+        }
+    }
 
     /// This method tests less than or equal to (`<=`).
     #[inline]
-    fn le(&self, other: &Self) -> bool { !other.lt(self) }
+    fn le(&self, other: &Self) -> bool {
+        match self.partial_cmp(other) {
+            Some(Less) | Some(Equal) => true,
+            _ => false,
+        }
+    }
 
     /// This method tests greater than (`>`).
     #[inline]
-    fn gt(&self, other: &Self) -> bool {  other.lt(self) }
+    fn gt(&self, other: &Self) -> bool {
+        match self.partial_cmp(other) {
+            Some(Greater) => true,
+            _ => false,
+        }
+    }
 
     /// This method tests greater than or equal to (`>=`).
     #[inline]
-    fn ge(&self, other: &Self) -> bool { !self.lt(other) }
+    fn ge(&self, other: &Self) -> bool {
+        match self.partial_cmp(other) {
+            Some(Greater) | Some(Equal) => true,
+            _ => false,
+        }
+    }
 }
 
 /// The equivalence relation. Two values may be equivalent even if they are
@@ -192,10 +235,10 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T {
 }
 
 // Implementation of PartialEq, Eq, PartialOrd and Ord for primitive types
-#[cfg(not(test))]
 mod impls {
     use cmp::{PartialOrd, Ord, PartialEq, Eq, Ordering,
               Less, Greater, Equal};
+    use option::{Option, Some, None};
 
     macro_rules! eq_impl(
         ($($t:ty)*) => ($(
@@ -228,6 +271,15 @@ impl Eq for $t {}
     macro_rules! ord_impl(
         ($($t:ty)*) => ($(
             impl PartialOrd for $t {
+                #[inline]
+                fn partial_cmp(&self, other: &$t) -> Option<Ordering> {
+                    match (self <= other, self >= other) {
+                        (false, false) => None,
+                        (false, true) => Some(Greater),
+                        (true, false) => Some(Less),
+                        (true, true) => Some(Equal),
+                    }
+                }
                 #[inline]
                 fn lt(&self, other: &$t) -> bool { (*self) < (*other) }
                 #[inline]
@@ -242,13 +294,15 @@ fn gt(&self, other: &$t) -> bool { (*self) > (*other) }
 
     impl PartialOrd for () {
         #[inline]
-        fn lt(&self, _other: &()) -> bool { false }
+        fn partial_cmp(&self, _: &()) -> Option<Ordering> {
+            Some(Equal)
+        }
     }
 
     impl PartialOrd for bool {
         #[inline]
-        fn lt(&self, other: &bool) -> bool {
-            (*self as u8) < (*other as u8)
+        fn partial_cmp(&self, other: &bool) -> Option<Ordering> {
+            (*self as u8).partial_cmp(&(*other as u8))
         }
     }
 
@@ -289,6 +343,10 @@ fn eq(&self, other: & &'a T) -> bool { *(*self) == *(*other) }
         fn ne(&self, other: & &'a T) -> bool { *(*self) != *(*other) }
     }
     impl<'a, T: PartialOrd> PartialOrd for &'a T {
+        #[inline]
+        fn partial_cmp(&self, other: &&'a T) -> Option<Ordering> {
+            (**self).partial_cmp(*other)
+        }
         #[inline]
         fn lt(&self, other: & &'a T) -> bool { *(*self) < *(*other) }
         #[inline]
@@ -312,6 +370,10 @@ fn eq(&self, other: &&'a mut T) -> bool { **self == *(*other) }
         fn ne(&self, other: &&'a mut T) -> bool { **self != *(*other) }
     }
     impl<'a, T: PartialOrd> PartialOrd for &'a mut T {
+        #[inline]
+        fn partial_cmp(&self, other: &&'a mut T) -> Option<Ordering> {
+            (**self).partial_cmp(*other)
+        }
         #[inline]
         fn lt(&self, other: &&'a mut T) -> bool { **self < **other }
         #[inline]
@@ -327,66 +389,3 @@ fn cmp(&self, other: &&'a mut T) -> Ordering { (**self).cmp(*other) }
     }
     impl<'a, T: Eq> Eq for &'a mut T {}
 }
-
-#[cfg(test)]
-mod test {
-    use super::lexical_ordering;
-
-    #[test]
-    fn test_int_totalord() {
-        assert_eq!(5u.cmp(&10), Less);
-        assert_eq!(10u.cmp(&5), Greater);
-        assert_eq!(5u.cmp(&5), Equal);
-        assert_eq!((-5u).cmp(&12), Less);
-        assert_eq!(12u.cmp(-5), Greater);
-    }
-
-    #[test]
-    fn test_mut_int_totalord() {
-        assert_eq!((&mut 5u).cmp(&10), Less);
-        assert_eq!((&mut 10u).cmp(&5), Greater);
-        assert_eq!((&mut 5u).cmp(&5), Equal);
-        assert_eq!((&mut -5u).cmp(&12), Less);
-        assert_eq!((&mut 12u).cmp(-5), Greater);
-    }
-
-    #[test]
-    fn test_ordering_order() {
-        assert!(Less < Equal);
-        assert_eq!(Greater.cmp(&Less), Greater);
-    }
-
-    #[test]
-    fn test_lexical_ordering() {
-        fn t(o1: Ordering, o2: Ordering, e: Ordering) {
-            assert_eq!(lexical_ordering(o1, o2), e);
-        }
-
-        let xs = [Less, Equal, Greater];
-        for &o in xs.iter() {
-            t(Less, o, Less);
-            t(Equal, o, o);
-            t(Greater, o, Greater);
-         }
-    }
-
-    #[test]
-    fn test_user_defined_eq() {
-        // Our type.
-        struct SketchyNum {
-            num : int
-        }
-
-        // Our implementation of `PartialEq` to support `==` and `!=`.
-        impl PartialEq for SketchyNum {
-            // Our custom eq allows numbers which are near each other to be equal! :D
-            fn eq(&self, other: &SketchyNum) -> bool {
-                (self.num - other.num).abs() < 5
-            }
-        }
-
-        // Now these binary operators will work when applied!
-        assert!(SketchyNum {num: 37} == SketchyNum {num: 34});
-        assert!(SketchyNum {num: 25} != SketchyNum {num: 57});
-    }
-}
index c64bd6201faf356fcb15b043bab6c0d3d00d5df7..4bc39db8ecf0932e2baef0c8e67406ed325f5110 100644 (file)
 #![allow(dead_code, missing_doc)]
 
 use fmt;
-#[cfg(not(test))] use intrinsics;
+use intrinsics;
 
 #[cold] #[inline(never)] // this is the slow path, always
 #[lang="fail_"]
-#[cfg(not(test))]
 fn fail_(expr: &'static str, file: &'static str, line: uint) -> ! {
     format_args!(|args| -> () {
         begin_unwind(args, file, line);
@@ -46,7 +45,6 @@ fn fail_(expr: &'static str, file: &'static str, line: uint) -> ! {
 
 #[cold]
 #[lang="fail_bounds_check"]
-#[cfg(not(test))]
 fn fail_bounds_check(file: &'static str, line: uint,
                      index: uint, len: uint) -> ! {
     format_args!(|args| -> () {
index ab151460537af4f8edf141457f426925fffaa43e..514b3f90df7c0dfde86baa6d9b56f9bd93da9072 100644 (file)
@@ -115,55 +115,3 @@ fn drop(&mut self) {
     }
 }
 
-#[cfg(test)]
-mod test {
-    use super::{try_finally, Finally};
-    use realstd::task::failing;
-
-    #[test]
-    fn test_success() {
-        let mut i = 0i;
-        try_finally(
-            &mut i, (),
-            |i, ()| {
-                *i = 10;
-            },
-            |i| {
-                assert!(!failing());
-                assert_eq!(*i, 10);
-                *i = 20;
-            });
-        assert_eq!(i, 20);
-    }
-
-    #[test]
-    #[should_fail]
-    fn test_fail() {
-        let mut i = 0i;
-        try_finally(
-            &mut i, (),
-            |i, ()| {
-                *i = 10;
-                fail!();
-            },
-            |i| {
-                assert!(failing());
-                assert_eq!(*i, 10);
-            })
-    }
-
-    #[test]
-    fn test_retval() {
-        let mut closure: || -> int = || 10;
-        let i = closure.finally(|| { });
-        assert_eq!(i, 10);
-    }
-
-    #[test]
-    fn test_compact() {
-        fn do_some_fallible_work() {}
-        fn but_always_run_this_function() { }
-        let mut f = do_some_fallible_work;
-        f.finally(but_always_run_this_function);
-    }
-}
index 1a66d952e9bc2d52a4c03cf133cf31ea354a8d8a..ff7d7827fbb8ef932c8ab949438d67eade40dcce 100644 (file)
@@ -496,31 +496,6 @@ pub fn argument<'a, T>(f: extern "Rust" fn(&T, &mut Formatter) -> Result,
     }
 }
 
-#[cfg(test)]
-pub fn format(args: &Arguments) -> ::realstd::string::String {
-    use str;
-    use realstd::io::MemWriter;
-
-    fn mywrite<T: ::realstd::io::Writer>(t: &mut T, b: &[u8]) {
-        use realstd::io::Writer;
-        let _ = t.write(b);
-    }
-
-    impl FormatWriter for MemWriter {
-        fn write(&mut self, bytes: &[u8]) -> Result {
-            mywrite(self, bytes);
-            Ok(())
-        }
-    }
-
-    let mut i = MemWriter::new();
-    let _ = write(&mut i, args);
-
-    let mut result = ::realstd::string::String::new();
-    result.push_str(str::from_utf8(i.get_ref()).unwrap());
-    result
-}
-
 /// When the compiler determines that the type of an argument *must* be a string
 /// (such as for select), then it invokes this method.
 #[doc(hidden)] #[inline]
@@ -686,7 +661,7 @@ impl<$($name:Show),*> Show for ($($name,)*) {
             fn fmt(&self, f: &mut Formatter) -> Result {
                 try!(write!(f, "("));
                 let ($(ref $name,)*) = *self;
-                let mut n = 0;
+                let mut n = 0i;
                 $(
                     if n > 0 {
                         try!(write!(f, ", "));
index 56d0817dd00befee541f79fb1a2cb3b7c0164e7d..d52791f6b0ea2e2768240bd6484d09099a6a1d8a 100644 (file)
@@ -188,283 +188,3 @@ macro_rules! integer {
 integer!(i16, u16)
 integer!(i32, u32)
 integer!(i64, u64)
-
-#[cfg(test)]
-mod tests {
-    use fmt::radix;
-    use super::{Binary, Octal, Decimal, LowerHex, UpperHex};
-    use super::{GenericRadix, Radix};
-    use realstd::str::Str;
-
-    #[test]
-    fn test_radix_base() {
-        assert_eq!(Binary.base(), 2);
-        assert_eq!(Octal.base(), 8);
-        assert_eq!(Decimal.base(), 10);
-        assert_eq!(LowerHex.base(), 16);
-        assert_eq!(UpperHex.base(), 16);
-        assert_eq!(Radix { base: 36 }.base(), 36);
-    }
-
-    #[test]
-    fn test_radix_prefix() {
-        assert_eq!(Binary.prefix(), "0b");
-        assert_eq!(Octal.prefix(), "0o");
-        assert_eq!(Decimal.prefix(), "");
-        assert_eq!(LowerHex.prefix(), "0x");
-        assert_eq!(UpperHex.prefix(), "0x");
-        assert_eq!(Radix { base: 36 }.prefix(), "");
-    }
-
-    #[test]
-    fn test_radix_digit() {
-        assert_eq!(Binary.digit(0), '0' as u8);
-        assert_eq!(Binary.digit(2), '2' as u8);
-        assert_eq!(Octal.digit(0), '0' as u8);
-        assert_eq!(Octal.digit(7), '7' as u8);
-        assert_eq!(Decimal.digit(0), '0' as u8);
-        assert_eq!(Decimal.digit(9), '9' as u8);
-        assert_eq!(LowerHex.digit(0), '0' as u8);
-        assert_eq!(LowerHex.digit(10), 'a' as u8);
-        assert_eq!(LowerHex.digit(15), 'f' as u8);
-        assert_eq!(UpperHex.digit(0), '0' as u8);
-        assert_eq!(UpperHex.digit(10), 'A' as u8);
-        assert_eq!(UpperHex.digit(15), 'F' as u8);
-        assert_eq!(Radix { base: 36 }.digit(0), '0' as u8);
-        assert_eq!(Radix { base: 36 }.digit(15), 'f' as u8);
-        assert_eq!(Radix { base: 36 }.digit(35), 'z' as u8);
-    }
-
-    #[test]
-    #[should_fail]
-    fn test_hex_radix_digit_overflow() {
-        let _ = LowerHex.digit(16);
-    }
-
-    #[test]
-    fn test_format_int() {
-        // Formatting integers should select the right implementation based off
-        // the type of the argument. Also, hex/octal/binary should be defined
-        // for integers, but they shouldn't emit the negative sign.
-        assert!(format!("{}", 1i).as_slice() == "1");
-        assert!(format!("{}", 1i8).as_slice() == "1");
-        assert!(format!("{}", 1i16).as_slice() == "1");
-        assert!(format!("{}", 1i32).as_slice() == "1");
-        assert!(format!("{}", 1i64).as_slice() == "1");
-        assert!(format!("{:d}", -1i).as_slice() == "-1");
-        assert!(format!("{:d}", -1i8).as_slice() == "-1");
-        assert!(format!("{:d}", -1i16).as_slice() == "-1");
-        assert!(format!("{:d}", -1i32).as_slice() == "-1");
-        assert!(format!("{:d}", -1i64).as_slice() == "-1");
-        assert!(format!("{:t}", 1i).as_slice() == "1");
-        assert!(format!("{:t}", 1i8).as_slice() == "1");
-        assert!(format!("{:t}", 1i16).as_slice() == "1");
-        assert!(format!("{:t}", 1i32).as_slice() == "1");
-        assert!(format!("{:t}", 1i64).as_slice() == "1");
-        assert!(format!("{:x}", 1i).as_slice() == "1");
-        assert!(format!("{:x}", 1i8).as_slice() == "1");
-        assert!(format!("{:x}", 1i16).as_slice() == "1");
-        assert!(format!("{:x}", 1i32).as_slice() == "1");
-        assert!(format!("{:x}", 1i64).as_slice() == "1");
-        assert!(format!("{:X}", 1i).as_slice() == "1");
-        assert!(format!("{:X}", 1i8).as_slice() == "1");
-        assert!(format!("{:X}", 1i16).as_slice() == "1");
-        assert!(format!("{:X}", 1i32).as_slice() == "1");
-        assert!(format!("{:X}", 1i64).as_slice() == "1");
-        assert!(format!("{:o}", 1i).as_slice() == "1");
-        assert!(format!("{:o}", 1i8).as_slice() == "1");
-        assert!(format!("{:o}", 1i16).as_slice() == "1");
-        assert!(format!("{:o}", 1i32).as_slice() == "1");
-        assert!(format!("{:o}", 1i64).as_slice() == "1");
-
-        assert!(format!("{}", 1u).as_slice() == "1");
-        assert!(format!("{}", 1u8).as_slice() == "1");
-        assert!(format!("{}", 1u16).as_slice() == "1");
-        assert!(format!("{}", 1u32).as_slice() == "1");
-        assert!(format!("{}", 1u64).as_slice() == "1");
-        assert!(format!("{:u}", 1u).as_slice() == "1");
-        assert!(format!("{:u}", 1u8).as_slice() == "1");
-        assert!(format!("{:u}", 1u16).as_slice() == "1");
-        assert!(format!("{:u}", 1u32).as_slice() == "1");
-        assert!(format!("{:u}", 1u64).as_slice() == "1");
-        assert!(format!("{:t}", 1u).as_slice() == "1");
-        assert!(format!("{:t}", 1u8).as_slice() == "1");
-        assert!(format!("{:t}", 1u16).as_slice() == "1");
-        assert!(format!("{:t}", 1u32).as_slice() == "1");
-        assert!(format!("{:t}", 1u64).as_slice() == "1");
-        assert!(format!("{:x}", 1u).as_slice() == "1");
-        assert!(format!("{:x}", 1u8).as_slice() == "1");
-        assert!(format!("{:x}", 1u16).as_slice() == "1");
-        assert!(format!("{:x}", 1u32).as_slice() == "1");
-        assert!(format!("{:x}", 1u64).as_slice() == "1");
-        assert!(format!("{:X}", 1u).as_slice() == "1");
-        assert!(format!("{:X}", 1u8).as_slice() == "1");
-        assert!(format!("{:X}", 1u16).as_slice() == "1");
-        assert!(format!("{:X}", 1u32).as_slice() == "1");
-        assert!(format!("{:X}", 1u64).as_slice() == "1");
-        assert!(format!("{:o}", 1u).as_slice() == "1");
-        assert!(format!("{:o}", 1u8).as_slice() == "1");
-        assert!(format!("{:o}", 1u16).as_slice() == "1");
-        assert!(format!("{:o}", 1u32).as_slice() == "1");
-        assert!(format!("{:o}", 1u64).as_slice() == "1");
-
-        // Test a larger number
-        assert!(format!("{:t}", 55i).as_slice() == "110111");
-        assert!(format!("{:o}", 55i).as_slice() == "67");
-        assert!(format!("{:d}", 55i).as_slice() == "55");
-        assert!(format!("{:x}", 55i).as_slice() == "37");
-        assert!(format!("{:X}", 55i).as_slice() == "37");
-    }
-
-    #[test]
-    fn test_format_int_zero() {
-        assert!(format!("{}", 0i).as_slice() == "0");
-        assert!(format!("{:d}", 0i).as_slice() == "0");
-        assert!(format!("{:t}", 0i).as_slice() == "0");
-        assert!(format!("{:o}", 0i).as_slice() == "0");
-        assert!(format!("{:x}", 0i).as_slice() == "0");
-        assert!(format!("{:X}", 0i).as_slice() == "0");
-
-        assert!(format!("{}", 0u).as_slice() == "0");
-        assert!(format!("{:u}", 0u).as_slice() == "0");
-        assert!(format!("{:t}", 0u).as_slice() == "0");
-        assert!(format!("{:o}", 0u).as_slice() == "0");
-        assert!(format!("{:x}", 0u).as_slice() == "0");
-        assert!(format!("{:X}", 0u).as_slice() == "0");
-    }
-
-    #[test]
-    fn test_format_int_flags() {
-        assert!(format!("{:3d}", 1i).as_slice() == "  1");
-        assert!(format!("{:>3d}", 1i).as_slice() == "  1");
-        assert!(format!("{:>+3d}", 1i).as_slice() == " +1");
-        assert!(format!("{:<3d}", 1i).as_slice() == "1  ");
-        assert!(format!("{:#d}", 1i).as_slice() == "1");
-        assert!(format!("{:#x}", 10i).as_slice() == "0xa");
-        assert!(format!("{:#X}", 10i).as_slice() == "0xA");
-        assert!(format!("{:#5x}", 10i).as_slice() == "  0xa");
-        assert!(format!("{:#o}", 10i).as_slice() == "0o12");
-        assert!(format!("{:08x}", 10i).as_slice() == "0000000a");
-        assert!(format!("{:8x}", 10i).as_slice() == "       a");
-        assert!(format!("{:<8x}", 10i).as_slice() == "a       ");
-        assert!(format!("{:>8x}", 10i).as_slice() == "       a");
-        assert!(format!("{:#08x}", 10i).as_slice() == "0x00000a");
-        assert!(format!("{:08d}", -10i).as_slice() == "-0000010");
-        assert!(format!("{:x}", -1u8).as_slice() == "ff");
-        assert!(format!("{:X}", -1u8).as_slice() == "FF");
-        assert!(format!("{:t}", -1u8).as_slice() == "11111111");
-        assert!(format!("{:o}", -1u8).as_slice() == "377");
-        assert!(format!("{:#x}", -1u8).as_slice() == "0xff");
-        assert!(format!("{:#X}", -1u8).as_slice() == "0xFF");
-        assert!(format!("{:#t}", -1u8).as_slice() == "0b11111111");
-        assert!(format!("{:#o}", -1u8).as_slice() == "0o377");
-    }
-
-    #[test]
-    fn test_format_int_sign_padding() {
-        assert!(format!("{:+5d}", 1i).as_slice() == "   +1");
-        assert!(format!("{:+5d}", -1i).as_slice() == "   -1");
-        assert!(format!("{:05d}", 1i).as_slice() == "00001");
-        assert!(format!("{:05d}", -1i).as_slice() == "-0001");
-        assert!(format!("{:+05d}", 1i).as_slice() == "+0001");
-        assert!(format!("{:+05d}", -1i).as_slice() == "-0001");
-    }
-
-    #[test]
-    fn test_format_int_twos_complement() {
-        use {i8, i16, i32, i64};
-        assert!(format!("{}", i8::MIN).as_slice() == "-128");
-        assert!(format!("{}", i16::MIN).as_slice() == "-32768");
-        assert!(format!("{}", i32::MIN).as_slice() == "-2147483648");
-        assert!(format!("{}", i64::MIN).as_slice() == "-9223372036854775808");
-    }
-
-    #[test]
-    fn test_format_radix() {
-        assert!(format!("{:04}", radix(3i, 2)).as_slice() == "0011");
-        assert!(format!("{}", radix(55i, 36)).as_slice() == "1j");
-    }
-
-    #[test]
-    #[should_fail]
-    fn test_radix_base_too_large() {
-        let _ = radix(55, 37);
-    }
-}
-
-#[cfg(test)]
-mod bench {
-    extern crate test;
-
-    mod uint {
-        use super::test::Bencher;
-        use fmt::radix;
-        use realstd::rand::{weak_rng, Rng};
-
-        #[bench]
-        fn format_bin(b: &mut Bencher) {
-            let mut rng = weak_rng();
-            b.iter(|| { format!("{:t}", rng.gen::<uint>()); })
-        }
-
-        #[bench]
-        fn format_oct(b: &mut Bencher) {
-            let mut rng = weak_rng();
-            b.iter(|| { format!("{:o}", rng.gen::<uint>()); })
-        }
-
-        #[bench]
-        fn format_dec(b: &mut Bencher) {
-            let mut rng = weak_rng();
-            b.iter(|| { format!("{:u}", rng.gen::<uint>()); })
-        }
-
-        #[bench]
-        fn format_hex(b: &mut Bencher) {
-            let mut rng = weak_rng();
-            b.iter(|| { format!("{:x}", rng.gen::<uint>()); })
-        }
-
-        #[bench]
-        fn format_base_36(b: &mut Bencher) {
-            let mut rng = weak_rng();
-            b.iter(|| { format!("{}", radix(rng.gen::<uint>(), 36)); })
-        }
-    }
-
-    mod int {
-        use super::test::Bencher;
-        use fmt::radix;
-        use realstd::rand::{weak_rng, Rng};
-
-        #[bench]
-        fn format_bin(b: &mut Bencher) {
-            let mut rng = weak_rng();
-            b.iter(|| { format!("{:t}", rng.gen::<int>()); })
-        }
-
-        #[bench]
-        fn format_oct(b: &mut Bencher) {
-            let mut rng = weak_rng();
-            b.iter(|| { format!("{:o}", rng.gen::<int>()); })
-        }
-
-        #[bench]
-        fn format_dec(b: &mut Bencher) {
-            let mut rng = weak_rng();
-            b.iter(|| { format!("{:d}", rng.gen::<int>()); })
-        }
-
-        #[bench]
-        fn format_hex(b: &mut Bencher) {
-            let mut rng = weak_rng();
-            b.iter(|| { format!("{:x}", rng.gen::<int>()); })
-        }
-
-        #[bench]
-        fn format_base_36(b: &mut Bencher) {
-            let mut rng = weak_rng();
-            b.iter(|| { format!("{}", radix(rng.gen::<int>(), 36)); })
-        }
-    }
-}
index fd06ae95f1b7f2bd33c131363bc2739e69ff9bc3..161dd7cef7e13fc3efdde9818fb24ece8df3ec6d 100644 (file)
 #![experimental]
 #![allow(missing_doc)]
 
-// This is needed to prevent duplicate lang item definitions.
-#[cfg(test)]
-pub use realcore::intrinsics::{TyDesc, Opaque, TyVisitor, TypeId};
-
 pub type GlueFn = extern "Rust" fn(*const i8);
 
 #[lang="ty_desc"]
-#[cfg(not(test))]
 pub struct TyDesc {
     // sizeof(T)
     pub size: uint,
@@ -70,13 +65,11 @@ pub struct TyDesc {
 }
 
 #[lang="opaque"]
-#[cfg(not(test))]
 pub enum Opaque { }
 
 pub type Disr = u64;
 
 #[lang="ty_visitor"]
-#[cfg(not(test))]
 pub trait TyVisitor {
     fn visit_bot(&mut self) -> bool;
     fn visit_nil(&mut self) -> bool;
@@ -564,12 +557,10 @@ pub fn volatile_copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T,
 #[lang="type_id"] // This needs to be kept in lockstep with the code in trans/intrinsic.rs and
                   // middle/lang_items.rs
 #[deriving(PartialEq, Eq, Show)]
-#[cfg(not(test))]
 pub struct TypeId {
     t: u64,
 }
 
-#[cfg(not(test))]
 impl TypeId {
     /// Returns the `TypeId` of the type this generic function has been instantiated with
     pub fn of<T: 'static>() -> TypeId {
index ec53ef93dc1dde10ff34a0443dd767756b85049f..5895d871dbe18e2bb3467f72c09f1fb630e3b9c0 100644 (file)
@@ -2183,7 +2183,7 @@ fn idx(&mut self, _: uint) -> Option<A> { Some(self.element.clone()) }
 pub mod order {
     use cmp;
     use cmp::{Eq, Ord, PartialOrd, PartialEq};
-    use option::{Some, None};
+    use option::{Option, Some, None};
     use super::Iterator;
 
     /// Compare `a` and `b` for equality using `Eq`
@@ -2212,6 +2212,22 @@ pub fn cmp<A: Ord, T: Iterator<A>, S: Iterator<A>>(mut a: T, mut b: S) -> cmp::O
         }
     }
 
+    /// Order `a` and `b` lexicographically using `PartialOrd`
+    pub fn partial_cmp<A: PartialOrd, T: Iterator<A>, S: Iterator<A>>(mut a: T, mut b: S)
+            -> Option<cmp::Ordering> {
+        loop {
+            match (a.next(), b.next()) {
+                (None, None) => return Some(cmp::Equal),
+                (None, _   ) => return Some(cmp::Less),
+                (_   , None) => return Some(cmp::Greater),
+                (Some(x), Some(y)) => match x.partial_cmp(&y) {
+                    Some(cmp::Equal) => (),
+                    non_eq => return non_eq,
+                },
+            }
+        }
+    }
+
     /// Compare `a` and `b` for equality (Using partial equality, `PartialEq`)
     pub fn eq<A: PartialEq, T: Iterator<A>, S: Iterator<A>>(mut a: T, mut b: S) -> bool {
         loop {
@@ -2281,868 +2297,5 @@ pub fn ge<A: PartialOrd, T: Iterator<A>, S: Iterator<A>>(mut a: T, mut b: S) ->
             }
         }
     }
-
-    #[test]
-    fn test_lt() {
-        use slice::ImmutableVector;
-
-        let empty: [int, ..0] = [];
-        let xs = [1i,2,3];
-        let ys = [1i,2,0];
-
-        assert!(!lt(xs.iter(), ys.iter()));
-        assert!(!le(xs.iter(), ys.iter()));
-        assert!( gt(xs.iter(), ys.iter()));
-        assert!( ge(xs.iter(), ys.iter()));
-
-        assert!( lt(ys.iter(), xs.iter()));
-        assert!( le(ys.iter(), xs.iter()));
-        assert!(!gt(ys.iter(), xs.iter()));
-        assert!(!ge(ys.iter(), xs.iter()));
-
-        assert!( lt(empty.iter(), xs.iter()));
-        assert!( le(empty.iter(), xs.iter()));
-        assert!(!gt(empty.iter(), xs.iter()));
-        assert!(!ge(empty.iter(), xs.iter()));
-
-        // Sequence with NaN
-        let u = [1.0f64, 2.0];
-        let v = [0.0f64/0.0, 3.0];
-
-        assert!(!lt(u.iter(), v.iter()));
-        assert!(!le(u.iter(), v.iter()));
-        assert!(!gt(u.iter(), v.iter()));
-        assert!(!ge(u.iter(), v.iter()));
-
-        let a = [0.0f64/0.0];
-        let b = [1.0f64];
-        let c = [2.0f64];
-
-        assert!(lt(a.iter(), b.iter()) == (a[0] <  b[0]));
-        assert!(le(a.iter(), b.iter()) == (a[0] <= b[0]));
-        assert!(gt(a.iter(), b.iter()) == (a[0] >  b[0]));
-        assert!(ge(a.iter(), b.iter()) == (a[0] >= b[0]));
-
-        assert!(lt(c.iter(), b.iter()) == (c[0] <  b[0]));
-        assert!(le(c.iter(), b.iter()) == (c[0] <= b[0]));
-        assert!(gt(c.iter(), b.iter()) == (c[0] >  b[0]));
-        assert!(ge(c.iter(), b.iter()) == (c[0] >= b[0]));
-    }
-
-    #[test]
-    fn test_multi_iter() {
-        use slice::ImmutableVector;
-        use iter::DoubleEndedIterator;
-        let xs = [1i,2,3,4];
-        let ys = [4i,3,2,1];
-        assert!(eq(xs.iter(), ys.iter().rev()));
-        assert!(lt(xs.iter(), xs.iter().skip(2)));
-    }
 }
 
-#[cfg(test)]
-mod tests {
-    use prelude::*;
-    use iter::*;
-    use num;
-    use realstd::vec::Vec;
-    use realstd::slice::Vector;
-    use realstd::gc::GC;
-
-    use cmp;
-    use realstd::owned::Box;
-    use uint;
-
-    impl<T> FromIterator<T> for Vec<T> {
-        fn from_iter<I: Iterator<T>>(mut iterator: I) -> Vec<T> {
-            let mut v = Vec::new();
-            for e in iterator {
-                v.push(e);
-            }
-            return v;
-        }
-    }
-
-    impl<'a, T> Iterator<&'a T> for ::realcore::slice::Items<'a, T> {
-        fn next(&mut self) -> Option<&'a T> {
-            use RealSome = realcore::option::Some;
-            use RealNone = realcore::option::None;
-            fn mynext<T, I: ::realcore::iter::Iterator<T>>(i: &mut I)
-                -> ::realcore::option::Option<T>
-            {
-                use realcore::iter::Iterator;
-                i.next()
-            }
-            match mynext(self) {
-                RealSome(t) => Some(t),
-                RealNone => None,
-            }
-        }
-    }
-
-    #[test]
-    fn test_counter_from_iter() {
-        let it = count(0i, 5).take(10);
-        let xs: Vec<int> = FromIterator::from_iter(it);
-        assert!(xs == vec![0, 5, 10, 15, 20, 25, 30, 35, 40, 45]);
-    }
-
-    #[test]
-    fn test_iterator_chain() {
-        let xs = [0u, 1, 2, 3, 4, 5];
-        let ys = [30u, 40, 50, 60];
-        let expected = [0, 1, 2, 3, 4, 5, 30, 40, 50, 60];
-        let mut it = xs.iter().chain(ys.iter());
-        let mut i = 0;
-        for &x in it {
-            assert_eq!(x, expected[i]);
-            i += 1;
-        }
-        assert_eq!(i, expected.len());
-
-        let ys = count(30u, 10).take(4);
-        let mut it = xs.iter().map(|&x| x).chain(ys);
-        let mut i = 0;
-        for x in it {
-            assert_eq!(x, expected[i]);
-            i += 1;
-        }
-        assert_eq!(i, expected.len());
-    }
-
-    #[test]
-    fn test_filter_map() {
-        let mut it = count(0u, 1u).take(10)
-            .filter_map(|x| if x % 2 == 0 { Some(x*x) } else { None });
-        assert!(it.collect::<Vec<uint>>() == vec![0*0, 2*2, 4*4, 6*6, 8*8]);
-    }
-
-    #[test]
-    fn test_iterator_enumerate() {
-        let xs = [0u, 1, 2, 3, 4, 5];
-        let mut it = xs.iter().enumerate();
-        for (i, &x) in it {
-            assert_eq!(i, x);
-        }
-    }
-
-    #[test]
-    fn test_iterator_peekable() {
-        let xs = vec![0u, 1, 2, 3, 4, 5];
-        let mut it = xs.iter().map(|&x|x).peekable();
-        assert_eq!(it.peek().unwrap(), &0);
-        assert_eq!(it.next().unwrap(), 0);
-        assert_eq!(it.next().unwrap(), 1);
-        assert_eq!(it.next().unwrap(), 2);
-        assert_eq!(it.peek().unwrap(), &3);
-        assert_eq!(it.peek().unwrap(), &3);
-        assert_eq!(it.next().unwrap(), 3);
-        assert_eq!(it.next().unwrap(), 4);
-        assert_eq!(it.peek().unwrap(), &5);
-        assert_eq!(it.next().unwrap(), 5);
-        assert!(it.peek().is_none());
-        assert!(it.next().is_none());
-    }
-
-    #[test]
-    fn test_iterator_take_while() {
-        let xs = [0u, 1, 2, 3, 5, 13, 15, 16, 17, 19];
-        let ys = [0u, 1, 2, 3, 5, 13];
-        let mut it = xs.iter().take_while(|&x| *x < 15u);
-        let mut i = 0;
-        for &x in it {
-            assert_eq!(x, ys[i]);
-            i += 1;
-        }
-        assert_eq!(i, ys.len());
-    }
-
-    #[test]
-    fn test_iterator_skip_while() {
-        let xs = [0u, 1, 2, 3, 5, 13, 15, 16, 17, 19];
-        let ys = [15, 16, 17, 19];
-        let mut it = xs.iter().skip_while(|&x| *x < 15u);
-        let mut i = 0;
-        for &x in it {
-            assert_eq!(x, ys[i]);
-            i += 1;
-        }
-        assert_eq!(i, ys.len());
-    }
-
-    #[test]
-    fn test_iterator_skip() {
-        let xs = [0u, 1, 2, 3, 5, 13, 15, 16, 17, 19, 20, 30];
-        let ys = [13, 15, 16, 17, 19, 20, 30];
-        let mut it = xs.iter().skip(5);
-        let mut i = 0;
-        for &x in it {
-            assert_eq!(x, ys[i]);
-            i += 1;
-        }
-        assert_eq!(i, ys.len());
-    }
-
-    #[test]
-    fn test_iterator_take() {
-        let xs = [0u, 1, 2, 3, 5, 13, 15, 16, 17, 19];
-        let ys = [0u, 1, 2, 3, 5];
-        let mut it = xs.iter().take(5);
-        let mut i = 0;
-        for &x in it {
-            assert_eq!(x, ys[i]);
-            i += 1;
-        }
-        assert_eq!(i, ys.len());
-    }
-
-    #[test]
-    fn test_iterator_scan() {
-        // test the type inference
-        fn add(old: &mut int, new: &uint) -> Option<f64> {
-            *old += *new as int;
-            Some(*old as f64)
-        }
-        let xs = [0u, 1, 2, 3, 4];
-        let ys = [0f64, 1.0, 3.0, 6.0, 10.0];
-
-        let mut it = xs.iter().scan(0, add);
-        let mut i = 0;
-        for x in it {
-            assert_eq!(x, ys[i]);
-            i += 1;
-        }
-        assert_eq!(i, ys.len());
-    }
-
-    #[test]
-    fn test_iterator_flat_map() {
-        let xs = [0u, 3, 6];
-        let ys = [0u, 1, 2, 3, 4, 5, 6, 7, 8];
-        let mut it = xs.iter().flat_map(|&x| count(x, 1).take(3));
-        let mut i = 0;
-        for x in it {
-            assert_eq!(x, ys[i]);
-            i += 1;
-        }
-        assert_eq!(i, ys.len());
-    }
-
-    #[test]
-    fn test_inspect() {
-        let xs = [1u, 2, 3, 4];
-        let mut n = 0;
-
-        let ys = xs.iter()
-                   .map(|&x| x)
-                   .inspect(|_| n += 1)
-                   .collect::<Vec<uint>>();
-
-        assert_eq!(n, xs.len());
-        assert_eq!(xs.as_slice(), ys.as_slice());
-    }
-
-    #[test]
-    fn test_unfoldr() {
-        fn count(st: &mut uint) -> Option<uint> {
-            if *st < 10 {
-                let ret = Some(*st);
-                *st += 1;
-                ret
-            } else {
-                None
-            }
-        }
-
-        let mut it = Unfold::new(0, count);
-        let mut i = 0;
-        for counted in it {
-            assert_eq!(counted, i);
-            i += 1;
-        }
-        assert_eq!(i, 10);
-    }
-
-    #[test]
-    fn test_cycle() {
-        let cycle_len = 3;
-        let it = count(0u, 1).take(cycle_len).cycle();
-        assert_eq!(it.size_hint(), (uint::MAX, None));
-        for (i, x) in it.take(100).enumerate() {
-            assert_eq!(i % cycle_len, x);
-        }
-
-        let mut it = count(0u, 1).take(0).cycle();
-        assert_eq!(it.size_hint(), (0, Some(0)));
-        assert_eq!(it.next(), None);
-    }
-
-    #[test]
-    fn test_iterator_nth() {
-        let v = &[0i, 1, 2, 3, 4];
-        for i in range(0u, v.len()) {
-            assert_eq!(v.iter().nth(i).unwrap(), &v[i]);
-        }
-    }
-
-    #[test]
-    fn test_iterator_last() {
-        let v = &[0i, 1, 2, 3, 4];
-        assert_eq!(v.iter().last().unwrap(), &4);
-        assert_eq!(v.slice(0, 1).iter().last().unwrap(), &0);
-    }
-
-    #[test]
-    fn test_iterator_len() {
-        let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
-        assert_eq!(v.slice(0, 4).iter().count(), 4);
-        assert_eq!(v.slice(0, 10).iter().count(), 10);
-        assert_eq!(v.slice(0, 0).iter().count(), 0);
-    }
-
-    #[test]
-    fn test_iterator_sum() {
-        let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
-        assert_eq!(v.slice(0, 4).iter().map(|&x| x).sum(), 6);
-        assert_eq!(v.iter().map(|&x| x).sum(), 55);
-        assert_eq!(v.slice(0, 0).iter().map(|&x| x).sum(), 0);
-    }
-
-    #[test]
-    fn test_iterator_product() {
-        let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
-        assert_eq!(v.slice(0, 4).iter().map(|&x| x).product(), 0);
-        assert_eq!(v.slice(1, 5).iter().map(|&x| x).product(), 24);
-        assert_eq!(v.slice(0, 0).iter().map(|&x| x).product(), 1);
-    }
-
-    #[test]
-    fn test_iterator_max() {
-        let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
-        assert_eq!(v.slice(0, 4).iter().map(|&x| x).max(), Some(3));
-        assert_eq!(v.iter().map(|&x| x).max(), Some(10));
-        assert_eq!(v.slice(0, 0).iter().map(|&x| x).max(), None);
-    }
-
-    #[test]
-    fn test_iterator_min() {
-        let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
-        assert_eq!(v.slice(0, 4).iter().map(|&x| x).min(), Some(0));
-        assert_eq!(v.iter().map(|&x| x).min(), Some(0));
-        assert_eq!(v.slice(0, 0).iter().map(|&x| x).min(), None);
-    }
-
-    #[test]
-    fn test_iterator_size_hint() {
-        let c = count(0i, 1);
-        let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9];
-        let v2 = &[10i, 11, 12];
-        let vi = v.iter();
-
-        assert_eq!(c.size_hint(), (uint::MAX, None));
-        assert_eq!(vi.size_hint(), (10, Some(10)));
-
-        assert_eq!(c.take(5).size_hint(), (5, Some(5)));
-        assert_eq!(c.skip(5).size_hint().val1(), None);
-        assert_eq!(c.take_while(|_| false).size_hint(), (0, None));
-        assert_eq!(c.skip_while(|_| false).size_hint(), (0, None));
-        assert_eq!(c.enumerate().size_hint(), (uint::MAX, None));
-        assert_eq!(c.chain(vi.map(|&i| i)).size_hint(), (uint::MAX, None));
-        assert_eq!(c.zip(vi).size_hint(), (10, Some(10)));
-        assert_eq!(c.scan(0, |_,_| Some(0)).size_hint(), (0, None));
-        assert_eq!(c.filter(|_| false).size_hint(), (0, None));
-        assert_eq!(c.map(|_| 0).size_hint(), (uint::MAX, None));
-        assert_eq!(c.filter_map(|_| Some(0)).size_hint(), (0, None));
-
-        assert_eq!(vi.take(5).size_hint(), (5, Some(5)));
-        assert_eq!(vi.take(12).size_hint(), (10, Some(10)));
-        assert_eq!(vi.skip(3).size_hint(), (7, Some(7)));
-        assert_eq!(vi.skip(12).size_hint(), (0, Some(0)));
-        assert_eq!(vi.take_while(|_| false).size_hint(), (0, Some(10)));
-        assert_eq!(vi.skip_while(|_| false).size_hint(), (0, Some(10)));
-        assert_eq!(vi.enumerate().size_hint(), (10, Some(10)));
-        assert_eq!(vi.chain(v2.iter()).size_hint(), (13, Some(13)));
-        assert_eq!(vi.zip(v2.iter()).size_hint(), (3, Some(3)));
-        assert_eq!(vi.scan(0, |_,_| Some(0)).size_hint(), (0, Some(10)));
-        assert_eq!(vi.filter(|_| false).size_hint(), (0, Some(10)));
-        assert_eq!(vi.map(|i| i+1).size_hint(), (10, Some(10)));
-        assert_eq!(vi.filter_map(|_| Some(0)).size_hint(), (0, Some(10)));
-    }
-
-    #[test]
-    fn test_collect() {
-        let a = vec![1i, 2, 3, 4, 5];
-        let b: Vec<int> = a.iter().map(|&x| x).collect();
-        assert!(a == b);
-    }
-
-    #[test]
-    fn test_all() {
-        let v: Box<&[int]> = box &[1i, 2, 3, 4, 5];
-        assert!(v.iter().all(|&x| x < 10));
-        assert!(!v.iter().all(|&x| x % 2 == 0));
-        assert!(!v.iter().all(|&x| x > 100));
-        assert!(v.slice(0, 0).iter().all(|_| fail!()));
-    }
-
-    #[test]
-    fn test_any() {
-        let v: Box<&[int]> = box &[1i, 2, 3, 4, 5];
-        assert!(v.iter().any(|&x| x < 10));
-        assert!(v.iter().any(|&x| x % 2 == 0));
-        assert!(!v.iter().any(|&x| x > 100));
-        assert!(!v.slice(0, 0).iter().any(|_| fail!()));
-    }
-
-    #[test]
-    fn test_find() {
-        let v: &[int] = &[1i, 3, 9, 27, 103, 14, 11];
-        assert_eq!(*v.iter().find(|x| *x & 1 == 0).unwrap(), 14);
-        assert_eq!(*v.iter().find(|x| *x % 3 == 0).unwrap(), 3);
-        assert!(v.iter().find(|x| *x % 12 == 0).is_none());
-    }
-
-    #[test]
-    fn test_position() {
-        let v = &[1i, 3, 9, 27, 103, 14, 11];
-        assert_eq!(v.iter().position(|x| *x & 1 == 0).unwrap(), 5);
-        assert_eq!(v.iter().position(|x| *x % 3 == 0).unwrap(), 1);
-        assert!(v.iter().position(|x| *x % 12 == 0).is_none());
-    }
-
-    #[test]
-    fn test_count() {
-        let xs = &[1i, 2, 2, 1, 5, 9, 0, 2];
-        assert_eq!(xs.iter().filter(|x| **x == 2).count(), 3);
-        assert_eq!(xs.iter().filter(|x| **x == 5).count(), 1);
-        assert_eq!(xs.iter().filter(|x| **x == 95).count(), 0);
-    }
-
-    #[test]
-    fn test_max_by() {
-        let xs: &[int] = &[-3i, 0, 1, 5, -10];
-        assert_eq!(*xs.iter().max_by(|x| x.abs()).unwrap(), -10);
-    }
-
-    #[test]
-    fn test_min_by() {
-        let xs: &[int] = &[-3i, 0, 1, 5, -10];
-        assert_eq!(*xs.iter().min_by(|x| x.abs()).unwrap(), 0);
-    }
-
-    #[test]
-    fn test_by_ref() {
-        let mut xs = range(0i, 10);
-        // sum the first five values
-        let partial_sum = xs.by_ref().take(5).fold(0, |a, b| a + b);
-        assert_eq!(partial_sum, 10);
-        assert_eq!(xs.next(), Some(5));
-    }
-
-    #[test]
-    fn test_rev() {
-        let xs = [2i, 4, 6, 8, 10, 12, 14, 16];
-        let mut it = xs.iter();
-        it.next();
-        it.next();
-        assert!(it.rev().map(|&x| x).collect::<Vec<int>>() ==
-                vec![16, 14, 12, 10, 8, 6]);
-    }
-
-    #[test]
-    fn test_double_ended_map() {
-        let xs = [1i, 2, 3, 4, 5, 6];
-        let mut it = xs.iter().map(|&x| x * -1);
-        assert_eq!(it.next(), Some(-1));
-        assert_eq!(it.next(), Some(-2));
-        assert_eq!(it.next_back(), Some(-6));
-        assert_eq!(it.next_back(), Some(-5));
-        assert_eq!(it.next(), Some(-3));
-        assert_eq!(it.next_back(), Some(-4));
-        assert_eq!(it.next(), None);
-    }
-
-    #[test]
-    fn test_double_ended_enumerate() {
-        let xs = [1i, 2, 3, 4, 5, 6];
-        let mut it = xs.iter().map(|&x| x).enumerate();
-        assert_eq!(it.next(), Some((0, 1)));
-        assert_eq!(it.next(), Some((1, 2)));
-        assert_eq!(it.next_back(), Some((5, 6)));
-        assert_eq!(it.next_back(), Some((4, 5)));
-        assert_eq!(it.next_back(), Some((3, 4)));
-        assert_eq!(it.next_back(), Some((2, 3)));
-        assert_eq!(it.next(), None);
-    }
-
-    #[test]
-    fn test_double_ended_zip() {
-        let xs = [1i, 2, 3, 4, 5, 6];
-        let ys = [1i, 2, 3, 7];
-        let a = xs.iter().map(|&x| x);
-        let b = ys.iter().map(|&x| x);
-        let mut it = a.zip(b);
-        assert_eq!(it.next(), Some((1, 1)));
-        assert_eq!(it.next(), Some((2, 2)));
-        assert_eq!(it.next_back(), Some((4, 7)));
-        assert_eq!(it.next_back(), Some((3, 3)));
-        assert_eq!(it.next(), None);
-    }
-
-    #[test]
-    fn test_double_ended_filter() {
-        let xs = [1i, 2, 3, 4, 5, 6];
-        let mut it = xs.iter().filter(|&x| *x & 1 == 0);
-        assert_eq!(it.next_back().unwrap(), &6);
-        assert_eq!(it.next_back().unwrap(), &4);
-        assert_eq!(it.next().unwrap(), &2);
-        assert_eq!(it.next_back(), None);
-    }
-
-    #[test]
-    fn test_double_ended_filter_map() {
-        let xs = [1i, 2, 3, 4, 5, 6];
-        let mut it = xs.iter().filter_map(|&x| if x & 1 == 0 { Some(x * 2) } else { None });
-        assert_eq!(it.next_back().unwrap(), 12);
-        assert_eq!(it.next_back().unwrap(), 8);
-        assert_eq!(it.next().unwrap(), 4);
-        assert_eq!(it.next_back(), None);
-    }
-
-    #[test]
-    fn test_double_ended_chain() {
-        let xs = [1i, 2, 3, 4, 5];
-        let ys = [7i, 9, 11];
-        let mut it = xs.iter().chain(ys.iter()).rev();
-        assert_eq!(it.next().unwrap(), &11)
-        assert_eq!(it.next().unwrap(), &9)
-        assert_eq!(it.next_back().unwrap(), &1)
-        assert_eq!(it.next_back().unwrap(), &2)
-        assert_eq!(it.next_back().unwrap(), &3)
-        assert_eq!(it.next_back().unwrap(), &4)
-        assert_eq!(it.next_back().unwrap(), &5)
-        assert_eq!(it.next_back().unwrap(), &7)
-        assert_eq!(it.next_back(), None)
-    }
-
-    #[test]
-    fn test_rposition() {
-        fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' }
-        fn g(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'd' }
-        let v = [(0i, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
-
-        assert_eq!(v.iter().rposition(f), Some(3u));
-        assert!(v.iter().rposition(g).is_none());
-    }
-
-    #[test]
-    #[should_fail]
-    fn test_rposition_fail() {
-        let v = [(box 0i, box(GC) 0i), (box 0i, box(GC) 0i),
-                 (box 0i, box(GC) 0i), (box 0i, box(GC) 0i)];
-        let mut i = 0i;
-        v.iter().rposition(|_elt| {
-            if i == 2 {
-                fail!()
-            }
-            i += 1;
-            false
-        });
-    }
-
-
-    #[cfg(test)]
-    fn check_randacc_iter<A: PartialEq, T: Clone + RandomAccessIterator<A>>(a: T, len: uint)
-    {
-        let mut b = a.clone();
-        assert_eq!(len, b.indexable());
-        let mut n = 0u;
-        for (i, elt) in a.enumerate() {
-            assert!(Some(elt) == b.idx(i));
-            n += 1;
-        }
-        assert_eq!(n, len);
-        assert!(None == b.idx(n));
-        // call recursively to check after picking off an element
-        if len > 0 {
-            b.next();
-            check_randacc_iter(b, len-1);
-        }
-    }
-
-
-    #[test]
-    fn test_double_ended_flat_map() {
-        let u = [0u,1];
-        let v = [5u,6,7,8];
-        let mut it = u.iter().flat_map(|x| v.slice(*x, v.len()).iter());
-        assert_eq!(it.next_back().unwrap(), &8);
-        assert_eq!(it.next().unwrap(),      &5);
-        assert_eq!(it.next_back().unwrap(), &7);
-        assert_eq!(it.next_back().unwrap(), &6);
-        assert_eq!(it.next_back().unwrap(), &8);
-        assert_eq!(it.next().unwrap(),      &6);
-        assert_eq!(it.next_back().unwrap(), &7);
-        assert_eq!(it.next_back(), None);
-        assert_eq!(it.next(),      None);
-        assert_eq!(it.next_back(), None);
-    }
-
-    #[test]
-    fn test_random_access_chain() {
-        let xs = [1i, 2, 3, 4, 5];
-        let ys = [7i, 9, 11];
-        let mut it = xs.iter().chain(ys.iter());
-        assert_eq!(it.idx(0).unwrap(), &1);
-        assert_eq!(it.idx(5).unwrap(), &7);
-        assert_eq!(it.idx(7).unwrap(), &11);
-        assert!(it.idx(8).is_none());
-
-        it.next();
-        it.next();
-        it.next_back();
-
-        assert_eq!(it.idx(0).unwrap(), &3);
-        assert_eq!(it.idx(4).unwrap(), &9);
-        assert!(it.idx(6).is_none());
-
-        check_randacc_iter(it, xs.len() + ys.len() - 3);
-    }
-
-    #[test]
-    fn test_random_access_enumerate() {
-        let xs = [1i, 2, 3, 4, 5];
-        check_randacc_iter(xs.iter().enumerate(), xs.len());
-    }
-
-    #[test]
-    fn test_random_access_rev() {
-        let xs = [1i, 2, 3, 4, 5];
-        check_randacc_iter(xs.iter().rev(), xs.len());
-        let mut it = xs.iter().rev();
-        it.next();
-        it.next_back();
-        it.next();
-        check_randacc_iter(it, xs.len() - 3);
-    }
-
-    #[test]
-    fn test_random_access_zip() {
-        let xs = [1i, 2, 3, 4, 5];
-        let ys = [7i, 9, 11];
-        check_randacc_iter(xs.iter().zip(ys.iter()), cmp::min(xs.len(), ys.len()));
-    }
-
-    #[test]
-    fn test_random_access_take() {
-        let xs = [1i, 2, 3, 4, 5];
-        let empty: &[int] = [];
-        check_randacc_iter(xs.iter().take(3), 3);
-        check_randacc_iter(xs.iter().take(20), xs.len());
-        check_randacc_iter(xs.iter().take(0), 0);
-        check_randacc_iter(empty.iter().take(2), 0);
-    }
-
-    #[test]
-    fn test_random_access_skip() {
-        let xs = [1i, 2, 3, 4, 5];
-        let empty: &[int] = [];
-        check_randacc_iter(xs.iter().skip(2), xs.len() - 2);
-        check_randacc_iter(empty.iter().skip(2), 0);
-    }
-
-    #[test]
-    fn test_random_access_inspect() {
-        let xs = [1i, 2, 3, 4, 5];
-
-        // test .map and .inspect that don't implement Clone
-        let mut it = xs.iter().inspect(|_| {});
-        assert_eq!(xs.len(), it.indexable());
-        for (i, elt) in xs.iter().enumerate() {
-            assert_eq!(Some(elt), it.idx(i));
-        }
-
-    }
-
-    #[test]
-    fn test_random_access_map() {
-        let xs = [1i, 2, 3, 4, 5];
-
-        let mut it = xs.iter().map(|x| *x);
-        assert_eq!(xs.len(), it.indexable());
-        for (i, elt) in xs.iter().enumerate() {
-            assert_eq!(Some(*elt), it.idx(i));
-        }
-    }
-
-    #[test]
-    fn test_random_access_cycle() {
-        let xs = [1i, 2, 3, 4, 5];
-        let empty: &[int] = [];
-        check_randacc_iter(xs.iter().cycle().take(27), 27);
-        check_randacc_iter(empty.iter().cycle(), 0);
-    }
-
-    #[test]
-    fn test_double_ended_range() {
-        assert!(range(11i, 14).rev().collect::<Vec<int>>() == vec![13i, 12, 11]);
-        for _ in range(10i, 0).rev() {
-            fail!("unreachable");
-        }
-
-        assert!(range(11u, 14).rev().collect::<Vec<uint>>() == vec![13u, 12, 11]);
-        for _ in range(10u, 0).rev() {
-            fail!("unreachable");
-        }
-    }
-
-    #[test]
-    fn test_range() {
-        /// A mock type to check Range when ToPrimitive returns None
-        struct Foo;
-
-        impl ToPrimitive for Foo {
-            fn to_i64(&self) -> Option<i64> { None }
-            fn to_u64(&self) -> Option<u64> { None }
-        }
-
-        impl Add<Foo, Foo> for Foo {
-            fn add(&self, _: &Foo) -> Foo {
-                Foo
-            }
-        }
-
-        impl PartialEq for Foo {
-            fn eq(&self, _: &Foo) -> bool {
-                true
-            }
-        }
-
-        impl PartialOrd for Foo {
-            fn lt(&self, _: &Foo) -> bool {
-                false
-            }
-        }
-
-        impl Clone for Foo {
-            fn clone(&self) -> Foo {
-                Foo
-            }
-        }
-
-        impl Mul<Foo, Foo> for Foo {
-            fn mul(&self, _: &Foo) -> Foo {
-                Foo
-            }
-        }
-
-        impl num::One for Foo {
-            fn one() -> Foo {
-                Foo
-            }
-        }
-
-        assert!(range(0i, 5).collect::<Vec<int>>() == vec![0i, 1, 2, 3, 4]);
-        assert!(range(-10i, -1).collect::<Vec<int>>() ==
-                   vec![-10, -9, -8, -7, -6, -5, -4, -3, -2]);
-        assert!(range(0i, 5).rev().collect::<Vec<int>>() == vec![4, 3, 2, 1, 0]);
-        assert_eq!(range(200i, -5).count(), 0);
-        assert_eq!(range(200i, -5).rev().count(), 0);
-        assert_eq!(range(200i, 200).count(), 0);
-        assert_eq!(range(200i, 200).rev().count(), 0);
-
-        assert_eq!(range(0i, 100).size_hint(), (100, Some(100)));
-        // this test is only meaningful when sizeof uint < sizeof u64
-        assert_eq!(range(uint::MAX - 1, uint::MAX).size_hint(), (1, Some(1)));
-        assert_eq!(range(-10i, -1).size_hint(), (9, Some(9)));
-        assert_eq!(range(Foo, Foo).size_hint(), (0, None));
-    }
-
-    #[test]
-    fn test_range_inclusive() {
-        assert!(range_inclusive(0i, 5).collect::<Vec<int>>() ==
-                vec![0i, 1, 2, 3, 4, 5]);
-        assert!(range_inclusive(0i, 5).rev().collect::<Vec<int>>() ==
-                vec![5i, 4, 3, 2, 1, 0]);
-        assert_eq!(range_inclusive(200i, -5).count(), 0);
-        assert_eq!(range_inclusive(200i, -5).rev().count(), 0);
-        assert!(range_inclusive(200i, 200).collect::<Vec<int>>() == vec![200]);
-        assert!(range_inclusive(200i, 200).rev().collect::<Vec<int>>() == vec![200]);
-    }
-
-    #[test]
-    fn test_range_step() {
-        assert!(range_step(0i, 20, 5).collect::<Vec<int>>() ==
-                vec![0, 5, 10, 15]);
-        assert!(range_step(20i, 0, -5).collect::<Vec<int>>() ==
-                vec![20, 15, 10, 5]);
-        assert!(range_step(20i, 0, -6).collect::<Vec<int>>() ==
-                vec![20, 14, 8, 2]);
-        assert!(range_step(200u8, 255, 50).collect::<Vec<u8>>() ==
-                vec![200u8, 250]);
-        assert!(range_step(200i, -5, 1).collect::<Vec<int>>() == vec![]);
-        assert!(range_step(200i, 200, 1).collect::<Vec<int>>() == vec![]);
-    }
-
-    #[test]
-    fn test_range_step_inclusive() {
-        assert!(range_step_inclusive(0i, 20, 5).collect::<Vec<int>>() ==
-                vec![0, 5, 10, 15, 20]);
-        assert!(range_step_inclusive(20i, 0, -5).collect::<Vec<int>>() ==
-                vec![20, 15, 10, 5, 0]);
-        assert!(range_step_inclusive(20i, 0, -6).collect::<Vec<int>>() ==
-                vec![20, 14, 8, 2]);
-        assert!(range_step_inclusive(200u8, 255, 50).collect::<Vec<u8>>() ==
-                vec![200u8, 250]);
-        assert!(range_step_inclusive(200i, -5, 1).collect::<Vec<int>>() ==
-                vec![]);
-        assert!(range_step_inclusive(200i, 200, 1).collect::<Vec<int>>() ==
-                vec![200]);
-    }
-
-    #[test]
-    fn test_reverse() {
-        let mut ys = [1i, 2, 3, 4, 5];
-        ys.mut_iter().reverse_();
-        assert!(ys == [5, 4, 3, 2, 1]);
-    }
-
-    #[test]
-    fn test_peekable_is_empty() {
-        let a = [1i];
-        let mut it = a.iter().peekable();
-        assert!( !it.is_empty() );
-        it.next();
-        assert!( it.is_empty() );
-    }
-
-    #[test]
-    fn test_min_max() {
-        let v: [int, ..0] = [];
-        assert_eq!(v.iter().min_max(), NoElements);
-
-        let v = [1i];
-        assert!(v.iter().min_max() == OneElement(&1));
-
-        let v = [1i, 2, 3, 4, 5];
-        assert!(v.iter().min_max() == MinMax(&1, &5));
-
-        let v = [1i, 2, 3, 4, 5, 6];
-        assert!(v.iter().min_max() == MinMax(&1, &6));
-
-        let v = [1i, 1, 1, 1];
-        assert!(v.iter().min_max() == MinMax(&1, &1));
-    }
-
-    #[test]
-    fn test_min_max_result() {
-        let r: MinMaxResult<int> = NoElements;
-        assert_eq!(r.into_option(), None)
-
-        let r = OneElement(1i);
-        assert_eq!(r.into_option(), Some((1,1)));
-
-        let r = MinMax(1i,2);
-        assert_eq!(r.into_option(), Some((1,2)));
-    }
-}
index 4dc45ceeb85adb098d07e814ac890e1de69e622c..385a33fb92a4c67cd02d71ecd26acb5d3813fc96 100644 (file)
@@ -43,7 +43,9 @@
 //!   the failure message, the file at which failure was invoked, and the line.
 //!   It is up to consumers of this core library to define this failure
 //!   function; it is only required to never return.
-//!
+
+// Since libcore defines many fundamental lang items, all tests live in a
+// separate crate, libcoretest, to avoid bizarre issues.
 
 #![crate_id = "core#0.11.0-pre"]
 #![experimental]
 #![feature(simd, unsafe_destructor)]
 #![deny(missing_doc)]
 
-#[cfg(test)] extern crate realcore = "core";
-#[cfg(test)] extern crate libc;
-#[cfg(test)] extern crate native;
-#[cfg(test)] extern crate realstd = "std";
-
-#[cfg(test)] pub use cmp = realcore::cmp;
-#[cfg(test)] pub use kinds = realcore::kinds;
-#[cfg(test)] pub use ops = realcore::ops;
-#[cfg(test)] pub use ty = realcore::ty;
-
 mod macros;
 
 #[path = "num/float_macros.rs"] mod float_macros;
 
 /* Core language traits */
 
-#[cfg(not(test))] pub mod kinds;
-#[cfg(not(test))] pub mod ops;
-#[cfg(not(test))] pub mod ty;
-#[cfg(not(test))] pub mod cmp;
+pub mod kinds;
+pub mod ops;
+pub mod ty;
+pub mod cmp;
 pub mod clone;
 pub mod default;
 pub mod collections;
@@ -144,11 +136,4 @@ mod std {
     pub use kinds;
     pub use option;
     pub use fmt;
-
-    #[cfg(test)] pub use realstd::rt;     // needed for fail!()
-    // #[cfg(test)] pub use realstd::option; // needed for fail!()
-    // #[cfg(test)] pub use realstd::fmt;    // needed for fail!()
-    #[cfg(test)] pub use realstd::os;     // needed for tests
-    #[cfg(test)] pub use realstd::slice;  // needed for tests
-    #[cfg(test)] pub use realstd::vec;    // needed for vec![]
 }
index a62bc10d8abc654c7b6d49ee597b8dd45f64edab..93c838198c559b60792b945f2f49cfa68af86089 100644 (file)
@@ -112,16 +112,6 @@ macro_rules! writeln(
     )
 )
 
-#[cfg(test)]
-macro_rules! vec( ($($e:expr),*) => ({
-    let mut _v = ::std::vec::Vec::new();
-    $(_v.push($e);)*
-    _v
-}) )
-
-#[cfg(test)]
-macro_rules! format( ($($arg:tt)*) => (format_args!(::fmt::format, $($arg)*)) )
-
 /// Write some formatted data into a stream.
 ///
 /// Identical to the macro in `std::macros`
index d1e2084243d413b293d61003b145f656e0350def..06e28816c1cd5015cca5bb4901b6c258f10d500b 100644 (file)
@@ -382,182 +382,3 @@ pub unsafe fn copy_mut_lifetime<'a, S, T>(_ptr: &'a mut S,
                                           ptr: &mut T) -> &'a mut T {
     transmute(ptr)
 }
-
-#[cfg(test)]
-mod tests {
-    use mem::*;
-    use option::{Some,None};
-    use realstd::str::StrAllocating;
-    use realstd::owned::Box;
-    use realstd::vec::Vec;
-    use raw;
-
-    #[test]
-    fn size_of_basic() {
-        assert_eq!(size_of::<u8>(), 1u);
-        assert_eq!(size_of::<u16>(), 2u);
-        assert_eq!(size_of::<u32>(), 4u);
-        assert_eq!(size_of::<u64>(), 8u);
-    }
-
-    #[test]
-    #[cfg(target_arch = "x86")]
-    #[cfg(target_arch = "arm")]
-    #[cfg(target_arch = "mips")]
-    #[cfg(target_arch = "mipsel")]
-    fn size_of_32() {
-        assert_eq!(size_of::<uint>(), 4u);
-        assert_eq!(size_of::<*const uint>(), 4u);
-    }
-
-    #[test]
-    #[cfg(target_arch = "x86_64")]
-    fn size_of_64() {
-        assert_eq!(size_of::<uint>(), 8u);
-        assert_eq!(size_of::<*const uint>(), 8u);
-    }
-
-    #[test]
-    fn size_of_val_basic() {
-        assert_eq!(size_of_val(&1u8), 1);
-        assert_eq!(size_of_val(&1u16), 2);
-        assert_eq!(size_of_val(&1u32), 4);
-        assert_eq!(size_of_val(&1u64), 8);
-    }
-
-    #[test]
-    fn align_of_basic() {
-        assert_eq!(align_of::<u8>(), 1u);
-        assert_eq!(align_of::<u16>(), 2u);
-        assert_eq!(align_of::<u32>(), 4u);
-    }
-
-    #[test]
-    #[cfg(target_arch = "x86")]
-    #[cfg(target_arch = "arm")]
-    #[cfg(target_arch = "mips")]
-    #[cfg(target_arch = "mipsel")]
-    fn align_of_32() {
-        assert_eq!(align_of::<uint>(), 4u);
-        assert_eq!(align_of::<*const uint>(), 4u);
-    }
-
-    #[test]
-    #[cfg(target_arch = "x86_64")]
-    fn align_of_64() {
-        assert_eq!(align_of::<uint>(), 8u);
-        assert_eq!(align_of::<*const uint>(), 8u);
-    }
-
-    #[test]
-    fn align_of_val_basic() {
-        assert_eq!(align_of_val(&1u8), 1u);
-        assert_eq!(align_of_val(&1u16), 2u);
-        assert_eq!(align_of_val(&1u32), 4u);
-    }
-
-    #[test]
-    fn test_swap() {
-        let mut x = 31337i;
-        let mut y = 42i;
-        swap(&mut x, &mut y);
-        assert_eq!(x, 42);
-        assert_eq!(y, 31337);
-    }
-
-    #[test]
-    fn test_replace() {
-        let mut x = Some("test".to_string());
-        let y = replace(&mut x, None);
-        assert!(x.is_none());
-        assert!(y.is_some());
-    }
-
-    #[test]
-    fn test_transmute_copy() {
-        assert_eq!(1u, unsafe { ::mem::transmute_copy(&1) });
-    }
-
-    #[test]
-    fn test_transmute() {
-        trait Foo {}
-        impl Foo for int {}
-
-        let a = box 100i as Box<Foo>;
-        unsafe {
-            let x: raw::TraitObject = transmute(a);
-            assert!(*(x.data as *const int) == 100);
-            let _x: Box<Foo> = transmute(x);
-        }
-
-        unsafe {
-            assert!(Vec::from_slice([76u8]) == transmute("L".to_string()));
-        }
-    }
-}
-
-// FIXME #13642 (these benchmarks should be in another place)
-/// Completely miscellaneous language-construct benchmarks.
-#[cfg(test)]
-mod bench {
-    extern crate test;
-    use self::test::Bencher;
-    use option::{Some,None};
-
-    // Static/dynamic method dispatch
-
-    struct Struct {
-        field: int
-    }
-
-    trait Trait {
-        fn method(&self) -> int;
-    }
-
-    impl Trait for Struct {
-        fn method(&self) -> int {
-            self.field
-        }
-    }
-
-    #[bench]
-    fn trait_vtable_method_call(b: &mut Bencher) {
-        let s = Struct { field: 10 };
-        let t = &s as &Trait;
-        b.iter(|| {
-            t.method()
-        });
-    }
-
-    #[bench]
-    fn trait_static_method_call(b: &mut Bencher) {
-        let s = Struct { field: 10 };
-        b.iter(|| {
-            s.method()
-        });
-    }
-
-    // Overhead of various match forms
-
-    #[bench]
-    fn match_option_some(b: &mut Bencher) {
-        let x = Some(10);
-        b.iter(|| {
-            match x {
-                Some(y) => y,
-                None => 11
-            }
-        });
-    }
-
-    #[bench]
-    fn match_vec_pattern(b: &mut Bencher) {
-        let x = [1,2,3,4,5,6];
-        b.iter(|| {
-            match x {
-                [1,2,3,..] => 10,
-                _ => 11
-            }
-        });
-    }
-}
index ef10c9abe1141b2b8a37c71c1ca5de184824f9d3..ff0494725f849316f04c5bf6b60f3b394777c577 100644 (file)
@@ -32,152 +32,4 @@ macro_rules! int_module (($T:ty, $bits:expr) => (
 #[unstable]
 pub static MAX: $T = !MIN;
 
-#[cfg(test)]
-mod tests {
-    use prelude::*;
-    use super::*;
-
-    use int;
-    use num;
-    use num::CheckedDiv;
-
-    #[test]
-    fn test_overflows() {
-        assert!(MAX > 0);
-        assert!(MIN <= 0);
-        assert!(MIN + MAX + 1 == 0);
-    }
-
-    #[test]
-    fn test_num() {
-        num::test_num(10 as $T, 2 as $T);
-    }
-
-    #[test]
-    pub fn test_abs() {
-        assert!((1 as $T).abs() == 1 as $T);
-        assert!((0 as $T).abs() == 0 as $T);
-        assert!((-1 as $T).abs() == 1 as $T);
-    }
-
-    #[test]
-    fn test_abs_sub() {
-        assert!((-1 as $T).abs_sub(&(1 as $T)) == 0 as $T);
-        assert!((1 as $T).abs_sub(&(1 as $T)) == 0 as $T);
-        assert!((1 as $T).abs_sub(&(0 as $T)) == 1 as $T);
-        assert!((1 as $T).abs_sub(&(-1 as $T)) == 2 as $T);
-    }
-
-    #[test]
-    fn test_signum() {
-        assert!((1 as $T).signum() == 1 as $T);
-        assert!((0 as $T).signum() == 0 as $T);
-        assert!((-0 as $T).signum() == 0 as $T);
-        assert!((-1 as $T).signum() == -1 as $T);
-    }
-
-    #[test]
-    fn test_is_positive() {
-        assert!((1 as $T).is_positive());
-        assert!(!(0 as $T).is_positive());
-        assert!(!(-0 as $T).is_positive());
-        assert!(!(-1 as $T).is_positive());
-    }
-
-    #[test]
-    fn test_is_negative() {
-        assert!(!(1 as $T).is_negative());
-        assert!(!(0 as $T).is_negative());
-        assert!(!(-0 as $T).is_negative());
-        assert!((-1 as $T).is_negative());
-    }
-
-    #[test]
-    fn test_bitwise_operators() {
-        assert!(0b1110 as $T == (0b1100 as $T).bitor(&(0b1010 as $T)));
-        assert!(0b1000 as $T == (0b1100 as $T).bitand(&(0b1010 as $T)));
-        assert!(0b0110 as $T == (0b1100 as $T).bitxor(&(0b1010 as $T)));
-        assert!(0b1110 as $T == (0b0111 as $T).shl(&(1 as $T)));
-        assert!(0b0111 as $T == (0b1110 as $T).shr(&(1 as $T)));
-        assert!(-(0b11 as $T) - (1 as $T) == (0b11 as $T).not());
-    }
-
-    static A: $T = 0b0101100;
-    static B: $T = 0b0100001;
-    static C: $T = 0b1111001;
-
-    static _0: $T = 0;
-    static _1: $T = !0;
-
-    #[test]
-    fn test_count_ones() {
-        assert!(A.count_ones() == 3);
-        assert!(B.count_ones() == 2);
-        assert!(C.count_ones() == 5);
-    }
-
-    #[test]
-    fn test_count_zeros() {
-        assert!(A.count_zeros() == BITS as $T - 3);
-        assert!(B.count_zeros() == BITS as $T - 2);
-        assert!(C.count_zeros() == BITS as $T - 5);
-    }
-
-    #[test]
-    fn test_rotate() {
-        assert_eq!(A.rotate_left(6).rotate_right(2).rotate_right(4), A);
-        assert_eq!(B.rotate_left(3).rotate_left(2).rotate_right(5), B);
-        assert_eq!(C.rotate_left(6).rotate_right(2).rotate_right(4), C);
-
-        // Rotating these should make no difference
-        //
-        // We test using 124 bits because to ensure that overlong bit shifts do
-        // not cause undefined behaviour. See #10183.
-        assert_eq!(_0.rotate_left(124), _0);
-        assert_eq!(_1.rotate_left(124), _1);
-        assert_eq!(_0.rotate_right(124), _0);
-        assert_eq!(_1.rotate_right(124), _1);
-    }
-
-    #[test]
-    fn test_swap_bytes() {
-        assert_eq!(A.swap_bytes().swap_bytes(), A);
-        assert_eq!(B.swap_bytes().swap_bytes(), B);
-        assert_eq!(C.swap_bytes().swap_bytes(), C);
-
-        // Swapping these should make no difference
-        assert_eq!(_0.swap_bytes(), _0);
-        assert_eq!(_1.swap_bytes(), _1);
-    }
-
-    #[test]
-    fn test_le() {
-        assert_eq!(Int::from_le(A.to_le()), A);
-        assert_eq!(Int::from_le(B.to_le()), B);
-        assert_eq!(Int::from_le(C.to_le()), C);
-        assert_eq!(Int::from_le(_0), _0);
-        assert_eq!(Int::from_le(_1), _1);
-        assert_eq!(_0.to_le(), _0);
-        assert_eq!(_1.to_le(), _1);
-    }
-
-    #[test]
-    fn test_be() {
-        assert_eq!(Int::from_be(A.to_be()), A);
-        assert_eq!(Int::from_be(B.to_be()), B);
-        assert_eq!(Int::from_be(C.to_be()), C);
-        assert_eq!(Int::from_be(_0), _0);
-        assert_eq!(Int::from_be(_1), _1);
-        assert_eq!(_0.to_be(), _0);
-        assert_eq!(_1.to_be(), _1);
-    }
-
-    #[test]
-    fn test_signed_checked_div() {
-        assert!(10i.checked_div(&2) == Some(5));
-        assert!(5i.checked_div(&0) == None);
-        assert!(int::MIN.checked_div(&-1) == None);
-    }
-}
-
 ))
index 512c107b930b67b559d78154b843d1b2cc2889db..b32e4167da1d45e90517b74a4e36b0a55af6791b 100644 (file)
@@ -1375,22 +1375,6 @@ fn checked_div(&self, v: &$t) -> Option<$t> {
 
 checkeddiv_uint_impl!(uint u8 u16 u32 u64)
 
-/// Helper function for testing numeric operations
-#[cfg(test)]
-pub fn test_num<T:Num + NumCast + ::std::fmt::Show>(ten: T, two: T) {
-    assert_eq!(ten.add(&two),  cast(12i).unwrap());
-    assert_eq!(ten.sub(&two),  cast(8i).unwrap());
-    assert_eq!(ten.mul(&two),  cast(20i).unwrap());
-    assert_eq!(ten.div(&two),  cast(5i).unwrap());
-    assert_eq!(ten.rem(&two),  cast(0i).unwrap());
-
-    assert_eq!(ten.add(&two),  ten + two);
-    assert_eq!(ten.sub(&two),  ten - two);
-    assert_eq!(ten.mul(&two),  ten * two);
-    assert_eq!(ten.div(&two),  ten / two);
-    assert_eq!(ten.rem(&two),  ten % two);
-}
-
 /// Used for representing the classification of floating point numbers
 #[deriving(PartialEq, Show)]
 pub enum FPCategory {
index 5828697ddad507c54abaf31179a9ee1c42fcab40..b0c570af04ac0f1fc664d08509458f4bc2407d26 100644 (file)
@@ -23,111 +23,4 @@ macro_rules! uint_module (($T:ty, $T_SIGNED:ty, $bits:expr) => (
 #[unstable]
 pub static MAX: $T = 0 as $T - 1 as $T;
 
-#[cfg(test)]
-mod tests {
-    use prelude::*;
-    use super::*;
-
-    use num;
-    use num::CheckedDiv;
-
-    #[test]
-    fn test_overflows() {
-        assert!(MAX > 0);
-        assert!(MIN <= 0);
-        assert!(MIN + MAX + 1 == 0);
-    }
-
-    #[test]
-    fn test_num() {
-        num::test_num(10 as $T, 2 as $T);
-    }
-
-    #[test]
-    fn test_bitwise_operators() {
-        assert!(0b1110 as $T == (0b1100 as $T).bitor(&(0b1010 as $T)));
-        assert!(0b1000 as $T == (0b1100 as $T).bitand(&(0b1010 as $T)));
-        assert!(0b0110 as $T == (0b1100 as $T).bitxor(&(0b1010 as $T)));
-        assert!(0b1110 as $T == (0b0111 as $T).shl(&(1 as $T)));
-        assert!(0b0111 as $T == (0b1110 as $T).shr(&(1 as $T)));
-        assert!(MAX - (0b1011 as $T) == (0b1011 as $T).not());
-    }
-
-    static A: $T = 0b0101100;
-    static B: $T = 0b0100001;
-    static C: $T = 0b1111001;
-
-    static _0: $T = 0;
-    static _1: $T = !0;
-
-    #[test]
-    fn test_count_ones() {
-        assert!(A.count_ones() == 3);
-        assert!(B.count_ones() == 2);
-        assert!(C.count_ones() == 5);
-    }
-
-    #[test]
-    fn test_count_zeros() {
-        assert!(A.count_zeros() == BITS as $T - 3);
-        assert!(B.count_zeros() == BITS as $T - 2);
-        assert!(C.count_zeros() == BITS as $T - 5);
-    }
-
-    #[test]
-    fn test_rotate() {
-        assert_eq!(A.rotate_left(6).rotate_right(2).rotate_right(4), A);
-        assert_eq!(B.rotate_left(3).rotate_left(2).rotate_right(5), B);
-        assert_eq!(C.rotate_left(6).rotate_right(2).rotate_right(4), C);
-
-        // Rotating these should make no difference
-        //
-        // We test using 124 bits because to ensure that overlong bit shifts do
-        // not cause undefined behaviour. See #10183.
-        assert_eq!(_0.rotate_left(124), _0);
-        assert_eq!(_1.rotate_left(124), _1);
-        assert_eq!(_0.rotate_right(124), _0);
-        assert_eq!(_1.rotate_right(124), _1);
-    }
-
-    #[test]
-    fn test_swap_bytes() {
-        assert_eq!(A.swap_bytes().swap_bytes(), A);
-        assert_eq!(B.swap_bytes().swap_bytes(), B);
-        assert_eq!(C.swap_bytes().swap_bytes(), C);
-
-        // Swapping these should make no difference
-        assert_eq!(_0.swap_bytes(), _0);
-        assert_eq!(_1.swap_bytes(), _1);
-    }
-
-    #[test]
-    fn test_le() {
-        assert_eq!(Int::from_le(A.to_le()), A);
-        assert_eq!(Int::from_le(B.to_le()), B);
-        assert_eq!(Int::from_le(C.to_le()), C);
-        assert_eq!(Int::from_le(_0), _0);
-        assert_eq!(Int::from_le(_1), _1);
-        assert_eq!(_0.to_le(), _0);
-        assert_eq!(_1.to_le(), _1);
-    }
-
-    #[test]
-    fn test_be() {
-        assert_eq!(Int::from_be(A.to_be()), A);
-        assert_eq!(Int::from_be(B.to_be()), B);
-        assert_eq!(Int::from_be(C.to_be()), C);
-        assert_eq!(Int::from_be(_0), _0);
-        assert_eq!(Int::from_be(_1), _1);
-        assert_eq!(_0.to_be(), _0);
-        assert_eq!(_1.to_be(), _1);
-    }
-
-    #[test]
-    fn test_unsigned_checked_div() {
-        assert!(10u.checked_div(&2) == Some(5));
-        assert!(5u.checked_div(&0) == None);
-    }
-}
-
 ))
index afa08f04cb20323919f37a377726ba5788202fb7..d42c09b8163dd1d6159264109b8ae85847f84d58 100644 (file)
@@ -117,7 +117,6 @@ pub trait Add<RHS,Result> {
 
 macro_rules! add_impl(
     ($($t:ty)*) => ($(
-        #[cfg(not(test))]
         impl Add<$t, $t> for $t {
             #[inline]
             fn add(&self, other: &$t) -> $t { (*self) + (*other) }
@@ -159,7 +158,6 @@ pub trait Sub<RHS,Result> {
 
 macro_rules! sub_impl(
     ($($t:ty)*) => ($(
-        #[cfg(not(test))]
         impl Sub<$t, $t> for $t {
             #[inline]
             fn sub(&self, other: &$t) -> $t { (*self) - (*other) }
@@ -201,7 +199,6 @@ pub trait Mul<RHS,Result> {
 
 macro_rules! mul_impl(
     ($($t:ty)*) => ($(
-        #[cfg(not(test))]
         impl Mul<$t, $t> for $t {
             #[inline]
             fn mul(&self, other: &$t) -> $t { (*self) * (*other) }
@@ -243,7 +240,6 @@ pub trait Div<RHS,Result> {
 
 macro_rules! div_impl(
     ($($t:ty)*) => ($(
-        #[cfg(not(test))]
         impl Div<$t, $t> for $t {
             #[inline]
             fn div(&self, other: &$t) -> $t { (*self) / (*other) }
@@ -285,7 +281,6 @@ pub trait Rem<RHS,Result> {
 
 macro_rules! rem_impl(
     ($($t:ty)*) => ($(
-        #[cfg(not(test))]
         impl Rem<$t, $t> for $t {
             #[inline]
             fn rem(&self, other: &$t) -> $t { (*self) % (*other) }
@@ -295,7 +290,6 @@ fn rem(&self, other: &$t) -> $t { (*self) % (*other) }
 
 macro_rules! rem_float_impl(
     ($t:ty, $fmod:ident) => {
-        #[cfg(not(test))]
         impl Rem<$t, $t> for $t {
             #[inline]
             fn rem(&self, other: &$t) -> $t {
@@ -342,7 +336,6 @@ pub trait Neg<Result> {
 
 macro_rules! neg_impl(
     ($($t:ty)*) => ($(
-        #[cfg(not(test))]
         impl Neg<$t> for $t {
             #[inline]
             fn neg(&self) -> $t { -*self }
@@ -352,7 +345,6 @@ fn neg(&self) -> $t { -*self }
 
 macro_rules! neg_uint_impl(
     ($t:ty, $t_signed:ty) => {
-        #[cfg(not(test))]
         impl Neg<$t> for $t {
             #[inline]
             fn neg(&self) -> $t { -(*self as $t_signed) as $t }
@@ -402,7 +394,6 @@ pub trait Not<Result> {
 
 macro_rules! not_impl(
     ($($t:ty)*) => ($(
-        #[cfg(not(test))]
         impl Not<$t> for $t {
             #[inline]
             fn not(&self) -> $t { !*self }
@@ -444,7 +435,6 @@ pub trait BitAnd<RHS,Result> {
 
 macro_rules! bitand_impl(
     ($($t:ty)*) => ($(
-        #[cfg(not(test))]
         impl BitAnd<$t, $t> for $t {
             #[inline]
             fn bitand(&self, rhs: &$t) -> $t { (*self) & (*rhs) }
@@ -486,7 +476,6 @@ pub trait BitOr<RHS,Result> {
 
 macro_rules! bitor_impl(
     ($($t:ty)*) => ($(
-        #[cfg(not(test))]
         impl BitOr<$t,$t> for $t {
             #[inline]
             fn bitor(&self, rhs: &$t) -> $t { (*self) | (*rhs) }
@@ -528,7 +517,6 @@ pub trait BitXor<RHS,Result> {
 
 macro_rules! bitxor_impl(
     ($($t:ty)*) => ($(
-        #[cfg(not(test))]
         impl BitXor<$t, $t> for $t {
             #[inline]
             fn bitxor(&self, other: &$t) -> $t { (*self) ^ (*other) }
@@ -746,28 +734,3 @@ pub trait FnOnce<Args,Result> {
     /// This is called when the call operator is used.
     fn call_once(self, args: Args) -> Result;
 }
-
-#[cfg(test)]
-mod bench {
-    extern crate test;
-    use self::test::Bencher;
-    use ops::Drop;
-
-    // Overhead of dtors
-
-    struct HasDtor {
-        x: int
-    }
-
-    impl Drop for HasDtor {
-        fn drop(&mut self) {
-        }
-    }
-
-    #[bench]
-    fn alloc_obj_with_dtor(b: &mut Bencher) {
-        b.iter(|| {
-            HasDtor { x : 10 };
-        })
-    }
-}
index 9748235e94a13478ae0d3d03e9fd968b5d99e208..b8612ed93e02dcd39dd1229c1e8da14a460b9f16 100644 (file)
@@ -587,310 +587,34 @@ impl<A> ExactSize<A> for Item<A> {}
 /// ```
 #[inline]
 pub fn collect<T, Iter: Iterator<Option<T>>, V: FromIterator<T>>(iter: Iter) -> Option<V> {
-    // FIXME(#11084): This should be twice as fast once this bug is closed.
-    let mut iter = iter.scan(false, |state, x| {
-        match x {
-            Some(x) => Some(x),
-            None => {
-                *state = true;
-                None
+    // FIXME(#11084): This could be replaced with Iterator::scan when this
+    // performance bug is closed.
+
+    struct Adapter<Iter> {
+        iter: Iter,
+        found_none: bool,
+    }
+
+    impl<T, Iter: Iterator<Option<T>>> Iterator<T> for Adapter<Iter> {
+        #[inline]
+        fn next(&mut self) -> Option<T> {
+            match self.iter.next() {
+                Some(Some(value)) => Some(value),
+                Some(None) => {
+                    self.found_none = true;
+                    None
+                }
+                None => None,
             }
         }
-    });
+    }
 
-    let v: V = FromIterator::from_iter(iter.by_ref());
+    let mut adapter = Adapter { iter: iter, found_none: false };
+    let v: V = FromIterator::from_iter(adapter.by_ref());
 
-    if iter.state {
+    if adapter.found_none {
         None
     } else {
         Some(v)
     }
 }
-
-/////////////////////////////////////////////////////////////////////////////
-// Tests
-/////////////////////////////////////////////////////////////////////////////
-
-#[cfg(test)]
-mod tests {
-    use realstd::vec::Vec;
-    use realstd::string::String;
-    use option::collect;
-    use prelude::*;
-    use realstd::str::{Str, StrAllocating};
-    use iter::range;
-
-    use str::StrSlice;
-    use kinds::marker;
-    use slice::ImmutableVector;
-
-    #[test]
-    fn test_get_ptr() {
-        unsafe {
-            let x = box 0;
-            let addr_x: *const int = ::mem::transmute(&*x);
-            let opt = Some(x);
-            let y = opt.unwrap();
-            let addr_y: *const int = ::mem::transmute(&*y);
-            assert_eq!(addr_x, addr_y);
-        }
-    }
-
-    #[test]
-    fn test_get_str() {
-        let x = "test".to_string();
-        let addr_x = x.as_slice().as_ptr();
-        let opt = Some(x);
-        let y = opt.unwrap();
-        let addr_y = y.as_slice().as_ptr();
-        assert_eq!(addr_x, addr_y);
-    }
-
-    #[test]
-    fn test_get_resource() {
-        use realstd::rc::Rc;
-        use cell::RefCell;
-
-        struct R {
-           i: Rc<RefCell<int>>,
-        }
-
-        #[unsafe_destructor]
-        impl ::ops::Drop for R {
-           fn drop(&mut self) {
-                let ii = &*self.i;
-                let i = *ii.borrow();
-                *ii.borrow_mut() = i + 1;
-            }
-        }
-
-        fn r(i: Rc<RefCell<int>>) -> R {
-            R {
-                i: i
-            }
-        }
-
-        fn realclone<T: ::realstd::clone::Clone>(t: &T) -> T {
-            use realstd::clone::Clone;
-            t.clone()
-        }
-
-        let i = Rc::new(RefCell::new(0i));
-        {
-            let x = r(realclone(&i));
-            let opt = Some(x);
-            let _y = opt.unwrap();
-        }
-        assert_eq!(*i.borrow(), 1);
-    }
-
-    #[test]
-    fn test_option_dance() {
-        let x = Some(());
-        let mut y = Some(5i);
-        let mut y2 = 0;
-        for _x in x.iter() {
-            y2 = y.take_unwrap();
-        }
-        assert_eq!(y2, 5);
-        assert!(y.is_none());
-    }
-
-    #[test] #[should_fail]
-    fn test_option_too_much_dance() {
-        let mut y = Some(marker::NoCopy);
-        let _y2 = y.take_unwrap();
-        let _y3 = y.take_unwrap();
-    }
-
-    #[test]
-    fn test_and() {
-        let x: Option<int> = Some(1i);
-        assert_eq!(x.and(Some(2i)), Some(2));
-        assert_eq!(x.and(None::<int>), None);
-
-        let x: Option<int> = None;
-        assert_eq!(x.and(Some(2i)), None);
-        assert_eq!(x.and(None::<int>), None);
-    }
-
-    #[test]
-    fn test_and_then() {
-        let x: Option<int> = Some(1);
-        assert_eq!(x.and_then(|x| Some(x + 1)), Some(2));
-        assert_eq!(x.and_then(|_| None::<int>), None);
-
-        let x: Option<int> = None;
-        assert_eq!(x.and_then(|x| Some(x + 1)), None);
-        assert_eq!(x.and_then(|_| None::<int>), None);
-    }
-
-    #[test]
-    fn test_or() {
-        let x: Option<int> = Some(1);
-        assert_eq!(x.or(Some(2)), Some(1));
-        assert_eq!(x.or(None), Some(1));
-
-        let x: Option<int> = None;
-        assert_eq!(x.or(Some(2)), Some(2));
-        assert_eq!(x.or(None), None);
-    }
-
-    #[test]
-    fn test_or_else() {
-        let x: Option<int> = Some(1);
-        assert_eq!(x.or_else(|| Some(2)), Some(1));
-        assert_eq!(x.or_else(|| None), Some(1));
-
-        let x: Option<int> = None;
-        assert_eq!(x.or_else(|| Some(2)), Some(2));
-        assert_eq!(x.or_else(|| None), None);
-    }
-
-    #[test]
-    fn test_option_while_some() {
-        let mut i = 0i;
-        Some(10).while_some(|j| {
-            i += 1;
-            if j > 0 {
-                Some(j-1)
-            } else {
-                None
-            }
-        });
-        assert_eq!(i, 11);
-    }
-
-    #[test]
-    fn test_unwrap() {
-        assert_eq!(Some(1i).unwrap(), 1);
-        let s = Some("hello".to_string()).unwrap();
-        assert_eq!(s.as_slice(), "hello");
-    }
-
-    #[test]
-    #[should_fail]
-    fn test_unwrap_fail1() {
-        let x: Option<int> = None;
-        x.unwrap();
-    }
-
-    #[test]
-    #[should_fail]
-    fn test_unwrap_fail2() {
-        let x: Option<String> = None;
-        x.unwrap();
-    }
-
-    #[test]
-    fn test_unwrap_or() {
-        let x: Option<int> = Some(1);
-        assert_eq!(x.unwrap_or(2), 1);
-
-        let x: Option<int> = None;
-        assert_eq!(x.unwrap_or(2), 2);
-    }
-
-    #[test]
-    fn test_unwrap_or_else() {
-        let x: Option<int> = Some(1);
-        assert_eq!(x.unwrap_or_else(|| 2), 1);
-
-        let x: Option<int> = None;
-        assert_eq!(x.unwrap_or_else(|| 2), 2);
-    }
-
-    #[test]
-    fn test_filtered() {
-        let some_stuff = Some(42i);
-        let modified_stuff = some_stuff.filtered(|&x| {x < 10});
-        assert_eq!(some_stuff.unwrap(), 42);
-        assert!(modified_stuff.is_none());
-    }
-
-    #[test]
-    fn test_iter() {
-        let val = 5i;
-
-        let x = Some(val);
-        let mut it = x.iter();
-
-        assert_eq!(it.size_hint(), (1, Some(1)));
-        assert_eq!(it.next(), Some(&val));
-        assert_eq!(it.size_hint(), (0, Some(0)));
-        assert!(it.next().is_none());
-    }
-
-    #[test]
-    fn test_mut_iter() {
-        let val = 5i;
-        let new_val = 11i;
-
-        let mut x = Some(val);
-        {
-            let mut it = x.mut_iter();
-
-            assert_eq!(it.size_hint(), (1, Some(1)));
-
-            match it.next() {
-                Some(interior) => {
-                    assert_eq!(*interior, val);
-                    *interior = new_val;
-                }
-                None => assert!(false),
-            }
-
-            assert_eq!(it.size_hint(), (0, Some(0)));
-            assert!(it.next().is_none());
-        }
-        assert_eq!(x, Some(new_val));
-    }
-
-    #[test]
-    fn test_ord() {
-        let small = Some(1.0f64);
-        let big = Some(5.0f64);
-        let nan = Some(0.0f64/0.0);
-        assert!(!(nan < big));
-        assert!(!(nan > big));
-        assert!(small < big);
-        assert!(None < big);
-        assert!(big > None);
-    }
-
-    #[test]
-    fn test_mutate() {
-        let mut x = Some(3i);
-        assert!(x.mutate(|i| i+1));
-        assert_eq!(x, Some(4i));
-        assert!(x.mutate_or_set(0, |i| i+1));
-        assert_eq!(x, Some(5i));
-        x = None;
-        assert!(!x.mutate(|i| i+1));
-        assert_eq!(x, None);
-        assert!(!x.mutate_or_set(0i, |i| i+1));
-        assert_eq!(x, Some(0i));
-    }
-
-    #[test]
-    fn test_collect() {
-        let v: Option<Vec<int>> = collect(range(0i, 0)
-                                          .map(|_| Some(0i)));
-        assert!(v == Some(vec![]));
-
-        let v: Option<Vec<int>> = collect(range(0i, 3)
-                                          .map(|x| Some(x)));
-        assert!(v == Some(vec![0, 1, 2]));
-
-        let v: Option<Vec<int>> = collect(range(0i, 3)
-                                          .map(|x| if x > 1 { None } else { Some(x) }));
-        assert!(v == None);
-
-        // test that it does not take more elements than it needs
-        let mut functions = [|| Some(()), || None, || fail!()];
-
-        let v: Option<Vec<()>> = collect(functions.mut_iter().map(|f| (*f)()));
-
-        assert!(v == None);
-    }
-}
index 44e68952df29fa40075cbd361020d4d3fb6994df..093591cd796d1cf4026605f338da2be55a87af46 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
+// 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.
 //
@@ -93,7 +93,7 @@
 use iter::{range, Iterator};
 use option::{Some, None, Option};
 
-#[cfg(not(test))] use cmp::{PartialEq, Eq, PartialOrd, Equiv};
+use cmp::{PartialEq, Eq, PartialOrd, Equiv, Ordering, Less, Equal, Greater};
 
 /// Create a null pointer.
 ///
@@ -404,7 +404,6 @@ unsafe fn to_option(&self) -> Option<&T> {
 }
 
 // Equality for pointers
-#[cfg(not(test))]
 impl<T> PartialEq for *const T {
     #[inline]
     fn eq(&self, other: &*const T) -> bool {
@@ -414,10 +413,8 @@ fn eq(&self, other: &*const T) -> bool {
     fn ne(&self, other: &*const T) -> bool { !self.eq(other) }
 }
 
-#[cfg(not(test))]
 impl<T> Eq for *const T {}
 
-#[cfg(not(test))]
 impl<T> PartialEq for *mut T {
     #[inline]
     fn eq(&self, other: &*mut T) -> bool {
@@ -427,18 +424,15 @@ fn eq(&self, other: &*mut T) -> bool {
     fn ne(&self, other: &*mut T) -> bool { !self.eq(other) }
 }
 
-#[cfg(not(test))]
 impl<T> Eq for *mut T {}
 
 // Equivalence for pointers
-#[cfg(not(test))]
 impl<T> Equiv<*mut T> for *const T {
     fn equiv(&self, other: &*mut T) -> bool {
         self.to_uint() == other.to_uint()
     }
 }
 
-#[cfg(not(test))]
 impl<T> Equiv<*const T> for *mut T {
     fn equiv(&self, other: &*const T) -> bool {
         self.to_uint() == other.to_uint()
@@ -460,7 +454,6 @@ fn clone(&self) -> *mut T {
 }
 
 // Equality for extern "C" fn pointers
-#[cfg(not(test))]
 mod externfnpointers {
     use mem;
     use cmp::PartialEq;
@@ -494,274 +487,52 @@ fn eq(&self, other: &extern "C" fn($($p),*) -> _R) -> bool {
 }
 
 // Comparison for pointers
-#[cfg(not(test))]
 impl<T> PartialOrd for *const T {
     #[inline]
-    fn lt(&self, other: &*const T) -> bool { *self < *other }
-}
-
-#[cfg(not(test))]
-impl<T> PartialOrd for *mut T {
-    #[inline]
-    fn lt(&self, other: &*mut T) -> bool { *self < *other }
-}
-
-#[cfg(test)]
-#[allow(deprecated, experimental)]
-pub mod test {
-    use super::*;
-    use prelude::*;
-
-    use realstd::c_str::ToCStr;
-    use mem;
-    use libc;
-    use realstd::str;
-    use realstd::str::Str;
-    use realstd::vec::Vec;
-    use realstd::collections::Collection;
-    use slice::{ImmutableVector, MutableVector};
-
-    #[test]
-    fn test() {
-        unsafe {
-            struct Pair {
-                fst: int,
-                snd: int
-            };
-            let mut p = Pair {fst: 10, snd: 20};
-            let pptr: *mut Pair = &mut p;
-            let iptr: *mut int = mem::transmute(pptr);
-            assert_eq!(*iptr, 10);
-            *iptr = 30;
-            assert_eq!(*iptr, 30);
-            assert_eq!(p.fst, 30);
-
-            *pptr = Pair {fst: 50, snd: 60};
-            assert_eq!(*iptr, 50);
-            assert_eq!(p.fst, 50);
-            assert_eq!(p.snd, 60);
-
-            let v0 = vec![32000u16, 32001u16, 32002u16];
-            let mut v1 = vec![0u16, 0u16, 0u16];
-
-            copy_memory(v1.as_mut_ptr().offset(1),
-                        v0.as_ptr().offset(1), 1);
-            assert!((*v1.get(0) == 0u16 &&
-                     *v1.get(1) == 32001u16 &&
-                     *v1.get(2) == 0u16));
-            copy_memory(v1.as_mut_ptr(),
-                        v0.as_ptr().offset(2), 1);
-            assert!((*v1.get(0) == 32002u16 &&
-                     *v1.get(1) == 32001u16 &&
-                     *v1.get(2) == 0u16));
-            copy_memory(v1.as_mut_ptr().offset(2),
-                        v0.as_ptr(), 1u);
-            assert!((*v1.get(0) == 32002u16 &&
-                     *v1.get(1) == 32001u16 &&
-                     *v1.get(2) == 32000u16));
-        }
-    }
-
-    #[test]
-    fn test_position() {
-        use libc::c_char;
-
-        "hello".with_c_str(|p| {
-            unsafe {
-                assert!(2u == position(p, |c| *c == 'l' as c_char));
-                assert!(4u == position(p, |c| *c == 'o' as c_char));
-                assert!(5u == position(p, |c| *c == 0 as c_char));
-            }
-        })
-    }
-
-    #[test]
-    fn test_buf_len() {
-        "hello".with_c_str(|p0| {
-            "there".with_c_str(|p1| {
-                "thing".with_c_str(|p2| {
-                    let v = vec![p0, p1, p2, null()];
-                    unsafe {
-                        assert_eq!(buf_len(v.as_ptr()), 3u);
-                    }
-                })
-            })
-        })
-    }
-
-    #[test]
-    fn test_is_null() {
-        let p: *const int = null();
-        assert!(p.is_null());
-        assert!(!p.is_not_null());
-
-        let q = unsafe { p.offset(1) };
-        assert!(!q.is_null());
-        assert!(q.is_not_null());
-
-        let mp: *mut int = mut_null();
-        assert!(mp.is_null());
-        assert!(!mp.is_not_null());
-
-        let mq = unsafe { mp.offset(1) };
-        assert!(!mq.is_null());
-        assert!(mq.is_not_null());
-    }
-
-    #[test]
-    fn test_to_option() {
-        unsafe {
-            let p: *const int = null();
-            assert_eq!(p.to_option(), None);
-
-            let q: *const int = &2;
-            assert_eq!(q.to_option().unwrap(), &2);
-
-            let p: *mut int = mut_null();
-            assert_eq!(p.to_option(), None);
-
-            let q: *mut int = &mut 2;
-            assert_eq!(q.to_option().unwrap(), &2);
-        }
-    }
-
-    #[test]
-    fn test_ptr_addition() {
-        unsafe {
-            let xs = Vec::from_elem(16, 5i);
-            let mut ptr = xs.as_ptr();
-            let end = ptr.offset(16);
-
-            while ptr < end {
-                assert_eq!(*ptr, 5);
-                ptr = ptr.offset(1);
-            }
-
-            let mut xs_mut = xs;
-            let mut m_ptr = xs_mut.as_mut_ptr();
-            let m_end = m_ptr.offset(16);
-
-            while m_ptr < m_end {
-                *m_ptr += 5;
-                m_ptr = m_ptr.offset(1);
-            }
-
-            assert!(xs_mut == Vec::from_elem(16, 10i));
+    fn partial_cmp(&self, other: &*const T) -> Option<Ordering> {
+        if self < other {
+            Some(Less)
+        } else if self == other {
+            Some(Equal)
+        } else {
+            Some(Greater)
         }
     }
 
-    #[test]
-    fn test_ptr_subtraction() {
-        unsafe {
-            let xs = vec![0,1,2,3,4,5,6,7,8,9];
-            let mut idx = 9i8;
-            let ptr = xs.as_ptr();
+    #[inline]
+    fn lt(&self, other: &*const T) -> bool { *self < *other }
 
-            while idx >= 0i8 {
-                assert_eq!(*(ptr.offset(idx as int)), idx as int);
-                idx = idx - 1i8;
-            }
+    #[inline]
+    fn le(&self, other: &*const T) -> bool { *self <= *other }
 
-            let mut xs_mut = xs;
-            let m_start = xs_mut.as_mut_ptr();
-            let mut m_ptr = m_start.offset(9);
+    #[inline]
+    fn gt(&self, other: &*const T) -> bool { *self > *other }
 
-            while m_ptr >= m_start {
-                *m_ptr += *m_ptr;
-                m_ptr = m_ptr.offset(-1);
-            }
+    #[inline]
+    fn ge(&self, other: &*const T) -> bool { *self >= *other }
+}
 
-            assert!(xs_mut == vec![0,2,4,6,8,10,12,14,16,18]);
+impl<T> PartialOrd for *mut T {
+    #[inline]
+    fn partial_cmp(&self, other: &*mut T) -> Option<Ordering> {
+        if self < other {
+            Some(Less)
+        } else if self == other {
+            Some(Equal)
+        } else {
+            Some(Greater)
         }
     }
 
-    #[test]
-    fn test_ptr_array_each_with_len() {
-        unsafe {
-            let one = "oneOne".to_c_str();
-            let two = "twoTwo".to_c_str();
-            let three = "threeThree".to_c_str();
-            let arr = vec![
-                one.with_ref(|buf| buf),
-                two.with_ref(|buf| buf),
-                three.with_ref(|buf| buf)
-            ];
-            let expected_arr = [
-                one, two, three
-            ];
-
-            let mut ctr = 0;
-            let mut iteration_count = 0;
-            array_each_with_len(arr.as_ptr(), arr.len(), |e| {
-                    let actual = str::raw::from_c_str(e);
-                    let expected = expected_arr[ctr].with_ref(|buf| {
-                            str::raw::from_c_str(buf)
-                        });
-                    assert_eq!(actual.as_slice(), expected.as_slice());
-                    ctr += 1;
-                    iteration_count += 1;
-                });
-            assert_eq!(iteration_count, 3u);
-        }
-    }
+    #[inline]
+    fn lt(&self, other: &*mut T) -> bool { *self < *other }
 
-    #[test]
-    fn test_ptr_array_each() {
-        unsafe {
-            let one = "oneOne".to_c_str();
-            let two = "twoTwo".to_c_str();
-            let three = "threeThree".to_c_str();
-            let arr = vec![
-                one.with_ref(|buf| buf),
-                two.with_ref(|buf| buf),
-                three.with_ref(|buf| buf),
-                // fake a null terminator
-                null()
-            ];
-            let expected_arr = [
-                one, two, three
-            ];
-
-            let arr_ptr = arr.as_ptr();
-            let mut ctr = 0u;
-            let mut iteration_count = 0u;
-            array_each(arr_ptr, |e| {
-                    let actual = str::raw::from_c_str(e);
-                    let expected = expected_arr[ctr].with_ref(|buf| {
-                        str::raw::from_c_str(buf)
-                    });
-                    assert_eq!(actual.as_slice(), expected.as_slice());
-                    ctr += 1;
-                    iteration_count += 1;
-                });
-            assert_eq!(iteration_count, 3);
-        }
-    }
+    #[inline]
+    fn le(&self, other: &*mut T) -> bool { *self <= *other }
 
-    #[test]
-    #[should_fail]
-    fn test_ptr_array_each_with_len_null_ptr() {
-        unsafe {
-            array_each_with_len(0 as *const *const libc::c_char, 1, |e| {
-                str::raw::from_c_str(e);
-            });
-        }
-    }
-    #[test]
-    #[should_fail]
-    fn test_ptr_array_each_null_ptr() {
-        unsafe {
-            array_each(0 as *const *const libc::c_char, |e| {
-                str::raw::from_c_str(e);
-            });
-        }
-    }
+    #[inline]
+    fn gt(&self, other: &*mut T) -> bool { *self > *other }
 
-    #[test]
-    fn test_set_memory() {
-        let mut xs = [0u8, ..20];
-        let ptr = xs.as_mut_ptr();
-        unsafe { set_memory(ptr, 5u8, xs.len()); }
-        assert!(xs == [5u8, ..20]);
-    }
+    #[inline]
+    fn ge(&self, other: &*mut T) -> bool { *self >= *other }
 }
index f32e6bd9c7cc5986361df5277505f47d18f0c38a..da9fab0fc6f50ef8894618d0076214a703df268f 100644 (file)
@@ -70,32 +70,3 @@ fn repr(&self) -> T { unsafe { mem::transmute_copy(self) } }
 impl<'a, T> Repr<Slice<T>> for &'a [T] {}
 impl<'a> Repr<Slice<u8>> for &'a str {}
 
-#[cfg(test)]
-mod tests {
-    use super::*;
-
-    use mem;
-
-    #[test]
-    fn synthesize_closure() {
-        unsafe {
-            let x = 10;
-            let f: |int| -> int = |y| x + y;
-
-            assert_eq!(f(20), 30);
-
-            let original_closure: Closure = mem::transmute(f);
-
-            let actual_function_pointer = original_closure.code;
-            let environment = original_closure.env;
-
-            let new_closure = Closure {
-                code: actual_function_pointer,
-                env: environment
-            };
-
-            let new_f: |int| -> int = mem::transmute(new_closure);
-            assert_eq!(new_f(20), 30);
-        }
-    }
-}
index 6c163b7919920b08d0d528b0a437eee6bddd7c4b..5cbbf30cd360721c912bdb4e63fd07031c6e93c9 100644 (file)
@@ -585,20 +585,32 @@ pub fn unwrap_err(self) -> E {
 /// ```
 #[inline]
 pub fn collect<T, E, Iter: Iterator<Result<T, E>>, V: FromIterator<T>>(iter: Iter) -> Result<V, E> {
-    // FIXME(#11084): This should be twice as fast once this bug is closed.
-    let mut iter = iter.scan(None, |state, x| {
-        match x {
-            Ok(x) => Some(x),
-            Err(err) => {
-                *state = Some(err);
-                None
+    // FIXME(#11084): This could be replaced with Iterator::scan when this
+    // performance bug is closed.
+
+    struct Adapter<Iter, E> {
+        iter: Iter,
+        err: Option<E>,
+    }
+
+    impl<T, E, Iter: Iterator<Result<T, E>>> Iterator<T> for Adapter<Iter, E> {
+        #[inline]
+        fn next(&mut self) -> Option<T> {
+            match self.iter.next() {
+                Some(Ok(value)) => Some(value),
+                Some(Err(err)) => {
+                    self.err = Some(err);
+                    None
+                }
+                None => None,
             }
         }
-    });
+    }
 
-    let v: V = FromIterator::from_iter(iter.by_ref());
+    let mut adapter = Adapter { iter: iter, err: None };
+    let v: V = FromIterator::from_iter(adapter.by_ref());
 
-    match iter.state {
+    match adapter.err {
         Some(err) => Err(err),
         None => Ok(v),
     }
@@ -635,166 +647,3 @@ pub fn fold<T,
 pub fn fold_<T,E,Iter:Iterator<Result<T,E>>>(iterator: Iter) -> Result<(),E> {
     fold(iterator, (), |_, _| ())
 }
-
-/////////////////////////////////////////////////////////////////////////////
-// Tests
-/////////////////////////////////////////////////////////////////////////////
-
-#[cfg(test)]
-mod tests {
-    use realstd::vec::Vec;
-
-    use result::{collect, fold, fold_};
-    use prelude::*;
-    use realstd::str::Str;
-    use iter::range;
-
-    pub fn op1() -> Result<int, &'static str> { Ok(666) }
-    pub fn op2() -> Result<int, &'static str> { Err("sadface") }
-
-    #[test]
-    pub fn test_and() {
-        assert_eq!(op1().and(Ok(667i)).unwrap(), 667);
-        assert_eq!(op1().and(Err::<(), &'static str>("bad")).unwrap_err(),
-                   "bad");
-
-        assert_eq!(op2().and(Ok(667i)).unwrap_err(), "sadface");
-        assert_eq!(op2().and(Err::<(),&'static str>("bad")).unwrap_err(),
-                   "sadface");
-    }
-
-    #[test]
-    pub fn test_and_then() {
-        assert_eq!(op1().and_then(|i| Ok::<int, &'static str>(i + 1)).unwrap(), 667);
-        assert_eq!(op1().and_then(|_| Err::<int, &'static str>("bad")).unwrap_err(),
-                   "bad");
-
-        assert_eq!(op2().and_then(|i| Ok::<int, &'static str>(i + 1)).unwrap_err(),
-                   "sadface");
-        assert_eq!(op2().and_then(|_| Err::<int, &'static str>("bad")).unwrap_err(),
-                   "sadface");
-    }
-
-    #[test]
-    pub fn test_or() {
-        assert_eq!(op1().or(Ok(667)).unwrap(), 666);
-        assert_eq!(op1().or(Err("bad")).unwrap(), 666);
-
-        assert_eq!(op2().or(Ok(667)).unwrap(), 667);
-        assert_eq!(op2().or(Err("bad")).unwrap_err(), "bad");
-    }
-
-    #[test]
-    pub fn test_or_else() {
-        assert_eq!(op1().or_else(|_| Ok::<int, &'static str>(667)).unwrap(), 666);
-        assert_eq!(op1().or_else(|e| Err::<int, &'static str>(e)).unwrap(), 666);
-
-        assert_eq!(op2().or_else(|_| Ok::<int, &'static str>(667)).unwrap(), 667);
-        assert_eq!(op2().or_else(|e| Err::<int, &'static str>(e)).unwrap_err(),
-                   "sadface");
-    }
-
-    #[test]
-    pub fn test_impl_map() {
-        assert!(Ok::<int, int>(1).map(|x| x + 1) == Ok(2));
-        assert!(Err::<int, int>(1).map(|x| x + 1) == Err(1));
-    }
-
-    #[test]
-    pub fn test_impl_map_err() {
-        assert!(Ok::<int, int>(1).map_err(|x| x + 1) == Ok(1));
-        assert!(Err::<int, int>(1).map_err(|x| x + 1) == Err(2));
-    }
-
-    #[test]
-    fn test_collect() {
-        let v: Result<Vec<int>, ()> = collect(range(0i, 0).map(|_| Ok::<int, ()>(0)));
-        assert!(v == Ok(vec![]));
-
-        let v: Result<Vec<int>, ()> = collect(range(0i, 3).map(|x| Ok::<int, ()>(x)));
-        assert!(v == Ok(vec![0, 1, 2]));
-
-        let v: Result<Vec<int>, int> = collect(range(0i, 3)
-                                               .map(|x| if x > 1 { Err(x) } else { Ok(x) }));
-        assert!(v == Err(2));
-
-        // test that it does not take more elements than it needs
-        let mut functions = [|| Ok(()), || Err(1i), || fail!()];
-
-        let v: Result<Vec<()>, int> = collect(functions.mut_iter().map(|f| (*f)()));
-        assert!(v == Err(1));
-    }
-
-    #[test]
-    fn test_fold() {
-        assert_eq!(fold_(range(0i, 0)
-                        .map(|_| Ok::<(), ()>(()))),
-                   Ok(()));
-        assert_eq!(fold(range(0i, 3)
-                        .map(|x| Ok::<int, ()>(x)),
-                        0, |a, b| a + b),
-                   Ok(3));
-        assert_eq!(fold_(range(0i, 3)
-                        .map(|x| if x > 1 { Err(x) } else { Ok(()) })),
-                   Err(2));
-
-        // test that it does not take more elements than it needs
-        let mut functions = [|| Ok(()), || Err(1i), || fail!()];
-
-        assert_eq!(fold_(functions.mut_iter()
-                        .map(|f| (*f)())),
-                   Err(1));
-    }
-
-    #[test]
-    pub fn test_fmt_default() {
-        let ok: Result<int, &'static str> = Ok(100);
-        let err: Result<int, &'static str> = Err("Err");
-
-        let s = format!("{}", ok);
-        assert_eq!(s.as_slice(), "Ok(100)");
-        let s = format!("{}", err);
-        assert_eq!(s.as_slice(), "Err(Err)");
-    }
-
-    #[test]
-    pub fn test_unwrap_or() {
-        let ok: Result<int, &'static str> = Ok(100i);
-        let ok_err: Result<int, &'static str> = Err("Err");
-
-        assert_eq!(ok.unwrap_or(50), 100);
-        assert_eq!(ok_err.unwrap_or(50), 50);
-    }
-
-    #[test]
-    pub fn test_unwrap_or_else() {
-        fn handler(msg: &'static str) -> int {
-            if msg == "I got this." {
-                50i
-            } else {
-                fail!("BadBad")
-            }
-        }
-
-        let ok: Result<int, &'static str> = Ok(100);
-        let ok_err: Result<int, &'static str> = Err("I got this.");
-
-        assert_eq!(ok.unwrap_or_else(handler), 100);
-        assert_eq!(ok_err.unwrap_or_else(handler), 50);
-    }
-
-    #[test]
-    #[should_fail]
-    pub fn test_unwrap_or_else_failure() {
-        fn handler(msg: &'static str) -> int {
-            if msg == "I got this." {
-                50i
-            } else {
-                fail!("BadBad")
-            }
-        }
-
-        let bad_err: Result<int, &'static str> = Err("Unrecoverable mess.");
-        let _ : int = bad_err.unwrap_or_else(handler);
-    }
-}
index fea7986eee5951793455e2cd8ad52b2522b00c34..a9e7efdf05a5ada6177858be6609b33f093ee568 100644 (file)
@@ -246,7 +246,6 @@ fn idx(&mut self, index: uint) -> Option<&'a [T]> {
 
 // Equality
 
-#[cfg(not(test))]
 #[allow(missing_doc)]
 pub mod traits {
     use super::*;
@@ -254,6 +253,7 @@ pub mod traits {
     use cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering, Equiv};
     use iter::order;
     use collections::Collection;
+    use option::Option;
 
     impl<'a,T:PartialEq> PartialEq for &'a [T] {
         fn eq(&self, other: & &'a [T]) -> bool {
@@ -280,6 +280,11 @@ fn cmp(&self, other: & &'a [T]) -> Ordering {
     }
 
     impl<'a, T: PartialOrd> PartialOrd for &'a [T] {
+        #[inline]
+        fn partial_cmp(&self, other: &&'a [T]) -> Option<Ordering> {
+            order::partial_cmp(self.iter(), other.iter())
+        }
+        #[inline]
         fn lt(&self, other: & &'a [T]) -> bool {
             order::lt(self.iter(), other.iter())
         }
@@ -298,9 +303,6 @@ fn gt(&self, other: & &'a [T]) -> bool {
     }
 }
 
-#[cfg(test)]
-pub mod traits {}
-
 /// Any vector that can be represented as a slice.
 pub trait Vector<T> {
     /// Work with `self` as a slice.
index 0d4b5f590742be64e0740a223aeb7e4d5f940364..b336c57efa07228ad8d6d54518b3e6af46904079 100644 (file)
@@ -16,6 +16,7 @@
 
 use mem;
 use char;
+use char::Char;
 use clone::Clone;
 use cmp;
 use cmp::{PartialEq, Eq};
@@ -24,7 +25,7 @@
 use iter::{Filter, Map, Iterator};
 use iter::{DoubleEndedIterator, ExactSize};
 use iter::range;
-use num::Saturating;
+use num::{CheckedMul, Saturating};
 use option::{None, Option, Some};
 use raw::Repr;
 use slice::ImmutableVector;
@@ -557,6 +558,41 @@ fn next(&mut self) -> Option<&'a str> {
     }
 }
 
+/// External iterator for a string's UTF16 codeunits.
+/// Use with the `std::iter` module.
+#[deriving(Clone)]
+pub struct Utf16CodeUnits<'a> {
+    chars: Chars<'a>,
+    extra: u16
+}
+
+impl<'a> Iterator<u16> for Utf16CodeUnits<'a> {
+    #[inline]
+    fn next(&mut self) -> Option<u16> {
+        if self.extra != 0 {
+            let tmp = self.extra;
+            self.extra = 0;
+            return Some(tmp);
+        }
+
+        let mut buf = [0u16, ..2];
+        self.chars.next().map(|ch| {
+            let n = ch.encode_utf16(buf /* as mut slice! */);
+            if n == 2 { self.extra = buf[1]; }
+            buf[0]
+        })
+    }
+
+    #[inline]
+    fn size_hint(&self) -> (uint, Option<uint>) {
+        let (low, high) = self.chars.size_hint();
+        // every char gets either one u16 or two u16,
+        // so this iterator is between 1 or 2 times as
+        // long as the underlying iterator.
+        (low, high.and_then(|n| n.checked_mul(&2)))
+    }
+}
+
 /*
 Section: Comparing strings
 */
@@ -579,20 +615,12 @@ fn eq_slice_(a: &str, b: &str) -> bool {
 /// Bytewise slice equality
 /// NOTE: This function is (ab)used in rustc::middle::trans::_match
 /// to compare &[u8] byte slices that are not necessarily valid UTF-8.
-#[cfg(not(test))]
 #[lang="str_eq"]
 #[inline]
 pub fn eq_slice(a: &str, b: &str) -> bool {
     eq_slice_(a, b)
 }
 
-/// Bytewise slice equality
-#[cfg(test)]
-#[inline]
-pub fn eq_slice(a: &str, b: &str) -> bool {
-    eq_slice_(a, b)
-}
-
 /*
 Section: Misc
 */
@@ -934,13 +962,12 @@ pub unsafe fn slice_unchecked<'a>(s: &'a str, begin: uint, end: uint) -> &'a str
 Section: Trait implementations
 */
 
-#[cfg(not(test))]
 #[allow(missing_doc)]
 pub mod traits {
     use cmp::{Ord, Ordering, Less, Equal, Greater, PartialEq, PartialOrd, Equiv, Eq};
     use collections::Collection;
     use iter::Iterator;
-    use option::{Some, None};
+    use option::{Option, Some, None};
     use str::{Str, StrSlice, eq_slice};
 
     impl<'a> Ord for &'a str {
@@ -971,7 +998,9 @@ impl<'a> Eq for &'a str {}
 
     impl<'a> PartialOrd for &'a str {
         #[inline]
-        fn lt(&self, other: & &'a str) -> bool { self.cmp(other) == Less }
+        fn partial_cmp(&self, other: &&'a str) -> Option<Ordering> {
+            Some(self.cmp(other))
+        }
     }
 
     impl<'a, S: Str> Equiv<S> for &'a str {
@@ -980,9 +1009,6 @@ fn equiv(&self, other: &S) -> bool { eq_slice(*self, other.as_slice()) }
     }
 }
 
-#[cfg(test)]
-pub mod traits {}
-
 /// Any string that can be represented as a slice
 pub trait Str {
     /// Work with `self` as a slice.
@@ -1619,6 +1645,9 @@ pub trait StrSlice<'a> {
     /// and that it is not reallocated (e.g. by pushing to the
     /// string).
     fn as_ptr(&self) -> *const u8;
+
+    /// Return an iterator of `u16` over the string encoded as UTF-16.
+    fn utf16_units(&self) -> Utf16CodeUnits<'a>;
 }
 
 impl<'a> StrSlice<'a> for &'a str {
@@ -1967,6 +1996,11 @@ fn subslice_offset(&self, inner: &str) -> uint {
     fn as_ptr(&self) -> *const u8 {
         self.repr().data
     }
+
+    #[inline]
+    fn utf16_units(&self) -> Utf16CodeUnits<'a> {
+        Utf16CodeUnits{ chars: self.chars(), extra: 0}
+    }
 }
 
 impl<'a> Default for &'a str {
index 3508da5d516289c7ef3ceaae7ba3629c94a1ba74..0e3722894bc467771f52af3266c888691733581a 100644 (file)
@@ -62,8 +62,9 @@
 #![doc(primitive = "tuple")]
 
 use clone::Clone;
-#[cfg(not(test))] use cmp::*;
-#[cfg(not(test))] use default::Default;
+use cmp::*;
+use default::Default;
+use option::{Option, Some};
 
 // macro for implementing n-ary tuple functions and operations
 macro_rules! tuple_impls {
@@ -111,7 +112,6 @@ fn clone(&self) -> ($($T,)+) {
                 }
             }
 
-            #[cfg(not(test))]
             impl<$($T:PartialEq),+> PartialEq for ($($T,)+) {
                 #[inline]
                 fn eq(&self, other: &($($T,)+)) -> bool {
@@ -123,11 +123,13 @@ fn ne(&self, other: &($($T,)+)) -> bool {
                 }
             }
 
-            #[cfg(not(test))]
             impl<$($T:Eq),+> Eq for ($($T,)+) {}
 
-            #[cfg(not(test))]
             impl<$($T:PartialOrd + PartialEq),+> PartialOrd for ($($T,)+) {
+                #[inline]
+                fn partial_cmp(&self, other: &($($T,)+)) -> Option<Ordering> {
+                    lexical_partial_cmp!($(self.$refN(), other.$refN()),+)
+                }
                 #[inline]
                 fn lt(&self, other: &($($T,)+)) -> bool {
                     lexical_ord!(lt, $(self.$refN(), other.$refN()),+)
@@ -146,7 +148,6 @@ fn gt(&self, other: &($($T,)+)) -> bool {
                 }
             }
 
-            #[cfg(not(test))]
             impl<$($T:Ord),+> Ord for ($($T,)+) {
                 #[inline]
                 fn cmp(&self, other: &($($T,)+)) -> Ordering {
@@ -154,7 +155,6 @@ fn cmp(&self, other: &($($T,)+)) -> Ordering {
                 }
             }
 
-            #[cfg(not(test))]
             impl<$($T:Default),+> Default for ($($T,)+) {
                 #[inline]
                 fn default() -> ($($T,)+) {
@@ -177,6 +177,16 @@ macro_rules! lexical_ord {
     ($rel: ident, $a:expr, $b:expr) => { (*$a) . $rel ($b) };
 }
 
+macro_rules! lexical_partial_cmp {
+    ($a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => {
+        match ($a).partial_cmp($b) {
+            Some(Equal) => lexical_partial_cmp!($($rest_a, $rest_b),+),
+            ordering   => ordering
+        }
+    };
+    ($a:expr, $b:expr) => { ($a).partial_cmp($b) };
+}
+
 macro_rules! lexical_cmp {
     ($a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => {
         match ($a).cmp($b) {
@@ -292,93 +302,3 @@ macro_rules! lexical_cmp {
     }
 }
 
-#[cfg(test)]
-mod tests {
-    use super::*;
-    use clone::Clone;
-    use cmp::*;
-    use realstd::str::Str;
-
-    #[test]
-    fn test_clone() {
-        let a = (1i, "2");
-        let b = a.clone();
-        assert_eq!(a, b);
-    }
-
-    #[test]
-    fn test_getters() {
-        macro_rules! test_getter(
-            ($x:expr, $valN:ident, $refN:ident, $mutN:ident,
-             $init:expr, $incr:expr, $result:expr) => ({
-                assert_eq!($x.$valN(), $init);
-                assert_eq!(*$x.$refN(), $init);
-                *$x.$mutN() += $incr;
-                assert_eq!(*$x.$refN(), $result);
-            })
-        )
-        let mut x = (0u8, 1u16, 2u32, 3u64, 4u, 5i8, 6i16, 7i32, 8i64, 9i, 10f32, 11f64);
-        test_getter!(x, val0,  ref0,  mut0,  0,    1,   1);
-        test_getter!(x, val1,  ref1,  mut1,  1,    1,   2);
-        test_getter!(x, val2,  ref2,  mut2,  2,    1,   3);
-        test_getter!(x, val3,  ref3,  mut3,  3,    1,   4);
-        test_getter!(x, val4,  ref4,  mut4,  4,    1,   5);
-        test_getter!(x, val5,  ref5,  mut5,  5,    1,   6);
-        test_getter!(x, val6,  ref6,  mut6,  6,    1,   7);
-        test_getter!(x, val7,  ref7,  mut7,  7,    1,   8);
-        test_getter!(x, val8,  ref8,  mut8,  8,    1,   9);
-        test_getter!(x, val9,  ref9,  mut9,  9,    1,   10);
-        test_getter!(x, val10, ref10, mut10, 10.0, 1.0, 11.0);
-        test_getter!(x, val11, ref11, mut11, 11.0, 1.0, 12.0);
-    }
-
-    #[test]
-    fn test_tuple_cmp() {
-        let (small, big) = ((1u, 2u, 3u), (3u, 2u, 1u));
-
-        let nan = 0.0f64/0.0;
-
-        // PartialEq
-        assert_eq!(small, small);
-        assert_eq!(big, big);
-        assert!(small != big);
-        assert!(big != small);
-
-        // PartialOrd
-        assert!(small < big);
-        assert!(!(small < small));
-        assert!(!(big < small));
-        assert!(!(big < big));
-
-        assert!(small <= small);
-        assert!(big <= big);
-
-        assert!(big > small);
-        assert!(small >= small);
-        assert!(big >= small);
-        assert!(big >= big);
-
-        assert!(!((1.0f64, 2.0f64) < (nan, 3.0)));
-        assert!(!((1.0f64, 2.0f64) <= (nan, 3.0)));
-        assert!(!((1.0f64, 2.0f64) > (nan, 3.0)));
-        assert!(!((1.0f64, 2.0f64) >= (nan, 3.0)));
-        assert!(((1.0f64, 2.0f64) < (2.0, nan)));
-        assert!(!((2.0f64, 2.0f64) < (2.0, nan)));
-
-        // Ord
-        assert!(small.cmp(&small) == Equal);
-        assert!(big.cmp(&big) == Equal);
-        assert!(small.cmp(&big) == Less);
-        assert!(big.cmp(&small) == Greater);
-    }
-
-    #[test]
-    fn test_show() {
-        let s = format!("{}", (1i,));
-        assert_eq!(s.as_slice(), "(1,)");
-        let s = format!("{}", (1i, true));
-        assert_eq!(s.as_slice(), "(1, true)");
-        let s = format!("{}", (1i, "hi", true));
-        assert_eq!(s.as_slice(), "(1, hi, true)");
-    }
-}
diff --git a/src/libcoretest/any.rs b/src/libcoretest/any.rs
new file mode 100644 (file)
index 0000000..fae4a26
--- /dev/null
@@ -0,0 +1,131 @@
+// 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 core::any::*;
+use test::Bencher;
+use test;
+
+#[deriving(PartialEq, Show)]
+struct Test;
+
+static TEST: &'static str = "Test";
+
+#[test]
+fn any_referenced() {
+    let (a, b, c) = (&5u as &Any, &TEST as &Any, &Test as &Any);
+
+    assert!(a.is::<uint>());
+    assert!(!b.is::<uint>());
+    assert!(!c.is::<uint>());
+
+    assert!(!a.is::<&'static str>());
+    assert!(b.is::<&'static str>());
+    assert!(!c.is::<&'static str>());
+
+    assert!(!a.is::<Test>());
+    assert!(!b.is::<Test>());
+    assert!(c.is::<Test>());
+}
+
+#[test]
+fn any_owning() {
+    let (a, b, c) = (box 5u as Box<Any>, box TEST as Box<Any>, box Test as Box<Any>);
+
+    assert!(a.is::<uint>());
+    assert!(!b.is::<uint>());
+    assert!(!c.is::<uint>());
+
+    assert!(!a.is::<&'static str>());
+    assert!(b.is::<&'static str>());
+    assert!(!c.is::<&'static str>());
+
+    assert!(!a.is::<Test>());
+    assert!(!b.is::<Test>());
+    assert!(c.is::<Test>());
+}
+
+#[test]
+fn any_as_ref() {
+    let a = &5u as &Any;
+
+    match a.as_ref::<uint>() {
+        Some(&5) => {}
+        x => fail!("Unexpected value {}", x)
+    }
+
+    match a.as_ref::<Test>() {
+        None => {}
+        x => fail!("Unexpected value {}", x)
+    }
+}
+
+#[test]
+fn any_as_mut() {
+    let mut a = 5u;
+    let mut b = box 7u;
+
+    let a_r = &mut a as &mut Any;
+    let tmp: &mut uint = &mut *b;
+    let b_r = tmp as &mut Any;
+
+    match a_r.as_mut::<uint>() {
+        Some(x) => {
+            assert_eq!(*x, 5u);
+            *x = 612;
+        }
+        x => fail!("Unexpected value {}", x)
+    }
+
+    match b_r.as_mut::<uint>() {
+        Some(x) => {
+            assert_eq!(*x, 7u);
+            *x = 413;
+        }
+        x => fail!("Unexpected value {}", x)
+    }
+
+    match a_r.as_mut::<Test>() {
+        None => (),
+        x => fail!("Unexpected value {}", x)
+    }
+
+    match b_r.as_mut::<Test>() {
+        None => (),
+        x => fail!("Unexpected value {}", x)
+    }
+
+    match a_r.as_mut::<uint>() {
+        Some(&612) => {}
+        x => fail!("Unexpected value {}", x)
+    }
+
+    match b_r.as_mut::<uint>() {
+        Some(&413) => {}
+        x => fail!("Unexpected value {}", x)
+    }
+}
+
+#[test]
+fn any_fixed_vec() {
+    let test = [0u, ..8];
+    let test = &test as &Any;
+    assert!(test.is::<[uint, ..8]>());
+    assert!(!test.is::<[uint, ..10]>());
+}
+
+
+#[bench]
+fn bench_as_ref(b: &mut Bencher) {
+    b.iter(|| {
+        let mut x = 0i;
+        let mut y = &mut x as &mut Any;
+        test::black_box(&mut y);
+        test::black_box(y.as_ref::<int>() == Some(&0));
+    });
+}
diff --git a/src/libcoretest/atomics.rs b/src/libcoretest/atomics.rs
new file mode 100644 (file)
index 0000000..3f960ae
--- /dev/null
@@ -0,0 +1,83 @@
+// 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 core::atomics::*;
+
+#[test]
+fn bool_() {
+    let a = AtomicBool::new(false);
+    assert_eq!(a.compare_and_swap(false, true, SeqCst), false);
+    assert_eq!(a.compare_and_swap(false, true, SeqCst), true);
+
+    a.store(false, SeqCst);
+    assert_eq!(a.compare_and_swap(false, true, SeqCst), false);
+}
+
+#[test]
+fn bool_and() {
+    let a = AtomicBool::new(true);
+    assert_eq!(a.fetch_and(false, SeqCst),true);
+    assert_eq!(a.load(SeqCst),false);
+}
+
+#[test]
+fn uint_and() {
+    let x = AtomicUint::new(0xf731);
+    assert_eq!(x.fetch_and(0x137f, SeqCst), 0xf731);
+    assert_eq!(x.load(SeqCst), 0xf731 & 0x137f);
+}
+
+#[test]
+fn uint_or() {
+    let x = AtomicUint::new(0xf731);
+    assert_eq!(x.fetch_or(0x137f, SeqCst), 0xf731);
+    assert_eq!(x.load(SeqCst), 0xf731 | 0x137f);
+}
+
+#[test]
+fn uint_xor() {
+    let x = AtomicUint::new(0xf731);
+    assert_eq!(x.fetch_xor(0x137f, SeqCst), 0xf731);
+    assert_eq!(x.load(SeqCst), 0xf731 ^ 0x137f);
+}
+
+#[test]
+fn int_and() {
+    let x = AtomicInt::new(0xf731);
+    assert_eq!(x.fetch_and(0x137f, SeqCst), 0xf731);
+    assert_eq!(x.load(SeqCst), 0xf731 & 0x137f);
+}
+
+#[test]
+fn int_or() {
+    let x = AtomicInt::new(0xf731);
+    assert_eq!(x.fetch_or(0x137f, SeqCst), 0xf731);
+    assert_eq!(x.load(SeqCst), 0xf731 | 0x137f);
+}
+
+#[test]
+fn int_xor() {
+    let x = AtomicInt::new(0xf731);
+    assert_eq!(x.fetch_xor(0x137f, SeqCst), 0xf731);
+    assert_eq!(x.load(SeqCst), 0xf731 ^ 0x137f);
+}
+
+static mut S_BOOL : AtomicBool = INIT_ATOMIC_BOOL;
+static mut S_INT  : AtomicInt  = INIT_ATOMIC_INT;
+static mut S_UINT : AtomicUint = INIT_ATOMIC_UINT;
+
+#[test]
+fn static_init() {
+    unsafe {
+        assert!(!S_BOOL.load(SeqCst));
+        assert!(S_INT.load(SeqCst) == 0);
+        assert!(S_UINT.load(SeqCst) == 0);
+    }
+}
diff --git a/src/libcoretest/cell.rs b/src/libcoretest/cell.rs
new file mode 100644 (file)
index 0000000..b3ae110
--- /dev/null
@@ -0,0 +1,129 @@
+// 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 core::cell::*;
+use std::mem::drop;
+
+#[test]
+fn smoketest_cell() {
+    let x = Cell::new(10i);
+    assert!(x == Cell::new(10));
+    assert!(x.get() == 10);
+    x.set(20);
+    assert!(x == Cell::new(20));
+    assert!(x.get() == 20);
+
+    let y = Cell::new((30i, 40i));
+    assert!(y == Cell::new((30, 40)));
+    assert!(y.get() == (30, 40));
+}
+
+#[test]
+fn cell_has_sensible_show() {
+    let x = Cell::new("foo bar");
+    assert!(format!("{}", x).as_slice().contains(x.get()));
+
+    x.set("baz qux");
+    assert!(format!("{}", x).as_slice().contains(x.get()));
+}
+
+#[test]
+fn ref_and_refmut_have_sensible_show() {
+    let refcell = RefCell::new("foo");
+
+    let refcell_refmut = refcell.borrow_mut();
+    assert!(format!("{}", refcell_refmut).as_slice().contains("foo"));
+    drop(refcell_refmut);
+
+    let refcell_ref = refcell.borrow();
+    assert!(format!("{}", refcell_ref).as_slice().contains("foo"));
+    drop(refcell_ref);
+}
+
+#[test]
+fn double_imm_borrow() {
+    let x = RefCell::new(0i);
+    let _b1 = x.borrow();
+    x.borrow();
+}
+
+#[test]
+fn no_mut_then_imm_borrow() {
+    let x = RefCell::new(0i);
+    let _b1 = x.borrow_mut();
+    assert!(x.try_borrow().is_none());
+}
+
+#[test]
+fn no_imm_then_borrow_mut() {
+    let x = RefCell::new(0i);
+    let _b1 = x.borrow();
+    assert!(x.try_borrow_mut().is_none());
+}
+
+#[test]
+fn no_double_borrow_mut() {
+    let x = RefCell::new(0i);
+    let _b1 = x.borrow_mut();
+    assert!(x.try_borrow_mut().is_none());
+}
+
+#[test]
+fn imm_release_borrow_mut() {
+    let x = RefCell::new(0i);
+    {
+        let _b1 = x.borrow();
+    }
+    x.borrow_mut();
+}
+
+#[test]
+fn mut_release_borrow_mut() {
+    let x = RefCell::new(0i);
+    {
+        let _b1 = x.borrow_mut();
+    }
+    x.borrow();
+}
+
+#[test]
+fn double_borrow_single_release_no_borrow_mut() {
+    let x = RefCell::new(0i);
+    let _b1 = x.borrow();
+    {
+        let _b2 = x.borrow();
+    }
+    assert!(x.try_borrow_mut().is_none());
+}
+
+#[test]
+#[should_fail]
+fn discard_doesnt_unborrow() {
+    let x = RefCell::new(0i);
+    let _b = x.borrow();
+    let _ = _b;
+    let _b = x.borrow_mut();
+}
+
+#[test]
+#[allow(experimental)]
+fn clone_ref_updates_flag() {
+    let x = RefCell::new(0i);
+    {
+        let b1 = x.borrow();
+        assert!(x.try_borrow_mut().is_none());
+        {
+            let _b2 = clone_ref(&b1);
+            assert!(x.try_borrow_mut().is_none());
+        }
+        assert!(x.try_borrow_mut().is_none());
+    }
+    assert!(x.try_borrow_mut().is_some());
+}
diff --git a/src/libcoretest/char.rs b/src/libcoretest/char.rs
new file mode 100644 (file)
index 0000000..852edd9
--- /dev/null
@@ -0,0 +1,202 @@
+// 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 core::char::{escape_unicode, escape_default};
+
+#[test]
+fn test_is_lowercase() {
+    assert!('a'.is_lowercase());
+    assert!('ö'.is_lowercase());
+    assert!('ß'.is_lowercase());
+    assert!(!'Ü'.is_lowercase());
+    assert!(!'P'.is_lowercase());
+}
+
+#[test]
+fn test_is_uppercase() {
+    assert!(!'h'.is_uppercase());
+    assert!(!'ä'.is_uppercase());
+    assert!(!'ß'.is_uppercase());
+    assert!('Ö'.is_uppercase());
+    assert!('T'.is_uppercase());
+}
+
+#[test]
+fn test_is_whitespace() {
+    assert!(' '.is_whitespace());
+    assert!('\u2007'.is_whitespace());
+    assert!('\t'.is_whitespace());
+    assert!('\n'.is_whitespace());
+    assert!(!'a'.is_whitespace());
+    assert!(!'_'.is_whitespace());
+    assert!(!'\u0000'.is_whitespace());
+}
+
+#[test]
+fn test_to_digit() {
+    assert_eq!('0'.to_digit(10u), Some(0u));
+    assert_eq!('1'.to_digit(2u), Some(1u));
+    assert_eq!('2'.to_digit(3u), Some(2u));
+    assert_eq!('9'.to_digit(10u), Some(9u));
+    assert_eq!('a'.to_digit(16u), Some(10u));
+    assert_eq!('A'.to_digit(16u), Some(10u));
+    assert_eq!('b'.to_digit(16u), Some(11u));
+    assert_eq!('B'.to_digit(16u), Some(11u));
+    assert_eq!('z'.to_digit(36u), Some(35u));
+    assert_eq!('Z'.to_digit(36u), Some(35u));
+    assert_eq!(' '.to_digit(10u), None);
+    assert_eq!('$'.to_digit(36u), None);
+}
+
+#[test]
+fn test_to_lowercase() {
+    assert_eq!('A'.to_lowercase(), 'a');
+    assert_eq!('Ö'.to_lowercase(), 'ö');
+    assert_eq!('ß'.to_lowercase(), 'ß');
+    assert_eq!('Ü'.to_lowercase(), 'ü');
+    assert_eq!('💩'.to_lowercase(), '💩');
+    assert_eq!('Σ'.to_lowercase(), 'σ');
+    assert_eq!('Τ'.to_lowercase(), 'τ');
+    assert_eq!('Ι'.to_lowercase(), 'ι');
+    assert_eq!('Γ'.to_lowercase(), 'γ');
+    assert_eq!('Μ'.to_lowercase(), 'μ');
+    assert_eq!('Α'.to_lowercase(), 'α');
+    assert_eq!('Σ'.to_lowercase(), 'σ');
+}
+
+#[test]
+fn test_to_uppercase() {
+    assert_eq!('a'.to_uppercase(), 'A');
+    assert_eq!('ö'.to_uppercase(), 'Ö');
+    assert_eq!('ß'.to_uppercase(), 'ß'); // not ẞ: Latin capital letter sharp s
+    assert_eq!('ü'.to_uppercase(), 'Ü');
+    assert_eq!('💩'.to_uppercase(), '💩');
+
+    assert_eq!('σ'.to_uppercase(), 'Σ');
+    assert_eq!('τ'.to_uppercase(), 'Τ');
+    assert_eq!('ι'.to_uppercase(), 'Ι');
+    assert_eq!('γ'.to_uppercase(), 'Γ');
+    assert_eq!('μ'.to_uppercase(), 'Μ');
+    assert_eq!('α'.to_uppercase(), 'Α');
+    assert_eq!('ς'.to_uppercase(), 'Σ');
+}
+
+#[test]
+fn test_is_control() {
+    assert!('\u0000'.is_control());
+    assert!('\u0003'.is_control());
+    assert!('\u0006'.is_control());
+    assert!('\u0009'.is_control());
+    assert!('\u007f'.is_control());
+    assert!('\u0092'.is_control());
+    assert!(!'\u0020'.is_control());
+    assert!(!'\u0055'.is_control());
+    assert!(!'\u0068'.is_control());
+}
+
+#[test]
+fn test_is_digit() {
+   assert!('2'.is_digit());
+   assert!('7'.is_digit());
+   assert!(!'c'.is_digit());
+   assert!(!'i'.is_digit());
+   assert!(!'z'.is_digit());
+   assert!(!'Q'.is_digit());
+}
+
+#[test]
+fn test_escape_default() {
+    fn string(c: char) -> String {
+        let mut result = String::new();
+        escape_default(c, |c| { result.push_char(c); });
+        return result;
+    }
+    let s = string('\n');
+    assert_eq!(s.as_slice(), "\\n");
+    let s = string('\r');
+    assert_eq!(s.as_slice(), "\\r");
+    let s = string('\'');
+    assert_eq!(s.as_slice(), "\\'");
+    let s = string('"');
+    assert_eq!(s.as_slice(), "\\\"");
+    let s = string(' ');
+    assert_eq!(s.as_slice(), " ");
+    let s = string('a');
+    assert_eq!(s.as_slice(), "a");
+    let s = string('~');
+    assert_eq!(s.as_slice(), "~");
+    let s = string('\x00');
+    assert_eq!(s.as_slice(), "\\x00");
+    let s = string('\x1f');
+    assert_eq!(s.as_slice(), "\\x1f");
+    let s = string('\x7f');
+    assert_eq!(s.as_slice(), "\\x7f");
+    let s = string('\xff');
+    assert_eq!(s.as_slice(), "\\xff");
+    let s = string('\u011b');
+    assert_eq!(s.as_slice(), "\\u011b");
+    let s = string('\U0001d4b6');
+    assert_eq!(s.as_slice(), "\\U0001d4b6");
+}
+
+#[test]
+fn test_escape_unicode() {
+    fn string(c: char) -> String {
+        let mut result = String::new();
+        escape_unicode(c, |c| { result.push_char(c); });
+        return result;
+    }
+    let s = string('\x00');
+    assert_eq!(s.as_slice(), "\\x00");
+    let s = string('\n');
+    assert_eq!(s.as_slice(), "\\x0a");
+    let s = string(' ');
+    assert_eq!(s.as_slice(), "\\x20");
+    let s = string('a');
+    assert_eq!(s.as_slice(), "\\x61");
+    let s = string('\u011b');
+    assert_eq!(s.as_slice(), "\\u011b");
+    let s = string('\U0001d4b6');
+    assert_eq!(s.as_slice(), "\\U0001d4b6");
+}
+
+#[test]
+fn test_to_str() {
+    let s = 't'.to_str();
+    assert_eq!(s.as_slice(), "t");
+}
+
+#[test]
+fn test_encode_utf8() {
+    fn check(input: char, expect: &[u8]) {
+        let mut buf = [0u8, ..4];
+        let n = input.encode_utf8(buf /* as mut slice! */);
+        assert_eq!(buf.slice_to(n), expect);
+    }
+
+    check('x', [0x78]);
+    check('\u00e9', [0xc3, 0xa9]);
+    check('\ua66e', [0xea, 0x99, 0xae]);
+    check('\U0001f4a9', [0xf0, 0x9f, 0x92, 0xa9]);
+}
+
+#[test]
+fn test_encode_utf16() {
+    fn check(input: char, expect: &[u16]) {
+        let mut buf = [0u16, ..2];
+        let n = input.encode_utf16(buf /* as mut slice! */);
+        assert_eq!(buf.slice_to(n), expect);
+    }
+
+    check('x', [0x0078]);
+    check('\u00e9', [0x00e9]);
+    check('\ua66e', [0xa66e]);
+    check('\U0001f4a9', [0xd83d, 0xdca9]);
+}
diff --git a/src/libcoretest/clone.rs b/src/libcoretest/clone.rs
new file mode 100644 (file)
index 0000000..67c30d9
--- /dev/null
@@ -0,0 +1,39 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[test]
+fn test_borrowed_clone() {
+    let x = 5i;
+    let y: &int = &x;
+    let z: &int = (&y).clone();
+    assert_eq!(*z, 5);
+}
+
+#[test]
+fn test_clone_from() {
+    let a = box 5i;
+    let mut b = box 10i;
+    b.clone_from(&a);
+    assert_eq!(*b, 5);
+}
+
+#[test]
+fn test_extern_fn_clone() {
+    trait Empty {}
+    impl Empty for int {}
+
+    fn test_fn_a() -> f64 { 1.0 }
+    fn test_fn_b<T: Empty>(x: T) -> T { x }
+    fn test_fn_c(_: int, _: f64, _: int, _: int, _: int) {}
+
+    let _ = test_fn_a.clone();
+    let _ = test_fn_b::<int>.clone();
+    let _ = test_fn_c.clone();
+}
diff --git a/src/libcoretest/cmp.rs b/src/libcoretest/cmp.rs
new file mode 100644 (file)
index 0000000..88e944b
--- /dev/null
@@ -0,0 +1,69 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use core::cmp::lexical_ordering;
+
+#[test]
+fn test_int_totalord() {
+    assert_eq!(5i.cmp(&10), Less);
+    assert_eq!(10i.cmp(&5), Greater);
+    assert_eq!(5i.cmp(&5), Equal);
+    assert_eq!((-5i).cmp(&12), Less);
+    assert_eq!(12i.cmp(&-5), Greater);
+}
+
+#[test]
+fn test_mut_int_totalord() {
+    assert_eq!((&mut 5i).cmp(&&mut 10), Less);
+    assert_eq!((&mut 10i).cmp(&&mut 5), Greater);
+    assert_eq!((&mut 5i).cmp(&&mut 5), Equal);
+    assert_eq!((&mut -5i).cmp(&&mut 12), Less);
+    assert_eq!((&mut 12i).cmp(&&mut -5), Greater);
+}
+
+#[test]
+fn test_ordering_order() {
+    assert!(Less < Equal);
+    assert_eq!(Greater.cmp(&Less), Greater);
+}
+
+#[test]
+fn test_lexical_ordering() {
+    fn t(o1: Ordering, o2: Ordering, e: Ordering) {
+        assert_eq!(lexical_ordering(o1, o2), e);
+    }
+
+    let xs = [Less, Equal, Greater];
+    for &o in xs.iter() {
+        t(Less, o, Less);
+        t(Equal, o, o);
+        t(Greater, o, Greater);
+     }
+}
+
+#[test]
+fn test_user_defined_eq() {
+    // Our type.
+    struct SketchyNum {
+        num : int
+    }
+
+    // Our implementation of `PartialEq` to support `==` and `!=`.
+    impl PartialEq for SketchyNum {
+        // Our custom eq allows numbers which are near each other to be equal! :D
+        fn eq(&self, other: &SketchyNum) -> bool {
+            (self.num - other.num).abs() < 5
+        }
+    }
+
+    // Now these binary operators will work when applied!
+    assert!(SketchyNum {num: 37} == SketchyNum {num: 34});
+    assert!(SketchyNum {num: 25} != SketchyNum {num: 57});
+}
diff --git a/src/libcoretest/finally.rs b/src/libcoretest/finally.rs
new file mode 100644 (file)
index 0000000..5da0040
--- /dev/null
@@ -0,0 +1,59 @@
+// 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 core::finally::{try_finally, Finally};
+use std::task::failing;
+
+#[test]
+fn test_success() {
+    let mut i = 0i;
+    try_finally(
+        &mut i, (),
+        |i, ()| {
+            *i = 10;
+        },
+        |i| {
+            assert!(!failing());
+            assert_eq!(*i, 10);
+            *i = 20;
+        });
+    assert_eq!(i, 20);
+}
+
+#[test]
+#[should_fail]
+fn test_fail() {
+    let mut i = 0i;
+    try_finally(
+        &mut i, (),
+        |i, ()| {
+            *i = 10;
+            fail!();
+        },
+        |i| {
+            assert!(failing());
+            assert_eq!(*i, 10);
+        })
+}
+
+#[test]
+fn test_retval() {
+    let mut closure: || -> int = || 10;
+    let i = closure.finally(|| { });
+    assert_eq!(i, 10);
+}
+
+#[test]
+fn test_compact() {
+    fn do_some_fallible_work() {}
+    fn but_always_run_this_function() { }
+    let mut f = do_some_fallible_work;
+    f.finally(but_always_run_this_function);
+}
diff --git a/src/libcoretest/fmt/mod.rs b/src/libcoretest/fmt/mod.rs
new file mode 100644 (file)
index 0000000..9fc09b3
--- /dev/null
@@ -0,0 +1,11 @@
+// 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.
+
+mod num;
diff --git a/src/libcoretest/fmt/num.rs b/src/libcoretest/fmt/num.rs
new file mode 100644 (file)
index 0000000..baef7e3
--- /dev/null
@@ -0,0 +1,234 @@
+// 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.
+#![allow(unsigned_negate)]
+
+use core::fmt::radix;
+
+#[test]
+fn test_format_int() {
+    // Formatting integers should select the right implementation based off
+    // the type of the argument. Also, hex/octal/binary should be defined
+    // for integers, but they shouldn't emit the negative sign.
+    assert!(format!("{}", 1i).as_slice() == "1");
+    assert!(format!("{}", 1i8).as_slice() == "1");
+    assert!(format!("{}", 1i16).as_slice() == "1");
+    assert!(format!("{}", 1i32).as_slice() == "1");
+    assert!(format!("{}", 1i64).as_slice() == "1");
+    assert!(format!("{:d}", -1i).as_slice() == "-1");
+    assert!(format!("{:d}", -1i8).as_slice() == "-1");
+    assert!(format!("{:d}", -1i16).as_slice() == "-1");
+    assert!(format!("{:d}", -1i32).as_slice() == "-1");
+    assert!(format!("{:d}", -1i64).as_slice() == "-1");
+    assert!(format!("{:t}", 1i).as_slice() == "1");
+    assert!(format!("{:t}", 1i8).as_slice() == "1");
+    assert!(format!("{:t}", 1i16).as_slice() == "1");
+    assert!(format!("{:t}", 1i32).as_slice() == "1");
+    assert!(format!("{:t}", 1i64).as_slice() == "1");
+    assert!(format!("{:x}", 1i).as_slice() == "1");
+    assert!(format!("{:x}", 1i8).as_slice() == "1");
+    assert!(format!("{:x}", 1i16).as_slice() == "1");
+    assert!(format!("{:x}", 1i32).as_slice() == "1");
+    assert!(format!("{:x}", 1i64).as_slice() == "1");
+    assert!(format!("{:X}", 1i).as_slice() == "1");
+    assert!(format!("{:X}", 1i8).as_slice() == "1");
+    assert!(format!("{:X}", 1i16).as_slice() == "1");
+    assert!(format!("{:X}", 1i32).as_slice() == "1");
+    assert!(format!("{:X}", 1i64).as_slice() == "1");
+    assert!(format!("{:o}", 1i).as_slice() == "1");
+    assert!(format!("{:o}", 1i8).as_slice() == "1");
+    assert!(format!("{:o}", 1i16).as_slice() == "1");
+    assert!(format!("{:o}", 1i32).as_slice() == "1");
+    assert!(format!("{:o}", 1i64).as_slice() == "1");
+
+    assert!(format!("{}", 1u).as_slice() == "1");
+    assert!(format!("{}", 1u8).as_slice() == "1");
+    assert!(format!("{}", 1u16).as_slice() == "1");
+    assert!(format!("{}", 1u32).as_slice() == "1");
+    assert!(format!("{}", 1u64).as_slice() == "1");
+    assert!(format!("{:u}", 1u).as_slice() == "1");
+    assert!(format!("{:u}", 1u8).as_slice() == "1");
+    assert!(format!("{:u}", 1u16).as_slice() == "1");
+    assert!(format!("{:u}", 1u32).as_slice() == "1");
+    assert!(format!("{:u}", 1u64).as_slice() == "1");
+    assert!(format!("{:t}", 1u).as_slice() == "1");
+    assert!(format!("{:t}", 1u8).as_slice() == "1");
+    assert!(format!("{:t}", 1u16).as_slice() == "1");
+    assert!(format!("{:t}", 1u32).as_slice() == "1");
+    assert!(format!("{:t}", 1u64).as_slice() == "1");
+    assert!(format!("{:x}", 1u).as_slice() == "1");
+    assert!(format!("{:x}", 1u8).as_slice() == "1");
+    assert!(format!("{:x}", 1u16).as_slice() == "1");
+    assert!(format!("{:x}", 1u32).as_slice() == "1");
+    assert!(format!("{:x}", 1u64).as_slice() == "1");
+    assert!(format!("{:X}", 1u).as_slice() == "1");
+    assert!(format!("{:X}", 1u8).as_slice() == "1");
+    assert!(format!("{:X}", 1u16).as_slice() == "1");
+    assert!(format!("{:X}", 1u32).as_slice() == "1");
+    assert!(format!("{:X}", 1u64).as_slice() == "1");
+    assert!(format!("{:o}", 1u).as_slice() == "1");
+    assert!(format!("{:o}", 1u8).as_slice() == "1");
+    assert!(format!("{:o}", 1u16).as_slice() == "1");
+    assert!(format!("{:o}", 1u32).as_slice() == "1");
+    assert!(format!("{:o}", 1u64).as_slice() == "1");
+
+    // Test a larger number
+    assert!(format!("{:t}", 55i).as_slice() == "110111");
+    assert!(format!("{:o}", 55i).as_slice() == "67");
+    assert!(format!("{:d}", 55i).as_slice() == "55");
+    assert!(format!("{:x}", 55i).as_slice() == "37");
+    assert!(format!("{:X}", 55i).as_slice() == "37");
+}
+
+#[test]
+fn test_format_int_zero() {
+    assert!(format!("{}", 0i).as_slice() == "0");
+    assert!(format!("{:d}", 0i).as_slice() == "0");
+    assert!(format!("{:t}", 0i).as_slice() == "0");
+    assert!(format!("{:o}", 0i).as_slice() == "0");
+    assert!(format!("{:x}", 0i).as_slice() == "0");
+    assert!(format!("{:X}", 0i).as_slice() == "0");
+
+    assert!(format!("{}", 0u).as_slice() == "0");
+    assert!(format!("{:u}", 0u).as_slice() == "0");
+    assert!(format!("{:t}", 0u).as_slice() == "0");
+    assert!(format!("{:o}", 0u).as_slice() == "0");
+    assert!(format!("{:x}", 0u).as_slice() == "0");
+    assert!(format!("{:X}", 0u).as_slice() == "0");
+}
+
+#[test]
+fn test_format_int_flags() {
+    assert!(format!("{:3d}", 1i).as_slice() == "  1");
+    assert!(format!("{:>3d}", 1i).as_slice() == "  1");
+    assert!(format!("{:>+3d}", 1i).as_slice() == " +1");
+    assert!(format!("{:<3d}", 1i).as_slice() == "1  ");
+    assert!(format!("{:#d}", 1i).as_slice() == "1");
+    assert!(format!("{:#x}", 10i).as_slice() == "0xa");
+    assert!(format!("{:#X}", 10i).as_slice() == "0xA");
+    assert!(format!("{:#5x}", 10i).as_slice() == "  0xa");
+    assert!(format!("{:#o}", 10i).as_slice() == "0o12");
+    assert!(format!("{:08x}", 10i).as_slice() == "0000000a");
+    assert!(format!("{:8x}", 10i).as_slice() == "       a");
+    assert!(format!("{:<8x}", 10i).as_slice() == "a       ");
+    assert!(format!("{:>8x}", 10i).as_slice() == "       a");
+    assert!(format!("{:#08x}", 10i).as_slice() == "0x00000a");
+    assert!(format!("{:08d}", -10i).as_slice() == "-0000010");
+    assert!(format!("{:x}", -1u8).as_slice() == "ff");
+    assert!(format!("{:X}", -1u8).as_slice() == "FF");
+    assert!(format!("{:t}", -1u8).as_slice() == "11111111");
+    assert!(format!("{:o}", -1u8).as_slice() == "377");
+    assert!(format!("{:#x}", -1u8).as_slice() == "0xff");
+    assert!(format!("{:#X}", -1u8).as_slice() == "0xFF");
+    assert!(format!("{:#t}", -1u8).as_slice() == "0b11111111");
+    assert!(format!("{:#o}", -1u8).as_slice() == "0o377");
+}
+
+#[test]
+fn test_format_int_sign_padding() {
+    assert!(format!("{:+5d}", 1i).as_slice() == "   +1");
+    assert!(format!("{:+5d}", -1i).as_slice() == "   -1");
+    assert!(format!("{:05d}", 1i).as_slice() == "00001");
+    assert!(format!("{:05d}", -1i).as_slice() == "-0001");
+    assert!(format!("{:+05d}", 1i).as_slice() == "+0001");
+    assert!(format!("{:+05d}", -1i).as_slice() == "-0001");
+}
+
+#[test]
+fn test_format_int_twos_complement() {
+    use core::{i8, i16, i32, i64};
+    assert!(format!("{}", i8::MIN).as_slice() == "-128");
+    assert!(format!("{}", i16::MIN).as_slice() == "-32768");
+    assert!(format!("{}", i32::MIN).as_slice() == "-2147483648");
+    assert!(format!("{}", i64::MIN).as_slice() == "-9223372036854775808");
+}
+
+#[test]
+fn test_format_radix() {
+    assert!(format!("{:04}", radix(3i, 2)).as_slice() == "0011");
+    assert!(format!("{}", radix(55i, 36)).as_slice() == "1j");
+}
+
+#[test]
+#[should_fail]
+fn test_radix_base_too_large() {
+    let _ = radix(55i, 37);
+}
+
+mod uint {
+    use test::Bencher;
+    use core::fmt::radix;
+    use std::rand::{weak_rng, Rng};
+
+    #[bench]
+    fn format_bin(b: &mut Bencher) {
+        let mut rng = weak_rng();
+        b.iter(|| { format!("{:t}", rng.gen::<uint>()); })
+    }
+
+    #[bench]
+    fn format_oct(b: &mut Bencher) {
+        let mut rng = weak_rng();
+        b.iter(|| { format!("{:o}", rng.gen::<uint>()); })
+    }
+
+    #[bench]
+    fn format_dec(b: &mut Bencher) {
+        let mut rng = weak_rng();
+        b.iter(|| { format!("{:u}", rng.gen::<uint>()); })
+    }
+
+    #[bench]
+    fn format_hex(b: &mut Bencher) {
+        let mut rng = weak_rng();
+        b.iter(|| { format!("{:x}", rng.gen::<uint>()); })
+    }
+
+    #[bench]
+    fn format_base_36(b: &mut Bencher) {
+        let mut rng = weak_rng();
+        b.iter(|| { format!("{}", radix(rng.gen::<uint>(), 36)); })
+    }
+}
+
+mod int {
+    use test::Bencher;
+    use core::fmt::radix;
+    use std::rand::{weak_rng, Rng};
+
+    #[bench]
+    fn format_bin(b: &mut Bencher) {
+        let mut rng = weak_rng();
+        b.iter(|| { format!("{:t}", rng.gen::<int>()); })
+    }
+
+    #[bench]
+    fn format_oct(b: &mut Bencher) {
+        let mut rng = weak_rng();
+        b.iter(|| { format!("{:o}", rng.gen::<int>()); })
+    }
+
+    #[bench]
+    fn format_dec(b: &mut Bencher) {
+        let mut rng = weak_rng();
+        b.iter(|| { format!("{:d}", rng.gen::<int>()); })
+    }
+
+    #[bench]
+    fn format_hex(b: &mut Bencher) {
+        let mut rng = weak_rng();
+        b.iter(|| { format!("{:x}", rng.gen::<int>()); })
+    }
+
+    #[bench]
+    fn format_base_36(b: &mut Bencher) {
+        let mut rng = weak_rng();
+        b.iter(|| { format!("{}", radix(rng.gen::<int>(), 36)); })
+    }
+}
diff --git a/src/libcoretest/iter.rs b/src/libcoretest/iter.rs
new file mode 100644 (file)
index 0000000..86b5ffe
--- /dev/null
@@ -0,0 +1,835 @@
+// 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 core::iter::*;
+use core::iter::order::*;
+use core::uint;
+use core::cmp;
+use core::num;
+
+#[test]
+fn test_lt() {
+    let empty: [int, ..0] = [];
+    let xs = [1i,2,3];
+    let ys = [1i,2,0];
+
+    assert!(!lt(xs.iter(), ys.iter()));
+    assert!(!le(xs.iter(), ys.iter()));
+    assert!( gt(xs.iter(), ys.iter()));
+    assert!( ge(xs.iter(), ys.iter()));
+
+    assert!( lt(ys.iter(), xs.iter()));
+    assert!( le(ys.iter(), xs.iter()));
+    assert!(!gt(ys.iter(), xs.iter()));
+    assert!(!ge(ys.iter(), xs.iter()));
+
+    assert!( lt(empty.iter(), xs.iter()));
+    assert!( le(empty.iter(), xs.iter()));
+    assert!(!gt(empty.iter(), xs.iter()));
+    assert!(!ge(empty.iter(), xs.iter()));
+
+    // Sequence with NaN
+    let u = [1.0f64, 2.0];
+    let v = [0.0f64/0.0, 3.0];
+
+    assert!(!lt(u.iter(), v.iter()));
+    assert!(!le(u.iter(), v.iter()));
+    assert!(!gt(u.iter(), v.iter()));
+    assert!(!ge(u.iter(), v.iter()));
+
+    let a = [0.0f64/0.0];
+    let b = [1.0f64];
+    let c = [2.0f64];
+
+    assert!(lt(a.iter(), b.iter()) == (a[0] <  b[0]));
+    assert!(le(a.iter(), b.iter()) == (a[0] <= b[0]));
+    assert!(gt(a.iter(), b.iter()) == (a[0] >  b[0]));
+    assert!(ge(a.iter(), b.iter()) == (a[0] >= b[0]));
+
+    assert!(lt(c.iter(), b.iter()) == (c[0] <  b[0]));
+    assert!(le(c.iter(), b.iter()) == (c[0] <= b[0]));
+    assert!(gt(c.iter(), b.iter()) == (c[0] >  b[0]));
+    assert!(ge(c.iter(), b.iter()) == (c[0] >= b[0]));
+}
+
+#[test]
+fn test_multi_iter() {
+    let xs = [1i,2,3,4];
+    let ys = [4i,3,2,1];
+    assert!(eq(xs.iter(), ys.iter().rev()));
+    assert!(lt(xs.iter(), xs.iter().skip(2)));
+}
+
+#[test]
+fn test_counter_from_iter() {
+    let it = count(0i, 5).take(10);
+    let xs: Vec<int> = FromIterator::from_iter(it);
+    assert!(xs == vec![0, 5, 10, 15, 20, 25, 30, 35, 40, 45]);
+}
+
+#[test]
+fn test_iterator_chain() {
+    let xs = [0u, 1, 2, 3, 4, 5];
+    let ys = [30u, 40, 50, 60];
+    let expected = [0, 1, 2, 3, 4, 5, 30, 40, 50, 60];
+    let mut it = xs.iter().chain(ys.iter());
+    let mut i = 0;
+    for &x in it {
+        assert_eq!(x, expected[i]);
+        i += 1;
+    }
+    assert_eq!(i, expected.len());
+
+    let ys = count(30u, 10).take(4);
+    let mut it = xs.iter().map(|&x| x).chain(ys);
+    let mut i = 0;
+    for x in it {
+        assert_eq!(x, expected[i]);
+        i += 1;
+    }
+    assert_eq!(i, expected.len());
+}
+
+#[test]
+fn test_filter_map() {
+    let mut it = count(0u, 1u).take(10)
+        .filter_map(|x| if x % 2 == 0 { Some(x*x) } else { None });
+    assert!(it.collect::<Vec<uint>>() == vec![0*0, 2*2, 4*4, 6*6, 8*8]);
+}
+
+#[test]
+fn test_iterator_enumerate() {
+    let xs = [0u, 1, 2, 3, 4, 5];
+    let mut it = xs.iter().enumerate();
+    for (i, &x) in it {
+        assert_eq!(i, x);
+    }
+}
+
+#[test]
+fn test_iterator_peekable() {
+    let xs = vec![0u, 1, 2, 3, 4, 5];
+    let mut it = xs.iter().map(|&x|x).peekable();
+    assert_eq!(it.peek().unwrap(), &0);
+    assert_eq!(it.next().unwrap(), 0);
+    assert_eq!(it.next().unwrap(), 1);
+    assert_eq!(it.next().unwrap(), 2);
+    assert_eq!(it.peek().unwrap(), &3);
+    assert_eq!(it.peek().unwrap(), &3);
+    assert_eq!(it.next().unwrap(), 3);
+    assert_eq!(it.next().unwrap(), 4);
+    assert_eq!(it.peek().unwrap(), &5);
+    assert_eq!(it.next().unwrap(), 5);
+    assert!(it.peek().is_none());
+    assert!(it.next().is_none());
+}
+
+#[test]
+fn test_iterator_take_while() {
+    let xs = [0u, 1, 2, 3, 5, 13, 15, 16, 17, 19];
+    let ys = [0u, 1, 2, 3, 5, 13];
+    let mut it = xs.iter().take_while(|&x| *x < 15u);
+    let mut i = 0;
+    for &x in it {
+        assert_eq!(x, ys[i]);
+        i += 1;
+    }
+    assert_eq!(i, ys.len());
+}
+
+#[test]
+fn test_iterator_skip_while() {
+    let xs = [0u, 1, 2, 3, 5, 13, 15, 16, 17, 19];
+    let ys = [15, 16, 17, 19];
+    let mut it = xs.iter().skip_while(|&x| *x < 15u);
+    let mut i = 0;
+    for &x in it {
+        assert_eq!(x, ys[i]);
+        i += 1;
+    }
+    assert_eq!(i, ys.len());
+}
+
+#[test]
+fn test_iterator_skip() {
+    let xs = [0u, 1, 2, 3, 5, 13, 15, 16, 17, 19, 20, 30];
+    let ys = [13, 15, 16, 17, 19, 20, 30];
+    let mut it = xs.iter().skip(5);
+    let mut i = 0;
+    for &x in it {
+        assert_eq!(x, ys[i]);
+        i += 1;
+    }
+    assert_eq!(i, ys.len());
+}
+
+#[test]
+fn test_iterator_take() {
+    let xs = [0u, 1, 2, 3, 5, 13, 15, 16, 17, 19];
+    let ys = [0u, 1, 2, 3, 5];
+    let mut it = xs.iter().take(5);
+    let mut i = 0;
+    for &x in it {
+        assert_eq!(x, ys[i]);
+        i += 1;
+    }
+    assert_eq!(i, ys.len());
+}
+
+#[test]
+fn test_iterator_scan() {
+    // test the type inference
+    fn add(old: &mut int, new: &uint) -> Option<f64> {
+        *old += *new as int;
+        Some(*old as f64)
+    }
+    let xs = [0u, 1, 2, 3, 4];
+    let ys = [0f64, 1.0, 3.0, 6.0, 10.0];
+
+    let mut it = xs.iter().scan(0, add);
+    let mut i = 0;
+    for x in it {
+        assert_eq!(x, ys[i]);
+        i += 1;
+    }
+    assert_eq!(i, ys.len());
+}
+
+#[test]
+fn test_iterator_flat_map() {
+    let xs = [0u, 3, 6];
+    let ys = [0u, 1, 2, 3, 4, 5, 6, 7, 8];
+    let mut it = xs.iter().flat_map(|&x| count(x, 1).take(3));
+    let mut i = 0;
+    for x in it {
+        assert_eq!(x, ys[i]);
+        i += 1;
+    }
+    assert_eq!(i, ys.len());
+}
+
+#[test]
+fn test_inspect() {
+    let xs = [1u, 2, 3, 4];
+    let mut n = 0;
+
+    let ys = xs.iter()
+               .map(|&x| x)
+               .inspect(|_| n += 1)
+               .collect::<Vec<uint>>();
+
+    assert_eq!(n, xs.len());
+    assert_eq!(xs.as_slice(), ys.as_slice());
+}
+
+#[test]
+fn test_unfoldr() {
+    fn count(st: &mut uint) -> Option<uint> {
+        if *st < 10 {
+            let ret = Some(*st);
+            *st += 1;
+            ret
+        } else {
+            None
+        }
+    }
+
+    let mut it = Unfold::new(0, count);
+    let mut i = 0;
+    for counted in it {
+        assert_eq!(counted, i);
+        i += 1;
+    }
+    assert_eq!(i, 10);
+}
+
+#[test]
+fn test_cycle() {
+    let cycle_len = 3;
+    let it = count(0u, 1).take(cycle_len).cycle();
+    assert_eq!(it.size_hint(), (uint::MAX, None));
+    for (i, x) in it.take(100).enumerate() {
+        assert_eq!(i % cycle_len, x);
+    }
+
+    let mut it = count(0u, 1).take(0).cycle();
+    assert_eq!(it.size_hint(), (0, Some(0)));
+    assert_eq!(it.next(), None);
+}
+
+#[test]
+fn test_iterator_nth() {
+    let v = &[0i, 1, 2, 3, 4];
+    for i in range(0u, v.len()) {
+        assert_eq!(v.iter().nth(i).unwrap(), &v[i]);
+    }
+}
+
+#[test]
+fn test_iterator_last() {
+    let v = &[0i, 1, 2, 3, 4];
+    assert_eq!(v.iter().last().unwrap(), &4);
+    assert_eq!(v.slice(0, 1).iter().last().unwrap(), &0);
+}
+
+#[test]
+fn test_iterator_len() {
+    let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
+    assert_eq!(v.slice(0, 4).iter().count(), 4);
+    assert_eq!(v.slice(0, 10).iter().count(), 10);
+    assert_eq!(v.slice(0, 0).iter().count(), 0);
+}
+
+#[test]
+fn test_iterator_sum() {
+    let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
+    assert_eq!(v.slice(0, 4).iter().map(|&x| x).sum(), 6);
+    assert_eq!(v.iter().map(|&x| x).sum(), 55);
+    assert_eq!(v.slice(0, 0).iter().map(|&x| x).sum(), 0);
+}
+
+#[test]
+fn test_iterator_product() {
+    let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
+    assert_eq!(v.slice(0, 4).iter().map(|&x| x).product(), 0);
+    assert_eq!(v.slice(1, 5).iter().map(|&x| x).product(), 24);
+    assert_eq!(v.slice(0, 0).iter().map(|&x| x).product(), 1);
+}
+
+#[test]
+fn test_iterator_max() {
+    let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
+    assert_eq!(v.slice(0, 4).iter().map(|&x| x).max(), Some(3));
+    assert_eq!(v.iter().map(|&x| x).max(), Some(10));
+    assert_eq!(v.slice(0, 0).iter().map(|&x| x).max(), None);
+}
+
+#[test]
+fn test_iterator_min() {
+    let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
+    assert_eq!(v.slice(0, 4).iter().map(|&x| x).min(), Some(0));
+    assert_eq!(v.iter().map(|&x| x).min(), Some(0));
+    assert_eq!(v.slice(0, 0).iter().map(|&x| x).min(), None);
+}
+
+#[test]
+fn test_iterator_size_hint() {
+    let c = count(0i, 1);
+    let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+    let v2 = &[10i, 11, 12];
+    let vi = v.iter();
+
+    assert_eq!(c.size_hint(), (uint::MAX, None));
+    assert_eq!(vi.size_hint(), (10, Some(10)));
+
+    assert_eq!(c.take(5).size_hint(), (5, Some(5)));
+    assert_eq!(c.skip(5).size_hint().val1(), None);
+    assert_eq!(c.take_while(|_| false).size_hint(), (0, None));
+    assert_eq!(c.skip_while(|_| false).size_hint(), (0, None));
+    assert_eq!(c.enumerate().size_hint(), (uint::MAX, None));
+    assert_eq!(c.chain(vi.map(|&i| i)).size_hint(), (uint::MAX, None));
+    assert_eq!(c.zip(vi).size_hint(), (10, Some(10)));
+    assert_eq!(c.scan(0i, |_,_| Some(0i)).size_hint(), (0, None));
+    assert_eq!(c.filter(|_| false).size_hint(), (0, None));
+    assert_eq!(c.map(|_| 0i).size_hint(), (uint::MAX, None));
+    assert_eq!(c.filter_map(|_| Some(0i)).size_hint(), (0, None));
+
+    assert_eq!(vi.take(5).size_hint(), (5, Some(5)));
+    assert_eq!(vi.take(12).size_hint(), (10, Some(10)));
+    assert_eq!(vi.skip(3).size_hint(), (7, Some(7)));
+    assert_eq!(vi.skip(12).size_hint(), (0, Some(0)));
+    assert_eq!(vi.take_while(|_| false).size_hint(), (0, Some(10)));
+    assert_eq!(vi.skip_while(|_| false).size_hint(), (0, Some(10)));
+    assert_eq!(vi.enumerate().size_hint(), (10, Some(10)));
+    assert_eq!(vi.chain(v2.iter()).size_hint(), (13, Some(13)));
+    assert_eq!(vi.zip(v2.iter()).size_hint(), (3, Some(3)));
+    assert_eq!(vi.scan(0i, |_,_| Some(0i)).size_hint(), (0, Some(10)));
+    assert_eq!(vi.filter(|_| false).size_hint(), (0, Some(10)));
+    assert_eq!(vi.map(|i| i+1).size_hint(), (10, Some(10)));
+    assert_eq!(vi.filter_map(|_| Some(0i)).size_hint(), (0, Some(10)));
+}
+
+#[test]
+fn test_collect() {
+    let a = vec![1i, 2, 3, 4, 5];
+    let b: Vec<int> = a.iter().map(|&x| x).collect();
+    assert!(a == b);
+}
+
+#[test]
+fn test_all() {
+    let v: Box<&[int]> = box &[1i, 2, 3, 4, 5];
+    assert!(v.iter().all(|&x| x < 10));
+    assert!(!v.iter().all(|&x| x % 2 == 0));
+    assert!(!v.iter().all(|&x| x > 100));
+    assert!(v.slice(0, 0).iter().all(|_| fail!()));
+}
+
+#[test]
+fn test_any() {
+    let v: Box<&[int]> = box &[1i, 2, 3, 4, 5];
+    assert!(v.iter().any(|&x| x < 10));
+    assert!(v.iter().any(|&x| x % 2 == 0));
+    assert!(!v.iter().any(|&x| x > 100));
+    assert!(!v.slice(0, 0).iter().any(|_| fail!()));
+}
+
+#[test]
+fn test_find() {
+    let v: &[int] = &[1i, 3, 9, 27, 103, 14, 11];
+    assert_eq!(*v.iter().find(|x| *x & 1 == 0).unwrap(), 14);
+    assert_eq!(*v.iter().find(|x| *x % 3 == 0).unwrap(), 3);
+    assert!(v.iter().find(|x| *x % 12 == 0).is_none());
+}
+
+#[test]
+fn test_position() {
+    let v = &[1i, 3, 9, 27, 103, 14, 11];
+    assert_eq!(v.iter().position(|x| *x & 1 == 0).unwrap(), 5);
+    assert_eq!(v.iter().position(|x| *x % 3 == 0).unwrap(), 1);
+    assert!(v.iter().position(|x| *x % 12 == 0).is_none());
+}
+
+#[test]
+fn test_count() {
+    let xs = &[1i, 2, 2, 1, 5, 9, 0, 2];
+    assert_eq!(xs.iter().filter(|x| **x == 2).count(), 3);
+    assert_eq!(xs.iter().filter(|x| **x == 5).count(), 1);
+    assert_eq!(xs.iter().filter(|x| **x == 95).count(), 0);
+}
+
+#[test]
+fn test_max_by() {
+    let xs: &[int] = &[-3i, 0, 1, 5, -10];
+    assert_eq!(*xs.iter().max_by(|x| x.abs()).unwrap(), -10);
+}
+
+#[test]
+fn test_min_by() {
+    let xs: &[int] = &[-3i, 0, 1, 5, -10];
+    assert_eq!(*xs.iter().min_by(|x| x.abs()).unwrap(), 0);
+}
+
+#[test]
+fn test_by_ref() {
+    let mut xs = range(0i, 10);
+    // sum the first five values
+    let partial_sum = xs.by_ref().take(5).fold(0, |a, b| a + b);
+    assert_eq!(partial_sum, 10);
+    assert_eq!(xs.next(), Some(5));
+}
+
+#[test]
+fn test_rev() {
+    let xs = [2i, 4, 6, 8, 10, 12, 14, 16];
+    let mut it = xs.iter();
+    it.next();
+    it.next();
+    assert!(it.rev().map(|&x| x).collect::<Vec<int>>() ==
+            vec![16, 14, 12, 10, 8, 6]);
+}
+
+#[test]
+fn test_double_ended_map() {
+    let xs = [1i, 2, 3, 4, 5, 6];
+    let mut it = xs.iter().map(|&x| x * -1);
+    assert_eq!(it.next(), Some(-1));
+    assert_eq!(it.next(), Some(-2));
+    assert_eq!(it.next_back(), Some(-6));
+    assert_eq!(it.next_back(), Some(-5));
+    assert_eq!(it.next(), Some(-3));
+    assert_eq!(it.next_back(), Some(-4));
+    assert_eq!(it.next(), None);
+}
+
+#[test]
+fn test_double_ended_enumerate() {
+    let xs = [1i, 2, 3, 4, 5, 6];
+    let mut it = xs.iter().map(|&x| x).enumerate();
+    assert_eq!(it.next(), Some((0, 1)));
+    assert_eq!(it.next(), Some((1, 2)));
+    assert_eq!(it.next_back(), Some((5, 6)));
+    assert_eq!(it.next_back(), Some((4, 5)));
+    assert_eq!(it.next_back(), Some((3, 4)));
+    assert_eq!(it.next_back(), Some((2, 3)));
+    assert_eq!(it.next(), None);
+}
+
+#[test]
+fn test_double_ended_zip() {
+    let xs = [1i, 2, 3, 4, 5, 6];
+    let ys = [1i, 2, 3, 7];
+    let a = xs.iter().map(|&x| x);
+    let b = ys.iter().map(|&x| x);
+    let mut it = a.zip(b);
+    assert_eq!(it.next(), Some((1, 1)));
+    assert_eq!(it.next(), Some((2, 2)));
+    assert_eq!(it.next_back(), Some((4, 7)));
+    assert_eq!(it.next_back(), Some((3, 3)));
+    assert_eq!(it.next(), None);
+}
+
+#[test]
+fn test_double_ended_filter() {
+    let xs = [1i, 2, 3, 4, 5, 6];
+    let mut it = xs.iter().filter(|&x| *x & 1 == 0);
+    assert_eq!(it.next_back().unwrap(), &6);
+    assert_eq!(it.next_back().unwrap(), &4);
+    assert_eq!(it.next().unwrap(), &2);
+    assert_eq!(it.next_back(), None);
+}
+
+#[test]
+fn test_double_ended_filter_map() {
+    let xs = [1i, 2, 3, 4, 5, 6];
+    let mut it = xs.iter().filter_map(|&x| if x & 1 == 0 { Some(x * 2) } else { None });
+    assert_eq!(it.next_back().unwrap(), 12);
+    assert_eq!(it.next_back().unwrap(), 8);
+    assert_eq!(it.next().unwrap(), 4);
+    assert_eq!(it.next_back(), None);
+}
+
+#[test]
+fn test_double_ended_chain() {
+    let xs = [1i, 2, 3, 4, 5];
+    let ys = [7i, 9, 11];
+    let mut it = xs.iter().chain(ys.iter()).rev();
+    assert_eq!(it.next().unwrap(), &11)
+    assert_eq!(it.next().unwrap(), &9)
+    assert_eq!(it.next_back().unwrap(), &1)
+    assert_eq!(it.next_back().unwrap(), &2)
+    assert_eq!(it.next_back().unwrap(), &3)
+    assert_eq!(it.next_back().unwrap(), &4)
+    assert_eq!(it.next_back().unwrap(), &5)
+    assert_eq!(it.next_back().unwrap(), &7)
+    assert_eq!(it.next_back(), None)
+}
+
+#[test]
+fn test_rposition() {
+    fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' }
+    fn g(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'd' }
+    let v = [(0i, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
+
+    assert_eq!(v.iter().rposition(f), Some(3u));
+    assert!(v.iter().rposition(g).is_none());
+}
+
+#[test]
+#[should_fail]
+fn test_rposition_fail() {
+    use std::gc::GC;
+    let v = [(box 0i, box(GC) 0i), (box 0i, box(GC) 0i),
+             (box 0i, box(GC) 0i), (box 0i, box(GC) 0i)];
+    let mut i = 0i;
+    v.iter().rposition(|_elt| {
+        if i == 2 {
+            fail!()
+        }
+        i += 1;
+        false
+    });
+}
+
+
+#[cfg(test)]
+fn check_randacc_iter<A: PartialEq, T: Clone + RandomAccessIterator<A>>(a: T, len: uint)
+{
+    let mut b = a.clone();
+    assert_eq!(len, b.indexable());
+    let mut n = 0u;
+    for (i, elt) in a.enumerate() {
+        assert!(Some(elt) == b.idx(i));
+        n += 1;
+    }
+    assert_eq!(n, len);
+    assert!(None == b.idx(n));
+    // call recursively to check after picking off an element
+    if len > 0 {
+        b.next();
+        check_randacc_iter(b, len-1);
+    }
+}
+
+
+#[test]
+fn test_double_ended_flat_map() {
+    let u = [0u,1];
+    let v = [5u,6,7,8];
+    let mut it = u.iter().flat_map(|x| v.slice(*x, v.len()).iter());
+    assert_eq!(it.next_back().unwrap(), &8);
+    assert_eq!(it.next().unwrap(),      &5);
+    assert_eq!(it.next_back().unwrap(), &7);
+    assert_eq!(it.next_back().unwrap(), &6);
+    assert_eq!(it.next_back().unwrap(), &8);
+    assert_eq!(it.next().unwrap(),      &6);
+    assert_eq!(it.next_back().unwrap(), &7);
+    assert_eq!(it.next_back(), None);
+    assert_eq!(it.next(),      None);
+    assert_eq!(it.next_back(), None);
+}
+
+#[test]
+fn test_random_access_chain() {
+    let xs = [1i, 2, 3, 4, 5];
+    let ys = [7i, 9, 11];
+    let mut it = xs.iter().chain(ys.iter());
+    assert_eq!(it.idx(0).unwrap(), &1);
+    assert_eq!(it.idx(5).unwrap(), &7);
+    assert_eq!(it.idx(7).unwrap(), &11);
+    assert!(it.idx(8).is_none());
+
+    it.next();
+    it.next();
+    it.next_back();
+
+    assert_eq!(it.idx(0).unwrap(), &3);
+    assert_eq!(it.idx(4).unwrap(), &9);
+    assert!(it.idx(6).is_none());
+
+    check_randacc_iter(it, xs.len() + ys.len() - 3);
+}
+
+#[test]
+fn test_random_access_enumerate() {
+    let xs = [1i, 2, 3, 4, 5];
+    check_randacc_iter(xs.iter().enumerate(), xs.len());
+}
+
+#[test]
+fn test_random_access_rev() {
+    let xs = [1i, 2, 3, 4, 5];
+    check_randacc_iter(xs.iter().rev(), xs.len());
+    let mut it = xs.iter().rev();
+    it.next();
+    it.next_back();
+    it.next();
+    check_randacc_iter(it, xs.len() - 3);
+}
+
+#[test]
+fn test_random_access_zip() {
+    let xs = [1i, 2, 3, 4, 5];
+    let ys = [7i, 9, 11];
+    check_randacc_iter(xs.iter().zip(ys.iter()), cmp::min(xs.len(), ys.len()));
+}
+
+#[test]
+fn test_random_access_take() {
+    let xs = [1i, 2, 3, 4, 5];
+    let empty: &[int] = [];
+    check_randacc_iter(xs.iter().take(3), 3);
+    check_randacc_iter(xs.iter().take(20), xs.len());
+    check_randacc_iter(xs.iter().take(0), 0);
+    check_randacc_iter(empty.iter().take(2), 0);
+}
+
+#[test]
+fn test_random_access_skip() {
+    let xs = [1i, 2, 3, 4, 5];
+    let empty: &[int] = [];
+    check_randacc_iter(xs.iter().skip(2), xs.len() - 2);
+    check_randacc_iter(empty.iter().skip(2), 0);
+}
+
+#[test]
+fn test_random_access_inspect() {
+    let xs = [1i, 2, 3, 4, 5];
+
+    // test .map and .inspect that don't implement Clone
+    let mut it = xs.iter().inspect(|_| {});
+    assert_eq!(xs.len(), it.indexable());
+    for (i, elt) in xs.iter().enumerate() {
+        assert_eq!(Some(elt), it.idx(i));
+    }
+
+}
+
+#[test]
+fn test_random_access_map() {
+    let xs = [1i, 2, 3, 4, 5];
+
+    let mut it = xs.iter().map(|x| *x);
+    assert_eq!(xs.len(), it.indexable());
+    for (i, elt) in xs.iter().enumerate() {
+        assert_eq!(Some(*elt), it.idx(i));
+    }
+}
+
+#[test]
+fn test_random_access_cycle() {
+    let xs = [1i, 2, 3, 4, 5];
+    let empty: &[int] = [];
+    check_randacc_iter(xs.iter().cycle().take(27), 27);
+    check_randacc_iter(empty.iter().cycle(), 0);
+}
+
+#[test]
+fn test_double_ended_range() {
+    assert!(range(11i, 14).rev().collect::<Vec<int>>() == vec![13i, 12, 11]);
+    for _ in range(10i, 0).rev() {
+        fail!("unreachable");
+    }
+
+    assert!(range(11u, 14).rev().collect::<Vec<uint>>() == vec![13u, 12, 11]);
+    for _ in range(10u, 0).rev() {
+        fail!("unreachable");
+    }
+}
+
+#[test]
+fn test_range() {
+    /// A mock type to check Range when ToPrimitive returns None
+    struct Foo;
+
+    impl ToPrimitive for Foo {
+        fn to_i64(&self) -> Option<i64> { None }
+        fn to_u64(&self) -> Option<u64> { None }
+    }
+
+    impl Add<Foo, Foo> for Foo {
+        fn add(&self, _: &Foo) -> Foo {
+            Foo
+        }
+    }
+
+    impl PartialEq for Foo {
+        fn eq(&self, _: &Foo) -> bool {
+            true
+        }
+    }
+
+    impl PartialOrd for Foo {
+        fn partial_cmp(&self, _: &Foo) -> Option<Ordering> {
+            None
+        }
+    }
+
+    impl Clone for Foo {
+        fn clone(&self) -> Foo {
+            Foo
+        }
+    }
+
+    impl Mul<Foo, Foo> for Foo {
+        fn mul(&self, _: &Foo) -> Foo {
+            Foo
+        }
+    }
+
+    impl num::One for Foo {
+        fn one() -> Foo {
+            Foo
+        }
+    }
+
+    assert!(range(0i, 5).collect::<Vec<int>>() == vec![0i, 1, 2, 3, 4]);
+    assert!(range(-10i, -1).collect::<Vec<int>>() ==
+               vec![-10, -9, -8, -7, -6, -5, -4, -3, -2]);
+    assert!(range(0i, 5).rev().collect::<Vec<int>>() == vec![4, 3, 2, 1, 0]);
+    assert_eq!(range(200i, -5).count(), 0);
+    assert_eq!(range(200i, -5).rev().count(), 0);
+    assert_eq!(range(200i, 200).count(), 0);
+    assert_eq!(range(200i, 200).rev().count(), 0);
+
+    assert_eq!(range(0i, 100).size_hint(), (100, Some(100)));
+    // this test is only meaningful when sizeof uint < sizeof u64
+    assert_eq!(range(uint::MAX - 1, uint::MAX).size_hint(), (1, Some(1)));
+    assert_eq!(range(-10i, -1).size_hint(), (9, Some(9)));
+    assert_eq!(range(Foo, Foo).size_hint(), (0, None));
+}
+
+#[test]
+fn test_range_inclusive() {
+    assert!(range_inclusive(0i, 5).collect::<Vec<int>>() ==
+            vec![0i, 1, 2, 3, 4, 5]);
+    assert!(range_inclusive(0i, 5).rev().collect::<Vec<int>>() ==
+            vec![5i, 4, 3, 2, 1, 0]);
+    assert_eq!(range_inclusive(200i, -5).count(), 0);
+    assert_eq!(range_inclusive(200i, -5).rev().count(), 0);
+    assert!(range_inclusive(200i, 200).collect::<Vec<int>>() == vec![200]);
+    assert!(range_inclusive(200i, 200).rev().collect::<Vec<int>>() == vec![200]);
+}
+
+#[test]
+fn test_range_step() {
+    assert!(range_step(0i, 20, 5).collect::<Vec<int>>() ==
+            vec![0, 5, 10, 15]);
+    assert!(range_step(20i, 0, -5).collect::<Vec<int>>() ==
+            vec![20, 15, 10, 5]);
+    assert!(range_step(20i, 0, -6).collect::<Vec<int>>() ==
+            vec![20, 14, 8, 2]);
+    assert!(range_step(200u8, 255, 50).collect::<Vec<u8>>() ==
+            vec![200u8, 250]);
+    assert!(range_step(200i, -5, 1).collect::<Vec<int>>() == vec![]);
+    assert!(range_step(200i, 200, 1).collect::<Vec<int>>() == vec![]);
+}
+
+#[test]
+fn test_range_step_inclusive() {
+    assert!(range_step_inclusive(0i, 20, 5).collect::<Vec<int>>() ==
+            vec![0, 5, 10, 15, 20]);
+    assert!(range_step_inclusive(20i, 0, -5).collect::<Vec<int>>() ==
+            vec![20, 15, 10, 5, 0]);
+    assert!(range_step_inclusive(20i, 0, -6).collect::<Vec<int>>() ==
+            vec![20, 14, 8, 2]);
+    assert!(range_step_inclusive(200u8, 255, 50).collect::<Vec<u8>>() ==
+            vec![200u8, 250]);
+    assert!(range_step_inclusive(200i, -5, 1).collect::<Vec<int>>() ==
+            vec![]);
+    assert!(range_step_inclusive(200i, 200, 1).collect::<Vec<int>>() ==
+            vec![200]);
+}
+
+#[test]
+fn test_reverse() {
+    let mut ys = [1i, 2, 3, 4, 5];
+    ys.mut_iter().reverse_();
+    assert!(ys == [5, 4, 3, 2, 1]);
+}
+
+#[test]
+fn test_peekable_is_empty() {
+    let a = [1i];
+    let mut it = a.iter().peekable();
+    assert!( !it.is_empty() );
+    it.next();
+    assert!( it.is_empty() );
+}
+
+#[test]
+fn test_min_max() {
+    let v: [int, ..0] = [];
+    assert_eq!(v.iter().min_max(), NoElements);
+
+    let v = [1i];
+    assert!(v.iter().min_max() == OneElement(&1));
+
+    let v = [1i, 2, 3, 4, 5];
+    assert!(v.iter().min_max() == MinMax(&1, &5));
+
+    let v = [1i, 2, 3, 4, 5, 6];
+    assert!(v.iter().min_max() == MinMax(&1, &6));
+
+    let v = [1i, 1, 1, 1];
+    assert!(v.iter().min_max() == MinMax(&1, &1));
+}
+
+#[test]
+fn test_min_max_result() {
+    let r: MinMaxResult<int> = NoElements;
+    assert_eq!(r.into_option(), None)
+
+    let r = OneElement(1i);
+    assert_eq!(r.into_option(), Some((1,1)));
+
+    let r = MinMax(1i,2);
+    assert_eq!(r.into_option(), Some((1,2)));
+}
diff --git a/src/libcoretest/lib.rs b/src/libcoretest/lib.rs
new file mode 100644 (file)
index 0000000..3a3cac5
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+#![feature(globs, unsafe_destructor, macro_rules)]
+
+extern crate core;
+extern crate test;
+extern crate libc;
+
+mod any;
+mod atomics;
+mod cell;
+mod char;
+mod cmp;
+mod finally;
+mod fmt;
+mod iter;
+mod mem;
+mod num;
+mod ops;
+mod option;
+mod ptr;
+mod raw;
+mod result;
+mod tuple;
diff --git a/src/libcoretest/mem.rs b/src/libcoretest/mem.rs
new file mode 100644 (file)
index 0000000..fde6401
--- /dev/null
@@ -0,0 +1,173 @@
+// 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 core::mem::*;
+use test::Bencher;
+
+#[test]
+fn size_of_basic() {
+    assert_eq!(size_of::<u8>(), 1u);
+    assert_eq!(size_of::<u16>(), 2u);
+    assert_eq!(size_of::<u32>(), 4u);
+    assert_eq!(size_of::<u64>(), 8u);
+}
+
+#[test]
+#[cfg(target_arch = "x86")]
+#[cfg(target_arch = "arm")]
+#[cfg(target_arch = "mips")]
+#[cfg(target_arch = "mipsel")]
+fn size_of_32() {
+    assert_eq!(size_of::<uint>(), 4u);
+    assert_eq!(size_of::<*const uint>(), 4u);
+}
+
+#[test]
+#[cfg(target_arch = "x86_64")]
+fn size_of_64() {
+    assert_eq!(size_of::<uint>(), 8u);
+    assert_eq!(size_of::<*const uint>(), 8u);
+}
+
+#[test]
+fn size_of_val_basic() {
+    assert_eq!(size_of_val(&1u8), 1);
+    assert_eq!(size_of_val(&1u16), 2);
+    assert_eq!(size_of_val(&1u32), 4);
+    assert_eq!(size_of_val(&1u64), 8);
+}
+
+#[test]
+fn align_of_basic() {
+    assert_eq!(align_of::<u8>(), 1u);
+    assert_eq!(align_of::<u16>(), 2u);
+    assert_eq!(align_of::<u32>(), 4u);
+}
+
+#[test]
+#[cfg(target_arch = "x86")]
+#[cfg(target_arch = "arm")]
+#[cfg(target_arch = "mips")]
+#[cfg(target_arch = "mipsel")]
+fn align_of_32() {
+    assert_eq!(align_of::<uint>(), 4u);
+    assert_eq!(align_of::<*const uint>(), 4u);
+}
+
+#[test]
+#[cfg(target_arch = "x86_64")]
+fn align_of_64() {
+    assert_eq!(align_of::<uint>(), 8u);
+    assert_eq!(align_of::<*const uint>(), 8u);
+}
+
+#[test]
+fn align_of_val_basic() {
+    assert_eq!(align_of_val(&1u8), 1u);
+    assert_eq!(align_of_val(&1u16), 2u);
+    assert_eq!(align_of_val(&1u32), 4u);
+}
+
+#[test]
+fn test_swap() {
+    let mut x = 31337i;
+    let mut y = 42i;
+    swap(&mut x, &mut y);
+    assert_eq!(x, 42);
+    assert_eq!(y, 31337);
+}
+
+#[test]
+fn test_replace() {
+    let mut x = Some("test".to_string());
+    let y = replace(&mut x, None);
+    assert!(x.is_none());
+    assert!(y.is_some());
+}
+
+#[test]
+fn test_transmute_copy() {
+    assert_eq!(1u, unsafe { transmute_copy(&1i) });
+}
+
+#[test]
+fn test_transmute() {
+    trait Foo {}
+    impl Foo for int {}
+
+    let a = box 100i as Box<Foo>;
+    unsafe {
+        let x: ::core::raw::TraitObject = transmute(a);
+        assert!(*(x.data as *const int) == 100);
+        let _x: Box<Foo> = transmute(x);
+    }
+
+    unsafe {
+        assert!(Vec::from_slice([76u8]) == transmute("L".to_string()));
+    }
+}
+
+// FIXME #13642 (these benchmarks should be in another place)
+/// Completely miscellaneous language-construct benchmarks.
+// Static/dynamic method dispatch
+
+struct Struct {
+    field: int
+}
+
+trait Trait {
+    fn method(&self) -> int;
+}
+
+impl Trait for Struct {
+    fn method(&self) -> int {
+        self.field
+    }
+}
+
+#[bench]
+fn trait_vtable_method_call(b: &mut Bencher) {
+    let s = Struct { field: 10 };
+    let t = &s as &Trait;
+    b.iter(|| {
+        t.method()
+    });
+}
+
+#[bench]
+fn trait_static_method_call(b: &mut Bencher) {
+    let s = Struct { field: 10 };
+    b.iter(|| {
+        s.method()
+    });
+}
+
+// Overhead of various match forms
+
+#[bench]
+fn match_option_some(b: &mut Bencher) {
+    let x = Some(10i);
+    b.iter(|| {
+        match x {
+            Some(y) => y,
+            None => 11
+        }
+    });
+}
+
+#[bench]
+fn match_vec_pattern(b: &mut Bencher) {
+    let x = [1i,2,3,4,5,6];
+    b.iter(|| {
+        match x {
+            [1,2,3,..] => 10i,
+            _ => 11i,
+        }
+    });
+}
diff --git a/src/libcoretest/num/i16.rs b/src/libcoretest/num/i16.rs
new file mode 100644 (file)
index 0000000..f3c2d67
--- /dev/null
@@ -0,0 +1,11 @@
+// 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.
+
+int_module!(i16, i16)
diff --git a/src/libcoretest/num/i32.rs b/src/libcoretest/num/i32.rs
new file mode 100644 (file)
index 0000000..7232fc7
--- /dev/null
@@ -0,0 +1,11 @@
+// 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.
+
+int_module!(i32, i32)
diff --git a/src/libcoretest/num/i64.rs b/src/libcoretest/num/i64.rs
new file mode 100644 (file)
index 0000000..075b844
--- /dev/null
@@ -0,0 +1,11 @@
+// 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.
+
+int_module!(i64, i64)
diff --git a/src/libcoretest/num/i8.rs b/src/libcoretest/num/i8.rs
new file mode 100644 (file)
index 0000000..9e0439f
--- /dev/null
@@ -0,0 +1,11 @@
+// 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.
+
+int_module!(i8, i8)
diff --git a/src/libcoretest/num/int.rs b/src/libcoretest/num/int.rs
new file mode 100644 (file)
index 0000000..f01ec3f
--- /dev/null
@@ -0,0 +1,11 @@
+// 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.
+
+int_module!(int, int)
diff --git a/src/libcoretest/num/int_macros.rs b/src/libcoretest/num/int_macros.rs
new file mode 100644 (file)
index 0000000..940b036
--- /dev/null
@@ -0,0 +1,160 @@
+// 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.
+
+#![macro_escape]
+
+macro_rules! int_module (($T:ty, $T_i:ident) => (
+#[cfg(test)]
+mod tests {
+    use core::$T_i::*;
+    use core::int;
+    use num;
+    use core::num::CheckedDiv;
+
+    #[test]
+    fn test_overflows() {
+        assert!(MAX > 0);
+        assert!(MIN <= 0);
+        assert!(MIN + MAX + 1 == 0);
+    }
+
+    #[test]
+    fn test_num() {
+        num::test_num(10 as $T, 2 as $T);
+    }
+
+    #[test]
+    pub fn test_abs() {
+        assert!((1 as $T).abs() == 1 as $T);
+        assert!((0 as $T).abs() == 0 as $T);
+        assert!((-1 as $T).abs() == 1 as $T);
+    }
+
+    #[test]
+    fn test_abs_sub() {
+        assert!((-1 as $T).abs_sub(&(1 as $T)) == 0 as $T);
+        assert!((1 as $T).abs_sub(&(1 as $T)) == 0 as $T);
+        assert!((1 as $T).abs_sub(&(0 as $T)) == 1 as $T);
+        assert!((1 as $T).abs_sub(&(-1 as $T)) == 2 as $T);
+    }
+
+    #[test]
+    fn test_signum() {
+        assert!((1 as $T).signum() == 1 as $T);
+        assert!((0 as $T).signum() == 0 as $T);
+        assert!((-0 as $T).signum() == 0 as $T);
+        assert!((-1 as $T).signum() == -1 as $T);
+    }
+
+    #[test]
+    fn test_is_positive() {
+        assert!((1 as $T).is_positive());
+        assert!(!(0 as $T).is_positive());
+        assert!(!(-0 as $T).is_positive());
+        assert!(!(-1 as $T).is_positive());
+    }
+
+    #[test]
+    fn test_is_negative() {
+        assert!(!(1 as $T).is_negative());
+        assert!(!(0 as $T).is_negative());
+        assert!(!(-0 as $T).is_negative());
+        assert!((-1 as $T).is_negative());
+    }
+
+    #[test]
+    fn test_bitwise_operators() {
+        assert!(0b1110 as $T == (0b1100 as $T).bitor(&(0b1010 as $T)));
+        assert!(0b1000 as $T == (0b1100 as $T).bitand(&(0b1010 as $T)));
+        assert!(0b0110 as $T == (0b1100 as $T).bitxor(&(0b1010 as $T)));
+        assert!(0b1110 as $T == (0b0111 as $T).shl(&(1 as $T)));
+        assert!(0b0111 as $T == (0b1110 as $T).shr(&(1 as $T)));
+        assert!(-(0b11 as $T) - (1 as $T) == (0b11 as $T).not());
+    }
+
+    static A: $T = 0b0101100;
+    static B: $T = 0b0100001;
+    static C: $T = 0b1111001;
+
+    static _0: $T = 0;
+    static _1: $T = !0;
+
+    #[test]
+    fn test_count_ones() {
+        assert!(A.count_ones() == 3);
+        assert!(B.count_ones() == 2);
+        assert!(C.count_ones() == 5);
+    }
+
+    #[test]
+    fn test_count_zeros() {
+        assert!(A.count_zeros() == BITS as $T - 3);
+        assert!(B.count_zeros() == BITS as $T - 2);
+        assert!(C.count_zeros() == BITS as $T - 5);
+    }
+
+    #[test]
+    fn test_rotate() {
+        assert_eq!(A.rotate_left(6).rotate_right(2).rotate_right(4), A);
+        assert_eq!(B.rotate_left(3).rotate_left(2).rotate_right(5), B);
+        assert_eq!(C.rotate_left(6).rotate_right(2).rotate_right(4), C);
+
+        // Rotating these should make no difference
+        //
+        // We test using 124 bits because to ensure that overlong bit shifts do
+        // not cause undefined behaviour. See #10183.
+        assert_eq!(_0.rotate_left(124), _0);
+        assert_eq!(_1.rotate_left(124), _1);
+        assert_eq!(_0.rotate_right(124), _0);
+        assert_eq!(_1.rotate_right(124), _1);
+    }
+
+    #[test]
+    fn test_swap_bytes() {
+        assert_eq!(A.swap_bytes().swap_bytes(), A);
+        assert_eq!(B.swap_bytes().swap_bytes(), B);
+        assert_eq!(C.swap_bytes().swap_bytes(), C);
+
+        // Swapping these should make no difference
+        assert_eq!(_0.swap_bytes(), _0);
+        assert_eq!(_1.swap_bytes(), _1);
+    }
+
+    #[test]
+    fn test_le() {
+        assert_eq!(Int::from_le(A.to_le()), A);
+        assert_eq!(Int::from_le(B.to_le()), B);
+        assert_eq!(Int::from_le(C.to_le()), C);
+        assert_eq!(Int::from_le(_0), _0);
+        assert_eq!(Int::from_le(_1), _1);
+        assert_eq!(_0.to_le(), _0);
+        assert_eq!(_1.to_le(), _1);
+    }
+
+    #[test]
+    fn test_be() {
+        assert_eq!(Int::from_be(A.to_be()), A);
+        assert_eq!(Int::from_be(B.to_be()), B);
+        assert_eq!(Int::from_be(C.to_be()), C);
+        assert_eq!(Int::from_be(_0), _0);
+        assert_eq!(Int::from_be(_1), _1);
+        assert_eq!(_0.to_be(), _0);
+        assert_eq!(_1.to_be(), _1);
+    }
+
+    #[test]
+    fn test_signed_checked_div() {
+        assert!(10i.checked_div(&2) == Some(5));
+        assert!(5i.checked_div(&0) == None);
+        assert!(int::MIN.checked_div(&-1) == None);
+    }
+}
+
+))
diff --git a/src/libcoretest/num/mod.rs b/src/libcoretest/num/mod.rs
new file mode 100644 (file)
index 0000000..8bb238c
--- /dev/null
@@ -0,0 +1,39 @@
+// 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 core::num::cast;
+
+mod int_macros;
+mod i8;
+mod i16;
+mod i32;
+mod i64;
+mod int;
+mod uint_macros;
+mod u8;
+mod u16;
+mod u32;
+mod u64;
+mod uint;
+
+/// Helper function for testing numeric operations
+pub fn test_num<T:Num + NumCast + ::std::fmt::Show>(ten: T, two: T) {
+    assert_eq!(ten.add(&two),  cast(12i).unwrap());
+    assert_eq!(ten.sub(&two),  cast(8i).unwrap());
+    assert_eq!(ten.mul(&two),  cast(20i).unwrap());
+    assert_eq!(ten.div(&two),  cast(5i).unwrap());
+    assert_eq!(ten.rem(&two),  cast(0i).unwrap());
+
+    assert_eq!(ten.add(&two),  ten + two);
+    assert_eq!(ten.sub(&two),  ten - two);
+    assert_eq!(ten.mul(&two),  ten * two);
+    assert_eq!(ten.div(&two),  ten / two);
+    assert_eq!(ten.rem(&two),  ten % two);
+}
diff --git a/src/libcoretest/num/u16.rs b/src/libcoretest/num/u16.rs
new file mode 100644 (file)
index 0000000..d6aa647
--- /dev/null
@@ -0,0 +1,11 @@
+// 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.
+
+uint_module!(u16, u16)
diff --git a/src/libcoretest/num/u32.rs b/src/libcoretest/num/u32.rs
new file mode 100644 (file)
index 0000000..218e79d
--- /dev/null
@@ -0,0 +1,11 @@
+// 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.
+
+uint_module!(u32, u32)
diff --git a/src/libcoretest/num/u64.rs b/src/libcoretest/num/u64.rs
new file mode 100644 (file)
index 0000000..f78d481
--- /dev/null
@@ -0,0 +1,11 @@
+// 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.
+
+uint_module!(u64, u64)
diff --git a/src/libcoretest/num/u8.rs b/src/libcoretest/num/u8.rs
new file mode 100644 (file)
index 0000000..bb08072
--- /dev/null
@@ -0,0 +1,11 @@
+// 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.
+
+uint_module!(u8, u8)
diff --git a/src/libcoretest/num/uint.rs b/src/libcoretest/num/uint.rs
new file mode 100644 (file)
index 0000000..0db865f
--- /dev/null
@@ -0,0 +1,11 @@
+// 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.
+
+uint_module!(uint, uint)
diff --git a/src/libcoretest/num/uint_macros.rs b/src/libcoretest/num/uint_macros.rs
new file mode 100644 (file)
index 0000000..2272af6
--- /dev/null
@@ -0,0 +1,118 @@
+// 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.
+
+#![macro_escape]
+
+macro_rules! uint_module (($T:ty, $T_i:ident) => (
+#[cfg(test)]
+mod tests {
+    use core::$T_i::*;
+    use num;
+    use core::num::CheckedDiv;
+
+    #[test]
+    fn test_overflows() {
+        assert!(MAX > 0);
+        assert!(MIN <= 0);
+        assert!(MIN + MAX + 1 == 0);
+    }
+
+    #[test]
+    fn test_num() {
+        num::test_num(10 as $T, 2 as $T);
+    }
+
+    #[test]
+    fn test_bitwise_operators() {
+        assert!(0b1110 as $T == (0b1100 as $T).bitor(&(0b1010 as $T)));
+        assert!(0b1000 as $T == (0b1100 as $T).bitand(&(0b1010 as $T)));
+        assert!(0b0110 as $T == (0b1100 as $T).bitxor(&(0b1010 as $T)));
+        assert!(0b1110 as $T == (0b0111 as $T).shl(&(1 as $T)));
+        assert!(0b0111 as $T == (0b1110 as $T).shr(&(1 as $T)));
+        assert!(MAX - (0b1011 as $T) == (0b1011 as $T).not());
+    }
+
+    static A: $T = 0b0101100;
+    static B: $T = 0b0100001;
+    static C: $T = 0b1111001;
+
+    static _0: $T = 0;
+    static _1: $T = !0;
+
+    #[test]
+    fn test_count_ones() {
+        assert!(A.count_ones() == 3);
+        assert!(B.count_ones() == 2);
+        assert!(C.count_ones() == 5);
+    }
+
+    #[test]
+    fn test_count_zeros() {
+        assert!(A.count_zeros() == BITS as $T - 3);
+        assert!(B.count_zeros() == BITS as $T - 2);
+        assert!(C.count_zeros() == BITS as $T - 5);
+    }
+
+    #[test]
+    fn test_rotate() {
+        assert_eq!(A.rotate_left(6).rotate_right(2).rotate_right(4), A);
+        assert_eq!(B.rotate_left(3).rotate_left(2).rotate_right(5), B);
+        assert_eq!(C.rotate_left(6).rotate_right(2).rotate_right(4), C);
+
+        // Rotating these should make no difference
+        //
+        // We test using 124 bits because to ensure that overlong bit shifts do
+        // not cause undefined behaviour. See #10183.
+        assert_eq!(_0.rotate_left(124), _0);
+        assert_eq!(_1.rotate_left(124), _1);
+        assert_eq!(_0.rotate_right(124), _0);
+        assert_eq!(_1.rotate_right(124), _1);
+    }
+
+    #[test]
+    fn test_swap_bytes() {
+        assert_eq!(A.swap_bytes().swap_bytes(), A);
+        assert_eq!(B.swap_bytes().swap_bytes(), B);
+        assert_eq!(C.swap_bytes().swap_bytes(), C);
+
+        // Swapping these should make no difference
+        assert_eq!(_0.swap_bytes(), _0);
+        assert_eq!(_1.swap_bytes(), _1);
+    }
+
+    #[test]
+    fn test_le() {
+        assert_eq!(Int::from_le(A.to_le()), A);
+        assert_eq!(Int::from_le(B.to_le()), B);
+        assert_eq!(Int::from_le(C.to_le()), C);
+        assert_eq!(Int::from_le(_0), _0);
+        assert_eq!(Int::from_le(_1), _1);
+        assert_eq!(_0.to_le(), _0);
+        assert_eq!(_1.to_le(), _1);
+    }
+
+    #[test]
+    fn test_be() {
+        assert_eq!(Int::from_be(A.to_be()), A);
+        assert_eq!(Int::from_be(B.to_be()), B);
+        assert_eq!(Int::from_be(C.to_be()), C);
+        assert_eq!(Int::from_be(_0), _0);
+        assert_eq!(Int::from_be(_1), _1);
+        assert_eq!(_0.to_be(), _0);
+        assert_eq!(_1.to_be(), _1);
+    }
+
+    #[test]
+    fn test_unsigned_checked_div() {
+        assert!(10u.checked_div(&2) == Some(5));
+        assert!(5u.checked_div(&0) == None);
+    }
+}
+))
diff --git a/src/libcoretest/ops.rs b/src/libcoretest/ops.rs
new file mode 100644 (file)
index 0000000..447fd1c
--- /dev/null
@@ -0,0 +1,29 @@
+// 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 test::Bencher;
+
+// Overhead of dtors
+
+struct HasDtor {
+    _x: int
+}
+
+impl Drop for HasDtor {
+    fn drop(&mut self) {
+    }
+}
+
+#[bench]
+fn alloc_obj_with_dtor(b: &mut Bencher) {
+    b.iter(|| {
+        HasDtor { _x : 10 };
+    })
+}
diff --git a/src/libcoretest/option.rs b/src/libcoretest/option.rs
new file mode 100644 (file)
index 0000000..776637f
--- /dev/null
@@ -0,0 +1,278 @@
+// 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 core::option::*;
+use core::kinds::marker;
+use core::mem;
+
+#[test]
+fn test_get_ptr() {
+    unsafe {
+        let x = box 0i;
+        let addr_x: *const int = mem::transmute(&*x);
+        let opt = Some(x);
+        let y = opt.unwrap();
+        let addr_y: *const int = mem::transmute(&*y);
+        assert_eq!(addr_x, addr_y);
+    }
+}
+
+#[test]
+fn test_get_str() {
+    let x = "test".to_string();
+    let addr_x = x.as_slice().as_ptr();
+    let opt = Some(x);
+    let y = opt.unwrap();
+    let addr_y = y.as_slice().as_ptr();
+    assert_eq!(addr_x, addr_y);
+}
+
+#[test]
+fn test_get_resource() {
+    use std::rc::Rc;
+    use core::cell::RefCell;
+
+    struct R {
+       i: Rc<RefCell<int>>,
+    }
+
+    #[unsafe_destructor]
+    impl Drop for R {
+       fn drop(&mut self) {
+            let ii = &*self.i;
+            let i = *ii.borrow();
+            *ii.borrow_mut() = i + 1;
+        }
+    }
+
+    fn r(i: Rc<RefCell<int>>) -> R {
+        R {
+            i: i
+        }
+    }
+
+    let i = Rc::new(RefCell::new(0i));
+    {
+        let x = r(i.clone());
+        let opt = Some(x);
+        let _y = opt.unwrap();
+    }
+    assert_eq!(*i.borrow(), 1);
+}
+
+#[test]
+fn test_option_dance() {
+    let x = Some(());
+    let mut y = Some(5i);
+    let mut y2 = 0;
+    for _x in x.iter() {
+        y2 = y.take_unwrap();
+    }
+    assert_eq!(y2, 5);
+    assert!(y.is_none());
+}
+
+#[test] #[should_fail]
+fn test_option_too_much_dance() {
+    let mut y = Some(marker::NoCopy);
+    let _y2 = y.take_unwrap();
+    let _y3 = y.take_unwrap();
+}
+
+#[test]
+fn test_and() {
+    let x: Option<int> = Some(1i);
+    assert_eq!(x.and(Some(2i)), Some(2));
+    assert_eq!(x.and(None::<int>), None);
+
+    let x: Option<int> = None;
+    assert_eq!(x.and(Some(2i)), None);
+    assert_eq!(x.and(None::<int>), None);
+}
+
+#[test]
+fn test_and_then() {
+    let x: Option<int> = Some(1);
+    assert_eq!(x.and_then(|x| Some(x + 1)), Some(2));
+    assert_eq!(x.and_then(|_| None::<int>), None);
+
+    let x: Option<int> = None;
+    assert_eq!(x.and_then(|x| Some(x + 1)), None);
+    assert_eq!(x.and_then(|_| None::<int>), None);
+}
+
+#[test]
+fn test_or() {
+    let x: Option<int> = Some(1);
+    assert_eq!(x.or(Some(2)), Some(1));
+    assert_eq!(x.or(None), Some(1));
+
+    let x: Option<int> = None;
+    assert_eq!(x.or(Some(2)), Some(2));
+    assert_eq!(x.or(None), None);
+}
+
+#[test]
+fn test_or_else() {
+    let x: Option<int> = Some(1);
+    assert_eq!(x.or_else(|| Some(2)), Some(1));
+    assert_eq!(x.or_else(|| None), Some(1));
+
+    let x: Option<int> = None;
+    assert_eq!(x.or_else(|| Some(2)), Some(2));
+    assert_eq!(x.or_else(|| None), None);
+}
+
+#[test]
+fn test_option_while_some() {
+    let mut i = 0i;
+    Some(10i).while_some(|j| {
+        i += 1;
+        if j > 0 {
+            Some(j-1)
+        } else {
+            None
+        }
+    });
+    assert_eq!(i, 11);
+}
+
+#[test]
+fn test_unwrap() {
+    assert_eq!(Some(1i).unwrap(), 1);
+    let s = Some("hello".to_string()).unwrap();
+    assert_eq!(s.as_slice(), "hello");
+}
+
+#[test]
+#[should_fail]
+fn test_unwrap_fail1() {
+    let x: Option<int> = None;
+    x.unwrap();
+}
+
+#[test]
+#[should_fail]
+fn test_unwrap_fail2() {
+    let x: Option<String> = None;
+    x.unwrap();
+}
+
+#[test]
+fn test_unwrap_or() {
+    let x: Option<int> = Some(1);
+    assert_eq!(x.unwrap_or(2), 1);
+
+    let x: Option<int> = None;
+    assert_eq!(x.unwrap_or(2), 2);
+}
+
+#[test]
+fn test_unwrap_or_else() {
+    let x: Option<int> = Some(1);
+    assert_eq!(x.unwrap_or_else(|| 2), 1);
+
+    let x: Option<int> = None;
+    assert_eq!(x.unwrap_or_else(|| 2), 2);
+}
+
+#[test]
+fn test_filtered() {
+    let some_stuff = Some(42i);
+    let modified_stuff = some_stuff.filtered(|&x| {x < 10});
+    assert_eq!(some_stuff.unwrap(), 42);
+    assert!(modified_stuff.is_none());
+}
+
+#[test]
+fn test_iter() {
+    let val = 5i;
+
+    let x = Some(val);
+    let mut it = x.iter();
+
+    assert_eq!(it.size_hint(), (1, Some(1)));
+    assert_eq!(it.next(), Some(&val));
+    assert_eq!(it.size_hint(), (0, Some(0)));
+    assert!(it.next().is_none());
+}
+
+#[test]
+fn test_mut_iter() {
+    let val = 5i;
+    let new_val = 11i;
+
+    let mut x = Some(val);
+    {
+        let mut it = x.mut_iter();
+
+        assert_eq!(it.size_hint(), (1, Some(1)));
+
+        match it.next() {
+            Some(interior) => {
+                assert_eq!(*interior, val);
+                *interior = new_val;
+            }
+            None => assert!(false),
+        }
+
+        assert_eq!(it.size_hint(), (0, Some(0)));
+        assert!(it.next().is_none());
+    }
+    assert_eq!(x, Some(new_val));
+}
+
+#[test]
+fn test_ord() {
+    let small = Some(1.0f64);
+    let big = Some(5.0f64);
+    let nan = Some(0.0f64/0.0);
+    assert!(!(nan < big));
+    assert!(!(nan > big));
+    assert!(small < big);
+    assert!(None < big);
+    assert!(big > None);
+}
+
+#[test]
+fn test_mutate() {
+    let mut x = Some(3i);
+    assert!(x.mutate(|i| i+1));
+    assert_eq!(x, Some(4i));
+    assert!(x.mutate_or_set(0, |i| i+1));
+    assert_eq!(x, Some(5i));
+    x = None;
+    assert!(!x.mutate(|i| i+1));
+    assert_eq!(x, None);
+    assert!(!x.mutate_or_set(0i, |i| i+1));
+    assert_eq!(x, Some(0i));
+}
+
+#[test]
+fn test_collect() {
+    let v: Option<Vec<int>> = collect(range(0i, 0)
+                                      .map(|_| Some(0i)));
+    assert!(v == Some(vec![]));
+
+    let v: Option<Vec<int>> = collect(range(0i, 3)
+                                      .map(|x| Some(x)));
+    assert!(v == Some(vec![0, 1, 2]));
+
+    let v: Option<Vec<int>> = collect(range(0i, 3)
+                                      .map(|x| if x > 1 { None } else { Some(x) }));
+    assert!(v == None);
+
+    // test that it does not take more elements than it needs
+    let mut functions = [|| Some(()), || None, || fail!()];
+
+    let v: Option<Vec<()>> = collect(functions.mut_iter().map(|f| (*f)()));
+
+    assert!(v == None);
+}
diff --git a/src/libcoretest/ptr.rs b/src/libcoretest/ptr.rs
new file mode 100644 (file)
index 0000000..2a4ef5e
--- /dev/null
@@ -0,0 +1,255 @@
+// 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.
+#![allow(deprecated)]
+use core::ptr::*;
+use libc::c_char;
+use core::mem;
+use std::str;
+use libc;
+
+#[test]
+fn test() {
+    unsafe {
+        struct Pair {
+            fst: int,
+            snd: int
+        };
+        let mut p = Pair {fst: 10, snd: 20};
+        let pptr: *mut Pair = &mut p;
+        let iptr: *mut int = mem::transmute(pptr);
+        assert_eq!(*iptr, 10);
+        *iptr = 30;
+        assert_eq!(*iptr, 30);
+        assert_eq!(p.fst, 30);
+
+        *pptr = Pair {fst: 50, snd: 60};
+        assert_eq!(*iptr, 50);
+        assert_eq!(p.fst, 50);
+        assert_eq!(p.snd, 60);
+
+        let v0 = vec![32000u16, 32001u16, 32002u16];
+        let mut v1 = vec![0u16, 0u16, 0u16];
+
+        copy_memory(v1.as_mut_ptr().offset(1),
+                    v0.as_ptr().offset(1), 1);
+        assert!((*v1.get(0) == 0u16 &&
+                 *v1.get(1) == 32001u16 &&
+                 *v1.get(2) == 0u16));
+        copy_memory(v1.as_mut_ptr(),
+                    v0.as_ptr().offset(2), 1);
+        assert!((*v1.get(0) == 32002u16 &&
+                 *v1.get(1) == 32001u16 &&
+                 *v1.get(2) == 0u16));
+        copy_memory(v1.as_mut_ptr().offset(2),
+                    v0.as_ptr(), 1u);
+        assert!((*v1.get(0) == 32002u16 &&
+                 *v1.get(1) == 32001u16 &&
+                 *v1.get(2) == 32000u16));
+    }
+}
+
+#[test]
+fn test_position() {
+    use libc::c_char;
+
+    "hello".with_c_str(|p| {
+        unsafe {
+            assert!(2u == position(p, |c| *c == 'l' as c_char));
+            assert!(4u == position(p, |c| *c == 'o' as c_char));
+            assert!(5u == position(p, |c| *c == 0 as c_char));
+        }
+    })
+}
+
+#[test]
+fn test_buf_len() {
+    "hello".with_c_str(|p0| {
+        "there".with_c_str(|p1| {
+            "thing".with_c_str(|p2| {
+                let v = vec![p0, p1, p2, null()];
+                unsafe {
+                    assert_eq!(buf_len(v.as_ptr()), 3u);
+                }
+            })
+        })
+    })
+}
+
+#[test]
+fn test_is_null() {
+    let p: *const int = null();
+    assert!(p.is_null());
+    assert!(!p.is_not_null());
+
+    let q = unsafe { p.offset(1) };
+    assert!(!q.is_null());
+    assert!(q.is_not_null());
+
+    let mp: *mut int = mut_null();
+    assert!(mp.is_null());
+    assert!(!mp.is_not_null());
+
+    let mq = unsafe { mp.offset(1) };
+    assert!(!mq.is_null());
+    assert!(mq.is_not_null());
+}
+
+#[test]
+fn test_to_option() {
+    unsafe {
+        let p: *const int = null();
+        assert_eq!(p.to_option(), None);
+
+        let q: *const int = &2;
+        assert_eq!(q.to_option().unwrap(), &2);
+
+        let p: *mut int = mut_null();
+        assert_eq!(p.to_option(), None);
+
+        let q: *mut int = &mut 2;
+        assert_eq!(q.to_option().unwrap(), &2);
+    }
+}
+
+#[test]
+fn test_ptr_addition() {
+    unsafe {
+        let xs = Vec::from_elem(16, 5i);
+        let mut ptr = xs.as_ptr();
+        let end = ptr.offset(16);
+
+        while ptr < end {
+            assert_eq!(*ptr, 5);
+            ptr = ptr.offset(1);
+        }
+
+        let mut xs_mut = xs;
+        let mut m_ptr = xs_mut.as_mut_ptr();
+        let m_end = m_ptr.offset(16);
+
+        while m_ptr < m_end {
+            *m_ptr += 5;
+            m_ptr = m_ptr.offset(1);
+        }
+
+        assert!(xs_mut == Vec::from_elem(16, 10i));
+    }
+}
+
+#[test]
+fn test_ptr_subtraction() {
+    unsafe {
+        let xs = vec![0,1,2,3,4,5,6,7,8,9];
+        let mut idx = 9i8;
+        let ptr = xs.as_ptr();
+
+        while idx >= 0i8 {
+            assert_eq!(*(ptr.offset(idx as int)), idx as int);
+            idx = idx - 1i8;
+        }
+
+        let mut xs_mut = xs;
+        let m_start = xs_mut.as_mut_ptr();
+        let mut m_ptr = m_start.offset(9);
+
+        while m_ptr >= m_start {
+            *m_ptr += *m_ptr;
+            m_ptr = m_ptr.offset(-1);
+        }
+
+        assert!(xs_mut == vec![0,2,4,6,8,10,12,14,16,18]);
+    }
+}
+
+#[test]
+fn test_ptr_array_each_with_len() {
+    unsafe {
+        let one = "oneOne".to_c_str();
+        let two = "twoTwo".to_c_str();
+        let three = "threeThree".to_c_str();
+        let arr = vec![
+            one.as_ptr(),
+            two.as_ptr(),
+            three.as_ptr()
+        ];
+        let expected_arr = [
+            one, two, three
+        ];
+
+        let mut ctr = 0;
+        let mut iteration_count = 0;
+        array_each_with_len(arr.as_ptr(), arr.len(), |e| {
+                let actual = str::raw::from_c_str(e);
+                let expected = str::raw::from_c_str(expected_arr[ctr].as_ptr());
+                assert_eq!(actual.as_slice(), expected.as_slice());
+                ctr += 1;
+                iteration_count += 1;
+            });
+        assert_eq!(iteration_count, 3u);
+    }
+}
+
+#[test]
+fn test_ptr_array_each() {
+    unsafe {
+        let one = "oneOne".to_c_str();
+        let two = "twoTwo".to_c_str();
+        let three = "threeThree".to_c_str();
+        let arr = vec![
+            one.as_ptr(),
+            two.as_ptr(),
+            three.as_ptr(),
+            // fake a null terminator
+            null()
+        ];
+        let expected_arr = [
+            one, two, three
+        ];
+
+        let arr_ptr = arr.as_ptr();
+        let mut ctr = 0u;
+        let mut iteration_count = 0u;
+        array_each(arr_ptr, |e| {
+                let actual = str::raw::from_c_str(e);
+                let expected = str::raw::from_c_str(expected_arr[ctr].as_ptr());
+                assert_eq!(actual.as_slice(), expected.as_slice());
+                ctr += 1;
+                iteration_count += 1;
+            });
+        assert_eq!(iteration_count, 3);
+    }
+}
+
+#[test]
+#[should_fail]
+fn test_ptr_array_each_with_len_null_ptr() {
+    unsafe {
+        array_each_with_len(0 as *const *const libc::c_char, 1, |e| {
+            str::raw::from_c_str(e);
+        });
+    }
+}
+#[test]
+#[should_fail]
+fn test_ptr_array_each_null_ptr() {
+    unsafe {
+        array_each(0 as *const *const libc::c_char, |e| {
+            str::raw::from_c_str(e);
+        });
+    }
+}
+
+#[test]
+fn test_set_memory() {
+    let mut xs = [0u8, ..20];
+    let ptr = xs.as_mut_ptr();
+    unsafe { set_memory(ptr, 5u8, xs.len()); }
+    assert!(xs == [5u8, ..20]);
+}
diff --git a/src/libcoretest/raw.rs b/src/libcoretest/raw.rs
new file mode 100644 (file)
index 0000000..f2c23c7
--- /dev/null
@@ -0,0 +1,35 @@
+// 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 core::raw::*;
+use core::mem;
+
+#[test]
+fn synthesize_closure() {
+    unsafe {
+        let x = 10;
+        let f: |int| -> int = |y| x + y;
+
+        assert_eq!(f(20), 30);
+
+        let original_closure: Closure = mem::transmute(f);
+
+        let actual_function_pointer = original_closure.code;
+        let environment = original_closure.env;
+
+        let new_closure = Closure {
+            code: actual_function_pointer,
+            env: environment
+        };
+
+        let new_f: |int| -> int = mem::transmute(new_closure);
+        assert_eq!(new_f(20), 30);
+    }
+}
diff --git a/src/libcoretest/result.rs b/src/libcoretest/result.rs
new file mode 100644 (file)
index 0000000..7c7e0a5
--- /dev/null
@@ -0,0 +1,161 @@
+// 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 core::result::{collect, fold, fold_};
+use core::iter::range;
+
+pub fn op1() -> Result<int, &'static str> { Ok(666) }
+pub fn op2() -> Result<int, &'static str> { Err("sadface") }
+
+#[test]
+pub fn test_and() {
+    assert_eq!(op1().and(Ok(667i)).unwrap(), 667);
+    assert_eq!(op1().and(Err::<(), &'static str>("bad")).unwrap_err(),
+               "bad");
+
+    assert_eq!(op2().and(Ok(667i)).unwrap_err(), "sadface");
+    assert_eq!(op2().and(Err::<(),&'static str>("bad")).unwrap_err(),
+               "sadface");
+}
+
+#[test]
+pub fn test_and_then() {
+    assert_eq!(op1().and_then(|i| Ok::<int, &'static str>(i + 1)).unwrap(), 667);
+    assert_eq!(op1().and_then(|_| Err::<int, &'static str>("bad")).unwrap_err(),
+               "bad");
+
+    assert_eq!(op2().and_then(|i| Ok::<int, &'static str>(i + 1)).unwrap_err(),
+               "sadface");
+    assert_eq!(op2().and_then(|_| Err::<int, &'static str>("bad")).unwrap_err(),
+               "sadface");
+}
+
+#[test]
+pub fn test_or() {
+    assert_eq!(op1().or(Ok(667)).unwrap(), 666);
+    assert_eq!(op1().or(Err("bad")).unwrap(), 666);
+
+    assert_eq!(op2().or(Ok(667)).unwrap(), 667);
+    assert_eq!(op2().or(Err("bad")).unwrap_err(), "bad");
+}
+
+#[test]
+pub fn test_or_else() {
+    assert_eq!(op1().or_else(|_| Ok::<int, &'static str>(667)).unwrap(), 666);
+    assert_eq!(op1().or_else(|e| Err::<int, &'static str>(e)).unwrap(), 666);
+
+    assert_eq!(op2().or_else(|_| Ok::<int, &'static str>(667)).unwrap(), 667);
+    assert_eq!(op2().or_else(|e| Err::<int, &'static str>(e)).unwrap_err(),
+               "sadface");
+}
+
+#[test]
+pub fn test_impl_map() {
+    assert!(Ok::<int, int>(1).map(|x| x + 1) == Ok(2));
+    assert!(Err::<int, int>(1).map(|x| x + 1) == Err(1));
+}
+
+#[test]
+pub fn test_impl_map_err() {
+    assert!(Ok::<int, int>(1).map_err(|x| x + 1) == Ok(1));
+    assert!(Err::<int, int>(1).map_err(|x| x + 1) == Err(2));
+}
+
+#[test]
+fn test_collect() {
+    let v: Result<Vec<int>, ()> = collect(range(0i, 0).map(|_| Ok::<int, ()>(0)));
+    assert!(v == Ok(vec![]));
+
+    let v: Result<Vec<int>, ()> = collect(range(0i, 3).map(|x| Ok::<int, ()>(x)));
+    assert!(v == Ok(vec![0, 1, 2]));
+
+    let v: Result<Vec<int>, int> = collect(range(0i, 3)
+                                           .map(|x| if x > 1 { Err(x) } else { Ok(x) }));
+    assert!(v == Err(2));
+
+    // test that it does not take more elements than it needs
+    let mut functions = [|| Ok(()), || Err(1i), || fail!()];
+
+    let v: Result<Vec<()>, int> = collect(functions.mut_iter().map(|f| (*f)()));
+    assert!(v == Err(1));
+}
+
+#[test]
+fn test_fold() {
+    assert_eq!(fold_(range(0i, 0)
+                    .map(|_| Ok::<(), ()>(()))),
+               Ok(()));
+    assert_eq!(fold(range(0i, 3)
+                    .map(|x| Ok::<int, ()>(x)),
+                    0, |a, b| a + b),
+               Ok(3));
+    assert_eq!(fold_(range(0i, 3)
+                    .map(|x| if x > 1 { Err(x) } else { Ok(()) })),
+               Err(2));
+
+    // test that it does not take more elements than it needs
+    let mut functions = [|| Ok(()), || Err(1i), || fail!()];
+
+    assert_eq!(fold_(functions.mut_iter()
+                    .map(|f| (*f)())),
+               Err(1));
+}
+
+#[test]
+pub fn test_fmt_default() {
+    let ok: Result<int, &'static str> = Ok(100);
+    let err: Result<int, &'static str> = Err("Err");
+
+    let s = format!("{}", ok);
+    assert_eq!(s.as_slice(), "Ok(100)");
+    let s = format!("{}", err);
+    assert_eq!(s.as_slice(), "Err(Err)");
+}
+
+#[test]
+pub fn test_unwrap_or() {
+    let ok: Result<int, &'static str> = Ok(100i);
+    let ok_err: Result<int, &'static str> = Err("Err");
+
+    assert_eq!(ok.unwrap_or(50), 100);
+    assert_eq!(ok_err.unwrap_or(50), 50);
+}
+
+#[test]
+pub fn test_unwrap_or_else() {
+    fn handler(msg: &'static str) -> int {
+        if msg == "I got this." {
+            50i
+        } else {
+            fail!("BadBad")
+        }
+    }
+
+    let ok: Result<int, &'static str> = Ok(100);
+    let ok_err: Result<int, &'static str> = Err("I got this.");
+
+    assert_eq!(ok.unwrap_or_else(handler), 100);
+    assert_eq!(ok_err.unwrap_or_else(handler), 50);
+}
+
+#[test]
+#[should_fail]
+pub fn test_unwrap_or_else_failure() {
+    fn handler(msg: &'static str) -> int {
+        if msg == "I got this." {
+            50i
+        } else {
+            fail!("BadBad")
+        }
+    }
+
+    let bad_err: Result<int, &'static str> = Err("Unrecoverable mess.");
+    let _ : int = bad_err.unwrap_or_else(handler);
+}
diff --git a/src/libcoretest/tuple.rs b/src/libcoretest/tuple.rs
new file mode 100644 (file)
index 0000000..be71e42
--- /dev/null
@@ -0,0 +1,92 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[test]
+fn test_clone() {
+    let a = (1i, "2");
+    let b = a.clone();
+    assert_eq!(a, b);
+}
+
+#[test]
+fn test_getters() {
+    macro_rules! test_getter(
+        ($x:expr, $valN:ident, $refN:ident, $mutN:ident,
+         $init:expr, $incr:expr, $result:expr) => ({
+            assert_eq!($x.$valN(), $init);
+            assert_eq!(*$x.$refN(), $init);
+            *$x.$mutN() += $incr;
+            assert_eq!(*$x.$refN(), $result);
+        })
+    )
+    let mut x = (0u8, 1u16, 2u32, 3u64, 4u, 5i8, 6i16, 7i32, 8i64, 9i, 10f32, 11f64);
+    test_getter!(x, val0,  ref0,  mut0,  0,    1,   1);
+    test_getter!(x, val1,  ref1,  mut1,  1,    1,   2);
+    test_getter!(x, val2,  ref2,  mut2,  2,    1,   3);
+    test_getter!(x, val3,  ref3,  mut3,  3,    1,   4);
+    test_getter!(x, val4,  ref4,  mut4,  4,    1,   5);
+    test_getter!(x, val5,  ref5,  mut5,  5,    1,   6);
+    test_getter!(x, val6,  ref6,  mut6,  6,    1,   7);
+    test_getter!(x, val7,  ref7,  mut7,  7,    1,   8);
+    test_getter!(x, val8,  ref8,  mut8,  8,    1,   9);
+    test_getter!(x, val9,  ref9,  mut9,  9,    1,   10);
+    test_getter!(x, val10, ref10, mut10, 10.0, 1.0, 11.0);
+    test_getter!(x, val11, ref11, mut11, 11.0, 1.0, 12.0);
+}
+
+#[test]
+fn test_tuple_cmp() {
+    let (small, big) = ((1u, 2u, 3u), (3u, 2u, 1u));
+
+    let nan = 0.0f64/0.0;
+
+    // PartialEq
+    assert_eq!(small, small);
+    assert_eq!(big, big);
+    assert!(small != big);
+    assert!(big != small);
+
+    // PartialOrd
+    assert!(small < big);
+    assert!(!(small < small));
+    assert!(!(big < small));
+    assert!(!(big < big));
+
+    assert!(small <= small);
+    assert!(big <= big);
+
+    assert!(big > small);
+    assert!(small >= small);
+    assert!(big >= small);
+    assert!(big >= big);
+
+    assert!(!((1.0f64, 2.0f64) < (nan, 3.0)));
+    assert!(!((1.0f64, 2.0f64) <= (nan, 3.0)));
+    assert!(!((1.0f64, 2.0f64) > (nan, 3.0)));
+    assert!(!((1.0f64, 2.0f64) >= (nan, 3.0)));
+    assert!(((1.0f64, 2.0f64) < (2.0, nan)));
+    assert!(!((2.0f64, 2.0f64) < (2.0, nan)));
+
+    // Ord
+    assert!(small.cmp(&small) == Equal);
+    assert!(big.cmp(&big) == Equal);
+    assert!(small.cmp(&big) == Less);
+    assert!(big.cmp(&small) == Greater);
+}
+
+#[test]
+fn test_show() {
+    let s = format!("{}", (1i,));
+    assert_eq!(s.as_slice(), "(1,)");
+    let s = format!("{}", (1i, true));
+    assert_eq!(s.as_slice(), "(1, true)");
+    let s = format!("{}", (1i, "hi", true));
+    assert_eq!(s.as_slice(), "(1, hi, true)");
+}
index 1494a2defe949934173aab69655ba387704a8449..133353ec3d717a09a9225a332d77ae0e5b61f55a 100644 (file)
@@ -588,22 +588,22 @@ fn exact_test<T>(t: &T, e:&str) {
         assert_eq!(s.as_slice(), e);
     }
 
-    exact_test(&10, "10");
+    exact_test(&10i, "10");
     exact_test(&true, "true");
     exact_test(&false, "false");
-    exact_test(&1.234, "1.234f64");
+    exact_test(&1.234f64, "1.234f64");
     exact_test(&("hello"), "\"hello\"");
 
-    exact_test(&(box(GC) 10), "box(GC) 10");
-    exact_test(&(box 10), "box 10");
-    exact_test(&(&10), "&10");
-    let mut x = 10;
+    exact_test(&(box(GC) 10i), "box(GC) 10");
+    exact_test(&(box 10i), "box 10");
+    exact_test(&(&10i), "&10");
+    let mut x = 10i;
     exact_test(&(&mut x), "&mut 10");
 
-    exact_test(&(0 as *const ()), "(0x0 as *const ())");
-    exact_test(&(0 as *mut ()), "(0x0 as *mut ())");
+    exact_test(&(0i as *const()), "(0x0 as *const ())");
+    exact_test(&(0i as *mut ()), "(0x0 as *mut ())");
 
-    exact_test(&(1,), "(1,)");
+    exact_test(&(1i,), "(1,)");
     exact_test(&(&["hi", "there"]),
                "&[\"hi\", \"there\"]");
     exact_test(&(P{a:10, b:1.234}),
@@ -613,8 +613,8 @@ fn exact_test<T>(t: &T, e:&str) {
     exact_test(&(box P{a:10, b:1.234}),
                "box repr::P{a: 10, b: 1.234f64}");
 
-    exact_test(&(&[1, 2]), "&[1, 2]");
-    exact_test(&(&mut [1, 2]), "&mut [1, 2]");
+    exact_test(&(&[1i, 2i]), "&[1, 2]");
+    exact_test(&(&mut [1i, 2i]), "&mut [1, 2]");
 
     exact_test(&'\'', "'\\''");
     exact_test(&'"', "'\"'");
index a34791f470eaf9473a1a8dc0dc0a92e7948c4489..bd19f19cec6b2f86a9a1beee94f87b60c3720eab 100644 (file)
@@ -8,8 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::collections::Collection;
+use std::default::Default;
 use std::fmt;
 use std::iter::FromIterator;
+use std::path::BytesContainer;
 use std::slice;
 
 // Note 1: It is not clear whether the flexibility of providing both
@@ -61,6 +64,32 @@ pub fn iter(&'a self) -> slice::Items<'a,T> {
     }
 }
 
+impl<'a, T: PartialEq> PartialEq for MaybeOwnedVector<'a, T> {
+    fn eq(&self, other: &MaybeOwnedVector<T>) -> bool {
+        self.as_slice() == other.as_slice()
+    }
+}
+
+impl<'a, T: Eq> Eq for MaybeOwnedVector<'a, T> {}
+
+impl<'a, T: PartialOrd> PartialOrd for MaybeOwnedVector<'a, T> {
+    fn partial_cmp(&self, other: &MaybeOwnedVector<T>) -> Option<Ordering> {
+        self.as_slice().partial_cmp(&other.as_slice())
+    }
+}
+
+impl<'a, T: Ord> Ord for MaybeOwnedVector<'a, T> {
+    fn cmp(&self, other: &MaybeOwnedVector<T>) -> Ordering {
+        self.as_slice().cmp(&other.as_slice())
+    }
+}
+
+impl<'a, T: PartialEq, V: Vector<T>> Equiv<V> for MaybeOwnedVector<'a, T> {
+    fn equiv(&self, other: &V) -> bool {
+        self.as_slice() == other.as_slice()
+    }
+}
+
 // The `Vector` trait is provided in the prelude and is implemented on
 // both `&'a [T]` and `Vec<T>`, so it makes sense to try to support it
 // seamlessly.  The other vector related traits from the prelude do
@@ -108,6 +137,34 @@ fn into_owned(self) -> Vec<T> {
     }
 }
 
+impl<'a, T: Clone> Clone for MaybeOwnedVector<'a, T> {
+    fn clone(&self) -> MaybeOwnedVector<'a, T> {
+        match *self {
+            Growable(ref v) => Growable(v.to_owned()),
+            Borrowed(v) => Borrowed(v)
+        }
+    }
+}
+
+
+impl<'a, T> Default for MaybeOwnedVector<'a, T> {
+    fn default() -> MaybeOwnedVector<'a, T> {
+        Growable(Vec::new())
+    }
+}
+
+impl<'a, T> Collection for MaybeOwnedVector<'a, T> {
+    fn len(&self) -> uint {
+        self.as_slice().len()
+    }
+}
+
+impl<'a> BytesContainer for MaybeOwnedVector<'a, u8> {
+    fn container_as_bytes<'a>(&'a self) -> &'a [u8] {
+        self.as_slice()
+    }
+}
+
 impl<'a,T:Clone> MaybeOwnedVector<'a,T> {
     /// Convert `self` into a growable `Vec`, not making a copy if possible.
     pub fn into_vec(self) -> Vec<T> {
index c5130a542fc8295978a93c7798330089d359b9d8..7603b0a8013c75d25ad7d3a15ae86c2c5bb580d1 100644 (file)
@@ -1413,7 +1413,7 @@ struct S { field: () }
 
             impl Drop for S {
                 fn drop(&mut self) {
-                    let _foo = box 0;
+                    let _foo = box 0i;
                 }
             }
 
index 351afc1c5d4e9145caa8ac9223327a352490383d..1b43f236e69b554b9ba877f98c393d1b617415f0 100644 (file)
@@ -77,12 +77,12 @@ fn hex_float_lit_err(s: &str) -> Option<(uint, String)> {
     if chars.next() != Some('x') {
         return Some((i, "Expected 'x'".to_string()));
     } i+=1;
-    let mut d_len = 0;
+    let mut d_len = 0i;
     for _ in chars.take_while(|c| c.is_digit_radix(16)) { chars.next(); i+=1; d_len += 1;}
     if chars.next() != Some('.') {
         return Some((i, "Expected '.'".to_string()));
     } i+=1;
-    let mut f_len = 0;
+    let mut f_len = 0i;
     for _ in chars.take_while(|c| c.is_digit_radix(16)) { chars.next(); i+=1; f_len += 1;}
     if d_len == 0 && f_len == 0 {
         return Some((i, "Expected digits before or after decimal \
@@ -92,7 +92,7 @@ fn hex_float_lit_err(s: &str) -> Option<(uint, String)> {
         return Some((i, "Expected 'p'".to_string()));
     } i+=1;
     if chars.peek() == Some(&'-') { chars.next(); i+= 1 }
-    let mut e_len = 0;
+    let mut e_len = 0i;
     for _ in chars.take_while(|c| c.is_digit()) { chars.next(); i+=1; e_len += 1}
     if e_len == 0 {
         return Some((i, "Expected exponent digits".to_string()));
index 8c3cdf4e9ecaf53859c40b6c65db8d91715202a5..0977b55d8b9780d437f385fb473e1ecf49997943 100644 (file)
@@ -50,8 +50,8 @@ pub fn run(host: Option<&str>, servname: Option<&str>,
 
         // Make the call
         let s = unsafe {
-            let ch = if c_host.is_null() { null() } else { c_host.with_ref(|x| x) };
-            let cs = if c_serv.is_null() { null() } else { c_serv.with_ref(|x| x) };
+            let ch = if c_host.is_null() { null() } else { c_host.as_ptr() };
+            let cs = if c_serv.is_null() { null() } else { c_serv.as_ptr() };
             getaddrinfo(ch, cs, hint_ptr, &mut res)
         };
 
index 7e58102d2418399b9d314242be84edcfc1d9e332..802526c91969524a9cfd4023466b7fce9f93aa72 100644 (file)
@@ -70,6 +70,7 @@ pub fn CancelIoEx(hFile: libc::HANDLE,
 
 pub mod compat {
     use std::intrinsics::{atomic_store_relaxed, transmute};
+    use std::iter::Iterator;
     use libc::types::os::arch::extra::{LPCWSTR, HMODULE, LPCSTR, LPVOID};
 
     extern "system" {
@@ -82,7 +83,8 @@ pub mod compat {
     // layer (after it's loaded) shouldn't be any slower than a regular DLL
     // call.
     unsafe fn store_func(ptr: *mut uint, module: &str, symbol: &str, fallback: uint) {
-        let module = module.to_utf16().append_one(0);
+        let module: Vec<u16> = module.utf16_units().collect();
+        let module = module.append_one(0);
         symbol.with_c_str(|symbol| {
             let handle = GetModuleHandleW(module.as_ptr());
             let func: uint = transmute(GetProcAddress(handle, symbol));
index 72dad27c6e761f9a8b74ddaea6d3b93124258f5c..ddcff2be5f340c02eb8f43bc7aca910136c92bda 100644 (file)
@@ -339,7 +339,7 @@ pub fn open(path: &CString, fm: rtio::FileMode, fa: rtio::FileAccess)
                             libc::S_IRUSR | libc::S_IWUSR),
     };
 
-    match retry(|| unsafe { libc::open(path.with_ref(|p| p), flags, mode) }) {
+    match retry(|| unsafe { libc::open(path.as_ptr(), flags, mode) }) {
         -1 => Err(super::last_error()),
         fd => Ok(FileDesc::new(fd, true)),
     }
@@ -347,7 +347,7 @@ pub fn open(path: &CString, fm: rtio::FileMode, fa: rtio::FileAccess)
 
 pub fn mkdir(p: &CString, mode: uint) -> IoResult<()> {
     super::mkerr_libc(retry(|| unsafe {
-        libc::mkdir(p.with_ref(|p| p), mode as libc::mode_t)
+        libc::mkdir(p.as_ptr(), mode as libc::mode_t)
     }))
 }
 
@@ -356,7 +356,7 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
     use libc::{opendir, readdir_r, closedir};
 
     fn prune(root: &CString, dirs: Vec<Path>) -> Vec<CString> {
-        let root = unsafe { CString::new(root.with_ref(|p| p), false) };
+        let root = unsafe { CString::new(root.as_ptr(), false) };
         let root = Path::new(root);
 
         dirs.move_iter().filter(|path| {
@@ -373,7 +373,7 @@ fn prune(root: &CString, dirs: Vec<Path>) -> Vec<CString> {
     let mut buf = Vec::<u8>::with_capacity(size as uint);
     let ptr = buf.as_mut_slice().as_mut_ptr() as *mut dirent_t;
 
-    let dir_ptr = p.with_ref(|buf| unsafe { opendir(buf) });
+    let dir_ptr = unsafe {opendir(p.as_ptr())};
 
     if dir_ptr as uint != 0 {
         let mut paths = vec!();
@@ -393,36 +393,36 @@ fn prune(root: &CString, dirs: Vec<Path>) -> Vec<CString> {
 }
 
 pub fn unlink(p: &CString) -> IoResult<()> {
-    super::mkerr_libc(retry(|| unsafe { libc::unlink(p.with_ref(|p| p)) }))
+    super::mkerr_libc(retry(|| unsafe { libc::unlink(p.as_ptr()) }))
 }
 
 pub fn rename(old: &CString, new: &CString) -> IoResult<()> {
     super::mkerr_libc(retry(|| unsafe {
-        libc::rename(old.with_ref(|p| p), new.with_ref(|p| p))
+        libc::rename(old.as_ptr(), new.as_ptr())
     }))
 }
 
 pub fn chmod(p: &CString, mode: uint) -> IoResult<()> {
     super::mkerr_libc(retry(|| unsafe {
-        libc::chmod(p.with_ref(|p| p), mode as libc::mode_t)
+        libc::chmod(p.as_ptr(), mode as libc::mode_t)
     }))
 }
 
 pub fn rmdir(p: &CString) -> IoResult<()> {
     super::mkerr_libc(retry(|| unsafe {
-        libc::rmdir(p.with_ref(|p| p))
+        libc::rmdir(p.as_ptr())
     }))
 }
 
 pub fn chown(p: &CString, uid: int, gid: int) -> IoResult<()> {
     super::mkerr_libc(retry(|| unsafe {
-        libc::chown(p.with_ref(|p| p), uid as libc::uid_t,
+        libc::chown(p.as_ptr(), uid as libc::uid_t,
                     gid as libc::gid_t)
     }))
 }
 
 pub fn readlink(p: &CString) -> IoResult<CString> {
-    let p = p.with_ref(|p| p);
+    let p = p.as_ptr();
     let mut len = unsafe { libc::pathconf(p as *mut _, libc::_PC_NAME_MAX) };
     if len == -1 {
         len = 1024; // FIXME: read PATH_MAX from C ffi?
@@ -443,13 +443,13 @@ pub fn readlink(p: &CString) -> IoResult<CString> {
 
 pub fn symlink(src: &CString, dst: &CString) -> IoResult<()> {
     super::mkerr_libc(retry(|| unsafe {
-        libc::symlink(src.with_ref(|p| p), dst.with_ref(|p| p))
+        libc::symlink(src.as_ptr(), dst.as_ptr())
     }))
 }
 
 pub fn link(src: &CString, dst: &CString) -> IoResult<()> {
     super::mkerr_libc(retry(|| unsafe {
-        libc::link(src.with_ref(|p| p), dst.with_ref(|p| p))
+        libc::link(src.as_ptr(), dst.as_ptr())
     }))
 }
 
@@ -489,7 +489,7 @@ fn gen(_stat: &libc::stat) -> u64 { 0 }
 
 pub fn stat(p: &CString) -> IoResult<rtio::FileStat> {
     let mut stat: libc::stat = unsafe { mem::zeroed() };
-    match retry(|| unsafe { libc::stat(p.with_ref(|p| p), &mut stat) }) {
+    match retry(|| unsafe { libc::stat(p.as_ptr(), &mut stat) }) {
         0 => Ok(mkstat(&stat)),
         _ => Err(super::last_error()),
     }
@@ -497,7 +497,7 @@ pub fn stat(p: &CString) -> IoResult<rtio::FileStat> {
 
 pub fn lstat(p: &CString) -> IoResult<rtio::FileStat> {
     let mut stat: libc::stat = unsafe { mem::zeroed() };
-    match retry(|| unsafe { libc::lstat(p.with_ref(|p| p), &mut stat) }) {
+    match retry(|| unsafe { libc::lstat(p.as_ptr(), &mut stat) }) {
         0 => Ok(mkstat(&stat)),
         _ => Err(super::last_error()),
     }
@@ -509,7 +509,7 @@ pub fn utime(p: &CString, atime: u64, mtime: u64) -> IoResult<()> {
         modtime: (mtime / 1000) as libc::time_t,
     };
     super::mkerr_libc(retry(|| unsafe {
-        libc::utime(p.with_ref(|p| p), &buf)
+        libc::utime(p.as_ptr(), &buf)
     }))
 }
 
index cdbf762f87d528ba8ad4de9d266ff2845533866b..98553603313404382aafa07a63d726c28ef9b1a6 100644 (file)
@@ -255,7 +255,7 @@ fn drop(&mut self) {
 
 pub fn to_utf16(s: &CString) -> IoResult<Vec<u16>> {
     match s.as_str() {
-        Some(s) => Ok(s.to_utf16().append_one(0)),
+        Some(s) => Ok(s.utf16_units().collect::<Vec<u16>>().append_one(0)),
         None => Err(IoError {
             code: libc::ERROR_INVALID_NAME as uint,
             extra: 0,
@@ -347,7 +347,7 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
     use std::rt::libc_heap::malloc_raw;
 
     fn prune(root: &CString, dirs: Vec<Path>) -> Vec<CString> {
-        let root = unsafe { CString::new(root.with_ref(|p| p), false) };
+        let root = unsafe { CString::new(root.as_ptr(), false) };
         let root = Path::new(root);
 
         dirs.move_iter().filter(|path| {
@@ -360,7 +360,7 @@ fn prune(root: &CString, dirs: Vec<Path>) -> Vec<CString> {
         fn rust_list_dir_wfd_fp_buf(wfd: *mut libc::c_void) -> *const u16;
     }
     let star = Path::new(unsafe {
-        CString::new(p.with_ref(|p| p), false)
+        CString::new(p.as_ptr(), false)
     }).join("*");
     let path = try!(to_utf16(&star.to_c_str()));
 
index ae08d0ea0a9b75ab447a498aa81a8c7024a58338..b5b2065f996ed29d079807a1454c3f86f2763269 100644 (file)
@@ -278,7 +278,7 @@ fn drop(&mut self) {
         // careful to unlink the path before we close the file descriptor to
         // prevent races where we unlink someone else's path.
         unsafe {
-            let _ = libc::unlink(self.path.with_ref(|p| p));
+            let _ = libc::unlink(self.path.as_ptr());
         }
     }
 }
index 7f4c52585f2a4749ec800022739d7b77144aded8..6fab73115cf9a5e2dcd1ddf7847f2796b4f44e4d 100644 (file)
@@ -294,6 +294,8 @@ fn spawn_process_os(cfg: ProcessConfig,
     use libc::funcs::extra::msvcrt::get_osfhandle;
 
     use std::mem;
+    use std::iter::Iterator;
+    use std::str::StrSlice;
 
     if cfg.gid.is_some() || cfg.uid.is_some() {
         return Err(IoError {
@@ -328,7 +330,8 @@ fn spawn_process_os(cfg: ProcessConfig,
                         lpSecurityDescriptor: ptr::mut_null(),
                         bInheritHandle: 1,
                     };
-                    let filename = "NUL".to_utf16().append_one(0);
+                    let filename: Vec<u16> = "NUL".utf16_units().collect();
+                    let filename = filename.append_one(0);
                     *slot = libc::CreateFileW(filename.as_ptr(),
                                               access,
                                               libc::FILE_SHARE_READ |
@@ -371,7 +374,8 @@ fn spawn_process_os(cfg: ProcessConfig,
 
         with_envp(cfg.env, |envp| {
             with_dirp(cfg.cwd, |dirp| {
-                let mut cmd_str = cmd_str.to_utf16().append_one(0);
+                let mut cmd_str: Vec<u16> = cmd_str.as_slice().utf16_units().collect();
+                cmd_str = cmd_str.append_one(0);
                 let created = CreateProcessW(ptr::null(),
                                              cmd_str.as_mut_ptr(),
                                              ptr::mut_null(),
@@ -531,7 +535,7 @@ unsafe fn set_cloexec(fd: c_int) {
         assert_eq!(ret, 0);
     }
 
-    let dirp = cfg.cwd.map(|c| c.with_ref(|p| p)).unwrap_or(ptr::null());
+    let dirp = cfg.cwd.map(|c| c.as_ptr()).unwrap_or(ptr::null());
 
     let cfg = unsafe {
         mem::transmute::<ProcessConfig,ProcessConfig<'static>>(cfg)
@@ -633,7 +637,7 @@ fn fail(output: &mut file::FileDesc) -> ! {
                         } else {
                             libc::O_RDWR
                         };
-                        devnull.with_ref(|p| libc::open(p, flags, 0))
+                        libc::open(devnull.as_ptr(), flags, 0)
                     }
                     Some(obj) => {
                         let fd = obj.fd();
@@ -715,8 +719,8 @@ fn with_argv<T>(prog: &CString, args: &[CString],
     // larger than the lifetime of our invocation of cb, but this is
     // technically unsafe as the callback could leak these pointers
     // out of our scope.
-    ptrs.push(prog.with_ref(|buf| buf));
-    ptrs.extend(args.iter().map(|tmp| tmp.with_ref(|buf| buf)));
+    ptrs.push(prog.as_ptr());
+    ptrs.extend(args.iter().map(|tmp| tmp.as_ptr()));
 
     // Add a terminating null pointer (required by libc).
     ptrs.push(ptr::null());
@@ -770,7 +774,7 @@ fn with_envp<T>(env: Option<&[(CString, CString)]>, cb: |*mut c_void| -> T) -> T
                 let kv = format!("{}={}",
                                  pair.ref0().as_str().unwrap(),
                                  pair.ref1().as_str().unwrap());
-                blk.push_all(kv.to_utf16().as_slice());
+                blk.extend(kv.as_slice().utf16_units());
                 blk.push(0);
             }
 
@@ -788,7 +792,9 @@ fn with_dirp<T>(d: Option<&CString>, cb: |*const u16| -> T) -> T {
       Some(dir) => {
           let dir_str = dir.as_str()
                            .expect("expected workingdirectory to be utf-8 encoded");
-          let dir_str = dir_str.to_utf16().append_one(0);
+          let dir_str: Vec<u16> = dir_str.utf16_units().collect();
+          let dir_str = dir_str.append_one(0);
+
           cb(dir_str.as_ptr())
       },
       None => cb(ptr::null())
@@ -1136,7 +1142,7 @@ fn drain(fd: libc::c_int) -> bool {
     // which will wake up the other end at some point, so we just allow this
     // signal to be coalesced with the pending signals on the pipe.
     extern fn sigchld_handler(_signum: libc::c_int) {
-        let msg = 1;
+        let msg = 1i;
         match unsafe {
             libc::write(WRITE_FD, &msg as *const _ as *const libc::c_void, 1)
         } {
index 06e4792cdcccfdabb1bd8f80462d2bdfdf7fb85d..cc3753def59f4cc2a6ed98d1080f4a36fc33ae28 100644 (file)
@@ -91,8 +91,8 @@ impl Eq for BigUint {}
 
 impl PartialOrd for BigUint {
     #[inline]
-    fn lt(&self, other: &BigUint) -> bool {
-        self.cmp(other) == Less
+    fn partial_cmp(&self, other: &BigUint) -> Option<Ordering> {
+        Some(self.cmp(other))
     }
 }
 
@@ -215,7 +215,7 @@ fn sub(&self, other: &BigUint) -> BigUint {
         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 mut borrow = 0i;
         let diff: Vec<BigDigit> =  a.take(new_len).zip(b).map(|(ai, bi)| {
             let (hi, lo) = BigDigit::from_doublebigdigit(
                 BigDigit::base
@@ -816,8 +816,8 @@ impl Eq for BigInt {}
 
 impl PartialOrd for BigInt {
     #[inline]
-    fn lt(&self, other: &BigInt) -> bool {
-        self.cmp(other) == Less
+    fn partial_cmp(&self, other: &BigInt) -> Option<Ordering> {
+        Some(self.cmp(other))
     }
 }
 
index 971b6b1b51b2dbecac6b5bd7ca4ec49052bcadc5..9a455edf2c086e8d034b5c178847fda15b556ae5 100644 (file)
@@ -193,7 +193,8 @@ fn $method(&self, other: &Ratio<T>) -> $res {
     };
 }
 cmp_impl!(impl PartialEq, eq, ne)
-cmp_impl!(impl PartialOrd, lt, gt, le, ge)
+cmp_impl!(impl PartialOrd, lt -> bool, gt -> bool, le -> bool, ge -> bool,
+          partial_cmp -> Option<cmp::Ordering>)
 cmp_impl!(impl Eq, )
 cmp_impl!(impl Ord, cmp -> cmp::Ordering)
 
index 6caa936636a710528017b09d81a4ab008fb3c3a5..134e7af507010db11a2f0980e1951c8b73dd2ab3 100644 (file)
@@ -389,10 +389,10 @@ macro_rules! rngstepn(
                             }
                         }}
                     );
-                rngstepp!(0, 21);
-                rngstepn!(1, 5);
-                rngstepp!(2, 12);
-                rngstepn!(3, 33);
+                rngstepp!(0u, 21);
+                rngstepn!(1u, 5);
+                rngstepp!(2u, 12);
+                rngstepn!(3u, 33);
             }
         }
 
index 769b23a7e7bf9ea1254bb581d71b421345d993db..ae1a10f620663c3edcc6d9187bf17bf338cdd127 100644 (file)
@@ -111,7 +111,7 @@ fn fill_bytes(&mut self, dest: &mut [u8]) {
         // (3) adds more `unsafe` that needs to be checked, (4)
         // probably doesn't give much performance gain if
         // optimisations are on.
-        let mut count = 0;
+        let mut count = 0i;
         let mut num = 0;
         for byte in dest.mut_iter() {
             if count == 0 {
index 3dd054cee9d1e6b8f9f25c598f4f4a966fdfa45a..77433877ec6687c8729cd684821a6c49bd3d1ffa 100644 (file)
@@ -203,6 +203,8 @@ fn rand<R: Rng>(_: &mut R) -> () { () }
 tuple_impl!{A, B, C, D, E, F, G, H}
 tuple_impl!{A, B, C, D, E, F, G, H, I}
 tuple_impl!{A, B, C, D, E, F, G, H, I, J}
+tuple_impl!{A, B, C, D, E, F, G, H, I, J, K}
+tuple_impl!{A, B, C, D, E, F, G, H, I, J, K, L}
 
 impl<T:Rand> Rand for Option<T> {
     #[inline]
index 2fea75746be732cd4b81620102e2610dc07b4dd2..9cde40c196088648f3192bb11e7f603481b900ca 100644 (file)
@@ -770,7 +770,7 @@ fn parse_group_opts(&mut self) -> Result<(), Error> {
         }
         let start = self.chari;
         let mut flags = self.flags;
-        let mut sign = 1;
+        let mut sign = 1i;
         let mut saw_flag = false;
         loop {
             try!(self.noteof("expected non-empty set of flags or closing ')'"))
index 42e699fb6919b1680ea3f5ecf27ce06d1163da69..b4af291b7eae67ae4275bf7fba70449fb6decde7 100644 (file)
@@ -412,7 +412,7 @@ unsafe fn configure_llvm(sess: &Session) {
         {
             let add = |arg: &str| {
                 let s = arg.to_c_str();
-                llvm_args.push(s.with_ref(|p| p));
+                llvm_args.push(s.as_ptr());
                 llvm_c_strs.push(s);
             };
             add("rustc"); // fake program name
index 69cc52d68b30b3172a0ffea3d870d5faf7dde49d..b9ae9530f8e1c3291aa4a15be0393484b844b0e5 100644 (file)
@@ -94,7 +94,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
     // Internalize everything but the reachable symbols of the current module
     let cstrs: Vec<::std::c_str::CString> =
         reachable.iter().map(|s| s.as_slice().to_c_str()).collect();
-    let arr: Vec<*const i8> = cstrs.iter().map(|c| c.with_ref(|p| p)).collect();
+    let arr: Vec<*const i8> = cstrs.iter().map(|c| c.as_ptr()).collect();
     let ptr = arr.as_ptr();
     unsafe {
         llvm::LLVMRustRunRestrictionPass(llmod,
index 339db67b3f1a1db8eee9ae655f9ed1012184ef4b..b562d48f49d32ce7eb93b9a3ce010f962b8c3a0d 100644 (file)
@@ -391,8 +391,8 @@ fn check_foreign_fn(cx: &Context, decl: &ast::FnDecl) {
 
 impl HeapMemory {
     fn check_heap_type(&self, cx: &Context, span: Span, ty: ty::t) {
-        let mut n_box = 0;
-        let mut n_uniq = 0;
+        let mut n_box = 0i;
+        let mut n_uniq = 0i;
         ty::fold_ty(cx.tcx, ty, |t| {
             match ty::get(t).sty {
                 ty::ty_box(_) => {
index e646827fa23ddc7c6ba4f39ce309e0a9d601ae60..57006d5e72b9b632b60e469c1f65ab0af8c16cdf 100644 (file)
@@ -90,7 +90,7 @@ pub fn span_for_last_ident(&self, span: Span) -> Option<Span> {
         let mut result = None;
 
         let mut toks = self.retokenise_span(span);
-        let mut bracket_count = 0;
+        let mut bracket_count = 0u;
         loop {
             let ts = toks.next_token();
             if ts.tok == token::EOF {
@@ -113,7 +113,7 @@ pub fn span_for_last_ident(&self, span: Span) -> Option<Span> {
     // Return the span for the first identifier in the path.
     pub fn span_for_first_ident(&self, span: Span) -> Option<Span> {
         let mut toks = self.retokenise_span(span);
-        let mut bracket_count = 0;
+        let mut bracket_count = 0u;
         loop {
             let ts = toks.next_token();
             if ts.tok == token::EOF {
@@ -139,7 +139,7 @@ pub fn sub_span_for_meth_name(&self, span: Span) -> Option<Span> {
         let mut toks = self.retokenise_span(span);
         let mut prev = toks.next_token();
         let mut result = None;
-        let mut bracket_count = 0;
+        let mut bracket_count = 0u;
         let mut last_span = None;
         while prev.tok != token::EOF {
             last_span = None;
@@ -187,7 +187,7 @@ pub fn sub_span_for_type_name(&self, span: Span) -> Option<Span> {
         let mut toks = self.retokenise_span(span);
         let mut prev = toks.next_token();
         let mut result = None;
-        let mut bracket_count = 0;
+        let mut bracket_count = 0u;
         loop {
             let next = toks.next_token();
 
@@ -232,7 +232,7 @@ pub fn spans_with_brackets(&self, span: Span, nesting: int, limit: int) -> Vec<S
 
         let mut toks = self.retokenise_span(span);
         // We keep track of how many brackets we're nested in
-        let mut bracket_count = 0;
+        let mut bracket_count = 0i;
         loop {
             let ts = toks.next_token();
             if ts.tok == token::EOF {
@@ -291,7 +291,7 @@ pub fn sub_spans_before_tokens(&self,
         let mut next = toks.next_token();
         let mut stored_val = false;
         let mut found_val = false;
-        let mut bracket_count = 0;
+        let mut bracket_count = 0u;
         while next.tok != token::EOF {
             if bracket_count == 1 {
                 if next.tok == tok2 {
index 65f272072c0976611288330da63503de7979394c..400babb39f82cc12b8dee9be88cee6794947de08 100644 (file)
@@ -1433,24 +1433,23 @@ fn compile_unit_metadata(cx: &CrateContext) {
     let producer = format!("rustc version {}",
                            (option_env!("CFG_VERSION")).expect("CFG_VERSION"));
 
-    compile_unit_name.with_ref(|compile_unit_name| {
-        work_dir.as_vec().with_c_str(|work_dir| {
-            producer.with_c_str(|producer| {
-                "".with_c_str(|flags| {
-                    "".with_c_str(|split_name| {
-                        unsafe {
-                            llvm::LLVMDIBuilderCreateCompileUnit(
-                                debug_context(cx).builder,
-                                DW_LANG_RUST,
-                                compile_unit_name,
-                                work_dir,
-                                producer,
-                                cx.sess().opts.optimize != config::No,
-                                flags,
-                                0,
-                                split_name);
-                        }
-                    })
+    let compile_unit_name = compile_unit_name.as_ptr();
+    work_dir.as_vec().with_c_str(|work_dir| {
+        producer.with_c_str(|producer| {
+            "".with_c_str(|flags| {
+                "".with_c_str(|split_name| {
+                    unsafe {
+                        llvm::LLVMDIBuilderCreateCompileUnit(
+                            debug_context(cx).builder,
+                            DW_LANG_RUST,
+                            compile_unit_name,
+                            work_dir,
+                            producer,
+                            cx.sess().opts.optimize != config::No,
+                            flags,
+                            0,
+                            split_name);
+                    }
                 })
             })
         })
index fcd6c7e293ea26994f3fb183a9b54dcbd65d1612..488dc6d99e35c7a0d6063d816250a778ccaab540 100644 (file)
@@ -957,7 +957,11 @@ pub fn lltype_for_foreign_fn(ccx: &CrateContext, ty: ty::t) -> Type {
 
 fn add_argument_attributes(tys: &ForeignTypes,
                            llfn: ValueRef) {
-    let mut i = if tys.fn_ty.ret_ty.is_indirect() { 1 } else { 0 };
+    let mut i = if tys.fn_ty.ret_ty.is_indirect() {
+        1i
+    } else {
+        0i
+    };
 
     match tys.fn_ty.ret_ty.attr {
         Some(attr) => unsafe {
index 67437da44c5d612d4ab6e76318e9bae24f48a9b1..60ce9508dc46b3422eb7dc34e4c5def15d0b4297 100644 (file)
@@ -318,6 +318,9 @@ pub fn check_struct_pat_fields(pcx: &pat_ctxt,
     for field in fields.iter() {
         match field_map.find_mut(&field.ident.name) {
             Some(&(_, true)) => {
+                // Check the pattern anyway, so that attempts to look
+                // up its type won't fail
+                check_pat(pcx, &*field.pat, ty::mk_err());
                 tcx.sess.span_err(span,
                     format!("field `{}` bound twice in pattern",
                             token::get_ident(field.ident)).as_slice());
index bb20c3ce0b4aabbe646e69a4409c74b2cf71a58f..d808120db99ba8cad928fc1c117fe373db489580 100644 (file)
@@ -3805,7 +3805,15 @@ fn do_check(ccx: &CrateCtxt,
 
                     let inh = blank_inherited_fields(ccx);
                     let fcx = blank_fn_ctxt(ccx, &inh, rty, e.id);
-                    let declty = ty::mk_int_var(ccx.tcx, fcx.infcx().next_int_var_id());
+                    let declty = match hint {
+                        attr::ReprAny | attr::ReprExtern => ty::mk_int(),
+                        attr::ReprInt(_, attr::SignedInt(ity)) => {
+                            ty::mk_mach_int(ity)
+                        }
+                        attr::ReprInt(_, attr::UnsignedInt(ity)) => {
+                            ty::mk_mach_uint(ity)
+                        }
+                    };
                     check_const_with_ty(&fcx, e.span, &*e, declty);
                     // check_expr (from check_const pass) doesn't guarantee
                     // that the expression is in a form that eval_const_expr can
index 197a2370eff9e9d4b5cbe852f39f2e62bdda0559..bc02297b5b1f3cd27d89a55b4fb4890ab96cf9c7 100644 (file)
@@ -247,9 +247,13 @@ pub enum fixup_err {
 
 pub fn fixup_err_to_str(f: fixup_err) -> String {
     match f {
-      unresolved_int_ty(_) => "unconstrained integral type".to_string(),
+      unresolved_int_ty(_) => {
+          "cannot determine the type of this integer; add a suffix to \
+           specify the type explicitly".to_string()
+      }
       unresolved_float_ty(_) => {
-          "unconstrained floating point type".to_string()
+          "cannot determine the type of this number; add a suffix to specify \
+           the type explicitly".to_string()
       }
       unresolved_ty(_) => "unconstrained type".to_string(),
       cyclic_ty(_) => "cyclic type of infinite size".to_string(),
index ed6ea6c96775ebc571ee880845f0daed8e94ee17..adfbe9de2d5bf8b72769c6784a879a16dd64b702 100644 (file)
 use middle::ty;
 use middle::ty_fold;
 use middle::typeck::infer::{Bounds, cyclic_ty, fixup_err, fres, InferCtxt};
-use middle::typeck::infer::unresolved_ty;
-use middle::typeck::infer::unify::Root;
+use middle::typeck::infer::{unresolved_float_ty, unresolved_int_ty};
+use middle::typeck::infer::{unresolved_ty};
 use syntax::codemap::Span;
 use util::common::indent;
 use util::ppaux::{Repr, ty_to_str};
 
-use syntax::ast;
-
 pub static resolve_nested_tvar: uint = 0b0000000001;
 pub static resolve_rvar: uint        = 0b0000000010;
 pub static resolve_ivar: uint        = 0b0000000100;
@@ -83,21 +81,18 @@ pub struct ResolveState<'a> {
     err: Option<fixup_err>,
     v_seen: Vec<TyVid> ,
     type_depth: uint,
-    span: Option<Span>,
 }
 
 pub fn resolver<'a>(infcx: &'a InferCtxt,
                     modes: uint,
-                    span: Option<Span>)
-                    -> ResolveState<'a>
-{
+                    _: Option<Span>)
+                    -> ResolveState<'a> {
     ResolveState {
         infcx: infcx,
         modes: modes,
         err: None,
         v_seen: Vec::new(),
         type_depth: 0,
-        span: span
     }
 }
 
@@ -258,24 +253,10 @@ pub fn resolve_int_var(&mut self, vid: IntVid) -> ty::t {
           Some(UintType(t)) => ty::mk_mach_uint(t),
           None => {
             if self.should(force_ivar) {
-                // As a last resort, default to int and emit an error.
-                let ty = ty::mk_int();
-                table.borrow_mut().set(
-                    tcx, node.key, Root(Some(IntType(ast::TyI)), node.rank));
-
-                match self.span {
-                    Some(sp) => {
-                        self.infcx.tcx.sess.span_err(
-                            sp,
-                            "cannot determine the type of this integer; add \
-                             a suffix to specify the type explicitly");
-                    }
-                    None => { }
-                }
-                ty
-            } else {
-                ty::mk_int_var(self.infcx.tcx, vid)
+                // As a last resort, emit an error.
+                self.err = Some(unresolved_int_ty(vid));
             }
+            ty::mk_int_var(self.infcx.tcx, vid)
           }
         }
     }
@@ -292,24 +273,10 @@ pub fn resolve_float_var(&mut self, vid: FloatVid) -> ty::t {
           Some(t) => ty::mk_mach_float(t),
           None => {
             if self.should(force_fvar) {
-                // As a last resort, default to f64 and emit an error.
-                let ty = ty::mk_f64();
-                table.borrow_mut().set(
-                    tcx, node.key, Root(Some(ast::TyF64), node.rank));
-
-                match self.span {
-                    Some(sp) => {
-                        self.infcx.tcx.sess.span_err(
-                            sp,
-                            "cannot determine the type of this number; add \
-                             a suffix to specify the type explicitly");
-                    }
-                    None => { }
-                }
-                ty
-            } else {
-                ty::mk_float_var(self.infcx.tcx, vid)
+                // As a last resort, emit an error.
+                self.err = Some(unresolved_float_ty(vid));
             }
+            ty::mk_float_var(self.infcx.tcx, vid)
           }
         }
     }
diff --git a/src/librustdoc/externalfiles.rs b/src/librustdoc/externalfiles.rs
new file mode 100644 (file)
index 0000000..0931f13
--- /dev/null
@@ -0,0 +1,70 @@
+// 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::{io, str};
+
+#[deriving(Clone)]
+pub struct ExternalHtml{
+    pub in_header: String,
+    pub before_content: String,
+    pub after_content: String
+}
+
+impl ExternalHtml {
+    pub fn load(in_header: &[String], before_content: &[String], after_content: &[String])
+            -> Option<ExternalHtml> {
+        match (load_external_files(in_header),
+               load_external_files(before_content),
+               load_external_files(after_content)) {
+            (Some(ih), Some(bc), Some(ac)) => Some(ExternalHtml {
+                in_header: ih,
+                before_content: bc,
+                after_content: ac
+            }),
+            _ => None
+        }
+    }
+}
+
+pub fn load_string(input: &Path) -> io::IoResult<Option<String>> {
+    let mut f = try!(io::File::open(input));
+    let d = try!(f.read_to_end());
+    Ok(str::from_utf8(d.as_slice()).map(|s| s.to_string()))
+}
+
+macro_rules! load_or_return {
+    ($input: expr, $cant_read: expr, $not_utf8: expr) => {
+        {
+            let input = Path::new($input);
+            match ::externalfiles::load_string(&input) {
+                Err(e) => {
+                    let _ = writeln!(&mut io::stderr(),
+                                     "error reading `{}`: {}", input.display(), e);
+                    return $cant_read;
+                }
+                Ok(None) => {
+                    let _ = writeln!(&mut io::stderr(),
+                                     "error reading `{}`: not UTF-8", input.display());
+                    return $not_utf8;
+                }
+                Ok(Some(s)) => s
+            }
+        }
+    }
+}
+
+pub fn load_external_files(names: &[String]) -> Option<String> {
+    let mut out = String::new();
+    for name in names.iter() {
+        out.push_str(load_or_return!(name.as_slice(), None, None).as_slice());
+        out.push_char('\n');
+    }
+    Some(out)
+}
index cb2ebd15b3970ffc21733dc3672571bd1d479ba1..f07c016367634919387f6794fed522fd6a7673f9 100644 (file)
@@ -162,7 +162,8 @@ pub struct Lock {
 
     impl Lock {
         pub fn new(p: &Path) -> Lock {
-            let p_16 = p.as_str().unwrap().to_utf16().append_one(0);
+            let p_16: Vec<u16> = p.as_str().unwrap().utf16_units().collect();
+            let p_16 = p_16.append_one(0);
             let handle = unsafe {
                 libc::CreateFileW(p_16.as_ptr(),
                                   libc::FILE_GENERIC_READ |
index 1173f6eb5b8b49b8946f90ddee885f6e63e9748c..fa18b6291be74140dce46cf3e5eba7f419fbc678 100644 (file)
@@ -185,7 +185,7 @@ fn path(w: &mut fmt::Formatter, path: &clean::Path, print_all: bool,
     let mut generics = String::new();
     let last = path.segments.last().unwrap();
     if last.lifetimes.len() > 0 || last.types.len() > 0 {
-        let mut counter = 0;
+        let mut counter = 0u;
         generics.push_str("&lt;");
         for lifetime in last.lifetimes.iter() {
             if counter > 0 { generics.push_str(", "); }
index 61a2d3c5d9cc890d0a17e95ee3f7d2a8e2c0719f..aa298d07780bfe341da75be01175462e3ba40542 100644 (file)
 use std::fmt;
 use std::io;
 
+use externalfiles::ExternalHtml;
+
 #[deriving(Clone)]
 pub struct Layout {
     pub logo: String,
     pub favicon: String,
+    pub external_html: ExternalHtml,
     pub krate: String,
     pub playground_url: String,
 }
@@ -44,6 +47,7 @@ pub fn render<T: fmt::Show, S: fmt::Show>(
     <link rel="stylesheet" type="text/css" href="{root_path}main.css">
 
     {favicon}
+    {in_header}
 </head>
 <body>
     <!--[if lte IE 8]>
@@ -53,6 +57,8 @@ pub fn render<T: fmt::Show, S: fmt::Show>(
     </div>
     <![endif]-->
 
+    {before_content}
+
     <section class="sidebar">
         {logo}
         {sidebar}
@@ -105,6 +111,8 @@ pub fn render<T: fmt::Show, S: fmt::Show>(
         </div>
     </div>
 
+    {after_content}
+
     <script>
         window.rootPath = "{root_path}";
         window.currentCrate = "{krate}";
@@ -133,6 +141,9 @@ pub fn render<T: fmt::Show, S: fmt::Show>(
     } else {
         format!(r#"<link rel="shortcut icon" href="{}">"#, layout.favicon)
     },
+    in_header = layout.external_html.in_header,
+    before_content = layout.external_html.before_content,
+    after_content = layout.external_html.after_content,
     sidebar   = *sidebar,
     krate     = layout.krate,
     play_url  = layout.playground_url,
index 949936603e2b7566f067b2da0cf07705edd34c18..de4bbeb6e30c8a6439c31d1f46424392796f15cf 100644 (file)
@@ -206,9 +206,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
                     s.push_str(highlight::highlight(text.as_slice(), None, id)
                                          .as_slice());
                     let output = s.to_c_str();
-                    output.with_ref(|r| {
-                        hoedown_buffer_puts(ob, r)
-                    })
+                    hoedown_buffer_puts(ob, output.as_ptr());
                 }
             })
         }
index aacb13156b7c1ff3ab28dc2af2000075cd54a8e0..f5d379c4bafa10844c903ec6789f3638ff0498e2 100644 (file)
@@ -41,6 +41,8 @@
 use std::string::String;
 use std::sync::Arc;
 
+use externalfiles::ExternalHtml;
+
 use serialize::json::ToJson;
 use syntax::ast;
 use syntax::ast_util;
@@ -78,7 +80,7 @@ pub struct Context {
     /// This changes as the context descends into the module hierarchy.
     pub dst: Path,
     /// This describes the layout of each page, and is not modified after
-    /// creation of the context (contains info like the favicon)
+    /// creation of the context (contains info like the favicon and added html).
     pub layout: layout::Layout,
     /// This map is a list of what should be displayed on the sidebar of the
     /// current page. The key is the section header (traits, modules,
@@ -220,7 +222,7 @@ struct IndexItem {
 local_data_key!(pub current_location_key: Vec<String> )
 
 /// Generates the documentation for `crate` into the directory `dst`
-pub fn run(mut krate: clean::Crate, dst: Path) -> io::IoResult<()> {
+pub fn run(mut krate: clean::Crate, external_html: &ExternalHtml, dst: Path) -> io::IoResult<()> {
     let mut cx = Context {
         dst: dst,
         current: Vec::new(),
@@ -229,12 +231,14 @@ pub fn run(mut krate: clean::Crate, dst: Path) -> io::IoResult<()> {
         layout: layout::Layout {
             logo: "".to_string(),
             favicon: "".to_string(),
+            external_html: external_html.clone(),
             krate: krate.name.clone(),
             playground_url: "".to_string(),
         },
         include_sources: true,
         render_redirect_pages: false,
     };
+
     try!(mkdir(&cx.dst));
 
     // Crawl the crate attributes looking for attributes which control how we're
index be14ffa87af1ce8c55676c7914355a790ae964b5..86b80ee24943691a4abf49bab1ad1e7f0e9508c9 100644 (file)
@@ -32,6 +32,7 @@
 use std::str;
 use std::gc::Gc;
 use serialize::{json, Decodable, Encodable};
+use externalfiles::ExternalHtml;
 
 // reexported from `clean` so it can be easily updated with the mod itself
 pub use clean::SCHEMA_VERSION;
@@ -39,6 +40,8 @@
 pub mod clean;
 pub mod core;
 pub mod doctree;
+#[macro_escape]
+pub mod externalfiles;
 pub mod fold;
 pub mod html {
     pub mod highlight;
@@ -113,16 +116,17 @@ pub fn opts() -> Vec<getopts::OptGroup> {
                  "ARGS"),
         optmulti("", "markdown-css", "CSS files to include via <link> in a rendered Markdown file",
                  "FILES"),
-        optmulti("", "markdown-in-header",
-                 "files to include inline in the <head> section of a rendered Markdown file",
+        optmulti("", "html-in-header",
+                 "files to include inline in the <head> section of a rendered Markdown file \
+                 or generated documentation",
                  "FILES"),
-        optmulti("", "markdown-before-content",
+        optmulti("", "html-before-content",
                  "files to include inline between <body> and the content of a rendered \
-                 Markdown file",
+                 Markdown file or generated documentation",
                  "FILES"),
-        optmulti("", "markdown-after-content",
+        optmulti("", "html-after-content",
                  "files to include inline between the content and </body> of a rendered \
-                 Markdown file",
+                 Markdown file or generated documentation",
                  "FILES"),
         optopt("", "markdown-playground-url",
                "URL to send code snippets to", "URL")
@@ -179,6 +183,14 @@ pub fn main_args(args: &[String]) -> int {
     let output = matches.opt_str("o").map(|s| Path::new(s));
     let cfgs = matches.opt_strs("cfg");
 
+    let external_html = match ExternalHtml::load(
+            matches.opt_strs("html-in-header").as_slice(),
+            matches.opt_strs("html-before-content").as_slice(),
+            matches.opt_strs("html-after-content").as_slice()) {
+        Some(eh) => eh,
+        None => return 3
+    };
+
     match (should_test, markdown_input) {
         (true, true) => {
             return markdown::test(input, libs, test_args)
@@ -187,7 +199,7 @@ pub fn main_args(args: &[String]) -> int {
             return test::run(input, cfgs, libs, test_args)
         }
         (false, true) => return markdown::render(input, output.unwrap_or(Path::new("doc")),
-                                                 &matches),
+                                                 &matches, &external_html),
         (false, false) => {}
     }
 
@@ -215,7 +227,7 @@ pub fn main_args(args: &[String]) -> int {
     let started = time::precise_time_ns();
     match matches.opt_str("w").as_ref().map(|s| s.as_slice()) {
         Some("html") | None => {
-            match html::render::run(krate, output.unwrap_or(Path::new("doc"))) {
+            match html::render::run(krate, &external_html, output.unwrap_or(Path::new("doc"))) {
                 Ok(()) => {}
                 Err(e) => fail!("failed to generate documentation: {}", e),
             }
@@ -396,18 +408,17 @@ fn json_output(krate: clean::Crate, res: Vec<plugins::PluginJson> ,
     //   "crate": { parsed crate ... },
     //   "plugins": { output of plugins ... }
     // }
-    let mut json = box std::collections::TreeMap::new();
-    json.insert("schema".to_string(),
-                json::String(SCHEMA_VERSION.to_string()));
-    let plugins_json = box res.move_iter()
-                              .filter_map(|opt| {
-                                  match opt {
-                                      None => None,
-                                      Some((string, json)) => {
-                                          Some((string.to_string(), json))
-                                      }
+    let mut json = std::collections::TreeMap::new();
+    json.insert("schema".to_string(), json::String(SCHEMA_VERSION.to_string()));
+    let plugins_json = res.move_iter()
+                          .filter_map(|opt| {
+                              match opt {
+                                  None => None,
+                                  Some((string, json)) => {
+                                      Some((string.to_string(), json))
                                   }
-                              }).collect();
+                              }
+                          }).collect();
 
     // FIXME #8335: yuck, Rust -> str -> JSON round trip! No way to .encode
     // straight to the Rust JSON representation.
@@ -417,7 +428,7 @@ fn json_output(krate: clean::Crate, res: Vec<plugins::PluginJson> ,
             let mut encoder = json::Encoder::new(&mut w as &mut io::Writer);
             krate.encode(&mut encoder).unwrap();
         }
-        str::from_utf8(w.unwrap().as_slice()).unwrap().to_string()
+        str::from_utf8_owned(w.unwrap()).unwrap()
     };
     let crate_json = match json::from_str(crate_json_str.as_slice()) {
         Ok(j) => j,
@@ -428,6 +439,5 @@ fn json_output(krate: clean::Crate, res: Vec<plugins::PluginJson> ,
     json.insert("plugins".to_string(), json::Object(plugins_json));
 
     let mut file = try!(File::create(&dst));
-    try!(json::Object(json).to_writer(&mut file));
-    Ok(())
+    json::Object(json).to_writer(&mut file)
 }
index 76366240f1ac46eb199bc96ae3c519ff3987c57c..da271be4768e3de393d2a22389a4db620cd7a360 100644 (file)
@@ -9,43 +9,19 @@
 // except according to those terms.
 
 use std::collections::HashSet;
-use std::{str, io};
+use std::io;
 use std::string::String;
 
 use getopts;
 use testing;
 
+use externalfiles::ExternalHtml;
+
 use html::escape::Escape;
 use html::markdown;
 use html::markdown::{MarkdownWithToc, find_testable_code, reset_headers};
 use test::Collector;
 
-fn load_string(input: &Path) -> io::IoResult<Option<String>> {
-    let mut f = try!(io::File::open(input));
-    let d = try!(f.read_to_end());
-    Ok(str::from_utf8(d.as_slice()).map(|s| s.to_string()))
-}
-macro_rules! load_or_return {
-    ($input: expr, $cant_read: expr, $not_utf8: expr) => {
-        {
-            let input = Path::new($input);
-            match load_string(&input) {
-                Err(e) => {
-                    let _ = writeln!(&mut io::stderr(),
-                                     "error reading `{}`: {}", input.display(), e);
-                    return $cant_read;
-                }
-                Ok(None) => {
-                    let _ = writeln!(&mut io::stderr(),
-                                     "error reading `{}`: not UTF-8", input.display());
-                    return $not_utf8;
-                }
-                Ok(Some(s)) => s
-            }
-        }
-    }
-}
-
 /// Separate any lines at the start of the file that begin with `%`.
 fn extract_leading_metadata<'a>(s: &'a str) -> (Vec<&'a str>, &'a str) {
     let mut metadata = Vec::new();
@@ -62,18 +38,10 @@ fn extract_leading_metadata<'a>(s: &'a str) -> (Vec<&'a str>, &'a str) {
     (metadata, "")
 }
 
-fn load_external_files(names: &[String]) -> Option<String> {
-    let mut out = String::new();
-    for name in names.iter() {
-        out.push_str(load_or_return!(name.as_slice(), None, None).as_slice());
-        out.push_char('\n');
-    }
-    Some(out)
-}
-
 /// Render `input` (e.g. "foo.md") into an HTML file in `output`
 /// (e.g. output = "bar" => "bar/foo.html").
-pub fn render(input: &str, mut output: Path, matches: &getopts::Matches) -> int {
+pub fn render(input: &str, mut output: Path, matches: &getopts::Matches,
+              external_html: &ExternalHtml) -> int {
     let input_p = Path::new(input);
     output.push(input_p.filestem().unwrap());
     output.set_extension("html");
@@ -91,17 +59,6 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches) -> int
     }
     let playground = playground.unwrap_or("".to_string());
 
-    let (in_header, before_content, after_content) =
-        match (load_external_files(matches.opt_strs("markdown-in-header")
-                                          .as_slice()),
-               load_external_files(matches.opt_strs("markdown-before-content")
-                                          .as_slice()),
-               load_external_files(matches.opt_strs("markdown-after-content")
-                                          .as_slice())) {
-        (Some(a), Some(b), Some(c)) => (a,b,c),
-        _ => return 3
-    };
-
     let mut out = match io::File::create(&output) {
         Err(e) => {
             let _ = writeln!(&mut io::stderr(),
@@ -153,10 +110,10 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches) -> int
 </html>"#,
         title = Escape(title),
         css = css,
-        in_header = in_header,
-        before_content = before_content,
+        in_header = external_html.in_header,
+        before_content = external_html.before_content,
         text = MarkdownWithToc(text),
-        after_content = after_content,
+        after_content = external_html.after_content,
         playground = playground,
         );
 
index 26216f655304e734757d588d8c2d9ef85a35f0a6..9734ba2d7518ef90995726a20ab5b8cd906037e9 100644 (file)
@@ -51,11 +51,11 @@ fn main() {
     // Allocate the C string with an explicit local that owns the string. The
     // `c_buffer` pointer will be deallocated when `my_c_string` goes out of scope.
     let my_c_string = my_string.to_c_str();
-    my_c_string.with_ref(|c_buffer| {
-        unsafe { puts(c_buffer); }
-    });
+    unsafe {
+        puts(my_c_string.as_ptr());
+    }
 
-    // Don't save off the allocation of the C string, the `c_buffer` will be
+    // Don't save/return the pointer to the C string, the `c_buffer` will be
     // deallocated when this block returns!
     my_string.with_c_str(|c_buffer| {
         unsafe { puts(c_buffer); }
@@ -122,15 +122,71 @@ pub unsafe fn new(buf: *const libc::c_char, owns_buffer: bool) -> CString {
         CString { buf: buf, owns_buffer_: owns_buffer }
     }
 
-    /// Unwraps the wrapped `*libc::c_char` from the `CString` wrapper.
+    /// Return a pointer to the NUL-terminated string data.
+    ///
+    /// `.as_ptr` returns an internal pointer into the `CString`, and
+    /// may be invalidated when the `CString` falls out of scope (the
+    /// destructor will run, freeing the allocation if there is
+    /// one).
+    ///
+    /// ```rust
+    /// let foo = "some string";
+    ///
+    /// // right
+    /// let x = foo.to_c_str();
+    /// let p = x.as_ptr();
+    ///
+    /// // wrong (the CString will be freed, invalidating `p`)
+    /// let p = foo.to_c_str().as_ptr();
+    /// ```
+    ///
+    /// # Failure
+    ///
+    /// Fails if the CString is null.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// extern crate libc;
     ///
-    /// The original object is destructed after this method is called, and if
-    /// the underlying pointer was previously allocated, care must be taken to
-    /// ensure that it is deallocated properly.
-    pub unsafe fn unwrap(self) -> *const libc::c_char {
-        let mut c_str = self;
-        c_str.owns_buffer_ = false;
-        c_str.buf
+    /// fn main() {
+    ///     let c_str = "foo bar".to_c_str();
+    ///     unsafe {
+    ///         libc::puts(c_str.as_ptr());
+    ///     }
+    /// }
+    /// ```
+    pub fn as_ptr(&self) -> *const libc::c_char {
+        if self.buf.is_null() { fail!("CString is null!"); }
+
+        self.buf
+    }
+
+    /// Return a mutable pointer to the NUL-terminated string data.
+    ///
+    /// `.as_mut_ptr` returns an internal pointer into the `CString`, and
+    /// may be invalidated when the `CString` falls out of scope (the
+    /// destructor will run, freeing the allocation if there is
+    /// one).
+    ///
+    /// ```rust
+    /// let foo = "some string";
+    ///
+    /// // right
+    /// let mut x = foo.to_c_str();
+    /// let p = x.as_mut_ptr();
+    ///
+    /// // wrong (the CString will be freed, invalidating `p`)
+    /// let p = foo.to_c_str().as_mut_ptr();
+    /// ```
+    ///
+    /// # Failure
+    ///
+    /// Fails if the CString is null.
+    pub fn as_mut_ptr(&mut self) -> *mut libc::c_char {
+        if self.buf.is_null() { fail!("CString is null!") }
+
+        self.buf as *mut _
     }
 
     /// Calls a closure with a reference to the underlying `*libc::c_char`.
@@ -138,6 +194,7 @@ pub unsafe fn unwrap(self) -> *const libc::c_char {
     /// # Failure
     ///
     /// Fails if the CString is null.
+    #[deprecated="use `.as_ptr()`"]
     pub fn with_ref<T>(&self, f: |*const libc::c_char| -> T) -> T {
         if self.buf.is_null() { fail!("CString is null!"); }
         f(self.buf)
@@ -148,6 +205,7 @@ pub fn with_ref<T>(&self, f: |*const libc::c_char| -> T) -> T {
     /// # Failure
     ///
     /// Fails if the CString is null.
+    #[deprecated="use `.as_mut_ptr()`"]
     pub fn with_mut_ref<T>(&mut self, f: |*mut libc::c_char| -> T) -> T {
         if self.buf.is_null() { fail!("CString is null!"); }
         f(self.buf as *mut libc::c_char)
@@ -220,6 +278,22 @@ pub fn iter<'a>(&'a self) -> CChars<'a> {
             marker: marker::ContravariantLifetime,
         }
     }
+
+    /// Unwraps the wrapped `*libc::c_char` from the `CString` wrapper.
+    ///
+    /// Any ownership of the buffer by the `CString` wrapper is
+    /// forgotten, meaning that the backing allocation of this
+    /// `CString` is not automatically freed if it owns the
+    /// allocation. In this case, a user of `.unwrap()` should ensure
+    /// the allocation is freed, to avoid leaking memory.
+    ///
+    /// Prefer `.as_ptr()` when just retrieving a pointer to the
+    /// string data, as that does not relinquish ownership.
+    pub unsafe fn unwrap(mut self) -> *const libc::c_char {
+        self.owns_buffer_ = false;
+        self.buf
+    }
+
 }
 
 impl Drop for CString {
@@ -285,13 +359,15 @@ pub trait ToCStr {
     /// Fails the task if the receiver has an interior null.
     #[inline]
     fn with_c_str<T>(&self, f: |*const libc::c_char| -> T) -> T {
-        self.to_c_str().with_ref(f)
+        let c_str = self.to_c_str();
+        f(c_str.as_ptr())
     }
 
     /// Unsafe variant of `with_c_str()` that doesn't check for nulls.
     #[inline]
     unsafe fn with_c_str_unchecked<T>(&self, f: |*const libc::c_char| -> T) -> T {
-        self.to_c_str_unchecked().with_ref(f)
+        let c_str = self.to_c_str_unchecked();
+        f(c_str.as_ptr())
     }
 }
 
@@ -353,7 +429,7 @@ unsafe fn with_c_str_unchecked<T>(&self, f: |*const libc::c_char| -> T) -> T {
 impl<'a> ToCStr for &'a [u8] {
     fn to_c_str(&self) -> CString {
         let mut cs = unsafe { self.to_c_str_unchecked() };
-        cs.with_mut_ref(|buf| check_for_null(*self, buf));
+        check_for_null(*self, cs.as_mut_ptr());
         cs
     }
 
@@ -379,7 +455,7 @@ unsafe fn with_c_str_unchecked<T>(&self, f: |*const libc::c_char| -> T) -> T {
 // Unsafe function that handles possibly copying the &[u8] into a stack array.
 unsafe fn with_c_str<T>(v: &[u8], checked: bool,
                         f: |*const libc::c_char| -> T) -> T {
-    if v.len() < BUF_LEN {
+    let c_str = if v.len() < BUF_LEN {
         let mut buf: [u8, .. BUF_LEN] = mem::uninitialized();
         slice::bytes::copy_memory(buf, v);
         buf[v.len()] = 0;
@@ -389,12 +465,14 @@ unsafe fn with_c_str<T>(v: &[u8], checked: bool,
             check_for_null(v, buf as *mut libc::c_char);
         }
 
-        f(buf as *const libc::c_char)
+        return f(buf as *const libc::c_char)
     } else if checked {
-        v.to_c_str().with_ref(f)
+        v.to_c_str()
     } else {
-        v.to_c_str_unchecked().with_ref(f)
-    }
+        v.to_c_str_unchecked()
+    };
+
+    f(c_str.as_ptr())
 }
 
 #[inline]
@@ -482,53 +560,51 @@ fn test_str_multistring_parsing() {
 
     #[test]
     fn test_str_to_c_str() {
-        "".to_c_str().with_ref(|buf| {
-            unsafe {
-                assert_eq!(*buf.offset(0), 0);
-            }
-        });
+        let c_str = "".to_c_str();
+        unsafe {
+            assert_eq!(*c_str.as_ptr().offset(0), 0);
+        }
 
-        "hello".to_c_str().with_ref(|buf| {
-            unsafe {
-                assert_eq!(*buf.offset(0), 'h' as libc::c_char);
-                assert_eq!(*buf.offset(1), 'e' as libc::c_char);
-                assert_eq!(*buf.offset(2), 'l' as libc::c_char);
-                assert_eq!(*buf.offset(3), 'l' as libc::c_char);
-                assert_eq!(*buf.offset(4), 'o' as libc::c_char);
-                assert_eq!(*buf.offset(5), 0);
-            }
-        })
+        let c_str = "hello".to_c_str();
+        let buf = c_str.as_ptr();
+        unsafe {
+            assert_eq!(*buf.offset(0), 'h' as libc::c_char);
+            assert_eq!(*buf.offset(1), 'e' as libc::c_char);
+            assert_eq!(*buf.offset(2), 'l' as libc::c_char);
+            assert_eq!(*buf.offset(3), 'l' as libc::c_char);
+            assert_eq!(*buf.offset(4), 'o' as libc::c_char);
+            assert_eq!(*buf.offset(5), 0);
+        }
     }
 
     #[test]
     fn test_vec_to_c_str() {
         let b: &[u8] = [];
-        b.to_c_str().with_ref(|buf| {
-            unsafe {
-                assert_eq!(*buf.offset(0), 0);
-            }
-        });
+        let c_str = b.to_c_str();
+        unsafe {
+            assert_eq!(*c_str.as_ptr().offset(0), 0);
+        }
 
-        let _ = b"hello".to_c_str().with_ref(|buf| {
-            unsafe {
-                assert_eq!(*buf.offset(0), 'h' as libc::c_char);
-                assert_eq!(*buf.offset(1), 'e' as libc::c_char);
-                assert_eq!(*buf.offset(2), 'l' as libc::c_char);
-                assert_eq!(*buf.offset(3), 'l' as libc::c_char);
-                assert_eq!(*buf.offset(4), 'o' as libc::c_char);
-                assert_eq!(*buf.offset(5), 0);
-            }
-        });
+        let c_str = b"hello".to_c_str();
+        let buf = c_str.as_ptr();
+        unsafe {
+            assert_eq!(*buf.offset(0), 'h' as libc::c_char);
+            assert_eq!(*buf.offset(1), 'e' as libc::c_char);
+            assert_eq!(*buf.offset(2), 'l' as libc::c_char);
+            assert_eq!(*buf.offset(3), 'l' as libc::c_char);
+            assert_eq!(*buf.offset(4), 'o' as libc::c_char);
+            assert_eq!(*buf.offset(5), 0);
+        }
 
-        let _ = b"foo\xFF".to_c_str().with_ref(|buf| {
-            unsafe {
-                assert_eq!(*buf.offset(0), 'f' as libc::c_char);
-                assert_eq!(*buf.offset(1), 'o' as libc::c_char);
-                assert_eq!(*buf.offset(2), 'o' as libc::c_char);
-                assert_eq!(*buf.offset(3), 0xff as i8);
-                assert_eq!(*buf.offset(4), 0);
-            }
-        });
+        let c_str = b"foo\xFF".to_c_str();
+        let buf = c_str.as_ptr();
+        unsafe {
+            assert_eq!(*buf.offset(0), 'f' as libc::c_char);
+            assert_eq!(*buf.offset(1), 'o' as libc::c_char);
+            assert_eq!(*buf.offset(2), 'o' as libc::c_char);
+            assert_eq!(*buf.offset(3), 0xffu8 as i8);
+            assert_eq!(*buf.offset(4), 0);
+        }
     }
 
     #[test]
@@ -545,19 +621,18 @@ fn test_unwrap() {
     }
 
     #[test]
-    fn test_with_ref() {
+    fn test_as_ptr() {
         let c_str = "hello".to_c_str();
-        let len = unsafe { c_str.with_ref(|buf| libc::strlen(buf)) };
+        let len = unsafe { libc::strlen(c_str.as_ptr()) };
         assert!(!c_str.is_null());
         assert!(c_str.is_not_null());
         assert_eq!(len, 5);
     }
-
     #[test]
     #[should_fail]
-    fn test_with_ref_empty_fail() {
+    fn test_as_ptr_empty_fail() {
         let c_str = unsafe { CString::new(ptr::null(), false) };
-        c_str.with_ref(|_| ());
+        c_str.as_ptr();
     }
 
     #[test]
@@ -584,15 +659,15 @@ fn test_to_c_str_fail() {
     #[test]
     fn test_to_c_str_unchecked() {
         unsafe {
-            "he\x00llo".to_c_str_unchecked().with_ref(|buf| {
-                assert_eq!(*buf.offset(0), 'h' as libc::c_char);
-                assert_eq!(*buf.offset(1), 'e' as libc::c_char);
-                assert_eq!(*buf.offset(2), 0);
-                assert_eq!(*buf.offset(3), 'l' as libc::c_char);
-                assert_eq!(*buf.offset(4), 'l' as libc::c_char);
-                assert_eq!(*buf.offset(5), 'o' as libc::c_char);
-                assert_eq!(*buf.offset(6), 0);
-            })
+            let c_string = "he\x00llo".to_c_str_unchecked();
+            let buf = c_string.as_ptr();
+            assert_eq!(*buf.offset(0), 'h' as libc::c_char);
+            assert_eq!(*buf.offset(1), 'e' as libc::c_char);
+            assert_eq!(*buf.offset(2), 0);
+            assert_eq!(*buf.offset(3), 'l' as libc::c_char);
+            assert_eq!(*buf.offset(4), 'l' as libc::c_char);
+            assert_eq!(*buf.offset(5), 'o' as libc::c_char);
+            assert_eq!(*buf.offset(6), 0);
         }
     }
 
@@ -675,10 +750,10 @@ fn foo(f: |c: &CString|) {
             let s = "test".to_string();
             let c = s.to_c_str();
             // give the closure a non-owned CString
-            let mut c_ = c.with_ref(|c| unsafe { CString::new(c, false) } );
+            let mut c_ = unsafe { CString::new(c.as_ptr(), false) };
             f(&c_);
             // muck with the buffer for later printing
-            c_.with_mut_ref(|c| unsafe { *c = 'X' as libc::c_char } );
+            unsafe { *c_.as_mut_ptr() = 'X' as libc::c_char }
         }
 
         let mut c_: Option<CString> = None;
@@ -732,7 +807,7 @@ fn check(s: &str, c_str: *const libc::c_char) {
     fn bench_to_str(b: &mut Bencher, s: &str) {
         b.iter(|| {
             let c_str = s.to_c_str();
-            c_str.with_ref(|c_str_buf| check(s, c_str_buf))
+            check(s, c_str.as_ptr());
         })
     }
 
@@ -754,7 +829,7 @@ fn bench_to_c_str_long(b: &mut Bencher) {
     fn bench_to_c_str_unchecked(b: &mut Bencher, s: &str) {
         b.iter(|| {
             let c_str = unsafe { s.to_c_str_unchecked() };
-            c_str.with_ref(|c_str_buf| check(s, c_str_buf))
+            check(s, c_str.as_ptr())
         })
     }
 
index aca9e46d2f4a0aa43831f6a344a83cf8c32cb746..273505c416a3ca761d393390865a1f3bb989ef11 100644 (file)
@@ -335,11 +335,11 @@ mod bench {
 
     #[bench]
     fn alloc_managed_small(b: &mut Bencher) {
-        b.iter(|| { box(GC) 10 });
+        b.iter(|| { box(GC) 10i });
     }
 
     #[bench]
     fn alloc_managed_big(b: &mut Bencher) {
-        b.iter(|| { box(GC) ([10, ..1000]) });
+        b.iter(|| { box(GC) ([10i, ..1000]) });
     }
 }
index a0140129c0b406d666f0c7c350461ff6429f2543..813ea0f30f38b71afbb3655ccc7d82646ca1840c 100644 (file)
@@ -172,7 +172,7 @@ pub unsafe fn take<T>() -> Box<T> {
         rtassert!(!ptr.is_null());
         let ptr: Box<T> = mem::transmute(ptr);
         // can't use `as`, due to type not matching with `cfg(test)`
-        RT_TLS_PTR = mem::transmute(0);
+        RT_TLS_PTR = mem::transmute(0u);
         ptr
     }
 
@@ -189,7 +189,7 @@ pub unsafe fn try_take<T>() -> Option<Box<T>> {
         } else {
             let ptr: Box<T> = mem::transmute(ptr);
             // can't use `as`, due to type not matching with `cfg(test)`
-            RT_TLS_PTR = mem::transmute(0);
+            RT_TLS_PTR = mem::transmute(0u);
             Some(ptr)
         }
     }
index 6e27310f09ac92c838d94e00fa7b80e36d5d3340..891d0d5a8e3592053b8c4ff14c08079a71b6abbb 100644 (file)
@@ -560,7 +560,7 @@ mod test {
 
     #[test]
     fn local_heap() {
-        let a = box(GC) 5;
+        let a = box(GC) 5i;
         let b = a;
         assert!(*a == 5);
         assert!(*b == 5);
@@ -596,14 +596,14 @@ fn rng() {
     #[test]
     fn comm_stream() {
         let (tx, rx) = channel();
-        tx.send(10);
+        tx.send(10i);
         assert!(rx.recv() == 10);
     }
 
     #[test]
     fn comm_shared_chan() {
         let (tx, rx) = channel();
-        tx.send(10);
+        tx.send(10i);
         assert!(rx.recv() == 10);
     }
 
index e1db67140aad755cbd4d302a27d7a87e49adec74..3b9ee31d8e5078ff8170b246562ab2fbbf091abf 100644 (file)
@@ -100,15 +100,15 @@ fn tls_smoke_test() {
         use std::mem::transmute;
         unsafe {
             let mut key = 0;
-            let value = box 20;
+            let value = box 20i;
             create(&mut key);
             set(key, transmute(value));
             let value: Box<int> = transmute(get(key));
-            assert_eq!(value, box 20);
-            let value = box 30;
+            assert_eq!(value, box 20i);
+            let value = box 30i;
             set(key, transmute(value));
             let value: Box<int> = transmute(get(key));
-            assert_eq!(value, box 30);
+            assert_eq!(value, box 30i);
         }
     }
 }
index fa30199109e76ce2554da23076a1f33283b37d57..6eaab1c0961707347b3ab6070affe7105b3b0a82 100644 (file)
@@ -40,7 +40,7 @@ pub fn run(loop_: &Loop, node: Option<&str>, service: Option<&str>,
         let (_c_node, c_node_ptr) = match node {
             Some(n) => {
                 let c_node = n.to_c_str();
-                let c_node_ptr = c_node.with_ref(|r| r);
+                let c_node_ptr = c_node.as_ptr();
                 (Some(c_node), c_node_ptr)
             }
             None => (None, null())
@@ -49,7 +49,7 @@ pub fn run(loop_: &Loop, node: Option<&str>, service: Option<&str>,
         let (_c_service, c_service_ptr) = match service {
             Some(s) => {
                 let c_service = s.to_c_str();
-                let c_service_ptr = c_service.with_ref(|r| r);
+                let c_service_ptr = c_service.as_ptr();
                 (Some(c_service), c_service_ptr)
             }
             None => (None, null())
index 85abc45c4302a52c640690aa332fbf4f41e8ea9f..76b2c22e86e0f3c1281c1d964220c6374ba231a0 100644 (file)
@@ -41,7 +41,7 @@ pub fn open(io: &mut UvIoFactory, path: &CString, flags: int, mode: int)
     {
         execute(|req, cb| unsafe {
             uvll::uv_fs_open(io.uv_loop(),
-                             req, path.with_ref(|p| p), flags as c_int,
+                             req, path.as_ptr(), flags as c_int,
                              mode as c_int, cb)
         }).map(|req|
             FileWatcher::new(io, req.get_result() as c_int,
@@ -51,7 +51,7 @@ pub fn open(io: &mut UvIoFactory, path: &CString, flags: int, mode: int)
 
     pub fn unlink(loop_: &Loop, path: &CString) -> Result<(), UvError> {
         execute_nop(|req, cb| unsafe {
-            uvll::uv_fs_unlink(loop_.handle, req, path.with_ref(|p| p),
+            uvll::uv_fs_unlink(loop_.handle, req, path.as_ptr(),
                                cb)
         })
     }
@@ -60,14 +60,14 @@ pub fn lstat(loop_: &Loop, path: &CString)
         -> Result<rtio::FileStat, UvError>
     {
         execute(|req, cb| unsafe {
-            uvll::uv_fs_lstat(loop_.handle, req, path.with_ref(|p| p),
+            uvll::uv_fs_lstat(loop_.handle, req, path.as_ptr(),
                               cb)
         }).map(|req| req.mkstat())
     }
 
     pub fn stat(loop_: &Loop, path: &CString) -> Result<rtio::FileStat, UvError> {
         execute(|req, cb| unsafe {
-            uvll::uv_fs_stat(loop_.handle, req, path.with_ref(|p| p),
+            uvll::uv_fs_stat(loop_.handle, req, path.as_ptr(),
                              cb)
         }).map(|req| req.mkstat())
     }
@@ -125,14 +125,14 @@ pub fn mkdir(loop_: &Loop, path: &CString, mode: c_int)
         -> Result<(), UvError>
     {
         execute_nop(|req, cb| unsafe {
-            uvll::uv_fs_mkdir(loop_.handle, req, path.with_ref(|p| p),
+            uvll::uv_fs_mkdir(loop_.handle, req, path.as_ptr(),
                               mode, cb)
         })
     }
 
     pub fn rmdir(loop_: &Loop, path: &CString) -> Result<(), UvError> {
         execute_nop(|req, cb| unsafe {
-            uvll::uv_fs_rmdir(loop_.handle, req, path.with_ref(|p| p),
+            uvll::uv_fs_rmdir(loop_.handle, req, path.as_ptr(),
                               cb)
         })
     }
@@ -143,8 +143,8 @@ pub fn rename(loop_: &Loop, path: &CString, to: &CString)
         execute_nop(|req, cb| unsafe {
             uvll::uv_fs_rename(loop_.handle,
                                req,
-                               path.with_ref(|p| p),
-                               to.with_ref(|p| p),
+                               path.as_ptr(),
+                               to.as_ptr(),
                                cb)
         })
     }
@@ -153,7 +153,7 @@ pub fn chmod(loop_: &Loop, path: &CString, mode: c_int)
         -> Result<(), UvError>
     {
         execute_nop(|req, cb| unsafe {
-            uvll::uv_fs_chmod(loop_.handle, req, path.with_ref(|p| p),
+            uvll::uv_fs_chmod(loop_.handle, req, path.as_ptr(),
                               mode, cb)
         })
     }
@@ -163,10 +163,10 @@ pub fn readdir(loop_: &Loop, path: &CString, flags: c_int)
     {
         execute(|req, cb| unsafe {
             uvll::uv_fs_readdir(loop_.handle,
-                                req, path.with_ref(|p| p), flags, cb)
+                                req, path.as_ptr(), flags, cb)
         }).map(|req| unsafe {
             let mut paths = vec!();
-            let path = CString::new(path.with_ref(|p| p), false);
+            let path = CString::new(path.as_ptr(), false);
             let parent = Path::new(path);
             let _ = c_str::from_c_multistring(req.get_ptr() as *const libc::c_char,
                                               Some(req.get_result() as uint),
@@ -181,7 +181,7 @@ pub fn readdir(loop_: &Loop, path: &CString, flags: c_int)
     pub fn readlink(loop_: &Loop, path: &CString) -> Result<CString, UvError> {
         execute(|req, cb| unsafe {
             uvll::uv_fs_readlink(loop_.handle, req,
-                                 path.with_ref(|p| p), cb)
+                                 path.as_ptr(), cb)
         }).map(|req| {
             // Be sure to clone the cstring so we get an independently owned
             // allocation to work with and return.
@@ -196,7 +196,7 @@ pub fn chown(loop_: &Loop, path: &CString, uid: int, gid: int)
     {
         execute_nop(|req, cb| unsafe {
             uvll::uv_fs_chown(loop_.handle,
-                              req, path.with_ref(|p| p),
+                              req, path.as_ptr(),
                               uid as uvll::uv_uid_t,
                               gid as uvll::uv_gid_t,
                               cb)
@@ -216,8 +216,8 @@ pub fn link(loop_: &Loop, src: &CString, dst: &CString)
     {
         execute_nop(|req, cb| unsafe {
             uvll::uv_fs_link(loop_.handle, req,
-                             src.with_ref(|p| p),
-                             dst.with_ref(|p| p),
+                             src.as_ptr(),
+                             dst.as_ptr(),
                              cb)
         })
     }
@@ -227,8 +227,8 @@ pub fn symlink(loop_: &Loop, src: &CString, dst: &CString)
     {
         execute_nop(|req, cb| unsafe {
             uvll::uv_fs_symlink(loop_.handle, req,
-                                src.with_ref(|p| p),
-                                dst.with_ref(|p| p),
+                                src.as_ptr(),
+                                dst.as_ptr(),
                                 0, cb)
         })
     }
@@ -252,7 +252,7 @@ pub fn utime(loop_: &Loop, path: &CString, atime: u64, mtime: u64)
         let atime = atime as libc::c_double / 1000.0;
         let mtime = mtime as libc::c_double / 1000.0;
         execute_nop(|req, cb| unsafe {
-            uvll::uv_fs_utime(loop_.handle, req, path.with_ref(|p| p),
+            uvll::uv_fs_utime(loop_.handle, req, path.as_ptr(),
                               atime, mtime, cb)
         })
     }
index f1c37762129a3b442d8013e56e41bb47a804982e..edecb8475e9d136b285d31481d224784086899a8 100644 (file)
@@ -191,7 +191,7 @@ fn new_home(loop_: &Loop, home: HomeHandle) -> TcpWatcher {
         TcpWatcher {
             home: home,
             handle: handle,
-            stream: StreamWatcher::new(handle),
+            stream: StreamWatcher::new(handle, true),
             refcount: Refcount::new(),
             read_access: AccessTimeout::new(),
             write_access: AccessTimeout::new(),
@@ -278,7 +278,7 @@ fn letdie(&mut self) -> Result<(), IoError> {
     fn clone(&self) -> Box<rtio::RtioTcpStream + Send> {
         box TcpWatcher {
             handle: self.handle,
-            stream: StreamWatcher::new(self.handle),
+            stream: StreamWatcher::new(self.handle, false),
             home: self.home.clone(),
             refcount: self.refcount.clone(),
             read_access: self.read_access.clone(),
@@ -1160,7 +1160,7 @@ fn test_read_and_block() {
 
         let expected = 32;
         let mut current = 0;
-        let mut reads = 0;
+        let mut reads = 0u;
 
         while current < expected {
             let nread = stream.read(buf).ok().unwrap();
index f14f81b0b6072af3c286d3f404cdfef6476c5046..1c53814ac2441731be8ecdf52b04c7ef1c665fc6 100644 (file)
@@ -67,7 +67,7 @@ pub fn new_home(loop_: &Loop, home: HomeHandle, ipc: bool) -> PipeWatcher {
             handle
         };
         PipeWatcher {
-            stream: StreamWatcher::new(handle),
+            stream: StreamWatcher::new(handle, true),
             home: home,
             defused: false,
             refcount: Refcount::new(),
@@ -94,7 +94,7 @@ pub fn connect(io: &mut UvIoFactory, name: &CString, timeout: Option<u64>)
         cx.connect(pipe, timeout, io, |req, pipe, cb| {
             unsafe {
                 uvll::uv_pipe_connect(req.handle, pipe.handle(),
-                                      name.with_ref(|p| p), cb)
+                                      name.as_ptr(), cb)
             }
             0
         })
@@ -131,7 +131,7 @@ fn write(&mut self, buf: &[u8]) -> IoResult<()> {
 
     fn clone(&self) -> Box<rtio::RtioPipe + Send> {
         box PipeWatcher {
-            stream: StreamWatcher::new(self.stream.handle),
+            stream: StreamWatcher::new(self.stream.handle, false),
             defused: false,
             home: self.home.clone(),
             refcount: self.refcount.clone(),
@@ -227,7 +227,7 @@ pub fn bind(io: &mut UvIoFactory, name: &CString)
     {
         let pipe = PipeWatcher::new(io, false);
         match unsafe {
-            uvll::uv_pipe_bind(pipe.handle(), name.with_ref(|p| p))
+            uvll::uv_pipe_bind(pipe.handle(), name.as_ptr())
         } {
             0 => {
                 // If successful, unwrap the PipeWatcher because we control how
index a341f04f567835a8d288dd41198db641d391148c..61325d0ce948eb5bb6926ec4bcee141f30af0f7a 100644 (file)
@@ -85,7 +85,7 @@ pub fn spawn(io_loop: &mut UvIoFactory, cfg: rtio::ProcessConfig)
                     args: argv,
                     env: envp,
                     cwd: match cfg.cwd {
-                        Some(cwd) => cwd.with_ref(|p| p),
+                        Some(cwd) => cwd.as_ptr(),
                         None => ptr::null(),
                     },
                     flags: flags as libc::c_uint,
@@ -183,8 +183,8 @@ fn with_argv<T>(prog: &CString, args: &[CString],
     // larger than the lifetime of our invocation of cb, but this is
     // technically unsafe as the callback could leak these pointers
     // out of our scope.
-    ptrs.push(prog.with_ref(|buf| buf));
-    ptrs.extend(args.iter().map(|tmp| tmp.with_ref(|buf| buf)));
+    ptrs.push(prog.as_ptr());
+    ptrs.extend(args.iter().map(|tmp| tmp.as_ptr()));
 
     // Add a terminating null pointer (required by libc).
     ptrs.push(ptr::null());
index 902e2b0bd192fec42d3329f8674d01bdece34290..baaf1150ce0859261709abc0af5e99e45abeeb3f 100644 (file)
@@ -176,7 +176,7 @@ fn drop(&mut self) {
 impl Drop for State {
     fn drop(&mut self) {
         unsafe {
-            uvll::uv_close(self.handle, mem::transmute(0));
+            uvll::uv_close(self.handle, mem::transmute(0u));
             // Note that this does *not* free the handle, that is the
             // responsibility of the caller because the uv loop must be closed
             // before we deallocate this uv handle.
index f615e8287b3c7efb3b77daf3b07f3cd4f954c720..f6b9226588ca34572a7ac8e87172f7c77569d989 100644 (file)
@@ -59,8 +59,11 @@ impl StreamWatcher {
     // will be manipulated on each of the methods called on this watcher.
     // Wrappers should ensure to always reset the field to an appropriate value
     // if they rely on the field to perform an action.
-    pub fn new(stream: *mut uvll::uv_stream_t) -> StreamWatcher {
-        unsafe { uvll::set_data_for_uv_handle(stream, 0 as *mut int) }
+    pub fn new(stream: *mut uvll::uv_stream_t,
+               init: bool) -> StreamWatcher {
+        if init {
+            unsafe { uvll::set_data_for_uv_handle(stream, 0 as *mut int) }
+        }
         StreamWatcher {
             handle: stream,
             last_write_req: None,
index 85ec0c75d53c8cd270a0fd9ef63005bbf08894c1..70b17db8dcfdd147a8a4616866bbf41b94f028a4 100644 (file)
@@ -56,7 +56,7 @@ pub fn new(io: &mut UvIoFactory, fd: libc::c_int, readable: bool)
         let handle = UvHandle::alloc(None::<TtyWatcher>, uvll::UV_TTY);
         let mut watcher = TtyWatcher {
             tty: handle,
-            stream: StreamWatcher::new(handle),
+            stream: StreamWatcher::new(handle, true),
             home: io.make_handle(),
             fd: fd,
         };
index 054a97315add0fa083a95ea4ce6065978c96a4d1..675b2e507b3e9073448bfc99dc6369c53b39ed27 100644 (file)
@@ -55,12 +55,12 @@ pub enum Identifier {
 
 impl cmp::PartialOrd for Identifier {
     #[inline]
-    fn lt(&self, other: &Identifier) -> bool {
+    fn partial_cmp(&self, other: &Identifier) -> Option<Ordering> {
         match (self, other) {
-            (&Numeric(a), &Numeric(b)) => a < b,
-            (&Numeric(_), _) => true,
-            (&AlphaNumeric(ref a), &AlphaNumeric(ref b)) => *a < *b,
-            (&AlphaNumeric(_), _) => false
+            (&Numeric(a), &Numeric(ref b)) => a.partial_cmp(b),
+            (&Numeric(_), _) => Some(Less),
+            (&AlphaNumeric(ref a), &AlphaNumeric(ref b)) => a.partial_cmp(b),
+            (&AlphaNumeric(_), _) => Some(Greater)
         }
     }
 }
@@ -130,30 +130,31 @@ fn eq(&self, other: &Version) -> bool {
 
 impl cmp::PartialOrd for Version {
     #[inline]
-    fn lt(&self, other: &Version) -> bool {
-
-        self.major < other.major ||
-
-            (self.major == other.major &&
-             self.minor < other.minor) ||
-
-            (self.major == other.major &&
-             self.minor == other.minor &&
-             self.patch < other.patch) ||
-
-            (self.major == other.major &&
-             self.minor == other.minor &&
-             self.patch == other.patch &&
-             // NB: semver spec says 0.0.0-pre < 0.0.0
-             // but the version of ord defined for vec
-             // says that [] < [pre], so we alter it
-             // here.
-             (match (self.pre.len(), other.pre.len()) {
-                 (0, 0) => false,
-                 (0, _) => false,
-                 (_, 0) => true,
-                 (_, _) => self.pre < other.pre
-             }))
+    fn partial_cmp(&self, other: &Version) -> Option<Ordering> {
+        match self.major.partial_cmp(&other.major) {
+            Some(Equal) => {}
+            r => return r,
+        }
+
+        match self.minor.partial_cmp(&other.minor) {
+            Some(Equal) => {}
+            r => return r,
+        }
+
+        match self.patch.partial_cmp(&other.patch) {
+            Some(Equal) => {}
+            r => return r,
+        }
+
+        // NB: semver spec says 0.0.0-pre < 0.0.0
+        // but the version of ord defined for vec
+        // says that [] < [pre] so we alter it here
+        match (self.pre.len(), other.pre.len()) {
+            (0, 0) => Some(Equal),
+            (0, _) => Some(Greater),
+            (_, 0) => Some(Less),
+            (_, _) => self.pre.partial_cmp(&other.pre)
+        }
     }
 }
 
index ee1e836112e3d5a3c9e15c0cec5f3088b650d440..63cfbd6d9aa17b20074716547b7118b8289ffb72 100644 (file)
@@ -208,7 +208,7 @@ impl<'a> FromBase64 for &'a str {
     fn from_base64(&self) -> Result<Vec<u8>, FromBase64Error> {
         let mut r = Vec::new();
         let mut buf: u32 = 0;
-        let mut modulus = 0;
+        let mut modulus = 0i;
 
         let mut it = self.bytes().enumerate();
         for (idx, byte) in it {
index 2fccbc2fcaf20b443d847c6a2aa13f1ff07f565f..51fab7b135458ae5e8f06adb03184f438d7c0cb5 100644 (file)
@@ -104,7 +104,7 @@ impl<'a> FromHex for &'a str {
     fn from_hex(&self) -> Result<Vec<u8>, FromHexError> {
         // This may be an overestimate if there is any whitespace
         let mut b = Vec::with_capacity(self.len() / 2);
-        let mut modulus = 0;
+        let mut modulus = 0i;
         let mut buf = 0u8;
 
         for (idx, byte) in self.bytes().enumerate() {
index 9c91bd4b7e1a7e3a50cf7222a6decc7d44f4bb4b..832bc9c4e10cbb2c8f6085a2303aaaa92900e8d2 100644 (file)
 # What is JSON?
 
 JSON (JavaScript Object Notation) is a way to write data in Javascript.
-Like XML it allows one to encode structured data in a text format that can be read by humans easily.
-Its native compatibility with JavaScript and its simple syntax make it used widely.
+Like XML, it allows to encode structured data in a text format that can be easily read by humans.
+Its simple syntax and native compatibility with JavaScript have made it a widely used format.
+
+Data types that can be encoded are JavaScript types (see the `Json` enum for more details):
+
+* `Boolean`: equivalent to rust's `bool`
+* `Number`: equivalent to rust's `f64`
+* `String`: equivalent to rust's `String`
+* `Array`: equivalent to rust's `Vec<T>`, but also allowing objects of different types in the same
+array
+* `Object`: equivalent to rust's `Treemap<String, json::Json>`
+* `Null`
 
-Json data are encoded in a form of "key":"value".
-Data types that can be encoded are JavaScript types :
-boolean (`true` or `false`), number (`f64`), string, array, object, null.
 An object is a series of string keys mapping to values, in `"key": value` format.
 Arrays are enclosed in square brackets ([ ... ]) and objects in curly brackets ({ ... }).
 A simple JSON document encoding a person, his/her age, address and phone numbers could look like:
 
 # Rust Type-based Encoding and Decoding
 
-Rust provides a mechanism for low boilerplate encoding & decoding
-of values to and from JSON via the serialization API.
+Rust provides a mechanism for low boilerplate encoding & decoding of values to and from JSON via
+the serialization API.
 To be able to encode a piece of data, it must implement the `serialize::Encodable` trait.
 To be able to decode a piece of data, it must implement the `serialize::Decodable` trait.
-The Rust compiler provides an annotation to automatically generate
-the code for these traits: `#[deriving(Decodable, Encodable)]`
-
-To encode using Encodable :
-
-```rust
-use std::io;
-use serialize::{json, Encodable};
+The Rust compiler provides an annotation to automatically generate the code for these traits:
+`#[deriving(Decodable, Encodable)]`
 
- #[deriving(Encodable)]
- pub struct TestStruct   {
-    data_str: String,
- }
-
-fn main() {
-    let to_encode_object = TestStruct{data_str:"example of string to encode".to_string()};
-    let mut m = io::MemWriter::new();
-    {
-        let mut encoder = json::Encoder::new(&mut m as &mut Writer);
-        match to_encode_object.encode(&mut encoder) {
-            Ok(()) => (),
-            Err(e) => fail!("json encoding error: {}", e)
-        };
-    }
-}
-```
-
-Two wrapper functions are provided to encode a Encodable object
-into a string (String) or buffer (vec![u8]): `str_encode(&m)` and `buffer_encode(&m)`.
-
-```rust
-use serialize::json;
-let to_encode_object = "example of string to encode".to_string();
-let encoded_str: String = json::Encoder::str_encode(&to_encode_object);
-```
-
-JSON API provide an enum `json::Json` and a trait `ToJson` to encode object.
-The trait `ToJson` encode object into a container `json::Json` and the API provide writer
-to encode them into a stream or a string ...
+The JSON API provides an enum `json::Json` and a trait `ToJson` to encode objects.
+The `ToJson` trait provides a `to_json` method to convert an object into a `json::Json` value.
+A `json::Json` value can be encoded as a string or buffer using the functions described above.
+You can also use the `json::Encoder` object, which implements the `Encoder` trait.
 
 When using `ToJson` the `Encodable` trait implementation is not mandatory.
 
-A basic `ToJson` example using a TreeMap of attribute name / attribute value:
-
-
-```rust
-use std::collections::TreeMap;
-use serialize::json;
-use serialize::json::ToJson;
-
-pub struct MyStruct  {
-    attr1: u8,
-    attr2: String,
-}
-
-impl ToJson for MyStruct {
-    fn to_json( &self ) -> json::Json {
-        let mut d = box TreeMap::new();
-        d.insert("attr1".to_string(), self.attr1.to_json());
-        d.insert("attr2".to_string(), self.attr2.to_json());
-        json::Object(d)
-    }
-}
-
-fn main() {
-    let test2: MyStruct = MyStruct {attr1: 1, attr2:"test".to_string()};
-    let tjson: json::Json = test2.to_json();
-    let json_str: String = tjson.to_str().into_string();
-}
-```
-
-To decode a JSON string using `Decodable` trait :
-
-```rust
-extern crate serialize;
-use serialize::{json, Decodable};
-
-#[deriving(Decodable)]
-pub struct MyStruct  {
-     attr1: u8,
-     attr2: String,
-}
-
-fn main() {
-    let json_str_to_decode: String =
-            "{\"attr1\":1,\"attr2\":\"toto\"}".to_string();
-    let json_object = json::from_str(json_str_to_decode.as_slice());
-    let mut decoder = json::Decoder::new(json_object.unwrap());
-    let decoded_object: MyStruct = match Decodable::decode(&mut decoder) {
-        Ok(v) => v,
-        Err(e) => fail!("Decoding error: {}", e)
-    }; // create the final object
-}
-```
-
 # Examples of use
 
 ## Using Autoserialization
@@ -157,41 +79,37 @@ fn main() {
 
 ```rust
 extern crate serialize;
-use serialize::{json, Encodable, Decodable};
+use serialize::json;
 
- #[deriving(Decodable, Encodable)] //generate Decodable, Encodable impl.
- pub struct TestStruct1  {
+#[deriving(Decodable, Encodable)] //generate Decodable, Encodable impl.
+pub struct TestStruct1  {
     data_int: u8,
     data_str: String,
     data_vector: Vec<u8>,
- }
+}
 
-// To serialize use the `json::str_encode` to encode an object in a string.
-// It calls the generated `Encodable` impl.
 fn main() {
-    let to_encode_object = TestStruct1
+    let object = TestStruct1
          {data_int: 1, data_str:"toto".to_string(), data_vector:vec![2,3,4,5]};
-    let encoded_str: String = json::Encoder::str_encode(&to_encode_object);
 
-    // To deserialize use the `json::from_str` and `json::Decoder`
+    // Serialize using `json::encode`
+    let encoded = json::encode(&object);
 
-    let json_object = json::from_str(encoded_str.as_slice());
-    let mut decoder = json::Decoder::new(json_object.unwrap());
-    let decoded1: TestStruct1 = Decodable::decode(&mut decoder).unwrap(); // create the final object
+    // Deserialize using `json::decode`
+    let decoded: TestStruct1 = json::decode(encoded.as_slice()).unwrap();
 }
 ```
 
 ## Using `ToJson`
 
-This example uses the ToJson impl to deserialize the JSON string.
-Example of `ToJson` trait implementation for TestStruct1.
+This example uses the `ToJson` trait to generate the JSON string.
 
 ```rust
 use std::collections::TreeMap;
 use serialize::json::ToJson;
-use serialize::{json, Encodable, Decodable};
+use serialize::json;
 
-#[deriving(Decodable, Encodable)] // generate Decodable, Encodable impl.
+#[deriving(Decodable)]
 pub struct TestStruct1  {
     data_int: u8,
     data_str: String,
@@ -200,7 +118,7 @@ pub struct TestStruct1  {
 
 impl ToJson for TestStruct1 {
     fn to_json( &self ) -> json::Json {
-        let mut d = box TreeMap::new();
+        let mut d = TreeMap::new();
         d.insert("data_int".to_string(), self.data_int.to_json());
         d.insert("data_str".to_string(), self.data_str.to_json());
         d.insert("data_vector".to_string(), self.data_vector.to_json());
@@ -209,48 +127,38 @@ fn to_json( &self ) -> json::Json {
 }
 
 fn main() {
-    // Serialization using our impl of to_json
-
-    let test2: TestStruct1 = TestStruct1 {data_int: 1, data_str:"toto".to_string(),
-                                          data_vector:vec![2,3,4,5]};
+    // Serialize using `ToJson`
+    let test2 = TestStruct1 {data_int: 1, data_str:"toto".to_string(), data_vector:vec![2,3,4,5]};
     let tjson: json::Json = test2.to_json();
-    let json_str: String = tjson.to_str().into_string();
+    let json_str: String = tjson.to_str();
 
-    // Deserialize like before.
-
-    let mut decoder =
-        json::Decoder::new(json::from_str(json_str.as_slice()).unwrap());
-    // create the final object
-    let decoded2: TestStruct1 = Decodable::decode(&mut decoder).unwrap();
+    // Deserialize like before
+    let decoded: TestStruct1 = json::decode(json_str.as_slice()).unwrap();
 }
 ```
 
 */
 
-use std::char;
+use std;
 use std::collections::{HashMap, TreeMap};
-use std::f64;
-use std::fmt;
+use std::{char, f64, fmt, io, num, str};
 use std::io::MemWriter;
-use std::io;
-use std::mem::{swap,transmute};
+use std::mem::{swap, transmute};
 use std::num::{FPNaN, FPInfinite};
-use std::num;
 use std::str::ScalarValue;
-use std::str;
 use std::string::String;
 use std::vec::Vec;
 
 use Encodable;
 
 /// Represents a json value
-#[deriving(Clone, PartialEq)]
+#[deriving(Clone, PartialEq, PartialOrd)]
 pub enum Json {
     Number(f64),
     String(String),
     Boolean(bool),
     List(List),
-    Object(Box<Object>),
+    Object(Object),
     Null,
 }
 
@@ -318,13 +226,29 @@ pub fn error_str(error: ErrorCode) -> &'static str {
     }
 }
 
+/// Shortcut function to decode a JSON `&str` into an object
+pub fn decode<T: ::Decodable<Decoder, DecoderError>>(s: &str) -> DecodeResult<T> {
+    let json = match from_str(s) {
+        Ok(x) => x,
+        Err(e) => return Err(ParseError(e))
+    };
+
+    let mut decoder = Decoder::new(json);
+    ::Decodable::decode(&mut decoder)
+}
+
+/// Shortcut function to encode a `T` into a JSON `String`
+pub fn encode<'a, T: Encodable<Encoder<'a>, io::IoError>>(object: &T) -> String {
+    let buff = Encoder::buffer_encode(object);
+    str::from_utf8_owned(buff).unwrap()
+}
+
 impl fmt::Show for ErrorCode {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         error_str(*self).fmt(f)
     }
 }
 
-
 fn io_error_to_error(io: io::IoError) -> ParserError {
     IoError(io.kind, io.desc)
 }
@@ -363,41 +287,40 @@ fn spaces(n: uint) -> String {
 
 /// A structure for implementing serialization to JSON.
 pub struct Encoder<'a> {
-    wr: &'a mut io::Writer,
+    writer: &'a mut io::Writer,
 }
 
 impl<'a> Encoder<'a> {
     /// Creates a new JSON encoder whose output will be written to the writer
     /// specified.
-    pub fn new<'a>(wr: &'a mut io::Writer) -> Encoder<'a> {
-        Encoder { wr: wr }
+    pub fn new(writer: &'a mut io::Writer) -> Encoder<'a> {
+        Encoder { writer: writer }
     }
 
     /// Encode the specified struct into a json [u8]
-    pub fn buffer_encode<T:Encodable<Encoder<'a>, io::IoError>>(to_encode_object: &T) -> Vec<u8>  {
-       //Serialize the object in a string using a writer
+    pub fn buffer_encode<T:Encodable<Encoder<'a>, io::IoError>>(object: &T) -> Vec<u8>  {
+        //Serialize the object in a string using a writer
         let mut m = MemWriter::new();
         // FIXME(14302) remove the transmute and unsafe block.
         unsafe {
             let mut encoder = Encoder::new(&mut m as &mut io::Writer);
             // MemWriter never Errs
-            let _ = to_encode_object.encode(transmute(&mut encoder));
+            let _ = object.encode(transmute(&mut encoder));
         }
         m.unwrap()
     }
 
     /// Encode the specified struct into a json str
-    pub fn str_encode<T:Encodable<Encoder<'a>,
-                        io::IoError>>(
-                      to_encode_object: &T)
-                      -> String {
-        let buff = Encoder::buffer_encode(to_encode_object);
-        str::from_utf8(buff.as_slice()).unwrap().to_string()
+    ///
+    /// Note: this function is deprecated. Consider using `json::encode` instead.
+    #[deprecated = "Replaced by `json::encode`"]
+    pub fn str_encode<T: Encodable<Encoder<'a>, io::IoError>>(object: &T) -> String {
+        encode(object)
     }
 }
 
 impl<'a> ::Encoder<io::IoError> for Encoder<'a> {
-    fn emit_nil(&mut self) -> EncodeResult { write!(self.wr, "null") }
+    fn emit_nil(&mut self) -> EncodeResult { write!(self.writer, "null") }
 
     fn emit_uint(&mut self, v: uint) -> EncodeResult { self.emit_f64(v as f64) }
     fn emit_u64(&mut self, v: u64) -> EncodeResult { self.emit_f64(v as f64) }
@@ -413,14 +336,14 @@ fn emit_i8(&mut self, v: i8) -> EncodeResult  { self.emit_f64(v as f64) }
 
     fn emit_bool(&mut self, v: bool) -> EncodeResult {
         if v {
-            write!(self.wr, "true")
+            write!(self.writer, "true")
         } else {
-            write!(self.wr, "false")
+            write!(self.writer, "false")
         }
     }
 
     fn emit_f64(&mut self, v: f64) -> EncodeResult {
-        write!(self.wr, "{}", fmt_number_or_null(v))
+        write!(self.writer, "{}", fmt_number_or_null(v))
     }
     fn emit_f32(&mut self, v: f32) -> EncodeResult { self.emit_f64(v as f64) }
 
@@ -428,12 +351,12 @@ fn emit_char(&mut self, v: char) -> EncodeResult {
         self.emit_str(str::from_char(v).as_slice())
     }
     fn emit_str(&mut self, v: &str) -> EncodeResult {
-        write!(self.wr, "{}", escape_str(v))
+        write!(self.writer, "{}", escape_str(v))
     }
 
-    fn emit_enum(&mut self,
-                 _name: &str,
-                 f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { f(self) }
+    fn emit_enum(&mut self, _name: &str, f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
+        f(self)
+    }
 
     fn emit_enum_variant(&mut self,
                          name: &str,
@@ -444,13 +367,13 @@ fn emit_enum_variant(&mut self,
         // Bunny => "Bunny"
         // Kangaroo(34,"William") => {"variant": "Kangaroo", "fields": [34,"William"]}
         if cnt == 0 {
-            write!(self.wr, "{}", escape_str(name))
+            write!(self.writer, "{}", escape_str(name))
         } else {
-            try!(write!(self.wr, "{{\"variant\":"));
-            try!(write!(self.wr, "{}", escape_str(name)));
-            try!(write!(self.wr, ",\"fields\":["));
+            try!(write!(self.writer, "{{\"variant\":"));
+            try!(write!(self.writer, "{}", escape_str(name)));
+            try!(write!(self.writer, ",\"fields\":["));
             try!(f(self));
-            write!(self.wr, "]}}")
+            write!(self.writer, "]}}")
         }
     }
 
@@ -458,7 +381,7 @@ fn emit_enum_variant_arg(&mut self,
                              idx: uint,
                              f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
         if idx != 0 {
-            try!(write!(self.wr, ","));
+            try!(write!(self.writer, ","));
         }
         f(self)
     }
@@ -482,17 +405,17 @@ fn emit_struct(&mut self,
                    _: &str,
                    _: uint,
                    f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
-        try!(write!(self.wr, "{{"));
+        try!(write!(self.writer, "{{"));
         try!(f(self));
-        write!(self.wr, "}}")
+        write!(self.writer, "}}")
     }
 
     fn emit_struct_field(&mut self,
                          name: &str,
                          idx: uint,
                          f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
-        if idx != 0 { try!(write!(self.wr, ",")); }
-        try!(write!(self.wr, "{}:", escape_str(name)));
+        if idx != 0 { try!(write!(self.writer, ",")); }
+        try!(write!(self.writer, "{}:", escape_str(name)));
         f(self)
     }
 
@@ -526,29 +449,28 @@ fn emit_option_some(&mut self, f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeR
     }
 
     fn emit_seq(&mut self, _len: uint, f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
-        try!(write!(self.wr, "["));
+        try!(write!(self.writer, "["));
         try!(f(self));
-        write!(self.wr, "]")
+        write!(self.writer, "]")
     }
 
     fn emit_seq_elt(&mut self, idx: uint, f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
         if idx != 0 {
-            try!(write!(self.wr, ","));
+            try!(write!(self.writer, ","));
         }
         f(self)
     }
 
     fn emit_map(&mut self, _len: uint, f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
-        try!(write!(self.wr, "{{"));
+        try!(write!(self.writer, "{{"));
         try!(f(self));
-        write!(self.wr, "}}")
+        write!(self.writer, "}}")
     }
 
     fn emit_map_elt_key(&mut self,
                         idx: uint,
                         f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
-        use std::str::from_utf8;
-        if idx != 0 { try!(write!(self.wr, ",")) }
+        if idx != 0 { try!(write!(self.writer, ",")) }
         // ref #12967, make sure to wrap a key in double quotes,
         // in the event that its of a type that omits them (eg numbers)
         let mut buf = MemWriter::new();
@@ -557,20 +479,19 @@ fn emit_map_elt_key(&mut self,
             let mut check_encoder = Encoder::new(&mut buf);
             try!(f(transmute(&mut check_encoder)));
         }
-        let buf = buf.unwrap();
-        let out = from_utf8(buf.as_slice()).unwrap();
-        let needs_wrapping = out.char_at(0) != '"' &&
-            out.char_at_reverse(out.len()) != '"';
-        if needs_wrapping { try!(write!(self.wr, "\"")); }
+        let out = str::from_utf8_owned(buf.unwrap()).unwrap();
+        let out = out.as_slice();
+        let needs_wrapping = out.char_at(0) != '"' && out.char_at_reverse(out.len()) != '"';
+        if needs_wrapping { try!(write!(self.writer, "\"")); }
         try!(f(self));
-        if needs_wrapping { try!(write!(self.wr, "\"")); }
+        if needs_wrapping { try!(write!(self.writer, "\"")); }
         Ok(())
     }
 
     fn emit_map_elt_val(&mut self,
                         _idx: uint,
                         f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
-        try!(write!(self.wr, ":"));
+        try!(write!(self.writer, ":"));
         f(self)
     }
 }
@@ -578,22 +499,19 @@ fn emit_map_elt_val(&mut self,
 /// Another encoder for JSON, but prints out human-readable JSON instead of
 /// compact data
 pub struct PrettyEncoder<'a> {
-    wr: &'a mut io::Writer,
+    writer: &'a mut io::Writer,
     indent: uint,
 }
 
 impl<'a> PrettyEncoder<'a> {
     /// Creates a new encoder whose output will be written to the specified writer
-    pub fn new<'a>(wr: &'a mut io::Writer) -> PrettyEncoder<'a> {
-        PrettyEncoder {
-            wr: wr,
-            indent: 0,
-        }
+    pub fn new<'a>(writer: &'a mut io::Writer) -> PrettyEncoder<'a> {
+        PrettyEncoder { writer: writer, indent: 0 }
     }
 }
 
 impl<'a> ::Encoder<io::IoError> for PrettyEncoder<'a> {
-    fn emit_nil(&mut self) -> EncodeResult { write!(self.wr, "null") }
+    fn emit_nil(&mut self) -> EncodeResult { write!(self.writer, "null") }
 
     fn emit_uint(&mut self, v: uint) -> EncodeResult { self.emit_f64(v as f64) }
     fn emit_u64(&mut self, v: u64) -> EncodeResult { self.emit_f64(v as f64) }
@@ -609,14 +527,14 @@ fn emit_i8(&mut self, v: i8) -> EncodeResult { self.emit_f64(v as f64) }
 
     fn emit_bool(&mut self, v: bool) -> EncodeResult {
         if v {
-            write!(self.wr, "true")
+            write!(self.writer, "true")
         } else {
-            write!(self.wr, "false")
+            write!(self.writer, "false")
         }
     }
 
     fn emit_f64(&mut self, v: f64) -> EncodeResult {
-        write!(self.wr, "{}", fmt_number_or_null(v))
+        write!(self.writer, "{}", fmt_number_or_null(v))
     }
     fn emit_f32(&mut self, v: f32) -> EncodeResult {
         self.emit_f64(v as f64)
@@ -626,7 +544,7 @@ fn emit_char(&mut self, v: char) -> EncodeResult {
         self.emit_str(str::from_char(v).as_slice())
     }
     fn emit_str(&mut self, v: &str) -> EncodeResult {
-        write!(self.wr, "{}", escape_str(v))
+        write!(self.writer, "{}", escape_str(v))
     }
 
     fn emit_enum(&mut self,
@@ -641,14 +559,14 @@ fn emit_enum_variant(&mut self,
                          cnt: uint,
                          f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult {
         if cnt == 0 {
-            write!(self.wr, "{}", escape_str(name))
+            write!(self.writer, "{}", escape_str(name))
         } else {
             self.indent += 2;
-            try!(write!(self.wr, "[\n{}{},\n", spaces(self.indent),
+            try!(write!(self.writer, "[\n{}{},\n", spaces(self.indent),
                           escape_str(name)));
             try!(f(self));
             self.indent -= 2;
-            write!(self.wr, "\n{}]", spaces(self.indent))
+            write!(self.writer, "\n{}]", spaces(self.indent))
         }
     }
 
@@ -656,9 +574,9 @@ fn emit_enum_variant_arg(&mut self,
                              idx: uint,
                              f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult {
         if idx != 0 {
-            try!(write!(self.wr, ",\n"));
+            try!(write!(self.writer, ",\n"));
         }
-        try!(write!(self.wr, "{}", spaces(self.indent)));
+        try!(write!(self.writer, "{}", spaces(self.indent)));
         f(self)
     }
 
@@ -683,13 +601,13 @@ fn emit_struct(&mut self,
                    len: uint,
                    f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult {
         if len == 0 {
-            write!(self.wr, "{{}}")
+            write!(self.writer, "{{}}")
         } else {
-            try!(write!(self.wr, "{{"));
+            try!(write!(self.writer, "{{"));
             self.indent += 2;
             try!(f(self));
             self.indent -= 2;
-            write!(self.wr, "\n{}}}", spaces(self.indent))
+            write!(self.writer, "\n{}}}", spaces(self.indent))
         }
     }
 
@@ -698,11 +616,11 @@ fn emit_struct_field(&mut self,
                          idx: uint,
                          f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult {
         if idx == 0 {
-            try!(write!(self.wr, "\n"));
+            try!(write!(self.writer, "\n"));
         } else {
-            try!(write!(self.wr, ",\n"));
+            try!(write!(self.writer, ",\n"));
         }
-        try!(write!(self.wr, "{}{}: ", spaces(self.indent), escape_str(name)));
+        try!(write!(self.writer, "{}{}: ", spaces(self.indent), escape_str(name)));
         f(self)
     }
 
@@ -741,13 +659,13 @@ fn emit_seq(&mut self,
                 len: uint,
                 f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult {
         if len == 0 {
-            write!(self.wr, "[]")
+            write!(self.writer, "[]")
         } else {
-            try!(write!(self.wr, "["));
+            try!(write!(self.writer, "["));
             self.indent += 2;
             try!(f(self));
             self.indent -= 2;
-            write!(self.wr, "\n{}]", spaces(self.indent))
+            write!(self.writer, "\n{}]", spaces(self.indent))
         }
     }
 
@@ -755,11 +673,11 @@ fn emit_seq_elt(&mut self,
                     idx: uint,
                     f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult {
         if idx == 0 {
-            try!(write!(self.wr, "\n"));
+            try!(write!(self.writer, "\n"));
         } else {
-            try!(write!(self.wr, ",\n"));
+            try!(write!(self.writer, ",\n"));
         }
-        try!(write!(self.wr, "{}", spaces(self.indent)));
+        try!(write!(self.writer, "{}", spaces(self.indent)));
         f(self)
     }
 
@@ -767,26 +685,25 @@ fn emit_map(&mut self,
                 len: uint,
                 f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult {
         if len == 0 {
-            write!(self.wr, "{{}}")
+            write!(self.writer, "{{}}")
         } else {
-            try!(write!(self.wr, "{{"));
+            try!(write!(self.writer, "{{"));
             self.indent += 2;
             try!(f(self));
             self.indent -= 2;
-            write!(self.wr, "\n{}}}", spaces(self.indent))
+            write!(self.writer, "\n{}}}", spaces(self.indent))
         }
     }
 
     fn emit_map_elt_key(&mut self,
                         idx: uint,
                         f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult {
-        use std::str::from_utf8;
         if idx == 0 {
-            try!(write!(self.wr, "\n"));
+            try!(write!(self.writer, "\n"));
         } else {
-            try!(write!(self.wr, ",\n"));
+            try!(write!(self.writer, ",\n"));
         }
-        try!(write!(self.wr, "{}", spaces(self.indent)));
+        try!(write!(self.writer, "{}", spaces(self.indent)));
         // ref #12967, make sure to wrap a key in double quotes,
         // in the event that its of a type that omits them (eg numbers)
         let mut buf = MemWriter::new();
@@ -795,20 +712,19 @@ fn emit_map_elt_key(&mut self,
             let mut check_encoder = PrettyEncoder::new(&mut buf);
             try!(f(transmute(&mut check_encoder)));
         }
-        let buf = buf.unwrap();
-        let out = from_utf8(buf.as_slice()).unwrap();
-        let needs_wrapping = out.char_at(0) != '"' &&
-            out.char_at_reverse(out.len()) != '"';
-        if needs_wrapping { try!(write!(self.wr, "\"")); }
+        let out = str::from_utf8_owned(buf.unwrap()).unwrap();
+        let out = out.as_slice();
+        let needs_wrapping = out.char_at(0) != '"' && out.char_at_reverse(out.len()) != '"';
+        if needs_wrapping { try!(write!(self.writer, "\"")); }
         try!(f(self));
-        if needs_wrapping { try!(write!(self.wr, "\"")); }
+        if needs_wrapping { try!(write!(self.writer, "\"")); }
         Ok(())
     }
 
     fn emit_map_elt_val(&mut self,
                         _idx: uint,
                         f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult {
-        try!(write!(self.wr, ": "));
+        try!(write!(self.writer, ": "));
         f(self)
     }
 }
@@ -827,16 +743,16 @@ fn encode(&self, e: &mut E) -> Result<(), S> {
 }
 
 impl Json {
-    /// Encodes a json value into an io::writer.  Uses a single line.
-    pub fn to_writer(&self, wr: &mut io::Writer) -> EncodeResult {
-        let mut encoder = Encoder::new(wr);
+    /// Encodes a json value into an io::writer. Uses a single line.
+    pub fn to_writer(&self, writer: &mut io::Writer) -> EncodeResult {
+        let mut encoder = Encoder::new(writer);
         self.encode(&mut encoder)
     }
 
     /// Encodes a json value into an io::writer.
     /// Pretty-prints in a more readable format.
-    pub fn to_pretty_writer(&self, wr: &mut io::Writer) -> EncodeResult {
-        let mut encoder = PrettyEncoder::new(wr);
+    pub fn to_pretty_writer(&self, writer: &mut io::Writer) -> EncodeResult {
+        let mut encoder = PrettyEncoder::new(writer);
         self.encode(&mut encoder)
     }
 
@@ -844,7 +760,7 @@ pub fn to_pretty_writer(&self, wr: &mut io::Writer) -> EncodeResult {
     pub fn to_pretty_str(&self) -> String {
         let mut s = MemWriter::new();
         self.to_pretty_writer(&mut s as &mut io::Writer).unwrap();
-        str::from_utf8(s.unwrap().as_slice()).unwrap().to_string()
+        str::from_utf8_owned(s.unwrap()).unwrap()
     }
 
      /// If the Json value is an Object, returns the value associated with the provided key.
@@ -903,7 +819,7 @@ pub fn is_object<'a>(&'a self) -> bool {
     /// Returns None otherwise.
     pub fn as_object<'a>(&'a self) -> Option<&'a Object> {
         match self {
-            &Object(ref map) => Some(&**map),
+            &Object(ref map) => Some(map),
             _ => None
         }
     }
@@ -1038,27 +954,25 @@ enum InternalStackElement {
 
 impl Stack {
     pub fn new() -> Stack {
-        Stack {
-            stack: Vec::new(),
-            str_buffer: Vec::new(),
-        }
+        Stack { stack: Vec::new(), str_buffer: Vec::new() }
     }
 
     /// Returns The number of elements in the Stack.
     pub fn len(&self) -> uint { self.stack.len() }
 
-    /// Returns true if the stack is empty, equivalent to self.len() == 0.
-    pub fn is_empty(&self) -> bool { self.stack.len() == 0 }
+    /// Returns true if the stack is empty.
+    pub fn is_empty(&self) -> bool { self.stack.is_empty() }
 
     /// Provides access to the StackElement at a given index.
     /// lower indices are at the bottom of the stack while higher indices are
     /// at the top.
     pub fn get<'l>(&'l self, idx: uint) -> StackElement<'l> {
-        return match *self.stack.get(idx) {
-          InternalIndex(i) => { Index(i) }
-          InternalKey(start, size) => {
-            Key(str::from_utf8(self.str_buffer.slice(start as uint, (start+size) as uint)).unwrap())
-          }
+        match *self.stack.get(idx) {
+            InternalIndex(i) => { Index(i) }
+            InternalKey(start, size) => {
+                Key(str::from_utf8(
+                    self.str_buffer.slice(start as uint, start as uint + size as uint)).unwrap())
+            }
         }
     }
 
@@ -1124,9 +1038,7 @@ fn pop(&mut self) {
         match *self.stack.last().unwrap() {
             InternalKey(_, sz) => {
                 let new_size = self.str_buffer.len() - sz as uint;
-                unsafe {
-                    self.str_buffer.set_len(new_size);
-                }
+                self.str_buffer.truncate(new_size);
             }
             InternalIndex(_) => {}
         }
@@ -1146,8 +1058,8 @@ fn last_is_index(&self) -> bool {
     fn bump_index(&mut self) {
         let len = self.stack.len();
         let idx = match *self.stack.last().unwrap() {
-          InternalIndex(i) => { i + 1 }
-          _ => { fail!(); }
+            InternalIndex(i) => { i + 1 }
+            _ => { fail!(); }
         };
         *self.stack.get_mut(len - 1) = InternalIndex(idx);
     }
@@ -1249,23 +1161,14 @@ fn parse_number(&mut self) -> Result<f64, ParserError> {
             neg = -1.0;
         }
 
-        let mut res = match self.parse_integer() {
-          Ok(res) => res,
-          Err(e) => return Err(e)
-        };
+        let mut res = try!(self.parse_integer());
 
         if self.ch_is('.') {
-            match self.parse_decimal(res) {
-              Ok(r) => res = r,
-              Err(e) => return Err(e)
-            }
+            res = try!(self.parse_decimal(res));
         }
 
         if self.ch_is('e') || self.ch_is('E') {
-            match self.parse_exponent(res) {
-              Ok(r) => res = r,
-              Err(e) => return Err(e)
-            }
+            res = try!(self.parse_exponent(res));
         }
 
         Ok(neg * res)
@@ -1301,7 +1204,7 @@ fn parse_integer(&mut self) -> Result<f64, ParserError> {
         Ok(res)
     }
 
-    fn parse_decimal(&mut self, res: f64) -> Result<f64, ParserError> {
+    fn parse_decimal(&mut self, mut res: f64) -> Result<f64, ParserError> {
         self.bump();
 
         // Make sure a digit follows the decimal place.
@@ -1310,7 +1213,6 @@ fn parse_decimal(&mut self, res: f64) -> Result<f64, ParserError> {
              _ => return self.error(InvalidNumber)
         }
 
-        let mut res = res;
         let mut dec = 1.0;
         while !self.eof() {
             match self.ch_or_null() {
@@ -1356,7 +1258,7 @@ fn parse_exponent(&mut self, mut res: f64) -> Result<f64, ParserError> {
             }
         }
 
-        let exp: f64 = num::pow(10u as f64, exp);
+        let exp = num::pow(10_f64, exp);
         if neg_exp {
             res /= exp;
         } else {
@@ -1369,16 +1271,16 @@ fn parse_exponent(&mut self, mut res: f64) -> Result<f64, ParserError> {
     fn decode_hex_escape(&mut self) -> Result<u16, ParserError> {
         let mut i = 0u;
         let mut n = 0u16;
-        while i < 4u && !self.eof() {
+        while i < 4 && !self.eof() {
             self.bump();
             n = match self.ch_or_null() {
-                c @ '0' .. '9' => n * 16_u16 + ((c as u16) - ('0' as u16)),
-                'a' | 'A' => n * 16_u16 + 10_u16,
-                'b' | 'B' => n * 16_u16 + 11_u16,
-                'c' | 'C' => n * 16_u16 + 12_u16,
-                'd' | 'D' => n * 16_u16 + 13_u16,
-                'e' | 'E' => n * 16_u16 + 14_u16,
-                'f' | 'F' => n * 16_u16 + 15_u16,
+                c @ '0' .. '9' => n * 16 + ((c as u16) - ('0' as u16)),
+                'a' | 'A' => n * 16 + 10,
+                'b' | 'B' => n * 16 + 11,
+                'c' | 'C' => n * 16 + 12,
+                'd' | 'D' => n * 16 + 13,
+                'e' | 'E' => n * 16 + 14,
+                'f' | 'F' => n * 16 + 15,
                 _ => return self.error(InvalidEscape)
             };
 
@@ -1386,7 +1288,7 @@ fn decode_hex_escape(&mut self) -> Result<u16, ParserError> {
         }
 
         // Error out if we didn't parse 4 digits.
-        if i != 4u {
+        if i != 4 {
             return self.error(InvalidEscape);
         }
 
@@ -1419,9 +1321,7 @@ fn parse_str(&mut self) -> Result<String, ParserError> {
                         // Non-BMP characters are encoded as a sequence of
                         // two hex escapes, representing UTF-16 surrogates.
                         n1 @ 0xD800 .. 0xDBFF => {
-                            let c1 = self.next_char();
-                            let c2 = self.next_char();
-                            match (c1, c2) {
+                            match (self.next_char(), self.next_char()) {
                                 (Some('\\'), Some('u')) => (),
                                 _ => return self.error(UnexpectedEndOfHexEscape),
                             }
@@ -1636,37 +1536,37 @@ fn parse_object_end(&mut self) -> JsonEvent {
                 }
             }
             self.bump();
-            return ObjectEnd;
+            ObjectEnd
         } else if self.eof() {
-            return self.error_event(EOFWhileParsingObject);
+            self.error_event(EOFWhileParsingObject)
         } else {
-            return self.error_event(InvalidSyntax);
+            self.error_event(InvalidSyntax)
         }
     }
 
     fn parse_value(&mut self) -> JsonEvent {
         if self.eof() { return self.error_event(EOFWhileParsingValue); }
         match self.ch_or_null() {
-            'n' => { return self.parse_ident("ull", NullValue); }
-            't' => { return self.parse_ident("rue", BooleanValue(true)); }
-            'f' => { return self.parse_ident("alse", BooleanValue(false)); }
-            '0' .. '9' | '-' => return match self.parse_number() {
+            'n' => { self.parse_ident("ull", NullValue) }
+            't' => { self.parse_ident("rue", BooleanValue(true)) }
+            'f' => { self.parse_ident("alse", BooleanValue(false)) }
+            '0' .. '9' | '-' => match self.parse_number() {
                 Ok(f) => NumberValue(f),
                 Err(e) => Error(e),
             },
-            '"' => return match self.parse_str() {
+            '"' => match self.parse_str() {
                 Ok(s) => StringValue(s),
                 Err(e) => Error(e),
             },
             '[' => {
                 self.bump();
-                return ListStart;
+                ListStart
             }
             '{' => {
                 self.bump();
-                return ObjectStart;
+                ObjectStart
             }
-            _ => { return self.error_event(InvalidSyntax); }
+            _ => { self.error_event(InvalidSyntax) }
         }
     }
 
@@ -1694,10 +1594,7 @@ pub struct Builder<T> {
 impl<T: Iterator<char>> Builder<T> {
     /// Create a JSON Builder.
     pub fn new(src: T) -> Builder<T> {
-        Builder {
-            parser: Parser::new(src),
-            token: None,
-        }
+        Builder { parser: Parser::new(src), token: None, }
     }
 
     // Decode a Json value from a Parser.
@@ -1710,7 +1607,7 @@ pub fn build(&mut self) -> Result<Json, BuilderError> {
             Some(Error(e)) => { return Err(e); }
             ref tok => { fail!("unexpected token {}", tok.clone()); }
         }
-        return result;
+        result
     }
 
     fn bump(&mut self) {
@@ -1755,9 +1652,9 @@ fn build_list(&mut self) -> Result<Json, BuilderError> {
     fn build_object(&mut self) -> Result<Json, BuilderError> {
         self.bump();
 
-        let mut values = box TreeMap::new();
+        let mut values = TreeMap::new();
 
-        while self.token != None {
+        loop {
             match self.token {
                 Some(ObjectEnd) => { return Ok(Object(values)); }
                 Some(Error(e)) => { return Err(e); }
@@ -1778,16 +1675,15 @@ fn build_object(&mut self) -> Result<Json, BuilderError> {
     }
 }
 
-
 /// Decodes a json value from an `&mut io::Reader`
 pub fn from_reader(rdr: &mut io::Reader) -> Result<Json, BuilderError> {
     let contents = match rdr.read_to_end() {
         Ok(c) => c,
         Err(e) => return Err(io_error_to_error(e))
     };
-    let s = match str::from_utf8(contents.as_slice()) {
-        Some(s) => s.to_string(),
-        None => return Err(SyntaxError(NotUtf8, 0, 0))
+    let s = match str::from_utf8_owned(contents) {
+        Ok(s) => s,
+        _ => return Err(SyntaxError(NotUtf8, 0, 0))
     };
     let mut builder = Builder::new(s.as_slice().chars());
     builder.build()
@@ -1796,7 +1692,7 @@ pub fn from_reader(rdr: &mut io::Reader) -> Result<Json, BuilderError> {
 /// Decodes a json value from a string
 pub fn from_str(s: &str) -> Result<Json, BuilderError> {
     let mut builder = Builder::new(s.chars());
-    return builder.build();
+    builder.build()
 }
 
 /// A structure to decode JSON to values in rust.
@@ -1807,9 +1703,7 @@ pub struct Decoder {
 impl Decoder {
     /// Creates a new decoder instance for decoding the specified JSON value.
     pub fn new(json: Json) -> Decoder {
-        Decoder {
-            stack: vec!(json),
-        }
+        Decoder { stack: vec![json] }
     }
 }
 
@@ -1841,8 +1735,7 @@ macro_rules! expect(
 impl ::Decoder<DecoderError> for Decoder {
     fn read_nil(&mut self) -> DecodeResult<()> {
         debug!("read_nil");
-        try!(expect!(self.pop(), Null));
-        Ok(())
+        expect!(self.pop(), Null)
     }
 
     fn read_u64(&mut self)  -> DecodeResult<u64 > { Ok(try!(self.read_f64()) as u64) }
@@ -1859,28 +1752,24 @@ fn read_int(&mut self) -> DecodeResult<int> { Ok(try!(self.read_f64()) as int) }
 
     fn read_bool(&mut self) -> DecodeResult<bool> {
         debug!("read_bool");
-        Ok(try!(expect!(self.pop(), Boolean)))
+        expect!(self.pop(), Boolean)
     }
 
     fn read_f64(&mut self) -> DecodeResult<f64> {
-        use std::from_str::FromStr;
         debug!("read_f64");
         match self.pop() {
             Number(f) => Ok(f),
             String(s) => {
                 // re: #12967.. a type w/ numeric keys (ie HashMap<uint, V> etc)
-                // is going to have a string here, as per JSON spec..
-                Ok(FromStr::from_str(s.as_slice()).unwrap())
+                // is going to have a string here, as per JSON spec.
+                Ok(std::from_str::from_str(s.as_slice()).unwrap())
             },
             Null => Ok(f64::NAN),
-            value => {
-                Err(ExpectedError("Number".to_string(),
-                                  format!("{}", value)))
-            }
+            value => Err(ExpectedError("Number".to_string(), format!("{}", value)))
         }
     }
 
-    fn read_f32(&mut self) -> DecodeResult<f32> { Ok(try!(self.read_f64()) as f32) }
+    fn read_f32(&mut self) -> DecodeResult<f32> { self.read_f64().map(|x| x as f32) }
 
     fn read_char(&mut self) -> DecodeResult<char> {
         let s = try!(self.read_str());
@@ -1892,13 +1781,12 @@ fn read_char(&mut self) -> DecodeResult<char> {
                 _ => ()
             }
         }
-        Err(ExpectedError("single character string".to_string(),
-                          format!("{}", s)))
+        Err(ExpectedError("single character string".to_string(), format!("{}", s)))
     }
 
     fn read_str(&mut self) -> DecodeResult<String> {
         debug!("read_str");
-        Ok(try!(expect!(self.pop(), String)))
+        expect!(self.pop(), String)
     }
 
     fn read_enum<T>(&mut self,
@@ -1919,8 +1807,7 @@ fn read_enum_variant<T>(&mut self,
                 let n = match o.pop(&"variant".to_string()) {
                     Some(String(s)) => s,
                     Some(val) => {
-                        return Err(ExpectedError("String".to_string(),
-                                                 format!("{}", val)))
+                        return Err(ExpectedError("String".to_string(), format!("{}", val)))
                     }
                     None => {
                         return Err(MissingFieldError("variant".to_string()))
@@ -1929,12 +1816,11 @@ fn read_enum_variant<T>(&mut self,
                 match o.pop(&"fields".to_string()) {
                     Some(List(l)) => {
                         for field in l.move_iter().rev() {
-                            self.stack.push(field.clone());
+                            self.stack.push(field);
                         }
                     },
                     Some(val) => {
-                        return Err(ExpectedError("List".to_string(),
-                                                 format!("{}", val)))
+                        return Err(ExpectedError("List".to_string(), format!("{}", val)))
                     }
                     None => {
                         return Err(MissingFieldError("fields".to_string()))
@@ -1943,14 +1829,11 @@ fn read_enum_variant<T>(&mut self,
                 n
             }
             json => {
-                return Err(ExpectedError("String or Object".to_string(),
-                                         format!("{}", json)))
+                return Err(ExpectedError("String or Object".to_string(), format!("{}", json)))
             }
         };
         let idx = match names.iter()
-                             .position(|n| {
-                                 str::eq_slice(*n, name.as_slice())
-                             }) {
+                             .position(|n| str::eq_slice(*n, name.as_slice())) {
             Some(idx) => idx,
             None => return Err(UnknownVariantError(name))
         };
@@ -2087,110 +1970,24 @@ fn read_map_elt_val<T>(&mut self, idx: uint, f: |&mut Decoder| -> DecodeResult<T
     }
 }
 
-/// Test if two json values are less than one another
-impl PartialOrd for Json {
-    fn lt(&self, other: &Json) -> bool {
-        match *self {
-            Number(f0) => {
-                match *other {
-                    Number(f1) => f0 < f1,
-                    String(_) | Boolean(_) | List(_) | Object(_) |
-                    Null => true
-                }
-            }
-
-            String(ref s0) => {
-                match *other {
-                    Number(_) => false,
-                    String(ref s1) => s0 < s1,
-                    Boolean(_) | List(_) | Object(_) | Null => true
-                }
-            }
-
-            Boolean(b0) => {
-                match *other {
-                    Number(_) | String(_) => false,
-                    Boolean(b1) => b0 < b1,
-                    List(_) | Object(_) | Null => true
-                }
-            }
-
-            List(ref l0) => {
-                match *other {
-                    Number(_) | String(_) | Boolean(_) => false,
-                    List(ref l1) => (*l0) < (*l1),
-                    Object(_) | Null => true
-                }
-            }
-
-            Object(ref d0) => {
-                match *other {
-                    Number(_) | String(_) | Boolean(_) | List(_) => false,
-                    Object(ref d1) => d0 < d1,
-                    Null => true
-                }
-            }
-
-            Null => {
-                match *other {
-                    Number(_) | String(_) | Boolean(_) | List(_) |
-                    Object(_) =>
-                        false,
-                    Null => true
-                }
-            }
-        }
-    }
-}
-
 /// A trait for converting values to JSON
 pub trait ToJson {
     /// Converts the value of `self` to an instance of JSON
     fn to_json(&self) -> Json;
 }
 
-impl ToJson for Json {
-    fn to_json(&self) -> Json { (*self).clone() }
-}
-
-impl ToJson for int {
-    fn to_json(&self) -> Json { Number(*self as f64) }
-}
-
-impl ToJson for i8 {
-    fn to_json(&self) -> Json { Number(*self as f64) }
-}
-
-impl ToJson for i16 {
-    fn to_json(&self) -> Json { Number(*self as f64) }
-}
-
-impl ToJson for i32 {
-    fn to_json(&self) -> Json { Number(*self as f64) }
-}
-
-impl ToJson for i64 {
-    fn to_json(&self) -> Json { Number(*self as f64) }
-}
-
-impl ToJson for uint {
-    fn to_json(&self) -> Json { Number(*self as f64) }
-}
-
-impl ToJson for u8 {
-    fn to_json(&self) -> Json { Number(*self as f64) }
-}
+macro_rules! to_json_impl(
+    ($($t:ty), +) => (
+        $(impl ToJson for $t {
+            fn to_json(&self) -> Json { Number(*self as f64) }
+        })+
+    )
+)
 
-impl ToJson for u16 {
-    fn to_json(&self) -> Json { Number(*self as f64) }
-}
+to_json_impl!(int, i8, i16, i32, i64, uint, u8, u16, u32, u64)
 
-impl ToJson for u32 {
-    fn to_json(&self) -> Json { Number(*self as f64) }
-}
-
-impl ToJson for u64 {
-    fn to_json(&self) -> Json { Number(*self as f64) }
+impl ToJson for Json {
+    fn to_json(&self) -> Json { self.clone() }
 }
 
 impl ToJson for f32 {
@@ -2201,7 +1998,7 @@ impl ToJson for f64 {
     fn to_json(&self) -> Json {
         match self.classify() {
             FPNaN | FPInfinite => Null,
-            _ => Number(*self)
+            _                  => Number(*self)
         }
     }
 }
@@ -2218,59 +2015,71 @@ impl ToJson for String {
     fn to_json(&self) -> Json { String((*self).clone()) }
 }
 
-impl<A:ToJson,B:ToJson> ToJson for (A, B) {
-    fn to_json(&self) -> Json {
-        match *self {
-          (ref a, ref b) => {
-            List(vec![a.to_json(), b.to_json()])
-          }
-        }
-    }
-}
+macro_rules! tuple_impl {
+    // use variables to indicate the arity of the tuple
+    ($($tyvar:ident),* ) => {
+        // the trailing commas are for the 1 tuple
+        impl<
+            $( $tyvar : ToJson ),*
+            > ToJson for ( $( $tyvar ),* , ) {
 
-impl<A:ToJson,B:ToJson,C:ToJson> ToJson for (A, B, C) {
-    fn to_json(&self) -> Json {
-        match *self {
-          (ref a, ref b, ref c) => {
-            List(vec![a.to_json(), b.to_json(), c.to_json()])
-          }
+            #[inline]
+            #[allow(uppercase_variables)]
+            fn to_json(&self) -> Json {
+                match *self {
+                    ($(ref $tyvar),*,) => List(vec![$($tyvar.to_json()),*])
+                }
+            }
         }
     }
 }
 
-impl<'a, A:ToJson> ToJson for &'a [A] {
+tuple_impl!{A}
+tuple_impl!{A, B}
+tuple_impl!{A, B, C}
+tuple_impl!{A, B, C, D}
+tuple_impl!{A, B, C, D, E}
+tuple_impl!{A, B, C, D, E, F}
+tuple_impl!{A, B, C, D, E, F, G}
+tuple_impl!{A, B, C, D, E, F, G, H}
+tuple_impl!{A, B, C, D, E, F, G, H, I}
+tuple_impl!{A, B, C, D, E, F, G, H, I, J}
+tuple_impl!{A, B, C, D, E, F, G, H, I, J, K}
+tuple_impl!{A, B, C, D, E, F, G, H, I, J, K, L}
+
+impl<'a, A: ToJson> ToJson for &'a [A] {
     fn to_json(&self) -> Json { List(self.iter().map(|elt| elt.to_json()).collect()) }
 }
 
-impl<A:ToJson> ToJson for Vec<A> {
+impl<A: ToJson> ToJson for Vec<A> {
     fn to_json(&self) -> Json { List(self.iter().map(|elt| elt.to_json()).collect()) }
 }
 
-impl<A:ToJson> ToJson for TreeMap<String, A> {
+impl<A: ToJson> ToJson for TreeMap<String, A> {
     fn to_json(&self) -> Json {
         let mut d = TreeMap::new();
         for (key, value) in self.iter() {
             d.insert((*key).clone(), value.to_json());
         }
-        Object(box d)
+        Object(d)
     }
 }
 
-impl<A:ToJson> ToJson for HashMap<String, A> {
+impl<A: ToJson> ToJson for HashMap<String, A> {
     fn to_json(&self) -> Json {
         let mut d = TreeMap::new();
         for (key, value) in self.iter() {
             d.insert((*key).clone(), value.to_json());
         }
-        Object(box d)
+        Object(d)
     }
 }
 
 impl<A:ToJson> ToJson for Option<A> {
     fn to_json(&self) -> Json {
         match *self {
-          None => Null,
-          Some(ref value) => value.to_json()
+            None => Null,
+            Some(ref value) => value.to_json()
         }
     }
 }
@@ -2282,6 +2091,12 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+impl std::from_str::FromStr for Json {
+    fn from_str(s: &str) -> Option<Json> {
+        from_str(s).ok()
+    }
+}
+
 #[cfg(test)]
 mod tests {
     extern crate test;
@@ -2296,9 +2111,7 @@ mod tests {
                 InvalidSyntax, InvalidNumber, EOFWhileParsingObject, EOFWhileParsingList,
                 EOFWhileParsingValue, EOFWhileParsingString, KeyMustBeAString, ExpectedColon,
                 TrailingCharacters};
-    use std::f32;
-    use std::f64;
-    use std::io;
+    use std::{f32, f64, io};
     use std::collections::TreeMap;
 
     #[deriving(PartialEq, Encodable, Decodable, Show)]
@@ -2320,7 +2133,7 @@ struct Outer {
     }
 
     fn mk_object(items: &[(String, Json)]) -> Json {
-        let mut d = box TreeMap::new();
+        let mut d = TreeMap::new();
 
         for item in items.iter() {
             match *item {
@@ -2331,6 +2144,12 @@ fn mk_object(items: &[(String, Json)]) -> Json {
         Object(d)
     }
 
+    #[test]
+    fn test_from_str_trait() {
+        let s = "null";
+        assert!(::std::from_str::from_str::<Json>(s).unwrap() == from_str(s).unwrap());
+    }
+
     #[test]
     fn test_write_null() {
         assert_eq!(Null.to_str().into_string(), "null".to_string());
@@ -2493,15 +2312,15 @@ fn with_str_writer(f: |&mut io::Writer|) -> String {
     fn test_write_enum() {
         let animal = Dog;
         assert_eq!(
-            with_str_writer(|wr| {
-                let mut encoder = Encoder::new(wr);
+            with_str_writer(|writer| {
+                let mut encoder = Encoder::new(writer);
                 animal.encode(&mut encoder).unwrap();
             }),
             "\"Dog\"".to_string()
         );
         assert_eq!(
-            with_str_writer(|wr| {
-                let mut encoder = PrettyEncoder::new(wr);
+            with_str_writer(|writer| {
+                let mut encoder = PrettyEncoder::new(writer);
                 animal.encode(&mut encoder).unwrap();
             }),
             "\"Dog\"".to_string()
@@ -2509,15 +2328,15 @@ fn test_write_enum() {
 
         let animal = Frog("Henry".to_string(), 349);
         assert_eq!(
-            with_str_writer(|wr| {
-                let mut encoder = Encoder::new(wr);
+            with_str_writer(|writer| {
+                let mut encoder = Encoder::new(writer);
                 animal.encode(&mut encoder).unwrap();
             }),
             "{\"variant\":\"Frog\",\"fields\":[\"Henry\",349]}".to_string()
         );
         assert_eq!(
-            with_str_writer(|wr| {
-                let mut encoder = PrettyEncoder::new(wr);
+            with_str_writer(|writer| {
+                let mut encoder = PrettyEncoder::new(writer);
                 animal.encode(&mut encoder).unwrap();
             }),
             "\
@@ -2532,15 +2351,15 @@ fn test_write_enum() {
     #[test]
     fn test_write_some() {
         let value = Some("jodhpurs".to_string());
-        let s = with_str_writer(|wr| {
-            let mut encoder = Encoder::new(wr);
+        let s = with_str_writer(|writer| {
+            let mut encoder = Encoder::new(writer);
             value.encode(&mut encoder).unwrap();
         });
         assert_eq!(s, "\"jodhpurs\"".to_string());
 
         let value = Some("jodhpurs".to_string());
-        let s = with_str_writer(|wr| {
-            let mut encoder = PrettyEncoder::new(wr);
+        let s = with_str_writer(|writer| {
+            let mut encoder = PrettyEncoder::new(writer);
             value.encode(&mut encoder).unwrap();
         });
         assert_eq!(s, "\"jodhpurs\"".to_string());
@@ -2549,14 +2368,14 @@ fn test_write_some() {
     #[test]
     fn test_write_none() {
         let value: Option<String> = None;
-        let s = with_str_writer(|wr| {
-            let mut encoder = Encoder::new(wr);
+        let s = with_str_writer(|writer| {
+            let mut encoder = Encoder::new(writer);
             value.encode(&mut encoder).unwrap();
         });
         assert_eq!(s, "null".to_string());
 
-        let s = with_str_writer(|wr| {
-            let mut encoder = Encoder::new(wr);
+        let s = with_str_writer(|writer| {
+            let mut encoder = Encoder::new(writer);
             value.encode(&mut encoder).unwrap();
         });
         assert_eq!(s, "null".to_string());
@@ -2591,16 +2410,13 @@ fn test_read_identifiers() {
 
     #[test]
     fn test_decode_identifiers() {
-        let mut decoder = Decoder::new(from_str("null").unwrap());
-        let v: () = Decodable::decode(&mut decoder).unwrap();
+        let v: () = super::decode("null").unwrap();
         assert_eq!(v, ());
 
-        let mut decoder = Decoder::new(from_str("true").unwrap());
-        let v: bool = Decodable::decode(&mut decoder).unwrap();
+        let v: bool = super::decode("true").unwrap();
         assert_eq!(v, true);
 
-        let mut decoder = Decoder::new(from_str("false").unwrap());
-        let v: bool = Decodable::decode(&mut decoder).unwrap();
+        let v: bool = super::decode("false").unwrap();
         assert_eq!(v, false);
     }
 
@@ -2627,32 +2443,25 @@ fn test_read_number() {
 
     #[test]
     fn test_decode_numbers() {
-        let mut decoder = Decoder::new(from_str("3").unwrap());
-        let v: f64 = Decodable::decode(&mut decoder).unwrap();
+        let v: f64 = super::decode("3").unwrap();
         assert_eq!(v, 3.0);
 
-        let mut decoder = Decoder::new(from_str("3.1").unwrap());
-        let v: f64 = Decodable::decode(&mut decoder).unwrap();
+        let v: f64 = super::decode("3.1").unwrap();
         assert_eq!(v, 3.1);
 
-        let mut decoder = Decoder::new(from_str("-1.2").unwrap());
-        let v: f64 = Decodable::decode(&mut decoder).unwrap();
+        let v: f64 = super::decode("-1.2").unwrap();
         assert_eq!(v, -1.2);
 
-        let mut decoder = Decoder::new(from_str("0.4").unwrap());
-        let v: f64 = Decodable::decode(&mut decoder).unwrap();
+        let v: f64 = super::decode("0.4").unwrap();
         assert_eq!(v, 0.4);
 
-        let mut decoder = Decoder::new(from_str("0.4e5").unwrap());
-        let v: f64 = Decodable::decode(&mut decoder).unwrap();
+        let v: f64 = super::decode("0.4e5").unwrap();
         assert_eq!(v, 0.4e5);
 
-        let mut decoder = Decoder::new(from_str("0.4e15").unwrap());
-        let v: f64 = Decodable::decode(&mut decoder).unwrap();
+        let v: f64 = super::decode("0.4e15").unwrap();
         assert_eq!(v, 0.4e15);
 
-        let mut decoder = Decoder::new(from_str("0.4e-01").unwrap());
-        let v: f64 = Decodable::decode(&mut decoder).unwrap();
+        let v: f64 = super::decode("0.4e-01").unwrap();
         assert_eq!(v, 0.4e-01);
     }
 
@@ -2686,13 +2495,8 @@ fn test_decode_str() {
                  ("\"\\uAB12\"", "\uAB12")];
 
         for &(i, o) in s.iter() {
-            let mut decoder = Decoder::new(from_str(i).unwrap());
-            let v: String = Decodable::decode(&mut decoder).unwrap();
+            let v: String = super::decode(i).unwrap();
             assert_eq!(v.as_slice(), o);
-
-            let mut decoder = Decoder::new(from_str(i).unwrap());
-            let v: String = Decodable::decode(&mut decoder).unwrap();
-            assert_eq!(v, o.to_string());
         }
     }
 
@@ -2719,28 +2523,19 @@ fn test_read_list() {
 
     #[test]
     fn test_decode_list() {
-        let mut decoder = Decoder::new(from_str("[]").unwrap());
-        let v: Vec<()> = Decodable::decode(&mut decoder).unwrap();
+        let v: Vec<()> = super::decode("[]").unwrap();
         assert_eq!(v, vec![]);
 
-        let mut decoder = Decoder::new(from_str("[null]").unwrap());
-        let v: Vec<()> = Decodable::decode(&mut decoder).unwrap();
+        let v: Vec<()> = super::decode("[null]").unwrap();
         assert_eq!(v, vec![()]);
 
-        let mut decoder = Decoder::new(from_str("[true]").unwrap());
-        let v: Vec<bool> = Decodable::decode(&mut decoder).unwrap();
-        assert_eq!(v, vec![true]);
-
-        let mut decoder = Decoder::new(from_str("[true]").unwrap());
-        let v: Vec<bool> = Decodable::decode(&mut decoder).unwrap();
+        let v: Vec<bool> = super::decode("[true]").unwrap();
         assert_eq!(v, vec![true]);
 
-        let mut decoder = Decoder::new(from_str("[3, 1]").unwrap());
-        let v: Vec<int> = Decodable::decode(&mut decoder).unwrap();
+        let v: Vec<int> = super::decode("[3, 1]").unwrap();
         assert_eq!(v, vec![3, 1]);
 
-        let mut decoder = Decoder::new(from_str("[[3], [1, 2]]").unwrap());
-        let v: Vec<Vec<uint>> = Decodable::decode(&mut decoder).unwrap();
+        let v: Vec<Vec<uint>> = super::decode("[[3], [1, 2]]").unwrap();
         assert_eq!(v, vec![vec![3], vec![1, 2]]);
     }
 
@@ -2806,8 +2601,8 @@ fn test_decode_struct() {
                 { \"a\": null, \"b\": 2, \"c\": [\"abc\", \"xyz\"] }
             ]
         }";
-        let mut decoder = Decoder::new(from_str(s).unwrap());
-        let v: Outer = Decodable::decode(&mut decoder).unwrap();
+
+        let v: Outer = super::decode(s).unwrap();
         assert_eq!(
             v,
             Outer {
@@ -2825,35 +2620,29 @@ struct FloatStruct {
     }
     #[test]
     fn test_decode_struct_with_nan() {
-        let encoded_str = "{\"f\":null,\"a\":[null,123]}";
-        let json_object = from_str(encoded_str.as_slice());
-        let mut decoder = Decoder::new(json_object.unwrap());
-        let after: FloatStruct = Decodable::decode(&mut decoder).unwrap();
-        assert!(after.f.is_nan());
-        assert!(after.a.get(0).is_nan());
-        assert_eq!(after.a.get(1), &123f64);
+        let s = "{\"f\":null,\"a\":[null,123]}";
+        let obj: FloatStruct = super::decode(s).unwrap();
+        assert!(obj.f.is_nan());
+        assert!(obj.a.get(0).is_nan());
+        assert_eq!(obj.a.get(1), &123f64);
     }
 
     #[test]
     fn test_decode_option() {
-        let mut decoder = Decoder::new(from_str("null").unwrap());
-        let value: Option<String> = Decodable::decode(&mut decoder).unwrap();
+        let value: Option<String> = super::decode("null").unwrap();
         assert_eq!(value, None);
 
-        let mut decoder = Decoder::new(from_str("\"jodhpurs\"").unwrap());
-        let value: Option<String> = Decodable::decode(&mut decoder).unwrap();
+        let value: Option<String> = super::decode("\"jodhpurs\"").unwrap();
         assert_eq!(value, Some("jodhpurs".to_string()));
     }
 
     #[test]
     fn test_decode_enum() {
-        let mut decoder = Decoder::new(from_str("\"Dog\"").unwrap());
-        let value: Animal = Decodable::decode(&mut decoder).unwrap();
+        let value: Animal = super::decode("\"Dog\"").unwrap();
         assert_eq!(value, Dog);
 
         let s = "{\"variant\":\"Frog\",\"fields\":[\"Henry\",349]}";
-        let mut decoder = Decoder::new(from_str(s).unwrap());
-        let value: Animal = Decodable::decode(&mut decoder).unwrap();
+        let value: Animal = super::decode(s).unwrap();
         assert_eq!(value, Frog("Henry".to_string(), 349));
     }
 
@@ -2861,8 +2650,7 @@ fn test_decode_enum() {
     fn test_decode_map() {
         let s = "{\"a\": \"Dog\", \"b\": {\"variant\":\"Frog\",\
                   \"fields\":[\"Henry\", 349]}}";
-        let mut decoder = Decoder::new(from_str(s).unwrap());
-        let mut map: TreeMap<String, Animal> = Decodable::decode(&mut decoder).unwrap();
+        let mut map: TreeMap<String, Animal> = super::decode(s).unwrap();
 
         assert_eq!(map.pop(&"a".to_string()), Some(Dog));
         assert_eq!(map.pop(&"b".to_string()), Some(Frog("Henry".to_string(), 349)));
@@ -3387,7 +3175,7 @@ fn test_to_json() {
             let mut tree_map = TreeMap::new();
             tree_map.insert("a".to_string(), Number(1.0_f64));
             tree_map.insert("b".to_string(), Number(2.0_f64));
-            Object(box tree_map)
+            Object(tree_map)
         };
 
         assert_eq!(list2.to_json(), list2);
@@ -3424,7 +3212,7 @@ fn test_to_json() {
         hash_map.insert("a".to_string(), 1i);
         hash_map.insert("b".to_string(), 2);
         assert_eq!(hash_map.to_json(), object);
-        assert_eq!(Some(15i).to_json(), Number(15 as f64));
+        assert_eq!(Some(15i).to_json(), Number(15f64));
         assert_eq!(None::<int>.to_json(), Null);
     }
 
index ec2cc67a60a16a53f92e7fd5c715e72cdf10516a..728875ce2601012f3d25b645de37fddae4212a36 100644 (file)
@@ -281,19 +281,22 @@ fn dlsym(handle: *mut libc::c_void,
 #[cfg(target_os = "win32")]
 pub mod dl {
     use c_str::ToCStr;
+    use iter::Iterator;
     use libc;
     use os;
     use ptr;
     use result::{Ok, Err, Result};
-    use str::StrAllocating;
+    use str::StrSlice;
     use str;
     use string::String;
+    use vec::Vec;
 
     pub unsafe fn open_external<T: ToCStr>(filename: T) -> *mut u8 {
         // Windows expects Unicode data
         let filename_cstr = filename.to_c_str();
         let filename_str = str::from_utf8(filename_cstr.as_bytes_no_nul()).unwrap();
-        let filename_str = filename_str.to_utf16().append_one(0);
+        let filename_str: Vec<u16> = filename_str.utf16_units().collect();
+        let filename_str = filename_str.append_one(0);
         LoadLibraryW(filename_str.as_ptr() as *const libc::c_void) as *mut u8
     }
 
index 363c577563e8c8fad90346ad632cc5395c05c5de..80f1cbe6cb29e3bcdc07836c4c347bebef525f7d 100644 (file)
@@ -24,6 +24,7 @@
 use fmt;
 use hash;
 use kinds::marker;
+use option::Option;
 use ops::Deref;
 use raw;
 
@@ -58,6 +59,10 @@ fn eq(&self, other: &Gc<T>) -> bool { *(*self) == *(*other) }
     fn ne(&self, other: &Gc<T>) -> bool { *(*self) != *(*other) }
 }
 impl<T: PartialOrd + 'static> PartialOrd for Gc<T> {
+    #[inline]
+    fn partial_cmp(&self, other: &Gc<T>) -> Option<Ordering> {
+        (**self).partial_cmp(&**other)
+    }
     #[inline]
     fn lt(&self, other: &Gc<T>) -> bool { *(*self) < *(*other) }
     #[inline]
@@ -103,6 +108,13 @@ mod tests {
     use super::*;
     use cell::RefCell;
 
+    #[test]
+    fn test_managed_clone() {
+        let a = box(GC) 5i;
+        let b: Gc<int> = a.clone();
+        assert!(a == b);
+    }
+
     #[test]
     fn test_clone() {
         let x = Gc::new(RefCell::new(5));
index d8e04f1823938a4a900ce718599ff216d0dd3d86..bc8447dfa2ee9dcfc8161f0cb7c9879f38048b64 100644 (file)
@@ -1051,7 +1051,7 @@ pub fn tmpdir() -> TempDir {
         let initial_msg =   "food-is-yummy";
         let overwrite_msg =    "-the-bar!!";
         let final_msg =     "foo-the-bar!!";
-        let seek_idx = 3;
+        let seek_idx = 3i;
         let mut read_mem = [0, .. 13];
         let tmpdir = tmpdir();
         let filename = &tmpdir.join("file_rt_io_file_test_seek_and_write.txt");
index b79e831ff61356e491d2d0174dc8eb5521581c88..baf53251fbe082e5e485ac2df70e64d7dc36c72d 100644 (file)
@@ -1360,4 +1360,44 @@ pub fn peer_name(addr: SocketAddr) {
 
         rx2.recv();
     })
+
+    iotest!(fn clone_while_reading() {
+        let addr = next_test_ip6();
+        let listen = TcpListener::bind(addr.ip.to_str().as_slice(), addr.port);
+        let mut accept = listen.listen().unwrap();
+
+        // Enqueue a task to write to a socket
+        let (tx, rx) = channel();
+        let (txdone, rxdone) = channel();
+        let txdone2 = txdone.clone();
+        spawn(proc() {
+            let mut tcp = TcpStream::connect(addr.ip.to_str().as_slice(),
+                                             addr.port).unwrap();
+            rx.recv();
+            tcp.write_u8(0).unwrap();
+            txdone2.send(());
+        });
+
+        // Spawn off a reading clone
+        let tcp = accept.accept().unwrap();
+        let tcp2 = tcp.clone();
+        let txdone3 = txdone.clone();
+        spawn(proc() {
+            let mut tcp2 = tcp2;
+            tcp2.read_u8().unwrap();
+            txdone3.send(());
+        });
+
+        // Try to ensure that the reading clone is indeed reading
+        for _ in range(0i, 50) {
+            ::task::deschedule();
+        }
+
+        // clone the handle again while it's reading, then let it finish the
+        // read.
+        let _ = tcp.clone();
+        tx.send(());
+        rxdone.recv();
+        rxdone.recv();
+    })
 }
index 90f4cbb25778dcb1d8e174217249e240cd6fe25d..5201a81179144e2f7658f6c3d688ff101399c754 100644 (file)
@@ -365,7 +365,8 @@ pub fn getenv(n: &str) -> Option<String> {
     unsafe {
         with_env_lock(|| {
             use os::win32::{fill_utf16_buf_and_decode};
-            let n = n.to_utf16().append_one(0);
+            let n: Vec<u16> = n.utf16_units().collect();
+            let n = n.append_one(0);
             fill_utf16_buf_and_decode(|buf, sz| {
                 libc::GetEnvironmentVariableW(n.as_ptr(), buf, sz)
             })
@@ -411,8 +412,10 @@ fn _setenv(n: &str, v: &str) {
 
     #[cfg(windows)]
     fn _setenv(n: &str, v: &str) {
-        let n = n.to_utf16().append_one(0);
-        let v = v.to_utf16().append_one(0);
+        let n: Vec<u16> = n.utf16_units().collect();
+        let n = n.append_one(0);
+        let v: Vec<u16> = v.utf16_units().collect();
+        let v = v.append_one(0);
         unsafe {
             with_env_lock(|| {
                 libc::SetEnvironmentVariableW(n.as_ptr(), v.as_ptr());
@@ -437,7 +440,8 @@ fn _unsetenv(n: &str) {
 
     #[cfg(windows)]
     fn _unsetenv(n: &str) {
-        let n = n.to_utf16().append_one(0);
+        let n: Vec<u16> = n.utf16_units().collect();
+        let n = n.append_one(0);
         unsafe {
             with_env_lock(|| {
                 libc::SetEnvironmentVariableW(n.as_ptr(), ptr::null());
@@ -804,7 +808,7 @@ pub fn change_dir(p: &Path) -> bool {
     #[cfg(windows)]
     fn chdir(p: &Path) -> bool {
         let p = match p.as_str() {
-            Some(s) => s.to_utf16().append_one(0),
+            Some(s) => s.utf16_units().collect::<Vec<u16>>().append_one(0),
             None => return false,
         };
         unsafe {
@@ -1816,7 +1820,7 @@ fn test_setenv_overwrite() {
     #[ignore]
     fn test_getenv_big() {
         let mut s = "".to_string();
-        let mut i = 0;
+        let mut i = 0i;
         while i < 100 {
             s.push_str("aaaaaaaaaa");
             i += 1;
index e55dc165895164a5d07dd29f7137d1c82d878a37..6d48122b1867e98c69afb6d6dcc79a496c003398 100644 (file)
@@ -35,8 +35,8 @@
 Creation of a path is typically done with either `Path::new(some_str)` or
 `Path::new(some_vec)`. This path can be modified with `.push()` and
 `.pop()` (and other setters). The resulting Path can either be passed to another
-API that expects a path, or can be turned into a &[u8] with `.as_vec()` or a
-Option<&str> with `.as_str()`. Similarly, attributes of the path can be queried
+API that expects a path, or can be turned into a `&[u8]` with `.as_vec()` or a
+`Option<&str>` with `.as_str()`. Similarly, attributes of the path can be queried
 with methods such as `.filename()`. There are also methods that return a new
 path instead of modifying the receiver, such as `.join()` or `.dir_path()`.
 
index ffe4a94d2a209728870f63ee5747b66de073d418..f48d487461ef4b70cd968f8f63a25cba480e4348 100644 (file)
@@ -244,7 +244,7 @@ pub fn random<T: Rand>() -> T {
     task_rng().gen()
 }
 
-/// Randomly sample up to `n` elements from an iterator.
+/// Randomly sample up to `amount` elements from an iterator.
 ///
 /// # Example
 ///
@@ -257,11 +257,11 @@ pub fn random<T: Rand>() -> T {
 /// ```
 pub fn sample<T, I: Iterator<T>, R: Rng>(rng: &mut R,
                                          mut iter: I,
-                                         amt: uint) -> Vec<T> {
-    let mut reservoir: Vec<T> = iter.by_ref().take(amt).collect();
+                                         amount: uint) -> Vec<T> {
+    let mut reservoir: Vec<T> = iter.by_ref().take(amount).collect();
     for (i, elem) in iter.enumerate() {
-        let k = rng.gen_range(0, i + 1 + amt);
-        if k < amt {
+        let k = rng.gen_range(0, i + 1 + amount);
+        if k < amount {
             *reservoir.get_mut(k) = elem;
         }
     }
index 21d19deb0c7b6dcc7198dc7fbd931ea92f1bd98e..6492717d3ecafd95d8321818cd902c3b53af9ec4 100644 (file)
@@ -649,7 +649,7 @@ fn task_abort_no_kill_runtime() {
     use std::io::timer;
     use mem;
 
-    let mut tb = TaskBuilder::new();
+    let tb = TaskBuilder::new();
     let rx = tb.try_future(proc() {});
     mem::drop(rx);
     timer::sleep(1000);
index 8ce17b9bf3b64020de6a1154cbbae408a4a91c94..195efb844a78328fe3bc0535cece16307d057492 100644 (file)
@@ -143,7 +143,7 @@ pub fn swap(&self, val: Box<T>, order: Ordering) -> Option<Box<T>> {
     /// Remove the value, leaving the `AtomicOption` empty.
     #[inline]
     pub fn take(&self, order: Ordering) -> Option<Box<T>> {
-        unsafe { self.swap(mem::transmute(0), order) }
+        unsafe { self.swap(mem::transmute(0u), order) }
     }
 
     /// Replace an empty value with a non-empty value.
@@ -155,7 +155,7 @@ pub fn take(&self, order: Ordering) -> Option<Box<T>> {
     pub fn fill(&self, val: Box<T>, order: Ordering) -> Option<Box<T>> {
         unsafe {
             let val = mem::transmute(val);
-            let expected = mem::transmute(0);
+            let expected = mem::transmute(0u);
             let oldval = self.p.compare_and_swap(expected, val, order);
             if oldval == expected {
                 None
index 3840e55bb424de8751e13b3f3a4220cb71237b3a..4ab2ac97cc1574221ca42798a82f090782719f05 100644 (file)
@@ -64,7 +64,7 @@ pub fn duplex_stream_1() {
         let (left, right) = duplex();
 
         left.send("abc".to_string());
-        right.send(123);
+        right.send(123i);
 
         assert!(left.recv() == 123);
         assert!(right.recv() == "abc".to_string());
index 3e8f4eef3705ca44a5f214d281e22befab490b09..665f94d80b237cbe3f651cb8afef226f06577564 100644 (file)
@@ -1543,7 +1543,7 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
         let (tx, rx) = channel();
         let (cdone, pdone) = channel();
         let t = Thread::start(proc() {
-            let mut hits = 0;
+            let mut hits = 0u;
             while hits < 10 {
                 match rx.try_recv() {
                     Ok(()) => { hits += 1; }
@@ -1993,7 +1993,7 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
         let (tx, rx) = sync_channel::<()>(0);
         let (cdone, pdone) = channel();
         let t = Thread::start(proc() {
-            let mut hits = 0;
+            let mut hits = 0u;
             while hits < 10 {
                 match rx.try_recv() {
                     Ok(()) => { hits += 1; }
index cdd030ac34adcde2a09ddc3b9a722d88bf087283..8d2192aeb537ed19b823b1ed62eeebb34774fd4d 100644 (file)
 //!     let (mut worker, mut stealer) = pool.deque();
 //!
 //!     // Only the worker may push/pop
-//!     worker.push(1);
+//!     worker.push(1i);
 //!     worker.pop();
 //!
 //!     // Stealers take data from the other end of the deque
-//!     worker.push(1);
+//!     worker.push(1i);
 //!     stealer.steal();
 //!
 //!     // Stealers can be cloned to have many stealers stealing in parallel
-//!     worker.push(1);
+//!     worker.push(1i);
 //!     let mut stealer2 = stealer.clone();
 //!     stealer2.steal();
 
index dff9fee2b772d96f1a53255699cb9fdd099cb6b7..1d119bafea19955e03c2fdaaae0e83c003bedd32 100644 (file)
@@ -158,7 +158,7 @@ pub fn broadcast_on(&self, condvar_id: uint) -> uint {
 /// ```
 /// use sync::{Mutex, Arc};
 ///
-/// let mutex = Arc::new(Mutex::new(1));
+/// let mutex = Arc::new(Mutex::new(1i));
 /// let mutex2 = mutex.clone();
 ///
 /// spawn(proc() {
@@ -487,7 +487,7 @@ fn test_mutex_arc_condvar() {
 
     #[test] #[should_fail]
     fn test_arc_condvar_poison() {
-        let arc = Arc::new(Mutex::new(1));
+        let arc = Arc::new(Mutex::new(1i));
         let arc2 = arc.clone();
         let (tx, rx) = channel();
 
index 4bb0acf580c570162ac3032b542c7f165abe4426..ecd37e68880555dba3a43d41d955d4762e71f685 100644 (file)
@@ -167,8 +167,8 @@ mod tests {
     #[test]
     fn test_full() {
         let q = Queue::new();
-        q.push(box 1);
-        q.push(box 2);
+        q.push(box 1i);
+        q.push(box 2i);
     }
 
     #[test]
index a4da1fd2335470d5f7f3e86d033d70f262590fae..2834d404c1879e7de75b7b45577edbfbfcd01d7e 100644 (file)
@@ -252,8 +252,8 @@ fn smoke() {
     #[test]
     fn drop_full() {
         let q = Queue::new(0);
-        q.push(box 1);
-        q.push(box 2);
+        q.push(box 1i);
+        q.push(box 2i);
     }
 
     #[test]
@@ -284,7 +284,7 @@ fn stress_bound(bound: uint) {
                 for _ in range(0u, 100000) {
                     loop {
                         match b.pop() {
-                            Some(1) => break,
+                            Some(1i) => break,
                             Some(_) => fail!(),
                             None => {}
                         }
index 88ebe8a60faff5370bfacb7a1b5e025099d8add5..59cdec1ea88f07f240ad27aca105053111f6b475 100644 (file)
@@ -43,22 +43,116 @@ macro_rules! md (
         } }
     );
 
+    let ordering_ty = Literal(Path::new(vec!["std", "cmp", "Ordering"]));
+    let ret_ty = Literal(Path::new_(vec!["std", "option", "Option"],
+                                    None,
+                                    vec![box ordering_ty],
+                                    true));
+
+    let inline = cx.meta_word(span, InternedString::new("inline"));
+    let attrs = vec!(cx.attribute(span, inline));
+
+    let partial_cmp_def = MethodDef {
+        name: "partial_cmp",
+        generics: LifetimeBounds::empty(),
+        explicit_self: borrowed_explicit_self(),
+        args: vec![borrowed_self()],
+        ret_ty: ret_ty,
+        attributes: attrs,
+        const_nonmatching: false,
+        combine_substructure: combine_substructure(|cx, span, substr| {
+            cs_partial_cmp(cx, span, substr)
+        })
+    };
+
     let trait_def = TraitDef {
         span: span,
-        attributes: Vec::new(),
-        path: Path::new(vec!("std", "cmp", "PartialOrd")),
-        additional_bounds: Vec::new(),
+        attributes: vec![],
+        path: Path::new(vec!["std", "cmp", "PartialOrd"]),
+        additional_bounds: vec![],
         generics: LifetimeBounds::empty(),
-        methods: vec!(
+        methods: vec![
+            partial_cmp_def,
             md!("lt", true, false),
             md!("le", true, true),
             md!("gt", false, false),
             md!("ge", false, true)
-        )
+        ]
     };
     trait_def.expand(cx, mitem, item, push)
 }
 
+pub fn some_ordering_const(cx: &mut ExtCtxt, span: Span, cnst: Ordering) -> Gc<ast::Expr> {
+    let cnst = match cnst {
+        Less => "Less",
+        Equal => "Equal",
+        Greater => "Greater"
+    };
+    let ordering = cx.path_global(span,
+                                  vec!(cx.ident_of("std"),
+                                       cx.ident_of("cmp"),
+                                       cx.ident_of(cnst)));
+    let ordering = cx.expr_path(ordering);
+    cx.expr_some(span, ordering)
+}
+
+pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span,
+              substr: &Substructure) -> Gc<Expr> {
+    let test_id = cx.ident_of("__test");
+    let equals_expr = some_ordering_const(cx, span, Equal);
+
+    /*
+    Builds:
+
+    let __test = self_field1.partial_cmp(&other_field2);
+    if __test == ::std::option::Some(::std::cmp::Equal) {
+        let __test = self_field2.partial_cmp(&other_field2);
+        if __test == ::std::option::Some(::std::cmp::Equal) {
+            ...
+        } else {
+            __test
+        }
+    } else {
+        __test
+    }
+
+    FIXME #6449: These `if`s could/should be `match`es.
+    */
+    cs_same_method_fold(
+        // foldr nests the if-elses correctly, leaving the first field
+        // as the outermost one, and the last as the innermost.
+        false,
+        |cx, span, old, new| {
+            // let __test = new;
+            // if __test == Some(::std::cmp::Equal) {
+            //    old
+            // } else {
+            //    __test
+            // }
+
+            let assign = cx.stmt_let(span, false, test_id, new);
+
+            let cond = cx.expr_binary(span, ast::BiEq,
+                                      cx.expr_ident(span, test_id),
+                                      equals_expr.clone());
+            let if_ = cx.expr_if(span,
+                                 cond,
+                                 old, Some(cx.expr_ident(span, test_id)));
+            cx.expr_block(cx.block(span, vec!(assign), Some(if_)))
+        },
+        equals_expr.clone(),
+        |cx, span, list, _| {
+            match list {
+                // an earlier nonmatching variant is Less than a
+                // later one.
+                [(self_var, _, _), (other_var, _, _)] =>
+                     some_ordering_const(cx, span, self_var.cmp(&other_var)),
+                _ => cx.span_bug(span, "not exactly 2 arguments in `deriving(Ord)`")
+            }
+        },
+        cx, span, substr)
+}
+
 /// Strict inequality.
 fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt, span: Span,
          substr: &Substructure) -> Gc<Expr> {
index 6719f25abb942f0c671661619fdfb6c60447b32a..a9cf4fbd9f0f130855ce8c67d9bc5f0ab6f58a56 100644 (file)
@@ -998,7 +998,7 @@ pub fn print_method(&mut self, meth: &ast::Method) -> IoResult<()> {
 
     pub fn print_outer_attributes(&mut self,
                                   attrs: &[ast::Attribute]) -> IoResult<()> {
-        let mut count = 0;
+        let mut count = 0u;
         for attr in attrs.iter() {
             match attr.node.style {
                 ast::AttrOuter => {
@@ -1016,7 +1016,7 @@ pub fn print_outer_attributes(&mut self,
 
     pub fn print_inner_attributes(&mut self,
                                   attrs: &[ast::Attribute]) -> IoResult<()> {
-        let mut count = 0;
+        let mut count = 0u;
         for attr in attrs.iter() {
             match attr.node.style {
                 ast::AttrInner => {
index d5cc2c7f304c7146959312fe50a7d34ccfe0e7b3..43367611ab2b9bdade7c409237ccb678bc5db2cb 100644 (file)
@@ -166,8 +166,8 @@ fn test_len() {
         let v: SmallVector<int> = SmallVector::zero();
         assert_eq!(0, v.len());
 
-        assert_eq!(1, SmallVector::one(1).len());
-        assert_eq!(5, SmallVector::many(vec!(1, 2, 3, 4, 5)).len());
+        assert_eq!(1, SmallVector::one(1i).len());
+        assert_eq!(5, SmallVector::many(vec!(1i, 2, 3, 4, 5)).len());
     }
 
     #[test]
@@ -215,7 +215,7 @@ fn test_expect_one_zero() {
     #[test]
     #[should_fail]
     fn test_expect_one_many() {
-        SmallVector::many(vec!(1, 2)).expect_one("");
+        SmallVector::many(vec!(1i, 2)).expect_one("");
     }
 
     #[test]
index 26c9aaed568af47e9bc24fcca5a1a4ecb3efcafe..ec31ffc93f38e8c68c67171d3de5b19c5225ebc8 100644 (file)
@@ -1104,7 +1104,7 @@ fn calc_result(desc: &TestDesc, task_succeeded: bool) -> TestResult {
 
 impl ToJson for Metric {
     fn to_json(&self) -> json::Json {
-        let mut map = box TreeMap::new();
+        let mut map = TreeMap::new();
         map.insert("value".to_string(), json::Number(self.value));
         map.insert("noise".to_string(), json::Number(self.noise));
         json::Object(map)
index 566602b40910454ad3de610e28bb5917a204813c..577a1e8ea9e54957d1fef5952909c7251bac25af 100644 (file)
@@ -546,7 +546,7 @@ enum State {
     let mut host = "".to_string();
     let mut port = None;
 
-    let mut colon_count = 0;
+    let mut colon_count = 0u;
     let mut pos = 0;
     let mut begin = 2;
     let mut end = len;
index c0c884f5480c04b5840785bbf64ce1b2c4f244f1..d8f96e5abd44393ce6435a24654734e173a45bc6 100644 (file)
@@ -23,5 +23,5 @@ pub fn leaf<V>(value: V) -> TreeItem<V> {
 }
 
 fn main() {
-    BTree::<int> { node: leaf(1) };
+    BTree::<int> { node: leaf(1i) };
 }
index 1e746bf39db6196074bca1ea181bde9d73e9ab3c..c0cb501735da3d8b1c6a1376993f72626c915473 100644 (file)
@@ -22,6 +22,6 @@ pub fn new(val: int) -> FooBar {
     }
 
     pub fn foo(){
-        1+1;
+        1i+1;
     }
 }
index ebaed01756fb227911f4a92092f7b9bc212b5eb7..9a452ed18f67e5baae2d742d255b7b7b8f9b04b0 100644 (file)
@@ -12,7 +12,7 @@
 // anonymous fields of a tuple vs the same anonymous field.
 
 fn distinct_variant() {
-    let mut y = (1, 2);
+    let mut y = (1i, 2i);
 
     let a = match y {
         (ref mut a, _) => a
@@ -27,7 +27,7 @@ fn distinct_variant() {
 }
 
 fn same_variant() {
-    let mut y = (1, 2);
+    let mut y = (1i, 2i);
 
     let a = match y {
         (ref mut a, _) => a
index c7fb646f585b9fb5c9705154bf559c17955463f1..c872d0dc4b9c4aa5e0ada23002d18b5231a506d4 100644 (file)
@@ -9,9 +9,9 @@
 // except according to those terms.
 
 fn f() {
-    let mut a = [box 0, box 1];
+    let mut a = [box 0i, box 1i];
     drop(a[0]);
-    a[1] = box 2;
+    a[1] = box 2i;
     drop(a[0]); //~ ERROR use of moved value: `a[..]`
 }
 
index de18759e30a4cedb60913c4698b14b35b0dc5fe6..0b10ccfdca193cb537093bf4f06be60e8e7cfb6d 100644 (file)
 fn foo() -> int {
     let x: int;
 
-    while 1 != 2  {
+    while 1i != 2  {
         break;
         x = 0;
     }
 
     println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x`
 
-    return 17;
+    return 17i;
 }
 
 fn main() { println!("{}", foo()); }
index ce8b17ea40bc613a6d8fde024bade106c4189b90..886026e45d90f1f8c89734a3b04a0f77e2b1b572 100644 (file)
@@ -21,37 +21,37 @@ fn set(x: &mut int) {
 }
 
 fn a() {
-    let mut x = 3;
+    let mut x = 3i;
     let c1 = || x = 4;
     let c2 = || x * 5; //~ ERROR cannot borrow `x`
 }
 
 fn b() {
-    let mut x = 3;
+    let mut x = 3i;
     let c1 = || set(&mut x);
     let c2 = || get(&x); //~ ERROR cannot borrow `x`
 }
 
 fn c() {
-    let mut x = 3;
+    let mut x = 3i;
     let c1 = || set(&mut x);
     let c2 = || x * 5; //~ ERROR cannot borrow `x`
 }
 
 fn d() {
-    let mut x = 3;
+    let mut x = 3i;
     let c2 = || x * 5;
     x = 5; //~ ERROR cannot assign
 }
 
 fn e() {
-    let mut x = 3;
+    let mut x = 3i;
     let c1 = || get(&x);
     x = 5; //~ ERROR cannot assign
 }
 
 fn f() {
-    let mut x = box 3;
+    let mut x = box 3i;
     let c1 = || get(&*x);
     *x = 5; //~ ERROR cannot assign
 }
index e1967d4e6df94c5d91d957704a431b8894660154..6d382854d49f2b2b9cadf49bceb100effba039b2 100644 (file)
@@ -14,7 +14,7 @@
 
 
 fn a() {
-    let mut x = 3;
+    let mut x = 3i;
     let c1 = || x = 4;
     let c2 = || x = 5; //~ ERROR cannot borrow `x` as mutable more than once
 }
@@ -24,19 +24,19 @@ fn set(x: &mut int) {
 }
 
 fn b() {
-    let mut x = 3;
+    let mut x = 3i;
     let c1 = || set(&mut x);
     let c2 = || set(&mut x); //~ ERROR cannot borrow `x` as mutable more than once
 }
 
 fn c() {
-    let mut x = 3;
+    let mut x = 3i;
     let c1 = || x = 5;
     let c2 = || set(&mut x); //~ ERROR cannot borrow `x` as mutable more than once
 }
 
 fn d() {
-    let mut x = 3;
+    let mut x = 3i;
     let c1 = || x = 5;
     let c2 = || { let _y = || set(&mut x); }; // (nested closure)
     //~^ ERROR cannot borrow `x` as mutable more than once
index a35b36fd78ca8e6d10256f1bd132ca74807cb254..854d42219ea25b6b96e09c44378880a843402d8f 100644 (file)
@@ -11,6 +11,6 @@
 fn foo(x: int) { println!("{}", x); }
 
 fn main() {
-    let x: int; if 1 > 2 { x = 10; }
+    let x: int; if 1i > 2 { x = 10; }
     foo(x); //~ ERROR use of possibly uninitialized variable: `x`
 }
index 6e2dae0af7db06852639cd730bc5357128a3b9c6..74888cca2d4bde63648dfc8f12eaed26055dc93b 100644 (file)
@@ -14,7 +14,7 @@
 
 fn main() {
     let x: int;
-    if 1 > 2 {
+    if 1i > 2 {
         println!("whoops");
     } else {
         x = 10;
index 8af10231921aaac5a5774be33bd53ad7c65161e1..d127e9345cde18220f32d94f0f0e9d432b8f6c06 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 fn main() {
-    let mut _a = 3;
+    let mut _a = 3i;
     let _b = &mut _a;
     {
         let _c = &*_b;
index 9313473d6c916d334cdf13601da07b7c0acaa191..9d28b2a436f4aae19b6a10ca06530fb69f0c59d4 100644 (file)
@@ -9,11 +9,11 @@
 // except according to those terms.
 
 fn main() {
-let x = Some(box 1);
-match x {
-  Some(ref _y) => {
-    let _a = x; //~ ERROR cannot move
-  }
-  _ => {}
-}
+    let x = Some(box 1i);
+    match x {
+      Some(ref _y) => {
+        let _a = x; //~ ERROR cannot move
+      }
+      _ => {}
+    }
 }
index 39c3ae8fdfde0e3e4d9c1d797d3fe1850dc18979..973cf3bf8c889bf9568b2693fc77b5310f60ae30 100644 (file)
@@ -9,11 +9,11 @@
 // except according to those terms.
 
 fn main() {
-let x = Some(box 1);
-match x {
-  Some(ref y) => {
-    let _b = *y; //~ ERROR cannot move out
-  }
-  _ => {}
-}
+    let x = Some(box 1i);
+    match x {
+      Some(ref y) => {
+        let _b = *y; //~ ERROR cannot move out
+      }
+      _ => {}
+    }
 }
index 7a494b5959a8aef6bdeb7ce570b6f3e9e77c9ae0..c6020df2bc2ea4ecca23acbcd532328911375eb4 100644 (file)
@@ -35,20 +35,20 @@ fn guard() {
     // Here the guard performs a borrow. This borrow "infects" all
     // subsequent arms (but not the prior ones).
 
-    let mut a = box 3;
-    let mut b = box 4;
+    let mut a = box 3u;
+    let mut b = box 4u;
     let mut w = &*a;
-    match 22 {
+    match 22i {
         _ if cond() => {
-            b = box 5;
+            b = box 5u;
         }
 
         _ if link(&*b, &mut w) => {
-            b = box 6; //~ ERROR cannot assign
+            b = box 6u; //~ ERROR cannot assign
         }
 
         _ => {
-            b = box 7; //~ ERROR cannot assign
+            b = box 7u; //~ ERROR cannot assign
         }
     }
 
index a03087f9b2dad46b2d3131b57a7e00ffbb5207ae..385111170b1268f9bb6ec5f7f1c68561d553cd70 100644 (file)
@@ -9,9 +9,9 @@
 // except according to those terms.
 
 fn f() {
-    let x = [1].iter(); //~ ERROR borrowed value does not live long enough
-                        //~^^ NOTE reference must be valid for the block
-                        //~^^ NOTE consider using a `let` binding to increase its lifetime
+    let x = [1i].iter(); //~ ERROR borrowed value does not live long enough
+                         //~^^ NOTE reference must be valid for the block
+                         //~^^ NOTE consider using a `let` binding to increase its lifetime
 }
 
 fn main() {
index dba2c7dca766a653ced924464cdf7763b8784e2e..30430e00ef3422d35d5dd4af0b6dac9c88c7e04d 100644 (file)
@@ -24,10 +24,10 @@ fn foo<'a>(x: &'a Gc<int>) -> &'a int {
 }
 
 fn bar() {
-    let a = 3;
+    let a = 3i;
     let mut y = &a;
     if true {
-        let x = box(GC) 3;
+        let x = box(GC) 3i;
         y = &*x; //~ ERROR `*x` does not live long enough
     }
 }
index 6b5dd570e34e250151c66b4ee5f0ce7399e8a90e..f599f237ba672b86b9e1cf570897ecd4ccbdb960 100644 (file)
@@ -43,7 +43,7 @@ pub fn main() {
         }
     }
 
-    match [1,2,3] {
+    match [1i,2,3] {
         [x,_,_] => {
             x += 1; //~ ERROR re-assignment of immutable variable `x`
         }
index 35106487f3475153ea03911e96d2b34027cb7fe4..63409f5afb04c1dfa360cef193974bb7a7c8fae3 100644 (file)
@@ -12,7 +12,7 @@
 // borrowed path.
 
 fn main() {
-    let a = box box 2;
+    let a = box box 2i;
     let b = &a;
 
     let z = *a; //~ ERROR: cannot move out of `*a` because it is borrowed
index 1a96e5ef4b0ccbf301b5f6b6fea4bac199cb42ad..7962617916346bbad31b4523718a31dcda6b8c49 100644 (file)
@@ -11,6 +11,6 @@
 use std::rc::Rc;
 
 pub fn main() {
-    let _x = Rc::new(vec!(1, 2)).move_iter();
+    let _x = Rc::new(vec!(1i, 2)).move_iter();
     //~^ ERROR cannot move out of dereference of `&`-pointer
 }
index e12d2b9147978cebd33936d4257a659d245962e0..6faa634ad00b842499424ec3b8551e836db281e2 100644 (file)
@@ -13,9 +13,9 @@
 fn borrow<T>(_: &T) { }
 
 fn different_vars_after_borrows() {
-    let x1 = box 1;
+    let x1 = box 1i;
     let p1 = &x1;
-    let x2 = box 2;
+    let x2 = box 2i;
     let p2 = &x2;
     task::spawn(proc() {
         drop(x1); //~ ERROR cannot move `x1` into closure because it is borrowed
@@ -26,9 +26,9 @@ fn different_vars_after_borrows() {
 }
 
 fn different_vars_after_moves() {
-    let x1 = box 1;
+    let x1 = box 1i;
     drop(x1);
-    let x2 = box 2;
+    let x2 = box 2i;
     drop(x2);
     task::spawn(proc() {
         drop(x1); //~ ERROR capture of moved value: `x1`
@@ -37,7 +37,7 @@ fn different_vars_after_moves() {
 }
 
 fn same_var_after_borrow() {
-    let x = box 1;
+    let x = box 1i;
     let p = &x;
     task::spawn(proc() {
         drop(x); //~ ERROR cannot move `x` into closure because it is borrowed
@@ -47,7 +47,7 @@ fn same_var_after_borrow() {
 }
 
 fn same_var_after_move() {
-    let x = box 1;
+    let x = box 1i;
     drop(x);
     task::spawn(proc() {
         drop(x); //~ ERROR capture of moved value: `x`
index fb03ad61f3d1ef8404029c3ac8413cd8cdc05d97..5a129956487c9956069e168882fe13b99cf32cee 100644 (file)
@@ -12,7 +12,7 @@
 fn borrow(_v: &int) {}
 
 fn local() {
-    let mut v = box 3;
+    let mut v = box 3i;
     borrow(v);
 }
 
@@ -31,27 +31,27 @@ struct H { h: Box<int> }
 }
 
 fn aliased_imm() {
-    let mut v = box 3;
+    let mut v = box 3i;
     let _w = &v;
     borrow(v);
 }
 
 fn aliased_mut() {
-    let mut v = box 3;
+    let mut v = box 3i;
     let _w = &mut v;
     borrow(v); //~ ERROR cannot borrow `*v`
 }
 
 fn aliased_other() {
-    let mut v = box 3;
-    let mut w = box 4;
+    let mut v = box 3i;
+    let mut w = box 4i;
     let _x = &mut w;
     borrow(v);
 }
 
 fn aliased_other_reassign() {
-    let mut v = box 3;
-    let mut w = box 4;
+    let mut v = box 3i;
+    let mut w = box 4i;
     let mut _x = &mut w;
     _x = &mut v;
     borrow(v); //~ ERROR cannot borrow `*v`
index cca8ed93388bc26fa4ca867bb354a30562c03ab1..7b092d16eec69d9d9d0e298339265a74f757802d 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 fn main() {
-    let mut a = [1, 2, 3, 4];
+    let mut a = [1i, 2, 3, 4];
     let t = match a {
         [1, 2, ..tail] => tail,
         _ => unreachable!()
index f41f74b166fd2346dc22f84845482946dd565add..4a56f9821065bfd51163d0d39d9eba6fa5392bd8 100644 (file)
@@ -10,7 +10,7 @@
 
 
 fn a() {
-    let mut vec = [box 1, box 2, box 3];
+    let mut vec = [box 1i, box 2, box 3];
     match vec {
         [box ref _a, _, _] => {
             vec[0] = box 4; //~ ERROR cannot assign
@@ -19,7 +19,7 @@ fn a() {
 }
 
 fn b() {
-    let mut vec = vec!(box 1, box 2, box 3);
+    let mut vec = vec!(box 1i, box 2, box 3);
     let vec: &mut [Box<int>] = vec.as_mut_slice();
     match vec {
         [.._b] => {
@@ -29,7 +29,7 @@ fn b() {
 }
 
 fn c() {
-    let mut vec = vec!(box 1, box 2, box 3);
+    let mut vec = vec!(box 1i, box 2, box 3);
     let vec: &mut [Box<int>] = vec.as_mut_slice();
     match vec {
         [_a,         //~ ERROR cannot move out
@@ -47,7 +47,7 @@ fn c() {
 }
 
 fn d() {
-    let mut vec = vec!(box 1, box 2, box 3);
+    let mut vec = vec!(box 1i, box 2, box 3);
     let vec: &mut [Box<int>] = vec.as_mut_slice();
     match vec {
         [.._a,     //~ ERROR cannot move out
@@ -58,7 +58,7 @@ fn d() {
 }
 
 fn e() {
-    let mut vec = vec!(box 1, box 2, box 3);
+    let mut vec = vec!(box 1i, box 2, box 3);
     let vec: &mut [Box<int>] = vec.as_mut_slice();
     match vec {
         [_a, _b, _c] => {}  //~ ERROR cannot move out
index b904fd53d7279cf302348a3da8672b3bcfe19324..b5703e56642ad9de61a736eaf6b357f546db8e5f 100644 (file)
@@ -10,7 +10,7 @@
 
 fn f() -> int {
     let mut x: int;
-    while 1 == 1 { x = 10; }
+    while 1i == 1 { x = 10; }
     return x; //~ ERROR use of possibly uninitialized variable: `x`
 }
 
index 0d5a71559e8678317d1464fa7f13b3b6ba72e093..bea025df6fc859ca5a90e7086dd2ab70ae70f33d 100644 (file)
@@ -21,6 +21,6 @@ impl <T: Share> Foo for T { }
 
 fn main() {
     let (tx, rx) = channel();
-    1193182.foo(tx);
-    assert!(rx.recv() == 1193182);
+    1193182i.foo(tx);
+    assert!(rx.recv() == 1193182i);
 }
index ace917c704acb7d49922105eabd1929891bfb137..d8f771cfb5a736c8319b32c902f2792f461cf8b8 100644 (file)
@@ -10,7 +10,7 @@
 
 #![feature(macro_rules)]
 
-static A: uint = { 1; 2 };
+static A: uint = { 1u; 2 };
 //~^ ERROR: blocks in constants are limited to items and tail expressions
 
 static B: uint = { { } 2 };
@@ -21,7 +21,7 @@ macro_rules! foo {
 }
 static C: uint = { foo!() 2 };
 
-static D: uint = { let x = 4; 2 };
+static D: uint = { let x = 4u; 2 };
 //~^ ERROR: blocks in constants are limited to items and tail expressions
 
 pub fn main() {
index 077286eef499b7ec867c3bc6a21492a8d0592359..dd6c11d2b39932b2846af2c42fc0ec2902160105 100644 (file)
@@ -27,6 +27,7 @@ enum Enum {
 //~^^^^^ ERROR
 //~^^^^^^ ERROR
 //~^^^^^^^ ERROR
+//~^^^^^^^^ ERROR
    }
 }
 
index 8fd4ba6053e22b63b1c671a3e321b66f95603ed8..1b3d73a6f8bee9381534fe2ca11bd57e926a9a78 100644 (file)
@@ -27,6 +27,7 @@ enum Enum {
 //~^^^^^ ERROR
 //~^^^^^^ ERROR
 //~^^^^^^^ ERROR
+//~^^^^^^^^ ERROR
      )
 }
 
index 3a198a542e4ad15d0ba4c342ee9332b02ba5a645..2ef3b4dfe8a2f1218bc8e2ad19665713f8a4fbbf 100644 (file)
@@ -26,6 +26,7 @@ struct Struct {
 //~^^^^^ ERROR
 //~^^^^^^ ERROR
 //~^^^^^^^ ERROR
+//~^^^^^^^^ ERROR
 }
 
 fn main() {}
index 2de3c18425b5775670d07cb4ea5875d3fb1591cd..303896737dc28183ec4123cfafc036c2d5164db1 100644 (file)
@@ -26,6 +26,7 @@ struct Struct(
 //~^^^^^ ERROR
 //~^^^^^^ ERROR
 //~^^^^^^^ ERROR
+//~^^^^^^^^ ERROR
 );
 
 fn main() {}
index 8b00b6149099367c839e4c246af80d281e307dde..8de613ac03d0f1cbddf36133dec5604abec64517 100644 (file)
@@ -11,6 +11,6 @@
 
 fn main() {
     for
-        &1 //~ ERROR refutable pattern in `for` loop binding
-        in [1].iter() {}
+        &1i //~ ERROR refutable pattern in `for` loop binding
+        in [1i].iter() {}
 }
diff --git a/src/test/compile-fail/integer-literal-suffix-inference-2.rs b/src/test/compile-fail/integer-literal-suffix-inference-2.rs
new file mode 100644 (file)
index 0000000..7c862d0
--- /dev/null
@@ -0,0 +1,17 @@
+// 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.
+
+fn foo(_: *const ()) {}
+
+fn main() {
+    let a = 3;  //~ ERROR cannot determine a type for this local variable
+    foo(&a as *const _ as *const ());
+}
+
diff --git a/src/test/compile-fail/integer-literal-suffix-inference-3.rs b/src/test/compile-fail/integer-literal-suffix-inference-3.rs
new file mode 100644 (file)
index 0000000..dc3db98
--- /dev/null
@@ -0,0 +1,15 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    println!("{}", std::mem::size_of_val(&1));
+    //~^ ERROR cannot determine a type for this expression
+}
+
index 97642377ba8f4d74696edafbb6aed616eb062ba2..9141ab669bbc22fd06b809eef035f53985d44192 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 fn main() {
-    let x = box 1;
+    let x = box 1i;
     let f: proc() = proc() {
         let _a = x;
         drop(x);
index 333ff7118d45b4b2b7d33275341cdd6d95a6a33d..7856a5dcf7f2ef36e6fcc3b0ff8a29aed28a57e4 100644 (file)
@@ -11,6 +11,6 @@
 // This file must never have a trailing newline
 
 fn main() {
-    let x = Some(3);
-    let y = x.as_ref().unwrap_or(&5); //~ ERROR: borrowed value does not live long enough
+    let x = Some(3i);
+    let y = x.as_ref().unwrap_or(&5i); //~ ERROR: borrowed value does not live long enough
 }
index 0ca326c1e0d9fd101a1675e3ece815d146882938..e1acab4008a9b1a65586d8859ee05775b8a61469 100644 (file)
@@ -9,8 +9,8 @@
 // except according to those terms.
 
 fn main() {
-    let mut v = vec!(1);
-    let f = || v.push(2);
+    let mut v = vec!(1i);
+    let f = || v.push(2i);
     let _w = v; //~ ERROR: cannot move out of `v`
 
     f();
index a8d2c7509ce3fd6a265e89f6a884b3e9bc273116..5d62c25ea171b776ad56ef993509a28e90afbbdf 100644 (file)
@@ -10,7 +10,7 @@
 
 fn main() {
     let r = {
-        let x = box 42;
+        let x = box 42i;
         let f = proc() &x; //~ ERROR: `x` does not live long enough
         f()
     };
index 9ad593673120dfc8af143a423b3fc85680b34c1c..f824a06aed1b3912d66c3b00f6f8e736aecba81f 100644 (file)
@@ -14,7 +14,7 @@ fn main() {
         loop {
             let tx = tx;
             //~^ ERROR: use of moved value: `tx`
-            tx.send(1);
+            tx.send(1i);
         }
     });
 }
diff --git a/src/test/compile-fail/issue-15260.rs b/src/test/compile-fail/issue-15260.rs
new file mode 100644 (file)
index 0000000..0682613
--- /dev/null
@@ -0,0 +1,19 @@
+// 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.
+
+struct Foo {
+  a: uint,
+}
+
+fn main(){
+    let Foo {a: _, a: _} = Foo {a: 29};
+    //~^ ERROR field `a` bound twice in pattern
+}
+
index db3e9c23b76217ab8927770b5baf2bfceefc03cb..c59ee328eff40ab51bbb5655a7d8c3fba834c273 100644 (file)
@@ -10,9 +10,9 @@
 
 // compile-flags: -D while-true
 fn main() {
-  let mut i = 0;
+  let mut i = 0i;
   while true  { //~ ERROR denote infinite loops with loop
-    i += 1;
-    if i == 5 { break; }
+    i += 1i;
+    if i == 5i { break; }
   }
 }
index d6fe83a77032bd80b1e31a2f60c4b55d9586f4ef..293f372866d1097ea62b9348b65f4ff9a768ce05 100644 (file)
@@ -10,7 +10,7 @@
 
 #[deriving(PartialEq)]
 struct thing(uint);
-impl PartialOrd for thing { //~ ERROR not all trait methods implemented, missing: `lt`
+impl PartialOrd for thing { //~ ERROR not all trait methods implemented, missing: `partial_cmp`
     fn le(&self, other: &thing) -> bool { true }
     fn ge(&self, other: &thing) -> bool { true }
 }
index 4e128b63e925722862c07458e355358b1ae778d2..2445638d62e6059bc704e155d3516dc021337764 100644 (file)
@@ -14,7 +14,7 @@ struct Obj {
 
 impl Obj {
     pub fn boom() -> bool {
-        return 1+1 == 2
+        return 1i+1 == 2
     }
     pub fn chirp(&self) {
         self.boom(); //~ ERROR `&Obj` does not implement any method in scope named `boom`
@@ -24,5 +24,5 @@ pub fn chirp(&self) {
 fn main() {
     let o = Obj { member: 0 };
     o.chirp();
-    1 + 1;
+    1i + 1;
 }
index f8e59ad13ad7a127bb84bdb95f7910433e91382b..8417f7810ead2f7835c7119901a168df814694b0 100644 (file)
@@ -35,7 +35,7 @@ mod foo2 {
 static used_static: int = 0;
 pub static used_static2: int = used_static;
 static USED_STATIC: int = 0;
-static STATIC_USED_IN_ENUM_DISCRIMINANT: uint = 10;
+static STATIC_USED_IN_ENUM_DISCRIMINANT: int = 10;
 
 pub type typ = *const UsedStruct4;
 pub struct PubStruct;
@@ -77,7 +77,7 @@ pub fn pub_fn() {
     let e = foo3;
     SemiUsedStruct::la_la_la();
 
-    let i = 1;
+    let i = 1i;
     match i {
         USED_STATIC => (),
         _ => ()
index 2ec9efe9498cec0f440d8771174fc41af549797a..8f495645dc7ead9acee3d1789166190646a81861 100644 (file)
@@ -21,11 +21,11 @@ struct Foo {
 struct Bar { x: Box<int> } //~ ERROR type uses owned
 
 fn main() {
-    let _x : Bar = Bar {x : box 10}; //~ ERROR type uses owned
+    let _x : Bar = Bar {x : box 10i}; //~ ERROR type uses owned
 
-    box(GC) 2; //~ ERROR type uses managed
+    box(GC) 2i; //~ ERROR type uses managed
 
-    box 2; //~ ERROR type uses owned
+    box 2i; //~ ERROR type uses owned
     fn g(_: Box<Clone>) {} //~ ERROR type uses owned
     proc() {}; //~ ERROR type uses owned
 }
index 4d9383aeda2a1473d85d43eedc0eb5bc3b708a39..d51d5b4af87a99ce05ed2f15398deb1e08b757a4 100644 (file)
@@ -17,7 +17,7 @@ fn foo(&self) -> bool { self.y }
 }
 
 fn foo() -> int {
-    return (1); //~ ERROR unnecessary parentheses around `return` value
+    return (1i); //~ ERROR unnecessary parentheses around `return` value
 }
 fn bar() -> X {
     return (X { y: true }); //~ ERROR unnecessary parentheses around `return` value
@@ -45,7 +45,7 @@ fn main() {
         _ => {}
     }
 
-    let mut _a = (0); //~ ERROR unnecessary parentheses around assigned value
-    _a = (0); //~ ERROR unnecessary parentheses around assigned value
-    _a += (1); //~ ERROR unnecessary parentheses around assigned value
+    let mut _a = (0i); //~ ERROR unnecessary parentheses around assigned value
+    _a = (0i); //~ ERROR unnecessary parentheses around assigned value
+    _a += (1i); //~ ERROR unnecessary parentheses around assigned value
 }
index 4334d2f63ea59c41e94263c90b12700daf9330d6..f03e748e4176d5f495371816474818d307038ed4 100644 (file)
@@ -55,7 +55,7 @@ mod bar {
     pub mod c {
         use foo::Point;
         use foo::Square; //~ ERROR unused import
-        pub fn cc(p: Point) -> int { return 2 * (p.x + p.y); }
+        pub fn cc(p: Point) -> int { return 2i * (p.x + p.y); }
     }
 
     #[allow(unused_imports)]
@@ -66,8 +66,8 @@ mod foo {
 
 fn main() {
     cal(foo::Point{x:3, y:9});
-    let mut a = 3;
-    let mut b = 4;
+    let mut a = 3i;
+    let mut b = 4i;
     swap(&mut a, &mut b);
     test::C.b();
     let _a = foo();
index d5f34669a25e2355b415b366485fa2fce3ea2cb6..c5281bf678185b41d152e277cc6b32907bf19865 100644 (file)
 
 fn main() {
     // negative cases
-    let mut a = 3; //~ ERROR: variable does not need to be mutable
-    let mut a = 2; //~ ERROR: variable does not need to be mutable
-    let mut b = 3; //~ ERROR: variable does not need to be mutable
-    let mut a = vec!(3); //~ ERROR: variable does not need to be mutable
-    let (mut a, b) = (1, 2); //~ ERROR: variable does not need to be mutable
+    let mut a = 3i; //~ ERROR: variable does not need to be mutable
+    let mut a = 2i; //~ ERROR: variable does not need to be mutable
+    let mut b = 3i; //~ ERROR: variable does not need to be mutable
+    let mut a = vec!(3i); //~ ERROR: variable does not need to be mutable
+    let (mut a, b) = (1i, 2i); //~ ERROR: variable does not need to be mutable
 
-    match 30 {
+    match 30i {
         mut x => {} //~ ERROR: variable does not need to be mutable
     }
-    match (30, 2) {
+    match (30i, 2i) {
       (mut x, 1) | //~ ERROR: variable does not need to be mutable
       (mut x, 2) |
       (mut x, 3) => {
@@ -35,28 +35,28 @@ fn main() {
       _ => {}
     }
 
-    let x = |mut y: int| 10; //~ ERROR: variable does not need to be mutable
+    let x = |mut y: int| 10i; //~ ERROR: variable does not need to be mutable
     fn what(mut foo: int) {} //~ ERROR: variable does not need to be mutable
 
     // positive cases
-    let mut a = 2;
-    a = 3;
+    let mut a = 2i;
+    a = 3i;
     let mut a = Vec::new();
-    a.push(3);
+    a.push(3i);
     let mut a = Vec::new();
     callback(|| {
-        a.push(3);
+        a.push(3i);
     });
-    let (mut a, b) = (1, 2);
+    let (mut a, b) = (1i, 2i);
     a = 34;
 
-    match 30 {
+    match 30i {
         mut x => {
-            x = 21;
+            x = 21i;
         }
     }
 
-    match (30, 2) {
+    match (30i, 2i) {
       (mut x, 1) |
       (mut x, 2) |
       (mut x, 3) => {
@@ -65,12 +65,12 @@ fn what(mut foo: int) {} //~ ERROR: variable does not need to be mutable
       _ => {}
     }
 
-    let x = |mut y: int| y = 32;
-    fn nothing(mut foo: int) { foo = 37; }
+    let x = |mut y: int| y = 32i;
+    fn nothing(mut foo: int) { foo = 37i; }
 
     // leading underscore should avoid the warning, just like the
     // unused variable lint.
-    let mut _allowed = 1;
+    let mut _allowed = 1i;
 }
 
 fn callback(f: ||) {}
@@ -78,6 +78,6 @@ fn callback(f: ||) {}
 // make sure the lint attribute can be turned off
 #[allow(unused_mut)]
 fn foo(mut a: int) {
-    let mut a = 3;
-    let mut b = vec!(2);
+    let mut a = 3i;
+    let mut b = vec!(2i);
 }
index ee44872d1220143a7e252409f7ea0614194b98f4..68dbacaae5cf43230a7722be55223215c2e3f904 100644 (file)
@@ -29,40 +29,40 @@ fn f1d() {
 }
 
 fn f2() {
-    let x = 3;
+    let x = 3i;
     //~^ ERROR unused variable: `x`
 }
 
 fn f3() {
-    let mut x = 3;
+    let mut x = 3i;
     //~^ ERROR variable `x` is assigned to, but never used
-    x += 4;
+    x += 4i;
     //~^ ERROR value assigned to `x` is never read
 }
 
 fn f3b() {
-    let mut z = 3;
+    let mut z = 3i;
     //~^ ERROR variable `z` is assigned to, but never used
     loop {
-        z += 4;
+        z += 4i;
     }
 }
 
 #[allow(unused_variable)]
 fn f3c() {
-    let mut z = 3;
-    loop { z += 4; }
+    let mut z = 3i;
+    loop { z += 4i; }
 }
 
 #[allow(unused_variable)]
 #[allow(dead_assignment)]
 fn f3d() {
-    let mut x = 3;
-    x += 4;
+    let mut x = 3i;
+    x += 4i;
 }
 
 fn f4() {
-    match Some(3) {
+    match Some(3i) {
       Some(i) => {
         //~^ ERROR unused variable: `i`
       }
@@ -75,7 +75,7 @@ enum tri {
 }
 
 fn f4b() -> int {
-    match a(3) {
+    match a(3i) {
       a(i) | b(i) | c(i) => {
         i
       }
index d8d665e2af6b0a56c930a9faa94edfb9895a77e3..17f02abc8ec89ad7bf4ab81853fd95777409e7be 100644 (file)
@@ -9,9 +9,9 @@
 // except according to those terms.
 
 fn main() {
-    match 1 {
-        1 => 1, //~ ERROR mismatched types between arms
-        2u => 1,
-        _ => 2,
+    match 1i {
+        1i => 1i,
+        2u => 1i, //~ ERROR mismatched types
+        _ => 2i,
     };
 }
index a24d2ed4b7fba3da7eb6491bea94bc61d1c0431a..20adbeebdf1d70ff41f70788e9b51c8f57671303 100644 (file)
@@ -9,6 +9,6 @@
 // except according to those terms.
 
 fn main() {
-    match 0 { 1 => () } //~ ERROR non-exhaustive patterns
-    match 0 { 0 if false => () } //~ ERROR non-exhaustive patterns
+    match 0i { 1i => () } //~ ERROR non-exhaustive patterns
+    match 0i { 0i if false => () } //~ ERROR non-exhaustive patterns
 }
index 3f484511859f31dc4430d825b88fd06b02afed37..7c9c371c5267436934b911bdbbe97a30dfda1e37 100644 (file)
@@ -39,9 +39,9 @@ fn main() {
       _ => {}
     };
 
-    match 1.0 {
-      0.01 .. 6.5 => {}
-      0.02 => {}
+    match 1.0f64 {
+      0.01f64 .. 6.5f64 => {}
+      0.02f64 => {}
       _ => {}
     };
 }
index e778dd18e68d3e64ac24d34bacad4d4741371ab7..bac9fef2b17775f9e4608079489f2cfbc1d0eacd 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 fn a() {
-    let v = [1, 2, 3];
+    let v = [1i, 2, 3];
     match v {
         [_, _, _] => {}
         [_, _, _] => {} //~ ERROR unreachable pattern
index 82aa5c36c8e4342f04990f761a6fcfb9706be8d0..7a882b26db5904b38e8e65ad2e6de8334979a948 100644 (file)
@@ -25,13 +25,13 @@ fn f10() {
 
 fn f20() {
     let x = "hi".to_string();
-    let _y = (x, 3);
+    let _y = (x, 3i);
     touch(&x); //~ ERROR use of moved value: `x`
 }
 
 fn f21() {
-    let x = vec!(1, 2, 3);
-    let _y = (*x.get(0), 3);
+    let x = vec!(1i, 2, 3);
+    let _y = (*x.get(0), 3i);
     touch(&x);
 }
 
@@ -62,9 +62,9 @@ fn f50(cond: bool) {
     let x = "hi".to_string();
     let y = "ho".to_string();
     let _y = match cond {
-        _ if guard(x) => 10,
-        true => 10,
-        false => 20,
+        _ if guard(x) => 10i,
+        true => 10i,
+        false => 20i,
     };
     touch(&x); //~ ERROR use of moved value: `x`
     touch(&y);
index 99d7258477ace85d1f67529207171b38f986a071..ce6e793d55d4d9c1a923f15cf0cb95d95a7cd67d 100644 (file)
@@ -11,7 +11,7 @@
 use std::cell::RefCell;
 
 fn main() {
-    let m = RefCell::new(0);
+    let m = RefCell::new(0i);
     let mut b = m.borrow_mut();
     let b1 = &mut *b;
     let b2 = &mut *b; //~ ERROR cannot borrow
index f1e7ef216c32c6982b31445c677f2bb2ae4f1ad8..985bfec392c7f128dffc14bdbef6af3a7de201f8 100644 (file)
@@ -13,6 +13,6 @@
 fn f<T: Share>(_: T) {}
 
 fn main() {
-    let x = RefCell::new(0);
+    let x = RefCell::new(0i);
     f(x); //~ ERROR: which does not fulfill `Share`
 }
index 8e968d90a2f65750aeb87e9a8551653334cf630f..e269a736ce2577378d5374cd413962942eee37d1 100644 (file)
@@ -11,7 +11,7 @@
 use std::cell::RefCell;
 
 fn main() {
-    let m = RefCell::new(0);
+    let m = RefCell::new(0i);
     let p;
     {
         let b = m.borrow();
index bf79d1393b837a555d0f87b0fb002eb3218ca961..291340e55b856b9e04cb3bc27f674fb821de2dea 100644 (file)
@@ -13,7 +13,7 @@
 fn bar<T: Send>(_: T) {}
 
 fn main() {
-    let x = Rc::new(5);
+    let x = Rc::new(5i);
     bar(x);
     //~^ ERROR instantiating a type parameter with an incompatible type `alloc::rc::Rc<int>`,
     //         which does not fulfill `Send`
index ad79d03821206ffd76746b932b7dbb0bb00a69e5..f49592b173587d750f366607a8f04ecd59c436ea 100644 (file)
@@ -14,7 +14,7 @@
 fn bar<T: Share>(_: T) {}
 
 fn main() {
-    let x = Rc::new(RefCell::new(5));
+    let x = Rc::new(RefCell::new(5i));
     bar(x);
     //~^ ERROR instantiating a type parameter with an incompatible type
     //         `std::rc::Rc<std::cell::RefCell<int>>`, which does not fulfill `Share`
index cd78419439a96952db491d31ac1cfeb00be9850d..4de4af877127d1db27ef418e48ade49822a41321 100644 (file)
@@ -16,10 +16,10 @@ fn main() {
     match true { //~ ERROR non-exhaustive patterns: `false` not covered
       true => {}
     }
-    match Some(10) { //~ ERROR non-exhaustive patterns: `Some(_)` not covered
+    match Some(10i) { //~ ERROR non-exhaustive patterns: `Some(_)` not covered
       None => {}
     }
-    match (2, 3, 4) { //~ ERROR non-exhaustive patterns: `(_, _, _)` not covered
+    match (2i, 3i, 4i) { //~ ERROR non-exhaustive patterns: `(_, _, _)` not covered
       (_, _, 4) => {}
     }
     match (a, a) { //~ ERROR non-exhaustive patterns: `(a, a)` not covered
@@ -35,20 +35,20 @@ fn main() {
       (_, a) => {}
       (b, b) => {}
     }
-    let vec = vec!(Some(42), None, Some(21));
+    let vec = vec!(Some(42i), None, Some(21i));
     let vec: &[Option<int>] = vec.as_slice();
     match vec { //~ ERROR non-exhaustive patterns: `[]` not covered
         [Some(..), None, ..tail] => {}
         [Some(..), Some(..), ..tail] => {}
         [None] => {}
     }
-    let vec = vec!(1);
+    let vec = vec!(1i);
     let vec: &[int] = vec.as_slice();
     match vec {
         [_, ..tail] => (),
         [] => ()
     }
-    let vec = vec!(0.5);
+    let vec = vec!(0.5f32);
     let vec: &[f32] = vec.as_slice();
     match vec { //~ ERROR non-exhaustive patterns: `[_, _, _, _]` not covered
         [0.1, 0.2, 0.3] => (),
@@ -56,7 +56,7 @@ fn main() {
         [0.1] => (),
         [] => ()
     }
-    let vec = vec!(Some(42), None, Some(21));
+    let vec = vec!(Some(42i), None, Some(21i));
     let vec: &[Option<int>] = vec.as_slice();
     match vec {
         [Some(..), None, ..tail] => {}
index 9128ee68e26c5baec9c95c42620f8b62799c2898..28533518a25a1be656c3e1246dba83bbd6ca4b2a 100644 (file)
@@ -13,6 +13,6 @@ fn func((1, (Some(1), 2..3)): (int, (Option<int>, int))) { }
 //~^ ERROR refutable pattern in function argument: `(_, _)` not covered
 
 fn main() {
-    let (1, (Some(1), 2..3)) = (1, (None, 2));
+    let (1i, (Some(1i), 2i..3i)) = (1i, (None, 2i));
     //~^ ERROR refutable pattern in local binding: `(_, _)` not covered
 }
index 731b045d0f3224d6666cc1507f0b79fd2db92bda..846e03d57c3ae087870b13e096dfb7c454e9ec50 100644 (file)
@@ -13,9 +13,9 @@ fn env<'a>(blk: |p: ||: 'a|) {
     // the lifetime `'a`, which outlives the current
     // block.
 
-    let mut state = 0;
+    let mut state = 0i;
     let statep = &mut state;
-    blk(|| *statep = 1); //~ ERROR cannot infer
+    blk(|| *statep = 1i); //~ ERROR cannot infer
 }
 
 fn no_env_no_for<'a>(blk: |p: |||: 'a) {
@@ -31,7 +31,7 @@ fn repeating_loop() {
     // external to the loop.
 
     let closure;
-    let state = 0;
+    let state = 0i;
 
     loop {
         closure = || state; //~ ERROR cannot infer
@@ -47,7 +47,7 @@ fn repeating_while() {
     // external to the loop.
 
     let closure;
-    let state = 0;
+    let state = 0i;
 
     while true {
         closure = || state; //~ ERROR cannot infer
index f588655d1afa85af5b19e7fc1af8c8a46594d233..472df87dd2b0dd4a54f3577cd58a20a22f962a83 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 fn main() {
-    let x = 3;
+    let x = 3i;
 
     // Here, the variable `p` gets inferred to a type with a lifetime
     // of the loop body.  The regionck then determines that this type
@@ -17,7 +17,7 @@ fn main() {
     let mut p = &x;
 
     loop {
-        let x = 1 + *p;
+        let x = 1i + *p;
         p = &x; //~ ERROR `x` does not live long enough
     }
 }
index 89350f16167603f3b9ae01c8409623e2f405feea..22c6bdd2d504c4f0880e1a635c3a4536f8c3f0d1 100644 (file)
@@ -10,7 +10,7 @@
 
 // The type of `y` ends up getting inferred to the type of the block.
 fn broken() {
-    let mut x = 3;
+    let mut x = 3i;
     let mut _y = vec!(&mut x);
     while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed
         let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed
index d5e70205e9536f5ffa22f71232c8f5d0fc8b256c..6adc3b0aaf843b0d4a2676f6c2d85e199670e16a 100644 (file)
@@ -11,6 +11,6 @@
 #![allow(dead_code)]
 
 #[static_assert]
-static E: bool = 1 == 2; //~ ERROR static assertion failed
+static E: bool = 1i == 2; //~ ERROR static assertion failed
 
 fn main() {}
index 997003a28d4235343692d4d955317970a2ea5ab7..c410e85655258e161857a9b248d5e5779360e1f4 100644 (file)
@@ -19,7 +19,7 @@ fn main() {
     // name as a variable, hence this should be an unreachable pattern situation
     // instead of spitting out a custom error about some identifier collisions
     // (we should allow shadowing)
-    match 4 {
+    match 4i {
         a => {}
         _ => {} //~ ERROR: unreachable pattern
     }
index 880fbf0cb1d969eac56f60b9a8c993455ae788e4..d78643ccd104603c005f9cdaea3e2dea583cb855 100644 (file)
@@ -15,8 +15,8 @@
 fn f<T:'static>(_: T) {}
 
 fn main() {
-    let x = box(GC) 3;
+    let x = box(GC) 3i;
     f(x);
-    let x = &3;
+    let x = &3i;
     f(x);   //~ ERROR instantiating a type parameter with an incompatible type
 }
index 6dec86ddf622f8222613c9e587644ad6ff48b1ae..72ef4a03eab72cd772ba3a2cbca6bf0ba8af809b 100644 (file)
@@ -28,7 +28,7 @@ fn test<T: Share>(s: T){
 }
 
 fn main() {
-    let us = Unsafe::new(MyShare{u: Unsafe::new(0)});
+    let us = Unsafe::new(MyShare{u: Unsafe::new(0i)});
     test(us);
 
     let uns = Unsafe::new(NoShare{m: marker::NoShare});
index e8dc0fc3b6c285908200d8f9e4cc78d5f6f94814..67fbc08bd941b213938da65c6634fb72cfe9861b 100644 (file)
@@ -16,6 +16,6 @@ fn f<T:Send>(_i: T) {
 }
 
 fn main() {
-    let i = box box(GC) 100;
+    let i = box box(GC) 100i;
     f(i); //~ ERROR does not fulfill `Send`
 }
index 96adb29cbc80ddecc35918d5ef9cedb327d2699e..fb9a6b5201897446da23a28c9cda47f90b027202 100644 (file)
@@ -14,5 +14,5 @@
 fn main() {
   loop{}
 
-  let a = 3; //~ ERROR: unreachable statement
+  let a = 3i; //~ ERROR: unreachable statement
 }
index c321871c40f2c29983502976eef41e3068d4de08..c5cc7e8f7163b271d4c4a97535bb173500daf6d7 100644 (file)
@@ -51,8 +51,8 @@ fn f8<type X>(x1: &S<X>, x2: &S<X>) {
 
 // Test some tuples.
 fn f9<type X>(x1: Box<S<X>>, x2: Box<E<X>>) {
-    f5(&(*x1, 34)); //~ERROR instantiating a type parameter with an incompatible type `(S<X>,int)`,
-    f5(&(32, *x2)); //~ERROR instantiating a type parameter with an incompatible type `(int,E<X>)`,
+    f5(&(*x1, 34i)); //~ERROR instantiating a type parameter with an incompatible type `(S<X>,int)`,
+    f5(&(32i, *x2)); //~ERROR instantiating a type parameter with an incompatible type `(int,E<X>)`,
 }
 
 // I would like these to fail eventually.
index 9916fdba20f6ea82f1f3a94eb0032c614498a426..061b003b5e3f023360e1e3d64c68437eddb89d15 100644 (file)
@@ -29,12 +29,12 @@ fn f2<type X: T>(x: &X) {
 fn f3<type X>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
     let y: X = *x1; //~ERROR variable `y` has dynamically sized type `X`
     let y = *x2; //~ERROR variable `y` has dynamically sized type `X`
-    let (y, z) = (*x3, 4); //~ERROR variable `y` has dynamically sized type `X`
+    let (y, z) = (*x3, 4i); //~ERROR variable `y` has dynamically sized type `X`
 }
 fn f4<type X: T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
     let y: X = *x1;         //~ERROR variable `y` has dynamically sized type `X`
     let y = *x2;            //~ERROR variable `y` has dynamically sized type `X`
-    let (y, z) = (*x3, 4); //~ERROR variable `y` has dynamically sized type `X`
+    let (y, z) = (*x3, 4i); //~ERROR variable `y` has dynamically sized type `X`
 }
 
 fn g1<type X>(x: X) {} //~ERROR variable `x` has dynamically sized type `X`
index a3c7fc2d4c8af5a2d382ec74eca38b41b434f70e..9a179f434c275d1c2eddc725fce5804e654ef5b5 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 fn main() {
-    let mut xs = vec!(1, 2, 3, 4);
+    let mut xs = vec!(1i, 2, 3, 4);
 
     for x in xs.mut_iter() {
         xs.push(1) //~ ERROR cannot borrow `xs`
index 90515807ac6cca6451ce7059d6771640b8d1fb7a..8b6d160a6c5a98d3702e33c38b8af495e8cca273 100644 (file)
@@ -11,6 +11,6 @@
 // compile-flags: -D path-statement
 fn main() {
 
-    let x = 10;
+    let x = 10i;
     x; //~ ERROR path statement with no effect
 }
index da32518d9936dc3cc86814f759aa5b580185310e..51d2f36cc78b69cd1106413824ad8b4e787638a9 100644 (file)
@@ -67,7 +67,7 @@ fn main() {
     let f32: f32 = 2.5;
     let f64: f64 = 3.5;
     _zzz();
-    if 1 == 1 { _yyy(); }
+    if 1i == 1 { _yyy(); }
 }
 
 fn _zzz() {()}
index 01129c845e9eaa82ed91677215140e611c2a4513..dcfe1804510ad59364b060b30591a10f29731a75 100644 (file)
@@ -30,9 +30,9 @@
 use std::gc::GC;
 
 fn main() {
-    let a = box 1;
-    let b = box() (2, 3.5);
-    let c = box(GC) 4;
+    let a = box 1i;
+    let b = box() (2i, 3.5f64);
+    let c = box(GC) 4i;
     let d = box(GC) false;
     _zzz();
 }
index 7a89b682d1533923c750ad8d79f4819f494f7ce5..cc241040f2bd28335f178778a57a4fa77efdc34c 100644 (file)
@@ -39,8 +39,8 @@ fn some_generic_fun<T1, T2>(a: T1, b: T2) -> (T2, T1) {
 }
 
 fn main() {
-    some_generic_fun(0.5, 10);
-    some_generic_fun(&29, box 110);
+    some_generic_fun(0.5f64, 10i);
+    some_generic_fun(&29i, box 110i);
 }
 
 fn zzz() {()}
index c543a11475e06d38a93fc6e04f9aaaf5989ed656..d91d98f43050ff94d0aaff74378feb050e739dbf 100644 (file)
@@ -156,7 +156,7 @@ fn main() {
     let Struct { a: k, b: l } = Struct { a: 12, b: 13 };
 
     // ignored tuple element
-    let (m, _, n) = (14, 15, 16);
+    let (m, _, n) = (14i, 15i, 16i);
 
     // ignored struct field
     let Struct { b: o, .. } = Struct { a: 17, b: 18 };
@@ -169,25 +169,25 @@ fn main() {
 
     // complex nesting
     let ((u, v), ((w, (x, Struct { a: y, b: z})), Struct { a: ae, b: oe }), ue) =
-        ((25, 26), ((27, (28, Struct { a: 29, b: 30})), Struct { a: 31, b: 32 }), 33);
+        ((25i, 26i), ((27i, (28i, Struct { a: 29, b: 30})), Struct { a: 31, b: 32 }), 33i);
 
     // reference
-    let &aa = &(34, 35);
+    let &aa = &(34i, 35i);
 
     // reference
-    let &bb = &(36, 37);
+    let &bb = &(36i, 37i);
 
     // contained reference
-    let (&cc, _) = (&38, 39);
+    let (&cc, _) = (&38i, 39i);
 
     // unique pointer
-    let box dd = box() (40, 41, 42);
+    let box dd = box() (40i, 41i, 42i);
 
     // ref binding
-    let ref ee = (43, 44, 45);
+    let ref ee = (43i, 44i, 45i);
 
     // ref binding in tuple
-    let (ref ff, gg) = (46, (47, 48));
+    let (ref ff, gg) = (46i, (47i, 48i));
 
     // ref binding in struct
     let Struct { b: ref hh, .. } = Struct { a: 49, b: 50 };
index d439f49fe69253b0ef64db4d99ebc9ec9217dcd3..535efa0b84efc8ce90c9f9da3852530f021db2b4 100644 (file)
@@ -155,7 +155,7 @@ fn non_immediate_args(a: BigStruct, b: BigStruct) {
 }
 
 fn binding(a: i64, b: u64, c: f64) {
-    let x = 0;
+    let x = 0i;
 }
 
 fn assignment(mut a: u64, b: u64, c: f64) {
index a9ccf3cdb161be4c16e5c5204305c84a91c509c5..0160a6f1879dbe3706d2d4db0cf67f161d7b6157 100644 (file)
@@ -152,7 +152,7 @@ fn non_immediate_args(a: BigStruct, b: BigStruct) {
 
 #[no_split_stack]
 fn binding(a: i64, b: u64, c: f64) {
-    let x = 0;
+    let x = 0i;
 }
 
 #[no_split_stack]
index d9b20a84cddf42ef9d9d6436c23f5e02c966c23b..1805405dc1ef5d16522e13edf6f1e711e2a175ee 100644 (file)
@@ -43,8 +43,8 @@
 // gdb-command:continue
 
 fn outer<TA: Clone>(a: TA) {
-    inner(a.clone(), 1);
-    inner(a.clone(), 2.5);
+    inner(a.clone(), 1i);
+    inner(a.clone(), 2.5f64);
 
     fn inner<TX, TY>(x: TX, y: TY) {
         zzz();
index ad088d9a5eba6ccfa74befd10dd32c7c7b817eeb..9ed1c0175a91b50cea50abee50f17e385f74e7b1 100644 (file)
@@ -91,7 +91,7 @@ fn main() {
     let _ = stack.self_by_ref(-1, -2_i8);
     let _ = stack.self_by_val(-3, -4_i16);
 
-    let owned = box Struct { x: 1234.5 };
+    let owned = box Struct { x: 1234.5f64 };
     let _ = owned.self_by_ref(-5, -6_i32);
     let _ = owned.self_by_val(-7, -8_i64);
     let _ = owned.self_owned(-9, -10.5_f32);
index 82a9d7089666f59b0ca5a3a23877c2f6dd6fae06..b62b6f186b9aa6bab0aafebb9ce676ae365045b3 100644 (file)
@@ -61,8 +61,8 @@ fn static_method<T1, T2, T3>(arg1: T1, arg2: T2, arg3: T3) -> int {
 }
 
 fn main() {
-    Struct::static_method(1, 2);
-    Enum::static_method(-3, 4.5, 5);
+    Struct::static_method(1i, 2i);
+    Enum::static_method(-3i, 4.5f64, 5i);
 }
 
 fn zzz() {()}
index eddf4dfd7553ec4a905cdf3839a1f0928283d134..7fec116b8e58255a4dab5a1f4ec630a14b6b5e93 100644 (file)
@@ -72,7 +72,7 @@ fn main() {
     // 0b01011001 = 89
     let case3: Regular<u16, i32, u64>  = Case3 { a: 0, b: 6438275382588823897 };
 
-    let univariant = TheOnlyCase { a: -1 };
+    let univariant = TheOnlyCase { a: -1i };
 
     zzz();
 }
index 69217f4b8785161ac1d0fa6f6ce524bdad30322a..a2c5a0973fca4f2f6bd25c6fc6301393331a7d8c 100644 (file)
@@ -31,10 +31,13 @@ struct AGenericStruct<TKey, TValue> {
 
 fn main() {
 
-    let int_int = AGenericStruct { key: 0, value: 1 };
-    let int_float = AGenericStruct { key: 2, value: 3.5 };
-    let float_int = AGenericStruct { key: 4.5, value: 5 };
-    let float_int_float = AGenericStruct { key: 6.5, value: AGenericStruct { key: 7, value: 8.5 } };
+    let int_int = AGenericStruct { key: 0i, value: 1i };
+    let int_float = AGenericStruct { key: 2i, value: 3.5f64 };
+    let float_int = AGenericStruct { key: 4.5f64, value: 5i };
+    let float_int_float = AGenericStruct {
+        key: 6.5f64,
+        value: AGenericStruct { key: 7i, value: 8.5f64 },
+    };
 
     zzz();
 }
index 0f6ac953179f38a0cfa05f2bb21ea4658a1b59db..0fb823a74cc72c11ba27d7c2e828bc60b27b71c2 100644 (file)
 
 fn main() {
 
-    let range = [1, 2, 3];
+    let range = [1i, 2, 3];
 
-    let x = 1000000; // wan meeeljen doollaars!
+    let x = 1000000i; // wan meeeljen doollaars!
 
     for &x in range.iter() {
         zzz();
         sentinel();
 
-        let x = -1 * x;
+        let x = -1i * x;
 
         zzz();
         sentinel();
index ef573735d0d4c356f452404cabf39820aee4dbe2..6018e62af0078db154ffa225d47e02f3b1355deb 100644 (file)
@@ -80,8 +80,8 @@
 
 fn main() {
 
-    let x = 999;
-    let y = -1;
+    let x = 999i;
+    let y = -1i;
 
     zzz();
     sentinel();
@@ -90,13 +90,13 @@ fn main() {
         zzz();
         sentinel();
 
-        let x = 1001;
+        let x = 1001i;
 
         zzz();
         sentinel();
 
-        let x = 1002;
-        let y = 1003;
+        let x = 1002i;
+        let y = 1003i;
         zzz();
         sentinel();
     } else {
@@ -112,8 +112,8 @@ fn main() {
         zzz();
         sentinel();
 
-        let x = 1004;
-        let y = 1005;
+        let x = 1004i;
+        let y = 1005i;
         zzz();
         sentinel();
     }
index b347afbbbcdb541f9a49579b9a59987061a58cdd..7bec677e4b1005b9e379aa2e69f06011c6967121 100644 (file)
@@ -81,13 +81,13 @@ struct Struct {
 
 fn main() {
 
-    let shadowed = 231;
-    let not_shadowed = 232;
+    let shadowed = 231i;
+    let not_shadowed = 232i;
 
     zzz();
     sentinel();
 
-    match (233, 234) {
+    match (233i, 234i) {
         (shadowed, local_to_arm) => {
 
             zzz();
@@ -95,7 +95,7 @@ fn main() {
         }
     }
 
-    match (235, 236) {
+    match (235i, 236i) {
         // with literal
         (235, shadowed) => {
 
@@ -132,7 +132,7 @@ fn main() {
         _ => {}
     }
 
-    match (243, 244) {
+    match (243i, 244i) {
         (shadowed, ref local_to_arm) => {
 
             zzz();
index ad8f04d1fc795871bd93682b3423b4d003d5d3c7..0e47f2c9921fc5c74314339ee845f1faa4cc4d5d 100644 (file)
@@ -16,6 +16,6 @@
 // Nothing to do here really, just make sure it compiles. See issue #8513.
 fn main() {
     let _ = ||();
-    let _ = range(1u,3).map(|_| 5);
+    let _ = range(1u,3).map(|_| 5i);
 }
 
index c56cdbe0315024bfa466320b829f47704d82945e..0168eaa86c2d1d90d2647113c21a688717e49b07 100644 (file)
@@ -55,7 +55,7 @@ fn main() {
         zzz();
         sentinel();
 
-        let x = 2.5;
+        let x = 2.5f64;
 
         zzz();
         sentinel();
index 12e95c4f9c7430a649990f91ae93a28a1520e256..48edd7ae12a096f4bdcd81659626c6948e510feb 100644 (file)
@@ -84,7 +84,7 @@
 
 fn main() {
 
-    let mut x = 0;
+    let mut x = 0i;
 
     loop {
         if x >= 2 {
@@ -108,7 +108,7 @@ fn main() {
             zzz();
             sentinel();
 
-            let x = -987;
+            let x = -987i;
 
             zzz();
             sentinel();
index 328910b0f1341de46a65c83dfc962c783250a979..ce3b2a530e2c297f38096d3ab075944c6a8777c3 100644 (file)
@@ -55,7 +55,7 @@ fn main() {
         zzz();
         sentinel();
 
-        let x = 2.5;
+        let x = 2.5f64;
 
         zzz();
         sentinel();
index 1b2a9f75182963090143633c6ff4df0361914f4a..d726eb6581eb2cd9778903ae570f65d29ea3fb81 100644 (file)
@@ -84,7 +84,7 @@
 
 fn main() {
 
-    let mut x = 0;
+    let mut x = 0i;
 
     while x < 2 {
         zzz();
@@ -104,7 +104,7 @@ fn main() {
             zzz();
             sentinel();
 
-            let x = -987;
+            let x = -987i;
 
             zzz();
             sentinel();
index 3fb6f10fe332b3ba0c9a145698c27d66b00e9aee..e55271239d488bbf88fadb09e10ba0aaa7450242 100644 (file)
@@ -77,7 +77,7 @@ macro_rules! no_new_scope(
 
 macro_rules! new_scope(
     () => ({
-        let a = 890242;
+        let a = 890242i;
         zzz();
         sentinel();
     })
@@ -105,8 +105,8 @@ macro_rules! dup_expr(
 
 fn main() {
 
-    let a = trivial!(10);
-    let b = no_new_scope!(33);
+    let a = trivial!(10i);
+    let b = no_new_scope!(33i);
 
     zzz();
     sentinel();
@@ -116,12 +116,12 @@ fn main() {
     zzz();
     sentinel();
 
-    shadow_within_macro!(100);
+    shadow_within_macro!(100i);
 
     zzz();
     sentinel();
 
-    let c = dup_expr!(10 * 20);
+    let c = dup_expr!(10i * 20);
 
     zzz();
     sentinel();
index 41b88dc3e981d6f643a210f1197408daf13039d4..2a9969dc6e90310e42fd6466dd2bec61a365dbab 100644 (file)
@@ -227,8 +227,8 @@ fn a_function(x: int) -> int {
 
 fn main() {
 
-    let val = -1;
-    let ten = 10;
+    let val = -1i;
+    let ten = 10i;
 
     // surrounded by struct expression
     let point = Point {
@@ -280,7 +280,7 @@ fn main() {
         sentinel();
 
         val
-    }, 0);
+    }, 0i);
 
     zzz();
     sentinel();
@@ -355,7 +355,7 @@ fn main() {
     sentinel();
 
     // index expression
-    let a_vector = [10, ..20];
+    let a_vector = [10i, ..20];
     let _ = a_vector[{
         zzz();
         sentinel();
index 616f312c0784696259c0643de24b6e591c4d60e4..9cda2c45131db1f4e7ae770f6d0738acc2c8c9e2 100644 (file)
@@ -46,7 +46,7 @@ fn zzz() {()}
 
 fn some_function(a: int, b: int) {
     let some_variable = Struct { a: 11, b: 22 };
-    let some_other_variable = 23;
+    let some_other_variable = 23i;
     zzz();
 }
 
index b56db2d18468e2b3222d099bd75c43ea1ae4ddca..cc18ea64f383eeedeb74cbd18cf239ac3b66632a 100644 (file)
@@ -37,9 +37,9 @@ struct ContainsManaged {
 }
 
 fn main() {
-    let ordinary_unique = box() (-1, -2);
+    let ordinary_unique = box() (-1i, -2i);
 
-    let managed_within_unique = box ContainsManaged { x: -3, y: box(GC) -4 };
+    let managed_within_unique = box ContainsManaged { x: -3, y: box(GC) -4i };
 
     zzz();
 }
index 2f7b0c845ea80706ebede78e8127eabfa5715290..0bac86b1e66aa346c3db94632e614fb2c3999561 100644 (file)
@@ -91,7 +91,7 @@ fn main() {
     let _ = stack.self_by_ref(-1, -2);
     let _ = stack.self_by_val(-3, -4);
 
-    let owned = box Struct { x: 1234.5 };
+    let owned = box Struct { x: 1234.5f64 };
     let _ = owned.self_by_ref(-5, -6);
     let _ = owned.self_by_val(-7, -8);
     let _ = owned.self_owned(-9, -10);
index 510718254d9045afd00fd76ce5745114f0f0390f..9e40f03c201626a8a791c6224089e8f77af0a28b 100644 (file)
 #![allow(unused_variable)]
 
 fn function_one() {
-    let abc = 10101;
+    let abc = 10101i;
     zzz();
 }
 
 fn function_two() {
-    let abc = 20202;
+    let abc = 20202i;
     zzz();
 }
 
 
 fn function_three() {
-    let abc = 30303;
+    let abc = 30303i;
     zzz();
 }
 
index 362a8a93dd19b8a4e770beceabb42282502b8483..ef1c69f9eb8cf50a2744ffcfc015a5f76c13afea 100644 (file)
 #![allow(unused_variable)]
 
 fn function_one() {
-    let a = 10101;
+    let a = 10101i;
     zzz();
 }
 
 fn function_two() {
-    let b = 20202;
+    let b = 20202i;
     zzz();
 }
 
 
 fn function_three() {
-    let c = 30303;
+    let c = 30303i;
     zzz();
 }
 
index f967ced38ec11518beb3b60e8d9a36b35bf2b535..8ee6d434016f0b946cdecc1e00a244d870deeee9 100644 (file)
@@ -63,25 +63,25 @@ fn main() {
     zzz();
     sentinel();
 
-    let x = 10;
+    let x = 10i;
 
     zzz();
     sentinel();
 
-    let x = 10.5;
-    let y = 20;
+    let x = 10.5f64;
+    let y = 20i;
 
     zzz();
     sentinel();
 
     {
         let x = true;
-        let y = 2220;
+        let y = 2220i;
 
         zzz();
         sentinel();
 
-        let x = 203203.5;
+        let x = 203203.5f64;
 
         zzz();
         sentinel();
index 04cd7e1386324312ff7ad2325105a5ddadecfa2a..de6d6814308d8d6e0751a013909682690692ed9d 100644 (file)
@@ -72,18 +72,18 @@ struct NamedFieldsRepr<'a> {
 
 fn main() {
 
-    let some: Option<&u32> = Some(unsafe { std::mem::transmute(0x12345678) });
+    let some: Option<&u32> = Some(unsafe { std::mem::transmute(0x12345678u) });
     let none: Option<&u32> = None;
 
-    let full = Full(454545, unsafe { std::mem::transmute(0x87654321) }, 9988);
+    let full = Full(454545, unsafe { std::mem::transmute(0x87654321u) }, 9988);
 
-    let int_val = 0;
+    let int_val = 0i;
     let empty: &MoreFieldsRepr = unsafe { std::mem::transmute(&Empty) };
 
     let droid = Droid {
         id: 675675,
         range: 10000001,
-        internals: unsafe { std::mem::transmute(0x43218765) }
+        internals: unsafe { std::mem::transmute(0x43218765u) }
     };
 
     let void_droid: &NamedFieldsRepr = unsafe { std::mem::transmute(&Void) };
index 129263c0f7649d69649fb55dc8ee33f46c1271e8..c180d6b5bcfe7c5eadfb7af99544eb5d6bd80534 100644 (file)
@@ -39,13 +39,13 @@ fn a_function(x: bool, y: bool) {
     zzz();
     sentinel();
 
-    let x = 10;
+    let x = 10i;
 
     zzz();
     sentinel();
 
-    let x = 10.5;
-    let y = 20;
+    let x = 10.5f64;
+    let y = 20i;
 
     zzz();
     sentinel();
index 825ecb9c0ca7f74aac57932f011c857fb2988309..88ef3c4879e90d41eafe019100e0987b0cd1945a 100644 (file)
@@ -42,13 +42,13 @@ fn main() {
     zzz();
     sentinel();
 
-    let x = 10;
+    let x = 10i;
 
     zzz();
     sentinel();
 
-    let x = 10.5;
-    let y = 20;
+    let x = 10.5f64;
+    let y = 20i;
 
     zzz();
     sentinel();
index 171e3eae659f1c192026b006eb1092db2b05260c..107b64131e053d577b0e5a21ab81ae0414c7ea08 100644 (file)
@@ -60,7 +60,7 @@ fn main() {
         zzz();
         sentinel();
 
-        let x = 10;
+        let x = 10i;
 
         zzz();
         sentinel();
@@ -69,7 +69,7 @@ fn main() {
             zzz();
             sentinel();
 
-            let x = 10.5;
+            let x = 10.5f64;
 
             zzz();
             sentinel();
index 11f317469a27c5a072345bc7024c1047c8f4bb10..155865f415b6398aab09a1f6557108892a66961c 100644 (file)
@@ -26,7 +26,7 @@
 static mut VECT: [i32, ..3] = [1, 2, 3];
 
 fn main() {
-    let a = [1, 2, 3];
+    let a = [1i, 2, 3];
 
     unsafe {
         VECT[0] = 4;
index 20d634d047535dc3b93a5514b7115a3ac8c7631a..9433ddf1a1fc87f7cd59af5d600a719e9636a399 100644 (file)
@@ -17,9 +17,9 @@
 use std::cell::Cell;
 use std::gc::GC;
 
-fn test1() { let val = box(GC) 0; { } *val; }
+fn test1() { let val = box(GC) 0i; { } *val; }
 
-fn test2() -> int { let val = box(GC) 0; { } *val }
+fn test2() -> int { let val = box(GC) 0i; { } *val }
 
 struct S { eax: int }
 
@@ -36,13 +36,13 @@ fn test5() -> (int, int) { { } (0, 1) }
 fn test6() -> bool { { } (true || false) && true }
 
 fn test7() -> uint {
-    let regs = box(GC) 0;
+    let regs = box(GC) 0i;
     match true { true => { } _ => { } }
     (*regs < 2) as uint
 }
 
 fn test8() -> int {
-    let val = box(GC) 0;
+    let val = box(GC) 0i;
     match true {
         true => { }
         _    => { }
@@ -55,12 +55,12 @@ fn test8() -> int {
 }
 
 fn test9() {
-    let regs = box(GC) Cell::new(0);
+    let regs = box(GC) Cell::new(0i);
     match true { true => { } _ => { } } regs.set(regs.get() + 1);
 }
 
 fn test10() -> int {
-    let regs = box(GC) vec!(0);
+    let regs = box(GC) vec!(0i);
     match true { true => { } _ => { } }
     *(*regs).get(0)
 }
index 636fac82b6b00ae8a3c31010efd932cbe1196b35..85b71e4e86cc7bcb47feb1b664ccffff412ef138 100644 (file)
@@ -8,6 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn f() { if (1 == fail!()) { } else { } }
+fn f() { if (1i == fail!()) { } else { } }
 
 fn main() { }
index 5cf6d838f253fc987ae2b2cc8a8fea6afb25e326..c03ad499478925cbea5dd7e6afa5774e96c3c5f6 100644 (file)
@@ -11,7 +11,7 @@
 // pp-exact
 
 fn main() {
-    let x = Some(3);
+    let x = Some(3i);
     let _y =
         match x {
             Some(_) =>
index bb14a74fc183e8ce0daf2f1a80f70da8da15c908..67c389f7e1f0870748224e1bb40db04f79517f48 100644 (file)
@@ -11,7 +11,7 @@
 // pp-exact
 
 fn main() {
-    let x = Some(3);
+    let x = Some(3i);
     let _y =
         match x {
             Some(_) => "some(_)".to_string(),
index 1592e010aaff770537a7f36ee76eb80867ccb86a..850904fe53e44551294bcbdcfb2199e554ca3a4f 100644 (file)
@@ -18,10 +18,10 @@ fn block_nosemi() -> int { ({ 0 }) - 1 }
 
 fn if_semi() -> int { if true { f() } else { f() }; -1 }
 
-fn if_nosemi() -> int { (if true { 0 } else { 0 }) - 1 }
+fn if_nosemi() -> int { (if true { 0i } else { 0i }) - 1 }
 
 fn alt_semi() -> int { match true { true => { f() } _ => { } }; -1 }
 
 fn alt_no_semi() -> int { (match true { true => { 0 } _ => { 1 } }) - 1 }
 
-fn stmt() { { f() }; -1; }
+fn stmt() { { f() }; -1i; }
index dc2dae1044dac2354ef981979bce687c4384e4cd..401c63efbc468572c96071d4f240a51bd651c6a3 100644 (file)
@@ -15,25 +15,25 @@ fn main() {
     let _v1 =
         [
          // Comment
-         0,
+         0i,
          // Comment
-         1,
+         1i,
          // Comment
-         2];
+         2i];
     let _v2 =
-        [0, // Comment
-         1, // Comment
-         2]; // Comment
+        [0i, // Comment
+         1i, // Comment
+         2i]; // Comment
     let _v3 =
         [
          /* Comment */
-         0,
+         0i,
          /* Comment */
-         1,
+         1i,
          /* Comment */
-         2];
+         2i];
     let _v4 =
-        [0, /* Comment */
-         1, /* Comment */
-         2]; /* Comment */
+        [0i, /* Comment */
+         1i, /* Comment */
+         2i]; /* Comment */
 }
index dc2dae1044dac2354ef981979bce687c4384e4cd..401c63efbc468572c96071d4f240a51bd651c6a3 100644 (file)
@@ -15,25 +15,25 @@ fn main() {
     let _v1 =
         [
          // Comment
-         0,
+         0i,
          // Comment
-         1,
+         1i,
          // Comment
-         2];
+         2i];
     let _v2 =
-        [0, // Comment
-         1, // Comment
-         2]; // Comment
+        [0i, // Comment
+         1i, // Comment
+         2i]; // Comment
     let _v3 =
         [
          /* Comment */
-         0,
+         0i,
          /* Comment */
-         1,
+         1i,
          /* Comment */
-         2];
+         2i];
     let _v4 =
-        [0, /* Comment */
-         1, /* Comment */
-         2]; /* Comment */
+        [0i, /* Comment */
+         1i, /* Comment */
+         2i]; /* Comment */
 }
index c52c11b1b91881c68963d854fa45242ebedae8bc..fb069e61bd2a1b571a2bd36367cbabbf74ae6ac7 100644 (file)
@@ -8,8 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern:assertion failed: 1 == 2
+// error-pattern:assertion failed: 1i == 2
 
 fn main() {
-    assert!(1 == 2);
+    assert!(1i == 2);
 }
index be4ad0781f272f9ee40110772d5b1b79000ca3e9..df9050e218631b15161a7ae94200ee8c2497a99d 100644 (file)
@@ -14,6 +14,6 @@
 use std::mem::size_of;
 
 fn main() {
-    let xs = [1, 2, 3];
+    let xs = [1i, 2, 3];
     xs[uint::MAX / size_of::<int>() + 1];
 }
index de69b7b9fa6705ed03afd7c07abd96ef49415334..c58d30f272996dac263e14bf161e8c57baff7530 100644 (file)
@@ -10,6 +10,6 @@
 
 // error-pattern:attempted to divide by zero
 fn main() {
-    let y = 0;
-    let _z = 1 / y;
+    let y = 0i;
+    let _z = 1i / y;
 }
index f860fdffba1a329da93e3be96b830279f5f659ac..4af9b82ec7e22edf440ded5f61caab38f6812cea 100644 (file)
@@ -13,7 +13,7 @@
 
 // error-pattern:wooooo
 fn main() {
-    let mut a = 1;
-    if 1 == 1 { a = 2; }
+    let mut a = 1i;
+    if 1i == 1 { a = 2; }
     fail!(format!("woooo{}", "o"));
 }
index 73259e6e140f549d57664a736d44a8f22ccbe89a..55d86bc6493245722ce004567b6eefc7505af0f4 100644 (file)
@@ -12,4 +12,4 @@
 
 
 // error-pattern:explicit failure
-fn main() { let _x = if false { 0 } else if true { fail!() } else { 10 }; }
+fn main() { let _x = if false { 0i } else if true { fail!() } else { 10i }; }
index 075f6f5b4b1908286d50cac779bb9876bf0b4a94..d15ec3f7b486ab00150fea6c0915a37e168c1d5a 100644 (file)
@@ -12,4 +12,4 @@
 
 
 // error-pattern:explicit failure
-fn main() { let _x = match true { false => { 0 } true => { fail!() } }; }
+fn main() { let _x = match true { false => { 0i } true => { fail!() } }; }
index b1c8963e684d68bd8cfb5d27f9a6e256746878af..edb03b2d6b461ec110fe191f4c36a8d9a1b2d79c 100644 (file)
@@ -16,7 +16,7 @@ fn main() {
     let r: Result<int,_> = TaskBuilder::new().named("owned name".to_string())
                                              .try(proc() {
         fail!("test");
-        1
+        1i
     });
     assert!(r.is_ok());
 }
index 5153c5f2807b04b36f332cb36a472c89a548d080..0a74009977828e4ffa152f6d29131eaed7b86820 100644 (file)
@@ -15,7 +15,7 @@ fn main() {
         ::std::task::TaskBuilder::new().named("send name".into_maybe_owned())
                                        .try(proc() {
             fail!("test");
-            3
+            3i
         });
     assert!(r.is_ok());
 }
index 42cf79af66ee80626288eecc899ce8969ec6194e..54ccc98bcd9243d61f8c19eb01c855113358534c 100644 (file)
@@ -11,5 +11,5 @@
 
 
 
-// error-pattern:1 == 2
-fn main() { assert!((1 == 2)); }
+// error-pattern:1i == 2
+fn main() { assert!((1i == 2)); }
index a57f4683df315c6998931257667da01ddbbc51bc..80e275019ce24494acc57e1ba71bf1ddb3f95995 100644 (file)
@@ -16,7 +16,7 @@
 // error-pattern:so long
 fn main() {
     let mut x = Vec::new();
-    let y = vec!(3);
+    let y = vec!(3i);
     fail!("so long");
     x.push_all_move(y);
 }
index 76d4de7ecb03ce907b987c4e16e705a4dc36373e..544150517084c555691dc54cb9d9100ade80480c 100644 (file)
@@ -10,6 +10,6 @@
 
 // error-pattern:attempted remainder with a divisor of zero
 fn main() {
-    let y = 0;
-    let _z = 1 % y;
+    let y = 0i;
+    let _z = 1i % y;
 }
index 2f6bd9ad255e022fa763b7c37c20fad9e0302aee..c4dd8802d8a841f0ca1b7a65417430f83aace6f1 100644 (file)
@@ -15,6 +15,6 @@
 use std::gc::GC;
 
 fn main() {
-    let _a = box(GC) 0;
+    let _a = box(GC) 0i;
     assert!(false);
 }
index c370846c673db5240610f89512664d48eb228cab..f80f25ec6ebc2aabd8f05ec35614207675349ef4 100644 (file)
@@ -41,7 +41,7 @@ fn r(v: *const int) -> r {
 
 fn main() {
     unsafe {
-        let i1 = box 0;
+        let i1 = box 0i;
         let i1p = mem::transmute_copy(&i1);
         mem::forget(i1);
         let x = box(GC) r(i1p);
index e31f66ed9fb0857eb8cac854d2c9e6053443fa40..3647c553bf218a0118dddfb3d76020a7bf588340 100644 (file)
@@ -19,6 +19,6 @@ fn failfn() {
 }
 
 fn main() {
-    box(GC) 0;
+    box(GC) 0i;
     failfn();
 }
index 5dbfd73c1d7e7cea1334beca85348a177bfc2149..e25fe1908ba53f8cc21999329976f247e796d542 100644 (file)
@@ -15,6 +15,6 @@
 use std::gc::GC;
 
 fn main() {
-    box(GC) 0;
+    box(GC) 0i;
     fail!();
 }
index 6f2400ec4f0e441b65a4a741ad09468eb31cd24a..f6a3aa48def9b224e78d5b4b833eb7b7cddd142c 100644 (file)
@@ -15,8 +15,8 @@ fn a() { }
 fn b() { fail!(); }
 
 fn main() {
-    let _x = vec!(0);
+    let _x = vec!(0i);
     a();
-    let _y = vec!(0);
+    let _y = vec!(0i);
     b();
 }
index 8671758c42307cca64f4ec6dfe4e2faa25d6e1be..d77a9f911b5ef45ef8f9130ccf92e0cf7b88ff45 100644 (file)
@@ -22,6 +22,6 @@ fn x(it: |int|) {
 }
 
 fn main() {
-    let a = box(GC) 0;
+    let a = box(GC) 0i;
     x(|_i| { } );
 }
index d7b950ad5c19fa7a24484ebabd376802dab94044..9f00c0bc8bace24943e1303b8bccf0dad497c147 100644 (file)
@@ -15,7 +15,7 @@
 use std::gc::{GC};
 
 fn x(it: |int|) {
-    let _a = box(GC) 0;
+    let _a = box(GC) 0i;
     it(1);
 }
 
index 4f1e454c39e3f02731252f2bfd69823cd600c63d..f256884b312a706bf29a597a5291f263a596efad 100644 (file)
@@ -16,7 +16,7 @@
 use std::gc::GC;
 
 fn test_box() {
-    box(GC) 0;
+    box(GC) 0i;
 }
 fn test_str() {
   let res = match false { true => { "happy".to_string() },
index b7a12f08c410e8e4536897066e851cedc36914b7..bebf06cf45aebd6033c3bf34497eeadb07cc5c5e 100644 (file)
@@ -15,9 +15,9 @@
 use std::gc::GC;
 
 fn main() {
-    let _a = box(GC) 0;
+    let _a = box(GC) 0i;
     {
-        let _b = box(GC) 0;
+        let _b = box(GC) 0i;
         {
             fail!();
         }
index 2bd264d0e3365b34a1ec278574b8a3c2f3411cc0..5912f8167bc4948bb631a569bc79cd528076f4c3 100644 (file)
@@ -19,7 +19,7 @@
 // Voodoo. In unwind-alt we had to do this to trigger the bug. Might
 // have been to do with memory allocation patterns.
 fn prime() {
-    box(GC) 0;
+    box(GC) 0i;
 }
 
 fn partial() {
index 4ea099e9c0f36f34522eacc56f571279302cbc60..2e6eee65738927bf804908afe119ba3d532734fb 100644 (file)
@@ -19,7 +19,7 @@
 // Voodoo. In unwind-alt we had to do this to trigger the bug. Might
 // have been to do with memory allocation patterns.
 fn prime() {
-    box(GC) 0;
+    box(GC) 0i;
 }
 
 fn partial() {
index e0e043f623ba6f7f8855f498b3dfbcab4dbcb463..7ad02fcd3d75365f3914b44955dd3bd791900800 100644 (file)
 // Voodoo. In unwind-alt we had to do this to trigger the bug. Might
 // have been to do with memory allocation patterns.
 fn prime() {
-    box(GC) 0;
+    box(GC) 0i;
 }
 
 fn partial() {
-    let _x = vec!(vec!(0), f(), vec!(0));
+    let _x = vec!(vec!(0i), f(), vec!(0i));
 }
 
 fn main() {
index 498d3ee6b0bc1484fc72061a74df935d313b3731..8d0a14306d9901749d78059f272452fc72f924d4 100644 (file)
@@ -25,6 +25,6 @@ fn drop(&mut self) { fail!("squirrel") }
 fn r(i: int) -> r { r { i: i } }
 
 fn main() {
-    box(GC) 0;
+    box(GC) 0i;
     let _r = r(0);
 }
index da6205e9e373477fd6d22de518775e0ddd09476d..97f4d974d8dd68f5837c834fc2729a967b8c5fab 100644 (file)
 use std::gc::GC;
 
 fn f() {
-    let _a = box(GC) 0;
+    let _a = box(GC) 0i;
     fail!();
 }
 
 fn g() {
-    let _b = box(GC) 0;
+    let _b = box(GC) 0i;
     f();
 }
 
 fn main() {
-    let _a = box(GC) 0;
+    let _a = box(GC) 0i;
     g();
 }
index 08a22a7c355b779e82f7a7458ab9d99e2fc7b8e7..4a7914c568aca7d17723f0fbd57e72be8804f26e 100644 (file)
@@ -19,5 +19,5 @@ fn fold_local() -> Gc<Vec<int>> {
 }
 
 fn main() {
-    let _lss = (fold_local(), 0);
+    let _lss = (fold_local(), 0i);
 }
index acba93f7be3ba7e6de20e01d3ad19b698b04d6a9..29723b127290168fea77d741ae3320f031db3d2c 100644 (file)
@@ -20,5 +20,5 @@ fn f() {
 
 fn main() {
     f();
-    let _a = box(GC) 0;
+    let _a = box(GC) 0i;
 }
index af1e499d1f20390f485dbbf06ec5061a2f1510a8..233d367c4b1e16b2b7fee4b109dbe0926b4c93ab 100644 (file)
@@ -16,6 +16,6 @@ fn failfn() {
 }
 
 fn main() {
-    box 0;
+    box 0i;
     failfn();
 }
index 9d8411cfc58df447b93f9755e08cc1cecb9dd8b3..a5239a6cc665b3c67f243ac15e8798424a8a01b4 100644 (file)
@@ -1,8 +1,8 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 1"];
-    N3[label="block { 1; }"];
+    N2[label="expr 1i"];
+    N3[label="block { 1i; }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N1;
index 231aab69e50d95cd17f843f9047e6aab15ffc0c8..f1f1a1d5472f70423a77b33a82cf2dc36ff7cded 100644 (file)
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 pub fn lit_1() {
-    1;
+    1i;
 }
index aff430459e87229e65f80db04ca1fbb536f5460a..43462862f6ea9ef28166e58f736e7f578e9a24b1 100644 (file)
@@ -1,10 +1,10 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 3"];
-    N3[label="expr 33"];
-    N4[label="expr 3 + 33"];
-    N5[label="block { 3 + 33; }"];
+    N2[label="expr 3i"];
+    N3[label="expr 33i"];
+    N4[label="expr 3i + 33i"];
+    N5[label="block { 3i + 33i; }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index 8b172c0a10512655dfa0b6dc97b038f718b038ce..1007225f2f291ece6cf5c7cf4728b1e023a154b7 100644 (file)
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 pub fn expr_add_3() {
-    3 + 33;
+    3i + 33i;
 }
index adcc582c73387c646d5ea4957934e16ba8391a45..26c858a0828cab6a71f8f910a653d921f0f9bea7 100644 (file)
@@ -1,9 +1,9 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 4"];
+    N2[label="expr 4i"];
     N3[label="local _x"];
-    N4[label="block { let _x = 4; }"];
+    N4[label="block { let _x = 4i; }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index 2a0ac8ac9e57080224887d5891db71bc5a6b72c4..ed2f7e25dae6ce13b58da32e7a7f0fa23ef24f6d 100644 (file)
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 pub fn pat_id_4() {
-    let _x = 4;
+    let _x = 4i;
 }
index 2d52c14da6246aa5af033f20884922ec8bd3af34..850d04f430f0d4302c1fbe011f051398fa4b49f1 100644 (file)
@@ -1,13 +1,13 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 5"];
-    N3[label="expr 55"];
-    N4[label="expr (5, 55)"];
+    N2[label="expr 5i"];
+    N3[label="expr 55i"];
+    N4[label="expr (5i, 55i)"];
     N5[label="local _x"];
     N6[label="local _y"];
     N7[label="pat (_x, _y)"];
-    N8[label="block { let (_x, _y) = (5, 55); }"];
+    N8[label="block { let (_x, _y) = (5i, 55i); }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index 616d822bed07bf61283be397aff1ba42d61790c7..b2591bdd08a16843b1fcff0d0486d90c9ebab96f 100644 (file)
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 pub fn pat_tup_5() {
-    let (_x, _y) = (5, 55);
+    let (_x, _y) = (5i, 55i);
 }
index c99af1791495ff7605fd23eff22f8070e5aabc3c..251798fc7ed889d47de3bd9265ee8eb97b061d1b 100644 (file)
@@ -1,12 +1,12 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 7"];
-    N3[label="expr 77"];
-    N4[label="expr 777"];
-    N5[label="expr 7777"];
-    N6[label="expr [7, 77, 777, 7777]"];
-    N7[label="expr match [7, 77, 777, 7777] { [x, y, ..] => x + y }"];
+    N2[label="expr 7i"];
+    N3[label="expr 77i"];
+    N4[label="expr 777i"];
+    N5[label="expr 7777i"];
+    N6[label="expr [7i, 77i, 777i, 7777i]"];
+    N7[label="expr match [7i, 77i, 777i, 7777i] { [x, y, ..] => x + y }"];
     N8[label="local x"];
     N9[label="local y"];
     N10[label="pat .."];
@@ -14,7 +14,7 @@ digraph block {
     N12[label="expr x"];
     N13[label="expr y"];
     N14[label="expr x + y"];
-    N15[label="block { match [7, 77, 777, 7777] { [x, y, ..] => x + y }; }"];
+    N15[label="block { match [7i, 77i, 777i, 7777i] { [x, y, ..] => x + y }; }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index 39f71d309fdf9363d55bba93be259e0c8a51878a..fb3f2d24cddc7d0b055d5fb0db6fea43c10b9964 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 pub fn pat_vec_7() {
-    match [7, 77, 777, 7777] {
+    match [7i, 77i, 777i, 7777i] {
         [x, y, ..] => x + y
     };
 }
index 61a708cd9ccd4c1b15276a3a1538d572e3fac4ad..f43beb025e34581d663af2c02c641a244dc3b220 100644 (file)
@@ -1,18 +1,18 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 8"];
+    N2[label="expr 8i"];
     N3[label="local x"];
     N4[label="local _y"];
     N5[label="expr x"];
-    N6[label="expr 88"];
-    N7[label="expr x > 88"];
-    N8[label="expr 888"];
+    N6[label="expr 88i"];
+    N7[label="expr x > 88i"];
+    N8[label="expr 888i"];
     N9[label="expr _y"];
-    N10[label="expr _y = 888"];
-    N11[label="block { _y = 888; }"];
-    N12[label="expr if x > 88 { _y = 888; }"];
-    N13[label="block { let x = 8; let _y; if x > 88 { _y = 888; } }"];
+    N10[label="expr _y = 888i"];
+    N11[label="block { _y = 888i; }"];
+    N12[label="expr if x > 88i { _y = 888i; }"];
+    N13[label="block { let x = 8i; let _y; if x > 88i { _y = 888i; } }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index 6ba7b03d54da5f206a715299aee42935965c559b..5d166e5ffcd5d6800bc5e3851bed90e3e3e9c8fb 100644 (file)
@@ -9,8 +9,8 @@
 // except according to those terms.
 
 pub fn expr_if_onearm_8() {
-    let x = 8; let _y;
-    if x > 88 {
-        _y = 888;
+    let x = 8i; let _y;
+    if x > 88i {
+        _y = 888i;
     }
 }
index 892b9fcd841f8b6849864472d3165e6ba2697634..a3576b9c36b69b10318f9a9d779516e3a07a601d 100644 (file)
@@ -1,25 +1,25 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 91"];
+    N2[label="expr 91i"];
     N3[label="local x"];
     N4[label="local _y"];
     N5[label="expr x"];
-    N6[label="expr 92"];
-    N7[label="expr x > 92"];
-    N8[label="expr 93"];
+    N6[label="expr 92i"];
+    N7[label="expr x > 92i"];
+    N8[label="expr 93i"];
     N9[label="expr _y"];
-    N10[label="expr _y = 93"];
-    N11[label="block { _y = 93; }"];
-    N12[label="expr 94"];
-    N13[label="expr 95"];
-    N14[label="expr 94 + 95"];
+    N10[label="expr _y = 93i"];
+    N11[label="block { _y = 93i; }"];
+    N12[label="expr 94i"];
+    N13[label="expr 95i"];
+    N14[label="expr 94i + 95i"];
     N15[label="expr _y"];
-    N16[label="expr _y = 94 + 95"];
-    N17[label="block { _y = 94 + 95; }"];
-    N18[label="expr { _y = 94 + 95; }"];
-    N19[label="expr if x > 92 { _y = 93; } else { _y = 94 + 95; }"];
-    N20[label="block { let x = 91; let _y; if x > 92 { _y = 93; } else { _y = 94 + 95; } }"];
+    N16[label="expr _y = 94i + 95i"];
+    N17[label="block { _y = 94i + 95i; }"];
+    N18[label="expr { _y = 94i + 95i; }"];
+    N19[label="expr if x > 92i { _y = 93i; } else { _y = 94i + 95i; }"];
+    N20[label="block { let x = 91i; let _y; if x > 92i { _y = 93i; } else { _y = 94i + 95i; } }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index a78ccb8a93741a174368a5df7232510281d7d63a..cfe5f4f37d60fd438e23505e1a38a40951548410 100644 (file)
@@ -9,10 +9,10 @@
 // except according to those terms.
 
 pub fn expr_if_twoarm_9() {
-    let x = 91; let _y;
-    if x > 92 {
-        _y = 93;
+    let x = 91i; let _y;
+    if x > 92i {
+        _y = 93i;
     } else {
-        _y = 94+95;
+        _y = 94i+95i;
     }
 }
index 2cef122104edabadbb2969a6a80f87bb04db002f..69b5bd6f58cdf6d5cf6683f69bfc86b3ac4c9bd1 100644 (file)
@@ -1,18 +1,18 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 10"];
+    N2[label="expr 10i"];
     N3[label="local mut x"];
     N4[label="(dummy_node)"];
     N5[label="expr x"];
-    N6[label="expr 0"];
-    N7[label="expr x > 0"];
-    N8[label="expr while x > 0 { x -= 1; }"];
-    N9[label="expr 1"];
+    N6[label="expr 0i"];
+    N7[label="expr x > 0i"];
+    N8[label="expr while x > 0i { x -= 1i; }"];
+    N9[label="expr 1i"];
     N10[label="expr x"];
-    N11[label="expr x -= 1"];
-    N12[label="block { x -= 1; }"];
-    N13[label="block { let mut x = 10; while x > 0 { x -= 1; } }"];
+    N11[label="expr x -= 1i"];
+    N12[label="block { x -= 1i; }"];
+    N13[label="block { let mut x = 10i; while x > 0i { x -= 1i; } }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index 0ca7cc5ee86bd7f31ac6dda1a7c95140feba4e10..af263f0cf10db995287ba66b4793afe089ac6140 100644 (file)
@@ -9,8 +9,8 @@
 // except according to those terms.
 
 pub fn expr_while_10() {
-    let mut x = 10;
-    while x > 0 {
-        x -= 1;
+    let mut x = 10i;
+    while x > 0i {
+        x -= 1i;
     }
 }
index 59d65e5b8b7fc028e82f92d8e98fb2365394e576..44024cf76f31a1656df22cecadd770a33ea26e9e 100644 (file)
@@ -1,16 +1,16 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 11"];
+    N2[label="expr 11i"];
     N3[label="local mut _x"];
     N4[label="(dummy_node)"];
-    N5[label="expr loop  { _x -= 1; }"];
-    N6[label="expr 1"];
+    N5[label="expr loop  { _x -= 1i; }"];
+    N6[label="expr 1i"];
     N7[label="expr _x"];
-    N8[label="expr _x -= 1"];
-    N9[label="block { _x -= 1; }"];
+    N8[label="expr _x -= 1i"];
+    N9[label="block { _x -= 1i; }"];
     N10[label="expr \"unreachable\""];
-    N11[label="block { let mut _x = 11; loop  { _x -= 1; } \"unreachable\"; }"];
+    N11[label="block { let mut _x = 11i; loop  { _x -= 1i; } \"unreachable\"; }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index d0f3452119e16b512712c5b22673aec811cd9122..95260c608eca4cfbc3f92b284a5771c5805abbbf 100644 (file)
@@ -10,9 +10,9 @@
 
 #[allow(unreachable_code)]
 pub fn expr_loop_11() {
-    let mut _x = 11;
+    let mut _x = 11i;
     loop {
-        _x -= 1;
+        _x -= 1i;
     }
     "unreachable";
 }
index 9c0f25d5bece5eb8617ab57ddebf595bbfd8f2d7..ad257c19741b339719af363dc020188002828f12 100644 (file)
@@ -1,23 +1,23 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 12"];
+    N2[label="expr 12i"];
     N3[label="local mut x"];
     N4[label="(dummy_node)"];
-    N5[label="expr loop  { x -= 1; if x == 2 { break ; \"unreachable\"; } }"];
-    N6[label="expr 1"];
+    N5[label="expr loop  { x -= 1i; if x == 2i { break ; \"unreachable\"; } }"];
+    N6[label="expr 1i"];
     N7[label="expr x"];
-    N8[label="expr x -= 1"];
+    N8[label="expr x -= 1i"];
     N9[label="expr x"];
-    N10[label="expr 2"];
-    N11[label="expr x == 2"];
+    N10[label="expr 2i"];
+    N11[label="expr x == 2i"];
     N12[label="expr break"];
     N13[label="(dummy_node)"];
     N14[label="expr \"unreachable\""];
     N15[label="block { break ; \"unreachable\"; }"];
-    N16[label="expr if x == 2 { break ; \"unreachable\"; }"];
-    N17[label="block { x -= 1; if x == 2 { break ; \"unreachable\"; } }"];
-    N18[label="block { let mut x = 12; loop  { x -= 1; if x == 2 { break ; \"unreachable\"; } } }"];
+    N16[label="expr if x == 2i { break ; \"unreachable\"; }"];
+    N17[label="block { x -= 1i; if x == 2i { break ; \"unreachable\"; } }"];
+    N18[label="block { let mut x = 12i; loop  { x -= 1i; if x == 2i { break ; \"unreachable\"; } } }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
@@ -28,7 +28,7 @@ digraph block {
     N9 -> N10;
     N10 -> N11;
     N11 -> N12;
-    N12 -> N5[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 2 { break ; \"unreachable\"; },\lexiting scope_4 block { x -= 1; if x == 2 { break ; \"unreachable\"; } }"];
+    N12 -> N5[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 2i { break ; \"unreachable\"; },\lexiting scope_4 block { x -= 1i; if x == 2i { break ; \"unreachable\"; } }"];
     N13 -> N14;
     N14 -> N15;
     N11 -> N16;
index 90b146340b6f5ddf53f674e239c0a55ce9f169f4..625dd8cb03ef9f294abddebb8db2d912374f894e 100644 (file)
@@ -10,9 +10,9 @@
 
 #[allow(unreachable_code)]
 pub fn expr_loop_12() {
-    let mut x = 12;
+    let mut x = 12i;
     loop {
-        x -= 1;
-        if x == 2 { break; "unreachable"; }
+        x -= 1i;
+        if x == 2i { break; "unreachable"; }
     }
 }
index 0fa4e9b44de348dfe3431dfd26655ed3e33d0390..f8e4bd12bb031156b94d6c315e3a688327cac2ce 100644 (file)
@@ -1,17 +1,17 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 14"];
+    N2[label="expr 14i"];
     N3[label="local x"];
     N4[label="expr x"];
-    N5[label="expr 1"];
-    N6[label="expr x > 1"];
+    N5[label="expr 1i"];
+    N6[label="expr x > 1i"];
     N7[label="expr return"];
     N8[label="(dummy_node)"];
     N9[label="expr \"unreachable\""];
     N10[label="block { return; \"unreachable\"; }"];
-    N11[label="expr if x > 1 { return; \"unreachable\"; }"];
-    N12[label="block { let x = 14; if x > 1 { return; \"unreachable\"; } }"];
+    N11[label="expr if x > 1i { return; \"unreachable\"; }"];
+    N12[label="block { let x = 14i; if x > 1i { return; \"unreachable\"; } }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index 98ff095c8317cf1fc49004f18fb3209fd4bfe0d3..72616f315948733468243f4f3453c56023fa701b 100644 (file)
@@ -10,8 +10,8 @@
 
 #[allow(unreachable_code)]
 pub fn expr_ret_14() {
-    let x = 14;
-    if x > 1 {
+    let x = 14i;
+    if x > 1i {
         return;
         "unreachable";
     }
index f0278fba311e6ac250de2dc458176f9d604a012c..bc47d9aff81219231dd7bccf76b0e2fcad4a86ca 100644 (file)
@@ -1,42 +1,42 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 15"];
+    N2[label="expr 15i"];
     N3[label="local mut x"];
-    N4[label="expr 151"];
+    N4[label="expr 151i"];
     N5[label="local mut y"];
     N6[label="(dummy_node)"];
-    N7[label="expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1 { break \'outer ; \"unreachable\" }\l                if y >= 2 { break ; \"unreachable\" }\l                y -= 3;\l            }\l        y -= 4;\l        x -= 5;\l    }\l"];
+    N7[label="expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1i { break \'outer ; \"unreachable\" }\l                if y >= 2i { break ; \"unreachable\" }\l                y -= 3i;\l            }\l        y -= 4i;\l        x -= 5i;\l    }\l"];
     N8[label="(dummy_node)"];
-    N9[label="expr \'inner:\l    loop  {\l        if x == 1 { break \'outer ; \"unreachable\" }\l        if y >= 2 { break ; \"unreachable\" }\l        y -= 3;\l    }\l"];
+    N9[label="expr \'inner:\l    loop  {\l        if x == 1i { break \'outer ; \"unreachable\" }\l        if y >= 2i { break ; \"unreachable\" }\l        y -= 3i;\l    }\l"];
     N10[label="expr x"];
-    N11[label="expr 1"];
-    N12[label="expr x == 1"];
+    N11[label="expr 1i"];
+    N12[label="expr x == 1i"];
     N13[label="expr break \'outer"];
     N14[label="(dummy_node)"];
     N15[label="expr \"unreachable\""];
     N16[label="block { break \'outer ; \"unreachable\" }"];
-    N17[label="expr if x == 1 { break \'outer ; \"unreachable\" }"];
+    N17[label="expr if x == 1i { break \'outer ; \"unreachable\" }"];
     N18[label="expr y"];
-    N19[label="expr 2"];
-    N20[label="expr y >= 2"];
+    N19[label="expr 2i"];
+    N20[label="expr y >= 2i"];
     N21[label="expr break"];
     N22[label="(dummy_node)"];
     N23[label="expr \"unreachable\""];
     N24[label="block { break ; \"unreachable\" }"];
-    N25[label="expr if y >= 2 { break ; \"unreachable\" }"];
-    N26[label="expr 3"];
+    N25[label="expr if y >= 2i { break ; \"unreachable\" }"];
+    N26[label="expr 3i"];
     N27[label="expr y"];
-    N28[label="expr y -= 3"];
-    N29[label="block {\l    if x == 1 { break \'outer ; \"unreachable\" }\l    if y >= 2 { break ; \"unreachable\" }\l    y -= 3;\l}\l"];
-    N30[label="expr 4"];
+    N28[label="expr y -= 3i"];
+    N29[label="block {\l    if x == 1i { break \'outer ; \"unreachable\" }\l    if y >= 2i { break ; \"unreachable\" }\l    y -= 3i;\l}\l"];
+    N30[label="expr 4i"];
     N31[label="expr y"];
-    N32[label="expr y -= 4"];
-    N33[label="expr 5"];
+    N32[label="expr y -= 4i"];
+    N33[label="expr 5i"];
     N34[label="expr x"];
-    N35[label="expr x -= 5"];
-    N36[label="block {\l    \'inner:\l        loop  {\l            if x == 1 { break \'outer ; \"unreachable\" }\l            if y >= 2 { break ; \"unreachable\" }\l            y -= 3;\l        }\l    y -= 4;\l    x -= 5;\l}\l"];
-    N37[label="block {\l    let mut x = 15;\l    let mut y = 151;\l    \'outer:\l        loop  {\l            \'inner:\l                loop  {\l                    if x == 1 { break \'outer ; \"unreachable\" }\l                    if y >= 2 { break ; \"unreachable\" }\l                    y -= 3;\l                }\l            y -= 4;\l            x -= 5;\l        }\l}\l"];
+    N35[label="expr x -= 5i"];
+    N36[label="block {\l    \'inner:\l        loop  {\l            if x == 1i { break \'outer ; \"unreachable\" }\l            if y >= 2i { break ; \"unreachable\" }\l            y -= 3i;\l        }\l    y -= 4i;\l    x -= 5i;\l}\l"];
+    N37[label="block {\l    let mut x = 15i;\l    let mut y = 151i;\l    \'outer:\l        loop  {\l            \'inner:\l                loop  {\l                    if x == 1i { break \'outer ; \"unreachable\" }\l                    if y >= 2i { break ; \"unreachable\" }\l                    y -= 3i;\l                }\l            y -= 4i;\l            x -= 5i;\l        }\l}\l"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
@@ -47,7 +47,7 @@ digraph block {
     N10 -> N11;
     N11 -> N12;
     N12 -> N13;
-    N13 -> N7[label="exiting scope_0 expr break \'outer,\lexiting scope_1 stmt break \'outer ;,\lexiting scope_2 block { break \'outer ; \"unreachable\" },\lexiting scope_3 expr if x == 1 { break \'outer ; \"unreachable\" },\lexiting scope_4 stmt if x == 1 { break \'outer ; \"unreachable\" },\lexiting scope_5 block {\l    if x == 1 { break \'outer ; \"unreachable\" }\l    if y >= 2 { break ; \"unreachable\" }\l    y -= 3;\l}\l,\lexiting scope_6 expr \'inner:\l    loop  {\l        if x == 1 { break \'outer ; \"unreachable\" }\l        if y >= 2 { break ; \"unreachable\" }\l        y -= 3;\l    }\l,\lexiting scope_7 stmt \'inner:\l    loop  {\l        if x == 1 { break \'outer ; \"unreachable\" }\l        if y >= 2 { break ; \"unreachable\" }\l        y -= 3;\l    }\l,\lexiting scope_8 block {\l    \'inner:\l        loop  {\l            if x == 1 { break \'outer ; \"unreachable\" }\l            if y >= 2 { break ; \"unreachable\" }\l            y -= 3;\l        }\l    y -= 4;\l    x -= 5;\l}\l"];
+    N13 -> N7[label="exiting scope_0 expr break \'outer,\lexiting scope_1 stmt break \'outer ;,\lexiting scope_2 block { break \'outer ; \"unreachable\" },\lexiting scope_3 expr if x == 1i { break \'outer ; \"unreachable\" },\lexiting scope_4 stmt if x == 1i { break \'outer ; \"unreachable\" },\lexiting scope_5 block {\l    if x == 1i { break \'outer ; \"unreachable\" }\l    if y >= 2i { break ; \"unreachable\" }\l    y -= 3i;\l}\l,\lexiting scope_6 expr \'inner:\l    loop  {\l        if x == 1i { break \'outer ; \"unreachable\" }\l        if y >= 2i { break ; \"unreachable\" }\l        y -= 3i;\l    }\l,\lexiting scope_7 stmt \'inner:\l    loop  {\l        if x == 1i { break \'outer ; \"unreachable\" }\l        if y >= 2i { break ; \"unreachable\" }\l        y -= 3i;\l    }\l,\lexiting scope_8 block {\l    \'inner:\l        loop  {\l            if x == 1i { break \'outer ; \"unreachable\" }\l            if y >= 2i { break ; \"unreachable\" }\l            y -= 3i;\l        }\l    y -= 4i;\l    x -= 5i;\l}\l"];
     N14 -> N15;
     N15 -> N16;
     N12 -> N17;
@@ -56,7 +56,7 @@ digraph block {
     N18 -> N19;
     N19 -> N20;
     N20 -> N21;
-    N21 -> N9[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\" },\lexiting scope_3 expr if y >= 2 { break ; \"unreachable\" },\lexiting scope_4 stmt if y >= 2 { break ; \"unreachable\" },\lexiting scope_5 block {\l    if x == 1 { break \'outer ; \"unreachable\" }\l    if y >= 2 { break ; \"unreachable\" }\l    y -= 3;\l}\l"];
+    N21 -> N9[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\" },\lexiting scope_3 expr if y >= 2i { break ; \"unreachable\" },\lexiting scope_4 stmt if y >= 2i { break ; \"unreachable\" },\lexiting scope_5 block {\l    if x == 1i { break \'outer ; \"unreachable\" }\l    if y >= 2i { break ; \"unreachable\" }\l    y -= 3i;\l}\l"];
     N22 -> N23;
     N23 -> N24;
     N20 -> N25;
index 44c038d643badebb108167e91a49926dff13edff..e5ca1de3f2d2c8bb861887cb86acb99ec761b4c8 100644 (file)
 
 #[allow(unreachable_code)]
 pub fn expr_break_label_15() {
-    let mut x = 15;
-    let mut y = 151;
+    let mut x = 15i;
+    let mut y = 151i;
     'outer: loop {
         'inner: loop {
-            if x == 1 {
+            if x == 1i {
                 break 'outer;
                 "unreachable"
             }
-            if y >= 2 {
+            if y >= 2i {
                 break;
                 "unreachable"
             }
-            y -= 3;
+            y -= 3i;
         }
-        y -= 4;
-        x -= 5;
+        y -= 4i;
+        x -= 5i;
     }
 }
index 3f999ae3781426ab823ebc94129587310e307ca3..9c60e19f8b073c18141831c442e583f0c9933c09 100644 (file)
@@ -1,43 +1,43 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 16"];
+    N2[label="expr 16i"];
     N3[label="local mut x"];
-    N4[label="expr 16"];
+    N4[label="expr 16i"];
     N5[label="local mut y"];
     N6[label="(dummy_node)"];
-    N7[label="expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1 { continue \'outer ; \"unreachable\" }\l                if y >= 1 { break ; \"unreachable\" }\l                y -= 1;\l            }\l        y -= 1;\l        x -= 1;\l    }\l"];
+    N7[label="expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1i { continue \'outer ; \"unreachable\" }\l                if y >= 1i { break ; \"unreachable\" }\l                y -= 1i;\l            }\l        y -= 1i;\l        x -= 1i;\l    }\l"];
     N8[label="(dummy_node)"];
-    N9[label="expr \'inner:\l    loop  {\l        if x == 1 { continue \'outer ; \"unreachable\" }\l        if y >= 1 { break ; \"unreachable\" }\l        y -= 1;\l    }\l"];
+    N9[label="expr \'inner:\l    loop  {\l        if x == 1i { continue \'outer ; \"unreachable\" }\l        if y >= 1i { break ; \"unreachable\" }\l        y -= 1i;\l    }\l"];
     N10[label="expr x"];
-    N11[label="expr 1"];
-    N12[label="expr x == 1"];
+    N11[label="expr 1i"];
+    N12[label="expr x == 1i"];
     N13[label="expr continue \'outer"];
     N14[label="(dummy_node)"];
     N15[label="expr \"unreachable\""];
     N16[label="block { continue \'outer ; \"unreachable\" }"];
-    N17[label="expr if x == 1 { continue \'outer ; \"unreachable\" }"];
+    N17[label="expr if x == 1i { continue \'outer ; \"unreachable\" }"];
     N18[label="expr y"];
-    N19[label="expr 1"];
-    N20[label="expr y >= 1"];
+    N19[label="expr 1i"];
+    N20[label="expr y >= 1i"];
     N21[label="expr break"];
     N22[label="(dummy_node)"];
     N23[label="expr \"unreachable\""];
     N24[label="block { break ; \"unreachable\" }"];
-    N25[label="expr if y >= 1 { break ; \"unreachable\" }"];
-    N26[label="expr 1"];
+    N25[label="expr if y >= 1i { break ; \"unreachable\" }"];
+    N26[label="expr 1i"];
     N27[label="expr y"];
-    N28[label="expr y -= 1"];
-    N29[label="block {\l    if x == 1 { continue \'outer ; \"unreachable\" }\l    if y >= 1 { break ; \"unreachable\" }\l    y -= 1;\l}\l"];
-    N30[label="expr 1"];
+    N28[label="expr y -= 1i"];
+    N29[label="block {\l    if x == 1i { continue \'outer ; \"unreachable\" }\l    if y >= 1i { break ; \"unreachable\" }\l    y -= 1i;\l}\l"];
+    N30[label="expr 1i"];
     N31[label="expr y"];
-    N32[label="expr y -= 1"];
-    N33[label="expr 1"];
+    N32[label="expr y -= 1i"];
+    N33[label="expr 1i"];
     N34[label="expr x"];
-    N35[label="expr x -= 1"];
-    N36[label="block {\l    \'inner:\l        loop  {\l            if x == 1 { continue \'outer ; \"unreachable\" }\l            if y >= 1 { break ; \"unreachable\" }\l            y -= 1;\l        }\l    y -= 1;\l    x -= 1;\l}\l"];
+    N35[label="expr x -= 1i"];
+    N36[label="block {\l    \'inner:\l        loop  {\l            if x == 1i { continue \'outer ; \"unreachable\" }\l            if y >= 1i { break ; \"unreachable\" }\l            y -= 1i;\l        }\l    y -= 1i;\l    x -= 1i;\l}\l"];
     N37[label="expr \"unreachable\""];
-    N38[label="block {\l    let mut x = 16;\l    let mut y = 16;\l    \'outer:\l        loop  {\l            \'inner:\l                loop  {\l                    if x == 1 { continue \'outer ; \"unreachable\" }\l                    if y >= 1 { break ; \"unreachable\" }\l                    y -= 1;\l                }\l            y -= 1;\l            x -= 1;\l        }\l    \"unreachable\";\l}\l"];
+    N38[label="block {\l    let mut x = 16i;\l    let mut y = 16i;\l    \'outer:\l        loop  {\l            \'inner:\l                loop  {\l                    if x == 1i { continue \'outer ; \"unreachable\" }\l                    if y >= 1i { break ; \"unreachable\" }\l                    y -= 1i;\l                }\l            y -= 1i;\l            x -= 1i;\l        }\l    \"unreachable\";\l}\l"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
@@ -48,7 +48,7 @@ digraph block {
     N10 -> N11;
     N11 -> N12;
     N12 -> N13;
-    N13 -> N6[label="exiting scope_0 expr continue \'outer,\lexiting scope_1 stmt continue \'outer ;,\lexiting scope_2 block { continue \'outer ; \"unreachable\" },\lexiting scope_3 expr if x == 1 { continue \'outer ; \"unreachable\" },\lexiting scope_4 stmt if x == 1 { continue \'outer ; \"unreachable\" },\lexiting scope_5 block {\l    if x == 1 { continue \'outer ; \"unreachable\" }\l    if y >= 1 { break ; \"unreachable\" }\l    y -= 1;\l}\l,\lexiting scope_6 expr \'inner:\l    loop  {\l        if x == 1 { continue \'outer ; \"unreachable\" }\l        if y >= 1 { break ; \"unreachable\" }\l        y -= 1;\l    }\l,\lexiting scope_7 stmt \'inner:\l    loop  {\l        if x == 1 { continue \'outer ; \"unreachable\" }\l        if y >= 1 { break ; \"unreachable\" }\l        y -= 1;\l    }\l,\lexiting scope_8 block {\l    \'inner:\l        loop  {\l            if x == 1 { continue \'outer ; \"unreachable\" }\l            if y >= 1 { break ; \"unreachable\" }\l            y -= 1;\l        }\l    y -= 1;\l    x -= 1;\l}\l"];
+    N13 -> N6[label="exiting scope_0 expr continue \'outer,\lexiting scope_1 stmt continue \'outer ;,\lexiting scope_2 block { continue \'outer ; \"unreachable\" },\lexiting scope_3 expr if x == 1i { continue \'outer ; \"unreachable\" },\lexiting scope_4 stmt if x == 1i { continue \'outer ; \"unreachable\" },\lexiting scope_5 block {\l    if x == 1i { continue \'outer ; \"unreachable\" }\l    if y >= 1i { break ; \"unreachable\" }\l    y -= 1i;\l}\l,\lexiting scope_6 expr \'inner:\l    loop  {\l        if x == 1i { continue \'outer ; \"unreachable\" }\l        if y >= 1i { break ; \"unreachable\" }\l        y -= 1i;\l    }\l,\lexiting scope_7 stmt \'inner:\l    loop  {\l        if x == 1i { continue \'outer ; \"unreachable\" }\l        if y >= 1i { break ; \"unreachable\" }\l        y -= 1i;\l    }\l,\lexiting scope_8 block {\l    \'inner:\l        loop  {\l            if x == 1i { continue \'outer ; \"unreachable\" }\l            if y >= 1i { break ; \"unreachable\" }\l            y -= 1i;\l        }\l    y -= 1i;\l    x -= 1i;\l}\l"];
     N14 -> N15;
     N15 -> N16;
     N12 -> N17;
@@ -57,7 +57,7 @@ digraph block {
     N18 -> N19;
     N19 -> N20;
     N20 -> N21;
-    N21 -> N9[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\" },\lexiting scope_3 expr if y >= 1 { break ; \"unreachable\" },\lexiting scope_4 stmt if y >= 1 { break ; \"unreachable\" },\lexiting scope_5 block {\l    if x == 1 { continue \'outer ; \"unreachable\" }\l    if y >= 1 { break ; \"unreachable\" }\l    y -= 1;\l}\l"];
+    N21 -> N9[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\" },\lexiting scope_3 expr if y >= 1i { break ; \"unreachable\" },\lexiting scope_4 stmt if y >= 1i { break ; \"unreachable\" },\lexiting scope_5 block {\l    if x == 1i { continue \'outer ; \"unreachable\" }\l    if y >= 1i { break ; \"unreachable\" }\l    y -= 1i;\l}\l"];
     N22 -> N23;
     N23 -> N24;
     N20 -> N25;
index f4f23a65c93509abfce3d5892d859ea92a7993ec..78de99d28fccecb1a8d88621dd6d42ca474a0107 100644 (file)
 
 #[allow(unreachable_code)]
 pub fn expr_continue_label_16() {
-    let mut x = 16;
-    let mut y = 16;
+    let mut x = 16i;
+    let mut y = 16i;
     'outer: loop {
         'inner: loop {
-            if x == 1 {
+            if x == 1i {
                 continue 'outer;
                 "unreachable"
             }
-            if y >= 1 {
+            if y >= 1i {
                 break;
                 "unreachable"
             }
-            y -= 1;
+            y -= 1i;
         }
-        y -= 1;
-        x -= 1;
+        y -= 1i;
+        x -= 1i;
     }
     "unreachable";
 }
index e9bccdab81be1f59dbaefde500cbf690ce461b28..d3e098a71f2874be8657bfda9a68a960bd1f341a 100644 (file)
@@ -1,12 +1,12 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 1"];
-    N3[label="expr 7"];
-    N4[label="expr 17"];
-    N5[label="expr [1, 7, 17]"];
+    N2[label="expr 1i"];
+    N3[label="expr 7i"];
+    N4[label="expr 17i"];
+    N5[label="expr [1i, 7i, 17i]"];
     N6[label="local _v"];
-    N7[label="block { let _v = [1, 7, 17]; }"];
+    N7[label="block { let _v = [1i, 7i, 17i]; }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index 23f5bb8a1eb17b993fe026cc2c11f63f85f52fd8..23ce212c0af4855fc166604c4c73e7f492cbdde4 100644 (file)
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 pub fn expr_vec_17() {
-    let _v = [1, 7, 17];
+    let _v = [1i, 7i, 17i];
 }
index 593ad6f91ea5ce02ea2ca4002b2c88ef2a8093b1..716ec469fb0013c5c9df3d8b31ceb9069e3e3b84 100644 (file)
@@ -1,15 +1,15 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 2"];
-    N3[label="expr 0"];
-    N4[label="expr 20"];
-    N5[label="expr [2, 0, 20]"];
+    N2[label="expr 2u"];
+    N3[label="expr 0u"];
+    N4[label="expr 20u"];
+    N5[label="expr [2u, 0u, 20u]"];
     N6[label="local v"];
     N7[label="expr v"];
-    N8[label="expr 20"];
-    N9[label="expr v[20]"];
-    N10[label="block { let v = [2, 0, 20]; v[20]; }"];
+    N8[label="expr 20u"];
+    N9[label="expr v[20u]"];
+    N10[label="block { let v = [2u, 0u, 20u]; v[20u]; }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index d7349932355b10c92a06c3a1d93af996a6b7e7cb..7110ebe2b542978aed814ef097090e2b0927a906 100644 (file)
@@ -9,6 +9,6 @@
 // except according to those terms.
 
 pub fn expr_index_20() {
-    let v = [2, 0, 20];
-    v[20];
+    let v = [2u, 0u, 20u];
+    v[20u];
 }
index 0798c4a01c05ae9f862453ed574ac5be3f9a2531..2bbc3e7e5c8f0088578d3da453d57a068fde414c 100644 (file)
@@ -1,40 +1,40 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 15"];
+    N2[label="expr 15i"];
     N3[label="local mut x"];
-    N4[label="expr 151"];
+    N4[label="expr 151i"];
     N5[label="local mut y"];
     N6[label="(dummy_node)"];
-    N7[label="expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1 { break \'outer ; \"unreachable\"; }\l                if y >= 2 { return; \"unreachable\"; }\l                y -= 3;\l                x -= 5;\l            }\l        \"unreachable\";\l    }\l"];
+    N7[label="expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1i { break \'outer ; \"unreachable\"; }\l                if y >= 2i { return; \"unreachable\"; }\l                y -= 3i;\l                x -= 5i;\l            }\l        \"unreachable\";\l    }\l"];
     N8[label="(dummy_node)"];
-    N9[label="expr \'inner:\l    loop  {\l        if x == 1 { break \'outer ; \"unreachable\"; }\l        if y >= 2 { return; \"unreachable\"; }\l        y -= 3;\l        x -= 5;\l    }\l"];
+    N9[label="expr \'inner:\l    loop  {\l        if x == 1i { break \'outer ; \"unreachable\"; }\l        if y >= 2i { return; \"unreachable\"; }\l        y -= 3i;\l        x -= 5i;\l    }\l"];
     N10[label="expr x"];
-    N11[label="expr 1"];
-    N12[label="expr x == 1"];
+    N11[label="expr 1i"];
+    N12[label="expr x == 1i"];
     N13[label="expr break \'outer"];
     N14[label="(dummy_node)"];
     N15[label="expr \"unreachable\""];
     N16[label="block { break \'outer ; \"unreachable\"; }"];
-    N17[label="expr if x == 1 { break \'outer ; \"unreachable\"; }"];
+    N17[label="expr if x == 1i { break \'outer ; \"unreachable\"; }"];
     N18[label="expr y"];
-    N19[label="expr 2"];
-    N20[label="expr y >= 2"];
+    N19[label="expr 2i"];
+    N20[label="expr y >= 2i"];
     N21[label="expr return"];
     N22[label="(dummy_node)"];
     N23[label="expr \"unreachable\""];
     N24[label="block { return; \"unreachable\"; }"];
-    N25[label="expr if y >= 2 { return; \"unreachable\"; }"];
-    N26[label="expr 3"];
+    N25[label="expr if y >= 2i { return; \"unreachable\"; }"];
+    N26[label="expr 3i"];
     N27[label="expr y"];
-    N28[label="expr y -= 3"];
-    N29[label="expr 5"];
+    N28[label="expr y -= 3i"];
+    N29[label="expr 5i"];
     N30[label="expr x"];
-    N31[label="expr x -= 5"];
-    N32[label="block {\l    if x == 1 { break \'outer ; \"unreachable\"; }\l    if y >= 2 { return; \"unreachable\"; }\l    y -= 3;\l    x -= 5;\l}\l"];
+    N31[label="expr x -= 5i"];
+    N32[label="block {\l    if x == 1i { break \'outer ; \"unreachable\"; }\l    if y >= 2i { return; \"unreachable\"; }\l    y -= 3i;\l    x -= 5i;\l}\l"];
     N33[label="expr \"unreachable\""];
-    N34[label="block {\l    \'inner:\l        loop  {\l            if x == 1 { break \'outer ; \"unreachable\"; }\l            if y >= 2 { return; \"unreachable\"; }\l            y -= 3;\l            x -= 5;\l        }\l    \"unreachable\";\l}\l"];
-    N35[label="block {\l    let mut x = 15;\l    let mut y = 151;\l    \'outer:\l        loop  {\l            \'inner:\l                loop  {\l                    if x == 1 { break \'outer ; \"unreachable\"; }\l                    if y >= 2 { return; \"unreachable\"; }\l                    y -= 3;\l                    x -= 5;\l                }\l            \"unreachable\";\l        }\l}\l"];
+    N34[label="block {\l    \'inner:\l        loop  {\l            if x == 1i { break \'outer ; \"unreachable\"; }\l            if y >= 2i { return; \"unreachable\"; }\l            y -= 3i;\l            x -= 5i;\l        }\l    \"unreachable\";\l}\l"];
+    N35[label="block {\l    let mut x = 15i;\l    let mut y = 151i;\l    \'outer:\l        loop  {\l            \'inner:\l                loop  {\l                    if x == 1i { break \'outer ; \"unreachable\"; }\l                    if y >= 2i { return; \"unreachable\"; }\l                    y -= 3i;\l                    x -= 5i;\l                }\l            \"unreachable\";\l        }\l}\l"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
@@ -45,7 +45,7 @@ digraph block {
     N10 -> N11;
     N11 -> N12;
     N12 -> N13;
-    N13 -> N7[label="exiting scope_0 expr break \'outer,\lexiting scope_1 stmt break \'outer ;,\lexiting scope_2 block { break \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1 { break \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1 { break \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 1 { break \'outer ; \"unreachable\"; }\l    if y >= 2 { return; \"unreachable\"; }\l    y -= 3;\l    x -= 5;\l}\l,\lexiting scope_6 expr \'inner:\l    loop  {\l        if x == 1 { break \'outer ; \"unreachable\"; }\l        if y >= 2 { return; \"unreachable\"; }\l        y -= 3;\l        x -= 5;\l    }\l,\lexiting scope_7 stmt \'inner:\l    loop  {\l        if x == 1 { break \'outer ; \"unreachable\"; }\l        if y >= 2 { return; \"unreachable\"; }\l        y -= 3;\l        x -= 5;\l    }\l,\lexiting scope_8 block {\l    \'inner:\l        loop  {\l            if x == 1 { break \'outer ; \"unreachable\"; }\l            if y >= 2 { return; \"unreachable\"; }\l            y -= 3;\l            x -= 5;\l        }\l    \"unreachable\";\l}\l"];
+    N13 -> N7[label="exiting scope_0 expr break \'outer,\lexiting scope_1 stmt break \'outer ;,\lexiting scope_2 block { break \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1i { break \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1i { break \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 1i { break \'outer ; \"unreachable\"; }\l    if y >= 2i { return; \"unreachable\"; }\l    y -= 3i;\l    x -= 5i;\l}\l,\lexiting scope_6 expr \'inner:\l    loop  {\l        if x == 1i { break \'outer ; \"unreachable\"; }\l        if y >= 2i { return; \"unreachable\"; }\l        y -= 3i;\l        x -= 5i;\l    }\l,\lexiting scope_7 stmt \'inner:\l    loop  {\l        if x == 1i { break \'outer ; \"unreachable\"; }\l        if y >= 2i { return; \"unreachable\"; }\l        y -= 3i;\l        x -= 5i;\l    }\l,\lexiting scope_8 block {\l    \'inner:\l        loop  {\l            if x == 1i { break \'outer ; \"unreachable\"; }\l            if y >= 2i { return; \"unreachable\"; }\l            y -= 3i;\l            x -= 5i;\l        }\l    \"unreachable\";\l}\l"];
     N14 -> N15;
     N15 -> N16;
     N12 -> N17;
@@ -54,7 +54,7 @@ digraph block {
     N18 -> N19;
     N19 -> N20;
     N20 -> N21;
-    N21 -> N1[label="exiting scope_0 expr \'inner:\l    loop  {\l        if x == 1 { break \'outer ; \"unreachable\"; }\l        if y >= 2 { return; \"unreachable\"; }\l        y -= 3;\l        x -= 5;\l    }\l,\lexiting scope_1 expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1 { break \'outer ; \"unreachable\"; }\l                if y >= 2 { return; \"unreachable\"; }\l                y -= 3;\l                x -= 5;\l            }\l        \"unreachable\";\l    }\l"];
+    N21 -> N1[label="exiting scope_0 expr \'inner:\l    loop  {\l        if x == 1i { break \'outer ; \"unreachable\"; }\l        if y >= 2i { return; \"unreachable\"; }\l        y -= 3i;\l        x -= 5i;\l    }\l,\lexiting scope_1 expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1i { break \'outer ; \"unreachable\"; }\l                if y >= 2i { return; \"unreachable\"; }\l                y -= 3i;\l                x -= 5i;\l            }\l        \"unreachable\";\l    }\l"];
     N22 -> N23;
     N23 -> N24;
     N20 -> N25;
index 70083ed8312cbbb181e5d5652f8150646e496dc3..bff2da2506107d74e5db8691b0c5eb33fa54030a 100644 (file)
 
 #[allow(unreachable_code)]
 pub fn expr_break_label_21() {
-    let mut x = 15;
-    let mut y = 151;
+    let mut x = 15i;
+    let mut y = 151i;
     'outer: loop {
         'inner: loop {
-            if x == 1 {
+            if x == 1i {
                 break 'outer;
                 "unreachable";
             }
-            if y >= 2 {
+            if y >= 2i {
                 return;
                 "unreachable";
             }
-            y -= 3;
-            x -= 5;
+            y -= 3i;
+            x -= 5i;
         }
         "unreachable";
     }
index 9ad731bc756bfe8c2dd91bc1c8589768033733bd..8ecddba21fcc1180fc83c9f16b835005569e9382 100644 (file)
@@ -1,41 +1,41 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 15"];
+    N2[label="expr 15i"];
     N3[label="local mut x"];
-    N4[label="expr 151"];
+    N4[label="expr 151i"];
     N5[label="local mut y"];
     N6[label="(dummy_node)"];
-    N7[label="expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1 { continue \'outer ; \"unreachable\"; }\l                if y >= 2 { return; \"unreachable\"; }\l                x -= 1;\l                y -= 3;\l            }\l        \"unreachable\";\l    }\l"];
+    N7[label="expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1i { continue \'outer ; \"unreachable\"; }\l                if y >= 2i { return; \"unreachable\"; }\l                x -= 1i;\l                y -= 3i;\l            }\l        \"unreachable\";\l    }\l"];
     N8[label="(dummy_node)"];
-    N9[label="expr \'inner:\l    loop  {\l        if x == 1 { continue \'outer ; \"unreachable\"; }\l        if y >= 2 { return; \"unreachable\"; }\l        x -= 1;\l        y -= 3;\l    }\l"];
+    N9[label="expr \'inner:\l    loop  {\l        if x == 1i { continue \'outer ; \"unreachable\"; }\l        if y >= 2i { return; \"unreachable\"; }\l        x -= 1i;\l        y -= 3i;\l    }\l"];
     N10[label="expr x"];
-    N11[label="expr 1"];
-    N12[label="expr x == 1"];
+    N11[label="expr 1i"];
+    N12[label="expr x == 1i"];
     N13[label="expr continue \'outer"];
     N14[label="(dummy_node)"];
     N15[label="expr \"unreachable\""];
     N16[label="block { continue \'outer ; \"unreachable\"; }"];
-    N17[label="expr if x == 1 { continue \'outer ; \"unreachable\"; }"];
+    N17[label="expr if x == 1i { continue \'outer ; \"unreachable\"; }"];
     N18[label="expr y"];
-    N19[label="expr 2"];
-    N20[label="expr y >= 2"];
+    N19[label="expr 2i"];
+    N20[label="expr y >= 2i"];
     N21[label="expr return"];
     N22[label="(dummy_node)"];
     N23[label="expr \"unreachable\""];
     N24[label="block { return; \"unreachable\"; }"];
-    N25[label="expr if y >= 2 { return; \"unreachable\"; }"];
-    N26[label="expr 1"];
+    N25[label="expr if y >= 2i { return; \"unreachable\"; }"];
+    N26[label="expr 1i"];
     N27[label="expr x"];
-    N28[label="expr x -= 1"];
-    N29[label="expr 3"];
+    N28[label="expr x -= 1i"];
+    N29[label="expr 3i"];
     N30[label="expr y"];
-    N31[label="expr y -= 3"];
-    N32[label="block {\l    if x == 1 { continue \'outer ; \"unreachable\"; }\l    if y >= 2 { return; \"unreachable\"; }\l    x -= 1;\l    y -= 3;\l}\l"];
+    N31[label="expr y -= 3i"];
+    N32[label="block {\l    if x == 1i { continue \'outer ; \"unreachable\"; }\l    if y >= 2i { return; \"unreachable\"; }\l    x -= 1i;\l    y -= 3i;\l}\l"];
     N33[label="expr \"unreachable\""];
-    N34[label="block {\l    \'inner:\l        loop  {\l            if x == 1 { continue \'outer ; \"unreachable\"; }\l            if y >= 2 { return; \"unreachable\"; }\l            x -= 1;\l            y -= 3;\l        }\l    \"unreachable\";\l}\l"];
+    N34[label="block {\l    \'inner:\l        loop  {\l            if x == 1i { continue \'outer ; \"unreachable\"; }\l            if y >= 2i { return; \"unreachable\"; }\l            x -= 1i;\l            y -= 3i;\l        }\l    \"unreachable\";\l}\l"];
     N35[label="expr \"unreachable\""];
-    N36[label="block {\l    let mut x = 15;\l    let mut y = 151;\l    \'outer:\l        loop  {\l            \'inner:\l                loop  {\l                    if x == 1 { continue \'outer ; \"unreachable\"; }\l                    if y >= 2 { return; \"unreachable\"; }\l                    x -= 1;\l                    y -= 3;\l                }\l            \"unreachable\";\l        }\l    \"unreachable\";\l}\l"];
+    N36[label="block {\l    let mut x = 15i;\l    let mut y = 151i;\l    \'outer:\l        loop  {\l            \'inner:\l                loop  {\l                    if x == 1i { continue \'outer ; \"unreachable\"; }\l                    if y >= 2i { return; \"unreachable\"; }\l                    x -= 1i;\l                    y -= 3i;\l                }\l            \"unreachable\";\l        }\l    \"unreachable\";\l}\l"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
@@ -46,7 +46,7 @@ digraph block {
     N10 -> N11;
     N11 -> N12;
     N12 -> N13;
-    N13 -> N6[label="exiting scope_0 expr continue \'outer,\lexiting scope_1 stmt continue \'outer ;,\lexiting scope_2 block { continue \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1 { continue \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1 { continue \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 1 { continue \'outer ; \"unreachable\"; }\l    if y >= 2 { return; \"unreachable\"; }\l    x -= 1;\l    y -= 3;\l}\l,\lexiting scope_6 expr \'inner:\l    loop  {\l        if x == 1 { continue \'outer ; \"unreachable\"; }\l        if y >= 2 { return; \"unreachable\"; }\l        x -= 1;\l        y -= 3;\l    }\l,\lexiting scope_7 stmt \'inner:\l    loop  {\l        if x == 1 { continue \'outer ; \"unreachable\"; }\l        if y >= 2 { return; \"unreachable\"; }\l        x -= 1;\l        y -= 3;\l    }\l,\lexiting scope_8 block {\l    \'inner:\l        loop  {\l            if x == 1 { continue \'outer ; \"unreachable\"; }\l            if y >= 2 { return; \"unreachable\"; }\l            x -= 1;\l            y -= 3;\l        }\l    \"unreachable\";\l}\l"];
+    N13 -> N6[label="exiting scope_0 expr continue \'outer,\lexiting scope_1 stmt continue \'outer ;,\lexiting scope_2 block { continue \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1i { continue \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1i { continue \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 1i { continue \'outer ; \"unreachable\"; }\l    if y >= 2i { return; \"unreachable\"; }\l    x -= 1i;\l    y -= 3i;\l}\l,\lexiting scope_6 expr \'inner:\l    loop  {\l        if x == 1i { continue \'outer ; \"unreachable\"; }\l        if y >= 2i { return; \"unreachable\"; }\l        x -= 1i;\l        y -= 3i;\l    }\l,\lexiting scope_7 stmt \'inner:\l    loop  {\l        if x == 1i { continue \'outer ; \"unreachable\"; }\l        if y >= 2i { return; \"unreachable\"; }\l        x -= 1i;\l        y -= 3i;\l    }\l,\lexiting scope_8 block {\l    \'inner:\l        loop  {\l            if x == 1i { continue \'outer ; \"unreachable\"; }\l            if y >= 2i { return; \"unreachable\"; }\l            x -= 1i;\l            y -= 3i;\l        }\l    \"unreachable\";\l}\l"];
     N14 -> N15;
     N15 -> N16;
     N12 -> N17;
@@ -55,7 +55,7 @@ digraph block {
     N18 -> N19;
     N19 -> N20;
     N20 -> N21;
-    N21 -> N1[label="exiting scope_0 expr \'inner:\l    loop  {\l        if x == 1 { continue \'outer ; \"unreachable\"; }\l        if y >= 2 { return; \"unreachable\"; }\l        x -= 1;\l        y -= 3;\l    }\l,\lexiting scope_1 expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1 { continue \'outer ; \"unreachable\"; }\l                if y >= 2 { return; \"unreachable\"; }\l                x -= 1;\l                y -= 3;\l            }\l        \"unreachable\";\l    }\l"];
+    N21 -> N1[label="exiting scope_0 expr \'inner:\l    loop  {\l        if x == 1i { continue \'outer ; \"unreachable\"; }\l        if y >= 2i { return; \"unreachable\"; }\l        x -= 1i;\l        y -= 3i;\l    }\l,\lexiting scope_1 expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1i { continue \'outer ; \"unreachable\"; }\l                if y >= 2i { return; \"unreachable\"; }\l                x -= 1i;\l                y -= 3i;\l            }\l        \"unreachable\";\l    }\l"];
     N22 -> N23;
     N23 -> N24;
     N20 -> N25;
index b35aac9ec422e924e3f4d167ae0ba0ab080de24b..a6e3d571debabf7b54e43800daecdf5cba8cf181 100644 (file)
 
 #[allow(unreachable_code)]
 pub fn expr_break_label_21() {
-    let mut x = 15;
-    let mut y = 151;
+    let mut x = 15i;
+    let mut y = 151i;
     'outer: loop {
         'inner: loop {
-            if x == 1 {
+            if x == 1i {
                 continue 'outer;
                 "unreachable";
             }
-            if y >= 2 {
+            if y >= 2i {
                 return;
                 "unreachable";
             }
-            x -= 1;
-            y -= 3;
+            x -= 1i;
+            y -= 3i;
         }
         "unreachable";
     }
index 876957a0689d6ad50a75846086bf908cd521ba60..718d4687ef99087ad0f10af1e89c71e40dc25c48 100644 (file)
@@ -1,48 +1,48 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 23"];
+    N2[label="expr 23i"];
     N3[label="local mut x"];
-    N4[label="expr 23"];
+    N4[label="expr 23i"];
     N5[label="local mut y"];
-    N6[label="expr 23"];
+    N6[label="expr 23i"];
     N7[label="local mut z"];
     N8[label="(dummy_node)"];
     N9[label="expr x"];
-    N10[label="expr 0"];
-    N11[label="expr x > 0"];
-    N12[label="expr while x > 0 {\l    x -= 1;\l    while y > 0 {\l        y -= 1;\l        while z > 0 { z -= 1; }\l        if x > 10 { return; \"unreachable\"; }\l    }\l}\l"];
-    N13[label="expr 1"];
+    N10[label="expr 0i"];
+    N11[label="expr x > 0i"];
+    N12[label="expr while x > 0i {\l    x -= 1i;\l    while y > 0i {\l        y -= 1i;\l        while z > 0i { z -= 1i; }\l        if x > 10i { return; \"unreachable\"; }\l    }\l}\l"];
+    N13[label="expr 1i"];
     N14[label="expr x"];
-    N15[label="expr x -= 1"];
+    N15[label="expr x -= 1i"];
     N16[label="(dummy_node)"];
     N17[label="expr y"];
-    N18[label="expr 0"];
-    N19[label="expr y > 0"];
-    N20[label="expr while y > 0 {\l    y -= 1;\l    while z > 0 { z -= 1; }\l    if x > 10 { return; \"unreachable\"; }\l}\l"];
-    N21[label="expr 1"];
+    N18[label="expr 0i"];
+    N19[label="expr y > 0i"];
+    N20[label="expr while y > 0i {\l    y -= 1i;\l    while z > 0i { z -= 1i; }\l    if x > 10i { return; \"unreachable\"; }\l}\l"];
+    N21[label="expr 1i"];
     N22[label="expr y"];
-    N23[label="expr y -= 1"];
+    N23[label="expr y -= 1i"];
     N24[label="(dummy_node)"];
     N25[label="expr z"];
-    N26[label="expr 0"];
-    N27[label="expr z > 0"];
-    N28[label="expr while z > 0 { z -= 1; }"];
-    N29[label="expr 1"];
+    N26[label="expr 0i"];
+    N27[label="expr z > 0i"];
+    N28[label="expr while z > 0i { z -= 1i; }"];
+    N29[label="expr 1i"];
     N30[label="expr z"];
-    N31[label="expr z -= 1"];
-    N32[label="block { z -= 1; }"];
+    N31[label="expr z -= 1i"];
+    N32[label="block { z -= 1i; }"];
     N33[label="expr x"];
-    N34[label="expr 10"];
-    N35[label="expr x > 10"];
+    N34[label="expr 10i"];
+    N35[label="expr x > 10i"];
     N36[label="expr return"];
     N37[label="(dummy_node)"];
     N38[label="expr \"unreachable\""];
     N39[label="block { return; \"unreachable\"; }"];
-    N40[label="expr if x > 10 { return; \"unreachable\"; }"];
-    N41[label="block { y -= 1; while z > 0 { z -= 1; } if x > 10 { return; \"unreachable\"; } }"];
-    N42[label="block {\l    x -= 1;\l    while y > 0 {\l        y -= 1;\l        while z > 0 { z -= 1; }\l        if x > 10 { return; \"unreachable\"; }\l    }\l}\l"];
-    N43[label="block {\l    let mut x = 23;\l    let mut y = 23;\l    let mut z = 23;\l    while x > 0 {\l        x -= 1;\l        while y > 0 {\l            y -= 1;\l            while z > 0 { z -= 1; }\l            if x > 10 { return; \"unreachable\"; }\l        }\l    }\l}\l"];
+    N40[label="expr if x > 10i { return; \"unreachable\"; }"];
+    N41[label="block { y -= 1i; while z > 0i { z -= 1i; } if x > 10i { return; \"unreachable\"; } }"];
+    N42[label="block {\l    x -= 1i;\l    while y > 0i {\l        y -= 1i;\l        while z > 0i { z -= 1i; }\l        if x > 10i { return; \"unreachable\"; }\l    }\l}\l"];
+    N43[label="block {\l    let mut x = 23i;\l    let mut y = 23i;\l    let mut z = 23i;\l    while x > 0i {\l        x -= 1i;\l        while y > 0i {\l            y -= 1i;\l            while z > 0i { z -= 1i; }\l            if x > 10i { return; \"unreachable\"; }\l        }\l    }\l}\l"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
@@ -79,7 +79,7 @@ digraph block {
     N33 -> N34;
     N34 -> N35;
     N35 -> N36;
-    N36 -> N1[label="exiting scope_0 expr while y > 0 {\l    y -= 1;\l    while z > 0 { z -= 1; }\l    if x > 10 { return; \"unreachable\"; }\l}\l,\lexiting scope_1 expr while x > 0 {\l    x -= 1;\l    while y > 0 {\l        y -= 1;\l        while z > 0 { z -= 1; }\l        if x > 10 { return; \"unreachable\"; }\l    }\l}\l"];
+    N36 -> N1[label="exiting scope_0 expr while y > 0i {\l    y -= 1i;\l    while z > 0i { z -= 1i; }\l    if x > 10i { return; \"unreachable\"; }\l}\l,\lexiting scope_1 expr while x > 0i {\l    x -= 1i;\l    while y > 0i {\l        y -= 1i;\l        while z > 0i { z -= 1i; }\l        if x > 10i { return; \"unreachable\"; }\l    }\l}\l"];
     N37 -> N38;
     N38 -> N39;
     N35 -> N40;
index 52341a3fbd4080fde2487a85d1bc52f25ccb3f19..73bcc288ca7a265b099260477f95a5b321bf9194 100644 (file)
 
 #[allow(unreachable_code)]
 pub fn expr_while_23() {
-    let mut x = 23;
-    let mut y = 23;
-    let mut z = 23;
+    let mut x = 23i;
+    let mut y = 23i;
+    let mut z = 23i;
 
-    while x > 0 {
-        x -= 1;
+    while x > 0i {
+        x -= 1i;
 
-        while y > 0 {
-            y -= 1;
+        while y > 0i {
+            y -= 1i;
 
-            while z > 0 { z -= 1; }
+            while z > 0i { z -= 1i; }
 
-            if x > 10 {
+            if x > 10i {
                 return;
                 "unreachable";
             }
index 2558998be6e1fbff9db0d41762c2556b0511402d..646d98a54a7860bc4b38233ecd98749688cc2d1e 100644 (file)
@@ -1,63 +1,63 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 24"];
+    N2[label="expr 24i"];
     N3[label="local mut x"];
-    N4[label="expr 24"];
+    N4[label="expr 24i"];
     N5[label="local mut y"];
-    N6[label="expr 24"];
+    N6[label="expr 24i"];
     N7[label="local mut z"];
     N8[label="(dummy_node)"];
-    N9[label="expr loop  {\l    if x == 0 { break ; \"unreachable\"; }\l    x -= 1;\l    loop  {\l        if y == 0 { break ; \"unreachable\"; }\l        y -= 1;\l        loop  { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l        if x > 10 { return; \"unreachable\"; }\l    }\l}\l"];
+    N9[label="expr loop  {\l    if x == 0i { break ; \"unreachable\"; }\l    x -= 1i;\l    loop  {\l        if y == 0i { break ; \"unreachable\"; }\l        y -= 1i;\l        loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l        if x > 10i { return; \"unreachable\"; }\l    }\l}\l"];
     N10[label="expr x"];
-    N11[label="expr 0"];
-    N12[label="expr x == 0"];
+    N11[label="expr 0i"];
+    N12[label="expr x == 0i"];
     N13[label="expr break"];
     N14[label="(dummy_node)"];
     N15[label="expr \"unreachable\""];
     N16[label="block { break ; \"unreachable\"; }"];
-    N17[label="expr if x == 0 { break ; \"unreachable\"; }"];
-    N18[label="expr 1"];
+    N17[label="expr if x == 0i { break ; \"unreachable\"; }"];
+    N18[label="expr 1i"];
     N19[label="expr x"];
-    N20[label="expr x -= 1"];
+    N20[label="expr x -= 1i"];
     N21[label="(dummy_node)"];
-    N22[label="expr loop  {\l    if y == 0 { break ; \"unreachable\"; }\l    y -= 1;\l    loop  { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l    if x > 10 { return; \"unreachable\"; }\l}\l"];
+    N22[label="expr loop  {\l    if y == 0i { break ; \"unreachable\"; }\l    y -= 1i;\l    loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l    if x > 10i { return; \"unreachable\"; }\l}\l"];
     N23[label="expr y"];
-    N24[label="expr 0"];
-    N25[label="expr y == 0"];
+    N24[label="expr 0i"];
+    N25[label="expr y == 0i"];
     N26[label="expr break"];
     N27[label="(dummy_node)"];
     N28[label="expr \"unreachable\""];
     N29[label="block { break ; \"unreachable\"; }"];
-    N30[label="expr if y == 0 { break ; \"unreachable\"; }"];
-    N31[label="expr 1"];
+    N30[label="expr if y == 0i { break ; \"unreachable\"; }"];
+    N31[label="expr 1i"];
     N32[label="expr y"];
-    N33[label="expr y -= 1"];
+    N33[label="expr y -= 1i"];
     N34[label="(dummy_node)"];
-    N35[label="expr loop  { if z == 0 { break ; \"unreachable\"; } z -= 1; }"];
+    N35[label="expr loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"];
     N36[label="expr z"];
-    N37[label="expr 0"];
-    N38[label="expr z == 0"];
+    N37[label="expr 0i"];
+    N38[label="expr z == 0i"];
     N39[label="expr break"];
     N40[label="(dummy_node)"];
     N41[label="expr \"unreachable\""];
     N42[label="block { break ; \"unreachable\"; }"];
-    N43[label="expr if z == 0 { break ; \"unreachable\"; }"];
-    N44[label="expr 1"];
+    N43[label="expr if z == 0i { break ; \"unreachable\"; }"];
+    N44[label="expr 1i"];
     N45[label="expr z"];
-    N46[label="expr z -= 1"];
-    N47[label="block { if z == 0 { break ; \"unreachable\"; } z -= 1; }"];
+    N46[label="expr z -= 1i"];
+    N47[label="block { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"];
     N48[label="expr x"];
-    N49[label="expr 10"];
-    N50[label="expr x > 10"];
+    N49[label="expr 10i"];
+    N50[label="expr x > 10i"];
     N51[label="expr return"];
     N52[label="(dummy_node)"];
     N53[label="expr \"unreachable\""];
     N54[label="block { return; \"unreachable\"; }"];
-    N55[label="expr if x > 10 { return; \"unreachable\"; }"];
-    N56[label="block {\l    if y == 0 { break ; \"unreachable\"; }\l    y -= 1;\l    loop  { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l    if x > 10 { return; \"unreachable\"; }\l}\l"];
-    N57[label="block {\l    if x == 0 { break ; \"unreachable\"; }\l    x -= 1;\l    loop  {\l        if y == 0 { break ; \"unreachable\"; }\l        y -= 1;\l        loop  { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l        if x > 10 { return; \"unreachable\"; }\l    }\l}\l"];
-    N58[label="block {\l    let mut x = 24;\l    let mut y = 24;\l    let mut z = 24;\l    loop  {\l        if x == 0 { break ; \"unreachable\"; }\l        x -= 1;\l        loop  {\l            if y == 0 { break ; \"unreachable\"; }\l            y -= 1;\l            loop  { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l            if x > 10 { return; \"unreachable\"; }\l        }\l    }\l}\l"];
+    N55[label="expr if x > 10i { return; \"unreachable\"; }"];
+    N56[label="block {\l    if y == 0i { break ; \"unreachable\"; }\l    y -= 1i;\l    loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l    if x > 10i { return; \"unreachable\"; }\l}\l"];
+    N57[label="block {\l    if x == 0i { break ; \"unreachable\"; }\l    x -= 1i;\l    loop  {\l        if y == 0i { break ; \"unreachable\"; }\l        y -= 1i;\l        loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l        if x > 10i { return; \"unreachable\"; }\l    }\l}\l"];
+    N58[label="block {\l    let mut x = 24i;\l    let mut y = 24i;\l    let mut z = 24i;\l    loop  {\l        if x == 0i { break ; \"unreachable\"; }\l        x -= 1i;\l        loop  {\l            if y == 0i { break ; \"unreachable\"; }\l            y -= 1i;\l            loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l            if x > 10i { return; \"unreachable\"; }\l        }\l    }\l}\l"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
@@ -69,7 +69,7 @@ digraph block {
     N10 -> N11;
     N11 -> N12;
     N12 -> N13;
-    N13 -> N9[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 0 { break ; \"unreachable\"; },\lexiting scope_4 stmt if x == 0 { break ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 0 { break ; \"unreachable\"; }\l    x -= 1;\l    loop  {\l        if y == 0 { break ; \"unreachable\"; }\l        y -= 1;\l        loop  { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l        if x > 10 { return; \"unreachable\"; }\l    }\l}\l"];
+    N13 -> N9[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if x == 0i { break ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 0i { break ; \"unreachable\"; }\l    x -= 1i;\l    loop  {\l        if y == 0i { break ; \"unreachable\"; }\l        y -= 1i;\l        loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l        if x > 10i { return; \"unreachable\"; }\l    }\l}\l"];
     N14 -> N15;
     N15 -> N16;
     N12 -> N17;
@@ -82,7 +82,7 @@ digraph block {
     N23 -> N24;
     N24 -> N25;
     N25 -> N26;
-    N26 -> N22[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y == 0 { break ; \"unreachable\"; },\lexiting scope_4 stmt if y == 0 { break ; \"unreachable\"; },\lexiting scope_5 block {\l    if y == 0 { break ; \"unreachable\"; }\l    y -= 1;\l    loop  { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l    if x > 10 { return; \"unreachable\"; }\l}\l"];
+    N26 -> N22[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if y == 0i { break ; \"unreachable\"; },\lexiting scope_5 block {\l    if y == 0i { break ; \"unreachable\"; }\l    y -= 1i;\l    loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l    if x > 10i { return; \"unreachable\"; }\l}\l"];
     N27 -> N28;
     N28 -> N29;
     N25 -> N30;
@@ -95,7 +95,7 @@ digraph block {
     N36 -> N37;
     N37 -> N38;
     N38 -> N39;
-    N39 -> N35[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if z == 0 { break ; \"unreachable\"; },\lexiting scope_4 stmt if z == 0 { break ; \"unreachable\"; },\lexiting scope_5 block { if z == 0 { break ; \"unreachable\"; } z -= 1; }"];
+    N39 -> N35[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if z == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if z == 0i { break ; \"unreachable\"; },\lexiting scope_5 block { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"];
     N40 -> N41;
     N41 -> N42;
     N38 -> N43;
@@ -109,7 +109,7 @@ digraph block {
     N48 -> N49;
     N49 -> N50;
     N50 -> N51;
-    N51 -> N1[label="exiting scope_0 expr loop  {\l    if y == 0 { break ; \"unreachable\"; }\l    y -= 1;\l    loop  { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l    if x > 10 { return; \"unreachable\"; }\l}\l,\lexiting scope_1 expr loop  {\l    if x == 0 { break ; \"unreachable\"; }\l    x -= 1;\l    loop  {\l        if y == 0 { break ; \"unreachable\"; }\l        y -= 1;\l        loop  { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l        if x > 10 { return; \"unreachable\"; }\l    }\l}\l"];
+    N51 -> N1[label="exiting scope_0 expr loop  {\l    if y == 0i { break ; \"unreachable\"; }\l    y -= 1i;\l    loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l    if x > 10i { return; \"unreachable\"; }\l}\l,\lexiting scope_1 expr loop  {\l    if x == 0i { break ; \"unreachable\"; }\l    x -= 1i;\l    loop  {\l        if y == 0i { break ; \"unreachable\"; }\l        y -= 1i;\l        loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l        if x > 10i { return; \"unreachable\"; }\l    }\l}\l"];
     N52 -> N53;
     N53 -> N54;
     N50 -> N55;
index f796d660a185634d3cb033241752fefe39eb6e3c..afba1d202c927b5a407c2f0ee1916302ecc01d70 100644 (file)
 
 #[allow(unreachable_code)]
 pub fn expr_while_24() {
-    let mut x = 24;
-    let mut y = 24;
-    let mut z = 24;
+    let mut x = 24i;
+    let mut y = 24i;
+    let mut z = 24i;
 
     loop {
-        if x == 0 { break; "unreachable"; }
-        x -= 1;
+        if x == 0i { break; "unreachable"; }
+        x -= 1i;
 
         loop {
-            if y == 0 { break; "unreachable"; }
-            y -= 1;
+            if y == 0i { break; "unreachable"; }
+            y -= 1i;
 
             loop {
-                if z == 0 { break; "unreachable"; }
-                z -= 1;
+                if z == 0i { break; "unreachable"; }
+                z -= 1i;
             }
 
-            if x > 10 {
+            if x > 10i {
                 return;
                 "unreachable";
             }
index c393b63546c70eff0fcbc6db0d93a333ae240cfd..11b9c7ef05ecbf5bfbc05d6ce218c43157e42662 100644 (file)
@@ -1,63 +1,63 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 25"];
+    N2[label="expr 25i"];
     N3[label="local mut x"];
-    N4[label="expr 25"];
+    N4[label="expr 25i"];
     N5[label="local mut y"];
-    N6[label="expr 25"];
+    N6[label="expr 25i"];
     N7[label="local mut z"];
     N8[label="(dummy_node)"];
-    N9[label="expr \'a:\l    loop  {\l        if x == 0 { break ; \"unreachable\"; }\l        x -= 1;\l        \'a:\l            loop  {\l                if y == 0 { break ; \"unreachable\"; }\l                y -= 1;\l                \'a: loop  { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l                if x > 10 { continue \'a ; \"unreachable\"; }\l            }\l    }\l"];
+    N9[label="expr \'a:\l    loop  {\l        if x == 0i { break ; \"unreachable\"; }\l        x -= 1i;\l        \'a:\l            loop  {\l                if y == 0i { break ; \"unreachable\"; }\l                y -= 1i;\l                \'a: loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l                if x > 10i { continue \'a ; \"unreachable\"; }\l            }\l    }\l"];
     N10[label="expr x"];
-    N11[label="expr 0"];
-    N12[label="expr x == 0"];
+    N11[label="expr 0i"];
+    N12[label="expr x == 0i"];
     N13[label="expr break"];
     N14[label="(dummy_node)"];
     N15[label="expr \"unreachable\""];
     N16[label="block { break ; \"unreachable\"; }"];
-    N17[label="expr if x == 0 { break ; \"unreachable\"; }"];
-    N18[label="expr 1"];
+    N17[label="expr if x == 0i { break ; \"unreachable\"; }"];
+    N18[label="expr 1i"];
     N19[label="expr x"];
-    N20[label="expr x -= 1"];
+    N20[label="expr x -= 1i"];
     N21[label="(dummy_node)"];
-    N22[label="expr \'a:\l    loop  {\l        if y == 0 { break ; \"unreachable\"; }\l        y -= 1;\l        \'a: loop  { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l        if x > 10 { continue \'a ; \"unreachable\"; }\l    }\l"];
+    N22[label="expr \'a:\l    loop  {\l        if y == 0i { break ; \"unreachable\"; }\l        y -= 1i;\l        \'a: loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l        if x > 10i { continue \'a ; \"unreachable\"; }\l    }\l"];
     N23[label="expr y"];
-    N24[label="expr 0"];
-    N25[label="expr y == 0"];
+    N24[label="expr 0i"];
+    N25[label="expr y == 0i"];
     N26[label="expr break"];
     N27[label="(dummy_node)"];
     N28[label="expr \"unreachable\""];
     N29[label="block { break ; \"unreachable\"; }"];
-    N30[label="expr if y == 0 { break ; \"unreachable\"; }"];
-    N31[label="expr 1"];
+    N30[label="expr if y == 0i { break ; \"unreachable\"; }"];
+    N31[label="expr 1i"];
     N32[label="expr y"];
-    N33[label="expr y -= 1"];
+    N33[label="expr y -= 1i"];
     N34[label="(dummy_node)"];
-    N35[label="expr \'a: loop  { if z == 0 { break ; \"unreachable\"; } z -= 1; }"];
+    N35[label="expr \'a: loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"];
     N36[label="expr z"];
-    N37[label="expr 0"];
-    N38[label="expr z == 0"];
+    N37[label="expr 0i"];
+    N38[label="expr z == 0i"];
     N39[label="expr break"];
     N40[label="(dummy_node)"];
     N41[label="expr \"unreachable\""];
     N42[label="block { break ; \"unreachable\"; }"];
-    N43[label="expr if z == 0 { break ; \"unreachable\"; }"];
-    N44[label="expr 1"];
+    N43[label="expr if z == 0i { break ; \"unreachable\"; }"];
+    N44[label="expr 1i"];
     N45[label="expr z"];
-    N46[label="expr z -= 1"];
-    N47[label="block { if z == 0 { break ; \"unreachable\"; } z -= 1; }"];
+    N46[label="expr z -= 1i"];
+    N47[label="block { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"];
     N48[label="expr x"];
-    N49[label="expr 10"];
-    N50[label="expr x > 10"];
+    N49[label="expr 10i"];
+    N50[label="expr x > 10i"];
     N51[label="expr continue \'a"];
     N52[label="(dummy_node)"];
     N53[label="expr \"unreachable\""];
     N54[label="block { continue \'a ; \"unreachable\"; }"];
-    N55[label="expr if x > 10 { continue \'a ; \"unreachable\"; }"];
-    N56[label="block {\l    if y == 0 { break ; \"unreachable\"; }\l    y -= 1;\l    \'a: loop  { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l    if x > 10 { continue \'a ; \"unreachable\"; }\l}\l"];
-    N57[label="block {\l    if x == 0 { break ; \"unreachable\"; }\l    x -= 1;\l    \'a:\l        loop  {\l            if y == 0 { break ; \"unreachable\"; }\l            y -= 1;\l            \'a: loop  { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l            if x > 10 { continue \'a ; \"unreachable\"; }\l        }\l}\l"];
-    N58[label="block {\l    let mut x = 25;\l    let mut y = 25;\l    let mut z = 25;\l    \'a:\l        loop  {\l            if x == 0 { break ; \"unreachable\"; }\l            x -= 1;\l            \'a:\l                loop  {\l                    if y == 0 { break ; \"unreachable\"; }\l                    y -= 1;\l                    \'a: loop  { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l                    if x > 10 { continue \'a ; \"unreachable\"; }\l                }\l        }\l}\l"];
+    N55[label="expr if x > 10i { continue \'a ; \"unreachable\"; }"];
+    N56[label="block {\l    if y == 0i { break ; \"unreachable\"; }\l    y -= 1i;\l    \'a: loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l    if x > 10i { continue \'a ; \"unreachable\"; }\l}\l"];
+    N57[label="block {\l    if x == 0i { break ; \"unreachable\"; }\l    x -= 1i;\l    \'a:\l        loop  {\l            if y == 0i { break ; \"unreachable\"; }\l            y -= 1i;\l            \'a: loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l            if x > 10i { continue \'a ; \"unreachable\"; }\l        }\l}\l"];
+    N58[label="block {\l    let mut x = 25i;\l    let mut y = 25i;\l    let mut z = 25i;\l    \'a:\l        loop  {\l            if x == 0i { break ; \"unreachable\"; }\l            x -= 1i;\l            \'a:\l                loop  {\l                    if y == 0i { break ; \"unreachable\"; }\l                    y -= 1i;\l                    \'a:\l                        loop  {\l                            if z == 0i { break ; \"unreachable\"; }\l                            z -= 1i;\l                        }\l                    if x > 10i { continue \'a ; \"unreachable\"; }\l                }\l        }\l}\l"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
@@ -69,7 +69,7 @@ digraph block {
     N10 -> N11;
     N11 -> N12;
     N12 -> N13;
-    N13 -> N9[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 0 { break ; \"unreachable\"; },\lexiting scope_4 stmt if x == 0 { break ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 0 { break ; \"unreachable\"; }\l    x -= 1;\l    \'a:\l        loop  {\l            if y == 0 { break ; \"unreachable\"; }\l            y -= 1;\l            \'a: loop  { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l            if x > 10 { continue \'a ; \"unreachable\"; }\l        }\l}\l"];
+    N13 -> N9[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if x == 0i { break ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 0i { break ; \"unreachable\"; }\l    x -= 1i;\l    \'a:\l        loop  {\l            if y == 0i { break ; \"unreachable\"; }\l            y -= 1i;\l            \'a: loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l            if x > 10i { continue \'a ; \"unreachable\"; }\l        }\l}\l"];
     N14 -> N15;
     N15 -> N16;
     N12 -> N17;
@@ -82,7 +82,7 @@ digraph block {
     N23 -> N24;
     N24 -> N25;
     N25 -> N26;
-    N26 -> N22[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y == 0 { break ; \"unreachable\"; },\lexiting scope_4 stmt if y == 0 { break ; \"unreachable\"; },\lexiting scope_5 block {\l    if y == 0 { break ; \"unreachable\"; }\l    y -= 1;\l    \'a: loop  { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l    if x > 10 { continue \'a ; \"unreachable\"; }\l}\l"];
+    N26 -> N22[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if y == 0i { break ; \"unreachable\"; },\lexiting scope_5 block {\l    if y == 0i { break ; \"unreachable\"; }\l    y -= 1i;\l    \'a: loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l    if x > 10i { continue \'a ; \"unreachable\"; }\l}\l"];
     N27 -> N28;
     N28 -> N29;
     N25 -> N30;
@@ -95,7 +95,7 @@ digraph block {
     N36 -> N37;
     N37 -> N38;
     N38 -> N39;
-    N39 -> N35[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if z == 0 { break ; \"unreachable\"; },\lexiting scope_4 stmt if z == 0 { break ; \"unreachable\"; },\lexiting scope_5 block { if z == 0 { break ; \"unreachable\"; } z -= 1; }"];
+    N39 -> N35[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if z == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if z == 0i { break ; \"unreachable\"; },\lexiting scope_5 block { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"];
     N40 -> N41;
     N41 -> N42;
     N38 -> N43;
@@ -109,7 +109,7 @@ digraph block {
     N48 -> N49;
     N49 -> N50;
     N50 -> N51;
-    N51 -> N21[label="exiting scope_0 expr continue \'a,\lexiting scope_1 stmt continue \'a ;,\lexiting scope_2 block { continue \'a ; \"unreachable\"; },\lexiting scope_3 expr if x > 10 { continue \'a ; \"unreachable\"; },\lexiting scope_4 block {\l    if y == 0 { break ; \"unreachable\"; }\l    y -= 1;\l    \'a: loop  { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l    if x > 10 { continue \'a ; \"unreachable\"; }\l}\l"];
+    N51 -> N21[label="exiting scope_0 expr continue \'a,\lexiting scope_1 stmt continue \'a ;,\lexiting scope_2 block { continue \'a ; \"unreachable\"; },\lexiting scope_3 expr if x > 10i { continue \'a ; \"unreachable\"; },\lexiting scope_4 block {\l    if y == 0i { break ; \"unreachable\"; }\l    y -= 1i;\l    \'a: loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l    if x > 10i { continue \'a ; \"unreachable\"; }\l}\l"];
     N52 -> N53;
     N53 -> N54;
     N50 -> N55;
index 2ee2e48fd10e0d2a451644cc6575623f574184e2..933f95f228cd907f6c2c3f4d9f67a620fba2c313 100644 (file)
 
 #[allow(unreachable_code)]
 pub fn expr_while_25() {
-    let mut x = 25;
-    let mut y = 25;
-    let mut z = 25;
+    let mut x = 25i;
+    let mut y = 25i;
+    let mut z = 25i;
 
     'a: loop {
-        if x == 0 { break; "unreachable"; }
-        x -= 1;
+        if x == 0i { break; "unreachable"; }
+        x -= 1i;
 
         'a: loop {
-            if y == 0 { break; "unreachable"; }
-            y -= 1;
+            if y == 0i { break; "unreachable"; }
+            y -= 1i;
 
             'a: loop {
-                if z == 0 { break; "unreachable"; }
-                z -= 1;
+                if z == 0i { break; "unreachable"; }
+                z -= 1i;
             }
 
-            if x > 10 {
+            if x > 10i {
                 continue 'a;
                 "unreachable";
             }
index 08777490f212b2e83ba2dfcf39981650f6a003c9..9fe78cc2553e742ac3263245433bed9fedede75d 100644 (file)
@@ -25,7 +25,7 @@ fn main() {
     task::try(proc() {
         let _a = A;
         lib::callback(|| fail!());
-        1
+        1i
     });
 
     unsafe {
index f1fe1e945870a7c2d591d02742eafabb8c133097..5167764dd2860c153f7352f480e0997c67300524 100644 (file)
@@ -16,6 +16,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() {
-    println!("{:?}", f(Triple {x: 3, y: 4, z: 5}, 4).a.x);
+    println!("{:?}", f(Triple {x: 3, y: 4, z: 5}, 4i).a.x);
     println!("{:?}", f(5i, 6i).a);
 }
index d0ccfe0e21d6b90de7e5408b10b462deed6c8962..1c156f6551c8d2264a07241aac146d5ad7c7c164 100644 (file)
@@ -21,6 +21,6 @@ impl <T: Send> Foo for T { }
 
 pub fn main() {
     let (tx, rx) = channel();
-    1193182.foo(tx);
-    assert!(rx.recv() == 1193182);
+    1193182i.foo(tx);
+    assert!(rx.recv() == 1193182i);
 }
index 4f94673a2c027ef7b647f15527afc8b7cb26babb..d94547a4ddac64aa785fff0939fdf8f74fb2d054 100644 (file)
@@ -36,7 +36,7 @@ pub fn main() {
   let mut kitty = cat(1000u, 2, vec!("tabby".to_string()));
   assert_eq!(nyan.how_hungry, 99);
   assert_eq!(kitty.how_hungry, 2);
-  nyan.speak(vec!(1,2,3));
+  nyan.speak(vec!(1i,2,3));
   assert_eq!(nyan.meow_count(), 55u);
   kitty.speak(vec!("meow".to_string(), "mew".to_string(), "purr".to_string(), "chirp".to_string()));
   assert_eq!(kitty.meow_count(), 1004u);
index 470e16b4888a777d1c11bc26ea7990c0b37a4a98..35c69705925651f4aba1646f90cc3cfd30eec90a 100644 (file)
@@ -110,7 +110,7 @@ pub fn main() {
     end_of_block!(ref _x, AddFlags(1));
     end_of_block!(AddFlags { bits: ref _x }, AddFlags(1));
     end_of_block!(&AddFlags { bits }, &AddFlags(1));
-    end_of_block!((_, ref _y), (AddFlags(1), 22));
+    end_of_block!((_, ref _y), (AddFlags(1), 22i));
     end_of_block!(box ref _x, box AddFlags(1));
     end_of_block!(box _x, box AddFlags(1));
     end_of_block!(_, { { check_flags(0); &AddFlags(1) } });
@@ -120,7 +120,7 @@ pub fn main() {
     // LHS does not create a ref binding, so temporary lives as long
     // as statement, and we do not move the AddFlags out:
     end_of_stmt!(_, AddFlags(1));
-    end_of_stmt!((_, _), (AddFlags(1), 22));
+    end_of_stmt!((_, _), (AddFlags(1), 22i));
 
     // `&` operator appears inside an arg to a function,
     // so it is not prolonged:
index 7805a2bb49e80e9d7af00dd695c5532268c910db..cfba87c3f6994aef1b7795847f94bab737859796 100644 (file)
@@ -31,10 +31,10 @@ fn eq(&self, other: &Int) -> bool {
 }
 
 impl PartialOrd for Int {
-    fn lt(&self, other: &Int) -> bool {
+    fn partial_cmp(&self, other: &Int) -> Option<Ordering> {
         let Int(this) = *self;
         let Int(other) = *other;
-        this < other
+        this.partial_cmp(&other)
     }
 }
 
@@ -49,10 +49,10 @@ fn eq(&self, other: &RevInt) -> bool {
 }
 
 impl PartialOrd for RevInt {
-    fn lt(&self, other: &RevInt) -> bool {
+    fn partial_cmp(&self, other: &RevInt) -> Option<Ordering> {
         let RevInt(this) = *self;
         let RevInt(other) = *other;
-        this > other
+        other.partial_cmp(&this)
     }
 }
 
index be186a95a77be9f045fe3ccf0b3226a1971a07c6..c14f430e709837fcc051a9820ec1af40727c3fca 100644 (file)
@@ -53,28 +53,28 @@ macro_rules! assert_approx_eq(
 static W: int = 1024 >> 4;
 static X: uint = 1024 >> 4;
 
-static Y: bool = 1 == 1;
-static Z: bool = 1.0 == 1.0;
+static Y: bool = 1i == 1;
+static Z: bool = 1.0f64 == 1.0;
 
-static AA: bool = 1 <= 2;
-static AB: bool = -1 <= 2;
-static AC: bool = 1.0 <= 2.0;
+static AA: bool = 1i <= 2;
+static AB: bool = -1i <= 2;
+static AC: bool = 1.0f64 <= 2.0;
 
-static AD: bool = 1 < 2;
-static AE: bool = -1 < 2;
-static AF: bool = 1.0 < 2.0;
+static AD: bool = 1i < 2;
+static AE: bool = -1i < 2;
+static AF: bool = 1.0f64 < 2.0;
 
-static AG: bool = 1 != 2;
-static AH: bool = -1 != 2;
-static AI: bool = 1.0 != 2.0;
+static AG: bool = 1i != 2;
+static AH: bool = -1i != 2;
+static AI: bool = 1.0f64 != 2.0;
 
-static AJ: bool = 2 >= 1;
-static AK: bool = 2 >= -2;
-static AL: bool = 1.0 >= -2.0;
+static AJ: bool = 2i >= 1;
+static AK: bool = 2i >= -2;
+static AL: bool = 1.0f64 >= -2.0;
 
-static AM: bool = 2 > 1;
-static AN: bool = 2 > -2;
-static AO: bool = 1.0 > -2.0;
+static AM: bool = 2i > 1;
+static AN: bool = 2i > -2;
+static AO: bool = 1.0f64 > -2.0;
 
 pub fn main() {
     assert_eq!(A, -1);
index 7ca4e25a74d339e1d4ed5935066469f86ff016d0..08912419b5c9fe530f375263ea7d0594f80f90cd 100644 (file)
@@ -23,5 +23,5 @@ pub fn main() {
     foo(F{field: 42});
     foo((1, 2u));
     foo(@1);*/
-    foo(box 1);
+    foo(box 1i);
 }
index 51f5855bb92a08f12c991428077fe3d95041b52b..6790e237e26340a9212cd04a5f43dce5a35db580 100644 (file)
@@ -24,6 +24,6 @@ pub fn main() {
         assert!(*(&B[0] as *const u8) == A[0]);
 
         let bar = str::raw::from_utf8(A).to_c_str();
-        assert_eq!(bar.with_ref(|buf| str::raw::from_c_str(buf)), "hi".to_string());
+        assert_eq!(str::raw::from_c_str(bar.as_ptr()), "hi".to_string());
     }
 }
index 69ee47fd1d946e4ea97cf8a1814eb09d391a6a9d..df5c58ff04b6d7f8cc8c0c7dad5bc9f9c86f35b9 100644 (file)
@@ -18,7 +18,7 @@ fn eq(&self, _: &FailCmp) -> bool { fail!("eq") }
 }
 
 impl PartialOrd for FailCmp {
-    fn lt(&self, _: &FailCmp) -> bool { fail!("lt") }
+    fn partial_cmp(&self, _: &FailCmp) -> Option<Ordering> { fail!("partial_cmp") }
 }
 
 impl Eq for FailCmp {}
index 4ba3aa70dfcdfbdf04521319e6c5d2edea109245..9a93873f53865bf27a38c149897fb0e359ab27b6 100644 (file)
@@ -22,5 +22,5 @@ fn drop(&mut self) {
 }
 
 pub fn main() {
-    let _x = S { x: 1 };
+    let _x = S { x: 1i };
 }
index 97e873e9aff953cb41b110a3ba9cafd236317c42..b9efdeb3bedf523ecaaca9e47d6f9486a47b8335 100644 (file)
@@ -8,5 +8,5 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn wsucc(n: int) -> int { 0 + { return n + 1 } }
+fn wsucc(n: int) -> int { 0i + { return n + 1 } }
 pub fn main() { }
index 476d3f42d6ee31375484ea1cbca68d3490a72ea8..63f32ae702b178a9ad6d8b19d443cc3bf2673e25 100644 (file)
 
 
 pub fn main() {
-    if 1 == 2 {
+    if 1i == 2 {
         assert!((false));
-    } else if 2 == 3 {
+    } else if 2i == 3 {
         assert!((false));
-    } else if 3 == 4 { assert!((false)); } else { assert!((true)); }
-    if 1 == 2 { assert!((false)); } else if 2 == 2 { assert!((true)); }
-    if 1 == 2 {
+    } else if 3i == 4 { assert!((false)); } else { assert!((true)); }
+    if 1i == 2 { assert!((false)); } else if 2i == 2 { assert!((true)); }
+    if 1i == 2 {
         assert!((false));
-    } else if 2 == 2 {
-        if 1 == 1 {
+    } else if 2i == 2 {
+        if 1i == 1 {
             assert!((true));
-        } else { if 2 == 1 { assert!((false)); } else { assert!((false)); } }
+        } else { if 2i == 1 { assert!((false)); } else { assert!((false)); } }
     }
-    if 1 == 2 {
+    if 1i == 2 {
         assert!((false));
-    } else { if 1 == 2 { assert!((false)); } else { assert!((true)); } }
+    } else { if 1i == 2 { assert!((false)); } else { assert!((true)); } }
 }
index 1d7ec0aa1bc37664295f4197f82e69f9f83c56fe..5fe8bb27e15492d55b3c3d7c3861c174b64b4a68 100644 (file)
@@ -9,10 +9,10 @@
 // except according to those terms.
 
 enum Animal {
-    Cat = 0u,
-    Dog = 1u,
-    Horse = 2u,
-    Snake = 3u
+    Cat = 0,
+    Dog = 1,
+    Horse = 2,
+    Snake = 3,
 }
 
 enum Hero {
index 814e2cca97cc7c1bb3244b4640be418c6d58aa58..ccbc5d12191e805b0f33cfe7eceb332303cb3e05 100644 (file)
@@ -23,8 +23,8 @@ enum E {
             static C: E = V;
             pub fn check() {
                 assert_eq!(size_of::<E>(), size_of::<$t>());
-                assert_eq!(V as $t, $v);
-                assert_eq!(C as $t, $v);
+                assert_eq!(V as $t, $v as $t);
+                assert_eq!(C as $t, $v as $t);
                 assert_eq!(format!("{:?}", V), "V".to_string());
                 assert_eq!(format!("{:?}", C), "V".to_string());
             }
@@ -40,8 +40,6 @@ pub fn main() {
     check!(d, u16, 0xe8d8);
     check!(e, u32, 0x17273747);
     check!(f, u32, 0xe8d8c8b8);
-    check!(g, u64, 0x1727374757677787u64);
-    check!(h, u64, 0xe8d8c8b8a8988878u64);
 
     check!(z, i8, 0x17);
     check!(y, i8, -0x17);
@@ -49,8 +47,6 @@ pub fn main() {
     check!(w, i16, -0x1727);
     check!(v, i32, 0x17273747);
     check!(u, i32, -0x17273747);
-    check!(t, i64, 0x1727374757677787);
-    check!(s, i64, -0x1727374757677787);
 
     enum Simple { A, B }
     assert_eq!(::std::mem::size_of::<Simple>(), 1);
index 4ddff8d899afe9a120a1bcf7fe5c73ccf824859a..da35ffb52959b678c7be727a8fd3a8c8878d0027 100644 (file)
@@ -20,8 +20,8 @@
 
 enum List<X> { Nil, Cons(X, Gc<List<X>>) }
 pub fn main() {
-    match Cons(10, box(GC) Nil) {
-        Cons(10, _) => {}
+    match Cons(10i, box(GC) Nil) {
+        Cons(10i, _) => {}
         Nil => {}
         _ => fail!()
     }
index a55b5eebefbaee8a8d066d203b600cc2c3562c4b..b04f5e11042c8b5d7918a9afddc29f6d8c1aaa71 100644 (file)
@@ -16,9 +16,9 @@ enum Flopsy {
 static BAR2:uint = BAR;
 
 pub fn main() {
-    let _v = [0, .. Bunny as uint];
-    let _v = [0, .. BAR];
-    let _v = [0, .. BAR2];
+    let _v = [0i, .. Bunny as uint];
+    let _v = [0i, .. BAR];
+    let _v = [0i, .. BAR2];
     static BAR3:uint = BAR2;
-    let _v = [0, .. BAR3];
+    let _v = [0i, .. BAR3];
 }
index b9d005d945fb1d8eec4a4f30e4dba73d884dabf7..5652cdea8790efcf9e40f25398b61334968c7e9b 100644 (file)
@@ -12,4 +12,4 @@
 
 use std::gc::GC;
 
-pub fn main() { let x = { box(GC) 100 }; assert!((*x == 100)); }
+pub fn main() { let x = { box(GC) 100i }; assert!((*x == 100)); }
index df7ea0c943b38cd8742efa066fbddb9d7f344f0e..050ecebb2a1a92a12dc85549423af0a6fff7a729 100644 (file)
@@ -13,4 +13,4 @@
 use std::gc::GC;
 
 // Regression test for issue #388
-pub fn main() { let _x = { { box(GC) 10 } }; }
+pub fn main() { let _x = { { box(GC) 10i } }; }
index 12777bce710b5dba0211d5cecd232c8d3223c6f5..0dff989002f5b73930a73de80d45f1a8272fd2fc 100644 (file)
@@ -11,4 +11,4 @@
 
 
 
-pub fn main() { let x = { box 100 }; assert!((*x == 100)); }
+pub fn main() { let x = { box 100i }; assert!((*x == 100)); }
index afc7dfaf9b441bcfd51a03a5cd0c4ec4fe3f5d14..7b08251967e329aef037bf8fb16dd2432ed73389 100644 (file)
@@ -12,7 +12,7 @@
 
 fn f() {
     let _x = match true {
-        true => { 10 }
+        true => { 10i }
         false => { return }
     };
 }
index a34620d2e1be427f97afd9b03057e0b9c3e5b8ce..8e56011e6dcec71da8d7416d2600fd5cfa852404 100644 (file)
@@ -12,7 +12,7 @@
 // expression results in fail.
 pub fn main() {
     let _x = if true {
-        10
+        10i
     } else {
         if true { fail!() } else { fail!() }
     };
index 023ba508ae5f393a676896102359c3954219eb4f..e9f116fcdd4259a78ad6e443f0e8f6347f25d04d 100644 (file)
@@ -8,7 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn test_if_fail() { let x = if false { fail!() } else { 10 }; assert!((x == 10)); }
+fn test_if_fail() {
+    let x = if false { fail!() } else { 10i };
+    assert!((x == 10));
+}
 
 fn test_else_fail() {
     let x = if true { 10i } else { fail!() };
@@ -16,7 +19,7 @@ fn test_else_fail() {
 }
 
 fn test_elseif_fail() {
-    let x = if false { 0 } else if false { fail!() } else { 10i };
+    let x = if false { 0i } else if false { fail!() } else { 10i };
     assert_eq!(x, 10i);
 }
 
index 5c83e81d8be2cbb73eefb506d4d67c43e5d0a41b..0d23098d8fc77b94634726296da3765a9e671c11 100644 (file)
@@ -16,7 +16,7 @@
 pub fn main() {
     let _x =
         match true {
-          true => { 10 }
+          true => { 10i }
           false => { match true { true => { fail!() } false => { fail!() } } }
         };
 }
index d1300e7f30c0467e328764f3705cc86377a24960..09df423d2dadc97d7df945c0bc5849e91d5553f9 100644 (file)
 
 
 pub fn main() {
-    let f = 4.999999999999;
-    assert!((f > 4.90));
-    assert!((f < 5.0));
-    let g = 4.90000000001e-10;
-    assert!((g > 5e-11));
-    assert!((g < 5e-9));
+    let f = 4.999999999999f64;
+    assert!((f > 4.90f64));
+    assert!((f < 5.0f64));
+    let g = 4.90000000001e-10f64;
+    assert!((g > 5e-11f64));
+    assert!((g < 5e-9f64));
 }
index 34417891197a422dd6db05cf34c80eabec933198..80d3527736f40b9de881f4ce43bedf98eda37976 100644 (file)
@@ -13,6 +13,6 @@
 pub fn main() {
     // We should be able to type infer inside of ||s.
     let _f = || {
-        let i = 10;
+        let i = 10i;
     };
 }
index 87ed7826fed57fbe55fdccaffd2f74c4ca082bee..d9d3e3202609724cf92367ab344a84fc3c532cc7 100644 (file)
@@ -9,8 +9,8 @@
 // except according to those terms.
 
 pub fn main() {
-    let x = [1,..100];
-    let mut y = 0;
+    let x = [1i,..100];
+    let mut y = 0i;
     for i in x.iter() {
         if y > 10 {
             break;
index 78aba778421b190295818c9c83dc6f746f7a376a..f4d38dfcfc329e3373a829656a2a4b430c1df2d3 100644 (file)
@@ -9,10 +9,10 @@
 // except according to those terms.
 
 pub fn main() {
-    let x = [1,..100];
-    let y = [2,..100];
-    let mut p = 0;
-    let mut q = 0;
+    let x = [1i,..100];
+    let y = [2i,..100];
+    let mut p = 0i;
+    let mut q = 0i;
     for i in x.iter() {
         for j in y.iter() {
             p += *j;
index 593a996d8dfe9d465d4a1d97d497fdd35782e7ff..684a9b81fb256f72efa7d5009c90fac1d6e84495 100644 (file)
@@ -9,8 +9,8 @@
 // except according to those terms.
 
 pub fn main() {
-    let x = [1,..100];
-    let mut y = 0;
+    let x = [1i,..100];
+    let mut y = 0i;
     for i in x.iter() {
         y += *i
     }
index 21238e68b3143f59cd64362a59a2428cfd3a95b3..9dd52dfb6da0e42894be3b10692ed8ad9c665d33 100644 (file)
@@ -22,7 +22,7 @@ fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t),
 pub fn main() {
     unsafe {
         Thread::start(proc() {
-            let i = &100;
+            let i = &100i;
             rust_dbg_call(callback, mem::transmute(i));
         }).join();
     }
@@ -31,6 +31,6 @@ pub fn main() {
 extern fn callback(data: libc::uintptr_t) {
     unsafe {
         let data: *const int = mem::transmute(data);
-        assert_eq!(*data, 100);
+        assert_eq!(*data, 100i);
     }
 }
index f879e195292c8e722cc80745cf51c4c587ff98f5..ac97a2aa9e85482bc1568b72e1cee634c57b2dd5 100644 (file)
@@ -10,4 +10,4 @@
 
 enum wrapper<T> { wrapped(T), }
 
-pub fn main() { let _w = wrapped(vec!(1, 2, 3, 4, 5)); }
+pub fn main() { let _w = wrapped(vec!(1i, 2, 3, 4, 5)); }
index 18d1b7f03a1d095a0dc1a2f6776934a8ffb6b38c..4402dd35d0965b8b1c28748a57c91fa173d0e2b0 100644 (file)
@@ -13,4 +13,4 @@
 use std::gc::{Gc, GC};
 
 fn f<T>(_v: Gc<T>) { }
-pub fn main() { f(box(GC) vec!(1, 2, 3, 4, 5)); }
+pub fn main() { f(box(GC) vec!(1i, 2, 3, 4, 5)); }
index fb8140790e3e9f940ae7a8adcdd80ae28597bc57..7d011e57671de80d12f8e829304ebd599852296e 100644 (file)
@@ -12,4 +12,4 @@
 
 enum clam<T> { a(T), }
 
-pub fn main() { let _c = a(3); }
+pub fn main() { let _c = a(3i); }
index 450620767e301cf23483b5a971fd913bb38693b9..5bfbe4bf5a01da6b1d018ff7ceea0cafd79d0c91 100644 (file)
@@ -12,14 +12,14 @@ struct Pair { x: int, y: int }
 
 pub fn main() {
     let a: int =
-        match 10 { x if x < 7 => { 1 } x if x < 11 => { 2 } 10 => { 3 } _ => { 4 } };
+        match 10i { x if x < 7 => { 1i } x if x < 11 => { 2i } 10 => { 3i } _ => { 4i } };
     assert_eq!(a, 2);
 
     let b: int =
         match (Pair {x: 10, y: 20}) {
-          x if x.x < 5 && x.y < 5 => { 1 }
-          Pair {x: x, y: y} if x == 10 && y == 20 => { 2 }
-          Pair {x: _x, y: _y} => { 3 }
+          x if x.x < 5 && x.y < 5 => { 1i }
+          Pair {x: x, y: y} if x == 10 && y == 20 => { 2i }
+          Pair {x: _x, y: _y} => { 3i }
         };
     assert_eq!(b, 2);
 }
index 3969394a26b93a9daaa6a7c75722b1b268aa7db3..eb81f82a146f74cb425ae27acf0a1d8b71fd105e 100644 (file)
@@ -14,7 +14,7 @@ pub fn g() -> uint {14}
 
 pub fn main(){
     // should *not* shadow the module x:
-    let x = 9;
+    let x = 9i;
     // use it to avoid warnings:
     x+3;
     assert_eq!(x::g(),14);
index b176254a878bf77c6f321e126ec4e835aceb681f..27c63d425bf387a872ef925608d06217d360f7fb 100644 (file)
@@ -21,28 +21,28 @@ pub fn main() {
     //let (a, b, ..) = (5, 5, 5, 5);
     //let (.., c, d) = (5, 5, 5, 5);
     let Bar{b: b, ..} = Bar{a: 5, b: 5, c: 5, d: 5};
-    match [5, 5, 5, 5] {
+    match [5i, 5, 5, 5] {
         [..] => { }
     }
-    match [5, 5, 5, 5] {
+    match [5i, 5, 5, 5] {
         [a, ..] => { }
     }
-    match [5, 5, 5, 5] {
+    match [5i, 5, 5, 5] {
         [.., b] => { }
     }
-    match [5, 5, 5, 5] {
+    match [5i, 5, 5, 5] {
         [a, .., b] => { }
     }
-    match [5, 5, 5] {
+    match [5i, 5, 5] {
         [..] => { }
     }
-    match [5, 5, 5] {
+    match [5i, 5, 5] {
         [a, ..] => { }
     }
-    match [5, 5, 5] {
+    match [5i, 5, 5] {
         [.., a] => { }
     }
-    match [5, 5, 5] {
+    match [5i, 5, 5] {
         [a, .., b] => { }
     }
 }
index 24196c225719a113887d410990dad2b80e0a1b4f..19300569d2050cd6c24e37babcf38f959efe5376 100644 (file)
 
 pub fn main() {
     use std::mem::replace;
-    let mut x = 5;
+    let mut x = 5i;
     replace(&mut x, 6);
     {
         use std::mem::*;
-        let mut y = 6;
+        let mut y = 6i;
         swap(&mut x, &mut y);
     }
 }
index 44f6b6140fbffaeca2bdd1617d32b65c84280c32..0639d7320896bae349dad2523c4a0da69e0d5b83 100644 (file)
@@ -16,4 +16,4 @@ mod zed {
     pub fn bar() { println!("bar"); }
 }
 
-pub fn main() { let _zed = 42; bar(); }
+pub fn main() { let _zed = 42i; bar(); }
index b2b16c4ef84201229444bce76a2f29037727d7c4..a7b2a46f0c3a450d4a4c2ec34bb79cccc93e1964 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 pub fn main() {
-    let x = 2;
+    let x = 2i;
     let x_message = match x {
       0 .. 1     => { "not many".to_string() }
       _          => { "lots".to_string() }
index 5e0aeeb6bed7612a37f1ecb0eb4e3d41e3a08cee..5d4f6458cf9bcaa8d92307c5bbb326c65eddd058 100644 (file)
@@ -36,7 +36,7 @@ fn r(i: Gc<Cell<int>>) -> r {
 }
 
 fn test_box() {
-    let i = box(GC) Cell::new(0);
+    let i = box(GC) Cell::new(0i);
     {
         let _a = box(GC) r(i);
     }
@@ -44,7 +44,7 @@ fn test_box() {
 }
 
 fn test_rec() {
-    let i = box(GC) Cell::new(0);
+    let i = box(GC) Cell::new(0i);
     {
         let _a = Box {x: r(i)};
     }
@@ -56,7 +56,7 @@ enum t {
         t0(r),
     }
 
-    let i = box(GC) Cell::new(0);
+    let i = box(GC) Cell::new(0i);
     {
         let _a = t0(r(i));
     }
@@ -64,15 +64,15 @@ enum t {
 }
 
 fn test_tup() {
-    let i = box(GC) Cell::new(0);
+    let i = box(GC) Cell::new(0i);
     {
-        let _a = (r(i), 0);
+        let _a = (r(i), 0i);
     }
     assert_eq!(i.get(), 1);
 }
 
 fn test_unique() {
-    let i = box(GC) Cell::new(0);
+    let i = box(GC) Cell::new(0i);
     {
         let _a = box r(i);
     }
@@ -80,7 +80,7 @@ fn test_unique() {
 }
 
 fn test_box_rec() {
-    let i = box(GC) Cell::new(0);
+    let i = box(GC) Cell::new(0i);
     {
         let _a = box(GC) Box {
             x: r(i)
index bc77b4c534311f0115a3fe3966238d206d4882d5..a4ef77df311256a8bad53744bd536cab8c6b4aff 100644 (file)
@@ -13,6 +13,6 @@ pub fn main() {
     ////////////////// still not a doc comment
     /////**** nope, me neither */
     /*** And neither am I! */
-    5;
+    5i;
     /*****! certainly not I */
 }
index 7d5bd9d6a74db57c3614deece86a932dab8f0bbf..ad3a050dde9e9835bb3dce4c5ee797d916853122 100644 (file)
@@ -10,7 +10,7 @@
 
 pub fn main () {
   let mut line = "".to_string();
-  let mut i = 0;
+  let mut i = 0i;
   while line != "exit".to_string() {
     line = if i == 9 { "exit".to_string() } else { "notexit".to_string() };
     i += 1;
index 8acaa889a0490a7fcc2f7cfa1d9643761f54318f..e1634e44847ee4b33357ce207d0fdec8c9eff860 100644 (file)
@@ -27,80 +27,80 @@ pub fn main() {
 }
 
 fn lit_shadow_range() {
-    assert_eq!(2i, match 1 {
-        1 if false => 1,
+    assert_eq!(2i, match 1i {
+        1 if false => 1i,
         1..2 => 2,
         _ => 3
     });
 
     let x = 0i;
     assert_eq!(2i, match x+1 {
-        0 => 0,
+        0 => 0i,
         1 if false => 1,
         1..2 => 2,
         _ => 3
     });
 
     assert_eq!(2i, match val() {
-        1 if false => 1,
+        1 if false => 1i,
         1..2 => 2,
         _ => 3
     });
 
     assert_eq!(2i, match CONST {
-        0 => 0,
+        0 => 0i,
         1 if false => 1,
         1..2 => 2,
         _ => 3
     });
 
     // value is out of the range of second arm, should match wildcard pattern
-    assert_eq!(3i, match 3 {
-        1 if false => 1,
+    assert_eq!(3i, match 3i {
+        1 if false => 1i,
         1..2 => 2,
         _ => 3
     });
 }
 
 fn range_shadow_lit() {
-    assert_eq!(2i, match 1 {
-        1..2 if false => 1,
+    assert_eq!(2i, match 1i {
+        1..2 if false => 1i,
         1 => 2,
         _ => 3
     });
 
     let x = 0i;
     assert_eq!(2i, match x+1 {
-        0 => 0,
+        0 => 0i,
         1..2 if false => 1,
         1 => 2,
         _ => 3
     });
 
     assert_eq!(2i, match val() {
-        1..2 if false => 1,
+        1..2 if false => 1i,
         1 => 2,
         _ => 3
     });
 
     assert_eq!(2i, match CONST {
-        0 => 0,
+        0 => 0i,
         1..2 if false => 1,
         1 => 2,
         _ => 3
     });
 
     // ditto
-    assert_eq!(3i, match 3 {
-        1..2 if false => 1,
+    assert_eq!(3i, match 3i {
+        1..2 if false => 1i,
         1 => 2,
         _ => 3
     });
 }
 
 fn range_shadow_range() {
-    assert_eq!(2i, match 1 {
-        0..2 if false => 1,
+    assert_eq!(2i, match 1i {
+        0..2 if false => 1i,
         1..3 => 2,
         _ => 3,
     });
@@ -127,16 +127,16 @@ fn range_shadow_range() {
     });
 
     // ditto
-    assert_eq!(3i, match 5 {
-        0..2 if false => 1,
+    assert_eq!(3i, match 5i {
+        0..2 if false => 1i,
         1..3 => 2,
         _ => 3,
     });
 }
 
 fn multi_pats_shadow_lit() {
-    assert_eq!(2i, match 1 {
-        100 => 0,
+    assert_eq!(2i, match 1i {
+        100 => 0i,
         0 | 1..10 if false => 1,
         1 => 2,
         _ => 3,
@@ -144,8 +144,8 @@ fn multi_pats_shadow_lit() {
 }
 
 fn multi_pats_shadow_range() {
-    assert_eq!(2i, match 1 {
-        100 => 0,
+    assert_eq!(2i, match 1i {
+        100 => 0i,
         0 | 1..10 if false => 1,
         1..3 => 2,
         _ => 3,
@@ -153,8 +153,8 @@ fn multi_pats_shadow_range() {
 }
 
 fn lit_shadow_multi_pats() {
-    assert_eq!(2i, match 1 {
-        100 => 0,
+    assert_eq!(2i, match 1i {
+        100 => 0i,
         1 if false => 1,
         0 | 1..10 => 2,
         _ => 3,
@@ -162,8 +162,8 @@ fn lit_shadow_multi_pats() {
 }
 
 fn range_shadow_multi_pats() {
-    assert_eq!(2i, match 1 {
-        100 => 0,
+    assert_eq!(2i, match 1i {
+        100 => 0i,
         1..3 if false => 1,
         0 | 1..10 => 2,
         _ => 3,
@@ -182,5 +182,5 @@ enum Foo {
         [Bar(_, pred)] if !pred => 2i,
         _ => 0i,
     };
-    assert_eq!(2, r);
+    assert_eq!(2i, r);
 }
index 528e6d43cef730e3b41ac0865f0015d9c8bb8321..d8f8b979ad06366156df960e8ab4711b3aacd13e 100644 (file)
@@ -29,9 +29,9 @@ fn helper(rx: Receiver<Sender<()>>) {
 fn test() {
     let (tx, rx) = channel();
     spawn(proc() { helper(rx) });
-    let (snd, rcv) = channel();
+    let (snd, rcv) = channel::<int>();
     for _ in range(1i, 100000i) {
-        snd.send(1);
+        snd.send(1i);
         let (tx2, rx2) = channel();
         tx.send(tx2);
         select! {
index 44465fe5f80ee493fdacb95d5c2245638483c9f6..8176262abd918fc8ed47143923f7223b16588d6e 100644 (file)
@@ -10,5 +10,5 @@
 
 
 pub fn main() {
-    {|i| if 1 == i { }};
+    {|i| if 1i == i { }};
 }
index e5cfccac13a88323597e2a970c2aa4aba3b28b08..378fd4a222e388a6617e7d48be60b5f859abb73a 100644 (file)
@@ -17,7 +17,7 @@ macro_rules! outer (
     ($e:pat ) => (inner!($e)))
 
 fn main() {
-    let outer!(g1) = 13;
+    let outer!(g1) = 13i;
     g1;
 }
 
index 7276b11b1816cd4596408436403f6e4772db4dbe..d9d4120d4f40506e715e2b675776841a509a9d43 100644 (file)
@@ -16,7 +16,7 @@ pub fn main() {
     'foo: loop {
         'bar: loop {
             'quux: loop {
-                if 1 == 2 {
+                if 1i == 2 {
                     break 'foo;
                 }
                 else {
index 5cdda4e5548c3bcd80d79e19922d10a61d854106..41cf3eaf7e31a1cd4086f1ec45c8560c3e95c2a0 100644 (file)
@@ -15,5 +15,5 @@
 
 pub fn main() {
     let mut q = RingBuf::new();
-    q.push_back(10);
+    q.push_back(10i);
 }
index 4e73be8d84e3a582abed7c04804cc5a01a8b84ef..8c8b9d5df1359b6829aa8f9b9abce40451878758 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 pub fn main() {
-    let _foo = 100;
+    let _foo = 100i;
     static quux: int = 5;
 
     enum Stuff {
index e331173a1589d871066e35347af35facc4a1890d..11ebf014bc65e6ce1c97a258303f0b398fad1803 100644 (file)
@@ -21,5 +21,5 @@ fn deadcode() {
 }
 
 pub fn main() {
-    let _ = perform_hax(box 42);
+    let _ = perform_hax(box 42i);
 }
index 622b35b93aeadcf5ad19cecadc11b79f7c34558a..1a5b175cffcee5e402a53aaec1c415a646883526 100644 (file)
@@ -21,5 +21,5 @@ fn deadcode() {
 }
 
 pub fn main() {
-    perform_hax(box 42);
+    perform_hax(box 42i);
 }
index beba39602dedba6298e2fddbe662b381141b765f..a0a800e08906dc134f9a597873f80c851b03ca00 100644 (file)
@@ -22,11 +22,11 @@ enum object {
     int_value(i64),
 }
 
-fn lookup(table: Box<json::Object>, key: String, default: String) -> String
+fn lookup(table: json::Object, key: String, default: String) -> String
 {
     match table.find(&key.to_string()) {
         option::Some(&json::String(ref s)) => {
-            (*s).to_string()
+            s.to_string()
         }
         option::Some(value) => {
             println!("{} was expected to be a string but is a {:?}", key, value);
@@ -42,7 +42,7 @@ fn add_interface(_store: int, managed_ip: String, data: json::Json) -> (String,
 {
     match &data {
         &json::Object(ref interface) => {
-            let name = lookup((*interface).clone(),
+            let name = lookup(interface.clone(),
                               "ifDescr".to_string(),
                               "".to_string());
             let label = format!("{}-{}", managed_ip, name);
index 1217f32826f6d3be179ba888f22374baeba3443a..ef49d0a170f882256c3947c56b3f43cfde9e080f 100644 (file)
@@ -12,4 +12,4 @@
 
 fn id<T>(x: T) -> T { return x; }
 
-pub fn main() { assert!((quux(10) == 10)); }
+pub fn main() { assert!((quux(10i) == 10i)); }
index 99def5476f9a0bc563c83160df9e309334a7299f..eb422c9a8b99b4f5ca3b85e662dd5e1b8f9834f4 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 pub fn main() {
-    let x = &Some(1);
+    let x = &Some(1i);
     match x {
         &Some(_) => (),
         &None => (),
index 1b09889c887fbd2da7223394ef0832fe739c5e09..063b2d703014774f7eeff6f75834117487619622 100644 (file)
@@ -11,6 +11,6 @@
 #![allow(path_statement)]
 
 pub fn main() {
-    let y = box 1;
+    let y = box 1i;
     y;
 }
index f2973256199fa792a7db8127138a41ed06034fc5..447bf3b4b267e8f11d1fe16eb5f5497eb2423faa 100644 (file)
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 pub fn main() {
-    let _foo = [0, ..2*4];
+    let _foo = [0i, ..2*4];
 }
index 80727b569dea9b4bf8d52713cd1469084a9f4d17..e1ecf47e9260b1281f371acb9a746e2c468a432b 100644 (file)
@@ -15,7 +15,7 @@
 enum Either<T, U> { Left(T), Right(U) }
 
 pub fn main() {
-    match Left(box(GC) 17) {
+    match Left(box(GC) 17i) {
         Right(()) => {}
         _ => {}
     }
index 4eb005f3397252bc9da09a7e0e3d8cc8fac8efbf..6512db3b1c58a0f47767ce08a47d4722aea3e83f 100644 (file)
@@ -21,7 +21,7 @@ impl Foo for Struct {}
 
 pub fn main() {
     match A(box Struct as Box<Foo>) {
-        A(_a) => 0,
+        A(_a) => 0i,
     };
 }
 
index 06f41e9cb7a7913a9436b5330a16059c4ad58263..e5949e23467b08e1a23e39f1180108c919f28ab8 100644 (file)
@@ -14,5 +14,5 @@
 use minimal::{BTree, leaf};
 
 pub fn main() {
-    BTree::<int> { node: leaf(1) };
+    BTree::<int> { node: leaf(1i) };
 }
index 770de8f53466684be2ccfa8801dd60fa95f6c33e..e4f4db6ea63b710e878e3ce11b1071576a4e1c5c 100644 (file)
@@ -9,14 +9,14 @@
 // except according to those terms.
 
 pub fn main() {
-    match &[(box 5,box 7)] {
+    match &[(box 5i,box 7i)] {
         ps => {
            let (ref y, _) = ps[0];
            assert!(**y == 5);
         }
     }
 
-    match Some(&[(box 5,)]) {
+    match Some(&[(box 5i,)]) {
         Some(ps) => {
            let (ref y,) = ps[0];
            assert!(**y == 5);
@@ -24,7 +24,7 @@ pub fn main() {
         None => ()
     }
 
-    match Some(&[(box 5,box 7)]) {
+    match Some(&[(box 5i,box 7i)]) {
         Some(ps) => {
            let (ref y, ref z) = ps[0];
            assert!(**y == 5);
index 12dcc4ecd2c3a1b6685f364250b606bc581a2c0e..99ab83ec62073123afe4ef28cd0cc8e82dfa4674 100644 (file)
@@ -11,7 +11,7 @@
 fn f<T>(g: || -> T) -> T { g() }
 
 pub fn main() {
-  let _x = f( | | { 10 });
+  let _x = f( | | { 10i });
     // used to be: cannot determine a type for this expression
     f(| | { });
     // ditto
index 84e9de9b924ab7a4f8c21c0582780f04c0b07ed9..e787962bb813edd53b9dead43aff400574df5aa5 100644 (file)
@@ -19,7 +19,7 @@ fn assert_repr_eq<T>(obj : T, expected : String) {
 }
 
 pub fn main() {
-    let abc = [1, 2, 3];
+    let abc = [1i, 2, 3];
     let tf = [true, false];
     let x  = [(), ()];
     let slice = x.slice(0,1);
index 9f6b281810e31f2f10e5cfd430ac67a247b675b5..2fb96f593efa102377b1bcdca535d56b7d7bad7b 100644 (file)
@@ -16,6 +16,6 @@ fn main() {
     fn f(_: proc()) {}
     fn eat<T>(_: T) {}
 
-    let x = box(GC) 1;
+    let x = box(GC) 1i;
     f(proc() { eat(x) });
 }
index 6b8e250ea74bfb738f8e3bfb0fa0d03a81d501d5..dd12ea8b76523f7fd6c811db262e1e5e1f13589d 100644 (file)
@@ -14,5 +14,5 @@
 
 pub fn main() {
     testmod::foo();
-    testmod::FooBar::new(1);
+    testmod::FooBar::new(1i);
 }
index 7864f4fbdd66c70b38ce51ae375f83fb35e196e4..aa86f488906e68dcc7ac658f0232f4b3d1749827 100644 (file)
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 pub fn main() {
-    static S: uint = 23 as uint; [0, ..S]; ()
+    static S: uint = 23 as uint; [0i, ..S]; ()
 }
index ff568b77f08ac205fffb295f9579855d92868b76..885f266ca3d95e9f0544ce5467d06770fdd5b2dc 100644 (file)
@@ -19,7 +19,7 @@ mod foo {
 }
 
 fn bar() -> int {
-    match 0 {
-      _ => { 0 }
+    match 0i {
+      _ => { 0i }
     }
 }
index c4f37ccf88ad389fdea6660de57f90d95808f474..366b3c41328fde93223ec9298d64c1c8b427ad01 100644 (file)
@@ -13,7 +13,7 @@
 fn incr(x: &mut int) -> bool { *x += 1; assert!((false)); return false; }
 
 pub fn main() {
-    let x = 1 == 2 || 3 == 3;
+    let x = 1i == 2 || 3i == 3;
     assert!((x));
     let mut y: int = 10;
     println!("{:?}", x || incr(&mut y));
index 60f7689ecfa638b536111516e8ae9972d7ff1567..cd8be550d511beaac3d2ff15a6abb15a1e41b6b9 100644 (file)
@@ -12,4 +12,4 @@
 
 fn foo(x: int) { println!("{}", x); }
 
-pub fn main() { let mut x: int; if 1 > 2 { x = 12; } else { x = 10; } foo(x); }
+pub fn main() { let mut x: int; if 1i > 2 { x = 12; } else { x = 10; } foo(x); }
index cbe26844708db79e082b2bce2dbab5fd55ccf00b..7d30b22867c0561fa322f3394d307dbdd849b797 100644 (file)
@@ -14,6 +14,6 @@ pub fn main() {
     let mut i: int = 0;
     while i < 1000000 {
         i += 1;
-        let x = 3;
+        let x = 3i;
     }
 }
index 9c46ba2cb9bbfefdc0e3f0c074ed5c0fc120a020..4fe73188b45aaf809fffa733b1c1001a8ebe03f6 100644 (file)
@@ -16,5 +16,5 @@ fn forever() -> ! {
 }
 
 pub fn main() {
-  if (1 == 2) { forever(); }
+  if (1i == 2) { forever(); }
 }
index cfe51fe77589fd07c475917e5a530abe111bbac6..46d4fa460fe2b280d710d85b4dc8ede6409adffd 100644 (file)
@@ -12,7 +12,7 @@
 
 fn main() {
     let mut foo = Vec::new();
-    'foo: for i in [1, 2, 3].iter() {
+    'foo: for i in [1i, 2, 3].iter() {
         foo.push(i);
     }
 }
index 8b77500225022172302169bca8cca70f0f2bb8da..14aee4c3be81d001e25ab0dc0a5d5ccb1ed0a597 100644 (file)
@@ -17,7 +17,7 @@ fn my_fail() -> ! { loop {} }
 
 pub fn step(f: bool) {
     let mut g = S;
-    let mut i = 0;
+    let mut i = 0i;
     loop
     {
         if i > 10 { break; } else { i += 1; }
index ba897bd92c01757c7cadacc14cf665c1b154f43d..f3c299bd1f9138c9a9469b8fcc076f417d11fc02 100644 (file)
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 // n.b. This was only ever failing with optimization disabled.
-fn a() -> int { match return 1 { 2 => 3, _ => fail!() } }
+fn a() -> int { match return 1i { 2i => 3i, _ => fail!() } }
 pub fn main() { a(); }
index 433cf23626bbfa8f17b146cca75132c506e5837d..170a3513a1a3536c93f58eeac01f1792cacfdc18 100644 (file)
@@ -11,7 +11,7 @@
 struct X { x: int }
 
 pub fn main() {
-    let _x = match 0 {
+    let _x = match 0i {
       _ => X {
         x: 0
       }.x
index fe12b7c1585681f23a182737ec57a6f373976723..21c31b621835e37275d2eafb54da8bc183d05ea4 100644 (file)
@@ -11,7 +11,7 @@
 struct X { x: int }
 
 pub fn main() {
-    let _x = match 0 {
+    let _x = match 0i {
       _ => X {
         x: 0
       }
index 52d966a12d71a9d36b66a6d4dac21d0a2920d10f..2169e996577bf89756a9f515749638e19cc85ab9 100644 (file)
@@ -10,7 +10,7 @@
 
 fn test1() {
     // from issue 6338
-    match ((1, "a".to_string()), (2, "b".to_string())) {
+    match ((1i, "a".to_string()), (2i, "b".to_string())) {
         ((1, a), (2, b)) | ((2, b), (1, a)) => {
                 assert_eq!(a, "a".to_string());
                 assert_eq!(b, "b".to_string());
index 6b02b21a084bd950bdf6d2af91c51530339d499b..7421ae9588407f8f74fc4fb1e5e6cbab8c069919 100644 (file)
@@ -26,15 +26,15 @@ pub fn main() {
       'a'..'z' => {}
       _ => fail!("should suppport char ranges")
     }
-    match -3 {
+    match -3i {
       -7..5 => {}
       _ => fail!("should match signed range")
     }
-    match 3.0 {
+    match 3.0f64 {
       1.0..5.0 => {}
       _ => fail!("should match float range")
     }
-    match -1.5 {
+    match -1.5f64 {
       -3.6..3.6 => {}
       _ => fail!("should match negative float range")
     }
index eb1444be37844d8d7e3d6412343a5a21ad760e68..201abeba073883e6b8abca3e418263dca6ed535b 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 pub fn main() {
-    let x = 10;
+    let x = 10i;
     let y = x;
     assert!((y == 10));
 }
index d92496c4b7b40b6099a780c083251fcdb9da39ee..148c1c9f0cfafb714c52d1bf333541e31ba6dcc3 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 pub fn main() {
-    match -5 {
+    match -5i {
       -5 => {}
       _ => { fail!() }
     }
index 0150120e1dbcad86416acc8400ae02a5246668e5..b16bef3fc9902c168b676ffb4bc5d5dce9288268 100644 (file)
@@ -22,15 +22,15 @@ struct Structure {
 }
 
 pub fn main() {
-    let x: Box<int> = box(HEAP) 2;
-    let y: Box<int> = box 2;
-    let z: Gc<int> = box(GC) 2;
+    let x: Box<int> = box(HEAP) 2i;
+    let y: Box<int> = box 2i;
+    let z: Gc<int> = box(GC) 2i;
     let a: Gc<Structure> = box(GC) Structure {
         x: 10,
         y: 20,
     };
-    let b: Box<int> = box()(1 + 2);
-    let c = box()(3 + 4);
-    let d = box(GC)(5 + 6);
+    let b: Box<int> = box()(1i + 2);
+    let c = box()(3i + 4);
+    let d = box(GC)(5i + 6);
 }
 
index bee6d23a27d6245eef08d96588f22910c95cb9da..8d45b8ecb0844cc9c014d8bb4ce2d54f97eb1f24 100644 (file)
@@ -12,4 +12,4 @@
 
 
 // Testcase for issue #130, operator associativity.
-pub fn main() { assert!((3 * 5 / 2 == 7)); }
+pub fn main() { assert!((3i * 5i / 2i == 7i)); }
index 1566b9ed6f19c1d467e67426794bf03966b98521..19d1635a9a5e13e73802e445db9d6e3e0241e6e5 100644 (file)
@@ -21,7 +21,7 @@
 pub fn black_box<T>(dummy: T) { unsafe { asm!("" : : "r"(&dummy)) } }
 
 fn silent_recurse() {
-    let buf = [0, ..1000];
+    let buf = [0i, ..1000];
     black_box(buf);
     silent_recurse();
 }
index d1e9fb270d7bd1a744594b96342deaab1dc41ce0..498b81d307e29b613b3925f79b6f82c828e3d00b 100644 (file)
@@ -11,5 +11,5 @@
 fn f<T: 'static>(_x: T) {}
 
 pub fn main() {
-    f(box 5);
+    f(box 5i);
 }
index d9669812d2ad37711eb4388981fd2fdf54b3d8f3..569023c443908f77ae69e9662b5b234c42bc641a 100644 (file)
@@ -10,6 +10,6 @@
 
 pub fn main() {
     let x = true;
-    if x { let mut i = 10; while i > 0 { i -= 1; } }
+    if x { let mut i = 10i; while i > 0 { i -= 1; } }
     match x { true => { println!("right"); } false => { println!("wrong"); } }
 }
index d48f9dccaafc9561f79c2adf061820857e404c6c..16f5a06b88684a2ee98aadc844c8dec026d31750 100644 (file)
@@ -18,6 +18,6 @@ mod a {
 
 pub fn main() {
     unsafe {
-        a::free(transmute(0));
+        a::free(transmute(0u));
     }
 }
index 1342c2e77f28f88c9fc9eb89ef5f1f7c6d59ff34..13200d619d02e0ba9dbe63ca017f782280895ad1 100644 (file)
@@ -12,7 +12,7 @@
 fn view<'r, T>(x: &'r [T]) -> &'r [T] {x}
 
 pub fn main() {
-    let v = vec!(1, 2, 3);
+    let v = vec!(1i, 2, 3);
     let x = view(v.as_slice());
     let y = view(x.as_slice());
     assert!((*v.get(0) == x[0]) && (*v.get(0) == y[0]));
index dc6dac15bb2b1fb8547802e00c5b7c2f62f3101b..9dc3b7a0f80e146d991eb1928ba2329d5888dace 100644 (file)
@@ -33,11 +33,11 @@ fn r(i: Gc<Cell<int>>) -> r {
 }
 
 pub fn main() {
-    let i = box(GC) Cell::new(0);
+    let i = box(GC) Cell::new(0i);
     // Even though these look like copies, they are guaranteed not to be
     {
         let a = r(i);
-        let b = (a, 10);
+        let b = (a, 10i);
         let (c, _d) = b;
         println!("{:?}", c);
     }
index e613a83737e4d840cbedfa2500bf3f7f0174f6f5..75fb98f8e24f9f888cdca9b64e895af1d4fdbdae 100644 (file)
 use std::rc::Rc;
 
 pub fn main() {
-   let mut x = box 3;
+   let mut x = box 3i;
    x = x;
    assert!(*x == 3);
 
-   let mut x = Rc::new(3);
+   let mut x = Rc::new(3i);
    x = x;
    assert!(*x == 3);
 }
index a65e44166e9eded28c384d9b3293d4b1555d1a6d..96a12494b2ff2661170b99871af51063e03d197a 100644 (file)
@@ -19,7 +19,7 @@ fn foo(c: Vec<int> ) {
         some::<int>(_) => {
             for _i in c.iter() {
                 println!("{:?}", a);
-                let a = 17;
+                let a = 17i;
                 b.push(a);
             }
         }
@@ -29,4 +29,4 @@ fn foo(c: Vec<int> ) {
 
 enum t<T> { none, some(T), }
 
-pub fn main() { let x = 10; let x = x + 20; assert!((x == 30)); foo(Vec::new()); }
+pub fn main() { let x = 10i; let x = x + 20; assert!((x == 30)); foo(Vec::new()); }
index f8fd81b9365159f6bcc21f72e46515172385720f..c695fa2b72ec1cb7614be9b1f3240c75786389f3 100644 (file)
 static b: bool = true;
 
 #[static_assert]
-static c: bool = 1 == 1;
+static c: bool = 1i == 1;
 
 #[static_assert]
-static d: bool = 1 != 2;
+static d: bool = 1i != 2;
 
 #[static_assert]
-static f: bool = (4/2) == 2;
+static f: bool = (4i/2) == 2;
 
 pub fn main() {
 }
index 612483f69094d832bb86cc28bb69dba2d05b817c..dc1e23ca09cf4aa1441625ae6ef5fb9f625a4f44 100644 (file)
@@ -11,7 +11,7 @@
 pub fn main() {
     // Make sure we properly handle repeated self-appends.
     let mut a: String = "A".to_string();
-    let mut i = 20;
+    let mut i = 20i;
     let mut expected_len = 1u;
     while i > 0 {
         println!("{}", a.len());
index a3ab4637412fc0266b4d5637d89cee9987c6c241..2757439828dd97c3201d2421ea43eda9eb7055f2 100644 (file)
@@ -11,7 +11,7 @@
 extern crate libc;
 
 pub fn main() {
-  let f = 1 as *const libc::FILE;
+  let f = 1u as *const libc::FILE;
   println!("{}", f as int);
   println!("{}", f as uint);
   println!("{}", f as i8);
@@ -34,8 +34,8 @@ pub fn main() {
   println!("{}", 1 as u16);
   println!("{}", 1 as u32);
   println!("{}", 1 as u64);
-  println!("{}", 1 as f32);
-  println!("{}", 1 as f64);
+  println!("{}", 1i as f32);
+  println!("{}", 1i as f64);
 
   println!("{}", 1u as int);
   println!("{}", 1u as uint);
@@ -191,19 +191,6 @@ pub fn main() {
   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);
index 82a76512e08f7d5d1895f57f2067479e664f8ddf..9a77356d7ebf6673341bf7958dd99de70a598804 100644 (file)
@@ -11,7 +11,7 @@
 use std::mem::swap;
 
 pub fn main() {
-    let mut x = 3; let mut y = 7;
+    let mut x = 3i; let mut y = 7i;
     swap(&mut x, &mut y);
     assert!((x == 7)); assert!((y == 3));
 }
index 3d63acd5b83835450d95fe85b27b005974a28726..c04751d51b4fcc8be27d9a722684b532f69a9934 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 enum color {
-    red = 1u,
+    red = 1i,
     blue = 2,
 }
 
index 851f87adfc20dac8a0b72691db20eff460110b99..f72c0ef8d7b3c28cead566c80d3a54ffc26ee368 100644 (file)
@@ -21,7 +21,7 @@ fn test00() {
     });
 
     // Sleep long enough for the task to finish.
-    let mut i = 0;
+    let mut i = 0u;
     while i < 10000 {
         task::deschedule();
         i += 1;
index 391f0e20fccd945ef2b37b09bcea163cbb4130cf..eb0bfc969f396fadec3aeeea7d2b5b71f872e972 100644 (file)
@@ -18,7 +18,7 @@
 
 fn test_break() { loop { let _x: Gc<int> = break; } }
 
-fn test_cont() { let mut i = 0; while i < 1 { i += 1; let _x: Gc<int> = continue; } }
+fn test_cont() { let mut i = 0i; while i < 1 { i += 1; let _x: Gc<int> = continue; } }
 
 fn test_ret() { let _x: Gc<int> = return; }
 
index 13d79959f81f718f8ac598a522eaa88eff662450..8d580729da9804b11f90567cf247d205e5e413c3 100644 (file)
@@ -11,6 +11,6 @@
 fn f(_: int,) {}
 
 pub fn main() {
-    f(0,);
-    let (_, _,) = (1, 1,);
+    f(0i,);
+    let (_, _,) = (1i, 1i,);
 }
index 9e4a7c4be97126b14ffebbd4cef81854f7b402ae..447968eb8c4f8dd15f821f84958d423e4ad63fa9 100644 (file)
@@ -20,8 +20,8 @@
 
 pub fn main () {
 
-    let a = a_struct { x: 0 };
-    let b = a_struct { x: 1 };
+    let a = a_struct { x: 0i };
+    let b = a_struct { x: 1i };
 
     assert_eq!(0i.g(), 10);
     assert_eq!(a.g(), 10);
@@ -30,5 +30,5 @@ pub fn main () {
     assert_eq!(b.h(), 11);
     assert_eq!(A::lurr(&a, &b), 21);
 
-    welp(&0);
+    welp(&0i);
 }
index b87517940c2666fdc6dd3d6a1f37b06457f001a9..fd7e749935b2399a21c646680c4a6fe3b742b29d 100644 (file)
@@ -35,15 +35,15 @@ pub fn main() {
     p_foo(box(GC) r(10));
 
     p_foo(box r(10));
-    p_foo(box(GC) 10);
-    p_foo(box 10);
-    p_foo(10);
+    p_foo(box(GC) 10i);
+    p_foo(box 10i);
+    p_foo(10i);
 
     s_foo(box(GC) r(10));
-    s_foo(box(GC) 10);
-    s_foo(box 10);
-    s_foo(10);
+    s_foo(box(GC) 10i);
+    s_foo(box 10i);
+    s_foo(10i);
 
-    u_foo(box 10);
-    u_foo(10);
+    u_foo(box 10i);
+    u_foo(10i);
 }
index 37d06bf4f830880c8ad9c87b276855f3ab772387..f1e40cc3e587dd780732f07c44468a4941b6429e 100644 (file)
 #![allow(unused_variable)]
 
 fn f() {
-    let x = 10; let mut y = 11;
+    let x = 10i; let mut y = 11i;
     if true { match x { _ => { y = x; } } } else { }
 }
 
 pub fn main() {
-    let x = 10;
-    let mut y = 11;
+    let x = 10i;
+    let mut y = 11i;
     if true { while false { y = x; } } else { }
 }
index 42910c47005811e95ad887cb2f4871534774db12..cbb0dcc8f2b6e20e83928dc6cefe31ea9878ee2e 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 pub fn main() {
-    let (x, y) = (10, 20);
+    let (x, y) = (10i, 20i);
     let z = x + y;
     assert!((z == 30));
 }
index bf74dedebc4fbffc0731c91b1401576b9695c8bc..a189d4528ae34130fd1aae5b17e4481ef0e6c306 100644 (file)
@@ -16,7 +16,7 @@
 
 fn null<T>() -> *const T {
     unsafe {
-        mem::transmute(0)
+        mem::transmute(0u)
     }
 }
 
index 834b549d4f41343763b364ae70848b4bc9210be6..acd405e2659af3bbfbb0ce556f281438480e28d5 100644 (file)
@@ -9,9 +9,9 @@
 // except according to those terms.
 
 pub fn main() {
-    box 100;
+    box 100i;
 }
 
 fn vec() {
-    vec!(0);
+    vec!(0i);
 }
index 01aac804bb64f70470a3abbec37c532c25500e1e..a4b6ff5accff2084720350b179caafb8300bda49 100644 (file)
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 pub fn main() {
-    let _x = box vec!(0,0,0,0,0);
+    let _x = box vec!(0i,0,0,0,0);
 }
index d7105b472ccc561ffb04e47c4d6c7ec3ab657bfb..6e58ec23a3b03729965d941c5e6838e61fd83471 100644 (file)
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 pub fn main() {
-    let _i = box 100;
+    let _i = box 100i;
 }
index 2d74b3163d258e5cc98d4d71a25a705049c402d2..6b6754f34326d67b618bcc65136ba89a8c778cf6 100644 (file)
@@ -23,10 +23,10 @@ fn call_id() {
 
 fn call_id_3() { id(return) && id(return); }
 
-fn ret_ret() -> int { return (return 2) + 3; }
+fn ret_ret() -> int { return (return 2i) + 3i; }
 
 fn ret_guard() {
-    match 2 {
+    match 2i {
       x if (return) => { x; }
       _ => {}
     }
index 83795e64467e41a3715cf7c63fa3b56d41f08a0f..ba48ae1c0cef8798952bb27a154ad9428fa4c65d 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 pub fn main() {
-    let _x = box 1;
+    let _x = box 1i;
     let lam_move: || = || {};
     lam_move();
 }
index bac9ce814bc27503c9066b2b4d9a26f4c92f6f5e..883ec44bf2eb4e5cadc02b779114c48b303b2ab3 100644 (file)
@@ -16,6 +16,6 @@
 
 pub fn main()
 {
-    let y = box 1;
+    let y = box 1i;
     y;
 }
index f06791ff2c7b4b4990189fcd5fb266f02a1e2f5c..a81f88e2af373d8a132cc9900f82c5a1d72f86c3 100644 (file)
@@ -14,7 +14,7 @@
 use std::gc::GC;
 
 fn f() {
-    let _a = box(GC) 0;
+    let _a = box(GC) 0i;
     fail!();
 }
 
index ce2524396184e777cac6a0de9ce86958c2043c77..e5497427755fd23eeeb695949c226df2719889f2 100644 (file)
@@ -11,7 +11,7 @@
 use std::task;
 
 fn f() {
-    let _a = box 0;
+    let _a = box 0i;
     fail!();
 }
 
index 87b18f841ed28f4691d7bbc7904340ba527e0a86..d06e3dc0633fa46edd556185e55bd8b84d3f5b15 100644 (file)
@@ -19,5 +19,5 @@ macro_rules! vec [
 ]
 
 pub fn main() {
-    let my_vec = vec![1, 2, 3, 4, 5];
+    let my_vec = vec![1i, 2, 3, 4, 5];
 }
index ac869a10d2e7bb6a4252d548c4639e10127dfcc1..8ba8ba4482edc7e6089a23eb5e01ef5fad91a6a5 100644 (file)
@@ -69,7 +69,7 @@ fn d() {
 }
 
 fn e() {
-    match &[1, 2, 3] {
+    match &[1i, 2, 3] {
         [1, 2] => (),
         [..] => ()
     }
index 33f01c5bd41c8b3bf37bd3645c3b5bcfa78c97b5..fe0f92a0c111996f07280f11b951ca462bd3bdfc 100644 (file)
@@ -8,4 +8,4 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-pub fn main() { let mut v = vec!(1, 2, 3); v.push(1); }
+pub fn main() { let mut v = vec!(1i, 2, 3); v.push(1); }
index f5d09e308ba88783c9b47aa6b317b2970ceeb07a..18ccd8c96ab6c95316474933dfeba64fd2362838 100644 (file)
@@ -8,4 +8,4 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-pub fn main() { let _a = [0, ..1 as uint]; }
+pub fn main() { let _a = [0i, ..1 as uint]; }
index 61578578ab6da603fefda8724153e3044ad605d7..bae1a7c45e42374fd08eec83592da57cb7b0b67d 100644 (file)
@@ -38,7 +38,7 @@ fn zombiejesus() {
         while (return) {
             if (return) {
                 match (return) {
-                    1 => {
+                    1i => {
                         if (return) {
                             return
                         } else {
@@ -56,7 +56,7 @@ fn zombiejesus() {
 }
 
 fn notsure() {
-    let mut _x;
+    let mut _x: int;
     let mut _y = (_x = 0) == (_x = 0);
     let mut _z = (_x = 0) < (_x = 0);
     let _a = (_x += 0) == (_x = 0);
@@ -72,8 +72,8 @@ fn p() -> bool { true }
 
 fn angrydome() {
     loop { if break { } }
-    let mut i = 0;
-    loop { i += 1; if i == 1 { match (continue) { 1 => { }, _ => fail!("wat") } }
+    let mut i = 0i;
+    loop { i += 1; if i == 1 { match (continue) { 1i => { }, _ => fail!("wat") } }
       break; }
 }
 
index 36d902dc2e0209e6e7412274e22de3ab44d915e0..01c5986b130d7c0eee6ba72720cafe33a9f2aaab 100644 (file)
@@ -10,4 +10,4 @@
 
 
 
-pub fn main() { let x: int = 10; while x == 10 && x == 11 { let _y = 0xf00; } }
+pub fn main() { let x: int = 10; while x == 10 && x == 11 { let _y = 0xf00u; } }