about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--mk/cfg/x86_64-unknown-linux-gnu.mk1
-rw-r--r--mk/dist.mk1
-rw-r--r--mk/prepare.mk2
-rw-r--r--mk/target.mk1
-rw-r--r--mk/tests.mk5
-rw-r--r--mk/util.mk1
-rw-r--r--src/compiletest/compiletest.rs1
-rw-r--r--src/doc/grammar.md98
-rw-r--r--src/doc/intro.md2
-rw-r--r--src/doc/not_found.md1
-rw-r--r--src/doc/reference.md8
-rw-r--r--src/doc/trpl/arrays-vectors-and-slices.md2
-rw-r--r--src/doc/trpl/crates-and-modules.md4
-rw-r--r--src/doc/trpl/documentation.md11
-rw-r--r--src/doc/trpl/ffi.md1
-rw-r--r--src/doc/trpl/method-syntax.md6
-rw-r--r--src/doc/trpl/static-and-dynamic-dispatch.md2
-rw-r--r--src/doc/trpl/testing.md4
-rw-r--r--src/etc/featureck.py1
-rwxr-xr-xsrc/etc/gdb_rust_pretty_printing.py2
-rw-r--r--src/etc/mingw-fix-include/README.txt2
-rw-r--r--src/etc/third-party/COPYING.RUNTIME1
-rwxr-xr-xsrc/grammar/check.sh1
-rw-r--r--src/liballoc/arc.rs2
-rw-r--r--src/liballoc/boxed.rs2
-rw-r--r--src/liballoc/heap.rs2
-rw-r--r--src/liballoc/rc.rs3
-rw-r--r--src/libarena/lib.rs1
-rw-r--r--src/libbacktrace/Makefile.am4
-rw-r--r--src/libbacktrace/Makefile.in18
-rw-r--r--src/libbacktrace/alloc.c6
-rw-r--r--src/libbacktrace/atomic.c6
-rw-r--r--src/libbacktrace/backtrace-supported.h.in6
-rw-r--r--src/libbacktrace/backtrace.c6
-rw-r--r--src/libbacktrace/backtrace.h6
-rw-r--r--src/libbacktrace/btest.c8
-rwxr-xr-xsrc/libbacktrace/configure1
-rw-r--r--src/libbacktrace/configure.ac6
-rw-r--r--src/libbacktrace/dwarf.c12
-rw-r--r--src/libbacktrace/elf.c6
-rw-r--r--src/libbacktrace/fileline.c6
-rw-r--r--src/libbacktrace/hashtab.h4
-rw-r--r--src/libbacktrace/internal.h6
-rw-r--r--src/libbacktrace/ltmain.sh1
-rw-r--r--src/libbacktrace/mmap.c6
-rw-r--r--src/libbacktrace/mmapio.c6
-rw-r--r--src/libbacktrace/nounwind.c6
-rw-r--r--src/libbacktrace/posix.c6
-rw-r--r--src/libbacktrace/print.c6
-rw-r--r--src/libbacktrace/read.c6
-rw-r--r--src/libbacktrace/simple.c6
-rw-r--r--src/libbacktrace/state.c6
-rw-r--r--src/libbacktrace/unknown.c6
-rw-r--r--src/libcollections/binary_heap.rs220
-rw-r--r--src/libcollections/bit.rs1182
-rw-r--r--src/libcollections/borrow.rs2
-rw-r--r--src/libcollections/btree/map.rs310
-rw-r--r--src/libcollections/btree/node.rs7
-rw-r--r--src/libcollections/btree/set.rs181
-rw-r--r--src/libcollections/enum_set.rs243
-rw-r--r--src/libcollections/fmt.rs14
-rw-r--r--src/libcollections/lib.rs40
-rw-r--r--src/libcollections/linked_list.rs398
-rw-r--r--src/libcollections/macros.rs55
-rw-r--r--src/libcollections/slice.rs2607
-rw-r--r--src/libcollections/str.rs2606
-rw-r--r--src/libcollections/string.rs483
-rw-r--r--src/libcollections/vec.rs1008
-rw-r--r--src/libcollections/vec_deque.rs900
-rw-r--r--src/libcollections/vec_map.rs507
-rw-r--r--src/libcollectionstest/bench.rs (renamed from src/libcollections/bench.rs)4
-rw-r--r--src/libcollectionstest/binary_heap.rs219
-rw-r--r--src/libcollectionstest/bit/mod.rs12
-rw-r--r--src/libcollectionstest/bit/set.rs441
-rw-r--r--src/libcollectionstest/bit/vec.rs729
-rw-r--r--src/libcollectionstest/btree/map.rs299
-rw-r--r--src/libcollectionstest/btree/mod.rs12
-rw-r--r--src/libcollectionstest/btree/set.rs180
-rw-r--r--src/libcollectionstest/enum_set.rs244
-rw-r--r--src/libcollectionstest/fmt.rs17
-rw-r--r--src/libcollectionstest/lib.rs43
-rw-r--r--src/libcollectionstest/linked_list.rs397
-rw-r--r--src/libcollectionstest/slice.rs1571
-rw-r--r--src/libcollectionstest/str.rs1668
-rw-r--r--src/libcollectionstest/string.rs453
-rw-r--r--src/libcollectionstest/vec.rs994
-rw-r--r--src/libcollectionstest/vec_deque.rs888
-rw-r--r--src/libcollectionstest/vec_map.rs510
-rw-r--r--src/libcore/default.rs1
-rw-r--r--src/libcore/finally.rs1
-rw-r--r--src/libcore/macros.rs4
-rw-r--r--src/libcore/marker.rs4
-rw-r--r--src/libcore/mem.rs2
-rw-r--r--src/libcore/num/f32.rs2
-rw-r--r--src/libcore/num/f64.rs2
-rw-r--r--src/libcore/num/float_macros.rs1
-rw-r--r--src/libcore/num/mod.rs1022
-rw-r--r--src/libcore/ops.rs8
-rw-r--r--src/libcore/option.rs2
-rw-r--r--src/libcore/prelude.rs1
-rw-r--r--src/libcore/ptr.rs118
-rw-r--r--src/libcore/result.rs2
-rw-r--r--src/libcore/slice.rs5
-rw-r--r--src/libcore/str/mod.rs7
-rw-r--r--src/libcoretest/intrinsics.rs1
-rw-r--r--src/libflate/lib.rs68
-rw-r--r--src/liblibc/lib.rs4
-rw-r--r--src/liblog/lib.rs1
-rw-r--r--src/liblog/macros.rs1
-rw-r--r--src/librand/distributions/exponential.rs2
-rw-r--r--src/librand/distributions/gamma.rs8
-rw-r--r--src/librand/distributions/mod.rs4
-rw-r--r--src/librand/distributions/normal.rs4
-rw-r--r--src/librand/distributions/range.rs2
-rw-r--r--src/librand/lib.rs21
-rw-r--r--src/librand/reseeding.rs2
-rw-r--r--src/librustc/README.txt2
-rw-r--r--src/librustc/diagnostics.rs1
-rw-r--r--src/librustc/metadata/loader.rs4
-rw-r--r--src/librustc/metadata/tydecode.rs1
-rw-r--r--src/librustc/middle/cfg/graphviz.rs1
-rw-r--r--src/librustc/middle/check_match.rs1
-rw-r--r--src/librustc/middle/fast_reject.rs1
-rw-r--r--src/librustc/middle/infer/resolve.rs1
-rw-r--r--src/librustc/middle/infer/sub.rs1
-rw-r--r--src/librustc/middle/lang_items.rs18
-rw-r--r--src/librustc/middle/mem_categorization.rs1
-rw-r--r--src/librustc/middle/traits/project.rs2
-rw-r--r--src/librustc/middle/traits/util.rs2
-rw-r--r--src/librustc/middle/ty.rs23
-rw-r--r--src/librustc/middle/ty_walk.rs2
-rw-r--r--src/librustc_back/archive.rs1
-rw-r--r--src/librustc_back/target/dragonfly_base.rs1
-rw-r--r--src/librustc_back/target/freebsd_base.rs1
-rw-r--r--src/librustc_back/target/openbsd_base.rs1
-rw-r--r--src/librustc_resolve/build_reduced_graph.rs41
-rw-r--r--src/librustc_resolve/diagnostics.rs4
-rw-r--r--src/librustc_resolve/lib.rs1141
-rw-r--r--src/librustc_resolve/record_exports.rs13
-rw-r--r--src/librustc_resolve/resolve_imports.rs1021
-rw-r--r--src/librustc_trans/back/link.rs7
-rw-r--r--src/librustc_trans/back/lto.rs8
-rw-r--r--src/librustc_trans/trans/base.rs5
-rw-r--r--src/librustc_trans/trans/callee.rs2
-rw-r--r--src/librustc_trans/trans/closure.rs1
-rw-r--r--src/librustc_trans/trans/llrepr.rs2
-rw-r--r--src/librustc_typeck/check/closure.rs2
-rw-r--r--src/librustc_typeck/check/method/probe.rs76
-rw-r--r--src/librustc_typeck/check/upvar.rs2
-rw-r--r--src/librustc_typeck/check/vtable.rs1
-rw-r--r--src/librustc_typeck/coherence/orphan.rs137
-rw-r--r--src/librustc_typeck/diagnostics.rs1
-rw-r--r--src/librustc_typeck/variance.rs1
-rw-r--r--src/librustdoc/html/item_type.rs1
-rw-r--r--src/librustdoc/html/static/Heuristica-LICENSE.txt4
-rw-r--r--src/librustdoc/html/static/SourceCodePro-LICENSE.txt2
-rw-r--r--src/librustdoc/html/static/SourceSerifPro-LICENSE.txt2
-rw-r--r--src/librustdoc/html/static/playpen.js1
-rw-r--r--src/libserialize/hex.rs4
-rw-r--r--src/libserialize/json.rs2
-rw-r--r--src/libstd/bool.rs1
-rw-r--r--src/libstd/collections/hash/map.rs6
-rw-r--r--src/libstd/collections/hash/set.rs6
-rw-r--r--src/libstd/collections/hash/table.rs4
-rw-r--r--src/libstd/dynamic_lib.rs2
-rw-r--r--src/libstd/env.rs26
-rw-r--r--src/libstd/ffi/c_str.rs4
-rw-r--r--src/libstd/fs/mod.rs8
-rw-r--r--src/libstd/io/buffered.rs29
-rw-r--r--src/libstd/io/mod.rs9
-rw-r--r--src/libstd/macros.rs10
-rw-r--r--src/libstd/net/addr.rs395
-rw-r--r--src/libstd/net/ip.rs65
-rw-r--r--src/libstd/net/mod.rs17
-rw-r--r--src/libstd/net/parser.rs26
-rw-r--r--src/libstd/net/tcp.rs39
-rw-r--r--src/libstd/net/test.rs11
-rw-r--r--src/libstd/net/udp.rs30
-rw-r--r--src/libstd/num/f32.rs1230
-rw-r--r--src/libstd/num/f64.rs1229
-rw-r--r--src/libstd/num/float_macros.rs10
-rw-r--r--src/libstd/num/mod.rs3
-rw-r--r--src/libstd/num/strconv.rs5
-rw-r--r--src/libstd/old_io/buffered.rs7
-rw-r--r--src/libstd/old_io/comm_adapters.rs3
-rw-r--r--src/libstd/old_io/extensions.rs3
-rw-r--r--src/libstd/old_io/fs.rs21
-rw-r--r--src/libstd/old_io/mem.rs13
-rw-r--r--src/libstd/old_io/mod.rs8
-rw-r--r--src/libstd/old_io/net/ip.rs4
-rw-r--r--src/libstd/old_io/net/pipe.rs2
-rw-r--r--src/libstd/old_io/process.rs2
-rw-r--r--src/libstd/old_io/stdio.rs4
-rw-r--r--src/libstd/old_io/tempfile.rs1
-rw-r--r--src/libstd/old_io/timer.rs8
-rw-r--r--src/libstd/old_path/mod.rs2
-rw-r--r--src/libstd/old_path/posix.rs10
-rw-r--r--src/libstd/old_path/windows.rs9
-rw-r--r--src/libstd/os.rs37
-rw-r--r--src/libstd/path.rs9
-rw-r--r--src/libstd/prelude/v1.rs10
-rw-r--r--src/libstd/process.rs2
-rw-r--r--src/libstd/rand/mod.rs2
-rw-r--r--src/libstd/rand/os.rs3
-rw-r--r--src/libstd/rand/reader.rs3
-rw-r--r--src/libstd/rt/at_exit_imp.rs1
-rw-r--r--src/libstd/sync/barrier.rs2
-rw-r--r--src/libstd/sync/mutex.rs6
-rw-r--r--src/libstd/sync/once.rs2
-rw-r--r--src/libstd/sync/task_pool.rs2
-rw-r--r--src/libstd/sys/common/net2.rs32
-rw-r--r--src/libstd/sys/common/wtf8.rs12
-rw-r--r--src/libstd/sys/unix/net.rs8
-rw-r--r--src/libstd/sys/unix/os_str.rs1
-rw-r--r--src/libstd/sys/windows/net.rs8
-rw-r--r--src/libstd/sys/windows/process2.rs1
-rw-r--r--src/libstd/thread.rs12
-rw-r--r--src/libsyntax/ext/quote.rs12
-rw-r--r--src/libsyntax/ext/source_util.rs2
-rw-r--r--src/libsyntax/ext/tt/macro_parser.rs7
-rw-r--r--src/libsyntax/ext/tt/macro_rules.rs19
-rw-r--r--src/libsyntax/lib.rs1
-rw-r--r--src/libsyntax/parse/attr.rs58
-rw-r--r--src/libsyntax/parse/mod.rs14
-rw-r--r--src/libsyntax/parse/parser.rs712
-rw-r--r--src/libsyntax/test.rs18
-rw-r--r--src/libsyntax/util/parser_testing.rs4
-rw-r--r--src/libterm/lib.rs1
-rw-r--r--src/libtest/lib.rs1
-rw-r--r--src/libunicode/char.rs372
-rw-r--r--src/libunicode/lib.rs1
-rw-r--r--src/libunicode/u_str.rs3
-rw-r--r--src/rt/msvc/typeof.h1
-rw-r--r--src/rt/valgrind/memcheck.h2
-rw-r--r--src/test/auxiliary/changing-crates-a2.rs1
-rw-r--r--src/test/auxiliary/coherence-orphan-lib.rs1
-rw-r--r--src/test/auxiliary/default_type_params_xc.rs1
-rw-r--r--src/test/auxiliary/iss.rs1
-rw-r--r--src/test/auxiliary/issue-12133-dylib2.rs1
-rw-r--r--src/test/auxiliary/issue-13560-3.rs1
-rw-r--r--src/test/auxiliary/issue-16725.rs1
-rw-r--r--src/test/auxiliary/issue-5521.rs1
-rw-r--r--src/test/auxiliary/issue13213aux.rs1
-rw-r--r--src/test/auxiliary/issue_3907.rs1
-rw-r--r--src/test/auxiliary/issue_5844_aux.rs1
-rw-r--r--src/test/auxiliary/issue_8401.rs1
-rw-r--r--src/test/auxiliary/issue_9123.rs1
-rw-r--r--src/test/auxiliary/issue_9188.rs1
-rw-r--r--src/test/auxiliary/kinds_in_metadata.rs1
-rw-r--r--src/test/auxiliary/lang-item-public.rs2
-rw-r--r--src/test/auxiliary/namespaced_enums.rs1
-rw-r--r--src/test/auxiliary/plugin_crate_outlive_expansion_phase.rs1
-rw-r--r--src/test/auxiliary/privacy_reexport.rs2
-rw-r--r--src/test/auxiliary/pub_static_array.rs11
-rw-r--r--src/test/auxiliary/struct_variant_privacy.rs1
-rw-r--r--src/test/auxiliary/trait_bounds_on_structs_and_enums_xc.rs1
-rw-r--r--src/test/auxiliary/weak-lang-items.rs1
-rw-r--r--src/test/auxiliary/where_clauses_xc.rs1
-rw-r--r--src/test/auxiliary/xcrate_struct_aliases.rs1
-rw-r--r--src/test/auxiliary/xcrate_unit_struct.rs1
-rw-r--r--src/test/compile-fail/associated-types-coherence-failure.rs1
-rw-r--r--src/test/compile-fail/associated-types-eq-expr-path.rs2
-rw-r--r--src/test/compile-fail/associated-types-issue-17359.rs1
-rw-r--r--src/test/compile-fail/bad-crate-id2.rs1
-rw-r--r--src/test/compile-fail/borrowck-box-insensitivity.rs1
-rw-r--r--src/test/compile-fail/borrowck-closures-unique-imm.rs1
-rw-r--r--src/test/compile-fail/borrowck-field-sensitivity.rs1
-rw-r--r--src/test/compile-fail/borrowck-for-loop-correct-cmt-for-pattern.rs1
-rw-r--r--src/test/compile-fail/borrowck-for-loop-head-linkage.rs1
-rw-r--r--src/test/compile-fail/borrowck-issue-14498.rs1
-rw-r--r--src/test/compile-fail/borrowck-let-suggestion.rs1
-rw-r--r--src/test/compile-fail/borrowck-multiple-captures.rs1
-rw-r--r--src/test/compile-fail/borrowck-mutate-in-guard.rs1
-rw-r--r--src/test/compile-fail/borrowck-object-lifetime.rs1
-rw-r--r--src/test/compile-fail/borrowck-object-mutability.rs1
-rw-r--r--src/test/compile-fail/borrowck-overloaded-call.rs1
-rw-r--r--src/test/compile-fail/borrowck-overloaded-index-and-overloaded-deref.rs1
-rw-r--r--src/test/compile-fail/borrowck-partial-reinit-2.rs1
-rw-r--r--src/test/compile-fail/borrowck-unboxed-closures.rs1
-rw-r--r--src/test/compile-fail/borrowck-use-mut-borrow.rs1
-rw-r--r--src/test/compile-fail/closure-reform-bad.rs1
-rw-r--r--src/test/compile-fail/cross-borrow-trait.rs1
-rw-r--r--src/test/compile-fail/drop-with-active-borrows-1.rs1
-rw-r--r--src/test/compile-fail/duplicate-parameter.rs1
-rw-r--r--src/test/compile-fail/duplicate-type-parameter.rs1
-rw-r--r--src/test/compile-fail/explicit-self-lifetime-mismatch.rs1
-rw-r--r--src/test/compile-fail/extern-with-type-bounds.rs1
-rw-r--r--src/test/compile-fail/feature-gate-advanced-slice-features.rs1
-rw-r--r--src/test/compile-fail/feature-gate-box-expr.rs1
-rw-r--r--src/test/compile-fail/feature-gate-start.rs1
-rw-r--r--src/test/compile-fail/generic-no-mangle.rs1
-rw-r--r--src/test/compile-fail/indexing-requires-a-uint.rs1
-rw-r--r--src/test/compile-fail/infinite-macro-expansion.rs1
-rw-r--r--src/test/compile-fail/integral-indexing.rs8
-rw-r--r--src/test/compile-fail/intrinsic-return-address.rs2
-rw-r--r--src/test/compile-fail/issue-10536.rs1
-rw-r--r--src/test/compile-fail/issue-11192.rs1
-rw-r--r--src/test/compile-fail/issue-11593.rs1
-rw-r--r--src/test/compile-fail/issue-11844.rs1
-rw-r--r--src/test/compile-fail/issue-12041.rs1
-rw-r--r--src/test/compile-fail/issue-12612.rs1
-rw-r--r--src/test/compile-fail/issue-13407.rs19
-rw-r--r--src/test/compile-fail/issue-13446.rs1
-rw-r--r--src/test/compile-fail/issue-14092.rs1
-rw-r--r--src/test/compile-fail/issue-16149.rs1
-rw-r--r--src/test/compile-fail/issue-16338.rs1
-rw-r--r--src/test/compile-fail/issue-16725.rs1
-rw-r--r--src/test/compile-fail/issue-16922.rs20
-rw-r--r--src/test/compile-fail/issue-17718-const-bad-values.rs1
-rw-r--r--src/test/compile-fail/issue-18919.rs17
-rw-r--r--src/test/compile-fail/issue-19982.rs17
-rw-r--r--src/test/compile-fail/issue-20225.rs22
-rw-r--r--src/test/compile-fail/issue-20261.rs17
-rw-r--r--src/test/compile-fail/issue-20714.rs15
-rw-r--r--src/test/compile-fail/issue-3008-2.rs1
-rw-r--r--src/test/compile-fail/issue-3907.rs1
-rw-r--r--src/test/compile-fail/issue-5844.rs1
-rw-r--r--src/test/compile-fail/issue-7607-1.rs1
-rw-r--r--src/test/compile-fail/issue-8767.rs1
-rw-r--r--src/test/compile-fail/kindck-copy.rs1
-rw-r--r--src/test/compile-fail/kindck-nonsendable-1.rs1
-rw-r--r--src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs1
-rw-r--r--src/test/compile-fail/linkage3.rs1
-rw-r--r--src/test/compile-fail/lint-dead-code-3.rs2
-rw-r--r--src/test/compile-fail/lint-exceeding-bitshifts.rs1
-rw-r--r--src/test/compile-fail/lint-stability3.rs1
-rw-r--r--src/test/compile-fail/lint-uppercase-variables.rs1
-rw-r--r--src/test/compile-fail/macro-inner-attributes.rs1
-rw-r--r--src/test/compile-fail/macro-outer-attributes.rs1
-rw-r--r--src/test/compile-fail/manual-link-bad-form.rs2
-rw-r--r--src/test/compile-fail/manual-link-bad-kind.rs1
-rw-r--r--src/test/compile-fail/method-ambig-two-traits-cross-crate.rs1
-rw-r--r--src/test/compile-fail/method-missing-call.rs1
-rw-r--r--src/test/compile-fail/method-suggestion-no-duplication.rs2
-rw-r--r--src/test/compile-fail/mut-cross-borrowing.rs1
-rw-r--r--src/test/compile-fail/object-safety-by-value-self-use.rs1
-rw-r--r--src/test/compile-fail/opt-in-copy.rs1
-rw-r--r--src/test/compile-fail/overloaded-calls-nontuple.rs1
-rw-r--r--src/test/compile-fail/pattern-bindings-after-at.rs1
-rw-r--r--src/test/compile-fail/pattern-ident-path-generics.rs1
-rw-r--r--src/test/compile-fail/privacy1.rs16
-rw-r--r--src/test/compile-fail/region-bound-on-closure-outlives-call.rs1
-rw-r--r--src/test/compile-fail/region-object-lifetime-1.rs1
-rw-r--r--src/test/compile-fail/region-object-lifetime-2.rs1
-rw-r--r--src/test/compile-fail/region-object-lifetime-3.rs1
-rw-r--r--src/test/compile-fail/region-object-lifetime-4.rs1
-rw-r--r--src/test/compile-fail/region-object-lifetime-5.rs1
-rw-r--r--src/test/compile-fail/regionck-unboxed-closure-lifetimes.rs1
-rw-r--r--src/test/compile-fail/regions-close-associated-type-into-object.rs1
-rw-r--r--src/test/compile-fail/regions-close-object-into-object-1.rs1
-rw-r--r--src/test/compile-fail/regions-close-object-into-object-3.rs1
-rw-r--r--src/test/compile-fail/regions-close-object-into-object-4.rs1
-rw-r--r--src/test/compile-fail/regions-close-object-into-object-5.rs1
-rw-r--r--src/test/compile-fail/regions-close-param-into-object.rs1
-rw-r--r--src/test/compile-fail/resolve-conflict-extern-crate-vs-extern-crate.rs1
-rw-r--r--src/test/compile-fail/resolve-conflict-import-vs-extern-crate.rs1
-rw-r--r--src/test/compile-fail/resolve-conflict-import-vs-import.rs1
-rw-r--r--src/test/compile-fail/resolve-conflict-item-vs-extern-crate.rs1
-rw-r--r--src/test/compile-fail/resolve-conflict-item-vs-import.rs1
-rw-r--r--src/test/compile-fail/resolve-unknown-trait.rs1
-rw-r--r--src/test/compile-fail/shadowing-in-the-same-pattern.rs1
-rw-r--r--src/test/compile-fail/single-primitive-inherent-impl.rs24
-rw-r--r--src/test/compile-fail/static-array-across-crate.rs20
-rw-r--r--src/test/compile-fail/struct-variant-privacy-xc.rs1
-rw-r--r--src/test/compile-fail/structure-constructor-type-mismatch.rs1
-rw-r--r--src/test/compile-fail/trait-as-struct-constructor.rs1
-rw-r--r--src/test/compile-fail/trait-bounds-impl-comparison-2.rs1
-rw-r--r--src/test/compile-fail/trait-bounds-not-on-bare-trait.rs2
-rw-r--r--src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs1
-rw-r--r--src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs1
-rw-r--r--src/test/compile-fail/trait-bounds-on-structs-and-enums-xc.rs1
-rw-r--r--src/test/compile-fail/trait-bounds-on-structs-and-enums-xc1.rs1
-rw-r--r--src/test/compile-fail/trait-bounds-on-structs-and-enums.rs1
-rw-r--r--src/test/compile-fail/trait-coercion-generic-regions.rs1
-rw-r--r--src/test/compile-fail/transmute-different-sizes.rs2
-rw-r--r--src/test/compile-fail/type-params-in-different-spaces-2.rs1
-rw-r--r--src/test/compile-fail/type-params-in-different-spaces-3.rs1
-rw-r--r--src/test/compile-fail/ufcs-explicit-self-bad.rs1
-rw-r--r--src/test/compile-fail/ufcs-qpath-self-mismatch.rs1
-rw-r--r--src/test/compile-fail/unboxed-closure-sugar-nonexistent-trait.rs1
-rw-r--r--src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs1
-rw-r--r--src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs1
-rw-r--r--src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs1
-rw-r--r--src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs1
-rw-r--r--src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs1
-rw-r--r--src/test/compile-fail/unboxed-closures-infer-explicit-call-too-early.rs1
-rw-r--r--src/test/compile-fail/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs1
-rw-r--r--src/test/compile-fail/unboxed-closures-static-call-wrong-trait.rs1
-rw-r--r--src/test/compile-fail/unboxed-closures-vtable-mismatch.rs1
-rw-r--r--src/test/compile-fail/unboxed-closures-wrong-abi.rs1
-rw-r--r--src/test/compile-fail/variance-issue-20533.rs1
-rw-r--r--src/test/compile-fail/variance-trait-matching.rs1
-rw-r--r--src/test/compile-fail/vector-cast-weirdness.rs1
-rw-r--r--src/test/compile-fail/walk-struct-literal-with.rs1
-rw-r--r--src/test/compile-fail/where-clauses-unsatisfied.rs1
-rw-r--r--src/test/debuginfo/function-arg-initialization.rs3
-rw-r--r--src/test/debuginfo/generic-method-on-generic-struct.rs1
-rw-r--r--src/test/debuginfo/lexical-scope-in-parameterless-closure.rs1
-rw-r--r--src/test/debuginfo/limited-debuginfo.rs1
-rw-r--r--src/test/debuginfo/method-on-enum.rs1
-rw-r--r--src/test/debuginfo/method-on-generic-struct.rs1
-rw-r--r--src/test/debuginfo/method-on-struct.rs1
-rw-r--r--src/test/debuginfo/method-on-trait.rs1
-rw-r--r--src/test/debuginfo/method-on-tuple-struct.rs1
-rw-r--r--src/test/debuginfo/no-debug-attribute.rs1
-rw-r--r--src/test/debuginfo/recursive-struct.rs1
-rw-r--r--src/test/debuginfo/self-in-default-method.rs1
-rw-r--r--src/test/debuginfo/self-in-generic-default-method.rs1
-rw-r--r--src/test/parse-fail/ascii-only-character-escape.rs1
-rw-r--r--src/test/parse-fail/byte-literals.rs2
-rw-r--r--src/test/parse-fail/byte-string-literals.rs2
-rw-r--r--src/test/parse-fail/column-offset-1-based.rs2
-rw-r--r--src/test/parse-fail/issue-10392-2.rs1
-rw-r--r--src/test/parse-fail/issue-1655.rs2
-rw-r--r--src/test/parse-fail/issue-17718-const-mut.rs1
-rw-r--r--src/test/parse-fail/issue-20711-2.rs1
-rw-r--r--src/test/parse-fail/issue-2354-1.rs1
-rw-r--r--src/test/parse-fail/keywords-followed-by-double-colon.rs1
-rw-r--r--src/test/parse-fail/macro-attribute.rs1
-rw-r--r--src/test/parse-fail/macros-no-semicolon.rs1
-rw-r--r--src/test/parse-fail/obsolete-proc.rs2
-rw-r--r--src/test/parse-fail/raw-byte-string-eof.rs2
-rw-r--r--src/test/parse-fail/raw-byte-string-literals.rs2
-rw-r--r--src/test/parse-fail/struct-literal-in-for.rs1
-rw-r--r--src/test/parse-fail/struct-literal-in-if.rs1
-rw-r--r--src/test/parse-fail/struct-literal-in-match-discriminant.rs1
-rw-r--r--src/test/parse-fail/struct-literal-in-while.rs1
-rw-r--r--src/test/parse-fail/type-parameters-in-field-exprs.rs1
-rw-r--r--src/test/parse-fail/unboxed-closure-sugar-used-on-struct-3.rs1
-rw-r--r--src/test/parse-fail/use-mod-4.rs1
-rw-r--r--src/test/parse-fail/where-clauses-no-bounds-or-predicates.rs1
-rw-r--r--src/test/pretty/asm-clobbers.rs1
-rw-r--r--src/test/pretty/closure-reform-pretty.rs1
-rw-r--r--src/test/pretty/path-type-bounds.rs1
-rw-r--r--src/test/pretty/where-clauses.rs1
-rw-r--r--src/test/run-make/allow-non-lint-warnings-cmdline/Makefile1
-rw-r--r--src/test/run-make/allow-warnings-cmdline-stability/Makefile4
-rw-r--r--src/test/run-make/compiler-lookup-paths/c.rs1
-rw-r--r--src/test/run-make/crate-name-priority/foo1.rs1
-rw-r--r--src/test/run-make/extern-flag-disambiguates/Makefile1
-rw-r--r--src/test/run-make/extern-flag-fun/bar.rs1
-rw-r--r--src/test/run-make/extern-overrides-distribution/main.rs1
-rw-r--r--src/test/run-make/interdependent-c-libraries/Makefile1
-rw-r--r--src/test/run-make/interdependent-c-libraries/bar.rs1
-rw-r--r--src/test/run-make/issue-14500/Makefile1
-rw-r--r--src/test/run-make/libs-and-bins/Makefile1
-rw-r--r--src/test/run-make/link-path-order/Makefile1
-rw-r--r--src/test/run-make/linkage-attr-on-static/Makefile1
-rw-r--r--src/test/run-make/manual-link/Makefile1
-rw-r--r--src/test/run-make/many-crates-but-no-match/Makefile2
-rw-r--r--src/test/run-make/missing-crate-dependency/Makefile2
-rw-r--r--src/test/run-make/mixing-formats/baz2.rs1
-rw-r--r--src/test/run-make/obey-crate-type-flag/test.rs1
-rw-r--r--src/test/run-make/rustdoc-default-impl/bar.rs1
-rw-r--r--src/test/run-make/rustdoc-extern-method/Makefile1
-rw-r--r--src/test/run-make/rustdoc-negative-impl/Makefile1
-rw-r--r--src/test/run-make/rustdoc-recursion/Makefile1
-rw-r--r--src/test/run-make/rustdoc-recursion/foo.rs1
-rw-r--r--src/test/run-make/rustdoc-viewpath-self/Makefile1
-rw-r--r--src/test/run-make/rustdoc-where/Makefile1
-rw-r--r--src/test/run-make/tools.mk1
-rw-r--r--src/test/run-pass-fulldeps/compiler-calls.rs1
-rw-r--r--src/test/run-pass-fulldeps/quote-tokens.rs2
-rw-r--r--src/test/run-pass-valgrind/cleanup-auto-borrow-obj.rs1
-rw-r--r--src/test/run-pass/as-precedence.rs1
-rw-r--r--src/test/run-pass/backtrace-debuginfo-aux.rs1
-rw-r--r--src/test/run-pass/backtrace-debuginfo.rs1
-rw-r--r--src/test/run-pass/bare-fn-implements-fn-mut.rs1
-rw-r--r--src/test/run-pass/bitv-perf-test.rs1
-rw-r--r--src/test/run-pass/borrowck-field-sensitivity.rs1
-rw-r--r--src/test/run-pass/borrowck-move-by-capture-ok.rs1
-rw-r--r--src/test/run-pass/borrowck-use-mut-borrow.rs1
-rw-r--r--src/test/run-pass/can-copy-pod.rs2
-rw-r--r--src/test/run-pass/capture-clauses-boxed-closures.rs1
-rw-r--r--src/test/run-pass/class-exports.rs1
-rw-r--r--src/test/run-pass/cleanup-arm-conditional.rs1
-rw-r--r--src/test/run-pass/cleanup-shortcircuit.rs1
-rw-r--r--src/test/run-pass/closure-reform.rs1
-rw-r--r--src/test/run-pass/conditional-compile.rs1
-rw-r--r--src/test/run-pass/deriving-meta-multiple.rs1
-rw-r--r--src/test/run-pass/deriving-meta.rs1
-rw-r--r--src/test/run-pass/deriving-via-extension-hash-enum.rs1
-rw-r--r--src/test/run-pass/deriving-via-extension-hash-struct.rs1
-rw-r--r--src/test/run-pass/deriving-via-extension-type-params.rs1
-rw-r--r--src/test/run-pass/drop-with-type-ascription-1.rs1
-rw-r--r--src/test/run-pass/drop-with-type-ascription-2.rs1
-rw-r--r--src/test/run-pass/duplicated-external-mods.rs1
-rw-r--r--src/test/run-pass/export-multi.rs1
-rw-r--r--src/test/run-pass/export-non-interference3.rs1
-rw-r--r--src/test/run-pass/extern-compare-with-return-type.rs1
-rw-r--r--src/test/run-pass/extern-mod-syntax.rs1
-rw-r--r--src/test/run-pass/for-loop-goofiness.rs1
-rw-r--r--src/test/run-pass/format-nan.rs1
-rw-r--r--src/test/run-pass/import-from.rs1
-rw-r--r--src/test/run-pass/import-trailing-comma.rs1
-rw-r--r--src/test/run-pass/import2.rs1
-rw-r--r--src/test/run-pass/import3.rs1
-rw-r--r--src/test/run-pass/import4.rs1
-rw-r--r--src/test/run-pass/import5.rs1
-rw-r--r--src/test/run-pass/import6.rs1
-rw-r--r--src/test/run-pass/import7.rs1
-rw-r--r--src/test/run-pass/import8.rs1
-rw-r--r--src/test/run-pass/inherent-trait-method-order.rs1
-rw-r--r--src/test/run-pass/integer-literal-suffix-inference-2.rs1
-rw-r--r--src/test/run-pass/integer-literal-suffix-inference-3.rs1
-rw-r--r--src/test/run-pass/intrinsic-assume.rs1
-rw-r--r--src/test/run-pass/intrinsic-return-address.rs1
-rw-r--r--src/test/run-pass/intrinsics-math.rs1
-rw-r--r--src/test/run-pass/issue-11736.rs1
-rw-r--r--src/test/run-pass/issue-11820.rs19
-rw-r--r--src/test/run-pass/issue-12729.rs1
-rw-r--r--src/test/run-pass/issue-14421.rs1
-rw-r--r--src/test/run-pass/issue-15155.rs2
-rw-r--r--src/test/run-pass/issue-15221.rs1
-rw-r--r--src/test/run-pass/issue-16151.rs1
-rw-r--r--src/test/run-pass/issue-16278.rs1
-rw-r--r--src/test/run-pass/issue-16452.rs1
-rw-r--r--src/test/run-pass/issue-16597.rs2
-rw-r--r--src/test/run-pass/issue-16922.rs18
-rw-r--r--src/test/run-pass/issue-19982.rs22
-rw-r--r--src/test/run-pass/issue-20396.rs23
-rw-r--r--src/test/run-pass/issue-20823.rs2
-rw-r--r--src/test/run-pass/issue-21520.rs1
-rw-r--r--src/test/run-pass/issue-2214.rs1
-rw-r--r--src/test/run-pass/issue-22577.rs5
-rw-r--r--src/test/run-pass/issue-2383.rs1
-rw-r--r--src/test/run-pass/issue-2718.rs1
-rw-r--r--src/test/run-pass/issue-2804-2.rs1
-rw-r--r--src/test/run-pass/issue-2804.rs1
-rw-r--r--src/test/run-pass/issue-2904.rs1
-rw-r--r--src/test/run-pass/issue-3026.rs1
-rw-r--r--src/test/run-pass/issue-3979.rs1
-rw-r--r--src/test/run-pass/issue-4759.rs1
-rw-r--r--src/test/run-pass/issue-5060.rs1
-rw-r--r--src/test/run-pass/issue-5666.rs1
-rw-r--r--src/test/run-pass/issue-5950.rs2
-rw-r--r--src/test/run-pass/issue-6318.rs1
-rw-r--r--src/test/run-pass/issue-6919.rs1
-rw-r--r--src/test/run-pass/issue-7222.rs1
-rw-r--r--src/test/run-pass/issue-7607-2.rs2
-rw-r--r--src/test/run-pass/issue-8248.rs1
-rw-r--r--src/test/run-pass/issue-8249.rs1
-rw-r--r--src/test/run-pass/issue-8398.rs1
-rw-r--r--src/test/run-pass/issue-9188.rs1
-rw-r--r--src/test/run-pass/issue-9951.rs28
-rw-r--r--src/test/run-pass/kindck-implicit-close-over-mut-var.rs1
-rw-r--r--src/test/run-pass/kinds-in-metadata.rs1
-rw-r--r--src/test/run-pass/loop-label-shadowing.rs1
-rw-r--r--src/test/run-pass/macro-delimiter-significance.rs1
-rw-r--r--src/test/run-pass/macro-meta-items.rs1
-rw-r--r--src/test/run-pass/macro-method-issue-4621.rs3
-rw-r--r--src/test/run-pass/macro-with-attrs2.rs1
-rw-r--r--src/test/run-pass/method-normalize-bounds-issue-20604.rs1
-rw-r--r--src/test/run-pass/mid-path-type-params.rs1
-rw-r--r--src/test/run-pass/mod-view-items.rs1
-rw-r--r--src/test/run-pass/namespaced-enum-emulate-flat-xc.rs1
-rw-r--r--src/test/run-pass/namespaced-enums-xcrate.rs1
-rw-r--r--src/test/run-pass/new-box.rs1
-rw-r--r--src/test/run-pass/overloaded-calls-simple.rs1
-rw-r--r--src/test/run-pass/overloaded-calls-zero-args.rs2
-rw-r--r--src/test/run-pass/placement-new-arena.rs1
-rw-r--r--src/test/run-pass/ranges-precedence.rs1
-rw-r--r--src/test/run-pass/self-shadowing-import.rs1
-rw-r--r--src/test/run-pass/sepcomp-fns-backwards.rs1
-rw-r--r--src/test/run-pass/sepcomp-statics.rs1
-rw-r--r--src/test/run-pass/struct-aliases-xcrate.rs1
-rw-r--r--src/test/run-pass/struct-aliases.rs1
-rw-r--r--src/test/run-pass/test-fn-signature-verification-for-explicit-return-type.rs5
-rw-r--r--src/test/run-pass/test-should-fail-good-message.rs6
-rw-r--r--src/test/run-pass/trait-bounds-impl-comparison-duplicates.rs2
-rw-r--r--src/test/run-pass/trait-coercion-generic.rs1
-rw-r--r--src/test/run-pass/trait-coercion.rs1
-rw-r--r--src/test/run-pass/trait-contravariant-self.rs2
-rw-r--r--src/test/run-pass/trait-inheritance-num.rs1
-rw-r--r--src/test/run-pass/trait-inheritance-num0.rs1
-rw-r--r--src/test/run-pass/trait-inheritance-num2.rs1
-rw-r--r--src/test/run-pass/trait-static-method-overwriting.rs1
-rw-r--r--src/test/run-pass/ufcs-explicit-self.rs1
-rw-r--r--src/test/run-pass/unboxed-closures-all-traits.rs1
-rw-r--r--src/test/run-pass/unboxed-closures-boxed.rs1
-rw-r--r--src/test/run-pass/unboxed-closures-call-sugar-object-autoderef.rs1
-rw-r--r--src/test/run-pass/unboxed-closures-call-sugar-object.rs1
-rw-r--r--src/test/run-pass/unboxed-closures-direct-sugary-call.rs1
-rw-r--r--src/test/run-pass/unboxed-closures-drop.rs1
-rw-r--r--src/test/run-pass/unboxed-closures-extern-fn-hr.rs1
-rw-r--r--src/test/run-pass/unboxed-closures-extern-fn.rs1
-rw-r--r--src/test/run-pass/unboxed-closures-fn-as-fnmut-and-fnonce.rs1
-rw-r--r--src/test/run-pass/unboxed-closures-fnmut-as-fnonce.rs1
-rw-r--r--src/test/run-pass/unboxed-closures-generic.rs1
-rw-r--r--src/test/run-pass/unboxed-closures-infer-fnmut-calling-fnmut.rs1
-rw-r--r--src/test/run-pass/unboxed-closures-manual-impl.rs2
-rw-r--r--src/test/run-pass/unboxed-closures-prelude.rs1
-rw-r--r--src/test/run-pass/unboxed-closures-single-word-env.rs1
-rw-r--r--src/test/run-pass/unboxed-closures-static-call-fn-once.rs1
-rw-r--r--src/test/run-pass/unboxed-closures-zero-args.rs1
-rw-r--r--src/test/run-pass/use.rs1
-rw-r--r--src/test/run-pass/variance-trait-matching.rs2
-rw-r--r--src/test/run-pass/visible-private-types-feature-gate.rs1
-rw-r--r--src/test/run-pass/where-clause-method-substituion.rs1
-rw-r--r--src/test/run-pass/where-clauses-cross-crate.rs1
-rw-r--r--src/test/run-pass/where-clauses-unboxed-closures.rs1
-rw-r--r--src/test/run-pass/where-clauses.rs1
-rw-r--r--src/test/run-pass/where-for-self.rs1
604 files changed, 17751 insertions, 11226 deletions
diff --git a/README.md b/README.md
index 93f0daa7141..f92fc653e0e 100644
--- a/README.md
+++ b/README.md
@@ -64,7 +64,7 @@ Read ["Installing Rust"] from [The Book].
    # Choose one based on platform:
    $ pacman -S mingw-w64-i686-toolchain
    $ pacman -S mingw-w64-x86_64-toolchain
-   
+
    $ pacman -S base-devel
    ```
 
diff --git a/mk/cfg/x86_64-unknown-linux-gnu.mk b/mk/cfg/x86_64-unknown-linux-gnu.mk
index 845f9c1c52d..e5866094ee8 100644
--- a/mk/cfg/x86_64-unknown-linux-gnu.mk
+++ b/mk/cfg/x86_64-unknown-linux-gnu.mk
@@ -25,4 +25,3 @@ CFG_LDPATH_x86_64-unknown-linux-gnu :=
 CFG_RUN_x86_64-unknown-linux-gnu=$(2)
 CFG_RUN_TARG_x86_64-unknown-linux-gnu=$(call CFG_RUN_x86_64-unknown-linux-gnu,,$(2))
 CFG_GNU_TRIPLE_x86_64-unknown-linux-gnu := x86_64-unknown-linux-gnu
-
diff --git a/mk/dist.mk b/mk/dist.mk
index 831225556f3..57adaee5198 100644
--- a/mk/dist.mk
+++ b/mk/dist.mk
@@ -53,6 +53,7 @@ PKG_FILES := \
       driver                                   \
       etc                                      \
       $(foreach crate,$(CRATES),lib$(crate))   \
+      libcollectionstest                       \
       libcoretest                              \
       libbacktrace                             \
       rt                                       \
diff --git a/mk/prepare.mk b/mk/prepare.mk
index f1c4aa65f5f..4ded8a7916b 100644
--- a/mk/prepare.mk
+++ b/mk/prepare.mk
@@ -221,5 +221,3 @@ prepare-maybe-clean-$(1):
 
 
 endef
-
-
diff --git a/mk/target.mk b/mk/target.mk
index 0a41f363649..da18a9a4392 100644
--- a/mk/target.mk
+++ b/mk/target.mk
@@ -72,6 +72,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): CFG_COMPILER_HOST_TRIPLE = $(2)
 $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
 		$$(CRATEFILE_$(4)) \
 		$$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4)) \
+		$$(LLVM_CONFIG_$(2)) \
 		$$(TSREQ$(1)_T_$(2)_H_$(3)) \
 		| $$(TLIB$(1)_T_$(2)_H_$(3))/
 	@$$(call E, rustc: $$(@D)/lib$(4))
diff --git a/mk/tests.mk b/mk/tests.mk
index 48e50e47d4d..2fb33eb7db8 100644
--- a/mk/tests.mk
+++ b/mk/tests.mk
@@ -19,7 +19,10 @@
 DEPS_coretest :=
 $(eval $(call RUST_CRATE,coretest))
 
-TEST_TARGET_CRATES = $(filter-out core unicode,$(TARGET_CRATES)) coretest
+DEPS_collectionstest :=
+$(eval $(call RUST_CRATE,collectionstest))
+
+TEST_TARGET_CRATES = $(filter-out core unicode,$(TARGET_CRATES)) collectionstest coretest
 TEST_DOC_CRATES = $(DOC_CRATES)
 TEST_HOST_CRATES = $(filter-out rustc_typeck rustc_borrowck rustc_resolve rustc_trans rustc_lint,\
                      $(HOST_CRATES))
diff --git a/mk/util.mk b/mk/util.mk
index 3bbc8f413ae..b419c0bbe8e 100644
--- a/mk/util.mk
+++ b/mk/util.mk
@@ -17,4 +17,3 @@ else
 endif
 
 S := $(CFG_SRC_DIR)
-
diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs
index 50e74a13ee2..5ef93cb569e 100644
--- a/src/compiletest/compiletest.rs
+++ b/src/compiletest/compiletest.rs
@@ -20,7 +20,6 @@
 #![feature(std_misc)]
 #![feature(test)]
 #![feature(core)]
-#![feature(net)]
 #![feature(path_ext)]
 
 #![deny(warnings)]
diff --git a/src/doc/grammar.md b/src/doc/grammar.md
index 68ca1cb7217..1ea3c7d7bd9 100644
--- a/src/doc/grammar.md
+++ b/src/doc/grammar.md
@@ -290,7 +290,7 @@ transcriber : '(' transcriber * ')' | '[' transcriber * ']'
 
 # Items and attributes
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ## Items
 
@@ -301,7 +301,7 @@ item : mod_item | fn_item | type_item | struct_item | enum_item
 
 ### Type Parameters
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Modules
 
@@ -338,35 +338,35 @@ path_item : ident | "mod" ;
 
 ### Functions
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 #### Generic functions
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 #### Unsafety
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ##### Unsafe functions
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ##### Unsafe blocks
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 #### Diverging functions
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Type definitions
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Structures
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Constant items
 
@@ -382,15 +382,15 @@ static_item : "static" ident ':' type '=' expr ';' ;
 
 #### Mutable statics
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Traits
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Implementations
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### External blocks
 
@@ -401,11 +401,11 @@ extern_block : [ foreign_fn ] * ;
 
 ## Visibility and Privacy
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Re-exporting and Visibility
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ## Attributes
 
@@ -420,11 +420,11 @@ meta_seq : meta_item [ ',' meta_seq ] ? ;
 
 ## Statements
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Declaration statements
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 A _declaration statement_ is one that introduces one or more *names* into the
 enclosing statement block. The declared names may denote new slots or new
@@ -432,7 +432,7 @@ items.
 
 #### Item declarations
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 An _item declaration statement_ has a syntactic form identical to an
 [item](#items) declaration within a module. Declaring an item — a
@@ -450,35 +450,35 @@ init : [ '=' ] expr ;
 
 ### Expression statements
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ## Expressions
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 #### Lvalues, rvalues and temporaries
 
-**FIXME:** grammar?  
+**FIXME:** grammar?
 
 #### Moved and copied types
 
-**FIXME:** Do we want to capture this in the grammar as different productions? 
+**FIXME:** Do we want to capture this in the grammar as different productions?
 
 ### Literal expressions
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Path expressions
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Tuple expressions
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Unit expressions
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Structure expressions
 
@@ -527,7 +527,7 @@ idx_expr : expr '[' expr ']' ;
 
 ### Unary operator expressions
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Binary operator expressions
 
@@ -537,31 +537,31 @@ binop_expr : expr binop expr ;
 
 #### Arithmetic operators
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 #### Bitwise operators
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 #### Lazy boolean operators
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 #### Comparison operators
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 #### Type cast expressions
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 #### Assignment expressions
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 #### Compound assignment expressions
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 #### Operator precedence
 
@@ -680,49 +680,49 @@ return_expr : "return" expr ? ;
 
 # Type system
 
-**FIXME:** is this entire chapter relevant here? Or should it all have been covered by some production already? 
+**FIXME:** is this entire chapter relevant here? Or should it all have been covered by some production already?
 
 ## Types
 
 ### Primitive types
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 #### Machine types
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 #### Machine-dependent integer types
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Textual types
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Tuple types
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Array, and Slice types
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Structure types
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Enumerated types
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Pointer types
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Function types
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Closure types
 
@@ -739,15 +739,15 @@ bound := path | lifetime
 
 ### Object types
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Type parameters
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ### Self types
 
-**FIXME:** grammar? 
+**FIXME:** grammar?
 
 ## Type kinds
 
@@ -755,7 +755,7 @@ bound := path | lifetime
 
 # Memory and concurrency models
 
-**FIXME:** is this entire chapter relevant here? Or should it all have been covered by some production already? 
+**FIXME:** is this entire chapter relevant here? Or should it all have been covered by some production already?
 
 ## Memory model
 
diff --git a/src/doc/intro.md b/src/doc/intro.md
index 9e575abeee2..51280e58854 100644
--- a/src/doc/intro.md
+++ b/src/doc/intro.md
@@ -140,7 +140,7 @@ right at home if you've used tools like [Bundler](http://bundler.io/),
 [npm](https://www.npmjs.org/), or [pip](https://pip.pypa.io/en/latest/).
 There's no `Makefile`s or endless `autotools` output here. (Rust's tooling does
 [play nice with external libraries written in those
-tools](http://crates.io/native-build.html), if you need to.)
+tools](http://doc.crates.io/build-script.html), if you need to.)
 
 Enough about tools, let's talk code!
 
diff --git a/src/doc/not_found.md b/src/doc/not_found.md
index c746c5773dd..eae2bf1925a 100644
--- a/src/doc/not_found.md
+++ b/src/doc/not_found.md
@@ -63,4 +63,3 @@ function populate_rust_search() {
 populate_site_search();
 populate_rust_search();
 </script>
-
diff --git a/src/doc/reference.md b/src/doc/reference.md
index c4c122463a7..3fae49bfc6d 100644
--- a/src/doc/reference.md
+++ b/src/doc/reference.md
@@ -1961,16 +1961,18 @@ module through the rules above. It essentially allows public access into the
 re-exported item. For example, this program is valid:
 
 ```
-pub use self::implementation as api;
+pub use self::implementation::api;
 
 mod implementation {
-    pub fn f() {}
+    pub mod api {
+        pub fn f() {}
+    }
 }
 
 # fn main() {}
 ```
 
-This means that any external crate referencing `implementation::f` would
+This means that any external crate referencing `implementation::api::f` would
 receive a privacy violation, while the path `api::f` would be allowed.
 
 When re-exporting a private item, it can be thought of as allowing the "privacy
diff --git a/src/doc/trpl/arrays-vectors-and-slices.md b/src/doc/trpl/arrays-vectors-and-slices.md
index f1b5ecf4ff0..5d0f314e8c6 100644
--- a/src/doc/trpl/arrays-vectors-and-slices.md
+++ b/src/doc/trpl/arrays-vectors-and-slices.md
@@ -49,7 +49,7 @@ languages.
 
 A *vector* is a dynamic or "growable" array, implemented as the standard
 library type [`Vec<T>`](../std/vec/) (we'll talk about what the `<T>` means
-later). Vectors always allocate their data on the heap. Vectors are to slices 
+later). Vectors always allocate their data on the heap. Vectors are to slices
 what `String` is to `&str`. You can create them with the `vec!` macro:
 
 ```{rust}
diff --git a/src/doc/trpl/crates-and-modules.md b/src/doc/trpl/crates-and-modules.md
index 8eaad5067f0..f6f6046b9b4 100644
--- a/src/doc/trpl/crates-and-modules.md
+++ b/src/doc/trpl/crates-and-modules.md
@@ -551,9 +551,9 @@ module, we now have a `phrases::japanese::hello()` function and a
 `phrases::japanese::farewells::goodbye()`. Our internal organization doesn't
 define our external interface.
 
-Here we have a `pub use` for each function we want to bring into the 
+Here we have a `pub use` for each function we want to bring into the
 `japanese` scope. We could alternatively use the wildcard syntax to include
-everything from `greetings` into the current scope: `pub use self::greetings::*`. 
+everything from `greetings` into the current scope: `pub use self::greetings::*`.
 
 What about the `self`? Well, by default, `use` declarations are absolute paths,
 starting from your crate root. `self` makes that path relative to your current
diff --git a/src/doc/trpl/documentation.md b/src/doc/trpl/documentation.md
index 0553fe3280c..8e5b3b6a7f0 100644
--- a/src/doc/trpl/documentation.md
+++ b/src/doc/trpl/documentation.md
@@ -306,23 +306,23 @@ println!("{}", x + y);
 Here's the same explanation, in raw text:
 
 > First, we set `x` to five:
-> 
+>
 > ```text
 > let x = 5;
 > # let y = 6;
 > # println!("{}", x + y);
 > ```
-> 
+>
 > Next, we set `y` to six:
-> 
+>
 > ```text
 > # let x = 5;
 > let y = 6;
 > # println!("{}", x + y);
 > ```
-> 
+>
 > Finally, we print the sum of `x` and `y`:
-> 
+>
 > ```text
 > # let x = 5;
 > # let y = 6;
@@ -521,4 +521,3 @@ This sets a few different options, with a logo, favicon, and a root URL.
 - `--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.
-
diff --git a/src/doc/trpl/ffi.md b/src/doc/trpl/ffi.md
index 97e826579fd..20b0ffc1b28 100644
--- a/src/doc/trpl/ffi.md
+++ b/src/doc/trpl/ffi.md
@@ -543,4 +543,3 @@ The `extern` makes this function adhere to the C calling convention, as
 discussed above in "[Foreign Calling
 Conventions](ffi.html#foreign-calling-conventions)". The `no_mangle`
 attribute turns off Rust's name mangling, so that it is easier to link to.
-
diff --git a/src/doc/trpl/method-syntax.md b/src/doc/trpl/method-syntax.md
index 59be8c6704f..0ca42c3b12d 100644
--- a/src/doc/trpl/method-syntax.md
+++ b/src/doc/trpl/method-syntax.md
@@ -61,15 +61,15 @@ struct Circle {
 
 impl Circle {
     fn reference(&self) {
-       println!("taking self by reference!"); 
+       println!("taking self by reference!");
     }
 
     fn mutable_reference(&mut self) {
-       println!("taking self by mutable reference!"); 
+       println!("taking self by mutable reference!");
     }
 
     fn takes_ownership(self) {
-       println!("taking ownership of self!"); 
+       println!("taking ownership of self!");
     }
 }
 ```
diff --git a/src/doc/trpl/static-and-dynamic-dispatch.md b/src/doc/trpl/static-and-dynamic-dispatch.md
index 504ed63934c..a7794814156 100644
--- a/src/doc/trpl/static-and-dynamic-dispatch.md
+++ b/src/doc/trpl/static-and-dynamic-dispatch.md
@@ -95,7 +95,7 @@ However, the common case is that it is more efficient to use static dispatch,
 and one can always have a thin statically-dispatched wrapper function that does
 a dynamic dispatch, but not vice versa, meaning static calls are more flexible.
 The standard library tries to be statically dispatched where possible for this
-reason. 
+reason.
 
 ## Dynamic dispatch
 
diff --git a/src/doc/trpl/testing.md b/src/doc/trpl/testing.md
index 54c74fdd3e2..537e100d7d8 100644
--- a/src/doc/trpl/testing.md
+++ b/src/doc/trpl/testing.md
@@ -1,7 +1,7 @@
 % Testing
 
 > Program testing can be a very effective way to show the presence of bugs, but
-> it is hopelessly inadequate for showing their absence. 
+> it is hopelessly inadequate for showing their absence.
 >
 > Edsger W. Dijkstra, "The Humble Programmer" (1972)
 
@@ -308,7 +308,7 @@ extern crate adder;
 #[test]
 fn it_works() {
     assert_eq!(4, adder::add_two(2));
-}   
+}
 ```
 
 This looks similar to our previous tests, but slightly different. We now have
diff --git a/src/etc/featureck.py b/src/etc/featureck.py
index ce972c91c81..86fa779cced 100644
--- a/src/etc/featureck.py
+++ b/src/etc/featureck.py
@@ -242,4 +242,3 @@ print
 for line in lines:
     print "* " + line
 print
-
diff --git a/src/etc/gdb_rust_pretty_printing.py b/src/etc/gdb_rust_pretty_printing.py
index dbf27e88c14..4e489df7dd7 100755
--- a/src/etc/gdb_rust_pretty_printing.py
+++ b/src/etc/gdb_rust_pretty_printing.py
@@ -340,4 +340,4 @@ def extract_length_and_data_ptr_from_std_vec(vec_val):
     unique_ptr_val = vec_ptr_val[first_field(vec_ptr_val)]
     data_ptr = unique_ptr_val[first_field(unique_ptr_val)]
     assert data_ptr.type.code == gdb.TYPE_CODE_PTR
-    return (length, data_ptr)
\ No newline at end of file
+    return (length, data_ptr)
diff --git a/src/etc/mingw-fix-include/README.txt b/src/etc/mingw-fix-include/README.txt
index 876db17a248..e36e6abde91 100644
--- a/src/etc/mingw-fix-include/README.txt
+++ b/src/etc/mingw-fix-include/README.txt
@@ -1,6 +1,6 @@
 The purpose of these headers is to fix issues with mingw v4.0, as described in #9246.
 
-This works by adding this directory to GCC include search path before mingw system headers directories, 
+This works by adding this directory to GCC include search path before mingw system headers directories,
 so we can intercept their inclusions and add missing definitions without having to modify files in mingw/include.
 
 Once mingw fixes all 3 issues mentioned in #9246, this directory and all references to it from rust/mk/* may be removed.
diff --git a/src/etc/third-party/COPYING.RUNTIME b/src/etc/third-party/COPYING.RUNTIME
index e1b3c69c179..e86f7fb58a4 100644
--- a/src/etc/third-party/COPYING.RUNTIME
+++ b/src/etc/third-party/COPYING.RUNTIME
@@ -70,4 +70,3 @@ consistent with the licensing of the Independent Modules.
 The availability of this Exception does not imply any general
 presumption that third-party software is unaffected by the copyleft
 requirements of the license of GCC.
-
diff --git a/src/grammar/check.sh b/src/grammar/check.sh
index b5be3daa13e..b0628303b66 100755
--- a/src/grammar/check.sh
+++ b/src/grammar/check.sh
@@ -50,4 +50,3 @@ else
     printf "failed. $passed passed; $failed failed; $skipped skipped\n\n"
     exit 1
 fi
-
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs
index 748eb9dcb2f..8befb0579c3 100644
--- a/src/liballoc/arc.rs
+++ b/src/liballoc/arc.rs
@@ -94,7 +94,7 @@ use heap::deallocate;
 /// With simple pipes, without `Arc`, a copy would have to be made for each
 /// task.
 ///
-/// ```rust
+/// ```
 /// use std::sync::Arc;
 /// use std::thread;
 ///
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs
index 808830d4648..50935e6404d 100644
--- a/src/liballoc/boxed.rs
+++ b/src/liballoc/boxed.rs
@@ -64,7 +64,7 @@ use core::raw::TraitObject;
 ///
 /// The following two examples are equivalent:
 ///
-/// ```rust
+/// ```
 /// #![feature(box_syntax)]
 /// use std::boxed::HEAP;
 ///
diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs
index f9936b7a16a..25c6bda5f39 100644
--- a/src/liballoc/heap.rs
+++ b/src/liballoc/heap.rs
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#[cfg(stage0)]
 #[cfg(not(test))]
 use core::ptr::PtrExt;
 
@@ -387,7 +388,6 @@ mod imp {
 mod test {
     extern crate test;
     use self::test::Bencher;
-    use core::ptr::PtrExt;
     use boxed::Box;
     use heap;
 
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs
index 115acd4a0ef..3692149db44 100644
--- a/src/liballoc/rc.rs
+++ b/src/liballoc/rc.rs
@@ -159,7 +159,10 @@ use core::nonzero::NonZero;
 use core::ops::{Deref, Drop};
 use core::option::Option;
 use core::option::Option::{Some, None};
+#[cfg(stage0)]
 use core::ptr::{self, PtrExt};
+#[cfg(not(stage0))]
+use core::ptr;
 use core::result::Result;
 use core::result::Result::{Ok, Err};
 use core::intrinsics::assume;
diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs
index d08c9b3257a..029d9d03835 100644
--- a/src/libarena/lib.rs
+++ b/src/libarena/lib.rs
@@ -46,6 +46,7 @@ use std::intrinsics::{TyDesc, get_tydesc};
 use std::intrinsics;
 use std::marker;
 use std::mem;
+#[cfg(stage0)]
 use std::num::{Int, UnsignedInt};
 use std::ptr;
 use std::rc::Rc;
diff --git a/src/libbacktrace/Makefile.am b/src/libbacktrace/Makefile.am
index 6add85d7341..43728998292 100644
--- a/src/libbacktrace/Makefile.am
+++ b/src/libbacktrace/Makefile.am
@@ -6,12 +6,12 @@
 # met:
 
 #     (1) Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer. 
+#     notice, this list of conditions and the following disclaimer.
 
 #     (2) Redistributions in binary form must reproduce the above copyright
 #     notice, this list of conditions and the following disclaimer in
 #     the documentation and/or other materials provided with the
-#     distribution.  
+#     distribution.
 
 #     (3) The name of the author may not be used to
 #     endorse or promote products derived from this software without
diff --git a/src/libbacktrace/Makefile.in b/src/libbacktrace/Makefile.in
index 18c1ecaca54..93ccec2dbf9 100644
--- a/src/libbacktrace/Makefile.in
+++ b/src/libbacktrace/Makefile.in
@@ -23,12 +23,12 @@
 # met:
 
 #     (1) Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer. 
+#     notice, this list of conditions and the following disclaimer.
 
 #     (2) Redistributions in binary form must reproduce the above copyright
 #     notice, this list of conditions and the following disclaimer in
 #     the documentation and/or other materials provided with the
-#     distribution.  
+#     distribution.
 
 #     (3) The name of the author may not be used to
 #     endorse or promote products derived from this software without
@@ -117,10 +117,10 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	$(LDFLAGS) -o $@
 SOURCES = $(libbacktrace_la_SOURCES) $(EXTRA_libbacktrace_la_SOURCES) \
 	$(btest_SOURCES)
-MULTISRCTOP = 
-MULTIBUILDTOP = 
-MULTIDIRS = 
-MULTISUBDIR = 
+MULTISRCTOP =
+MULTIBUILDTOP =
+MULTIDIRS =
+MULTISUBDIR =
 MULTIDO = true
 MULTICLEAN = true
 ETAGS = etags
@@ -362,7 +362,7 @@ config.h: stamp-h1
 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
 	@rm -f stamp-h1
 	cd $(top_builddir) && $(SHELL) ./config.status config.h
-$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) 
+$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
 	($(am__cd) $(top_srcdir) && $(AUTOHEADER))
 	rm -f stamp-h1
 	touch $@
@@ -380,7 +380,7 @@ clean-noinstLTLIBRARIES:
 	  echo "rm -f \"$${dir}/so_locations\""; \
 	  rm -f "$${dir}/so_locations"; \
 	done
-libbacktrace.la: $(libbacktrace_la_OBJECTS) $(libbacktrace_la_DEPENDENCIES) 
+libbacktrace.la: $(libbacktrace_la_OBJECTS) $(libbacktrace_la_DEPENDENCIES)
 	$(LINK)  $(libbacktrace_la_OBJECTS) $(libbacktrace_la_LIBADD) $(LIBS)
 
 clean-checkPROGRAMS:
@@ -391,7 +391,7 @@ clean-checkPROGRAMS:
 	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
 	echo " rm -f" $$list; \
 	rm -f $$list
-btest$(EXEEXT): $(btest_OBJECTS) $(btest_DEPENDENCIES) 
+btest$(EXEEXT): $(btest_OBJECTS) $(btest_DEPENDENCIES)
 	@rm -f btest$(EXEEXT)
 	$(btest_LINK) $(btest_OBJECTS) $(btest_LDADD) $(LIBS)
 
diff --git a/src/libbacktrace/alloc.c b/src/libbacktrace/alloc.c
index 37eca65349e..4aa85d050fd 100644
--- a/src/libbacktrace/alloc.c
+++ b/src/libbacktrace/alloc.c
@@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are
 met:
 
     (1) Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer. 
+    notice, this list of conditions and the following disclaimer.
 
     (2) Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
-    distribution.  
-    
+    distribution.
+
     (3) The name of the author may not be used to
     endorse or promote products derived from this software without
     specific prior written permission.
diff --git a/src/libbacktrace/atomic.c b/src/libbacktrace/atomic.c
index f139d74aa5f..b31fa64c798 100644
--- a/src/libbacktrace/atomic.c
+++ b/src/libbacktrace/atomic.c
@@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are
 met:
 
     (1) Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer. 
+    notice, this list of conditions and the following disclaimer.
 
     (2) Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
-    distribution.  
-    
+    distribution.
+
     (3) The name of the author may not be used to
     endorse or promote products derived from this software without
     specific prior written permission.
diff --git a/src/libbacktrace/backtrace-supported.h.in b/src/libbacktrace/backtrace-supported.h.in
index 901e3f72a43..28488167c4e 100644
--- a/src/libbacktrace/backtrace-supported.h.in
+++ b/src/libbacktrace/backtrace-supported.h.in
@@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are
 met:
 
     (1) Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer. 
+    notice, this list of conditions and the following disclaimer.
 
     (2) Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
-    distribution.  
-    
+    distribution.
+
     (3) The name of the author may not be used to
     endorse or promote products derived from this software without
     specific prior written permission.
diff --git a/src/libbacktrace/backtrace.c b/src/libbacktrace/backtrace.c
index cc3105c06cb..4b90357df5f 100644
--- a/src/libbacktrace/backtrace.c
+++ b/src/libbacktrace/backtrace.c
@@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are
 met:
 
     (1) Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer. 
+    notice, this list of conditions and the following disclaimer.
 
     (2) Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
-    distribution.  
-    
+    distribution.
+
     (3) The name of the author may not be used to
     endorse or promote products derived from this software without
     specific prior written permission.
diff --git a/src/libbacktrace/backtrace.h b/src/libbacktrace/backtrace.h
index 03b5479081d..3f77093f767 100644
--- a/src/libbacktrace/backtrace.h
+++ b/src/libbacktrace/backtrace.h
@@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are
 met:
 
     (1) Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer. 
+    notice, this list of conditions and the following disclaimer.
 
     (2) Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
-    distribution.  
-    
+    distribution.
+
     (3) The name of the author may not be used to
     endorse or promote products derived from this software without
     specific prior written permission.
diff --git a/src/libbacktrace/btest.c b/src/libbacktrace/btest.c
index 4b67c3d8bd0..a1818f1ef83 100644
--- a/src/libbacktrace/btest.c
+++ b/src/libbacktrace/btest.c
@@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are
 met:
 
     (1) Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer. 
+    notice, this list of conditions and the following disclaimer.
 
     (2) Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
-    distribution.  
-    
+    distribution.
+
     (3) The name of the author may not be used to
     endorse or promote products derived from this software without
     specific prior written permission.
@@ -460,7 +460,7 @@ f23 (int f1line, int f2line)
 		       (unsigned int) bdata.index, j + 1);
 	      bdata.failed = 1;
 	    }
-	}      
+	}
 
       check ("test3", 0, all, f3line, "f23", &bdata.failed);
       check ("test3", 1, all, f2line, "f22", &bdata.failed);
diff --git a/src/libbacktrace/configure b/src/libbacktrace/configure
index 694b5d23c49..d5e08d93f6c 100755
--- a/src/libbacktrace/configure
+++ b/src/libbacktrace/configure
@@ -15153,4 +15153,3 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
 fi
-
diff --git a/src/libbacktrace/configure.ac b/src/libbacktrace/configure.ac
index 878bd2c1580..d661c7b2560 100644
--- a/src/libbacktrace/configure.ac
+++ b/src/libbacktrace/configure.ac
@@ -6,13 +6,13 @@
 # met:
 
 #     (1) Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer. 
+#     notice, this list of conditions and the following disclaimer.
 
 #     (2) Redistributions in binary form must reproduce the above copyright
 #     notice, this list of conditions and the following disclaimer in
 #     the documentation and/or other materials provided with the
-#     distribution.  
-    
+#     distribution.
+
 #     (3) The name of the author may not be used to
 #     endorse or promote products derived from this software without
 #     specific prior written permission.
diff --git a/src/libbacktrace/dwarf.c b/src/libbacktrace/dwarf.c
index ad52d73b752..5ecae711792 100644
--- a/src/libbacktrace/dwarf.c
+++ b/src/libbacktrace/dwarf.c
@@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are
 met:
 
     (1) Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer. 
+    notice, this list of conditions and the following disclaimer.
 
     (2) Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
-    distribution.  
-    
+    distribution.
+
     (3) The name of the author may not be used to
     endorse or promote products derived from this software without
     specific prior written permission.
@@ -1241,7 +1241,7 @@ add_unit_ranges (struct backtrace_state *state, uintptr_t base_address,
 
 static int
 find_address_ranges (struct backtrace_state *state, uintptr_t base_address,
-		     struct dwarf_buf *unit_buf, 
+		     struct dwarf_buf *unit_buf,
 		     const unsigned char *dwarf_str, size_t dwarf_str_size,
 		     const unsigned char *dwarf_ranges,
 		     size_t dwarf_ranges_size,
@@ -1599,7 +1599,7 @@ read_line_header (struct backtrace_state *state, struct unit *u,
 
   if (!advance (line_buf, hdrlen))
     return 0;
-  
+
   hdr->min_insn_len = read_byte (&hdr_buf);
   if (hdr->version < 4)
     hdr->max_ops_per_insn = 1;
@@ -1608,7 +1608,7 @@ read_line_header (struct backtrace_state *state, struct unit *u,
 
   /* We don't care about default_is_stmt.  */
   read_byte (&hdr_buf);
-  
+
   hdr->line_base = read_sbyte (&hdr_buf);
   hdr->line_range = read_byte (&hdr_buf);
 
diff --git a/src/libbacktrace/elf.c b/src/libbacktrace/elf.c
index 6c5b179e90d..5fc74add05c 100644
--- a/src/libbacktrace/elf.c
+++ b/src/libbacktrace/elf.c
@@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are
 met:
 
     (1) Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer. 
+    notice, this list of conditions and the following disclaimer.
 
     (2) Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
-    distribution.  
-    
+    distribution.
+
     (3) The name of the author may not be used to
     endorse or promote products derived from this software without
     specific prior written permission.
diff --git a/src/libbacktrace/fileline.c b/src/libbacktrace/fileline.c
index bab5351cab3..f45cccff713 100644
--- a/src/libbacktrace/fileline.c
+++ b/src/libbacktrace/fileline.c
@@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are
 met:
 
     (1) Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer. 
+    notice, this list of conditions and the following disclaimer.
 
     (2) Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
-    distribution.  
-    
+    distribution.
+
     (3) The name of the author may not be used to
     endorse or promote products derived from this software without
     specific prior written permission.
diff --git a/src/libbacktrace/hashtab.h b/src/libbacktrace/hashtab.h
index 4bb65d6c7a2..3736622e677 100644
--- a/src/libbacktrace/hashtab.h
+++ b/src/libbacktrace/hashtab.h
@@ -1,4 +1,4 @@
-/* An expandable hash tables datatype.  
+/* An expandable hash tables datatype.
    Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by Vladimir Makarov (vmakarov@cygnus.com).
@@ -61,7 +61,7 @@ typedef int (*htab_eq) (const void *, const void *);
 /* Cleanup function called whenever a live element is removed from
    the hash table.  */
 typedef void (*htab_del) (void *);
-  
+
 /* Function called by htab_traverse for each live element.  The first
    arg is the slot of the element (which can be passed to htab_clear_slot
    if desired), the second arg is the auxiliary pointer handed to
diff --git a/src/libbacktrace/internal.h b/src/libbacktrace/internal.h
index dd109db24ae..a13c775b628 100644
--- a/src/libbacktrace/internal.h
+++ b/src/libbacktrace/internal.h
@@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are
 met:
 
     (1) Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer. 
+    notice, this list of conditions and the following disclaimer.
 
     (2) Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
-    distribution.  
-    
+    distribution.
+
     (3) The name of the author may not be used to
     endorse or promote products derived from this software without
     specific prior written permission.
diff --git a/src/libbacktrace/ltmain.sh b/src/libbacktrace/ltmain.sh
index eaef55a5933..84f5be9249e 100644
--- a/src/libbacktrace/ltmain.sh
+++ b/src/libbacktrace/ltmain.sh
@@ -8633,4 +8633,3 @@ build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
 # sh-indentation:2
 # End:
 # vi:sw=2
-
diff --git a/src/libbacktrace/mmap.c b/src/libbacktrace/mmap.c
index b530e382388..1c691b02e7c 100644
--- a/src/libbacktrace/mmap.c
+++ b/src/libbacktrace/mmap.c
@@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are
 met:
 
     (1) Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer. 
+    notice, this list of conditions and the following disclaimer.
 
     (2) Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
-    distribution.  
-    
+    distribution.
+
     (3) The name of the author may not be used to
     endorse or promote products derived from this software without
     specific prior written permission.
diff --git a/src/libbacktrace/mmapio.c b/src/libbacktrace/mmapio.c
index 72940b403a3..8b8f124da9a 100644
--- a/src/libbacktrace/mmapio.c
+++ b/src/libbacktrace/mmapio.c
@@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are
 met:
 
     (1) Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer. 
+    notice, this list of conditions and the following disclaimer.
 
     (2) Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
-    distribution.  
-    
+    distribution.
+
     (3) The name of the author may not be used to
     endorse or promote products derived from this software without
     specific prior written permission.
diff --git a/src/libbacktrace/nounwind.c b/src/libbacktrace/nounwind.c
index 0097966b422..f8fdbdc85ac 100644
--- a/src/libbacktrace/nounwind.c
+++ b/src/libbacktrace/nounwind.c
@@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are
 met:
 
     (1) Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer. 
+    notice, this list of conditions and the following disclaimer.
 
     (2) Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
-    distribution.  
-    
+    distribution.
+
     (3) The name of the author may not be used to
     endorse or promote products derived from this software without
     specific prior written permission.
diff --git a/src/libbacktrace/posix.c b/src/libbacktrace/posix.c
index dba9e525e08..7f1c35ab970 100644
--- a/src/libbacktrace/posix.c
+++ b/src/libbacktrace/posix.c
@@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are
 met:
 
     (1) Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer. 
+    notice, this list of conditions and the following disclaimer.
 
     (2) Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
-    distribution.  
-    
+    distribution.
+
     (3) The name of the author may not be used to
     endorse or promote products derived from this software without
     specific prior written permission.
diff --git a/src/libbacktrace/print.c b/src/libbacktrace/print.c
index bd224e6bf4d..70e347f62c2 100644
--- a/src/libbacktrace/print.c
+++ b/src/libbacktrace/print.c
@@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are
 met:
 
     (1) Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer. 
+    notice, this list of conditions and the following disclaimer.
 
     (2) Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
-    distribution.  
-    
+    distribution.
+
     (3) The name of the author may not be used to
     endorse or promote products derived from this software without
     specific prior written permission.
diff --git a/src/libbacktrace/read.c b/src/libbacktrace/read.c
index c618a50b36d..e373b61de2e 100644
--- a/src/libbacktrace/read.c
+++ b/src/libbacktrace/read.c
@@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are
 met:
 
     (1) Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer. 
+    notice, this list of conditions and the following disclaimer.
 
     (2) Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
-    distribution.  
-    
+    distribution.
+
     (3) The name of the author may not be used to
     endorse or promote products derived from this software without
     specific prior written permission.
diff --git a/src/libbacktrace/simple.c b/src/libbacktrace/simple.c
index efa8b6fc639..dd70f831de7 100644
--- a/src/libbacktrace/simple.c
+++ b/src/libbacktrace/simple.c
@@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are
 met:
 
     (1) Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer. 
+    notice, this list of conditions and the following disclaimer.
 
     (2) Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
-    distribution.  
-    
+    distribution.
+
     (3) The name of the author may not be used to
     endorse or promote products derived from this software without
     specific prior written permission.
diff --git a/src/libbacktrace/state.c b/src/libbacktrace/state.c
index a7d4e07d1a5..bef47bd1a0f 100644
--- a/src/libbacktrace/state.c
+++ b/src/libbacktrace/state.c
@@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are
 met:
 
     (1) Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer. 
+    notice, this list of conditions and the following disclaimer.
 
     (2) Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
-    distribution.  
-    
+    distribution.
+
     (3) The name of the author may not be used to
     endorse or promote products derived from this software without
     specific prior written permission.
diff --git a/src/libbacktrace/unknown.c b/src/libbacktrace/unknown.c
index c1fe8811d47..e5e8421b3a9 100644
--- a/src/libbacktrace/unknown.c
+++ b/src/libbacktrace/unknown.c
@@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are
 met:
 
     (1) Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer. 
+    notice, this list of conditions and the following disclaimer.
 
     (2) Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
-    distribution.  
-    
+    distribution.
+
     (3) The name of the author may not be used to
     endorse or promote products derived from this software without
     specific prior written permission.
diff --git a/src/libcollections/binary_heap.rs b/src/libcollections/binary_heap.rs
index 2e575ddb00a..11c8656c994 100644
--- a/src/libcollections/binary_heap.rs
+++ b/src/libcollections/binary_heap.rs
@@ -163,6 +163,11 @@ use vec::{self, Vec};
 /// A priority queue implemented with a binary heap.
 ///
 /// This will be a max-heap.
+///
+/// It is a logic error for an item to be modified in such a way that the
+/// item's ordering relative to any other item, as determined by the `Ord`
+/// trait, changes while it is in the heap. This is normally only possible
+/// through `Cell`, `RefCell`, global state, I/O, or unsafe code.
 #[derive(Clone)]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct BinaryHeap<T> {
@@ -688,218 +693,3 @@ impl<T: Ord> Extend<T> for BinaryHeap<T> {
         }
     }
 }
-
-#[cfg(test)]
-mod tests {
-    use prelude::*;
-
-    use super::BinaryHeap;
-
-    #[test]
-    fn test_iterator() {
-        let data = vec![5, 9, 3];
-        let iterout = [9, 5, 3];
-        let heap = BinaryHeap::from_vec(data);
-        let mut i = 0;
-        for el in &heap {
-            assert_eq!(*el, iterout[i]);
-            i += 1;
-        }
-    }
-
-    #[test]
-    fn test_iterator_reverse() {
-        let data = vec![5, 9, 3];
-        let iterout = vec![3, 5, 9];
-        let pq = BinaryHeap::from_vec(data);
-
-        let v: Vec<_> = pq.iter().rev().cloned().collect();
-        assert_eq!(v, iterout);
-    }
-
-    #[test]
-    fn test_move_iter() {
-        let data = vec![5, 9, 3];
-        let iterout = vec![9, 5, 3];
-        let pq = BinaryHeap::from_vec(data);
-
-        let v: Vec<_> = pq.into_iter().collect();
-        assert_eq!(v, iterout);
-    }
-
-    #[test]
-    fn test_move_iter_size_hint() {
-        let data = vec![5, 9];
-        let pq = BinaryHeap::from_vec(data);
-
-        let mut it = pq.into_iter();
-
-        assert_eq!(it.size_hint(), (2, Some(2)));
-        assert_eq!(it.next(), Some(9));
-
-        assert_eq!(it.size_hint(), (1, Some(1)));
-        assert_eq!(it.next(), Some(5));
-
-        assert_eq!(it.size_hint(), (0, Some(0)));
-        assert_eq!(it.next(), None);
-    }
-
-    #[test]
-    fn test_move_iter_reverse() {
-        let data = vec![5, 9, 3];
-        let iterout = vec![3, 5, 9];
-        let pq = BinaryHeap::from_vec(data);
-
-        let v: Vec<_> = pq.into_iter().rev().collect();
-        assert_eq!(v, iterout);
-    }
-
-    #[test]
-    fn test_peek_and_pop() {
-        let data = vec![2, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1];
-        let mut sorted = data.clone();
-        sorted.sort();
-        let mut heap = BinaryHeap::from_vec(data);
-        while !heap.is_empty() {
-            assert_eq!(heap.peek().unwrap(), sorted.last().unwrap());
-            assert_eq!(heap.pop().unwrap(), sorted.pop().unwrap());
-        }
-    }
-
-    #[test]
-    fn test_push() {
-        let mut heap = BinaryHeap::from_vec(vec![2, 4, 9]);
-        assert_eq!(heap.len(), 3);
-        assert!(*heap.peek().unwrap() == 9);
-        heap.push(11);
-        assert_eq!(heap.len(), 4);
-        assert!(*heap.peek().unwrap() == 11);
-        heap.push(5);
-        assert_eq!(heap.len(), 5);
-        assert!(*heap.peek().unwrap() == 11);
-        heap.push(27);
-        assert_eq!(heap.len(), 6);
-        assert!(*heap.peek().unwrap() == 27);
-        heap.push(3);
-        assert_eq!(heap.len(), 7);
-        assert!(*heap.peek().unwrap() == 27);
-        heap.push(103);
-        assert_eq!(heap.len(), 8);
-        assert!(*heap.peek().unwrap() == 103);
-    }
-
-    #[test]
-    fn test_push_unique() {
-        let mut heap = BinaryHeap::<Box<_>>::from_vec(vec![box 2, box 4, box 9]);
-        assert_eq!(heap.len(), 3);
-        assert!(*heap.peek().unwrap() == box 9);
-        heap.push(box 11);
-        assert_eq!(heap.len(), 4);
-        assert!(*heap.peek().unwrap() == box 11);
-        heap.push(box 5);
-        assert_eq!(heap.len(), 5);
-        assert!(*heap.peek().unwrap() == box 11);
-        heap.push(box 27);
-        assert_eq!(heap.len(), 6);
-        assert!(*heap.peek().unwrap() == box 27);
-        heap.push(box 3);
-        assert_eq!(heap.len(), 7);
-        assert!(*heap.peek().unwrap() == box 27);
-        heap.push(box 103);
-        assert_eq!(heap.len(), 8);
-        assert!(*heap.peek().unwrap() == box 103);
-    }
-
-    #[test]
-    fn test_push_pop() {
-        let mut heap = BinaryHeap::from_vec(vec![5, 5, 2, 1, 3]);
-        assert_eq!(heap.len(), 5);
-        assert_eq!(heap.push_pop(6), 6);
-        assert_eq!(heap.len(), 5);
-        assert_eq!(heap.push_pop(0), 5);
-        assert_eq!(heap.len(), 5);
-        assert_eq!(heap.push_pop(4), 5);
-        assert_eq!(heap.len(), 5);
-        assert_eq!(heap.push_pop(1), 4);
-        assert_eq!(heap.len(), 5);
-    }
-
-    #[test]
-    fn test_replace() {
-        let mut heap = BinaryHeap::from_vec(vec![5, 5, 2, 1, 3]);
-        assert_eq!(heap.len(), 5);
-        assert_eq!(heap.replace(6).unwrap(), 5);
-        assert_eq!(heap.len(), 5);
-        assert_eq!(heap.replace(0).unwrap(), 6);
-        assert_eq!(heap.len(), 5);
-        assert_eq!(heap.replace(4).unwrap(), 5);
-        assert_eq!(heap.len(), 5);
-        assert_eq!(heap.replace(1).unwrap(), 4);
-        assert_eq!(heap.len(), 5);
-    }
-
-    fn check_to_vec(mut data: Vec<i32>) {
-        let heap = BinaryHeap::from_vec(data.clone());
-        let mut v = heap.clone().into_vec();
-        v.sort();
-        data.sort();
-
-        assert_eq!(v, data);
-        assert_eq!(heap.into_sorted_vec(), data);
-    }
-
-    #[test]
-    fn test_to_vec() {
-        check_to_vec(vec![]);
-        check_to_vec(vec![5]);
-        check_to_vec(vec![3, 2]);
-        check_to_vec(vec![2, 3]);
-        check_to_vec(vec![5, 1, 2]);
-        check_to_vec(vec![1, 100, 2, 3]);
-        check_to_vec(vec![1, 3, 5, 7, 9, 2, 4, 6, 8, 0]);
-        check_to_vec(vec![2, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1]);
-        check_to_vec(vec![9, 11, 9, 9, 9, 9, 11, 2, 3, 4, 11, 9, 0, 0, 0, 0]);
-        check_to_vec(vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
-        check_to_vec(vec![10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]);
-        check_to_vec(vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 1, 2]);
-        check_to_vec(vec![5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]);
-    }
-
-    #[test]
-    fn test_empty_pop() {
-        let mut heap = BinaryHeap::<i32>::new();
-        assert!(heap.pop().is_none());
-    }
-
-    #[test]
-    fn test_empty_peek() {
-        let empty = BinaryHeap::<i32>::new();
-        assert!(empty.peek().is_none());
-    }
-
-    #[test]
-    fn test_empty_replace() {
-        let mut heap = BinaryHeap::new();
-        assert!(heap.replace(5).is_none());
-    }
-
-    #[test]
-    fn test_from_iter() {
-        let xs = vec![9, 8, 7, 6, 5, 4, 3, 2, 1];
-
-        let mut q: BinaryHeap<_> = xs.iter().rev().cloned().collect();
-
-        for &x in &xs {
-            assert_eq!(q.pop().unwrap(), x);
-        }
-    }
-
-    #[test]
-    fn test_drain() {
-        let mut q: BinaryHeap<_> = [9, 8, 7, 6, 5, 4, 3, 2, 1].iter().cloned().collect();
-
-        assert_eq!(q.drain().take(5).count(), 5);
-
-        assert!(q.is_empty());
-    }
-}
diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs
index 7524fb6cf18..90fbe04d348 100644
--- a/src/libcollections/bit.rs
+++ b/src/libcollections/bit.rs
@@ -133,7 +133,7 @@ static FALSE: bool = false;
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::collections::BitVec;
 ///
 /// let mut bv = BitVec::from_elem(10, false);
@@ -1903,1183 +1903,3 @@ impl<'a> IntoIterator for &'a BitSet {
         self.iter()
     }
 }
-
-#[cfg(test)]
-mod tests {
-    use prelude::*;
-    use core::u32;
-
-    use super::BitVec;
-
-    #[test]
-    fn test_to_str() {
-        let zerolen = BitVec::new();
-        assert_eq!(format!("{:?}", zerolen), "");
-
-        let eightbits = BitVec::from_elem(8, false);
-        assert_eq!(format!("{:?}", eightbits), "00000000")
-    }
-
-    #[test]
-    fn test_0_elements() {
-        let act = BitVec::new();
-        let exp = Vec::new();
-        assert!(act.eq_vec(&exp));
-        assert!(act.none() && act.all());
-    }
-
-    #[test]
-    fn test_1_element() {
-        let mut act = BitVec::from_elem(1, false);
-        assert!(act.eq_vec(&[false]));
-        assert!(act.none() && !act.all());
-        act = BitVec::from_elem(1, true);
-        assert!(act.eq_vec(&[true]));
-        assert!(!act.none() && act.all());
-    }
-
-    #[test]
-    fn test_2_elements() {
-        let mut b = BitVec::from_elem(2, false);
-        b.set(0, true);
-        b.set(1, false);
-        assert_eq!(format!("{:?}", b), "10");
-        assert!(!b.none() && !b.all());
-    }
-
-    #[test]
-    fn test_10_elements() {
-        let mut act;
-        // all 0
-
-        act = BitVec::from_elem(10, false);
-        assert!((act.eq_vec(
-                    &[false, false, false, false, false, false, false, false, false, false])));
-        assert!(act.none() && !act.all());
-        // all 1
-
-        act = BitVec::from_elem(10, true);
-        assert!((act.eq_vec(&[true, true, true, true, true, true, true, true, true, true])));
-        assert!(!act.none() && act.all());
-        // mixed
-
-        act = BitVec::from_elem(10, false);
-        act.set(0, true);
-        act.set(1, true);
-        act.set(2, true);
-        act.set(3, true);
-        act.set(4, true);
-        assert!((act.eq_vec(&[true, true, true, true, true, false, false, false, false, false])));
-        assert!(!act.none() && !act.all());
-        // mixed
-
-        act = BitVec::from_elem(10, false);
-        act.set(5, true);
-        act.set(6, true);
-        act.set(7, true);
-        act.set(8, true);
-        act.set(9, true);
-        assert!((act.eq_vec(&[false, false, false, false, false, true, true, true, true, true])));
-        assert!(!act.none() && !act.all());
-        // mixed
-
-        act = BitVec::from_elem(10, false);
-        act.set(0, true);
-        act.set(3, true);
-        act.set(6, true);
-        act.set(9, true);
-        assert!((act.eq_vec(&[true, false, false, true, false, false, true, false, false, true])));
-        assert!(!act.none() && !act.all());
-    }
-
-    #[test]
-    fn test_31_elements() {
-        let mut act;
-        // all 0
-
-        act = BitVec::from_elem(31, false);
-        assert!(act.eq_vec(
-                &[false, false, false, false, false, false, false, false, false, false, false,
-                  false, false, false, false, false, false, false, false, false, false, false,
-                  false, false, false, false, false, false, false, false, false]));
-        assert!(act.none() && !act.all());
-        // all 1
-
-        act = BitVec::from_elem(31, true);
-        assert!(act.eq_vec(
-                &[true, true, true, true, true, true, true, true, true, true, true, true, true,
-                  true, true, true, true, true, true, true, true, true, true, true, true, true,
-                  true, true, true, true, true]));
-        assert!(!act.none() && act.all());
-        // mixed
-
-        act = BitVec::from_elem(31, false);
-        act.set(0, true);
-        act.set(1, true);
-        act.set(2, true);
-        act.set(3, true);
-        act.set(4, true);
-        act.set(5, true);
-        act.set(6, true);
-        act.set(7, true);
-        assert!(act.eq_vec(
-                &[true, true, true, true, true, true, true, true, false, false, false, false, false,
-                  false, false, false, false, false, false, false, false, false, false, false,
-                  false, false, false, false, false, false, false]));
-        assert!(!act.none() && !act.all());
-        // mixed
-
-        act = BitVec::from_elem(31, false);
-        act.set(16, true);
-        act.set(17, true);
-        act.set(18, true);
-        act.set(19, true);
-        act.set(20, true);
-        act.set(21, true);
-        act.set(22, true);
-        act.set(23, true);
-        assert!(act.eq_vec(
-                &[false, false, false, false, false, false, false, false, false, false, false,
-                  false, false, false, false, false, true, true, true, true, true, true, true, true,
-                  false, false, false, false, false, false, false]));
-        assert!(!act.none() && !act.all());
-        // mixed
-
-        act = BitVec::from_elem(31, false);
-        act.set(24, true);
-        act.set(25, true);
-        act.set(26, true);
-        act.set(27, true);
-        act.set(28, true);
-        act.set(29, true);
-        act.set(30, true);
-        assert!(act.eq_vec(
-                &[false, false, false, false, false, false, false, false, false, false, false,
-                  false, false, false, false, false, false, false, false, false, false, false,
-                  false, false, true, true, true, true, true, true, true]));
-        assert!(!act.none() && !act.all());
-        // mixed
-
-        act = BitVec::from_elem(31, false);
-        act.set(3, true);
-        act.set(17, true);
-        act.set(30, true);
-        assert!(act.eq_vec(
-                &[false, false, false, true, false, false, false, false, false, false, false, false,
-                  false, false, false, false, false, true, false, false, false, false, false, false,
-                  false, false, false, false, false, false, true]));
-        assert!(!act.none() && !act.all());
-    }
-
-    #[test]
-    fn test_32_elements() {
-        let mut act;
-        // all 0
-
-        act = BitVec::from_elem(32, false);
-        assert!(act.eq_vec(
-                &[false, false, false, false, false, false, false, false, false, false, false,
-                  false, false, false, false, false, false, false, false, false, false, false,
-                  false, false, false, false, false, false, false, false, false, false]));
-        assert!(act.none() && !act.all());
-        // all 1
-
-        act = BitVec::from_elem(32, true);
-        assert!(act.eq_vec(
-                &[true, true, true, true, true, true, true, true, true, true, true, true, true,
-                  true, true, true, true, true, true, true, true, true, true, true, true, true,
-                  true, true, true, true, true, true]));
-        assert!(!act.none() && act.all());
-        // mixed
-
-        act = BitVec::from_elem(32, false);
-        act.set(0, true);
-        act.set(1, true);
-        act.set(2, true);
-        act.set(3, true);
-        act.set(4, true);
-        act.set(5, true);
-        act.set(6, true);
-        act.set(7, true);
-        assert!(act.eq_vec(
-                &[true, true, true, true, true, true, true, true, false, false, false, false, false,
-                  false, false, false, false, false, false, false, false, false, false, false,
-                  false, false, false, false, false, false, false, false]));
-        assert!(!act.none() && !act.all());
-        // mixed
-
-        act = BitVec::from_elem(32, false);
-        act.set(16, true);
-        act.set(17, true);
-        act.set(18, true);
-        act.set(19, true);
-        act.set(20, true);
-        act.set(21, true);
-        act.set(22, true);
-        act.set(23, true);
-        assert!(act.eq_vec(
-                &[false, false, false, false, false, false, false, false, false, false, false,
-                  false, false, false, false, false, true, true, true, true, true, true, true, true,
-                  false, false, false, false, false, false, false, false]));
-        assert!(!act.none() && !act.all());
-        // mixed
-
-        act = BitVec::from_elem(32, false);
-        act.set(24, true);
-        act.set(25, true);
-        act.set(26, true);
-        act.set(27, true);
-        act.set(28, true);
-        act.set(29, true);
-        act.set(30, true);
-        act.set(31, true);
-        assert!(act.eq_vec(
-                &[false, false, false, false, false, false, false, false, false, false, false,
-                  false, false, false, false, false, false, false, false, false, false, false,
-                  false, false, true, true, true, true, true, true, true, true]));
-        assert!(!act.none() && !act.all());
-        // mixed
-
-        act = BitVec::from_elem(32, false);
-        act.set(3, true);
-        act.set(17, true);
-        act.set(30, true);
-        act.set(31, true);
-        assert!(act.eq_vec(
-                &[false, false, false, true, false, false, false, false, false, false, false, false,
-                  false, false, false, false, false, true, false, false, false, false, false, false,
-                  false, false, false, false, false, false, true, true]));
-        assert!(!act.none() && !act.all());
-    }
-
-    #[test]
-    fn test_33_elements() {
-        let mut act;
-        // all 0
-
-        act = BitVec::from_elem(33, false);
-        assert!(act.eq_vec(
-                &[false, false, false, false, false, false, false, false, false, false, false,
-                  false, false, false, false, false, false, false, false, false, false, false,
-                  false, false, false, false, false, false, false, false, false, false, false]));
-        assert!(act.none() && !act.all());
-        // all 1
-
-        act = BitVec::from_elem(33, true);
-        assert!(act.eq_vec(
-                &[true, true, true, true, true, true, true, true, true, true, true, true, true,
-                  true, true, true, true, true, true, true, true, true, true, true, true, true,
-                  true, true, true, true, true, true, true]));
-        assert!(!act.none() && act.all());
-        // mixed
-
-        act = BitVec::from_elem(33, false);
-        act.set(0, true);
-        act.set(1, true);
-        act.set(2, true);
-        act.set(3, true);
-        act.set(4, true);
-        act.set(5, true);
-        act.set(6, true);
-        act.set(7, true);
-        assert!(act.eq_vec(
-                &[true, true, true, true, true, true, true, true, false, false, false, false, false,
-                  false, false, false, false, false, false, false, false, false, false, false,
-                  false, false, false, false, false, false, false, false, false]));
-        assert!(!act.none() && !act.all());
-        // mixed
-
-        act = BitVec::from_elem(33, false);
-        act.set(16, true);
-        act.set(17, true);
-        act.set(18, true);
-        act.set(19, true);
-        act.set(20, true);
-        act.set(21, true);
-        act.set(22, true);
-        act.set(23, true);
-        assert!(act.eq_vec(
-                &[false, false, false, false, false, false, false, false, false, false, false,
-                  false, false, false, false, false, true, true, true, true, true, true, true, true,
-                  false, false, false, false, false, false, false, false, false]));
-        assert!(!act.none() && !act.all());
-        // mixed
-
-        act = BitVec::from_elem(33, false);
-        act.set(24, true);
-        act.set(25, true);
-        act.set(26, true);
-        act.set(27, true);
-        act.set(28, true);
-        act.set(29, true);
-        act.set(30, true);
-        act.set(31, true);
-        assert!(act.eq_vec(
-                &[false, false, false, false, false, false, false, false, false, false, false,
-                  false, false, false, false, false, false, false, false, false, false, false,
-                  false, false, true, true, true, true, true, true, true, true, false]));
-        assert!(!act.none() && !act.all());
-        // mixed
-
-        act = BitVec::from_elem(33, false);
-        act.set(3, true);
-        act.set(17, true);
-        act.set(30, true);
-        act.set(31, true);
-        act.set(32, true);
-        assert!(act.eq_vec(
-                &[false, false, false, true, false, false, false, false, false, false, false, false,
-                  false, false, false, false, false, true, false, false, false, false, false, false,
-                  false, false, false, false, false, false, true, true, true]));
-        assert!(!act.none() && !act.all());
-    }
-
-    #[test]
-    fn test_equal_differing_sizes() {
-        let v0 = BitVec::from_elem(10, false);
-        let v1 = BitVec::from_elem(11, false);
-        assert!(v0 != v1);
-    }
-
-    #[test]
-    fn test_equal_greatly_differing_sizes() {
-        let v0 = BitVec::from_elem(10, false);
-        let v1 = BitVec::from_elem(110, false);
-        assert!(v0 != v1);
-    }
-
-    #[test]
-    fn test_equal_sneaky_small() {
-        let mut a = BitVec::from_elem(1, false);
-        a.set(0, true);
-
-        let mut b = BitVec::from_elem(1, true);
-        b.set(0, true);
-
-        assert_eq!(a, b);
-    }
-
-    #[test]
-    fn test_equal_sneaky_big() {
-        let mut a = BitVec::from_elem(100, false);
-        for i in 0..100 {
-            a.set(i, true);
-        }
-
-        let mut b = BitVec::from_elem(100, true);
-        for i in 0..100 {
-            b.set(i, true);
-        }
-
-        assert_eq!(a, b);
-    }
-
-    #[test]
-    fn test_from_bytes() {
-        let bit_vec = BitVec::from_bytes(&[0b10110110, 0b00000000, 0b11111111]);
-        let str = concat!("10110110", "00000000", "11111111");
-        assert_eq!(format!("{:?}", bit_vec), str);
-    }
-
-    #[test]
-    fn test_to_bytes() {
-        let mut bv = BitVec::from_elem(3, true);
-        bv.set(1, false);
-        assert_eq!(bv.to_bytes(), [0b10100000]);
-
-        let mut bv = BitVec::from_elem(9, false);
-        bv.set(2, true);
-        bv.set(8, true);
-        assert_eq!(bv.to_bytes(), [0b00100000, 0b10000000]);
-    }
-
-    #[test]
-    fn test_from_bools() {
-        let bools = vec![true, false, true, true];
-        let bit_vec: BitVec = bools.iter().map(|n| *n).collect();
-        assert_eq!(format!("{:?}", bit_vec), "1011");
-    }
-
-    #[test]
-    fn test_to_bools() {
-        let bools = vec![false, false, true, false, false, true, true, false];
-        assert_eq!(BitVec::from_bytes(&[0b00100110]).iter().collect::<Vec<bool>>(), bools);
-    }
-
-    #[test]
-    fn test_bit_vec_iterator() {
-        let bools = vec![true, false, true, true];
-        let bit_vec: BitVec = bools.iter().map(|n| *n).collect();
-
-        assert_eq!(bit_vec.iter().collect::<Vec<bool>>(), bools);
-
-        let long: Vec<_> = (0..10000).map(|i| i % 2 == 0).collect();
-        let bit_vec: BitVec = long.iter().map(|n| *n).collect();
-        assert_eq!(bit_vec.iter().collect::<Vec<bool>>(), long)
-    }
-
-    #[test]
-    fn test_small_difference() {
-        let mut b1 = BitVec::from_elem(3, false);
-        let mut b2 = BitVec::from_elem(3, false);
-        b1.set(0, true);
-        b1.set(1, true);
-        b2.set(1, true);
-        b2.set(2, true);
-        assert!(b1.difference(&b2));
-        assert!(b1[0]);
-        assert!(!b1[1]);
-        assert!(!b1[2]);
-    }
-
-    #[test]
-    fn test_big_difference() {
-        let mut b1 = BitVec::from_elem(100, false);
-        let mut b2 = BitVec::from_elem(100, false);
-        b1.set(0, true);
-        b1.set(40, true);
-        b2.set(40, true);
-        b2.set(80, true);
-        assert!(b1.difference(&b2));
-        assert!(b1[0]);
-        assert!(!b1[40]);
-        assert!(!b1[80]);
-    }
-
-    #[test]
-    fn test_small_clear() {
-        let mut b = BitVec::from_elem(14, true);
-        assert!(!b.none() && b.all());
-        b.clear();
-        assert!(b.none() && !b.all());
-    }
-
-    #[test]
-    fn test_big_clear() {
-        let mut b = BitVec::from_elem(140, true);
-        assert!(!b.none() && b.all());
-        b.clear();
-        assert!(b.none() && !b.all());
-    }
-
-    #[test]
-    fn test_bit_vec_lt() {
-        let mut a = BitVec::from_elem(5, false);
-        let mut b = BitVec::from_elem(5, false);
-
-        assert!(!(a < b) && !(b < a));
-        b.set(2, true);
-        assert!(a < b);
-        a.set(3, true);
-        assert!(a < b);
-        a.set(2, true);
-        assert!(!(a < b) && b < a);
-        b.set(0, true);
-        assert!(a < b);
-    }
-
-    #[test]
-    fn test_ord() {
-        let mut a = BitVec::from_elem(5, false);
-        let mut b = BitVec::from_elem(5, false);
-
-        assert!(a <= b && a >= b);
-        a.set(1, true);
-        assert!(a > b && a >= b);
-        assert!(b < a && b <= a);
-        b.set(1, true);
-        b.set(2, true);
-        assert!(b > a && b >= a);
-        assert!(a < b && a <= b);
-    }
-
-
-    #[test]
-    fn test_small_bit_vec_tests() {
-        let v = BitVec::from_bytes(&[0]);
-        assert!(!v.all());
-        assert!(!v.any());
-        assert!(v.none());
-
-        let v = BitVec::from_bytes(&[0b00010100]);
-        assert!(!v.all());
-        assert!(v.any());
-        assert!(!v.none());
-
-        let v = BitVec::from_bytes(&[0xFF]);
-        assert!(v.all());
-        assert!(v.any());
-        assert!(!v.none());
-    }
-
-    #[test]
-    fn test_big_bit_vec_tests() {
-        let v = BitVec::from_bytes(&[ // 88 bits
-            0, 0, 0, 0,
-            0, 0, 0, 0,
-            0, 0, 0]);
-        assert!(!v.all());
-        assert!(!v.any());
-        assert!(v.none());
-
-        let v = BitVec::from_bytes(&[ // 88 bits
-            0, 0, 0b00010100, 0,
-            0, 0, 0, 0b00110100,
-            0, 0, 0]);
-        assert!(!v.all());
-        assert!(v.any());
-        assert!(!v.none());
-
-        let v = BitVec::from_bytes(&[ // 88 bits
-            0xFF, 0xFF, 0xFF, 0xFF,
-            0xFF, 0xFF, 0xFF, 0xFF,
-            0xFF, 0xFF, 0xFF]);
-        assert!(v.all());
-        assert!(v.any());
-        assert!(!v.none());
-    }
-
-    #[test]
-    fn test_bit_vec_push_pop() {
-        let mut s = BitVec::from_elem(5 * u32::BITS as usize - 2, false);
-        assert_eq!(s.len(), 5 * u32::BITS as usize - 2);
-        assert_eq!(s[5 * u32::BITS as usize - 3], false);
-        s.push(true);
-        s.push(true);
-        assert_eq!(s[5 * u32::BITS as usize - 2], true);
-        assert_eq!(s[5 * u32::BITS as usize - 1], true);
-        // Here the internal vector will need to be extended
-        s.push(false);
-        assert_eq!(s[5 * u32::BITS as usize], false);
-        s.push(false);
-        assert_eq!(s[5 * u32::BITS as usize + 1], false);
-        assert_eq!(s.len(), 5 * u32::BITS as usize + 2);
-        // Pop it all off
-        assert_eq!(s.pop(), Some(false));
-        assert_eq!(s.pop(), Some(false));
-        assert_eq!(s.pop(), Some(true));
-        assert_eq!(s.pop(), Some(true));
-        assert_eq!(s.len(), 5 * u32::BITS as usize - 2);
-    }
-
-    #[test]
-    fn test_bit_vec_truncate() {
-        let mut s = BitVec::from_elem(5 * u32::BITS as usize, true);
-
-        assert_eq!(s, BitVec::from_elem(5 * u32::BITS as usize, true));
-        assert_eq!(s.len(), 5 * u32::BITS as usize);
-        s.truncate(4 * u32::BITS as usize);
-        assert_eq!(s, BitVec::from_elem(4 * u32::BITS as usize, true));
-        assert_eq!(s.len(), 4 * u32::BITS as usize);
-        // Truncating to a size > s.len() should be a noop
-        s.truncate(5 * u32::BITS as usize);
-        assert_eq!(s, BitVec::from_elem(4 * u32::BITS as usize, true));
-        assert_eq!(s.len(), 4 * u32::BITS as usize);
-        s.truncate(3 * u32::BITS as usize - 10);
-        assert_eq!(s, BitVec::from_elem(3 * u32::BITS as usize - 10, true));
-        assert_eq!(s.len(), 3 * u32::BITS as usize - 10);
-        s.truncate(0);
-        assert_eq!(s, BitVec::from_elem(0, true));
-        assert_eq!(s.len(), 0);
-    }
-
-    #[test]
-    fn test_bit_vec_reserve() {
-        let mut s = BitVec::from_elem(5 * u32::BITS as usize, true);
-        // Check capacity
-        assert!(s.capacity() >= 5 * u32::BITS as usize);
-        s.reserve(2 * u32::BITS as usize);
-        assert!(s.capacity() >= 7 * u32::BITS as usize);
-        s.reserve(7 * u32::BITS as usize);
-        assert!(s.capacity() >= 12 * u32::BITS as usize);
-        s.reserve_exact(7 * u32::BITS as usize);
-        assert!(s.capacity() >= 12 * u32::BITS as usize);
-        s.reserve(7 * u32::BITS as usize + 1);
-        assert!(s.capacity() >= 12 * u32::BITS as usize + 1);
-        // Check that length hasn't changed
-        assert_eq!(s.len(), 5 * u32::BITS as usize);
-        s.push(true);
-        s.push(false);
-        s.push(true);
-        assert_eq!(s[5 * u32::BITS as usize - 1], true);
-        assert_eq!(s[5 * u32::BITS as usize - 0], true);
-        assert_eq!(s[5 * u32::BITS as usize + 1], false);
-        assert_eq!(s[5 * u32::BITS as usize + 2], true);
-    }
-
-    #[test]
-    fn test_bit_vec_grow() {
-        let mut bit_vec = BitVec::from_bytes(&[0b10110110, 0b00000000, 0b10101010]);
-        bit_vec.grow(32, true);
-        assert_eq!(bit_vec, BitVec::from_bytes(&[0b10110110, 0b00000000, 0b10101010,
-                                     0xFF, 0xFF, 0xFF, 0xFF]));
-        bit_vec.grow(64, false);
-        assert_eq!(bit_vec, BitVec::from_bytes(&[0b10110110, 0b00000000, 0b10101010,
-                                     0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0]));
-        bit_vec.grow(16, true);
-        assert_eq!(bit_vec, BitVec::from_bytes(&[0b10110110, 0b00000000, 0b10101010,
-                                     0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF]));
-    }
-
-    #[test]
-    fn test_bit_vec_extend() {
-        let mut bit_vec = BitVec::from_bytes(&[0b10110110, 0b00000000, 0b11111111]);
-        let ext = BitVec::from_bytes(&[0b01001001, 0b10010010, 0b10111101]);
-        bit_vec.extend(ext.iter());
-        assert_eq!(bit_vec, BitVec::from_bytes(&[0b10110110, 0b00000000, 0b11111111,
-                                     0b01001001, 0b10010010, 0b10111101]));
-    }
-}
-
-
-
-
-#[cfg(test)]
-mod bit_vec_bench {
-    use std::prelude::v1::*;
-    use std::rand;
-    use std::rand::Rng;
-    use std::u32;
-    use test::{Bencher, black_box};
-
-    use super::BitVec;
-
-    const BENCH_BITS : usize = 1 << 14;
-
-    fn rng() -> rand::IsaacRng {
-        let seed: &[_] = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
-        rand::SeedableRng::from_seed(seed)
-    }
-
-    #[bench]
-    fn bench_usize_small(b: &mut Bencher) {
-        let mut r = rng();
-        let mut bit_vec = 0 as usize;
-        b.iter(|| {
-            for _ in 0..100 {
-                bit_vec |= 1 << ((r.next_u32() as usize) % u32::BITS as usize);
-            }
-            black_box(&bit_vec);
-        });
-    }
-
-    #[bench]
-    fn bench_bit_set_big_fixed(b: &mut Bencher) {
-        let mut r = rng();
-        let mut bit_vec = BitVec::from_elem(BENCH_BITS, false);
-        b.iter(|| {
-            for _ in 0..100 {
-                bit_vec.set((r.next_u32() as usize) % BENCH_BITS, true);
-            }
-            black_box(&bit_vec);
-        });
-    }
-
-    #[bench]
-    fn bench_bit_set_big_variable(b: &mut Bencher) {
-        let mut r = rng();
-        let mut bit_vec = BitVec::from_elem(BENCH_BITS, false);
-        b.iter(|| {
-            for _ in 0..100 {
-                bit_vec.set((r.next_u32() as usize) % BENCH_BITS, r.gen());
-            }
-            black_box(&bit_vec);
-        });
-    }
-
-    #[bench]
-    fn bench_bit_set_small(b: &mut Bencher) {
-        let mut r = rng();
-        let mut bit_vec = BitVec::from_elem(u32::BITS as usize, false);
-        b.iter(|| {
-            for _ in 0..100 {
-                bit_vec.set((r.next_u32() as usize) % u32::BITS as usize, true);
-            }
-            black_box(&bit_vec);
-        });
-    }
-
-    #[bench]
-    fn bench_bit_vec_big_union(b: &mut Bencher) {
-        let mut b1 = BitVec::from_elem(BENCH_BITS, false);
-        let b2 = BitVec::from_elem(BENCH_BITS, false);
-        b.iter(|| {
-            b1.union(&b2)
-        })
-    }
-
-    #[bench]
-    fn bench_bit_vec_small_iter(b: &mut Bencher) {
-        let bit_vec = BitVec::from_elem(u32::BITS as usize, false);
-        b.iter(|| {
-            let mut sum = 0;
-            for _ in 0..10 {
-                for pres in &bit_vec {
-                    sum += pres as usize;
-                }
-            }
-            sum
-        })
-    }
-
-    #[bench]
-    fn bench_bit_vec_big_iter(b: &mut Bencher) {
-        let bit_vec = BitVec::from_elem(BENCH_BITS, false);
-        b.iter(|| {
-            let mut sum = 0;
-            for pres in &bit_vec {
-                sum += pres as usize;
-            }
-            sum
-        })
-    }
-}
-
-
-
-
-
-
-
-#[cfg(test)]
-mod bit_set_test {
-    use prelude::*;
-    use std::iter::range_step;
-
-    use super::{BitVec, BitSet};
-
-    #[test]
-    fn test_bit_set_show() {
-        let mut s = BitSet::new();
-        s.insert(1);
-        s.insert(10);
-        s.insert(50);
-        s.insert(2);
-        assert_eq!("{1, 2, 10, 50}", format!("{:?}", s));
-    }
-
-    #[test]
-    fn test_bit_set_from_usizes() {
-        let usizes = vec![0, 2, 2, 3];
-        let a: BitSet = usizes.into_iter().collect();
-        let mut b = BitSet::new();
-        b.insert(0);
-        b.insert(2);
-        b.insert(3);
-        assert_eq!(a, b);
-    }
-
-    #[test]
-    fn test_bit_set_iterator() {
-        let usizes = vec![0, 2, 2, 3];
-        let bit_vec: BitSet = usizes.into_iter().collect();
-
-        let idxs: Vec<_> = bit_vec.iter().collect();
-        assert_eq!(idxs, [0, 2, 3]);
-
-        let long: BitSet = (0..10000).filter(|&n| n % 2 == 0).collect();
-        let real: Vec<_> = range_step(0, 10000, 2).collect();
-
-        let idxs: Vec<_> = long.iter().collect();
-        assert_eq!(idxs, real);
-    }
-
-    #[test]
-    fn test_bit_set_frombit_vec_init() {
-        let bools = [true, false];
-        let lengths = [10, 64, 100];
-        for &b in &bools {
-            for &l in &lengths {
-                let bitset = BitSet::from_bit_vec(BitVec::from_elem(l, b));
-                assert_eq!(bitset.contains(&1), b);
-                assert_eq!(bitset.contains(&(l-1)), b);
-                assert!(!bitset.contains(&l));
-            }
-        }
-    }
-
-    #[test]
-    fn test_bit_vec_masking() {
-        let b = BitVec::from_elem(140, true);
-        let mut bs = BitSet::from_bit_vec(b);
-        assert!(bs.contains(&139));
-        assert!(!bs.contains(&140));
-        assert!(bs.insert(150));
-        assert!(!bs.contains(&140));
-        assert!(!bs.contains(&149));
-        assert!(bs.contains(&150));
-        assert!(!bs.contains(&151));
-    }
-
-    #[test]
-    fn test_bit_set_basic() {
-        let mut b = BitSet::new();
-        assert!(b.insert(3));
-        assert!(!b.insert(3));
-        assert!(b.contains(&3));
-        assert!(b.insert(4));
-        assert!(!b.insert(4));
-        assert!(b.contains(&3));
-        assert!(b.insert(400));
-        assert!(!b.insert(400));
-        assert!(b.contains(&400));
-        assert_eq!(b.len(), 3);
-    }
-
-    #[test]
-    fn test_bit_set_intersection() {
-        let mut a = BitSet::new();
-        let mut b = BitSet::new();
-
-        assert!(a.insert(11));
-        assert!(a.insert(1));
-        assert!(a.insert(3));
-        assert!(a.insert(77));
-        assert!(a.insert(103));
-        assert!(a.insert(5));
-
-        assert!(b.insert(2));
-        assert!(b.insert(11));
-        assert!(b.insert(77));
-        assert!(b.insert(5));
-        assert!(b.insert(3));
-
-        let expected = [3, 5, 11, 77];
-        let actual: Vec<_> = a.intersection(&b).collect();
-        assert_eq!(actual, expected);
-    }
-
-    #[test]
-    fn test_bit_set_difference() {
-        let mut a = BitSet::new();
-        let mut b = BitSet::new();
-
-        assert!(a.insert(1));
-        assert!(a.insert(3));
-        assert!(a.insert(5));
-        assert!(a.insert(200));
-        assert!(a.insert(500));
-
-        assert!(b.insert(3));
-        assert!(b.insert(200));
-
-        let expected = [1, 5, 500];
-        let actual: Vec<_> = a.difference(&b).collect();
-        assert_eq!(actual, expected);
-    }
-
-    #[test]
-    fn test_bit_set_symmetric_difference() {
-        let mut a = BitSet::new();
-        let mut b = BitSet::new();
-
-        assert!(a.insert(1));
-        assert!(a.insert(3));
-        assert!(a.insert(5));
-        assert!(a.insert(9));
-        assert!(a.insert(11));
-
-        assert!(b.insert(3));
-        assert!(b.insert(9));
-        assert!(b.insert(14));
-        assert!(b.insert(220));
-
-        let expected = [1, 5, 11, 14, 220];
-        let actual: Vec<_> = a.symmetric_difference(&b).collect();
-        assert_eq!(actual, expected);
-    }
-
-    #[test]
-    fn test_bit_set_union() {
-        let mut a = BitSet::new();
-        let mut b = BitSet::new();
-        assert!(a.insert(1));
-        assert!(a.insert(3));
-        assert!(a.insert(5));
-        assert!(a.insert(9));
-        assert!(a.insert(11));
-        assert!(a.insert(160));
-        assert!(a.insert(19));
-        assert!(a.insert(24));
-        assert!(a.insert(200));
-
-        assert!(b.insert(1));
-        assert!(b.insert(5));
-        assert!(b.insert(9));
-        assert!(b.insert(13));
-        assert!(b.insert(19));
-
-        let expected = [1, 3, 5, 9, 11, 13, 19, 24, 160, 200];
-        let actual: Vec<_> = a.union(&b).collect();
-        assert_eq!(actual, expected);
-    }
-
-    #[test]
-    fn test_bit_set_subset() {
-        let mut set1 = BitSet::new();
-        let mut set2 = BitSet::new();
-
-        assert!(set1.is_subset(&set2)); //  {}  {}
-        set2.insert(100);
-        assert!(set1.is_subset(&set2)); //  {}  { 1 }
-        set2.insert(200);
-        assert!(set1.is_subset(&set2)); //  {}  { 1, 2 }
-        set1.insert(200);
-        assert!(set1.is_subset(&set2)); //  { 2 }  { 1, 2 }
-        set1.insert(300);
-        assert!(!set1.is_subset(&set2)); // { 2, 3 }  { 1, 2 }
-        set2.insert(300);
-        assert!(set1.is_subset(&set2)); // { 2, 3 }  { 1, 2, 3 }
-        set2.insert(400);
-        assert!(set1.is_subset(&set2)); // { 2, 3 }  { 1, 2, 3, 4 }
-        set2.remove(&100);
-        assert!(set1.is_subset(&set2)); // { 2, 3 }  { 2, 3, 4 }
-        set2.remove(&300);
-        assert!(!set1.is_subset(&set2)); // { 2, 3 }  { 2, 4 }
-        set1.remove(&300);
-        assert!(set1.is_subset(&set2)); // { 2 }  { 2, 4 }
-    }
-
-    #[test]
-    fn test_bit_set_is_disjoint() {
-        let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
-        let b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01000000]));
-        let c = BitSet::new();
-        let d = BitSet::from_bit_vec(BitVec::from_bytes(&[0b00110000]));
-
-        assert!(!a.is_disjoint(&d));
-        assert!(!d.is_disjoint(&a));
-
-        assert!(a.is_disjoint(&b));
-        assert!(a.is_disjoint(&c));
-        assert!(b.is_disjoint(&a));
-        assert!(b.is_disjoint(&c));
-        assert!(c.is_disjoint(&a));
-        assert!(c.is_disjoint(&b));
-    }
-
-    #[test]
-    fn test_bit_set_union_with() {
-        //a should grow to include larger elements
-        let mut a = BitSet::new();
-        a.insert(0);
-        let mut b = BitSet::new();
-        b.insert(5);
-        let expected = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10000100]));
-        a.union_with(&b);
-        assert_eq!(a, expected);
-
-        // Standard
-        let mut a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
-        let mut b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01100010]));
-        let c = a.clone();
-        a.union_with(&b);
-        b.union_with(&c);
-        assert_eq!(a.len(), 4);
-        assert_eq!(b.len(), 4);
-    }
-
-    #[test]
-    fn test_bit_set_intersect_with() {
-        // Explicitly 0'ed bits
-        let mut a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
-        let mut b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b00000000]));
-        let c = a.clone();
-        a.intersect_with(&b);
-        b.intersect_with(&c);
-        assert!(a.is_empty());
-        assert!(b.is_empty());
-
-        // Uninitialized bits should behave like 0's
-        let mut a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
-        let mut b = BitSet::new();
-        let c = a.clone();
-        a.intersect_with(&b);
-        b.intersect_with(&c);
-        assert!(a.is_empty());
-        assert!(b.is_empty());
-
-        // Standard
-        let mut a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
-        let mut b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01100010]));
-        let c = a.clone();
-        a.intersect_with(&b);
-        b.intersect_with(&c);
-        assert_eq!(a.len(), 2);
-        assert_eq!(b.len(), 2);
-    }
-
-    #[test]
-    fn test_bit_set_difference_with() {
-        // Explicitly 0'ed bits
-        let mut a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b00000000]));
-        let b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
-        a.difference_with(&b);
-        assert!(a.is_empty());
-
-        // Uninitialized bits should behave like 0's
-        let mut a = BitSet::new();
-        let b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b11111111]));
-        a.difference_with(&b);
-        assert!(a.is_empty());
-
-        // Standard
-        let mut a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
-        let mut b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01100010]));
-        let c = a.clone();
-        a.difference_with(&b);
-        b.difference_with(&c);
-        assert_eq!(a.len(), 1);
-        assert_eq!(b.len(), 1);
-    }
-
-    #[test]
-    fn test_bit_set_symmetric_difference_with() {
-        //a should grow to include larger elements
-        let mut a = BitSet::new();
-        a.insert(0);
-        a.insert(1);
-        let mut b = BitSet::new();
-        b.insert(1);
-        b.insert(5);
-        let expected = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10000100]));
-        a.symmetric_difference_with(&b);
-        assert_eq!(a, expected);
-
-        let mut a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
-        let b = BitSet::new();
-        let c = a.clone();
-        a.symmetric_difference_with(&b);
-        assert_eq!(a, c);
-
-        // Standard
-        let mut a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b11100010]));
-        let mut b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101010]));
-        let c = a.clone();
-        a.symmetric_difference_with(&b);
-        b.symmetric_difference_with(&c);
-        assert_eq!(a.len(), 2);
-        assert_eq!(b.len(), 2);
-    }
-
-    #[test]
-    fn test_bit_set_eq() {
-        let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
-        let b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b00000000]));
-        let c = BitSet::new();
-
-        assert!(a == a);
-        assert!(a != b);
-        assert!(a != c);
-        assert!(b == b);
-        assert!(b == c);
-        assert!(c == c);
-    }
-
-    #[test]
-    fn test_bit_set_cmp() {
-        let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
-        let b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b00000000]));
-        let c = BitSet::new();
-
-        assert_eq!(a.cmp(&b), Greater);
-        assert_eq!(a.cmp(&c), Greater);
-        assert_eq!(b.cmp(&a), Less);
-        assert_eq!(b.cmp(&c), Equal);
-        assert_eq!(c.cmp(&a), Less);
-        assert_eq!(c.cmp(&b), Equal);
-    }
-
-    #[test]
-    fn test_bit_vec_remove() {
-        let mut a = BitSet::new();
-
-        assert!(a.insert(1));
-        assert!(a.remove(&1));
-
-        assert!(a.insert(100));
-        assert!(a.remove(&100));
-
-        assert!(a.insert(1000));
-        assert!(a.remove(&1000));
-        a.shrink_to_fit();
-    }
-
-    #[test]
-    fn test_bit_vec_clone() {
-        let mut a = BitSet::new();
-
-        assert!(a.insert(1));
-        assert!(a.insert(100));
-        assert!(a.insert(1000));
-
-        let mut b = a.clone();
-
-        assert!(a == b);
-
-        assert!(b.remove(&1));
-        assert!(a.contains(&1));
-
-        assert!(a.remove(&1000));
-        assert!(b.contains(&1000));
-    }
-}
-
-
-
-
-
-#[cfg(test)]
-mod bit_set_bench {
-    use std::prelude::v1::*;
-    use std::rand;
-    use std::rand::Rng;
-    use std::u32;
-    use test::{Bencher, black_box};
-
-    use super::{BitVec, BitSet};
-
-    const BENCH_BITS : usize = 1 << 14;
-
-    fn rng() -> rand::IsaacRng {
-        let seed: &[_] = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
-        rand::SeedableRng::from_seed(seed)
-    }
-
-    #[bench]
-    fn bench_bit_vecset_small(b: &mut Bencher) {
-        let mut r = rng();
-        let mut bit_vec = BitSet::new();
-        b.iter(|| {
-            for _ in 0..100 {
-                bit_vec.insert((r.next_u32() as usize) % u32::BITS as usize);
-            }
-            black_box(&bit_vec);
-        });
-    }
-
-    #[bench]
-    fn bench_bit_vecset_big(b: &mut Bencher) {
-        let mut r = rng();
-        let mut bit_vec = BitSet::new();
-        b.iter(|| {
-            for _ in 0..100 {
-                bit_vec.insert((r.next_u32() as usize) % BENCH_BITS);
-            }
-            black_box(&bit_vec);
-        });
-    }
-
-    #[bench]
-    fn bench_bit_vecset_iter(b: &mut Bencher) {
-        let bit_vec = BitSet::from_bit_vec(BitVec::from_fn(BENCH_BITS,
-                                              |idx| {idx % 3 == 0}));
-        b.iter(|| {
-            let mut sum = 0;
-            for idx in &bit_vec {
-                sum += idx as usize;
-            }
-            sum
-        })
-    }
-}
diff --git a/src/libcollections/borrow.rs b/src/libcollections/borrow.rs
index 5b799d3e5c0..4bedbdeb368 100644
--- a/src/libcollections/borrow.rs
+++ b/src/libcollections/borrow.rs
@@ -129,7 +129,7 @@ impl<T> ToOwned for T where T: Clone {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::borrow::Cow;
 ///
 /// fn abs_all(input: &mut Cow<[i32]>) {
diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs
index 5de6cbe61e9..c7e1e3c9176 100644
--- a/src/libcollections/btree/map.rs
+++ b/src/libcollections/btree/map.rs
@@ -64,6 +64,10 @@ use super::node::{self, Node, Found, GoDown};
 /// and possibly other factors. Using linear search, searching for a random element is expected
 /// to take O(B log<sub>B</sub>n) comparisons, which is generally worse than a BST. In practice,
 /// however, performance is excellent.
+///
+/// It is a logic error for a key to be modified in such a way that the key's ordering relative to
+/// any other key, as determined by the `Ord` trait, changes while it is in the map. This is
+/// normally only possible through `Cell`, `RefCell`, global state, I/O, or unsafe code.
 #[derive(Clone)]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct BTreeMap<K, V> {
@@ -1595,309 +1599,3 @@ impl<K: Ord, V> BTreeMap<K, V> {
         }
     }
 }
-
-
-
-
-
-#[cfg(test)]
-mod test {
-    use prelude::*;
-    use std::iter::range_inclusive;
-
-    use super::BTreeMap;
-    use super::Entry::{Occupied, Vacant};
-    use Bound::{self, Included, Excluded, Unbounded};
-
-    #[test]
-    fn test_basic_large() {
-        let mut map = BTreeMap::new();
-        let size = 10000;
-        assert_eq!(map.len(), 0);
-
-        for i in 0..size {
-            assert_eq!(map.insert(i, 10*i), None);
-            assert_eq!(map.len(), i + 1);
-        }
-
-        for i in 0..size {
-            assert_eq!(map.get(&i).unwrap(), &(i*10));
-        }
-
-        for i in size..size*2 {
-            assert_eq!(map.get(&i), None);
-        }
-
-        for i in 0..size {
-            assert_eq!(map.insert(i, 100*i), Some(10*i));
-            assert_eq!(map.len(), size);
-        }
-
-        for i in 0..size {
-            assert_eq!(map.get(&i).unwrap(), &(i*100));
-        }
-
-        for i in 0..size/2 {
-            assert_eq!(map.remove(&(i*2)), Some(i*200));
-            assert_eq!(map.len(), size - i - 1);
-        }
-
-        for i in 0..size/2 {
-            assert_eq!(map.get(&(2*i)), None);
-            assert_eq!(map.get(&(2*i+1)).unwrap(), &(i*200 + 100));
-        }
-
-        for i in 0..size/2 {
-            assert_eq!(map.remove(&(2*i)), None);
-            assert_eq!(map.remove(&(2*i+1)), Some(i*200 + 100));
-            assert_eq!(map.len(), size/2 - i - 1);
-        }
-    }
-
-    #[test]
-    fn test_basic_small() {
-        let mut map = BTreeMap::new();
-        assert_eq!(map.remove(&1), None);
-        assert_eq!(map.get(&1), None);
-        assert_eq!(map.insert(1, 1), None);
-        assert_eq!(map.get(&1), Some(&1));
-        assert_eq!(map.insert(1, 2), Some(1));
-        assert_eq!(map.get(&1), Some(&2));
-        assert_eq!(map.insert(2, 4), None);
-        assert_eq!(map.get(&2), Some(&4));
-        assert_eq!(map.remove(&1), Some(2));
-        assert_eq!(map.remove(&2), Some(4));
-        assert_eq!(map.remove(&1), None);
-    }
-
-    #[test]
-    fn test_iter() {
-        let size = 10000;
-
-        // Forwards
-        let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
-
-        fn test<T>(size: usize, mut iter: T) where T: Iterator<Item=(usize, usize)> {
-            for i in 0..size {
-                assert_eq!(iter.size_hint(), (size - i, Some(size - i)));
-                assert_eq!(iter.next().unwrap(), (i, i));
-            }
-            assert_eq!(iter.size_hint(), (0, Some(0)));
-            assert_eq!(iter.next(), None);
-        }
-        test(size, map.iter().map(|(&k, &v)| (k, v)));
-        test(size, map.iter_mut().map(|(&k, &mut v)| (k, v)));
-        test(size, map.into_iter());
-    }
-
-    #[test]
-    fn test_iter_rev() {
-        let size = 10000;
-
-        // Forwards
-        let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
-
-        fn test<T>(size: usize, mut iter: T) where T: Iterator<Item=(usize, usize)> {
-            for i in 0..size {
-                assert_eq!(iter.size_hint(), (size - i, Some(size - i)));
-                assert_eq!(iter.next().unwrap(), (size - i - 1, size - i - 1));
-            }
-            assert_eq!(iter.size_hint(), (0, Some(0)));
-            assert_eq!(iter.next(), None);
-        }
-        test(size, map.iter().rev().map(|(&k, &v)| (k, v)));
-        test(size, map.iter_mut().rev().map(|(&k, &mut v)| (k, v)));
-        test(size, map.into_iter().rev());
-    }
-
-    #[test]
-    fn test_iter_mixed() {
-        let size = 10000;
-
-        // Forwards
-        let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
-
-        fn test<T>(size: usize, mut iter: T)
-                where T: Iterator<Item=(usize, usize)> + DoubleEndedIterator {
-            for i in 0..size / 4 {
-                assert_eq!(iter.size_hint(), (size - i * 2, Some(size - i * 2)));
-                assert_eq!(iter.next().unwrap(), (i, i));
-                assert_eq!(iter.next_back().unwrap(), (size - i - 1, size - i - 1));
-            }
-            for i in size / 4..size * 3 / 4 {
-                assert_eq!(iter.size_hint(), (size * 3 / 4 - i, Some(size * 3 / 4 - i)));
-                assert_eq!(iter.next().unwrap(), (i, i));
-            }
-            assert_eq!(iter.size_hint(), (0, Some(0)));
-            assert_eq!(iter.next(), None);
-        }
-        test(size, map.iter().map(|(&k, &v)| (k, v)));
-        test(size, map.iter_mut().map(|(&k, &mut v)| (k, v)));
-        test(size, map.into_iter());
-    }
-
-    #[test]
-    fn test_range_small() {
-        let size = 5;
-
-        // Forwards
-        let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
-
-        let mut j = 0;
-        for ((&k, &v), i) in map.range(Included(&2), Unbounded).zip(2..size) {
-            assert_eq!(k, i);
-            assert_eq!(v, i);
-            j += 1;
-        }
-        assert_eq!(j, size - 2);
-    }
-
-    #[test]
-    fn test_range_1000() {
-        let size = 1000;
-        let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
-
-        fn test(map: &BTreeMap<u32, u32>, size: u32, min: Bound<&u32>, max: Bound<&u32>) {
-            let mut kvs = map.range(min, max).map(|(&k, &v)| (k, v));
-            let mut pairs = (0..size).map(|i| (i, i));
-
-            for (kv, pair) in kvs.by_ref().zip(pairs.by_ref()) {
-                assert_eq!(kv, pair);
-            }
-            assert_eq!(kvs.next(), None);
-            assert_eq!(pairs.next(), None);
-        }
-        test(&map, size, Included(&0), Excluded(&size));
-        test(&map, size, Unbounded, Excluded(&size));
-        test(&map, size, Included(&0), Included(&(size - 1)));
-        test(&map, size, Unbounded, Included(&(size - 1)));
-        test(&map, size, Included(&0), Unbounded);
-        test(&map, size, Unbounded, Unbounded);
-    }
-
-    #[test]
-    fn test_range() {
-        let size = 200;
-        let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
-
-        for i in 0..size {
-            for j in i..size {
-                let mut kvs = map.range(Included(&i), Included(&j)).map(|(&k, &v)| (k, v));
-                let mut pairs = range_inclusive(i, j).map(|i| (i, i));
-
-                for (kv, pair) in kvs.by_ref().zip(pairs.by_ref()) {
-                    assert_eq!(kv, pair);
-                }
-                assert_eq!(kvs.next(), None);
-                assert_eq!(pairs.next(), None);
-            }
-        }
-    }
-
-    #[test]
-    fn test_entry(){
-        let xs = [(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)];
-
-        let mut map: BTreeMap<_, _> = xs.iter().cloned().collect();
-
-        // Existing key (insert)
-        match map.entry(1) {
-            Vacant(_) => unreachable!(),
-            Occupied(mut view) => {
-                assert_eq!(view.get(), &10);
-                assert_eq!(view.insert(100), 10);
-            }
-        }
-        assert_eq!(map.get(&1).unwrap(), &100);
-        assert_eq!(map.len(), 6);
-
-
-        // Existing key (update)
-        match map.entry(2) {
-            Vacant(_) => unreachable!(),
-            Occupied(mut view) => {
-                let v = view.get_mut();
-                *v *= 10;
-            }
-        }
-        assert_eq!(map.get(&2).unwrap(), &200);
-        assert_eq!(map.len(), 6);
-
-        // Existing key (take)
-        match map.entry(3) {
-            Vacant(_) => unreachable!(),
-            Occupied(view) => {
-                assert_eq!(view.remove(), 30);
-            }
-        }
-        assert_eq!(map.get(&3), None);
-        assert_eq!(map.len(), 5);
-
-
-        // Inexistent key (insert)
-        match map.entry(10) {
-            Occupied(_) => unreachable!(),
-            Vacant(view) => {
-                assert_eq!(*view.insert(1000), 1000);
-            }
-        }
-        assert_eq!(map.get(&10).unwrap(), &1000);
-        assert_eq!(map.len(), 6);
-    }
-}
-
-
-
-
-
-
-#[cfg(test)]
-mod bench {
-    use prelude::*;
-    use std::rand::{weak_rng, Rng};
-    use test::{Bencher, black_box};
-
-    use super::BTreeMap;
-
-    map_insert_rand_bench!{insert_rand_100,    100,    BTreeMap}
-    map_insert_rand_bench!{insert_rand_10_000, 10_000, BTreeMap}
-
-    map_insert_seq_bench!{insert_seq_100,    100,    BTreeMap}
-    map_insert_seq_bench!{insert_seq_10_000, 10_000, BTreeMap}
-
-    map_find_rand_bench!{find_rand_100,    100,    BTreeMap}
-    map_find_rand_bench!{find_rand_10_000, 10_000, BTreeMap}
-
-    map_find_seq_bench!{find_seq_100,    100,    BTreeMap}
-    map_find_seq_bench!{find_seq_10_000, 10_000, BTreeMap}
-
-    fn bench_iter(b: &mut Bencher, size: i32) {
-        let mut map = BTreeMap::<i32, i32>::new();
-        let mut rng = weak_rng();
-
-        for _ in 0..size {
-            map.insert(rng.gen(), rng.gen());
-        }
-
-        b.iter(|| {
-            for entry in &map {
-                black_box(entry);
-            }
-        });
-    }
-
-    #[bench]
-    pub fn iter_20(b: &mut Bencher) {
-        bench_iter(b, 20);
-    }
-
-    #[bench]
-    pub fn iter_1000(b: &mut Bencher) {
-        bench_iter(b, 1000);
-    }
-
-    #[bench]
-    pub fn iter_100000(b: &mut Bencher) {
-        bench_iter(b, 100000);
-    }
-}
diff --git a/src/libcollections/btree/node.rs b/src/libcollections/btree/node.rs
index 1a8a4cb7e21..006d6bb040e 100644
--- a/src/libcollections/btree/node.rs
+++ b/src/libcollections/btree/node.rs
@@ -23,7 +23,7 @@ use core::iter::Zip;
 use core::marker::PhantomData;
 use core::ops::{Deref, DerefMut, Index, IndexMut};
 use core::ptr::Unique;
-use core::{slice, mem, ptr, cmp, num, raw};
+use core::{slice, mem, ptr, cmp, raw};
 use alloc::heap::{self, EMPTY};
 
 use borrow::Borrow;
@@ -105,7 +105,10 @@ struct MutNodeSlice<'a, K: 'a, V: 'a> {
 /// Fails if `target_alignment` is not a power of two.
 #[inline]
 fn round_up_to_next(unrounded: usize, target_alignment: usize) -> usize {
-    assert!(num::UnsignedInt::is_power_of_two(target_alignment));
+    #[cfg(stage0)]
+    use core::num::UnsignedInt;
+
+    assert!(target_alignment.is_power_of_two());
     (unrounded + target_alignment - 1) & !(target_alignment - 1)
 }
 
diff --git a/src/libcollections/btree/set.rs b/src/libcollections/btree/set.rs
index bc2e68b999a..5616d36ce0b 100644
--- a/src/libcollections/btree/set.rs
+++ b/src/libcollections/btree/set.rs
@@ -30,6 +30,10 @@ use Bound;
 ///
 /// See BTreeMap's documentation for a detailed discussion of this collection's performance
 /// benefits and drawbacks.
+///
+/// It is a logic error for an item to be modified in such a way that the item's ordering relative
+/// to any other item, as determined by the `Ord` trait, changes while it is in the set. This is
+/// normally only possible through `Cell`, `RefCell`, global state, I/O, or unsafe code.
 #[derive(Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct BTreeSet<T>{
@@ -738,180 +742,3 @@ impl<'a, T: Ord> Iterator for Union<'a, T> {
         }
     }
 }
-
-
-#[cfg(test)]
-mod test {
-    use prelude::*;
-
-    use super::BTreeSet;
-    use std::hash::{self, SipHasher};
-
-    #[test]
-    fn test_clone_eq() {
-      let mut m = BTreeSet::new();
-
-      m.insert(1);
-      m.insert(2);
-
-      assert!(m.clone() == m);
-    }
-
-    #[test]
-    fn test_hash() {
-      let mut x = BTreeSet::new();
-      let mut y = BTreeSet::new();
-
-      x.insert(1);
-      x.insert(2);
-      x.insert(3);
-
-      y.insert(3);
-      y.insert(2);
-      y.insert(1);
-
-      assert!(hash::hash::<_, SipHasher>(&x) == hash::hash::<_, SipHasher>(&y));
-    }
-
-    struct Counter<'a, 'b> {
-        i: &'a mut usize,
-        expected: &'b [i32],
-    }
-
-    impl<'a, 'b, 'c> FnMut<(&'c i32,)> for Counter<'a, 'b> {
-        type Output = bool;
-
-        extern "rust-call" fn call_mut(&mut self, (&x,): (&'c i32,)) -> bool {
-            assert_eq!(x, self.expected[*self.i]);
-            *self.i += 1;
-            true
-        }
-    }
-
-    fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F) where
-        // FIXME Replace Counter with `Box<FnMut(_) -> _>`
-        F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, Counter) -> bool,
-    {
-        let mut set_a = BTreeSet::new();
-        let mut set_b = BTreeSet::new();
-
-        for x in a { assert!(set_a.insert(*x)) }
-        for y in b { assert!(set_b.insert(*y)) }
-
-        let mut i = 0;
-        f(&set_a, &set_b, Counter { i: &mut i, expected: expected });
-        assert_eq!(i, expected.len());
-    }
-
-    #[test]
-    fn test_intersection() {
-        fn check_intersection(a: &[i32], b: &[i32], expected: &[i32]) {
-            check(a, b, expected, |x, y, f| x.intersection(y).all(f))
-        }
-
-        check_intersection(&[], &[], &[]);
-        check_intersection(&[1, 2, 3], &[], &[]);
-        check_intersection(&[], &[1, 2, 3], &[]);
-        check_intersection(&[2], &[1, 2, 3], &[2]);
-        check_intersection(&[1, 2, 3], &[2], &[2]);
-        check_intersection(&[11, 1, 3, 77, 103, 5, -5],
-                           &[2, 11, 77, -9, -42, 5, 3],
-                           &[3, 5, 11, 77]);
-    }
-
-    #[test]
-    fn test_difference() {
-        fn check_difference(a: &[i32], b: &[i32], expected: &[i32]) {
-            check(a, b, expected, |x, y, f| x.difference(y).all(f))
-        }
-
-        check_difference(&[], &[], &[]);
-        check_difference(&[1, 12], &[], &[1, 12]);
-        check_difference(&[], &[1, 2, 3, 9], &[]);
-        check_difference(&[1, 3, 5, 9, 11],
-                         &[3, 9],
-                         &[1, 5, 11]);
-        check_difference(&[-5, 11, 22, 33, 40, 42],
-                         &[-12, -5, 14, 23, 34, 38, 39, 50],
-                         &[11, 22, 33, 40, 42]);
-    }
-
-    #[test]
-    fn test_symmetric_difference() {
-        fn check_symmetric_difference(a: &[i32], b: &[i32], expected: &[i32]) {
-            check(a, b, expected, |x, y, f| x.symmetric_difference(y).all(f))
-        }
-
-        check_symmetric_difference(&[], &[], &[]);
-        check_symmetric_difference(&[1, 2, 3], &[2], &[1, 3]);
-        check_symmetric_difference(&[2], &[1, 2, 3], &[1, 3]);
-        check_symmetric_difference(&[1, 3, 5, 9, 11],
-                                   &[-2, 3, 9, 14, 22],
-                                   &[-2, 1, 5, 11, 14, 22]);
-    }
-
-    #[test]
-    fn test_union() {
-        fn check_union(a: &[i32], b: &[i32], expected: &[i32]) {
-            check(a, b, expected, |x, y, f| x.union(y).all(f))
-        }
-
-        check_union(&[], &[], &[]);
-        check_union(&[1, 2, 3], &[2], &[1, 2, 3]);
-        check_union(&[2], &[1, 2, 3], &[1, 2, 3]);
-        check_union(&[1, 3, 5, 9, 11, 16, 19, 24],
-                    &[-2, 1, 5, 9, 13, 19],
-                    &[-2, 1, 3, 5, 9, 11, 13, 16, 19, 24]);
-    }
-
-    #[test]
-    fn test_zip() {
-        let mut x = BTreeSet::new();
-        x.insert(5);
-        x.insert(12);
-        x.insert(11);
-
-        let mut y = BTreeSet::new();
-        y.insert("foo");
-        y.insert("bar");
-
-        let x = x;
-        let y = y;
-        let mut z = x.iter().zip(y.iter());
-
-        // FIXME: #5801: this needs a type hint to compile...
-        let result: Option<(&usize, & &'static str)> = z.next();
-        assert_eq!(result.unwrap(), (&5, &("bar")));
-
-        let result: Option<(&usize, & &'static str)> = z.next();
-        assert_eq!(result.unwrap(), (&11, &("foo")));
-
-        let result: Option<(&usize, & &'static str)> = z.next();
-        assert!(result.is_none());
-    }
-
-    #[test]
-    fn test_from_iter() {
-        let xs = [1, 2, 3, 4, 5, 6, 7, 8, 9];
-
-        let set: BTreeSet<_> = xs.iter().cloned().collect();
-
-        for x in &xs {
-            assert!(set.contains(x));
-        }
-    }
-
-    #[test]
-    fn test_show() {
-        let mut set = BTreeSet::new();
-        let empty = BTreeSet::<i32>::new();
-
-        set.insert(1);
-        set.insert(2);
-
-        let set_str = format!("{:?}", set);
-
-        assert_eq!(set_str, "{1, 2}");
-        assert_eq!(format!("{:?}", empty), "{}");
-    }
-}
diff --git a/src/libcollections/enum_set.rs b/src/libcollections/enum_set.rs
index 68ff94cfbfb..fe2efc7164d 100644
--- a/src/libcollections/enum_set.rs
+++ b/src/libcollections/enum_set.rs
@@ -24,6 +24,11 @@ use core::ops::{Sub, BitOr, BitAnd, BitXor};
 
 #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
 /// A specialized set implementation to use enum types.
+///
+/// It is a logic error for an item to be modified in such a way that the transformation of the
+/// item to or from a `usize`, as determined by the `CLike` trait, changes while the item is in the
+/// set. This is normally only possible through `Cell`, `RefCell`, global state, I/O, or unsafe
+/// code.
 pub struct EnumSet<E> {
     // We must maintain the invariant that no bits are set
     // for which no variant exists
@@ -280,241 +285,3 @@ impl<E:CLike> Extend<E> for EnumSet<E> {
         }
     }
 }
-
-#[cfg(test)]
-mod test {
-    use self::Foo::*;
-    use prelude::*;
-    use core::mem;
-
-    use super::{EnumSet, CLike};
-
-    #[derive(Copy, PartialEq, Debug)]
-    #[repr(usize)]
-    enum Foo {
-        A, B, C
-    }
-
-    impl CLike for Foo {
-        fn to_usize(&self) -> usize {
-            *self as usize
-        }
-
-        fn from_usize(v: usize) -> Foo {
-            unsafe { mem::transmute(v) }
-        }
-    }
-
-    #[test]
-    fn test_new() {
-        let e: EnumSet<Foo> = EnumSet::new();
-        assert!(e.is_empty());
-    }
-
-    #[test]
-    fn test_show() {
-        let mut e = EnumSet::new();
-        assert!(format!("{:?}", e) == "{}");
-        e.insert(A);
-        assert!(format!("{:?}", e) == "{A}");
-        e.insert(C);
-        assert!(format!("{:?}", e) == "{A, C}");
-    }
-
-    #[test]
-    fn test_len() {
-        let mut e = EnumSet::new();
-        assert_eq!(e.len(), 0);
-        e.insert(A);
-        e.insert(B);
-        e.insert(C);
-        assert_eq!(e.len(), 3);
-        e.remove(&A);
-        assert_eq!(e.len(), 2);
-        e.clear();
-        assert_eq!(e.len(), 0);
-    }
-
-    ///////////////////////////////////////////////////////////////////////////
-    // intersect
-
-    #[test]
-    fn test_two_empties_do_not_intersect() {
-        let e1: EnumSet<Foo> = EnumSet::new();
-        let e2: EnumSet<Foo> = EnumSet::new();
-        assert!(e1.is_disjoint(&e2));
-    }
-
-    #[test]
-    fn test_empty_does_not_intersect_with_full() {
-        let e1: EnumSet<Foo> = EnumSet::new();
-
-        let mut e2: EnumSet<Foo> = EnumSet::new();
-        e2.insert(A);
-        e2.insert(B);
-        e2.insert(C);
-
-        assert!(e1.is_disjoint(&e2));
-    }
-
-    #[test]
-    fn test_disjoint_intersects() {
-        let mut e1: EnumSet<Foo> = EnumSet::new();
-        e1.insert(A);
-
-        let mut e2: EnumSet<Foo> = EnumSet::new();
-        e2.insert(B);
-
-        assert!(e1.is_disjoint(&e2));
-    }
-
-    #[test]
-    fn test_overlapping_intersects() {
-        let mut e1: EnumSet<Foo> = EnumSet::new();
-        e1.insert(A);
-
-        let mut e2: EnumSet<Foo> = EnumSet::new();
-        e2.insert(A);
-        e2.insert(B);
-
-        assert!(!e1.is_disjoint(&e2));
-    }
-
-    ///////////////////////////////////////////////////////////////////////////
-    // contains and contains_elem
-
-    #[test]
-    fn test_superset() {
-        let mut e1: EnumSet<Foo> = EnumSet::new();
-        e1.insert(A);
-
-        let mut e2: EnumSet<Foo> = EnumSet::new();
-        e2.insert(A);
-        e2.insert(B);
-
-        let mut e3: EnumSet<Foo> = EnumSet::new();
-        e3.insert(C);
-
-        assert!(e1.is_subset(&e2));
-        assert!(e2.is_superset(&e1));
-        assert!(!e3.is_superset(&e2));
-        assert!(!e2.is_superset(&e3))
-    }
-
-    #[test]
-    fn test_contains() {
-        let mut e1: EnumSet<Foo> = EnumSet::new();
-        e1.insert(A);
-        assert!(e1.contains(&A));
-        assert!(!e1.contains(&B));
-        assert!(!e1.contains(&C));
-
-        e1.insert(A);
-        e1.insert(B);
-        assert!(e1.contains(&A));
-        assert!(e1.contains(&B));
-        assert!(!e1.contains(&C));
-    }
-
-    ///////////////////////////////////////////////////////////////////////////
-    // iter
-
-    #[test]
-    fn test_iterator() {
-        let mut e1: EnumSet<Foo> = EnumSet::new();
-
-        let elems: ::vec::Vec<Foo> = e1.iter().collect();
-        assert!(elems.is_empty());
-
-        e1.insert(A);
-        let elems: ::vec::Vec<_> = e1.iter().collect();
-        assert_eq!([A], elems);
-
-        e1.insert(C);
-        let elems: ::vec::Vec<_> = e1.iter().collect();
-        assert_eq!([A,C], elems);
-
-        e1.insert(C);
-        let elems: ::vec::Vec<_> = e1.iter().collect();
-        assert_eq!([A,C], elems);
-
-        e1.insert(B);
-        let elems: ::vec::Vec<_> = e1.iter().collect();
-        assert_eq!([A,B,C], elems);
-    }
-
-    ///////////////////////////////////////////////////////////////////////////
-    // operators
-
-    #[test]
-    fn test_operators() {
-        let mut e1: EnumSet<Foo> = EnumSet::new();
-        e1.insert(A);
-        e1.insert(C);
-
-        let mut e2: EnumSet<Foo> = EnumSet::new();
-        e2.insert(B);
-        e2.insert(C);
-
-        let e_union = e1 | e2;
-        let elems: ::vec::Vec<_> = e_union.iter().collect();
-        assert_eq!([A,B,C], elems);
-
-        let e_intersection = e1 & e2;
-        let elems: ::vec::Vec<_> = e_intersection.iter().collect();
-        assert_eq!([C], elems);
-
-        // Another way to express intersection
-        let e_intersection = e1 - (e1 - e2);
-        let elems: ::vec::Vec<_> = e_intersection.iter().collect();
-        assert_eq!([C], elems);
-
-        let e_subtract = e1 - e2;
-        let elems: ::vec::Vec<_> = e_subtract.iter().collect();
-        assert_eq!([A], elems);
-
-        // Bitwise XOR of two sets, aka symmetric difference
-        let e_symmetric_diff = e1 ^ e2;
-        let elems: ::vec::Vec<_> = e_symmetric_diff.iter().collect();
-        assert_eq!([A,B], elems);
-
-        // Another way to express symmetric difference
-        let e_symmetric_diff = (e1 - e2) | (e2 - e1);
-        let elems: ::vec::Vec<_> = e_symmetric_diff.iter().collect();
-        assert_eq!([A,B], elems);
-
-        // Yet another way to express symmetric difference
-        let e_symmetric_diff = (e1 | e2) - (e1 & e2);
-        let elems: ::vec::Vec<_> = e_symmetric_diff.iter().collect();
-        assert_eq!([A,B], elems);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_overflow() {
-        #[allow(dead_code)]
-        #[derive(Copy)]
-        #[repr(usize)]
-        enum Bar {
-            V00, V01, V02, V03, V04, V05, V06, V07, V08, V09,
-            V10, V11, V12, V13, V14, V15, V16, V17, V18, V19,
-            V20, V21, V22, V23, V24, V25, V26, V27, V28, V29,
-            V30, V31, V32, V33, V34, V35, V36, V37, V38, V39,
-            V40, V41, V42, V43, V44, V45, V46, V47, V48, V49,
-            V50, V51, V52, V53, V54, V55, V56, V57, V58, V59,
-            V60, V61, V62, V63, V64, V65, V66, V67, V68, V69,
-        }
-
-        impl CLike for Bar {
-            fn to_usize(&self) -> usize {
-                *self as usize
-            }
-
-            fn from_usize(v: usize) -> Bar {
-                unsafe { mem::transmute(v) }
-            }
-        }
-        let mut set = EnumSet::new();
-        set.insert(Bar::V64);
-    }
-}
diff --git a/src/libcollections/fmt.rs b/src/libcollections/fmt.rs
index 5d35c3902a3..1deb08ad0d1 100644
--- a/src/libcollections/fmt.rs
+++ b/src/libcollections/fmt.rs
@@ -422,7 +422,7 @@ use string;
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::fmt;
 ///
 /// let s = fmt::format(format_args!("Hello, {}!", "world"));
@@ -434,15 +434,3 @@ pub fn format(args: Arguments) -> string::String {
     let _ = write!(&mut output, "{}", args);
     output
 }
-
-#[cfg(test)]
-mod tests {
-    use prelude::*;
-    use fmt;
-
-    #[test]
-    fn test_format() {
-        let s = fmt::format(format_args!("Hello, {}!", "world"));
-        assert_eq!(s.as_slice(), "Hello, world!");
-    }
-}
diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs
index e90186d63b4..b75f346c188 100644
--- a/src/libcollections/lib.rs
+++ b/src/libcollections/lib.rs
@@ -27,6 +27,7 @@
 #![feature(box_syntax)]
 #![feature(box_patterns)]
 #![feature(core)]
+#![feature(lang_items)]
 #![feature(staged_api)]
 #![feature(unboxed_closures)]
 #![feature(unicode)]
@@ -46,9 +47,8 @@ extern crate core;
 extern crate unicode;
 extern crate alloc;
 
-#[cfg(test)] extern crate test;
 #[cfg(test)] #[macro_use] extern crate std;
-#[cfg(test)] #[macro_use] extern crate log;
+#[cfg(test)] extern crate test;
 
 pub use binary_heap::BinaryHeap;
 pub use bit_vec::BitVec;
@@ -84,8 +84,6 @@ pub use alloc::boxed;
 #[macro_use]
 mod macros;
 
-#[cfg(test)] #[macro_use] mod bench;
-
 pub mod binary_heap;
 mod bit;
 mod btree;
@@ -141,40 +139,6 @@ mod std {
     pub use core::ops;      // RangeFull
 }
 
-#[cfg(test)]
-mod prelude {
-    // from core.
-    pub use core::clone::Clone;
-    pub use core::cmp::{PartialEq, Eq, PartialOrd, Ord};
-    pub use core::cmp::Ordering::{Less, Equal, Greater};
-    pub use core::iter::range;
-    pub use core::iter::{FromIterator, Extend, IteratorExt};
-    pub use core::iter::{Iterator, DoubleEndedIterator, RandomAccessIterator};
-    pub use core::iter::{ExactSizeIterator};
-    pub use core::marker::{Copy, Send, Sized, Sync};
-    pub use core::mem::drop;
-    pub use core::ops::{Drop, Fn, FnMut, FnOnce};
-    pub use core::option::Option;
-    pub use core::option::Option::{Some, None};
-    pub use core::ptr::PtrExt;
-    pub use core::result::Result;
-    pub use core::result::Result::{Ok, Err};
-
-    // in core and collections (may differ).
-    pub use slice::{AsSlice, SliceExt};
-    pub use str::{Str, StrExt};
-
-    // from other crates.
-    pub use alloc::boxed::Box;
-    pub use unicode::char::CharExt;
-
-    // from collections.
-    pub use borrow::IntoCow;
-    pub use slice::SliceConcatExt;
-    pub use string::{String, ToString};
-    pub use vec::Vec;
-}
-
 /// An endpoint of a range of keys.
 #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
 pub enum Bound<T> {
diff --git a/src/libcollections/linked_list.rs b/src/libcollections/linked_list.rs
index 5ca3cb38058..9e0a6d04381 100644
--- a/src/libcollections/linked_list.rs
+++ b/src/libcollections/linked_list.rs
@@ -940,16 +940,21 @@ impl<A: Hash> Hash for LinkedList<A> {
 }
 
 #[cfg(test)]
-mod tests {
-    use prelude::*;
+mod test {
+    use std::clone::Clone;
+    use std::iter::{Iterator, IteratorExt};
+    use std::option::Option::{Some, None, self};
     use std::rand;
-    use std::hash::{self, SipHasher};
     use std::thread;
-    use test::Bencher;
-    use test;
+    use std::vec::Vec;
 
     use super::{LinkedList, Node};
 
+    #[cfg(test)]
+    fn list_from<T: Clone>(v: &[T]) -> LinkedList<T> {
+        v.iter().cloned().collect()
+    }
+
     pub fn check_links<T>(list: &LinkedList<T>) {
         let mut len = 0;
         let mut last_ptr: Option<&Node<T>> = None;
@@ -983,56 +988,6 @@ mod tests {
     }
 
     #[test]
-    fn test_basic() {
-        let mut m = LinkedList::<Box<_>>::new();
-        assert_eq!(m.pop_front(), None);
-        assert_eq!(m.pop_back(), None);
-        assert_eq!(m.pop_front(), None);
-        m.push_front(box 1);
-        assert_eq!(m.pop_front(), Some(box 1));
-        m.push_back(box 2);
-        m.push_back(box 3);
-        assert_eq!(m.len(), 2);
-        assert_eq!(m.pop_front(), Some(box 2));
-        assert_eq!(m.pop_front(), Some(box 3));
-        assert_eq!(m.len(), 0);
-        assert_eq!(m.pop_front(), None);
-        m.push_back(box 1);
-        m.push_back(box 3);
-        m.push_back(box 5);
-        m.push_back(box 7);
-        assert_eq!(m.pop_front(), Some(box 1));
-
-        let mut n = LinkedList::new();
-        n.push_front(2);
-        n.push_front(3);
-        {
-            assert_eq!(n.front().unwrap(), &3);
-            let x = n.front_mut().unwrap();
-            assert_eq!(*x, 3);
-            *x = 0;
-        }
-        {
-            assert_eq!(n.back().unwrap(), &2);
-            let y = n.back_mut().unwrap();
-            assert_eq!(*y, 2);
-            *y = 1;
-        }
-        assert_eq!(n.pop_front(), Some(0));
-        assert_eq!(n.pop_front(), Some(1));
-    }
-
-    #[cfg(test)]
-    fn generate_test() -> LinkedList<i32> {
-        list_from(&[0,1,2,3,4,5,6])
-    }
-
-    #[cfg(test)]
-    fn list_from<T: Clone>(v: &[T]) -> LinkedList<T> {
-        v.iter().cloned().collect()
-    }
-
-    #[test]
     fn test_append() {
         // Empty to empty
         {
@@ -1090,166 +1045,6 @@ mod tests {
     }
 
     #[test]
-    fn test_split_off() {
-        // singleton
-        {
-            let mut m = LinkedList::new();
-            m.push_back(1);
-
-            let p = m.split_off(0);
-            assert_eq!(m.len(), 0);
-            assert_eq!(p.len(), 1);
-            assert_eq!(p.back(), Some(&1));
-            assert_eq!(p.front(), Some(&1));
-        }
-
-        // not singleton, forwards
-        {
-            let u = vec![1,2,3,4,5];
-            let mut m = list_from(&u);
-            let mut n = m.split_off(2);
-            assert_eq!(m.len(), 2);
-            assert_eq!(n.len(), 3);
-            for elt in 1..3 {
-                assert_eq!(m.pop_front(), Some(elt));
-            }
-            for elt in 3..6 {
-                assert_eq!(n.pop_front(), Some(elt));
-            }
-        }
-        // not singleton, backwards
-        {
-            let u = vec![1,2,3,4,5];
-            let mut m = list_from(&u);
-            let mut n = m.split_off(4);
-            assert_eq!(m.len(), 4);
-            assert_eq!(n.len(), 1);
-            for elt in 1..5 {
-                assert_eq!(m.pop_front(), Some(elt));
-            }
-            for elt in 5..6 {
-                assert_eq!(n.pop_front(), Some(elt));
-            }
-        }
-
-        // no-op on the last index
-        {
-            let mut m = LinkedList::new();
-            m.push_back(1);
-
-            let p = m.split_off(1);
-            assert_eq!(m.len(), 1);
-            assert_eq!(p.len(), 0);
-            assert_eq!(m.back(), Some(&1));
-            assert_eq!(m.front(), Some(&1));
-        }
-
-    }
-
-    #[test]
-    fn test_iterator() {
-        let m = generate_test();
-        for (i, elt) in m.iter().enumerate() {
-            assert_eq!(i as i32, *elt);
-        }
-        let mut n = LinkedList::new();
-        assert_eq!(n.iter().next(), None);
-        n.push_front(4);
-        let mut it = n.iter();
-        assert_eq!(it.size_hint(), (1, Some(1)));
-        assert_eq!(it.next().unwrap(), &4);
-        assert_eq!(it.size_hint(), (0, Some(0)));
-        assert_eq!(it.next(), None);
-    }
-
-    #[test]
-    fn test_iterator_clone() {
-        let mut n = LinkedList::new();
-        n.push_back(2);
-        n.push_back(3);
-        n.push_back(4);
-        let mut it = n.iter();
-        it.next();
-        let mut jt = it.clone();
-        assert_eq!(it.next(), jt.next());
-        assert_eq!(it.next_back(), jt.next_back());
-        assert_eq!(it.next(), jt.next());
-    }
-
-    #[test]
-    fn test_iterator_double_end() {
-        let mut n = LinkedList::new();
-        assert_eq!(n.iter().next(), None);
-        n.push_front(4);
-        n.push_front(5);
-        n.push_front(6);
-        let mut it = n.iter();
-        assert_eq!(it.size_hint(), (3, Some(3)));
-        assert_eq!(it.next().unwrap(), &6);
-        assert_eq!(it.size_hint(), (2, Some(2)));
-        assert_eq!(it.next_back().unwrap(), &4);
-        assert_eq!(it.size_hint(), (1, Some(1)));
-        assert_eq!(it.next_back().unwrap(), &5);
-        assert_eq!(it.next_back(), None);
-        assert_eq!(it.next(), None);
-    }
-
-    #[test]
-    fn test_rev_iter() {
-        let m = generate_test();
-        for (i, elt) in m.iter().rev().enumerate() {
-            assert_eq!((6 - i) as i32, *elt);
-        }
-        let mut n = LinkedList::new();
-        assert_eq!(n.iter().rev().next(), None);
-        n.push_front(4);
-        let mut it = n.iter().rev();
-        assert_eq!(it.size_hint(), (1, Some(1)));
-        assert_eq!(it.next().unwrap(), &4);
-        assert_eq!(it.size_hint(), (0, Some(0)));
-        assert_eq!(it.next(), None);
-    }
-
-    #[test]
-    fn test_mut_iter() {
-        let mut m = generate_test();
-        let mut len = m.len();
-        for (i, elt) in m.iter_mut().enumerate() {
-            assert_eq!(i as i32, *elt);
-            len -= 1;
-        }
-        assert_eq!(len, 0);
-        let mut n = LinkedList::new();
-        assert!(n.iter_mut().next().is_none());
-        n.push_front(4);
-        n.push_back(5);
-        let mut it = n.iter_mut();
-        assert_eq!(it.size_hint(), (2, Some(2)));
-        assert!(it.next().is_some());
-        assert!(it.next().is_some());
-        assert_eq!(it.size_hint(), (0, Some(0)));
-        assert!(it.next().is_none());
-    }
-
-    #[test]
-    fn test_iterator_mut_double_end() {
-        let mut n = LinkedList::new();
-        assert!(n.iter_mut().next_back().is_none());
-        n.push_front(4);
-        n.push_front(5);
-        n.push_front(6);
-        let mut it = n.iter_mut();
-        assert_eq!(it.size_hint(), (3, Some(3)));
-        assert_eq!(*it.next().unwrap(), 6);
-        assert_eq!(it.size_hint(), (2, Some(2)));
-        assert_eq!(*it.next_back().unwrap(), 4);
-        assert_eq!(it.size_hint(), (1, Some(1)));
-        assert_eq!(*it.next_back().unwrap(), 5);
-        assert!(it.next_back().is_none());
-        assert!(it.next().is_none());
-    }
-
-    #[test]
     fn test_insert_prev() {
         let mut m = list_from(&[0,2,4,6,8]);
         let len = m.len();
@@ -1277,20 +1072,6 @@ mod tests {
     }
 
     #[test]
-    fn test_mut_rev_iter() {
-        let mut m = generate_test();
-        for (i, elt) in m.iter_mut().rev().enumerate() {
-            assert_eq!((6 - i) as i32, *elt);
-        }
-        let mut n = LinkedList::new();
-        assert!(n.iter_mut().rev().next().is_none());
-        n.push_front(4);
-        let mut it = n.iter_mut().rev();
-        assert!(it.next().is_some());
-        assert!(it.next().is_none());
-    }
-
-    #[test]
     fn test_send() {
         let n = list_from(&[1,2,3]);
         thread::spawn(move || {
@@ -1301,81 +1082,6 @@ mod tests {
     }
 
     #[test]
-    fn test_eq() {
-        let mut n = list_from(&[]);
-        let mut m = list_from(&[]);
-        assert!(n == m);
-        n.push_front(1);
-        assert!(n != m);
-        m.push_back(1);
-        assert!(n == m);
-
-        let n = list_from(&[2,3,4]);
-        let m = list_from(&[1,2,3]);
-        assert!(n != m);
-    }
-
-    #[test]
-    fn test_hash() {
-      let mut x = LinkedList::new();
-      let mut y = LinkedList::new();
-
-      assert!(hash::hash::<_, SipHasher>(&x) == hash::hash::<_, SipHasher>(&y));
-
-      x.push_back(1);
-      x.push_back(2);
-      x.push_back(3);
-
-      y.push_front(3);
-      y.push_front(2);
-      y.push_front(1);
-
-      assert!(hash::hash::<_, SipHasher>(&x) == hash::hash::<_, SipHasher>(&y));
-    }
-
-    #[test]
-    fn test_ord() {
-        let n = list_from(&[]);
-        let m = list_from(&[1,2,3]);
-        assert!(n < m);
-        assert!(m > n);
-        assert!(n <= n);
-        assert!(n >= n);
-    }
-
-    #[test]
-    fn test_ord_nan() {
-        let nan = 0.0f64/0.0;
-        let n = list_from(&[nan]);
-        let m = list_from(&[nan]);
-        assert!(!(n < m));
-        assert!(!(n > m));
-        assert!(!(n <= m));
-        assert!(!(n >= m));
-
-        let n = list_from(&[nan]);
-        let one = list_from(&[1.0f64]);
-        assert!(!(n < one));
-        assert!(!(n > one));
-        assert!(!(n <= one));
-        assert!(!(n >= one));
-
-        let u = list_from(&[1.0f64,2.0,nan]);
-        let v = list_from(&[1.0f64,2.0,3.0]);
-        assert!(!(u < v));
-        assert!(!(u > v));
-        assert!(!(u <= v));
-        assert!(!(u >= v));
-
-        let s = list_from(&[1.0f64,2.0,4.0,2.0]);
-        let t = list_from(&[1.0f64,2.0,3.0,2.0]);
-        assert!(!(s < t));
-        assert!(s > one);
-        assert!(!(s <= one));
-        assert!(s >= one);
-    }
-
-    #[test]
     fn test_fuzz() {
         for _ in 0..25 {
             fuzz_test(3);
@@ -1384,15 +1090,6 @@ mod tests {
         }
     }
 
-    #[test]
-    fn test_show() {
-        let list: LinkedList<_> = (0..10).collect();
-        assert_eq!(format!("{:?}", list), "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
-
-        let list: LinkedList<_> = vec!["just", "one", "test", "more"].iter().cloned().collect();
-        assert_eq!(format!("{:?}", list), "[\"just\", \"one\", \"test\", \"more\"]");
-    }
-
     #[cfg(test)]
     fn fuzz_test(sz: i32) {
         let mut m: LinkedList<_> = LinkedList::new();
@@ -1431,79 +1128,4 @@ mod tests {
         }
         assert_eq!(i, v.len());
     }
-
-    #[bench]
-    fn bench_collect_into(b: &mut test::Bencher) {
-        let v = &[0; 64];
-        b.iter(|| {
-            let _: LinkedList<_> = v.iter().cloned().collect();
-        })
-    }
-
-    #[bench]
-    fn bench_push_front(b: &mut test::Bencher) {
-        let mut m: LinkedList<_> = LinkedList::new();
-        b.iter(|| {
-            m.push_front(0);
-        })
-    }
-
-    #[bench]
-    fn bench_push_back(b: &mut test::Bencher) {
-        let mut m: LinkedList<_> = LinkedList::new();
-        b.iter(|| {
-            m.push_back(0);
-        })
-    }
-
-    #[bench]
-    fn bench_push_back_pop_back(b: &mut test::Bencher) {
-        let mut m: LinkedList<_> = LinkedList::new();
-        b.iter(|| {
-            m.push_back(0);
-            m.pop_back();
-        })
-    }
-
-    #[bench]
-    fn bench_push_front_pop_front(b: &mut test::Bencher) {
-        let mut m: LinkedList<_> = LinkedList::new();
-        b.iter(|| {
-            m.push_front(0);
-            m.pop_front();
-        })
-    }
-
-    #[bench]
-    fn bench_iter(b: &mut test::Bencher) {
-        let v = &[0; 128];
-        let m: LinkedList<_> = v.iter().cloned().collect();
-        b.iter(|| {
-            assert!(m.iter().count() == 128);
-        })
-    }
-    #[bench]
-    fn bench_iter_mut(b: &mut test::Bencher) {
-        let v = &[0; 128];
-        let mut m: LinkedList<_> = v.iter().cloned().collect();
-        b.iter(|| {
-            assert!(m.iter_mut().count() == 128);
-        })
-    }
-    #[bench]
-    fn bench_iter_rev(b: &mut test::Bencher) {
-        let v = &[0; 128];
-        let m: LinkedList<_> = v.iter().cloned().collect();
-        b.iter(|| {
-            assert!(m.iter().rev().count() == 128);
-        })
-    }
-    #[bench]
-    fn bench_iter_mut_rev(b: &mut test::Bencher) {
-        let v = &[0; 128];
-        let mut m: LinkedList<_> = v.iter().cloned().collect();
-        b.iter(|| {
-            assert!(m.iter_mut().rev().count() == 128);
-        })
-    }
 }
diff --git a/src/libcollections/macros.rs b/src/libcollections/macros.rs
index 0f6a85d75da..3c7326dbd8f 100644
--- a/src/libcollections/macros.rs
+++ b/src/libcollections/macros.rs
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#[cfg(stage0)]
 /// Creates a `Vec` containing the arguments.
 ///
 /// `vec!` allows `Vec`s to be defined with the same syntax as array expressions.
@@ -45,6 +46,60 @@ macro_rules! vec {
     ($($x:expr,)*) => (vec![$($x),*])
 }
 
+#[cfg(not(stage0))]
+/// Creates a `Vec` containing the arguments.
+///
+/// `vec!` allows `Vec`s to be defined with the same syntax as array expressions.
+/// There are two forms of this macro:
+///
+/// - Create a `Vec` containing a given list of elements:
+///
+/// ```
+/// let v = vec![1, 2, 3];
+/// assert_eq!(v[0], 1);
+/// assert_eq!(v[1], 2);
+/// assert_eq!(v[2], 3);
+/// ```
+///
+/// - Create a `Vec` from a given element and size:
+///
+/// ```
+/// let v = vec![1; 3];
+/// assert_eq!(v, [1, 1, 1]);
+/// ```
+///
+/// Note that unlike array expressions this syntax supports all elements
+/// which implement `Clone` and the number of elements doesn't have to be
+/// a constant.
+#[cfg(not(test))]
+#[macro_export]
+#[stable(feature = "rust1", since = "1.0.0")]
+macro_rules! vec {
+    ($elem:expr; $n:expr) => (
+        $crate::vec::from_elem($elem, $n)
+    );
+    ($($x:expr),*) => (
+        <[_]>::into_vec($crate::boxed::Box::new([$($x),*]))
+    );
+    ($($x:expr,)*) => (vec![$($x),*])
+}
+
+// HACK(japaric): with cfg(test) the inherent `[T]::into_vec` method, which is required for this
+// macro definition, is not available. Instead use the `slice::into_vec`  function which is only
+// available with cfg(test)
+// NB see the slice::hack module in slice.rs for more information
+#[cfg(not(stage0))]
+#[cfg(test)]
+macro_rules! vec {
+    ($elem:expr; $n:expr) => (
+        $crate::vec::from_elem($elem, $n)
+    );
+    ($($x:expr),*) => (
+        $crate::slice::into_vec($crate::boxed::Box::new([$($x),*]))
+    );
+    ($($x:expr,)*) => (vec![$($x),*])
+}
+
 /// Use the syntax described in `std::fmt` to create a value of type `String`.
 /// See `std::fmt` for more information.
 ///
diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs
index e1c27095b2f..4993994d46b 100644
--- a/src/libcollections/slice.rs
+++ b/src/libcollections/slice.rs
@@ -99,6 +99,7 @@ use core::mem;
 use core::num::wrapping::WrappingOps;
 use core::ops::FnMut;
 use core::option::Option::{self, Some, None};
+#[cfg(stage0)]
 use core::ptr::PtrExt;
 use core::ptr;
 use core::result::Result;
@@ -120,6 +121,7 @@ pub use core::slice::{from_raw_buf, from_raw_mut_buf};
 // Basic slice extension methods
 ////////////////////////////////////////////////////////////////////////////////
 
+#[cfg(stage0)]
 /// Allocating extension methods for slices.
 #[stable(feature = "rust1", since = "1.0.0")]
 pub trait SliceExt {
@@ -134,7 +136,7 @@ pub trait SliceExt {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// let mut v = [5, 4, 1, 3, 2];
     /// v.sort_by(|a, b| a.cmp(b));
     /// assert!(v == [1, 2, 3, 4, 5]);
@@ -160,7 +162,7 @@ pub trait SliceExt {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// let mut a = [1, 2, 3, 4, 5];
     /// let b = vec![6, 7, 8];
     /// let num_moved = a.move_from(b, 0, 3);
@@ -282,7 +284,7 @@ pub trait SliceExt {
     /// Print the adjacent pairs of a slice (i.e. `[1,2]`, `[2,3]`,
     /// `[3,4]`):
     ///
-    /// ```rust
+    /// ```
     /// let v = &[1, 2, 3, 4];
     /// for win in v.windows(2) {
     ///     println!("{:?}", win);
@@ -305,7 +307,7 @@ pub trait SliceExt {
     /// Print the slice two elements at a time (i.e. `[1,2]`,
     /// `[3,4]`, `[5]`):
     ///
-    /// ```rust
+    /// ```
     /// let v = &[1, 2, 3, 4, 5];
     /// for win in v.chunks(2) {
     ///     println!("{:?}", win);
@@ -396,7 +398,7 @@ pub trait SliceExt {
     /// uniquely determined position; the second and third are not
     /// found; the fourth could match any position in `[1,4]`.
     ///
-    /// ```rust
+    /// ```
     /// let s = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
     /// let s = s.as_slice();
     ///
@@ -531,7 +533,7 @@ pub trait SliceExt {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// let mut v = ["a", "b", "c", "d"];
     /// v.swap(1, 3);
     /// assert!(v == ["a", "d", "c", "b"]);
@@ -551,7 +553,7 @@ pub trait SliceExt {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// let mut v = [1, 2, 3, 4, 5, 6];
     ///
     /// // scoped to restrict the lifetime of the borrows
@@ -580,7 +582,7 @@ pub trait SliceExt {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// let mut v = [1, 2, 3];
     /// v.reverse();
     /// assert!(v == [3, 2, 1]);
@@ -612,7 +614,7 @@ pub trait SliceExt {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// let v = [1, 2, 3];
     /// let mut perms = v.permutations();
     ///
@@ -623,7 +625,7 @@ pub trait SliceExt {
     ///
     /// Iterating through permutations one by one.
     ///
-    /// ```rust
+    /// ```
     /// let v = [1, 2, 3];
     /// let mut perms = v.permutations();
     ///
@@ -640,7 +642,7 @@ pub trait SliceExt {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// let mut dst = [0, 0, 0];
     /// let src = [1, 2];
     ///
@@ -660,7 +662,7 @@ pub trait SliceExt {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// let mut v = [-5, 4, 1, -3, 2];
     ///
     /// v.sort();
@@ -682,7 +684,7 @@ pub trait SliceExt {
     /// uniquely determined position; the second and third are not
     /// found; the fourth could match any position in `[1,4]`.
     ///
-    /// ```rust
+    /// ```
     /// let s = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
     /// let s = s.as_slice();
     ///
@@ -709,7 +711,7 @@ pub trait SliceExt {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// let v: &mut [_] = &mut [0, 1, 2];
     /// v.next_permutation();
     /// let b: &mut [_] = &mut [0, 2, 1];
@@ -729,7 +731,7 @@ pub trait SliceExt {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// let v: &mut [_] = &mut [1, 0, 2];
     /// v.prev_permutation();
     /// let b: &mut [_] = &mut [0, 2, 1];
@@ -795,6 +797,7 @@ pub trait SliceExt {
     fn into_vec(self: Box<Self>) -> Vec<Self::Item>;
 }
 
+#[cfg(stage0)]
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T> SliceExt for [T] {
     type Item = T;
@@ -1080,6 +1083,942 @@ impl<T> SliceExt for [T] {
     }
 }
 
+// HACK(japaric) needed for the implementation of `vec!` macro during testing
+// NB see the hack module in this file for more details
+#[cfg(not(stage0))]
+#[cfg(test)]
+pub use self::hack::into_vec;
+
+// HACK(japaric) needed for the implementation of `Vec::clone` during testing
+// NB see the hack module in this file for more details
+#[cfg(not(stage0))]
+#[cfg(test)]
+pub use self::hack::to_vec;
+
+// HACK(japaric): With cfg(test) `impl [T]` is not available, these three functions are actually
+// methods that are in `impl [T]` but not in `core::slice::SliceExt` - we need to supply these
+// functions for the `test_permutations` test
+#[cfg(not(stage0))]
+mod hack {
+    use alloc::boxed::Box;
+    use core::clone::Clone;
+    #[cfg(test)]
+    use core::iter::{Iterator, IteratorExt};
+    use core::mem;
+    #[cfg(test)]
+    use core::option::Option::{Some, None};
+
+    #[cfg(test)]
+    use string::ToString;
+    use vec::Vec;
+
+    use super::{ElementSwaps, Permutations};
+
+    pub fn into_vec<T>(mut b: Box<[T]>) -> Vec<T> {
+        unsafe {
+            let xs = Vec::from_raw_parts(b.as_mut_ptr(), b.len(), b.len());
+            mem::forget(b);
+            xs
+        }
+    }
+
+    pub fn permutations<T>(s: &[T]) -> Permutations<T> where T: Clone {
+        Permutations{
+            swaps: ElementSwaps::new(s.len()),
+            v: to_vec(s),
+        }
+    }
+
+    #[inline]
+    pub fn to_vec<T>(s: &[T]) -> Vec<T> where T: Clone {
+        let mut vector = Vec::with_capacity(s.len());
+        vector.push_all(s);
+        vector
+    }
+
+    // NB we can remove this hack if we move this test to libcollectionstest - but that can't be
+    // done right now because the test needs access to the private fields of Permutations
+    #[test]
+    fn test_permutations() {
+        {
+            let v: [i32; 0] = [];
+            let mut it = permutations(&v);
+            let (min_size, max_opt) = it.size_hint();
+            assert_eq!(min_size, 1);
+            assert_eq!(max_opt.unwrap(), 1);
+            assert_eq!(it.next(), Some(to_vec(&v)));
+            assert_eq!(it.next(), None);
+        }
+        {
+            let v = ["Hello".to_string()];
+            let mut it = permutations(&v);
+            let (min_size, max_opt) = it.size_hint();
+            assert_eq!(min_size, 1);
+            assert_eq!(max_opt.unwrap(), 1);
+            assert_eq!(it.next(), Some(to_vec(&v)));
+            assert_eq!(it.next(), None);
+        }
+        {
+            let v = [1, 2, 3];
+            let mut it = permutations(&v);
+            let (min_size, max_opt) = it.size_hint();
+            assert_eq!(min_size, 3*2);
+            assert_eq!(max_opt.unwrap(), 3*2);
+            assert_eq!(it.next().unwrap(), [1,2,3]);
+            assert_eq!(it.next().unwrap(), [1,3,2]);
+            assert_eq!(it.next().unwrap(), [3,1,2]);
+            let (min_size, max_opt) = it.size_hint();
+            assert_eq!(min_size, 3);
+            assert_eq!(max_opt.unwrap(), 3);
+            assert_eq!(it.next().unwrap(), [3,2,1]);
+            assert_eq!(it.next().unwrap(), [2,3,1]);
+            assert_eq!(it.next().unwrap(), [2,1,3]);
+            assert_eq!(it.next(), None);
+        }
+        {
+            // check that we have N! permutations
+            let v = ['A', 'B', 'C', 'D', 'E', 'F'];
+            let mut amt = 0;
+            let mut it = permutations(&v);
+            let (min_size, max_opt) = it.size_hint();
+            for _perm in it.by_ref() {
+                amt += 1;
+            }
+            assert_eq!(amt, it.swaps.swaps_made);
+            assert_eq!(amt, min_size);
+            assert_eq!(amt, 2 * 3 * 4 * 5 * 6);
+            assert_eq!(amt, max_opt.unwrap());
+        }
+    }
+}
+
+#[cfg(not(stage0))]
+/// Allocating extension methods for slices.
+#[lang = "slice"]
+#[cfg(not(test))]
+#[stable(feature = "rust1", since = "1.0.0")]
+impl<T> [T] {
+    /// Sorts the slice, in place, using `compare` to compare
+    /// elements.
+    ///
+    /// This sort is `O(n log n)` worst-case and stable, but allocates
+    /// approximately `2 * n`, where `n` is the length of `self`.
+    ///
+    /// # Examples
+    ///
+    /// ```rust
+    /// let mut v = [5, 4, 1, 3, 2];
+    /// v.sort_by(|a, b| a.cmp(b));
+    /// assert!(v == [1, 2, 3, 4, 5]);
+    ///
+    /// // reverse sorting
+    /// v.sort_by(|a, b| b.cmp(a));
+    /// assert!(v == [5, 4, 3, 2, 1]);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn sort_by<F>(&mut self, compare: F) where F: FnMut(&T, &T) -> Ordering {
+        merge_sort(self, compare)
+    }
+
+    /// Consumes `src` and moves as many elements as it can into `self`
+    /// from the range [start,end).
+    ///
+    /// Returns the number of elements copied (the shorter of `self.len()`
+    /// and `end - start`).
+    ///
+    /// # Arguments
+    ///
+    /// * src - A mutable vector of `T`
+    /// * start - The index into `src` to start copying from
+    /// * end - The index into `src` to stop copying from
+    ///
+    /// # Examples
+    ///
+    /// ```rust
+    /// let mut a = [1, 2, 3, 4, 5];
+    /// let b = vec![6, 7, 8];
+    /// let num_moved = a.move_from(b, 0, 3);
+    /// assert_eq!(num_moved, 3);
+    /// assert!(a == [6, 7, 8, 4, 5]);
+    /// ```
+    #[unstable(feature = "collections",
+               reason = "uncertain about this API approach")]
+    #[inline]
+    pub fn move_from(&mut self, mut src: Vec<T>, start: usize, end: usize) -> usize {
+        for (a, b) in self.iter_mut().zip(src[start .. end].iter_mut()) {
+            mem::swap(a, b);
+        }
+        cmp::min(self.len(), end-start)
+    }
+
+    /// Deprecated: use `&s[start .. end]` notation instead.
+    #[unstable(feature = "collections",
+               reason = "will be replaced by slice syntax")]
+    #[deprecated(since = "1.0.0", reason = "use &s[start .. end] instead")]
+    #[inline]
+    pub fn slice(&self, start: usize, end: usize) -> &[T] {
+        &self[start .. end]
+    }
+
+    /// Deprecated: use `&s[start..]` notation instead.
+    #[unstable(feature = "collections",
+               reason = "will be replaced by slice syntax")]
+    #[deprecated(since = "1.0.0", reason = "use &s[start..] instead")]
+    #[inline]
+    pub fn slice_from(&self, start: usize) -> &[T] {
+        &self[start ..]
+    }
+
+    /// Deprecated: use `&s[..end]` notation instead.
+    #[unstable(feature = "collections",
+               reason = "will be replaced by slice syntax")]
+    #[deprecated(since = "1.0.0", reason = "use &s[..end] instead")]
+    #[inline]
+    pub fn slice_to(&self, end: usize) -> &[T] {
+        &self[.. end]
+    }
+
+    /// Divides one slice into two at an index.
+    ///
+    /// The first will contain all indices from `[0, mid)` (excluding
+    /// the index `mid` itself) and the second will contain all
+    /// indices from `[mid, len)` (excluding the index `len` itself).
+    ///
+    /// Panics if `mid > len`.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let v = [10, 40, 30, 20, 50];
+    /// let (v1, v2) = v.split_at(2);
+    /// assert_eq!([10, 40], v1);
+    /// assert_eq!([30, 20, 50], v2);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn split_at(&self, mid: usize) -> (&[T], &[T]) {
+        core_slice::SliceExt::split_at(self, mid)
+    }
+
+    /// Returns an iterator over the slice.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn iter(&self) -> Iter<T> {
+        core_slice::SliceExt::iter(self)
+    }
+
+    /// Returns an iterator over subslices separated by elements that match
+    /// `pred`.  The matched element is not contained in the subslices.
+    ///
+    /// # Examples
+    ///
+    /// Print the slice split by numbers divisible by 3 (i.e. `[10, 40]`,
+    /// `[20]`, `[50]`):
+    ///
+    /// ```
+    /// let v = [10, 40, 30, 20, 60, 50];
+    /// for group in v.split(|num| *num % 3 == 0) {
+    ///     println!("{:?}", group);
+    /// }
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn split<F>(&self, pred: F) -> Split<T, F> where F: FnMut(&T) -> bool {
+        core_slice::SliceExt::split(self, pred)
+    }
+
+    /// Returns an iterator over subslices separated by elements that match
+    /// `pred`, limited to splitting at most `n` times.  The matched element is
+    /// not contained in the subslices.
+    ///
+    /// # Examples
+    ///
+    /// Print the slice split once by numbers divisible by 3 (i.e. `[10, 40]`,
+    /// `[20, 60, 50]`):
+    ///
+    /// ```
+    /// let v = [10, 40, 30, 20, 60, 50];
+    /// for group in v.splitn(1, |num| *num % 3 == 0) {
+    ///     println!("{:?}", group);
+    /// }
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn splitn<F>(&self, n: usize, pred: F) -> SplitN<T, F> where F: FnMut(&T) -> bool {
+        core_slice::SliceExt::splitn(self, n, pred)
+    }
+
+    /// Returns an iterator over subslices separated by elements that match
+    /// `pred` limited to splitting at most `n` times. This starts at the end of
+    /// the slice and works backwards.  The matched element is not contained in
+    /// the subslices.
+    ///
+    /// # Examples
+    ///
+    /// Print the slice split once, starting from the end, by numbers divisible
+    /// by 3 (i.e. `[50]`, `[10, 40, 30, 20]`):
+    ///
+    /// ```
+    /// let v = [10, 40, 30, 20, 60, 50];
+    /// for group in v.rsplitn(1, |num| *num % 3 == 0) {
+    ///     println!("{:?}", group);
+    /// }
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn rsplitn<F>(&self, n: usize, pred: F) -> RSplitN<T, F> where F: FnMut(&T) -> bool {
+        core_slice::SliceExt::rsplitn(self, n, pred)
+    }
+
+    /// Returns an iterator over all contiguous windows of length
+    /// `size`. The windows overlap. If the slice is shorter than
+    /// `size`, the iterator returns no values.
+    ///
+    /// # Panics
+    ///
+    /// Panics if `size` is 0.
+    ///
+    /// # Example
+    ///
+    /// Print the adjacent pairs of a slice (i.e. `[1,2]`, `[2,3]`,
+    /// `[3,4]`):
+    ///
+    /// ```rust
+    /// let v = &[1, 2, 3, 4];
+    /// for win in v.windows(2) {
+    ///     println!("{:?}", win);
+    /// }
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn windows(&self, size: usize) -> Windows<T> {
+        core_slice::SliceExt::windows(self, size)
+    }
+
+    /// Returns an iterator over `size` elements of the slice at a
+    /// time. The chunks do not overlap. If `size` does not divide the
+    /// length of the slice, then the last chunk will not have length
+    /// `size`.
+    ///
+    /// # Panics
+    ///
+    /// Panics if `size` is 0.
+    ///
+    /// # Example
+    ///
+    /// Print the slice two elements at a time (i.e. `[1,2]`,
+    /// `[3,4]`, `[5]`):
+    ///
+    /// ```rust
+    /// let v = &[1, 2, 3, 4, 5];
+    /// for win in v.chunks(2) {
+    ///     println!("{:?}", win);
+    /// }
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn chunks(&self, size: usize) -> Chunks<T> {
+        core_slice::SliceExt::chunks(self, size)
+    }
+
+    /// Returns the element of a slice at the given index, or `None` if the
+    /// index is out of bounds.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let v = [10, 40, 30];
+    /// assert_eq!(Some(&40), v.get(1));
+    /// assert_eq!(None, v.get(3));
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn get(&self, index: usize) -> Option<&T> {
+        core_slice::SliceExt::get(self, index)
+    }
+
+    /// Returns the first element of a slice, or `None` if it is empty.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let v = [10, 40, 30];
+    /// assert_eq!(Some(&10), v.first());
+    ///
+    /// let w: &[i32] = &[];
+    /// assert_eq!(None, w.first());
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn first(&self) -> Option<&T> {
+        core_slice::SliceExt::first(self)
+    }
+
+    /// Returns all but the first element of a slice.
+    #[unstable(feature = "collections", reason = "likely to be renamed")]
+    #[inline]
+    pub fn tail(&self) -> &[T] {
+        core_slice::SliceExt::tail(self)
+    }
+
+    /// Returns all but the last element of a slice.
+    #[unstable(feature = "collections", reason = "likely to be renamed")]
+    #[inline]
+    pub fn init(&self) -> &[T] {
+        core_slice::SliceExt::init(self)
+    }
+
+    /// Returns the last element of a slice, or `None` if it is empty.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let v = [10, 40, 30];
+    /// assert_eq!(Some(&30), v.last());
+    ///
+    /// let w: &[i32] = &[];
+    /// assert_eq!(None, w.last());
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn last(&self) -> Option<&T> {
+        core_slice::SliceExt::last(self)
+    }
+
+    /// Returns a pointer to the element at the given index, without doing
+    /// bounds checking.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub unsafe fn get_unchecked(&self, index: usize) -> &T {
+        core_slice::SliceExt::get_unchecked(self, index)
+    }
+
+    /// Returns an unsafe pointer to the slice's buffer
+    ///
+    /// The caller must ensure that the slice outlives the pointer this
+    /// function returns, or else it will end up pointing to garbage.
+    ///
+    /// Modifying the slice may cause its buffer to be reallocated, which
+    /// would also make any pointers to it invalid.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn as_ptr(&self) -> *const T {
+        core_slice::SliceExt::as_ptr(self)
+    }
+
+    /// Binary search a sorted slice with a comparator function.
+    ///
+    /// The comparator function should implement an order consistent
+    /// with the sort order of the underlying slice, returning an
+    /// order code that indicates whether its argument is `Less`,
+    /// `Equal` or `Greater` the desired target.
+    ///
+    /// If a matching value is found then returns `Ok`, containing
+    /// the index for the matched element; if no match is found then
+    /// `Err` is returned, containing the index where a matching
+    /// element could be inserted while maintaining sorted order.
+    ///
+    /// # Example
+    ///
+    /// Looks up a series of four elements. The first is found, with a
+    /// uniquely determined position; the second and third are not
+    /// found; the fourth could match any position in `[1,4]`.
+    ///
+    /// ```rust
+    /// let s = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
+    /// let s = s.as_slice();
+    ///
+    /// let seek = 13;
+    /// assert_eq!(s.binary_search_by(|probe| probe.cmp(&seek)), Ok(9));
+    /// let seek = 4;
+    /// assert_eq!(s.binary_search_by(|probe| probe.cmp(&seek)), Err(7));
+    /// let seek = 100;
+    /// assert_eq!(s.binary_search_by(|probe| probe.cmp(&seek)), Err(13));
+    /// let seek = 1;
+    /// let r = s.binary_search_by(|probe| probe.cmp(&seek));
+    /// assert!(match r { Ok(1...4) => true, _ => false, });
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn binary_search_by<F>(&self, f: F) -> Result<usize, usize> where F: FnMut(&T) -> Ordering {
+        core_slice::SliceExt::binary_search_by(self, f)
+    }
+
+    /// Return the number of elements in the slice
+    ///
+    /// # Example
+    ///
+    /// ```
+    /// let a = [1, 2, 3];
+    /// assert_eq!(a.len(), 3);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn len(&self) -> usize {
+        core_slice::SliceExt::len(self)
+    }
+
+    /// Returns true if the slice has a length of 0
+    ///
+    /// # Example
+    ///
+    /// ```
+    /// let a = [1, 2, 3];
+    /// assert!(!a.is_empty());
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn is_empty(&self) -> bool {
+        core_slice::SliceExt::is_empty(self)
+    }
+
+    /// Returns a mutable reference to the element at the given index,
+    /// or `None` if the index is out of bounds
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn get_mut(&mut self, index: usize) -> Option<&mut T> {
+        core_slice::SliceExt::get_mut(self, index)
+    }
+
+    /// Work with `self` as a mut slice.
+    /// Primarily intended for getting a &mut [T] from a [T; N].
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn as_mut_slice(&mut self) -> &mut [T] {
+        core_slice::SliceExt::as_mut_slice(self)
+    }
+
+    /// Deprecated: use `&mut s[start .. end]` instead.
+    #[unstable(feature = "collections",
+               reason = "will be replaced by slice syntax")]
+    #[deprecated(since = "1.0.0", reason = "use &mut s[start .. end] instead")]
+    #[inline]
+    pub fn slice_mut(&mut self, start: usize, end: usize) -> &mut [T] {
+        &mut self[start .. end]
+    }
+
+    /// Deprecated: use `&mut s[start ..]` instead.
+    #[unstable(feature = "collections",
+               reason = "will be replaced by slice syntax")]
+    #[deprecated(since = "1.0.0", reason = "use &mut s[start ..] instead")]
+    #[inline]
+    pub fn slice_from_mut(&mut self, start: usize) -> &mut [T] {
+        &mut self[start ..]
+    }
+
+    /// Deprecated: use `&mut s[.. end]` instead.
+    #[unstable(feature = "collections",
+               reason = "will be replaced by slice syntax")]
+    #[deprecated(since = "1.0.0", reason = "use &mut s[.. end] instead")]
+    #[inline]
+    pub fn slice_to_mut(&mut self, end: usize) -> &mut [T] {
+        &mut self[.. end]
+    }
+
+    /// Returns an iterator that allows modifying each value
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn iter_mut(&mut self) -> IterMut<T> {
+        core_slice::SliceExt::iter_mut(self)
+    }
+
+    /// Returns a mutable pointer to the first element of a slice, or `None` if it is empty
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn first_mut(&mut self) -> Option<&mut T> {
+        core_slice::SliceExt::first_mut(self)
+    }
+
+    /// Returns all but the first element of a mutable slice
+    #[unstable(feature = "collections",
+               reason = "likely to be renamed or removed")]
+    #[inline]
+    pub fn tail_mut(&mut self) -> &mut [T] {
+        core_slice::SliceExt::tail_mut(self)
+    }
+
+    /// Returns all but the last element of a mutable slice
+    #[unstable(feature = "collections",
+               reason = "likely to be renamed or removed")]
+    #[inline]
+    pub fn init_mut(&mut self) -> &mut [T] {
+        core_slice::SliceExt::init_mut(self)
+    }
+
+    /// Returns a mutable pointer to the last item in the slice.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn last_mut(&mut self) -> Option<&mut T> {
+        core_slice::SliceExt::last_mut(self)
+    }
+
+    /// Returns an iterator over mutable subslices separated by elements that
+    /// match `pred`.  The matched element is not contained in the subslices.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn split_mut<F>(&mut self, pred: F) -> SplitMut<T, F> where F: FnMut(&T) -> bool {
+        core_slice::SliceExt::split_mut(self, pred)
+    }
+
+    /// Returns an iterator over subslices separated by elements that match
+    /// `pred`, limited to splitting at most `n` times.  The matched element is
+    /// not contained in the subslices.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn splitn_mut<F>(&mut self, n: usize, pred: F) -> SplitNMut<T, F>
+                         where F: FnMut(&T) -> bool {
+        core_slice::SliceExt::splitn_mut(self, n, pred)
+    }
+
+    /// Returns an iterator over subslices separated by elements that match
+    /// `pred` limited to splitting at most `n` times. This starts at the end of
+    /// the slice and works backwards.  The matched element is not contained in
+    /// the subslices.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn rsplitn_mut<F>(&mut self,  n: usize, pred: F) -> RSplitNMut<T, F>
+                      where F: FnMut(&T) -> bool {
+        core_slice::SliceExt::rsplitn_mut(self, n, pred)
+    }
+
+    /// Returns an iterator over `chunk_size` elements of the slice at a time.
+    /// The chunks are mutable and do not overlap. If `chunk_size` does
+    /// not divide the length of the slice, then the last chunk will not
+    /// have length `chunk_size`.
+    ///
+    /// # Panics
+    ///
+    /// Panics if `chunk_size` is 0.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut<T> {
+        core_slice::SliceExt::chunks_mut(self, chunk_size)
+    }
+
+    /// Swaps two elements in a slice.
+    ///
+    /// # Arguments
+    ///
+    /// * a - The index of the first element
+    /// * b - The index of the second element
+    ///
+    /// # Panics
+    ///
+    /// Panics if `a` or `b` are out of bounds.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// let mut v = ["a", "b", "c", "d"];
+    /// v.swap(1, 3);
+    /// assert!(v == ["a", "d", "c", "b"]);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn swap(&mut self, a: usize, b: usize) {
+        core_slice::SliceExt::swap(self, a, b)
+    }
+
+    /// Divides one `&mut` into two at an index.
+    ///
+    /// The first will contain all indices from `[0, mid)` (excluding
+    /// the index `mid` itself) and the second will contain all
+    /// indices from `[mid, len)` (excluding the index `len` itself).
+    ///
+    /// # Panics
+    ///
+    /// Panics if `mid > len`.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// let mut v = [1, 2, 3, 4, 5, 6];
+    ///
+    /// // scoped to restrict the lifetime of the borrows
+    /// {
+    ///    let (left, right) = v.split_at_mut(0);
+    ///    assert!(left == []);
+    ///    assert!(right == [1, 2, 3, 4, 5, 6]);
+    /// }
+    ///
+    /// {
+    ///     let (left, right) = v.split_at_mut(2);
+    ///     assert!(left == [1, 2]);
+    ///     assert!(right == [3, 4, 5, 6]);
+    /// }
+    ///
+    /// {
+    ///     let (left, right) = v.split_at_mut(6);
+    ///     assert!(left == [1, 2, 3, 4, 5, 6]);
+    ///     assert!(right == []);
+    /// }
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn split_at_mut(&mut self, mid: usize) -> (&mut [T], &mut [T]) {
+        core_slice::SliceExt::split_at_mut(self, mid)
+    }
+
+    /// Reverse the order of elements in a slice, in place.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// let mut v = [1, 2, 3];
+    /// v.reverse();
+    /// assert!(v == [3, 2, 1]);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn reverse(&mut self) {
+        core_slice::SliceExt::reverse(self)
+    }
+
+    /// Returns an unsafe mutable pointer to the element in index
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut T {
+        core_slice::SliceExt::get_unchecked_mut(self, index)
+    }
+
+    /// Return an unsafe mutable pointer to the slice's buffer.
+    ///
+    /// The caller must ensure that the slice outlives the pointer this
+    /// function returns, or else it will end up pointing to garbage.
+    ///
+    /// Modifying the slice may cause its buffer to be reallocated, which
+    /// would also make any pointers to it invalid.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn as_mut_ptr(&mut self) -> *mut T {
+        core_slice::SliceExt::as_mut_ptr(self)
+    }
+
+    /// Copies `self` into a new `Vec`.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn to_vec(&self) -> Vec<T> where T: Clone {
+        // NB see hack module in this file
+        hack::to_vec(self)
+    }
+
+    /// Creates an iterator that yields every possible permutation of the
+    /// vector in succession.
+    ///
+    /// # Examples
+    ///
+    /// ```rust
+    /// let v = [1, 2, 3];
+    /// let mut perms = v.permutations();
+    ///
+    /// for p in perms {
+    ///   println!("{:?}", p);
+    /// }
+    /// ```
+    ///
+    /// Iterating through permutations one by one.
+    ///
+    /// ```rust
+    /// let v = [1, 2, 3];
+    /// let mut perms = v.permutations();
+    ///
+    /// assert_eq!(Some(vec![1, 2, 3]), perms.next());
+    /// assert_eq!(Some(vec![1, 3, 2]), perms.next());
+    /// assert_eq!(Some(vec![3, 1, 2]), perms.next());
+    /// ```
+    #[unstable(feature = "collections")]
+    #[inline]
+    pub fn permutations(&self) -> Permutations<T> where T: Clone {
+        // NB see hack module in this file
+        hack::permutations(self)
+    }
+
+    /// Copies as many elements from `src` as it can into `self` (the
+    /// shorter of `self.len()` and `src.len()`). Returns the number
+    /// of elements copied.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// let mut dst = [0, 0, 0];
+    /// let src = [1, 2];
+    ///
+    /// assert!(dst.clone_from_slice(&src) == 2);
+    /// assert!(dst == [1, 2, 0]);
+    ///
+    /// let src2 = [3, 4, 5, 6];
+    /// assert!(dst.clone_from_slice(&src2) == 3);
+    /// assert!(dst == [3, 4, 5]);
+    /// ```
+    #[unstable(feature = "collections")]
+    pub fn clone_from_slice(&mut self, src: &[T]) -> usize where T: Clone {
+        core_slice::SliceExt::clone_from_slice(self, src)
+    }
+
+    /// Sorts the slice, in place.
+    ///
+    /// This is equivalent to `self.sort_by(|a, b| a.cmp(b))`.
+    ///
+    /// # Examples
+    ///
+    /// ```rust
+    /// let mut v = [-5, 4, 1, -3, 2];
+    ///
+    /// v.sort();
+    /// assert!(v == [-5, -3, 1, 2, 4]);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn sort(&mut self) where T: Ord {
+        self.sort_by(|a, b| a.cmp(b))
+    }
+
+    /// Binary search a sorted slice for a given element.
+    ///
+    /// If the value is found then `Ok` is returned, containing the
+    /// index of the matching element; if the value is not found then
+    /// `Err` is returned, containing the index where a matching
+    /// element could be inserted while maintaining sorted order.
+    ///
+    /// # Example
+    ///
+    /// Looks up a series of four elements. The first is found, with a
+    /// uniquely determined position; the second and third are not
+    /// found; the fourth could match any position in `[1,4]`.
+    ///
+    /// ```rust
+    /// let s = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
+    /// let s = s.as_slice();
+    ///
+    /// assert_eq!(s.binary_search(&13),  Ok(9));
+    /// assert_eq!(s.binary_search(&4),   Err(7));
+    /// assert_eq!(s.binary_search(&100), Err(13));
+    /// let r = s.binary_search(&1);
+    /// assert!(match r { Ok(1...4) => true, _ => false, });
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn binary_search(&self, x: &T) -> Result<usize, usize> where T: Ord {
+        core_slice::SliceExt::binary_search(self, x)
+    }
+
+    /// Deprecated: use `binary_search` instead.
+    #[unstable(feature = "collections")]
+    #[deprecated(since = "1.0.0", reason = "use binary_search instead")]
+    pub fn binary_search_elem(&self, x: &T) -> Result<usize, usize> where T: Ord {
+        self.binary_search(x)
+    }
+
+    /// Mutates the slice to the next lexicographic permutation.
+    ///
+    /// Returns `true` if successful and `false` if the slice is at the
+    /// last-ordered permutation.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// let v: &mut [_] = &mut [0, 1, 2];
+    /// v.next_permutation();
+    /// let b: &mut [_] = &mut [0, 2, 1];
+    /// assert!(v == b);
+    /// v.next_permutation();
+    /// let b: &mut [_] = &mut [1, 0, 2];
+    /// assert!(v == b);
+    /// ```
+    #[unstable(feature = "collections",
+               reason = "uncertain if this merits inclusion in std")]
+    pub fn next_permutation(&mut self) -> bool where T: Ord {
+        core_slice::SliceExt::next_permutation(self)
+    }
+
+    /// Mutates the slice to the previous lexicographic permutation.
+    ///
+    /// Returns `true` if successful and `false` if the slice is at the
+    /// first-ordered permutation.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// let v: &mut [_] = &mut [1, 0, 2];
+    /// v.prev_permutation();
+    /// let b: &mut [_] = &mut [0, 2, 1];
+    /// assert!(v == b);
+    /// v.prev_permutation();
+    /// let b: &mut [_] = &mut [0, 1, 2];
+    /// assert!(v == b);
+    /// ```
+    #[unstable(feature = "collections",
+               reason = "uncertain if this merits inclusion in std")]
+    pub fn prev_permutation(&mut self) -> bool where T: Ord {
+        core_slice::SliceExt::prev_permutation(self)
+    }
+
+    /// Find the first index containing a matching value.
+    #[unstable(feature = "collections")]
+    pub fn position_elem(&self, t: &T) -> Option<usize> where T: PartialEq {
+        core_slice::SliceExt::position_elem(self, t)
+    }
+
+    /// Find the last index containing a matching value.
+    #[unstable(feature = "collections")]
+    pub fn rposition_elem(&self, t: &T) -> Option<usize> where T: PartialEq {
+        core_slice::SliceExt::rposition_elem(self, t)
+    }
+
+    /// Returns true if the slice contains an element with the given value.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let v = [10, 40, 30];
+    /// assert!(v.contains(&30));
+    /// assert!(!v.contains(&50));
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn contains(&self, x: &T) -> bool where T: PartialEq {
+        core_slice::SliceExt::contains(self, x)
+    }
+
+    /// Returns true if `needle` is a prefix of the slice.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let v = [10, 40, 30];
+    /// assert!(v.starts_with(&[10]));
+    /// assert!(v.starts_with(&[10, 40]));
+    /// assert!(!v.starts_with(&[50]));
+    /// assert!(!v.starts_with(&[10, 50]));
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn starts_with(&self, needle: &[T]) -> bool where T: PartialEq {
+        core_slice::SliceExt::starts_with(self, needle)
+    }
+
+    /// Returns true if `needle` is a suffix of the slice.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let v = [10, 40, 30];
+    /// assert!(v.ends_with(&[30]));
+    /// assert!(v.ends_with(&[40, 30]));
+    /// assert!(!v.ends_with(&[50]));
+    /// assert!(!v.ends_with(&[50, 30]));
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn ends_with(&self, needle: &[T]) -> bool where T: PartialEq {
+        core_slice::SliceExt::ends_with(self, needle)
+    }
+
+    /// Convert `self` into a vector without clones or allocation.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn into_vec(self: Box<Self>) -> Vec<T> {
+        // NB see hack module in this file
+        hack::into_vec(self)
+    }
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // Extension traits for slices over specific kinds of data
 ////////////////////////////////////////////////////////////////////////////////
@@ -1189,7 +2128,15 @@ impl<T> BorrowMut<[T]> for Vec<T> {
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: Clone> ToOwned for [T] {
     type Owned = Vec<T>;
+    #[cfg(not(test))]
     fn to_owned(&self) -> Vec<T> { self.to_vec() }
+
+    // HACK(japaric): with cfg(test) the inherent `[T]::to_vec`, which is required for this method
+    // definition, is not available. Since we don't require this method for testing purposes, I'll
+    // just stub it
+    // NB see the slice::hack module in slice.rs for more information
+    #[cfg(test)]
+    fn to_owned(&self) -> Vec<T> { panic!("not available with cfg(test)") }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -1506,1633 +2453,3 @@ fn merge_sort<T, F>(v: &mut [T], mut compare: F) where F: FnMut(&T, &T) -> Order
         old
     }
 }
-
-#[cfg(test)]
-mod tests {
-    use alloc::boxed::Box;
-    use core::cmp::Ordering::{Greater, Less, Equal};
-    use core::prelude::{Some, None, Clone};
-    use core::prelude::{Iterator, IteratorExt};
-    use core::prelude::{AsSlice};
-    use core::prelude::Ord;
-    use core::default::Default;
-    use core::mem;
-    use std::iter::RandomAccessIterator;
-    use std::rand::{Rng, thread_rng};
-    use std::rc::Rc;
-    use string::ToString;
-    use vec::Vec;
-    use super::{ElementSwaps, SliceConcatExt, SliceExt};
-
-    fn square(n: usize) -> usize { n * n }
-
-    fn is_odd(n: &usize) -> bool { *n % 2 == 1 }
-
-    #[test]
-    fn test_from_fn() {
-        // Test on-stack from_fn.
-        let mut v: Vec<_> = (0..3).map(square).collect();
-        {
-            let v = v;
-            assert_eq!(v.len(), 3);
-            assert_eq!(v[0], 0);
-            assert_eq!(v[1], 1);
-            assert_eq!(v[2], 4);
-        }
-
-        // Test on-heap from_fn.
-        v = (0..5).map(square).collect();
-        {
-            let v = v;
-            assert_eq!(v.len(), 5);
-            assert_eq!(v[0], 0);
-            assert_eq!(v[1], 1);
-            assert_eq!(v[2], 4);
-            assert_eq!(v[3], 9);
-            assert_eq!(v[4], 16);
-        }
-    }
-
-    #[test]
-    fn test_from_elem() {
-        // Test on-stack from_elem.
-        let mut v = vec![10, 10];
-        {
-            let v = v;
-            assert_eq!(v.len(), 2);
-            assert_eq!(v[0], 10);
-            assert_eq!(v[1], 10);
-        }
-
-        // Test on-heap from_elem.
-        v = vec![20; 6];
-        {
-            let v = v.as_slice();
-            assert_eq!(v[0], 20);
-            assert_eq!(v[1], 20);
-            assert_eq!(v[2], 20);
-            assert_eq!(v[3], 20);
-            assert_eq!(v[4], 20);
-            assert_eq!(v[5], 20);
-        }
-    }
-
-    #[test]
-    fn test_is_empty() {
-        let xs: [i32; 0] = [];
-        assert!(xs.is_empty());
-        assert!(![0].is_empty());
-    }
-
-    #[test]
-    fn test_len_divzero() {
-        type Z = [i8; 0];
-        let v0 : &[Z] = &[];
-        let v1 : &[Z] = &[[]];
-        let v2 : &[Z] = &[[], []];
-        assert_eq!(mem::size_of::<Z>(), 0);
-        assert_eq!(v0.len(), 0);
-        assert_eq!(v1.len(), 1);
-        assert_eq!(v2.len(), 2);
-    }
-
-    #[test]
-    fn test_get() {
-        let mut a = vec![11];
-        assert_eq!(a.get(1), None);
-        a = vec![11, 12];
-        assert_eq!(a.get(1).unwrap(), &12);
-        a = vec![11, 12, 13];
-        assert_eq!(a.get(1).unwrap(), &12);
-    }
-
-    #[test]
-    fn test_first() {
-        let mut a = vec![];
-        assert_eq!(a.first(), None);
-        a = vec![11];
-        assert_eq!(a.first().unwrap(), &11);
-        a = vec![11, 12];
-        assert_eq!(a.first().unwrap(), &11);
-    }
-
-    #[test]
-    fn test_first_mut() {
-        let mut a = vec![];
-        assert_eq!(a.first_mut(), None);
-        a = vec![11];
-        assert_eq!(*a.first_mut().unwrap(), 11);
-        a = vec![11, 12];
-        assert_eq!(*a.first_mut().unwrap(), 11);
-    }
-
-    #[test]
-    fn test_tail() {
-        let mut a = vec![11];
-        let b: &[i32] = &[];
-        assert_eq!(a.tail(), b);
-        a = vec![11, 12];
-        let b: &[i32] = &[12];
-        assert_eq!(a.tail(), b);
-    }
-
-    #[test]
-    fn test_tail_mut() {
-        let mut a = vec![11];
-        let b: &mut [i32] = &mut [];
-        assert!(a.tail_mut() == b);
-        a = vec![11, 12];
-        let b: &mut [_] = &mut [12];
-        assert!(a.tail_mut() == b);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_tail_empty() {
-        let a = Vec::<i32>::new();
-        a.tail();
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_tail_mut_empty() {
-        let mut a = Vec::<i32>::new();
-        a.tail_mut();
-    }
-
-    #[test]
-    fn test_init() {
-        let mut a = vec![11];
-        let b: &[i32] = &[];
-        assert_eq!(a.init(), b);
-        a = vec![11, 12];
-        let b: &[_] = &[11];
-        assert_eq!(a.init(), b);
-    }
-
-    #[test]
-    fn test_init_mut() {
-        let mut a = vec![11];
-        let b: &mut [i32] = &mut [];
-        assert!(a.init_mut() == b);
-        a = vec![11, 12];
-        let b: &mut [_] = &mut [11];
-        assert!(a.init_mut() == b);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_init_empty() {
-        let a = Vec::<i32>::new();
-        a.init();
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_init_mut_empty() {
-        let mut a = Vec::<i32>::new();
-        a.init_mut();
-    }
-
-    #[test]
-    fn test_last() {
-        let mut a = vec![];
-        assert_eq!(a.last(), None);
-        a = vec![11];
-        assert_eq!(a.last().unwrap(), &11);
-        a = vec![11, 12];
-        assert_eq!(a.last().unwrap(), &12);
-    }
-
-    #[test]
-    fn test_last_mut() {
-        let mut a = vec![];
-        assert_eq!(a.last_mut(), None);
-        a = vec![11];
-        assert_eq!(*a.last_mut().unwrap(), 11);
-        a = vec![11, 12];
-        assert_eq!(*a.last_mut().unwrap(), 12);
-    }
-
-    #[test]
-    fn test_slice() {
-        // Test fixed length vector.
-        let vec_fixed = [1, 2, 3, 4];
-        let v_a = vec_fixed[1..vec_fixed.len()].to_vec();
-        assert_eq!(v_a.len(), 3);
-
-        assert_eq!(v_a[0], 2);
-        assert_eq!(v_a[1], 3);
-        assert_eq!(v_a[2], 4);
-
-        // Test on stack.
-        let vec_stack: &[_] = &[1, 2, 3];
-        let v_b = vec_stack[1..3].to_vec();
-        assert_eq!(v_b.len(), 2);
-
-        assert_eq!(v_b[0], 2);
-        assert_eq!(v_b[1], 3);
-
-        // Test `Box<[T]>`
-        let vec_unique = vec![1, 2, 3, 4, 5, 6];
-        let v_d = vec_unique[1..6].to_vec();
-        assert_eq!(v_d.len(), 5);
-
-        assert_eq!(v_d[0], 2);
-        assert_eq!(v_d[1], 3);
-        assert_eq!(v_d[2], 4);
-        assert_eq!(v_d[3], 5);
-        assert_eq!(v_d[4], 6);
-    }
-
-    #[test]
-    fn test_slice_from() {
-        let vec: &[_] = &[1, 2, 3, 4];
-        assert_eq!(&vec[..], vec);
-        let b: &[_] = &[3, 4];
-        assert_eq!(&vec[2..], b);
-        let b: &[_] = &[];
-        assert_eq!(&vec[4..], b);
-    }
-
-    #[test]
-    fn test_slice_to() {
-        let vec: &[_] = &[1, 2, 3, 4];
-        assert_eq!(&vec[..4], vec);
-        let b: &[_] = &[1, 2];
-        assert_eq!(&vec[..2], b);
-        let b: &[_] = &[];
-        assert_eq!(&vec[..0], b);
-    }
-
-
-    #[test]
-    fn test_pop() {
-        let mut v = vec![5];
-        let e = v.pop();
-        assert_eq!(v.len(), 0);
-        assert_eq!(e, Some(5));
-        let f = v.pop();
-        assert_eq!(f, None);
-        let g = v.pop();
-        assert_eq!(g, None);
-    }
-
-    #[test]
-    fn test_swap_remove() {
-        let mut v = vec![1, 2, 3, 4, 5];
-        let mut e = v.swap_remove(0);
-        assert_eq!(e, 1);
-        assert_eq!(v, [5, 2, 3, 4]);
-        e = v.swap_remove(3);
-        assert_eq!(e, 4);
-        assert_eq!(v, [5, 2, 3]);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_swap_remove_fail() {
-        let mut v = vec![1];
-        let _ = v.swap_remove(0);
-        let _ = v.swap_remove(0);
-    }
-
-    #[test]
-    fn test_swap_remove_noncopyable() {
-        // Tests that we don't accidentally run destructors twice.
-        let mut v: Vec<Box<_>> = Vec::new();
-        v.push(box 0u8);
-        v.push(box 0u8);
-        v.push(box 0u8);
-        let mut _e = v.swap_remove(0);
-        assert_eq!(v.len(), 2);
-        _e = v.swap_remove(1);
-        assert_eq!(v.len(), 1);
-        _e = v.swap_remove(0);
-        assert_eq!(v.len(), 0);
-    }
-
-    #[test]
-    fn test_push() {
-        // Test on-stack push().
-        let mut v = vec![];
-        v.push(1);
-        assert_eq!(v.len(), 1);
-        assert_eq!(v[0], 1);
-
-        // Test on-heap push().
-        v.push(2);
-        assert_eq!(v.len(), 2);
-        assert_eq!(v[0], 1);
-        assert_eq!(v[1], 2);
-    }
-
-    #[test]
-    fn test_truncate() {
-        let mut v: Vec<Box<_>> = vec![box 6,box 5,box 4];
-        v.truncate(1);
-        let v = v;
-        assert_eq!(v.len(), 1);
-        assert_eq!(*(v[0]), 6);
-        // If the unsafe block didn't drop things properly, we blow up here.
-    }
-
-    #[test]
-    fn test_clear() {
-        let mut v: Vec<Box<_>> = vec![box 6,box 5,box 4];
-        v.clear();
-        assert_eq!(v.len(), 0);
-        // If the unsafe block didn't drop things properly, we blow up here.
-    }
-
-    #[test]
-    fn test_dedup() {
-        fn case(a: Vec<i32>, b: Vec<i32>) {
-            let mut v = a;
-            v.dedup();
-            assert_eq!(v, b);
-        }
-        case(vec![], vec![]);
-        case(vec![1], vec![1]);
-        case(vec![1,1], vec![1]);
-        case(vec![1,2,3], vec![1,2,3]);
-        case(vec![1,1,2,3], vec![1,2,3]);
-        case(vec![1,2,2,3], vec![1,2,3]);
-        case(vec![1,2,3,3], vec![1,2,3]);
-        case(vec![1,1,2,2,2,3,3], vec![1,2,3]);
-    }
-
-    #[test]
-    fn test_dedup_unique() {
-        let mut v0: Vec<Box<_>> = vec![box 1, box 1, box 2, box 3];
-        v0.dedup();
-        let mut v1: Vec<Box<_>> = vec![box 1, box 2, box 2, box 3];
-        v1.dedup();
-        let mut v2: Vec<Box<_>> = vec![box 1, box 2, box 3, box 3];
-        v2.dedup();
-        /*
-         * If the boxed pointers were leaked or otherwise misused, valgrind
-         * and/or rt should raise errors.
-         */
-    }
-
-    #[test]
-    fn test_dedup_shared() {
-        let mut v0: Vec<Box<_>> = vec![box 1, box 1, box 2, box 3];
-        v0.dedup();
-        let mut v1: Vec<Box<_>> = vec![box 1, box 2, box 2, box 3];
-        v1.dedup();
-        let mut v2: Vec<Box<_>> = vec![box 1, box 2, box 3, box 3];
-        v2.dedup();
-        /*
-         * If the pointers were leaked or otherwise misused, valgrind and/or
-         * rt should raise errors.
-         */
-    }
-
-    #[test]
-    fn test_retain() {
-        let mut v = vec![1, 2, 3, 4, 5];
-        v.retain(is_odd);
-        assert_eq!(v, [1, 3, 5]);
-    }
-
-    #[test]
-    fn test_element_swaps() {
-        let mut v = [1, 2, 3];
-        for (i, (a, b)) in ElementSwaps::new(v.len()).enumerate() {
-            v.swap(a, b);
-            match i {
-                0 => assert!(v == [1, 3, 2]),
-                1 => assert!(v == [3, 1, 2]),
-                2 => assert!(v == [3, 2, 1]),
-                3 => assert!(v == [2, 3, 1]),
-                4 => assert!(v == [2, 1, 3]),
-                5 => assert!(v == [1, 2, 3]),
-                _ => panic!(),
-            }
-        }
-    }
-
-    #[test]
-    fn test_permutations() {
-        {
-            let v: [i32; 0] = [];
-            let mut it = v.permutations();
-            let (min_size, max_opt) = it.size_hint();
-            assert_eq!(min_size, 1);
-            assert_eq!(max_opt.unwrap(), 1);
-            assert_eq!(it.next(), Some(v.to_vec()));
-            assert_eq!(it.next(), None);
-        }
-        {
-            let v = ["Hello".to_string()];
-            let mut it = v.permutations();
-            let (min_size, max_opt) = it.size_hint();
-            assert_eq!(min_size, 1);
-            assert_eq!(max_opt.unwrap(), 1);
-            assert_eq!(it.next(), Some(v.to_vec()));
-            assert_eq!(it.next(), None);
-        }
-        {
-            let v = [1, 2, 3];
-            let mut it = v.permutations();
-            let (min_size, max_opt) = it.size_hint();
-            assert_eq!(min_size, 3*2);
-            assert_eq!(max_opt.unwrap(), 3*2);
-            assert_eq!(it.next(), Some(vec![1,2,3]));
-            assert_eq!(it.next(), Some(vec![1,3,2]));
-            assert_eq!(it.next(), Some(vec![3,1,2]));
-            let (min_size, max_opt) = it.size_hint();
-            assert_eq!(min_size, 3);
-            assert_eq!(max_opt.unwrap(), 3);
-            assert_eq!(it.next(), Some(vec![3,2,1]));
-            assert_eq!(it.next(), Some(vec![2,3,1]));
-            assert_eq!(it.next(), Some(vec![2,1,3]));
-            assert_eq!(it.next(), None);
-        }
-        {
-            // check that we have N! permutations
-            let v = ['A', 'B', 'C', 'D', 'E', 'F'];
-            let mut amt = 0;
-            let mut it = v.permutations();
-            let (min_size, max_opt) = it.size_hint();
-            for _perm in it.by_ref() {
-                amt += 1;
-            }
-            assert_eq!(amt, it.swaps.swaps_made);
-            assert_eq!(amt, min_size);
-            assert_eq!(amt, 2 * 3 * 4 * 5 * 6);
-            assert_eq!(amt, max_opt.unwrap());
-        }
-    }
-
-    #[test]
-    fn test_lexicographic_permutations() {
-        let v : &mut[_] = &mut[1, 2, 3, 4, 5];
-        assert!(v.prev_permutation() == false);
-        assert!(v.next_permutation());
-        let b: &mut[_] = &mut[1, 2, 3, 5, 4];
-        assert!(v == b);
-        assert!(v.prev_permutation());
-        let b: &mut[_] = &mut[1, 2, 3, 4, 5];
-        assert!(v == b);
-        assert!(v.next_permutation());
-        assert!(v.next_permutation());
-        let b: &mut[_] = &mut[1, 2, 4, 3, 5];
-        assert!(v == b);
-        assert!(v.next_permutation());
-        let b: &mut[_] = &mut[1, 2, 4, 5, 3];
-        assert!(v == b);
-
-        let v : &mut[_] = &mut[1, 0, 0, 0];
-        assert!(v.next_permutation() == false);
-        assert!(v.prev_permutation());
-        let b: &mut[_] = &mut[0, 1, 0, 0];
-        assert!(v == b);
-        assert!(v.prev_permutation());
-        let b: &mut[_] = &mut[0, 0, 1, 0];
-        assert!(v == b);
-        assert!(v.prev_permutation());
-        let b: &mut[_] = &mut[0, 0, 0, 1];
-        assert!(v == b);
-        assert!(v.prev_permutation() == false);
-    }
-
-    #[test]
-    fn test_lexicographic_permutations_empty_and_short() {
-        let empty : &mut[i32] = &mut[];
-        assert!(empty.next_permutation() == false);
-        let b: &mut[i32] = &mut[];
-        assert!(empty == b);
-        assert!(empty.prev_permutation() == false);
-        assert!(empty == b);
-
-        let one_elem : &mut[_] = &mut[4];
-        assert!(one_elem.prev_permutation() == false);
-        let b: &mut[_] = &mut[4];
-        assert!(one_elem == b);
-        assert!(one_elem.next_permutation() == false);
-        assert!(one_elem == b);
-
-        let two_elem : &mut[_] = &mut[1, 2];
-        assert!(two_elem.prev_permutation() == false);
-        let b : &mut[_] = &mut[1, 2];
-        let c : &mut[_] = &mut[2, 1];
-        assert!(two_elem == b);
-        assert!(two_elem.next_permutation());
-        assert!(two_elem == c);
-        assert!(two_elem.next_permutation() == false);
-        assert!(two_elem == c);
-        assert!(two_elem.prev_permutation());
-        assert!(two_elem == b);
-        assert!(two_elem.prev_permutation() == false);
-        assert!(two_elem == b);
-    }
-
-    #[test]
-    fn test_position_elem() {
-        assert!([].position_elem(&1).is_none());
-
-        let v1 = vec![1, 2, 3, 3, 2, 5];
-        assert_eq!(v1.position_elem(&1), Some(0));
-        assert_eq!(v1.position_elem(&2), Some(1));
-        assert_eq!(v1.position_elem(&5), Some(5));
-        assert!(v1.position_elem(&4).is_none());
-    }
-
-    #[test]
-    fn test_binary_search() {
-        assert_eq!([1,2,3,4,5].binary_search(&5).ok(), Some(4));
-        assert_eq!([1,2,3,4,5].binary_search(&4).ok(), Some(3));
-        assert_eq!([1,2,3,4,5].binary_search(&3).ok(), Some(2));
-        assert_eq!([1,2,3,4,5].binary_search(&2).ok(), Some(1));
-        assert_eq!([1,2,3,4,5].binary_search(&1).ok(), Some(0));
-
-        assert_eq!([2,4,6,8,10].binary_search(&1).ok(), None);
-        assert_eq!([2,4,6,8,10].binary_search(&5).ok(), None);
-        assert_eq!([2,4,6,8,10].binary_search(&4).ok(), Some(1));
-        assert_eq!([2,4,6,8,10].binary_search(&10).ok(), Some(4));
-
-        assert_eq!([2,4,6,8].binary_search(&1).ok(), None);
-        assert_eq!([2,4,6,8].binary_search(&5).ok(), None);
-        assert_eq!([2,4,6,8].binary_search(&4).ok(), Some(1));
-        assert_eq!([2,4,6,8].binary_search(&8).ok(), Some(3));
-
-        assert_eq!([2,4,6].binary_search(&1).ok(), None);
-        assert_eq!([2,4,6].binary_search(&5).ok(), None);
-        assert_eq!([2,4,6].binary_search(&4).ok(), Some(1));
-        assert_eq!([2,4,6].binary_search(&6).ok(), Some(2));
-
-        assert_eq!([2,4].binary_search(&1).ok(), None);
-        assert_eq!([2,4].binary_search(&5).ok(), None);
-        assert_eq!([2,4].binary_search(&2).ok(), Some(0));
-        assert_eq!([2,4].binary_search(&4).ok(), Some(1));
-
-        assert_eq!([2].binary_search(&1).ok(), None);
-        assert_eq!([2].binary_search(&5).ok(), None);
-        assert_eq!([2].binary_search(&2).ok(), Some(0));
-
-        assert_eq!([].binary_search(&1).ok(), None);
-        assert_eq!([].binary_search(&5).ok(), None);
-
-        assert!([1,1,1,1,1].binary_search(&1).ok() != None);
-        assert!([1,1,1,1,2].binary_search(&1).ok() != None);
-        assert!([1,1,1,2,2].binary_search(&1).ok() != None);
-        assert!([1,1,2,2,2].binary_search(&1).ok() != None);
-        assert_eq!([1,2,2,2,2].binary_search(&1).ok(), Some(0));
-
-        assert_eq!([1,2,3,4,5].binary_search(&6).ok(), None);
-        assert_eq!([1,2,3,4,5].binary_search(&0).ok(), None);
-    }
-
-    #[test]
-    fn test_reverse() {
-        let mut v = vec![10, 20];
-        assert_eq!(v[0], 10);
-        assert_eq!(v[1], 20);
-        v.reverse();
-        assert_eq!(v[0], 20);
-        assert_eq!(v[1], 10);
-
-        let mut v3 = Vec::<i32>::new();
-        v3.reverse();
-        assert!(v3.is_empty());
-    }
-
-    #[test]
-    fn test_sort() {
-        for len in 4..25 {
-            for _ in 0..100 {
-                let mut v: Vec<_> = thread_rng().gen_iter::<i32>().take(len).collect();
-                let mut v1 = v.clone();
-
-                v.sort();
-                assert!(v.windows(2).all(|w| w[0] <= w[1]));
-
-                v1.sort_by(|a, b| a.cmp(b));
-                assert!(v1.windows(2).all(|w| w[0] <= w[1]));
-
-                v1.sort_by(|a, b| b.cmp(a));
-                assert!(v1.windows(2).all(|w| w[0] >= w[1]));
-            }
-        }
-
-        // shouldn't panic
-        let mut v: [i32; 0] = [];
-        v.sort();
-
-        let mut v = [0xDEADBEEFu64];
-        v.sort();
-        assert!(v == [0xDEADBEEF]);
-    }
-
-    #[test]
-    fn test_sort_stability() {
-        for len in 4..25 {
-            for _ in 0..10 {
-                let mut counts = [0; 10];
-
-                // create a vector like [(6, 1), (5, 1), (6, 2), ...],
-                // where the first item of each tuple is random, but
-                // the second item represents which occurrence of that
-                // number this element is, i.e. the second elements
-                // will occur in sorted order.
-                let mut v: Vec<_> = (0..len).map(|_| {
-                        let n = thread_rng().gen::<usize>() % 10;
-                        counts[n] += 1;
-                        (n, counts[n])
-                    }).collect();
-
-                // only sort on the first element, so an unstable sort
-                // may mix up the counts.
-                v.sort_by(|&(a,_), &(b,_)| a.cmp(&b));
-
-                // this comparison includes the count (the second item
-                // of the tuple), so elements with equal first items
-                // will need to be ordered with increasing
-                // counts... i.e. exactly asserting that this sort is
-                // stable.
-                assert!(v.windows(2).all(|w| w[0] <= w[1]));
-            }
-        }
-    }
-
-    #[test]
-    fn test_concat() {
-        let v: [Vec<i32>; 0] = [];
-        let c = v.concat();
-        assert_eq!(c, []);
-        let d = [vec![1], vec![2, 3]].concat();
-        assert_eq!(d, [1, 2, 3]);
-
-        let v: &[&[_]] = &[&[1], &[2, 3]];
-        assert_eq!(v.connect(&0), [1, 0, 2, 3]);
-        let v: &[&[_]] = &[&[1], &[2], &[3]];
-        assert_eq!(v.connect(&0), [1, 0, 2, 0, 3]);
-    }
-
-    #[test]
-    fn test_connect() {
-        let v: [Vec<i32>; 0] = [];
-        assert_eq!(v.connect(&0), []);
-        assert_eq!([vec![1], vec![2, 3]].connect(&0), [1, 0, 2, 3]);
-        assert_eq!([vec![1], vec![2], vec![3]].connect(&0), [1, 0, 2, 0, 3]);
-
-        let v: [&[_]; 2] = [&[1], &[2, 3]];
-        assert_eq!(v.connect(&0), [1, 0, 2, 3]);
-        let v: [&[_]; 3] = [&[1], &[2], &[3]];
-        assert_eq!(v.connect(&0), [1, 0, 2, 0, 3]);
-    }
-
-    #[test]
-    fn test_insert() {
-        let mut a = vec![1, 2, 4];
-        a.insert(2, 3);
-        assert_eq!(a, [1, 2, 3, 4]);
-
-        let mut a = vec![1, 2, 3];
-        a.insert(0, 0);
-        assert_eq!(a, [0, 1, 2, 3]);
-
-        let mut a = vec![1, 2, 3];
-        a.insert(3, 4);
-        assert_eq!(a, [1, 2, 3, 4]);
-
-        let mut a = vec![];
-        a.insert(0, 1);
-        assert_eq!(a, [1]);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_insert_oob() {
-        let mut a = vec![1, 2, 3];
-        a.insert(4, 5);
-    }
-
-    #[test]
-    fn test_remove() {
-        let mut a = vec![1, 2, 3, 4];
-
-        assert_eq!(a.remove(2), 3);
-        assert_eq!(a, [1, 2, 4]);
-
-        assert_eq!(a.remove(2), 4);
-        assert_eq!(a, [1, 2]);
-
-        assert_eq!(a.remove(0), 1);
-        assert_eq!(a, [2]);
-
-        assert_eq!(a.remove(0), 2);
-        assert_eq!(a, []);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_remove_fail() {
-        let mut a = vec![1];
-        let _ = a.remove(0);
-        let _ = a.remove(0);
-    }
-
-    #[test]
-    fn test_capacity() {
-        let mut v = vec![0];
-        v.reserve_exact(10);
-        assert!(v.capacity() >= 11);
-    }
-
-    #[test]
-    fn test_slice_2() {
-        let v = vec![1, 2, 3, 4, 5];
-        let v = v.slice(1, 3);
-        assert_eq!(v.len(), 2);
-        assert_eq!(v[0], 2);
-        assert_eq!(v[1], 3);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_permute_fail() {
-        let v: [(Box<_>, Rc<_>); 4] =
-            [(box 0, Rc::new(0)), (box 0, Rc::new(0)),
-             (box 0, Rc::new(0)), (box 0, Rc::new(0))];
-        let mut i = 0;
-        for _ in v.permutations() {
-            if i == 2 {
-                panic!()
-            }
-            i += 1;
-        }
-    }
-
-    #[test]
-    fn test_total_ord() {
-        let c = &[1, 2, 3];
-        [1, 2, 3, 4][..].cmp(c) == Greater;
-        let c = &[1, 2, 3, 4];
-        [1, 2, 3][..].cmp(c) == Less;
-        let c = &[1, 2, 3, 6];
-        [1, 2, 3, 4][..].cmp(c) == Equal;
-        let c = &[1, 2, 3, 4, 5, 6];
-        [1, 2, 3, 4, 5, 5, 5, 5][..].cmp(c) == Less;
-        let c = &[1, 2, 3, 4];
-        [2, 2][..].cmp(c) == Greater;
-    }
-
-    #[test]
-    fn test_iterator() {
-        let xs = [1, 2, 5, 10, 11];
-        let mut it = xs.iter();
-        assert_eq!(it.size_hint(), (5, Some(5)));
-        assert_eq!(it.next().unwrap(), &1);
-        assert_eq!(it.size_hint(), (4, Some(4)));
-        assert_eq!(it.next().unwrap(), &2);
-        assert_eq!(it.size_hint(), (3, Some(3)));
-        assert_eq!(it.next().unwrap(), &5);
-        assert_eq!(it.size_hint(), (2, Some(2)));
-        assert_eq!(it.next().unwrap(), &10);
-        assert_eq!(it.size_hint(), (1, Some(1)));
-        assert_eq!(it.next().unwrap(), &11);
-        assert_eq!(it.size_hint(), (0, Some(0)));
-        assert!(it.next().is_none());
-    }
-
-    #[test]
-    fn test_random_access_iterator() {
-        let xs = [1, 2, 5, 10, 11];
-        let mut it = xs.iter();
-
-        assert_eq!(it.indexable(), 5);
-        assert_eq!(it.idx(0).unwrap(), &1);
-        assert_eq!(it.idx(2).unwrap(), &5);
-        assert_eq!(it.idx(4).unwrap(), &11);
-        assert!(it.idx(5).is_none());
-
-        assert_eq!(it.next().unwrap(), &1);
-        assert_eq!(it.indexable(), 4);
-        assert_eq!(it.idx(0).unwrap(), &2);
-        assert_eq!(it.idx(3).unwrap(), &11);
-        assert!(it.idx(4).is_none());
-
-        assert_eq!(it.next().unwrap(), &2);
-        assert_eq!(it.indexable(), 3);
-        assert_eq!(it.idx(1).unwrap(), &10);
-        assert!(it.idx(3).is_none());
-
-        assert_eq!(it.next().unwrap(), &5);
-        assert_eq!(it.indexable(), 2);
-        assert_eq!(it.idx(1).unwrap(), &11);
-
-        assert_eq!(it.next().unwrap(), &10);
-        assert_eq!(it.indexable(), 1);
-        assert_eq!(it.idx(0).unwrap(), &11);
-        assert!(it.idx(1).is_none());
-
-        assert_eq!(it.next().unwrap(), &11);
-        assert_eq!(it.indexable(), 0);
-        assert!(it.idx(0).is_none());
-
-        assert!(it.next().is_none());
-    }
-
-    #[test]
-    fn test_iter_size_hints() {
-        let mut xs = [1, 2, 5, 10, 11];
-        assert_eq!(xs.iter().size_hint(), (5, Some(5)));
-        assert_eq!(xs.iter_mut().size_hint(), (5, Some(5)));
-    }
-
-    #[test]
-    fn test_iter_clone() {
-        let xs = [1, 2, 5];
-        let mut it = xs.iter();
-        it.next();
-        let mut jt = it.clone();
-        assert_eq!(it.next(), jt.next());
-        assert_eq!(it.next(), jt.next());
-        assert_eq!(it.next(), jt.next());
-    }
-
-    #[test]
-    fn test_mut_iterator() {
-        let mut xs = [1, 2, 3, 4, 5];
-        for x in &mut xs {
-            *x += 1;
-        }
-        assert!(xs == [2, 3, 4, 5, 6])
-    }
-
-    #[test]
-    fn test_rev_iterator() {
-
-        let xs = [1, 2, 5, 10, 11];
-        let ys = [11, 10, 5, 2, 1];
-        let mut i = 0;
-        for &x in xs.iter().rev() {
-            assert_eq!(x, ys[i]);
-            i += 1;
-        }
-        assert_eq!(i, 5);
-    }
-
-    #[test]
-    fn test_mut_rev_iterator() {
-        let mut xs = [1, 2, 3, 4, 5];
-        for (i,x) in xs.iter_mut().rev().enumerate() {
-            *x += i;
-        }
-        assert!(xs == [5, 5, 5, 5, 5])
-    }
-
-    #[test]
-    fn test_move_iterator() {
-        let xs = vec![1,2,3,4,5];
-        assert_eq!(xs.into_iter().fold(0, |a: usize, b: usize| 10*a + b), 12345);
-    }
-
-    #[test]
-    fn test_move_rev_iterator() {
-        let xs = vec![1,2,3,4,5];
-        assert_eq!(xs.into_iter().rev().fold(0, |a: usize, b: usize| 10*a + b), 54321);
-    }
-
-    #[test]
-    fn test_splitator() {
-        let xs = &[1,2,3,4,5];
-
-        let splits: &[&[_]] = &[&[1], &[3], &[5]];
-        assert_eq!(xs.split(|x| *x % 2 == 0).collect::<Vec<_>>(),
-                   splits);
-        let splits: &[&[_]] = &[&[], &[2,3,4,5]];
-        assert_eq!(xs.split(|x| *x == 1).collect::<Vec<_>>(),
-                   splits);
-        let splits: &[&[_]] = &[&[1,2,3,4], &[]];
-        assert_eq!(xs.split(|x| *x == 5).collect::<Vec<_>>(),
-                   splits);
-        let splits: &[&[_]] = &[&[1,2,3,4,5]];
-        assert_eq!(xs.split(|x| *x == 10).collect::<Vec<_>>(),
-                   splits);
-        let splits: &[&[_]] = &[&[], &[], &[], &[], &[], &[]];
-        assert_eq!(xs.split(|_| true).collect::<Vec<&[i32]>>(),
-                   splits);
-
-        let xs: &[i32] = &[];
-        let splits: &[&[i32]] = &[&[]];
-        assert_eq!(xs.split(|x| *x == 5).collect::<Vec<&[i32]>>(), splits);
-    }
-
-    #[test]
-    fn test_splitnator() {
-        let xs = &[1,2,3,4,5];
-
-        let splits: &[&[_]] = &[&[1,2,3,4,5]];
-        assert_eq!(xs.splitn(0, |x| *x % 2 == 0).collect::<Vec<_>>(),
-                   splits);
-        let splits: &[&[_]] = &[&[1], &[3,4,5]];
-        assert_eq!(xs.splitn(1, |x| *x % 2 == 0).collect::<Vec<_>>(),
-                   splits);
-        let splits: &[&[_]] = &[&[], &[], &[], &[4,5]];
-        assert_eq!(xs.splitn(3, |_| true).collect::<Vec<_>>(),
-                   splits);
-
-        let xs: &[i32] = &[];
-        let splits: &[&[i32]] = &[&[]];
-        assert_eq!(xs.splitn(1, |x| *x == 5).collect::<Vec<_>>(), splits);
-    }
-
-    #[test]
-    fn test_splitnator_mut() {
-        let xs = &mut [1,2,3,4,5];
-
-        let splits: &[&mut[_]] = &[&mut [1,2,3,4,5]];
-        assert_eq!(xs.splitn_mut(0, |x| *x % 2 == 0).collect::<Vec<_>>(),
-                   splits);
-        let splits: &[&mut[_]] = &[&mut [1], &mut [3,4,5]];
-        assert_eq!(xs.splitn_mut(1, |x| *x % 2 == 0).collect::<Vec<_>>(),
-                   splits);
-        let splits: &[&mut[_]] = &[&mut [], &mut [], &mut [], &mut [4,5]];
-        assert_eq!(xs.splitn_mut(3, |_| true).collect::<Vec<_>>(),
-                   splits);
-
-        let xs: &mut [i32] = &mut [];
-        let splits: &[&mut[i32]] = &[&mut []];
-        assert_eq!(xs.splitn_mut(1, |x| *x == 5).collect::<Vec<_>>(),
-                   splits);
-    }
-
-    #[test]
-    fn test_rsplitator() {
-        let xs = &[1,2,3,4,5];
-
-        let splits: &[&[_]] = &[&[5], &[3], &[1]];
-        assert_eq!(xs.split(|x| *x % 2 == 0).rev().collect::<Vec<_>>(),
-                   splits);
-        let splits: &[&[_]] = &[&[2,3,4,5], &[]];
-        assert_eq!(xs.split(|x| *x == 1).rev().collect::<Vec<_>>(),
-                   splits);
-        let splits: &[&[_]] = &[&[], &[1,2,3,4]];
-        assert_eq!(xs.split(|x| *x == 5).rev().collect::<Vec<_>>(),
-                   splits);
-        let splits: &[&[_]] = &[&[1,2,3,4,5]];
-        assert_eq!(xs.split(|x| *x == 10).rev().collect::<Vec<_>>(),
-                   splits);
-
-        let xs: &[i32] = &[];
-        let splits: &[&[i32]] = &[&[]];
-        assert_eq!(xs.split(|x| *x == 5).rev().collect::<Vec<&[i32]>>(), splits);
-    }
-
-    #[test]
-    fn test_rsplitnator() {
-        let xs = &[1,2,3,4,5];
-
-        let splits: &[&[_]] = &[&[1,2,3,4,5]];
-        assert_eq!(xs.rsplitn(0, |x| *x % 2 == 0).collect::<Vec<_>>(),
-                   splits);
-        let splits: &[&[_]] = &[&[5], &[1,2,3]];
-        assert_eq!(xs.rsplitn(1, |x| *x % 2 == 0).collect::<Vec<_>>(),
-                   splits);
-        let splits: &[&[_]] = &[&[], &[], &[], &[1,2]];
-        assert_eq!(xs.rsplitn(3, |_| true).collect::<Vec<_>>(),
-                   splits);
-
-        let xs: &[i32]  = &[];
-        let splits: &[&[i32]] = &[&[]];
-        assert_eq!(xs.rsplitn(1, |x| *x == 5).collect::<Vec<&[i32]>>(), splits);
-    }
-
-    #[test]
-    fn test_windowsator() {
-        let v = &[1,2,3,4];
-
-        let wins: &[&[_]] = &[&[1,2], &[2,3], &[3,4]];
-        assert_eq!(v.windows(2).collect::<Vec<_>>(), wins);
-
-        let wins: &[&[_]] = &[&[1,2,3], &[2,3,4]];
-        assert_eq!(v.windows(3).collect::<Vec<_>>(), wins);
-        assert!(v.windows(6).next().is_none());
-
-        let wins: &[&[_]] = &[&[3,4], &[2,3], &[1,2]];
-        assert_eq!(v.windows(2).rev().collect::<Vec<&[_]>>(), wins);
-        let mut it = v.windows(2);
-        assert_eq!(it.indexable(), 3);
-        let win: &[_] = &[1,2];
-        assert_eq!(it.idx(0).unwrap(), win);
-        let win: &[_] = &[2,3];
-        assert_eq!(it.idx(1).unwrap(), win);
-        let win: &[_] = &[3,4];
-        assert_eq!(it.idx(2).unwrap(), win);
-        assert_eq!(it.idx(3), None);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_windowsator_0() {
-        let v = &[1,2,3,4];
-        let _it = v.windows(0);
-    }
-
-    #[test]
-    fn test_chunksator() {
-        use core::iter::ExactSizeIterator;
-
-        let v = &[1,2,3,4,5];
-
-        assert_eq!(v.chunks(2).len(), 3);
-
-        let chunks: &[&[_]] = &[&[1,2], &[3,4], &[5]];
-        assert_eq!(v.chunks(2).collect::<Vec<_>>(), chunks);
-        let chunks: &[&[_]] = &[&[1,2,3], &[4,5]];
-        assert_eq!(v.chunks(3).collect::<Vec<_>>(), chunks);
-        let chunks: &[&[_]] = &[&[1,2,3,4,5]];
-        assert_eq!(v.chunks(6).collect::<Vec<_>>(), chunks);
-
-        let chunks: &[&[_]] = &[&[5], &[3,4], &[1,2]];
-        assert_eq!(v.chunks(2).rev().collect::<Vec<_>>(), chunks);
-        let mut it = v.chunks(2);
-        assert_eq!(it.indexable(), 3);
-
-        let chunk: &[_] = &[1,2];
-        assert_eq!(it.idx(0).unwrap(), chunk);
-        let chunk: &[_] = &[3,4];
-        assert_eq!(it.idx(1).unwrap(), chunk);
-        let chunk: &[_] = &[5];
-        assert_eq!(it.idx(2).unwrap(), chunk);
-        assert_eq!(it.idx(3), None);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_chunksator_0() {
-        let v = &[1,2,3,4];
-        let _it = v.chunks(0);
-    }
-
-    #[test]
-    fn test_move_from() {
-        let mut a = [1,2,3,4,5];
-        let b = vec![6,7,8];
-        assert_eq!(a.move_from(b, 0, 3), 3);
-        assert!(a == [6,7,8,4,5]);
-        let mut a = [7,2,8,1];
-        let b = vec![3,1,4,1,5,9];
-        assert_eq!(a.move_from(b, 0, 6), 4);
-        assert!(a == [3,1,4,1]);
-        let mut a = [1,2,3,4];
-        let b = vec![5,6,7,8,9,0];
-        assert_eq!(a.move_from(b, 2, 3), 1);
-        assert!(a == [7,2,3,4]);
-        let mut a = [1,2,3,4,5];
-        let b = vec![5,6,7,8,9,0];
-        assert_eq!(a[2..4].move_from(b,1,6), 2);
-        assert!(a == [1,2,6,7,5]);
-    }
-
-    #[test]
-    fn test_reverse_part() {
-        let mut values = [1,2,3,4,5];
-        values[1..4].reverse();
-        assert!(values == [1,4,3,2,5]);
-    }
-
-    #[test]
-    fn test_show() {
-        macro_rules! test_show_vec {
-            ($x:expr, $x_str:expr) => ({
-                let (x, x_str) = ($x, $x_str);
-                assert_eq!(format!("{:?}", x), x_str);
-                assert_eq!(format!("{:?}", x), x_str);
-            })
-        }
-        let empty = Vec::<i32>::new();
-        test_show_vec!(empty, "[]");
-        test_show_vec!(vec![1], "[1]");
-        test_show_vec!(vec![1, 2, 3], "[1, 2, 3]");
-        test_show_vec!(vec![vec![], vec![1], vec![1, 1]],
-                       "[[], [1], [1, 1]]");
-
-        let empty_mut: &mut [i32] = &mut[];
-        test_show_vec!(empty_mut, "[]");
-        let v = &mut[1];
-        test_show_vec!(v, "[1]");
-        let v = &mut[1, 2, 3];
-        test_show_vec!(v, "[1, 2, 3]");
-        let v: &mut[&mut[_]] = &mut[&mut[], &mut[1], &mut[1, 1]];
-        test_show_vec!(v, "[[], [1], [1, 1]]");
-    }
-
-    #[test]
-    fn test_vec_default() {
-        macro_rules! t {
-            ($ty:ty) => {{
-                let v: $ty = Default::default();
-                assert!(v.is_empty());
-            }}
-        }
-
-        t!(&[i32]);
-        t!(Vec<i32>);
-    }
-
-    #[test]
-    fn test_bytes_set_memory() {
-        use slice::bytes::MutableByteVector;
-        let mut values = [1,2,3,4,5];
-        values[0..5].set_memory(0xAB);
-        assert!(values == [0xAB, 0xAB, 0xAB, 0xAB, 0xAB]);
-        values[2..4].set_memory(0xFF);
-        assert!(values == [0xAB, 0xAB, 0xFF, 0xFF, 0xAB]);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_overflow_does_not_cause_segfault() {
-        let mut v = vec![];
-        v.reserve_exact(-1);
-        v.push(1);
-        v.push(2);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_overflow_does_not_cause_segfault_managed() {
-        let mut v = vec![Rc::new(1)];
-        v.reserve_exact(-1);
-        v.push(Rc::new(2));
-    }
-
-    #[test]
-    fn test_mut_split_at() {
-        let mut values = [1u8,2,3,4,5];
-        {
-            let (left, right) = values.split_at_mut(2);
-            {
-                let left: &[_] = left;
-                assert!(left[..left.len()] == [1, 2]);
-            }
-            for p in left {
-                *p += 1;
-            }
-
-            {
-                let right: &[_] = right;
-                assert!(right[..right.len()] == [3, 4, 5]);
-            }
-            for p in right {
-                *p += 2;
-            }
-        }
-
-        assert!(values == [2, 3, 5, 6, 7]);
-    }
-
-    #[derive(Clone, PartialEq)]
-    struct Foo;
-
-    #[test]
-    fn test_iter_zero_sized() {
-        let mut v = vec![Foo, Foo, Foo];
-        assert_eq!(v.len(), 3);
-        let mut cnt = 0;
-
-        for f in &v {
-            assert!(*f == Foo);
-            cnt += 1;
-        }
-        assert_eq!(cnt, 3);
-
-        for f in &v[1..3] {
-            assert!(*f == Foo);
-            cnt += 1;
-        }
-        assert_eq!(cnt, 5);
-
-        for f in &mut v {
-            assert!(*f == Foo);
-            cnt += 1;
-        }
-        assert_eq!(cnt, 8);
-
-        for f in v {
-            assert!(f == Foo);
-            cnt += 1;
-        }
-        assert_eq!(cnt, 11);
-
-        let xs: [Foo; 3] = [Foo, Foo, Foo];
-        cnt = 0;
-        for f in &xs {
-            assert!(*f == Foo);
-            cnt += 1;
-        }
-        assert!(cnt == 3);
-    }
-
-    #[test]
-    fn test_shrink_to_fit() {
-        let mut xs = vec![0, 1, 2, 3];
-        for i in 4..100 {
-            xs.push(i)
-        }
-        assert_eq!(xs.capacity(), 128);
-        xs.shrink_to_fit();
-        assert_eq!(xs.capacity(), 100);
-        assert_eq!(xs, (0..100).collect::<Vec<_>>());
-    }
-
-    #[test]
-    fn test_starts_with() {
-        assert!(b"foobar".starts_with(b"foo"));
-        assert!(!b"foobar".starts_with(b"oob"));
-        assert!(!b"foobar".starts_with(b"bar"));
-        assert!(!b"foo".starts_with(b"foobar"));
-        assert!(!b"bar".starts_with(b"foobar"));
-        assert!(b"foobar".starts_with(b"foobar"));
-        let empty: &[u8] = &[];
-        assert!(empty.starts_with(empty));
-        assert!(!empty.starts_with(b"foo"));
-        assert!(b"foobar".starts_with(empty));
-    }
-
-    #[test]
-    fn test_ends_with() {
-        assert!(b"foobar".ends_with(b"bar"));
-        assert!(!b"foobar".ends_with(b"oba"));
-        assert!(!b"foobar".ends_with(b"foo"));
-        assert!(!b"foo".ends_with(b"foobar"));
-        assert!(!b"bar".ends_with(b"foobar"));
-        assert!(b"foobar".ends_with(b"foobar"));
-        let empty: &[u8] = &[];
-        assert!(empty.ends_with(empty));
-        assert!(!empty.ends_with(b"foo"));
-        assert!(b"foobar".ends_with(empty));
-    }
-
-    #[test]
-    fn test_mut_splitator() {
-        let mut xs = [0,1,0,2,3,0,0,4,5,0];
-        assert_eq!(xs.split_mut(|x| *x == 0).count(), 6);
-        for slice in xs.split_mut(|x| *x == 0) {
-            slice.reverse();
-        }
-        assert!(xs == [0,1,0,3,2,0,0,5,4,0]);
-
-        let mut xs = [0,1,0,2,3,0,0,4,5,0,6,7];
-        for slice in xs.split_mut(|x| *x == 0).take(5) {
-            slice.reverse();
-        }
-        assert!(xs == [0,1,0,3,2,0,0,5,4,0,6,7]);
-    }
-
-    #[test]
-    fn test_mut_splitator_rev() {
-        let mut xs = [1,2,0,3,4,0,0,5,6,0];
-        for slice in xs.split_mut(|x| *x == 0).rev().take(4) {
-            slice.reverse();
-        }
-        assert!(xs == [1,2,0,4,3,0,0,6,5,0]);
-    }
-
-    #[test]
-    fn test_get_mut() {
-        let mut v = [0,1,2];
-        assert_eq!(v.get_mut(3), None);
-        v.get_mut(1).map(|e| *e = 7);
-        assert_eq!(v[1], 7);
-        let mut x = 2;
-        assert_eq!(v.get_mut(2), Some(&mut x));
-    }
-
-    #[test]
-    fn test_mut_chunks() {
-        use core::iter::ExactSizeIterator;
-
-        let mut v = [0, 1, 2, 3, 4, 5, 6];
-        assert_eq!(v.chunks_mut(2).len(), 4);
-        for (i, chunk) in v.chunks_mut(3).enumerate() {
-            for x in chunk {
-                *x = i as u8;
-            }
-        }
-        let result = [0, 0, 0, 1, 1, 1, 2];
-        assert!(v == result);
-    }
-
-    #[test]
-    fn test_mut_chunks_rev() {
-        let mut v = [0, 1, 2, 3, 4, 5, 6];
-        for (i, chunk) in v.chunks_mut(3).rev().enumerate() {
-            for x in chunk {
-                *x = i as u8;
-            }
-        }
-        let result = [2, 2, 2, 1, 1, 1, 0];
-        assert!(v == result);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_mut_chunks_0() {
-        let mut v = [1, 2, 3, 4];
-        let _it = v.chunks_mut(0);
-    }
-
-    #[test]
-    fn test_mut_last() {
-        let mut x = [1, 2, 3, 4, 5];
-        let h = x.last_mut();
-        assert_eq!(*h.unwrap(), 5);
-
-        let y: &mut [i32] = &mut [];
-        assert!(y.last_mut().is_none());
-    }
-
-    #[test]
-    fn test_to_vec() {
-        let xs: Box<_> = box [1, 2, 3];
-        let ys = xs.to_vec();
-        assert_eq!(ys, [1, 2, 3]);
-    }
-}
-
-#[cfg(test)]
-mod bench {
-    use prelude::*;
-    use core::mem;
-    use core::ptr;
-    use core::iter::repeat;
-    use std::rand::{weak_rng, Rng};
-    use test::{Bencher, black_box};
-
-    #[bench]
-    fn iterator(b: &mut Bencher) {
-        // peculiar numbers to stop LLVM from optimising the summation
-        // out.
-        let v: Vec<_> = (0..100).map(|i| i ^ (i << 1) ^ (i >> 1)).collect();
-
-        b.iter(|| {
-            let mut sum = 0;
-            for x in &v {
-                sum += *x;
-            }
-            // sum == 11806, to stop dead code elimination.
-            if sum == 0 {panic!()}
-        })
-    }
-
-    #[bench]
-    fn mut_iterator(b: &mut Bencher) {
-        let mut v: Vec<_> = repeat(0).take(100).collect();
-
-        b.iter(|| {
-            let mut i = 0;
-            for x in &mut v {
-                *x = i;
-                i += 1;
-            }
-        })
-    }
-
-    #[bench]
-    fn concat(b: &mut Bencher) {
-        let xss: Vec<Vec<i32>> =
-            (0..100).map(|i| (0..i).collect()).collect();
-        b.iter(|| {
-            xss.concat();
-        });
-    }
-
-    #[bench]
-    fn connect(b: &mut Bencher) {
-        let xss: Vec<Vec<i32>> =
-            (0..100).map(|i| (0..i).collect()).collect();
-        b.iter(|| {
-            xss.connect(&0)
-        });
-    }
-
-    #[bench]
-    fn push(b: &mut Bencher) {
-        let mut vec = Vec::<i32>::new();
-        b.iter(|| {
-            vec.push(0);
-            black_box(&vec);
-        });
-    }
-
-    #[bench]
-    fn starts_with_same_vector(b: &mut Bencher) {
-        let vec: Vec<_> = (0..100).collect();
-        b.iter(|| {
-            vec.starts_with(&vec)
-        })
-    }
-
-    #[bench]
-    fn starts_with_single_element(b: &mut Bencher) {
-        let vec: Vec<_> = vec![0];
-        b.iter(|| {
-            vec.starts_with(&vec)
-        })
-    }
-
-    #[bench]
-    fn starts_with_diff_one_element_at_end(b: &mut Bencher) {
-        let vec: Vec<_> = (0..100).collect();
-        let mut match_vec: Vec<_> = (0..99).collect();
-        match_vec.push(0);
-        b.iter(|| {
-            vec.starts_with(&match_vec)
-        })
-    }
-
-    #[bench]
-    fn ends_with_same_vector(b: &mut Bencher) {
-        let vec: Vec<_> = (0..100).collect();
-        b.iter(|| {
-            vec.ends_with(&vec)
-        })
-    }
-
-    #[bench]
-    fn ends_with_single_element(b: &mut Bencher) {
-        let vec: Vec<_> = vec![0];
-        b.iter(|| {
-            vec.ends_with(&vec)
-        })
-    }
-
-    #[bench]
-    fn ends_with_diff_one_element_at_beginning(b: &mut Bencher) {
-        let vec: Vec<_> = (0..100).collect();
-        let mut match_vec: Vec<_> = (0..100).collect();
-        match_vec[0] = 200;
-        b.iter(|| {
-            vec.starts_with(&match_vec)
-        })
-    }
-
-    #[bench]
-    fn contains_last_element(b: &mut Bencher) {
-        let vec: Vec<_> = (0..100).collect();
-        b.iter(|| {
-            vec.contains(&99)
-        })
-    }
-
-    #[bench]
-    fn zero_1kb_from_elem(b: &mut Bencher) {
-        b.iter(|| {
-            repeat(0u8).take(1024).collect::<Vec<_>>()
-        });
-    }
-
-    #[bench]
-    fn zero_1kb_set_memory(b: &mut Bencher) {
-        b.iter(|| {
-            let mut v = Vec::<u8>::with_capacity(1024);
-            unsafe {
-                let vp = v.as_mut_ptr();
-                ptr::set_memory(vp, 0, 1024);
-                v.set_len(1024);
-            }
-            v
-        });
-    }
-
-    #[bench]
-    fn zero_1kb_loop_set(b: &mut Bencher) {
-        b.iter(|| {
-            let mut v = Vec::<u8>::with_capacity(1024);
-            unsafe {
-                v.set_len(1024);
-            }
-            for i in 0..1024 {
-                v[i] = 0;
-            }
-        });
-    }
-
-    #[bench]
-    fn zero_1kb_mut_iter(b: &mut Bencher) {
-        b.iter(|| {
-            let mut v = Vec::<u8>::with_capacity(1024);
-            unsafe {
-                v.set_len(1024);
-            }
-            for x in &mut v {
-                *x = 0;
-            }
-            v
-        });
-    }
-
-    #[bench]
-    fn random_inserts(b: &mut Bencher) {
-        let mut rng = weak_rng();
-        b.iter(|| {
-            let mut v: Vec<_> = repeat((0, 0)).take(30).collect();
-            for _ in 0..100 {
-                let l = v.len();
-                v.insert(rng.gen::<usize>() % (l + 1),
-                         (1, 1));
-            }
-        })
-    }
-    #[bench]
-    fn random_removes(b: &mut Bencher) {
-        let mut rng = weak_rng();
-        b.iter(|| {
-            let mut v: Vec<_> = repeat((0, 0)).take(130).collect();
-            for _ in 0..100 {
-                let l = v.len();
-                v.remove(rng.gen::<usize>() % l);
-            }
-        })
-    }
-
-    #[bench]
-    fn sort_random_small(b: &mut Bencher) {
-        let mut rng = weak_rng();
-        b.iter(|| {
-            let mut v: Vec<_> = rng.gen_iter::<u64>().take(5).collect();
-            v.sort();
-        });
-        b.bytes = 5 * mem::size_of::<u64>() as u64;
-    }
-
-    #[bench]
-    fn sort_random_medium(b: &mut Bencher) {
-        let mut rng = weak_rng();
-        b.iter(|| {
-            let mut v: Vec<_> = rng.gen_iter::<u64>().take(100).collect();
-            v.sort();
-        });
-        b.bytes = 100 * mem::size_of::<u64>() as u64;
-    }
-
-    #[bench]
-    fn sort_random_large(b: &mut Bencher) {
-        let mut rng = weak_rng();
-        b.iter(|| {
-            let mut v: Vec<_> = rng.gen_iter::<u64>().take(10000).collect();
-            v.sort();
-        });
-        b.bytes = 10000 * mem::size_of::<u64>() as u64;
-    }
-
-    #[bench]
-    fn sort_sorted(b: &mut Bencher) {
-        let mut v: Vec<_> = (0..10000).collect();
-        b.iter(|| {
-            v.sort();
-        });
-        b.bytes = (v.len() * mem::size_of_val(&v[0])) as u64;
-    }
-
-    type BigSortable = (u64, u64, u64, u64);
-
-    #[bench]
-    fn sort_big_random_small(b: &mut Bencher) {
-        let mut rng = weak_rng();
-        b.iter(|| {
-            let mut v = rng.gen_iter::<BigSortable>().take(5)
-                           .collect::<Vec<BigSortable>>();
-            v.sort();
-        });
-        b.bytes = 5 * mem::size_of::<BigSortable>() as u64;
-    }
-
-    #[bench]
-    fn sort_big_random_medium(b: &mut Bencher) {
-        let mut rng = weak_rng();
-        b.iter(|| {
-            let mut v = rng.gen_iter::<BigSortable>().take(100)
-                           .collect::<Vec<BigSortable>>();
-            v.sort();
-        });
-        b.bytes = 100 * mem::size_of::<BigSortable>() as u64;
-    }
-
-    #[bench]
-    fn sort_big_random_large(b: &mut Bencher) {
-        let mut rng = weak_rng();
-        b.iter(|| {
-            let mut v = rng.gen_iter::<BigSortable>().take(10000)
-                           .collect::<Vec<BigSortable>>();
-            v.sort();
-        });
-        b.bytes = 10000 * mem::size_of::<BigSortable>() as u64;
-    }
-
-    #[bench]
-    fn sort_big_sorted(b: &mut Bencher) {
-        let mut v: Vec<BigSortable> = (0..10000).map(|i| (i, i, i, i)).collect();
-        b.iter(|| {
-            v.sort();
-        });
-        b.bytes = (v.len() * mem::size_of_val(&v[0])) as u64;
-    }
-}
diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs
index 31d7677d19e..b2273646b95 100644
--- a/src/libcollections/str.rs
+++ b/src/libcollections/str.rs
@@ -59,17 +59,21 @@ use self::DecompositionType::*;
 use core::clone::Clone;
 use core::iter::AdditiveIterator;
 use core::iter::{Iterator, IteratorExt, Extend};
+#[cfg(stage0)]
 use core::ops::Index;
+#[cfg(stage0)]
 use core::ops::RangeFull;
 use core::option::Option::{self, Some, None};
 use core::result::Result;
 use core::slice::AsSlice;
 use core::str as core_str;
+#[cfg(stage0)]
 use unicode::char::CharExt;
 use unicode::str::{UnicodeStr, Utf16Encoder};
 
 use vec_deque::VecDeque;
 use borrow::{Borrow, ToOwned};
+#[cfg(stage0)]
 use slice::SliceExt;
 use string::String;
 use unicode;
@@ -415,6 +419,7 @@ Section: CowString
 Section: Trait implementations
 */
 
+#[cfg(stage0)]
 /// Any string that can be represented as a slice.
 #[stable(feature = "rust1", since = "1.0.0")]
 pub trait StrExt: Index<RangeFull, Output = str> {
@@ -906,7 +911,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// assert!("banana".ends_with("nana"));
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
@@ -1539,6 +1544,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
     }
 }
 
+#[cfg(stage0)]
 #[stable(feature = "rust1", since = "1.0.0")]
 impl StrExt for str {
     fn slice(&self, begin: usize, end: usize) -> &str {
@@ -1554,1667 +1560,1135 @@ impl StrExt for str {
     }
 }
 
-#[cfg(test)]
-mod tests {
-    use prelude::*;
-
-    use core::iter::AdditiveIterator;
-    use super::from_utf8;
-    use super::Utf8Error;
-
-    #[test]
-    fn test_le() {
-        assert!("" <= "");
-        assert!("" <= "foo");
-        assert!("foo" <= "foo");
-        assert!("foo" != "bar");
-    }
-
-    #[test]
-    fn test_len() {
-        assert_eq!("".len(), 0);
-        assert_eq!("hello world".len(), 11);
-        assert_eq!("\x63".len(), 1);
-        assert_eq!("\u{a2}".len(), 2);
-        assert_eq!("\u{3c0}".len(), 2);
-        assert_eq!("\u{2620}".len(), 3);
-        assert_eq!("\u{1d11e}".len(), 4);
-
-        assert_eq!("".chars().count(), 0);
-        assert_eq!("hello world".chars().count(), 11);
-        assert_eq!("\x63".chars().count(), 1);
-        assert_eq!("\u{a2}".chars().count(), 1);
-        assert_eq!("\u{3c0}".chars().count(), 1);
-        assert_eq!("\u{2620}".chars().count(), 1);
-        assert_eq!("\u{1d11e}".chars().count(), 1);
-        assert_eq!("ประเทศไทย中华Việt Nam".chars().count(), 19);
-
-        assert_eq!("hello".width(false), 10);
-        assert_eq!("hello".width(true), 10);
-        assert_eq!("\0\0\0\0\0".width(false), 0);
-        assert_eq!("\0\0\0\0\0".width(true), 0);
-        assert_eq!("".width(false), 0);
-        assert_eq!("".width(true), 0);
-        assert_eq!("\u{2081}\u{2082}\u{2083}\u{2084}".width(false), 4);
-        assert_eq!("\u{2081}\u{2082}\u{2083}\u{2084}".width(true), 8);
-    }
-
-    #[test]
-    fn test_find() {
-        assert_eq!("hello".find('l'), Some(2));
-        assert_eq!("hello".find(|c:char| c == 'o'), Some(4));
-        assert!("hello".find('x').is_none());
-        assert!("hello".find(|c:char| c == 'x').is_none());
-        assert_eq!("ประเทศไทย中华Việt Nam".find('华'), Some(30));
-        assert_eq!("ประเทศไทย中华Việt Nam".find(|c: char| c == '华'), Some(30));
-    }
-
-    #[test]
-    fn test_rfind() {
-        assert_eq!("hello".rfind('l'), Some(3));
-        assert_eq!("hello".rfind(|c:char| c == 'o'), Some(4));
-        assert!("hello".rfind('x').is_none());
-        assert!("hello".rfind(|c:char| c == 'x').is_none());
-        assert_eq!("ประเทศไทย中华Việt Nam".rfind('华'), Some(30));
-        assert_eq!("ประเทศไทย中华Việt Nam".rfind(|c: char| c == '华'), Some(30));
-    }
-
-    #[test]
-    fn test_collect() {
-        let empty = String::from_str("");
-        let s: String = empty.chars().collect();
-        assert_eq!(empty, s);
-        let data = String::from_str("ประเทศไทย中");
-        let s: String = data.chars().collect();
-        assert_eq!(data, s);
-    }
-
-    #[test]
-    fn test_into_bytes() {
-        let data = String::from_str("asdf");
-        let buf = data.into_bytes();
-        assert_eq!(b"asdf", buf);
-    }
-
-    #[test]
-    fn test_find_str() {
-        // byte positions
-        assert_eq!("".find_str(""), Some(0));
-        assert!("banana".find_str("apple pie").is_none());
-
-        let data = "abcabc";
-        assert_eq!(data[0..6].find_str("ab"), Some(0));
-        assert_eq!(data[2..6].find_str("ab"), Some(3 - 2));
-        assert!(data[2..4].find_str("ab").is_none());
-
-        let string = "ประเทศไทย中华Việt Nam";
-        let mut data = String::from_str(string);
-        data.push_str(string);
-        assert!(data.find_str("ไท华").is_none());
-        assert_eq!(data[0..43].find_str(""), Some(0));
-        assert_eq!(data[6..43].find_str(""), Some(6 - 6));
-
-        assert_eq!(data[0..43].find_str("ประ"), Some( 0));
-        assert_eq!(data[0..43].find_str("ทศไ"), Some(12));
-        assert_eq!(data[0..43].find_str("ย中"), Some(24));
-        assert_eq!(data[0..43].find_str("iệt"), Some(34));
-        assert_eq!(data[0..43].find_str("Nam"), Some(40));
-
-        assert_eq!(data[43..86].find_str("ประ"), Some(43 - 43));
-        assert_eq!(data[43..86].find_str("ทศไ"), Some(55 - 43));
-        assert_eq!(data[43..86].find_str("ย中"), Some(67 - 43));
-        assert_eq!(data[43..86].find_str("iệt"), Some(77 - 43));
-        assert_eq!(data[43..86].find_str("Nam"), Some(83 - 43));
-    }
-
-    #[test]
-    fn test_slice_chars() {
-        fn t(a: &str, b: &str, start: usize) {
-            assert_eq!(a.slice_chars(start, start + b.chars().count()), b);
-        }
-        t("", "", 0);
-        t("hello", "llo", 2);
-        t("hello", "el", 1);
-        t("αβλ", "β", 1);
-        t("αβλ", "", 3);
-        assert_eq!("ะเทศไท", "ประเทศไทย中华Việt Nam".slice_chars(2, 8));
-    }
-
-    fn s(x: &str) -> String { x.to_string() }
-
-    macro_rules! test_concat {
-        ($expected: expr, $string: expr) => {
-            {
-                let s: String = $string.concat();
-                assert_eq!($expected, s);
-            }
-        }
-    }
-
-    #[test]
-    fn test_concat_for_different_types() {
-        test_concat!("ab", vec![s("a"), s("b")]);
-        test_concat!("ab", vec!["a", "b"]);
-        test_concat!("ab", vec!["a", "b"]);
-        test_concat!("ab", vec![s("a"), s("b")]);
+#[cfg(not(stage0))]
+/// Any string that can be represented as a slice.
+#[lang = "str"]
+#[cfg(not(test))]
+#[stable(feature = "rust1", since = "1.0.0")]
+impl str {
+    /// Escapes each char in `s` with `char::escape_default`.
+    #[unstable(feature = "collections",
+               reason = "return type may change to be an iterator")]
+    pub fn escape_default(&self) -> String {
+        self.chars().flat_map(|c| c.escape_default()).collect()
     }
 
-    #[test]
-    fn test_concat_for_different_lengths() {
-        let empty: &[&str] = &[];
-        test_concat!("", empty);
-        test_concat!("a", ["a"]);
-        test_concat!("ab", ["a", "b"]);
-        test_concat!("abc", ["", "a", "bc"]);
+    /// Escapes each char in `s` with `char::escape_unicode`.
+    #[unstable(feature = "collections",
+               reason = "return type may change to be an iterator")]
+    pub fn escape_unicode(&self) -> String {
+        self.chars().flat_map(|c| c.escape_unicode()).collect()
     }
 
-    macro_rules! test_connect {
-        ($expected: expr, $string: expr, $delim: expr) => {
-            {
-                let s = $string.connect($delim);
-                assert_eq!($expected, s);
-            }
+    /// Replaces all occurrences of one string with another.
+    ///
+    /// `replace` takes two arguments, a sub-`&str` to find in `self`, and a second `&str` to
+    /// replace it with. If the original `&str` isn't found, no change occurs.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let s = "this is old";
+    ///
+    /// assert_eq!(s.replace("old", "new"), "this is new");
+    /// ```
+    ///
+    /// When a `&str` isn't found:
+    ///
+    /// ```
+    /// let s = "this is old";
+    /// assert_eq!(s.replace("cookie monster", "little lamb"), s);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn replace(&self, from: &str, to: &str) -> String {
+        let mut result = String::new();
+        let mut last_end = 0;
+        for (start, end) in self.match_indices(from) {
+            result.push_str(unsafe { self.slice_unchecked(last_end, start) });
+            result.push_str(to);
+            last_end = end;
         }
+        result.push_str(unsafe { self.slice_unchecked(last_end, self.len()) });
+        result
     }
 
-    #[test]
-    fn test_connect_for_different_types() {
-        test_connect!("a-b", ["a", "b"], "-");
-        let hyphen = "-".to_string();
-        test_connect!("a-b", [s("a"), s("b")], &*hyphen);
-        test_connect!("a-b", vec!["a", "b"], &*hyphen);
-        test_connect!("a-b", &*vec!["a", "b"], "-");
-        test_connect!("a-b", vec![s("a"), s("b")], "-");
-    }
-
-    #[test]
-    fn test_connect_for_different_lengths() {
-        let empty: &[&str] = &[];
-        test_connect!("", empty, "-");
-        test_connect!("a", ["a"], "-");
-        test_connect!("a-b", ["a", "b"], "-");
-        test_connect!("-a-bc", ["", "a", "bc"], "-");
-    }
-
-    #[test]
-    fn test_unsafe_slice() {
-        assert_eq!("ab", unsafe {"abc".slice_unchecked(0, 2)});
-        assert_eq!("bc", unsafe {"abc".slice_unchecked(1, 3)});
-        assert_eq!("", unsafe {"abc".slice_unchecked(1, 1)});
-        fn a_million_letter_a() -> String {
-            let mut i = 0;
-            let mut rs = String::new();
-            while i < 100000 {
-                rs.push_str("aaaaaaaaaa");
-                i += 1;
-            }
-            rs
-        }
-        fn half_a_million_letter_a() -> String {
-            let mut i = 0;
-            let mut rs = String::new();
-            while i < 100000 {
-                rs.push_str("aaaaa");
-                i += 1;
-            }
-            rs
-        }
-        let letters = a_million_letter_a();
-        assert!(half_a_million_letter_a() ==
-            unsafe {String::from_str(letters.slice_unchecked(
-                                     0,
-                                     500000))});
-    }
-
-    #[test]
-    fn test_starts_with() {
-        assert!(("".starts_with("")));
-        assert!(("abc".starts_with("")));
-        assert!(("abc".starts_with("a")));
-        assert!((!"a".starts_with("abc")));
-        assert!((!"".starts_with("abc")));
-        assert!((!"ödd".starts_with("-")));
-        assert!(("ödd".starts_with("öd")));
-    }
-
-    #[test]
-    fn test_ends_with() {
-        assert!(("".ends_with("")));
-        assert!(("abc".ends_with("")));
-        assert!(("abc".ends_with("c")));
-        assert!((!"a".ends_with("abc")));
-        assert!((!"".ends_with("abc")));
-        assert!((!"ddö".ends_with("-")));
-        assert!(("ddö".ends_with("dö")));
-    }
-
-    #[test]
-    fn test_is_empty() {
-        assert!("".is_empty());
-        assert!(!"a".is_empty());
-    }
-
-    #[test]
-    fn test_replace() {
-        let a = "a";
-        assert_eq!("".replace(a, "b"), String::from_str(""));
-        assert_eq!("a".replace(a, "b"), String::from_str("b"));
-        assert_eq!("ab".replace(a, "b"), String::from_str("bb"));
-        let test = "test";
-        assert!(" test test ".replace(test, "toast") ==
-            String::from_str(" toast toast "));
-        assert_eq!(" test test ".replace(test, ""), String::from_str("   "));
-    }
-
-    #[test]
-    fn test_replace_2a() {
-        let data = "ประเทศไทย中华";
-        let repl = "دولة الكويت";
-
-        let a = "ประเ";
-        let a2 = "دولة الكويتทศไทย中华";
-        assert_eq!(data.replace(a, repl), a2);
-    }
-
-    #[test]
-    fn test_replace_2b() {
-        let data = "ประเทศไทย中华";
-        let repl = "دولة الكويت";
-
-        let b = "ะเ";
-        let b2 = "ปรدولة الكويتทศไทย中华";
-        assert_eq!(data.replace(b, repl), b2);
-    }
-
-    #[test]
-    fn test_replace_2c() {
-        let data = "ประเทศไทย中华";
-        let repl = "دولة الكويت";
-
-        let c = "中华";
-        let c2 = "ประเทศไทยدولة الكويت";
-        assert_eq!(data.replace(c, repl), c2);
-    }
-
-    #[test]
-    fn test_replace_2d() {
-        let data = "ประเทศไทย中华";
-        let repl = "دولة الكويت";
-
-        let d = "ไท华";
-        assert_eq!(data.replace(d, repl), data);
-    }
-
-    #[test]
-    fn test_slice() {
-        assert_eq!("ab", "abc".slice(0, 2));
-        assert_eq!("bc", "abc".slice(1, 3));
-        assert_eq!("", "abc".slice(1, 1));
-        assert_eq!("\u{65e5}", "\u{65e5}\u{672c}".slice(0, 3));
-
-        let data = "ประเทศไทย中华";
-        assert_eq!("ป", data.slice(0, 3));
-        assert_eq!("ร", data.slice(3, 6));
-        assert_eq!("", data.slice(3, 3));
-        assert_eq!("华", data.slice(30, 33));
-
-        fn a_million_letter_x() -> String {
-            let mut i = 0;
-            let mut rs = String::new();
-            while i < 100000 {
-                rs.push_str("华华华华华华华华华华");
-                i += 1;
-            }
-            rs
-        }
-        fn half_a_million_letter_x() -> String {
-            let mut i = 0;
-            let mut rs = String::new();
-            while i < 100000 {
-                rs.push_str("华华华华华");
-                i += 1;
-            }
-            rs
-        }
-        let letters = a_million_letter_x();
-        assert!(half_a_million_letter_x() ==
-            String::from_str(letters.slice(0, 3 * 500000)));
-    }
-
-    #[test]
-    fn test_slice_2() {
-        let ss = "中华Việt Nam";
-
-        assert_eq!("华", ss.slice(3, 6));
-        assert_eq!("Việt Nam", ss.slice(6, 16));
-
-        assert_eq!("ab", "abc".slice(0, 2));
-        assert_eq!("bc", "abc".slice(1, 3));
-        assert_eq!("", "abc".slice(1, 1));
-
-        assert_eq!("中", ss.slice(0, 3));
-        assert_eq!("华V", ss.slice(3, 7));
-        assert_eq!("", ss.slice(3, 3));
-        /*0: 中
-          3: 华
-          6: V
-          7: i
-          8: ệ
-         11: t
-         12:
-         13: N
-         14: a
-         15: m */
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_slice_fail() {
-        "中华Việt Nam".slice(0, 2);
-    }
-
-    #[test]
-    fn test_slice_from() {
-        assert_eq!("abcd".slice_from(0), "abcd");
-        assert_eq!("abcd".slice_from(2), "cd");
-        assert_eq!("abcd".slice_from(4), "");
-    }
-    #[test]
-    fn test_slice_to() {
-        assert_eq!("abcd".slice_to(0), "");
-        assert_eq!("abcd".slice_to(2), "ab");
-        assert_eq!("abcd".slice_to(4), "abcd");
-    }
-
-    #[test]
-    fn test_trim_left_matches() {
-        let v: &[char] = &[];
-        assert_eq!(" *** foo *** ".trim_left_matches(v), " *** foo *** ");
-        let chars: &[char] = &['*', ' '];
-        assert_eq!(" *** foo *** ".trim_left_matches(chars), "foo *** ");
-        assert_eq!(" ***  *** ".trim_left_matches(chars), "");
-        assert_eq!("foo *** ".trim_left_matches(chars), "foo *** ");
-
-        assert_eq!("11foo1bar11".trim_left_matches('1'), "foo1bar11");
-        let chars: &[char] = &['1', '2'];
-        assert_eq!("12foo1bar12".trim_left_matches(chars), "foo1bar12");
-        assert_eq!("123foo1bar123".trim_left_matches(|c: char| c.is_numeric()), "foo1bar123");
-    }
-
-    #[test]
-    fn test_trim_right_matches() {
-        let v: &[char] = &[];
-        assert_eq!(" *** foo *** ".trim_right_matches(v), " *** foo *** ");
-        let chars: &[char] = &['*', ' '];
-        assert_eq!(" *** foo *** ".trim_right_matches(chars), " *** foo");
-        assert_eq!(" ***  *** ".trim_right_matches(chars), "");
-        assert_eq!(" *** foo".trim_right_matches(chars), " *** foo");
-
-        assert_eq!("11foo1bar11".trim_right_matches('1'), "11foo1bar");
-        let chars: &[char] = &['1', '2'];
-        assert_eq!("12foo1bar12".trim_right_matches(chars), "12foo1bar");
-        assert_eq!("123foo1bar123".trim_right_matches(|c: char| c.is_numeric()), "123foo1bar");
-    }
-
-    #[test]
-    fn test_trim_matches() {
-        let v: &[char] = &[];
-        assert_eq!(" *** foo *** ".trim_matches(v), " *** foo *** ");
-        let chars: &[char] = &['*', ' '];
-        assert_eq!(" *** foo *** ".trim_matches(chars), "foo");
-        assert_eq!(" ***  *** ".trim_matches(chars), "");
-        assert_eq!("foo".trim_matches(chars), "foo");
-
-        assert_eq!("11foo1bar11".trim_matches('1'), "foo1bar");
-        let chars: &[char] = &['1', '2'];
-        assert_eq!("12foo1bar12".trim_matches(chars), "foo1bar");
-        assert_eq!("123foo1bar123".trim_matches(|c: char| c.is_numeric()), "foo1bar");
-    }
-
-    #[test]
-    fn test_trim_left() {
-        assert_eq!("".trim_left(), "");
-        assert_eq!("a".trim_left(), "a");
-        assert_eq!("    ".trim_left(), "");
-        assert_eq!("     blah".trim_left(), "blah");
-        assert_eq!("   \u{3000}  wut".trim_left(), "wut");
-        assert_eq!("hey ".trim_left(), "hey ");
-    }
-
-    #[test]
-    fn test_trim_right() {
-        assert_eq!("".trim_right(), "");
-        assert_eq!("a".trim_right(), "a");
-        assert_eq!("    ".trim_right(), "");
-        assert_eq!("blah     ".trim_right(), "blah");
-        assert_eq!("wut   \u{3000}  ".trim_right(), "wut");
-        assert_eq!(" hey".trim_right(), " hey");
-    }
-
-    #[test]
-    fn test_trim() {
-        assert_eq!("".trim(), "");
-        assert_eq!("a".trim(), "a");
-        assert_eq!("    ".trim(), "");
-        assert_eq!("    blah     ".trim(), "blah");
-        assert_eq!("\nwut   \u{3000}  ".trim(), "wut");
-        assert_eq!(" hey dude ".trim(), "hey dude");
-    }
-
-    #[test]
-    fn test_is_whitespace() {
-        assert!("".chars().all(|c| c.is_whitespace()));
-        assert!(" ".chars().all(|c| c.is_whitespace()));
-        assert!("\u{2009}".chars().all(|c| c.is_whitespace())); // Thin space
-        assert!("  \n\t   ".chars().all(|c| c.is_whitespace()));
-        assert!(!"   _   ".chars().all(|c| c.is_whitespace()));
-    }
-
-    #[test]
-    fn test_slice_shift_char() {
-        let data = "ประเทศไทย中";
-        assert_eq!(data.slice_shift_char(), Some(('ป', "ระเทศไทย中")));
-    }
-
-    #[test]
-    fn test_slice_shift_char_2() {
-        let empty = "";
-        assert_eq!(empty.slice_shift_char(), None);
-    }
-
-    #[test]
-    fn test_is_utf8() {
-        // deny overlong encodings
-        assert!(from_utf8(&[0xc0, 0x80]).is_err());
-        assert!(from_utf8(&[0xc0, 0xae]).is_err());
-        assert!(from_utf8(&[0xe0, 0x80, 0x80]).is_err());
-        assert!(from_utf8(&[0xe0, 0x80, 0xaf]).is_err());
-        assert!(from_utf8(&[0xe0, 0x81, 0x81]).is_err());
-        assert!(from_utf8(&[0xf0, 0x82, 0x82, 0xac]).is_err());
-        assert!(from_utf8(&[0xf4, 0x90, 0x80, 0x80]).is_err());
-
-        // deny surrogates
-        assert!(from_utf8(&[0xED, 0xA0, 0x80]).is_err());
-        assert!(from_utf8(&[0xED, 0xBF, 0xBF]).is_err());
-
-        assert!(from_utf8(&[0xC2, 0x80]).is_ok());
-        assert!(from_utf8(&[0xDF, 0xBF]).is_ok());
-        assert!(from_utf8(&[0xE0, 0xA0, 0x80]).is_ok());
-        assert!(from_utf8(&[0xED, 0x9F, 0xBF]).is_ok());
-        assert!(from_utf8(&[0xEE, 0x80, 0x80]).is_ok());
-        assert!(from_utf8(&[0xEF, 0xBF, 0xBF]).is_ok());
-        assert!(from_utf8(&[0xF0, 0x90, 0x80, 0x80]).is_ok());
-        assert!(from_utf8(&[0xF4, 0x8F, 0xBF, 0xBF]).is_ok());
-    }
-
-    #[test]
-    fn test_is_utf16() {
-        use unicode::str::is_utf16;
-        macro_rules! pos {
-            ($($e:expr),*) => { { $(assert!(is_utf16($e));)* } }
-        }
-
-        // non-surrogates
-        pos!(&[0x0000],
-             &[0x0001, 0x0002],
-             &[0xD7FF],
-             &[0xE000]);
-
-        // surrogate pairs (randomly generated with Python 3's
-        // .encode('utf-16be'))
-        pos!(&[0xdb54, 0xdf16, 0xd880, 0xdee0, 0xdb6a, 0xdd45],
-             &[0xd91f, 0xdeb1, 0xdb31, 0xdd84, 0xd8e2, 0xde14],
-             &[0xdb9f, 0xdc26, 0xdb6f, 0xde58, 0xd850, 0xdfae]);
-
-        // mixtures (also random)
-        pos!(&[0xd921, 0xdcc2, 0x002d, 0x004d, 0xdb32, 0xdf65],
-             &[0xdb45, 0xdd2d, 0x006a, 0xdacd, 0xddfe, 0x0006],
-             &[0x0067, 0xd8ff, 0xddb7, 0x000f, 0xd900, 0xdc80]);
-
-        // negative tests
-        macro_rules! neg {
-            ($($e:expr),*) => { { $(assert!(!is_utf16($e));)* } }
-        }
-
-        neg!(
-            // surrogate + regular unit
-            &[0xdb45, 0x0000],
-            // surrogate + lead surrogate
-            &[0xd900, 0xd900],
-            // unterminated surrogate
-            &[0xd8ff],
-            // trail surrogate without a lead
-            &[0xddb7]);
-
-        // random byte sequences that Python 3's .decode('utf-16be')
-        // failed on
-        neg!(&[0x5b3d, 0x0141, 0xde9e, 0x8fdc, 0xc6e7],
-             &[0xdf5a, 0x82a5, 0x62b9, 0xb447, 0x92f3],
-             &[0xda4e, 0x42bc, 0x4462, 0xee98, 0xc2ca],
-             &[0xbe00, 0xb04a, 0x6ecb, 0xdd89, 0xe278],
-             &[0x0465, 0xab56, 0xdbb6, 0xa893, 0x665e],
-             &[0x6b7f, 0x0a19, 0x40f4, 0xa657, 0xdcc5],
-             &[0x9b50, 0xda5e, 0x24ec, 0x03ad, 0x6dee],
-             &[0x8d17, 0xcaa7, 0xf4ae, 0xdf6e, 0xbed7],
-             &[0xdaee, 0x2584, 0x7d30, 0xa626, 0x121a],
-             &[0xd956, 0x4b43, 0x7570, 0xccd6, 0x4f4a],
-             &[0x9dcf, 0x1b49, 0x4ba5, 0xfce9, 0xdffe],
-             &[0x6572, 0xce53, 0xb05a, 0xf6af, 0xdacf],
-             &[0x1b90, 0x728c, 0x9906, 0xdb68, 0xf46e],
-             &[0x1606, 0xbeca, 0xbe76, 0x860f, 0xdfa5],
-             &[0x8b4f, 0xde7a, 0xd220, 0x9fac, 0x2b6f],
-             &[0xb8fe, 0xebbe, 0xda32, 0x1a5f, 0x8b8b],
-             &[0x934b, 0x8956, 0xc434, 0x1881, 0xddf7],
-             &[0x5a95, 0x13fc, 0xf116, 0xd89b, 0x93f9],
-             &[0xd640, 0x71f1, 0xdd7d, 0x77eb, 0x1cd8],
-             &[0x348b, 0xaef0, 0xdb2c, 0xebf1, 0x1282],
-             &[0x50d7, 0xd824, 0x5010, 0xb369, 0x22ea]);
-    }
-
-    #[test]
-    fn test_as_bytes() {
-        // no null
-        let v = [
-            224, 184, 168, 224, 185, 132, 224, 184, 151, 224, 184, 162, 228,
-            184, 173, 229, 141, 142, 86, 105, 225, 187, 135, 116, 32, 78, 97,
-            109
-        ];
-        let b: &[u8] = &[];
-        assert_eq!("".as_bytes(), b);
-        assert_eq!("abc".as_bytes(), b"abc");
-        assert_eq!("ศไทย中华Việt Nam".as_bytes(), v);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_as_bytes_fail() {
-        // Don't double free. (I'm not sure if this exercises the
-        // original problem code path anymore.)
-        let s = String::from_str("");
-        let _bytes = s.as_bytes();
-        panic!();
-    }
-
-    #[test]
-    fn test_as_ptr() {
-        let buf = "hello".as_ptr();
-        unsafe {
-            assert_eq!(*buf.offset(0), b'h');
-            assert_eq!(*buf.offset(1), b'e');
-            assert_eq!(*buf.offset(2), b'l');
-            assert_eq!(*buf.offset(3), b'l');
-            assert_eq!(*buf.offset(4), b'o');
+    /// Returns an iterator over the string in Unicode Normalization Form D
+    /// (canonical decomposition).
+    #[inline]
+    #[unstable(feature = "collections",
+               reason = "this functionality may be moved to libunicode")]
+    pub fn nfd_chars(&self) -> Decompositions {
+        Decompositions {
+            iter: self[..].chars(),
+            buffer: Vec::new(),
+            sorted: false,
+            kind: Canonical
         }
     }
 
-    #[test]
-    fn test_subslice_offset() {
-        let a = "kernelsprite";
-        let b = &a[7..a.len()];
-        let c = &a[0..a.len() - 6];
-        assert_eq!(a.subslice_offset(b), 7);
-        assert_eq!(a.subslice_offset(c), 0);
-
-        let string = "a\nb\nc";
-        let lines: Vec<&str> = string.lines().collect();
-        assert_eq!(string.subslice_offset(lines[0]), 0);
-        assert_eq!(string.subslice_offset(lines[1]), 2);
-        assert_eq!(string.subslice_offset(lines[2]), 4);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_subslice_offset_2() {
-        let a = "alchemiter";
-        let b = "cruxtruder";
-        a.subslice_offset(b);
-    }
-
-    #[test]
-    fn vec_str_conversions() {
-        let s1: String = String::from_str("All mimsy were the borogoves");
-
-        let v: Vec<u8> = s1.as_bytes().to_vec();
-        let s2: String = String::from_str(from_utf8(&v).unwrap());
-        let mut i = 0;
-        let n1 = s1.len();
-        let n2 = v.len();
-        assert_eq!(n1, n2);
-        while i < n1 {
-            let a: u8 = s1.as_bytes()[i];
-            let b: u8 = s2.as_bytes()[i];
-            debug!("{}", a);
-            debug!("{}", b);
-            assert_eq!(a, b);
-            i += 1;
+    /// Returns an iterator over the string in Unicode Normalization Form KD
+    /// (compatibility decomposition).
+    #[inline]
+    #[unstable(feature = "collections",
+               reason = "this functionality may be moved to libunicode")]
+    pub fn nfkd_chars(&self) -> Decompositions {
+        Decompositions {
+            iter: self[..].chars(),
+            buffer: Vec::new(),
+            sorted: false,
+            kind: Compatible
         }
     }
 
-    #[test]
-    fn test_contains() {
-        assert!("abcde".contains("bcd"));
-        assert!("abcde".contains("abcd"));
-        assert!("abcde".contains("bcde"));
-        assert!("abcde".contains(""));
-        assert!("".contains(""));
-        assert!(!"abcde".contains("def"));
-        assert!(!"".contains("a"));
-
-        let data = "ประเทศไทย中华Việt Nam";
-        assert!(data.contains("ประเ"));
-        assert!(data.contains("ะเ"));
-        assert!(data.contains("中华"));
-        assert!(!data.contains("ไท华"));
-    }
-
-    #[test]
-    fn test_contains_char() {
-        assert!("abc".contains_char('b'));
-        assert!("a".contains_char('a'));
-        assert!(!"abc".contains_char('d'));
-        assert!(!"".contains_char('a'));
-    }
-
-    #[test]
-    fn test_char_at() {
-        let s = "ศไทย中华Việt Nam";
-        let v = vec!['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
-        let mut pos = 0;
-        for ch in &v {
-            assert!(s.char_at(pos) == *ch);
-            pos += ch.to_string().len();
+    /// An Iterator over the string in Unicode Normalization Form C
+    /// (canonical decomposition followed by canonical composition).
+    #[inline]
+    #[unstable(feature = "collections",
+               reason = "this functionality may be moved to libunicode")]
+    pub fn nfc_chars(&self) -> Recompositions {
+        Recompositions {
+            iter: self.nfd_chars(),
+            state: Composing,
+            buffer: VecDeque::new(),
+            composee: None,
+            last_ccc: None
         }
     }
 
-    #[test]
-    fn test_char_at_reverse() {
-        let s = "ศไทย中华Việt Nam";
-        let v = vec!['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
-        let mut pos = s.len();
-        for ch in v.iter().rev() {
-            assert!(s.char_at_reverse(pos) == *ch);
-            pos -= ch.to_string().len();
+    /// An Iterator over the string in Unicode Normalization Form KC
+    /// (compatibility decomposition followed by canonical composition).
+    #[inline]
+    #[unstable(feature = "collections",
+               reason = "this functionality may be moved to libunicode")]
+    pub fn nfkc_chars(&self) -> Recompositions {
+        Recompositions {
+            iter: self.nfkd_chars(),
+            state: Composing,
+            buffer: VecDeque::new(),
+            composee: None,
+            last_ccc: None
         }
     }
 
-    #[test]
-    fn test_escape_unicode() {
-        assert_eq!("abc".escape_unicode(),
-                   String::from_str("\\u{61}\\u{62}\\u{63}"));
-        assert_eq!("a c".escape_unicode(),
-                   String::from_str("\\u{61}\\u{20}\\u{63}"));
-        assert_eq!("\r\n\t".escape_unicode(),
-                   String::from_str("\\u{d}\\u{a}\\u{9}"));
-        assert_eq!("'\"\\".escape_unicode(),
-                   String::from_str("\\u{27}\\u{22}\\u{5c}"));
-        assert_eq!("\x00\x01\u{fe}\u{ff}".escape_unicode(),
-                   String::from_str("\\u{0}\\u{1}\\u{fe}\\u{ff}"));
-        assert_eq!("\u{100}\u{ffff}".escape_unicode(),
-                   String::from_str("\\u{100}\\u{ffff}"));
-        assert_eq!("\u{10000}\u{10ffff}".escape_unicode(),
-                   String::from_str("\\u{10000}\\u{10ffff}"));
-        assert_eq!("ab\u{fb00}".escape_unicode(),
-                   String::from_str("\\u{61}\\u{62}\\u{fb00}"));
-        assert_eq!("\u{1d4ea}\r".escape_unicode(),
-                   String::from_str("\\u{1d4ea}\\u{d}"));
-    }
-
-    #[test]
-    fn test_escape_default() {
-        assert_eq!("abc".escape_default(), String::from_str("abc"));
-        assert_eq!("a c".escape_default(), String::from_str("a c"));
-        assert_eq!("\r\n\t".escape_default(), String::from_str("\\r\\n\\t"));
-        assert_eq!("'\"\\".escape_default(), String::from_str("\\'\\\"\\\\"));
-        assert_eq!("\u{100}\u{ffff}".escape_default(),
-                   String::from_str("\\u{100}\\u{ffff}"));
-        assert_eq!("\u{10000}\u{10ffff}".escape_default(),
-                   String::from_str("\\u{10000}\\u{10ffff}"));
-        assert_eq!("ab\u{fb00}".escape_default(),
-                   String::from_str("ab\\u{fb00}"));
-        assert_eq!("\u{1d4ea}\r".escape_default(),
-                   String::from_str("\\u{1d4ea}\\r"));
-    }
-
-    #[test]
-    fn test_total_ord() {
-        "1234".cmp("123") == Greater;
-        "123".cmp("1234") == Less;
-        "1234".cmp("1234") == Equal;
-        "12345555".cmp("123456") == Less;
-        "22".cmp("1234") == Greater;
-    }
-
-    #[test]
-    fn test_char_range_at() {
-        let data = "b¢€𤭢𤭢€¢b";
-        assert_eq!('b', data.char_range_at(0).ch);
-        assert_eq!('¢', data.char_range_at(1).ch);
-        assert_eq!('€', data.char_range_at(3).ch);
-        assert_eq!('𤭢', data.char_range_at(6).ch);
-        assert_eq!('𤭢', data.char_range_at(10).ch);
-        assert_eq!('€', data.char_range_at(14).ch);
-        assert_eq!('¢', data.char_range_at(17).ch);
-        assert_eq!('b', data.char_range_at(19).ch);
-    }
-
-    #[test]
-    fn test_char_range_at_reverse_underflow() {
-        assert_eq!("abc".char_range_at_reverse(0).next, 0);
-    }
-
-    #[test]
-    fn test_iterator() {
-        let s = "ศไทย中华Việt Nam";
-        let v = ['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
-
-        let mut pos = 0;
-        let it = s.chars();
-
-        for c in it {
-            assert_eq!(c, v[pos]);
-            pos += 1;
-        }
-        assert_eq!(pos, v.len());
+    /// Returns `true` if `self` contains another `&str`.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// assert!("bananas".contains("nana"));
+    ///
+    /// assert!(!"bananas".contains("foobar"));
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn contains<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool {
+        core_str::StrExt::contains(&self[..], pat)
     }
 
-    #[test]
-    fn test_rev_iterator() {
-        let s = "ศไทย中华Việt Nam";
-        let v = ['m', 'a', 'N', ' ', 't', 'ệ','i','V','华','中','ย','ท','ไ','ศ'];
-
-        let mut pos = 0;
-        let it = s.chars().rev();
-
-        for c in it {
-            assert_eq!(c, v[pos]);
-            pos += 1;
-        }
-        assert_eq!(pos, v.len());
+    /// Returns `true` if `self` contains a `char`.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// assert!("hello".contains_char('e'));
+    ///
+    /// assert!(!"hello".contains_char('z'));
+    /// ```
+    #[unstable(feature = "collections")]
+    #[deprecated(since = "1.0.0", reason = "use `contains()` with a char")]
+    pub fn contains_char<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool {
+        core_str::StrExt::contains_char(&self[..], pat)
     }
 
-    #[test]
-    fn test_chars_decoding() {
-        let mut bytes = [0; 4];
-        for c in (0..0x110000).filter_map(|c| ::core::char::from_u32(c)) {
-            let len = c.encode_utf8(&mut bytes).unwrap_or(0);
-            let s = ::core::str::from_utf8(&bytes[..len]).unwrap();
-            if Some(c) != s.chars().next() {
-                panic!("character {:x}={} does not decode correctly", c as u32, c);
-            }
-        }
+    /// An iterator over the codepoints of `self`.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let v: Vec<char> = "abc åäö".chars().collect();
+    ///
+    /// assert_eq!(v, ['a', 'b', 'c', ' ', 'å', 'ä', 'ö']);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn chars(&self) -> Chars {
+        core_str::StrExt::chars(&self[..])
     }
 
-    #[test]
-    fn test_chars_rev_decoding() {
-        let mut bytes = [0; 4];
-        for c in (0..0x110000).filter_map(|c| ::core::char::from_u32(c)) {
-            let len = c.encode_utf8(&mut bytes).unwrap_or(0);
-            let s = ::core::str::from_utf8(&bytes[..len]).unwrap();
-            if Some(c) != s.chars().rev().next() {
-                panic!("character {:x}={} does not decode correctly", c as u32, c);
-            }
-        }
+    /// An iterator over the bytes of `self`.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let v: Vec<u8> = "bors".bytes().collect();
+    ///
+    /// assert_eq!(v, b"bors".to_vec());
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn bytes(&self) -> Bytes {
+        core_str::StrExt::bytes(&self[..])
     }
 
-    #[test]
-    fn test_iterator_clone() {
-        let s = "ศไทย中华Việt Nam";
-        let mut it = s.chars();
-        it.next();
-        assert!(it.clone().zip(it).all(|(x,y)| x == y));
+    /// An iterator over the characters of `self` and their byte offsets.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let v: Vec<(usize, char)> = "abc".char_indices().collect();
+    /// let b = vec![(0, 'a'), (1, 'b'), (2, 'c')];
+    ///
+    /// assert_eq!(v, b);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn char_indices(&self) -> CharIndices {
+        core_str::StrExt::char_indices(&self[..])
     }
 
-    #[test]
-    fn test_bytesator() {
-        let s = "ศไทย中华Việt Nam";
-        let v = [
-            224, 184, 168, 224, 185, 132, 224, 184, 151, 224, 184, 162, 228,
-            184, 173, 229, 141, 142, 86, 105, 225, 187, 135, 116, 32, 78, 97,
-            109
-        ];
-        let mut pos = 0;
-
-        for b in s.bytes() {
-            assert_eq!(b, v[pos]);
-            pos += 1;
-        }
+    /// An iterator over substrings of `self`, separated by characters
+    /// matched by a pattern.
+    ///
+    /// The pattern can be a simple `&str`, or a closure that determines
+    /// the split.
+    ///
+    /// # Examples
+    ///
+    /// Simple `&str` patterns:
+    ///
+    /// ```
+    /// let v: Vec<&str> = "Mary had a little lamb".split(' ').collect();
+    /// assert_eq!(v, ["Mary", "had", "a", "little", "lamb"]);
+    ///
+    /// let v: Vec<&str> = "".split('X').collect();
+    /// assert_eq!(v, [""]);
+    /// ```
+    ///
+    /// More complex patterns with a lambda:
+    ///
+    /// ```
+    /// let v: Vec<&str> = "abc1def2ghi".split(|c: char| c.is_numeric()).collect();
+    /// assert_eq!(v, ["abc", "def", "ghi"]);
+    ///
+    /// let v: Vec<&str> = "lionXXtigerXleopard".split('X').collect();
+    /// assert_eq!(v, ["lion", "", "tiger", "leopard"]);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn split<'a, P: Pattern<'a>>(&'a self, pat: P) -> Split<'a, P> {
+        core_str::StrExt::split(&self[..], pat)
     }
 
-    #[test]
-    fn test_bytes_revator() {
-        let s = "ศไทย中华Việt Nam";
-        let v = [
-            224, 184, 168, 224, 185, 132, 224, 184, 151, 224, 184, 162, 228,
-            184, 173, 229, 141, 142, 86, 105, 225, 187, 135, 116, 32, 78, 97,
-            109
-        ];
-        let mut pos = v.len();
-
-        for b in s.bytes().rev() {
-            pos -= 1;
-            assert_eq!(b, v[pos]);
-        }
+    /// An iterator over substrings of `self`, separated by characters matched by a pattern,
+    /// restricted to splitting at most `count` times.
+    ///
+    /// The pattern can be a simple `&str`, or a closure that determines
+    /// the split.
+    ///
+    /// # Examples
+    ///
+    /// Simple `&str` patterns:
+    ///
+    /// ```
+    /// let v: Vec<&str> = "Mary had a little lambda".splitn(2, ' ').collect();
+    /// assert_eq!(v, ["Mary", "had", "a little lambda"]);
+    ///
+    /// let v: Vec<&str> = "lionXXtigerXleopard".splitn(2, 'X').collect();
+    /// assert_eq!(v, ["lion", "", "tigerXleopard"]);
+    ///
+    /// let v: Vec<&str> = "abcXdef".splitn(0, 'X').collect();
+    /// assert_eq!(v, ["abcXdef"]);
+    ///
+    /// let v: Vec<&str> = "".splitn(1, 'X').collect();
+    /// assert_eq!(v, [""]);
+    /// ```
+    ///
+    /// More complex patterns with a lambda:
+    ///
+    /// ```
+    /// let v: Vec<&str> = "abc1def2ghi".splitn(1, |c: char| c.is_numeric()).collect();
+    /// assert_eq!(v, ["abc", "def2ghi"]);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn splitn<'a, P: Pattern<'a>>(&'a self, count: usize, pat: P) -> SplitN<'a, P> {
+        core_str::StrExt::splitn(&self[..], count, pat)
     }
 
-    #[test]
-    fn test_char_indicesator() {
-        let s = "ศไทย中华Việt Nam";
-        let p = [0, 3, 6, 9, 12, 15, 18, 19, 20, 23, 24, 25, 26, 27];
-        let v = ['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
-
-        let mut pos = 0;
-        let it = s.char_indices();
-
-        for c in it {
-            assert_eq!(c, (p[pos], v[pos]));
-            pos += 1;
-        }
-        assert_eq!(pos, v.len());
-        assert_eq!(pos, p.len());
+    /// An iterator over substrings of `self`, separated by characters
+    /// matched by a pattern.
+    ///
+    /// Equivalent to `split`, except that the trailing substring is skipped if empty.
+    ///
+    /// The pattern can be a simple `&str`, or a closure that determines
+    /// the split.
+    ///
+    /// # Examples
+    ///
+    /// Simple `&str` patterns:
+    ///
+    /// ```
+    /// let v: Vec<&str> = "A.B.".split_terminator('.').collect();
+    /// assert_eq!(v, ["A", "B"]);
+    ///
+    /// let v: Vec<&str> = "A..B..".split_terminator('.').collect();
+    /// assert_eq!(v, ["A", "", "B", ""]);
+    /// ```
+    ///
+    /// More complex patterns with a lambda:
+    ///
+    /// ```
+    /// let v: Vec<&str> = "abc1def2ghi3".split_terminator(|c: char| c.is_numeric()).collect();
+    /// assert_eq!(v, ["abc", "def", "ghi"]);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn split_terminator<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitTerminator<'a, P> {
+        core_str::StrExt::split_terminator(&self[..], pat)
     }
 
-    #[test]
-    fn test_char_indices_revator() {
-        let s = "ศไทย中华Việt Nam";
-        let p = [27, 26, 25, 24, 23, 20, 19, 18, 15, 12, 9, 6, 3, 0];
-        let v = ['m', 'a', 'N', ' ', 't', 'ệ','i','V','华','中','ย','ท','ไ','ศ'];
-
-        let mut pos = 0;
-        let it = s.char_indices().rev();
-
-        for c in it {
-            assert_eq!(c, (p[pos], v[pos]));
-            pos += 1;
-        }
-        assert_eq!(pos, v.len());
-        assert_eq!(pos, p.len());
+    /// An iterator over substrings of `self`, separated by characters matched by a pattern,
+    /// starting from the end of the string.
+    ///
+    /// Restricted to splitting at most `count` times.
+    ///
+    /// The pattern can be a simple `&str`, or a closure that determines the split.
+    ///
+    /// # Examples
+    ///
+    /// Simple `&str` patterns:
+    ///
+    /// ```
+    /// let v: Vec<&str> = "Mary had a little lamb".rsplitn(2, ' ').collect();
+    /// assert_eq!(v, ["lamb", "little", "Mary had a"]);
+    ///
+    /// let v: Vec<&str> = "lionXXtigerXleopard".rsplitn(2, 'X').collect();
+    /// assert_eq!(v, ["leopard", "tiger", "lionX"]);
+    /// ```
+    ///
+    /// More complex patterns with a lambda:
+    ///
+    /// ```
+    /// let v: Vec<&str> = "abc1def2ghi".rsplitn(1, |c: char| c.is_numeric()).collect();
+    /// assert_eq!(v, ["ghi", "abc1def"]);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn rsplitn<'a, P: Pattern<'a>>(&'a self, count: usize, pat: P) -> RSplitN<'a, P> {
+        core_str::StrExt::rsplitn(&self[..], count, pat)
     }
 
-    #[test]
-    fn test_splitn_char_iterator() {
-        let data = "\nMäry häd ä little lämb\nLittle lämb\n";
-
-        let split: Vec<&str> = data.splitn(3, ' ').collect();
-        assert_eq!(split, ["\nMäry", "häd", "ä", "little lämb\nLittle lämb\n"]);
-
-        let split: Vec<&str> = data.splitn(3, |c: char| c == ' ').collect();
-        assert_eq!(split, ["\nMäry", "häd", "ä", "little lämb\nLittle lämb\n"]);
-
-        // Unicode
-        let split: Vec<&str> = data.splitn(3, 'ä').collect();
-        assert_eq!(split, ["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]);
-
-        let split: Vec<&str> = data.splitn(3, |c: char| c == 'ä').collect();
-        assert_eq!(split, ["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]);
+    /// An iterator over the start and end indices of the disjoint matches of a `&str` within
+    /// `self`.
+    ///
+    /// That is, each returned value `(start, end)` satisfies `self.slice(start, end) == sep`. For
+    /// matches of `sep` within `self` that overlap, only the indices corresponding to the first
+    /// match are returned.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let v: Vec<(usize, usize)> = "abcXXXabcYYYabc".match_indices("abc").collect();
+    /// assert_eq!(v, [(0,3), (6,9), (12,15)]);
+    ///
+    /// let v: Vec<(usize, usize)> = "1abcabc2".match_indices("abc").collect();
+    /// assert_eq!(v, [(1,4), (4,7)]);
+    ///
+    /// let v: Vec<(usize, usize)> = "ababa".match_indices("aba").collect();
+    /// assert_eq!(v, [(0, 3)]); // only the first `aba`
+    /// ```
+    #[unstable(feature = "collections",
+               reason = "might have its iterator type changed")]
+    // NB: Right now MatchIndices yields `(usize, usize)`,
+    // but it would be more consistent and useful to return `(usize, &str)`
+    pub fn match_indices<'a, P: Pattern<'a>>(&'a self, pat: P) -> MatchIndices<'a, P> {
+        core_str::StrExt::match_indices(&self[..], pat)
     }
 
-    #[test]
-    fn test_split_char_iterator_no_trailing() {
-        let data = "\nMäry häd ä little lämb\nLittle lämb\n";
-
-        let split: Vec<&str> = data.split('\n').collect();
-        assert_eq!(split, ["", "Märy häd ä little lämb", "Little lämb", ""]);
-
-        let split: Vec<&str> = data.split_terminator('\n').collect();
-        assert_eq!(split, ["", "Märy häd ä little lämb", "Little lämb"]);
+    /// An iterator over the substrings of `self` separated by a `&str`.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let v: Vec<&str> = "abcXXXabcYYYabc".split_str("abc").collect();
+    /// assert_eq!(v, ["", "XXX", "YYY", ""]);
+    ///
+    /// let v: Vec<&str> = "1abcabc2".split_str("abc").collect();
+    /// assert_eq!(v, ["1", "", "2"]);
+    /// ```
+    #[unstable(feature = "collections")]
+    #[deprecated(since = "1.0.0", reason = "use `split()` with a `&str`")]
+    #[allow(deprecated) /* for SplitStr */]
+    pub fn split_str<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitStr<'a, P> {
+        core_str::StrExt::split_str(&self[..], pat)
     }
 
-    #[test]
-    fn test_words() {
-        let data = "\n \tMäry   häd\tä  little lämb\nLittle lämb\n";
-        let words: Vec<&str> = data.words().collect();
-        assert_eq!(words, ["Märy", "häd", "ä", "little", "lämb", "Little", "lämb"])
+    /// An iterator over the lines of a string, separated by `\n`.
+    ///
+    /// This does not include the empty string after a trailing `\n`.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let four_lines = "foo\nbar\n\nbaz";
+    /// let v: Vec<&str> = four_lines.lines().collect();
+    ///
+    /// assert_eq!(v, ["foo", "bar", "", "baz"]);
+    /// ```
+    ///
+    /// Leaving off the trailing character:
+    ///
+    /// ```
+    /// let four_lines = "foo\nbar\n\nbaz\n";
+    /// let v: Vec<&str> = four_lines.lines().collect();
+    ///
+    /// assert_eq!(v, ["foo", "bar", "", "baz"]);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn lines(&self) -> Lines {
+        core_str::StrExt::lines(&self[..])
     }
 
-    #[test]
-    fn test_nfd_chars() {
-        macro_rules! t {
-            ($input: expr, $expected: expr) => {
-                assert_eq!($input.nfd_chars().collect::<String>(), $expected);
-            }
-        }
-        t!("abc", "abc");
-        t!("\u{1e0b}\u{1c4}", "d\u{307}\u{1c4}");
-        t!("\u{2026}", "\u{2026}");
-        t!("\u{2126}", "\u{3a9}");
-        t!("\u{1e0b}\u{323}", "d\u{323}\u{307}");
-        t!("\u{1e0d}\u{307}", "d\u{323}\u{307}");
-        t!("a\u{301}", "a\u{301}");
-        t!("\u{301}a", "\u{301}a");
-        t!("\u{d4db}", "\u{1111}\u{1171}\u{11b6}");
-        t!("\u{ac1c}", "\u{1100}\u{1162}");
-    }
-
-    #[test]
-    fn test_nfkd_chars() {
-        macro_rules! t {
-            ($input: expr, $expected: expr) => {
-                assert_eq!($input.nfkd_chars().collect::<String>(), $expected);
-            }
-        }
-        t!("abc", "abc");
-        t!("\u{1e0b}\u{1c4}", "d\u{307}DZ\u{30c}");
-        t!("\u{2026}", "...");
-        t!("\u{2126}", "\u{3a9}");
-        t!("\u{1e0b}\u{323}", "d\u{323}\u{307}");
-        t!("\u{1e0d}\u{307}", "d\u{323}\u{307}");
-        t!("a\u{301}", "a\u{301}");
-        t!("\u{301}a", "\u{301}a");
-        t!("\u{d4db}", "\u{1111}\u{1171}\u{11b6}");
-        t!("\u{ac1c}", "\u{1100}\u{1162}");
-    }
-
-    #[test]
-    fn test_nfc_chars() {
-        macro_rules! t {
-            ($input: expr, $expected: expr) => {
-                assert_eq!($input.nfc_chars().collect::<String>(), $expected);
-            }
-        }
-        t!("abc", "abc");
-        t!("\u{1e0b}\u{1c4}", "\u{1e0b}\u{1c4}");
-        t!("\u{2026}", "\u{2026}");
-        t!("\u{2126}", "\u{3a9}");
-        t!("\u{1e0b}\u{323}", "\u{1e0d}\u{307}");
-        t!("\u{1e0d}\u{307}", "\u{1e0d}\u{307}");
-        t!("a\u{301}", "\u{e1}");
-        t!("\u{301}a", "\u{301}a");
-        t!("\u{d4db}", "\u{d4db}");
-        t!("\u{ac1c}", "\u{ac1c}");
-        t!("a\u{300}\u{305}\u{315}\u{5ae}b", "\u{e0}\u{5ae}\u{305}\u{315}b");
-    }
-
-    #[test]
-    fn test_nfkc_chars() {
-        macro_rules! t {
-            ($input: expr, $expected: expr) => {
-                assert_eq!($input.nfkc_chars().collect::<String>(), $expected);
-            }
-        }
-        t!("abc", "abc");
-        t!("\u{1e0b}\u{1c4}", "\u{1e0b}D\u{17d}");
-        t!("\u{2026}", "...");
-        t!("\u{2126}", "\u{3a9}");
-        t!("\u{1e0b}\u{323}", "\u{1e0d}\u{307}");
-        t!("\u{1e0d}\u{307}", "\u{1e0d}\u{307}");
-        t!("a\u{301}", "\u{e1}");
-        t!("\u{301}a", "\u{301}a");
-        t!("\u{d4db}", "\u{d4db}");
-        t!("\u{ac1c}", "\u{ac1c}");
-        t!("a\u{300}\u{305}\u{315}\u{5ae}b", "\u{e0}\u{5ae}\u{305}\u{315}b");
-    }
-
-    #[test]
-    fn test_lines() {
-        let data = "\nMäry häd ä little lämb\n\nLittle lämb\n";
-        let lines: Vec<&str> = data.lines().collect();
-        assert_eq!(lines, ["", "Märy häd ä little lämb", "", "Little lämb"]);
-
-        let data = "\nMäry häd ä little lämb\n\nLittle lämb"; // no trailing \n
-        let lines: Vec<&str> = data.lines().collect();
-        assert_eq!(lines, ["", "Märy häd ä little lämb", "", "Little lämb"]);
-    }
-
-    #[test]
-    fn test_graphemes() {
-        use core::iter::order;
-        // official Unicode test data
-        // from http://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt
-        let test_same: [(_, &[_]); 325] = [
-            ("\u{20}\u{20}", &["\u{20}", "\u{20}"]),
-            ("\u{20}\u{308}\u{20}", &["\u{20}\u{308}", "\u{20}"]),
-            ("\u{20}\u{D}", &["\u{20}", "\u{D}"]),
-            ("\u{20}\u{308}\u{D}", &["\u{20}\u{308}", "\u{D}"]),
-            ("\u{20}\u{A}", &["\u{20}", "\u{A}"]),
-            ("\u{20}\u{308}\u{A}", &["\u{20}\u{308}", "\u{A}"]),
-            ("\u{20}\u{1}", &["\u{20}", "\u{1}"]),
-            ("\u{20}\u{308}\u{1}", &["\u{20}\u{308}", "\u{1}"]),
-            ("\u{20}\u{300}", &["\u{20}\u{300}"]),
-            ("\u{20}\u{308}\u{300}", &["\u{20}\u{308}\u{300}"]),
-            ("\u{20}\u{1100}", &["\u{20}", "\u{1100}"]),
-            ("\u{20}\u{308}\u{1100}", &["\u{20}\u{308}", "\u{1100}"]),
-            ("\u{20}\u{1160}", &["\u{20}", "\u{1160}"]),
-            ("\u{20}\u{308}\u{1160}", &["\u{20}\u{308}", "\u{1160}"]),
-            ("\u{20}\u{11A8}", &["\u{20}", "\u{11A8}"]),
-            ("\u{20}\u{308}\u{11A8}", &["\u{20}\u{308}", "\u{11A8}"]),
-            ("\u{20}\u{AC00}", &["\u{20}", "\u{AC00}"]),
-            ("\u{20}\u{308}\u{AC00}", &["\u{20}\u{308}", "\u{AC00}"]),
-            ("\u{20}\u{AC01}", &["\u{20}", "\u{AC01}"]),
-            ("\u{20}\u{308}\u{AC01}", &["\u{20}\u{308}", "\u{AC01}"]),
-            ("\u{20}\u{1F1E6}", &["\u{20}", "\u{1F1E6}"]),
-            ("\u{20}\u{308}\u{1F1E6}", &["\u{20}\u{308}", "\u{1F1E6}"]),
-            ("\u{20}\u{378}", &["\u{20}", "\u{378}"]),
-            ("\u{20}\u{308}\u{378}", &["\u{20}\u{308}", "\u{378}"]),
-            ("\u{D}\u{20}", &["\u{D}", "\u{20}"]),
-            ("\u{D}\u{308}\u{20}", &["\u{D}", "\u{308}", "\u{20}"]),
-            ("\u{D}\u{D}", &["\u{D}", "\u{D}"]),
-            ("\u{D}\u{308}\u{D}", &["\u{D}", "\u{308}", "\u{D}"]),
-            ("\u{D}\u{A}", &["\u{D}\u{A}"]),
-            ("\u{D}\u{308}\u{A}", &["\u{D}", "\u{308}", "\u{A}"]),
-            ("\u{D}\u{1}", &["\u{D}", "\u{1}"]),
-            ("\u{D}\u{308}\u{1}", &["\u{D}", "\u{308}", "\u{1}"]),
-            ("\u{D}\u{300}", &["\u{D}", "\u{300}"]),
-            ("\u{D}\u{308}\u{300}", &["\u{D}", "\u{308}\u{300}"]),
-            ("\u{D}\u{903}", &["\u{D}", "\u{903}"]),
-            ("\u{D}\u{1100}", &["\u{D}", "\u{1100}"]),
-            ("\u{D}\u{308}\u{1100}", &["\u{D}", "\u{308}", "\u{1100}"]),
-            ("\u{D}\u{1160}", &["\u{D}", "\u{1160}"]),
-            ("\u{D}\u{308}\u{1160}", &["\u{D}", "\u{308}", "\u{1160}"]),
-            ("\u{D}\u{11A8}", &["\u{D}", "\u{11A8}"]),
-            ("\u{D}\u{308}\u{11A8}", &["\u{D}", "\u{308}", "\u{11A8}"]),
-            ("\u{D}\u{AC00}", &["\u{D}", "\u{AC00}"]),
-            ("\u{D}\u{308}\u{AC00}", &["\u{D}", "\u{308}", "\u{AC00}"]),
-            ("\u{D}\u{AC01}", &["\u{D}", "\u{AC01}"]),
-            ("\u{D}\u{308}\u{AC01}", &["\u{D}", "\u{308}", "\u{AC01}"]),
-            ("\u{D}\u{1F1E6}", &["\u{D}", "\u{1F1E6}"]),
-            ("\u{D}\u{308}\u{1F1E6}", &["\u{D}", "\u{308}", "\u{1F1E6}"]),
-            ("\u{D}\u{378}", &["\u{D}", "\u{378}"]),
-            ("\u{D}\u{308}\u{378}", &["\u{D}", "\u{308}", "\u{378}"]),
-            ("\u{A}\u{20}", &["\u{A}", "\u{20}"]),
-            ("\u{A}\u{308}\u{20}", &["\u{A}", "\u{308}", "\u{20}"]),
-            ("\u{A}\u{D}", &["\u{A}", "\u{D}"]),
-            ("\u{A}\u{308}\u{D}", &["\u{A}", "\u{308}", "\u{D}"]),
-            ("\u{A}\u{A}", &["\u{A}", "\u{A}"]),
-            ("\u{A}\u{308}\u{A}", &["\u{A}", "\u{308}", "\u{A}"]),
-            ("\u{A}\u{1}", &["\u{A}", "\u{1}"]),
-            ("\u{A}\u{308}\u{1}", &["\u{A}", "\u{308}", "\u{1}"]),
-            ("\u{A}\u{300}", &["\u{A}", "\u{300}"]),
-            ("\u{A}\u{308}\u{300}", &["\u{A}", "\u{308}\u{300}"]),
-            ("\u{A}\u{903}", &["\u{A}", "\u{903}"]),
-            ("\u{A}\u{1100}", &["\u{A}", "\u{1100}"]),
-            ("\u{A}\u{308}\u{1100}", &["\u{A}", "\u{308}", "\u{1100}"]),
-            ("\u{A}\u{1160}", &["\u{A}", "\u{1160}"]),
-            ("\u{A}\u{308}\u{1160}", &["\u{A}", "\u{308}", "\u{1160}"]),
-            ("\u{A}\u{11A8}", &["\u{A}", "\u{11A8}"]),
-            ("\u{A}\u{308}\u{11A8}", &["\u{A}", "\u{308}", "\u{11A8}"]),
-            ("\u{A}\u{AC00}", &["\u{A}", "\u{AC00}"]),
-            ("\u{A}\u{308}\u{AC00}", &["\u{A}", "\u{308}", "\u{AC00}"]),
-            ("\u{A}\u{AC01}", &["\u{A}", "\u{AC01}"]),
-            ("\u{A}\u{308}\u{AC01}", &["\u{A}", "\u{308}", "\u{AC01}"]),
-            ("\u{A}\u{1F1E6}", &["\u{A}", "\u{1F1E6}"]),
-            ("\u{A}\u{308}\u{1F1E6}", &["\u{A}", "\u{308}", "\u{1F1E6}"]),
-            ("\u{A}\u{378}", &["\u{A}", "\u{378}"]),
-            ("\u{A}\u{308}\u{378}", &["\u{A}", "\u{308}", "\u{378}"]),
-            ("\u{1}\u{20}", &["\u{1}", "\u{20}"]),
-            ("\u{1}\u{308}\u{20}", &["\u{1}", "\u{308}", "\u{20}"]),
-            ("\u{1}\u{D}", &["\u{1}", "\u{D}"]),
-            ("\u{1}\u{308}\u{D}", &["\u{1}", "\u{308}", "\u{D}"]),
-            ("\u{1}\u{A}", &["\u{1}", "\u{A}"]),
-            ("\u{1}\u{308}\u{A}", &["\u{1}", "\u{308}", "\u{A}"]),
-            ("\u{1}\u{1}", &["\u{1}", "\u{1}"]),
-            ("\u{1}\u{308}\u{1}", &["\u{1}", "\u{308}", "\u{1}"]),
-            ("\u{1}\u{300}", &["\u{1}", "\u{300}"]),
-            ("\u{1}\u{308}\u{300}", &["\u{1}", "\u{308}\u{300}"]),
-            ("\u{1}\u{903}", &["\u{1}", "\u{903}"]),
-            ("\u{1}\u{1100}", &["\u{1}", "\u{1100}"]),
-            ("\u{1}\u{308}\u{1100}", &["\u{1}", "\u{308}", "\u{1100}"]),
-            ("\u{1}\u{1160}", &["\u{1}", "\u{1160}"]),
-            ("\u{1}\u{308}\u{1160}", &["\u{1}", "\u{308}", "\u{1160}"]),
-            ("\u{1}\u{11A8}", &["\u{1}", "\u{11A8}"]),
-            ("\u{1}\u{308}\u{11A8}", &["\u{1}", "\u{308}", "\u{11A8}"]),
-            ("\u{1}\u{AC00}", &["\u{1}", "\u{AC00}"]),
-            ("\u{1}\u{308}\u{AC00}", &["\u{1}", "\u{308}", "\u{AC00}"]),
-            ("\u{1}\u{AC01}", &["\u{1}", "\u{AC01}"]),
-            ("\u{1}\u{308}\u{AC01}", &["\u{1}", "\u{308}", "\u{AC01}"]),
-            ("\u{1}\u{1F1E6}", &["\u{1}", "\u{1F1E6}"]),
-            ("\u{1}\u{308}\u{1F1E6}", &["\u{1}", "\u{308}", "\u{1F1E6}"]),
-            ("\u{1}\u{378}", &["\u{1}", "\u{378}"]),
-            ("\u{1}\u{308}\u{378}", &["\u{1}", "\u{308}", "\u{378}"]),
-            ("\u{300}\u{20}", &["\u{300}", "\u{20}"]),
-            ("\u{300}\u{308}\u{20}", &["\u{300}\u{308}", "\u{20}"]),
-            ("\u{300}\u{D}", &["\u{300}", "\u{D}"]),
-            ("\u{300}\u{308}\u{D}", &["\u{300}\u{308}", "\u{D}"]),
-            ("\u{300}\u{A}", &["\u{300}", "\u{A}"]),
-            ("\u{300}\u{308}\u{A}", &["\u{300}\u{308}", "\u{A}"]),
-            ("\u{300}\u{1}", &["\u{300}", "\u{1}"]),
-            ("\u{300}\u{308}\u{1}", &["\u{300}\u{308}", "\u{1}"]),
-            ("\u{300}\u{300}", &["\u{300}\u{300}"]),
-            ("\u{300}\u{308}\u{300}", &["\u{300}\u{308}\u{300}"]),
-            ("\u{300}\u{1100}", &["\u{300}", "\u{1100}"]),
-            ("\u{300}\u{308}\u{1100}", &["\u{300}\u{308}", "\u{1100}"]),
-            ("\u{300}\u{1160}", &["\u{300}", "\u{1160}"]),
-            ("\u{300}\u{308}\u{1160}", &["\u{300}\u{308}", "\u{1160}"]),
-            ("\u{300}\u{11A8}", &["\u{300}", "\u{11A8}"]),
-            ("\u{300}\u{308}\u{11A8}", &["\u{300}\u{308}", "\u{11A8}"]),
-            ("\u{300}\u{AC00}", &["\u{300}", "\u{AC00}"]),
-            ("\u{300}\u{308}\u{AC00}", &["\u{300}\u{308}", "\u{AC00}"]),
-            ("\u{300}\u{AC01}", &["\u{300}", "\u{AC01}"]),
-            ("\u{300}\u{308}\u{AC01}", &["\u{300}\u{308}", "\u{AC01}"]),
-            ("\u{300}\u{1F1E6}", &["\u{300}", "\u{1F1E6}"]),
-            ("\u{300}\u{308}\u{1F1E6}", &["\u{300}\u{308}", "\u{1F1E6}"]),
-            ("\u{300}\u{378}", &["\u{300}", "\u{378}"]),
-            ("\u{300}\u{308}\u{378}", &["\u{300}\u{308}", "\u{378}"]),
-            ("\u{903}\u{20}", &["\u{903}", "\u{20}"]),
-            ("\u{903}\u{308}\u{20}", &["\u{903}\u{308}", "\u{20}"]),
-            ("\u{903}\u{D}", &["\u{903}", "\u{D}"]),
-            ("\u{903}\u{308}\u{D}", &["\u{903}\u{308}", "\u{D}"]),
-            ("\u{903}\u{A}", &["\u{903}", "\u{A}"]),
-            ("\u{903}\u{308}\u{A}", &["\u{903}\u{308}", "\u{A}"]),
-            ("\u{903}\u{1}", &["\u{903}", "\u{1}"]),
-            ("\u{903}\u{308}\u{1}", &["\u{903}\u{308}", "\u{1}"]),
-            ("\u{903}\u{300}", &["\u{903}\u{300}"]),
-            ("\u{903}\u{308}\u{300}", &["\u{903}\u{308}\u{300}"]),
-            ("\u{903}\u{1100}", &["\u{903}", "\u{1100}"]),
-            ("\u{903}\u{308}\u{1100}", &["\u{903}\u{308}", "\u{1100}"]),
-            ("\u{903}\u{1160}", &["\u{903}", "\u{1160}"]),
-            ("\u{903}\u{308}\u{1160}", &["\u{903}\u{308}", "\u{1160}"]),
-            ("\u{903}\u{11A8}", &["\u{903}", "\u{11A8}"]),
-            ("\u{903}\u{308}\u{11A8}", &["\u{903}\u{308}", "\u{11A8}"]),
-            ("\u{903}\u{AC00}", &["\u{903}", "\u{AC00}"]),
-            ("\u{903}\u{308}\u{AC00}", &["\u{903}\u{308}", "\u{AC00}"]),
-            ("\u{903}\u{AC01}", &["\u{903}", "\u{AC01}"]),
-            ("\u{903}\u{308}\u{AC01}", &["\u{903}\u{308}", "\u{AC01}"]),
-            ("\u{903}\u{1F1E6}", &["\u{903}", "\u{1F1E6}"]),
-            ("\u{903}\u{308}\u{1F1E6}", &["\u{903}\u{308}", "\u{1F1E6}"]),
-            ("\u{903}\u{378}", &["\u{903}", "\u{378}"]),
-            ("\u{903}\u{308}\u{378}", &["\u{903}\u{308}", "\u{378}"]),
-            ("\u{1100}\u{20}", &["\u{1100}", "\u{20}"]),
-            ("\u{1100}\u{308}\u{20}", &["\u{1100}\u{308}", "\u{20}"]),
-            ("\u{1100}\u{D}", &["\u{1100}", "\u{D}"]),
-            ("\u{1100}\u{308}\u{D}", &["\u{1100}\u{308}", "\u{D}"]),
-            ("\u{1100}\u{A}", &["\u{1100}", "\u{A}"]),
-            ("\u{1100}\u{308}\u{A}", &["\u{1100}\u{308}", "\u{A}"]),
-            ("\u{1100}\u{1}", &["\u{1100}", "\u{1}"]),
-            ("\u{1100}\u{308}\u{1}", &["\u{1100}\u{308}", "\u{1}"]),
-            ("\u{1100}\u{300}", &["\u{1100}\u{300}"]),
-            ("\u{1100}\u{308}\u{300}", &["\u{1100}\u{308}\u{300}"]),
-            ("\u{1100}\u{1100}", &["\u{1100}\u{1100}"]),
-            ("\u{1100}\u{308}\u{1100}", &["\u{1100}\u{308}", "\u{1100}"]),
-            ("\u{1100}\u{1160}", &["\u{1100}\u{1160}"]),
-            ("\u{1100}\u{308}\u{1160}", &["\u{1100}\u{308}", "\u{1160}"]),
-            ("\u{1100}\u{11A8}", &["\u{1100}", "\u{11A8}"]),
-            ("\u{1100}\u{308}\u{11A8}", &["\u{1100}\u{308}", "\u{11A8}"]),
-            ("\u{1100}\u{AC00}", &["\u{1100}\u{AC00}"]),
-            ("\u{1100}\u{308}\u{AC00}", &["\u{1100}\u{308}", "\u{AC00}"]),
-            ("\u{1100}\u{AC01}", &["\u{1100}\u{AC01}"]),
-            ("\u{1100}\u{308}\u{AC01}", &["\u{1100}\u{308}", "\u{AC01}"]),
-            ("\u{1100}\u{1F1E6}", &["\u{1100}", "\u{1F1E6}"]),
-            ("\u{1100}\u{308}\u{1F1E6}", &["\u{1100}\u{308}", "\u{1F1E6}"]),
-            ("\u{1100}\u{378}", &["\u{1100}", "\u{378}"]),
-            ("\u{1100}\u{308}\u{378}", &["\u{1100}\u{308}", "\u{378}"]),
-            ("\u{1160}\u{20}", &["\u{1160}", "\u{20}"]),
-            ("\u{1160}\u{308}\u{20}", &["\u{1160}\u{308}", "\u{20}"]),
-            ("\u{1160}\u{D}", &["\u{1160}", "\u{D}"]),
-            ("\u{1160}\u{308}\u{D}", &["\u{1160}\u{308}", "\u{D}"]),
-            ("\u{1160}\u{A}", &["\u{1160}", "\u{A}"]),
-            ("\u{1160}\u{308}\u{A}", &["\u{1160}\u{308}", "\u{A}"]),
-            ("\u{1160}\u{1}", &["\u{1160}", "\u{1}"]),
-            ("\u{1160}\u{308}\u{1}", &["\u{1160}\u{308}", "\u{1}"]),
-            ("\u{1160}\u{300}", &["\u{1160}\u{300}"]),
-            ("\u{1160}\u{308}\u{300}", &["\u{1160}\u{308}\u{300}"]),
-            ("\u{1160}\u{1100}", &["\u{1160}", "\u{1100}"]),
-            ("\u{1160}\u{308}\u{1100}", &["\u{1160}\u{308}", "\u{1100}"]),
-            ("\u{1160}\u{1160}", &["\u{1160}\u{1160}"]),
-            ("\u{1160}\u{308}\u{1160}", &["\u{1160}\u{308}", "\u{1160}"]),
-            ("\u{1160}\u{11A8}", &["\u{1160}\u{11A8}"]),
-            ("\u{1160}\u{308}\u{11A8}", &["\u{1160}\u{308}", "\u{11A8}"]),
-            ("\u{1160}\u{AC00}", &["\u{1160}", "\u{AC00}"]),
-            ("\u{1160}\u{308}\u{AC00}", &["\u{1160}\u{308}", "\u{AC00}"]),
-            ("\u{1160}\u{AC01}", &["\u{1160}", "\u{AC01}"]),
-            ("\u{1160}\u{308}\u{AC01}", &["\u{1160}\u{308}", "\u{AC01}"]),
-            ("\u{1160}\u{1F1E6}", &["\u{1160}", "\u{1F1E6}"]),
-            ("\u{1160}\u{308}\u{1F1E6}", &["\u{1160}\u{308}", "\u{1F1E6}"]),
-            ("\u{1160}\u{378}", &["\u{1160}", "\u{378}"]),
-            ("\u{1160}\u{308}\u{378}", &["\u{1160}\u{308}", "\u{378}"]),
-            ("\u{11A8}\u{20}", &["\u{11A8}", "\u{20}"]),
-            ("\u{11A8}\u{308}\u{20}", &["\u{11A8}\u{308}", "\u{20}"]),
-            ("\u{11A8}\u{D}", &["\u{11A8}", "\u{D}"]),
-            ("\u{11A8}\u{308}\u{D}", &["\u{11A8}\u{308}", "\u{D}"]),
-            ("\u{11A8}\u{A}", &["\u{11A8}", "\u{A}"]),
-            ("\u{11A8}\u{308}\u{A}", &["\u{11A8}\u{308}", "\u{A}"]),
-            ("\u{11A8}\u{1}", &["\u{11A8}", "\u{1}"]),
-            ("\u{11A8}\u{308}\u{1}", &["\u{11A8}\u{308}", "\u{1}"]),
-            ("\u{11A8}\u{300}", &["\u{11A8}\u{300}"]),
-            ("\u{11A8}\u{308}\u{300}", &["\u{11A8}\u{308}\u{300}"]),
-            ("\u{11A8}\u{1100}", &["\u{11A8}", "\u{1100}"]),
-            ("\u{11A8}\u{308}\u{1100}", &["\u{11A8}\u{308}", "\u{1100}"]),
-            ("\u{11A8}\u{1160}", &["\u{11A8}", "\u{1160}"]),
-            ("\u{11A8}\u{308}\u{1160}", &["\u{11A8}\u{308}", "\u{1160}"]),
-            ("\u{11A8}\u{11A8}", &["\u{11A8}\u{11A8}"]),
-            ("\u{11A8}\u{308}\u{11A8}", &["\u{11A8}\u{308}", "\u{11A8}"]),
-            ("\u{11A8}\u{AC00}", &["\u{11A8}", "\u{AC00}"]),
-            ("\u{11A8}\u{308}\u{AC00}", &["\u{11A8}\u{308}", "\u{AC00}"]),
-            ("\u{11A8}\u{AC01}", &["\u{11A8}", "\u{AC01}"]),
-            ("\u{11A8}\u{308}\u{AC01}", &["\u{11A8}\u{308}", "\u{AC01}"]),
-            ("\u{11A8}\u{1F1E6}", &["\u{11A8}", "\u{1F1E6}"]),
-            ("\u{11A8}\u{308}\u{1F1E6}", &["\u{11A8}\u{308}", "\u{1F1E6}"]),
-            ("\u{11A8}\u{378}", &["\u{11A8}", "\u{378}"]),
-            ("\u{11A8}\u{308}\u{378}", &["\u{11A8}\u{308}", "\u{378}"]),
-            ("\u{AC00}\u{20}", &["\u{AC00}", "\u{20}"]),
-            ("\u{AC00}\u{308}\u{20}", &["\u{AC00}\u{308}", "\u{20}"]),
-            ("\u{AC00}\u{D}", &["\u{AC00}", "\u{D}"]),
-            ("\u{AC00}\u{308}\u{D}", &["\u{AC00}\u{308}", "\u{D}"]),
-            ("\u{AC00}\u{A}", &["\u{AC00}", "\u{A}"]),
-            ("\u{AC00}\u{308}\u{A}", &["\u{AC00}\u{308}", "\u{A}"]),
-            ("\u{AC00}\u{1}", &["\u{AC00}", "\u{1}"]),
-            ("\u{AC00}\u{308}\u{1}", &["\u{AC00}\u{308}", "\u{1}"]),
-            ("\u{AC00}\u{300}", &["\u{AC00}\u{300}"]),
-            ("\u{AC00}\u{308}\u{300}", &["\u{AC00}\u{308}\u{300}"]),
-            ("\u{AC00}\u{1100}", &["\u{AC00}", "\u{1100}"]),
-            ("\u{AC00}\u{308}\u{1100}", &["\u{AC00}\u{308}", "\u{1100}"]),
-            ("\u{AC00}\u{1160}", &["\u{AC00}\u{1160}"]),
-            ("\u{AC00}\u{308}\u{1160}", &["\u{AC00}\u{308}", "\u{1160}"]),
-            ("\u{AC00}\u{11A8}", &["\u{AC00}\u{11A8}"]),
-            ("\u{AC00}\u{308}\u{11A8}", &["\u{AC00}\u{308}", "\u{11A8}"]),
-            ("\u{AC00}\u{AC00}", &["\u{AC00}", "\u{AC00}"]),
-            ("\u{AC00}\u{308}\u{AC00}", &["\u{AC00}\u{308}", "\u{AC00}"]),
-            ("\u{AC00}\u{AC01}", &["\u{AC00}", "\u{AC01}"]),
-            ("\u{AC00}\u{308}\u{AC01}", &["\u{AC00}\u{308}", "\u{AC01}"]),
-            ("\u{AC00}\u{1F1E6}", &["\u{AC00}", "\u{1F1E6}"]),
-            ("\u{AC00}\u{308}\u{1F1E6}", &["\u{AC00}\u{308}", "\u{1F1E6}"]),
-            ("\u{AC00}\u{378}", &["\u{AC00}", "\u{378}"]),
-            ("\u{AC00}\u{308}\u{378}", &["\u{AC00}\u{308}", "\u{378}"]),
-            ("\u{AC01}\u{20}", &["\u{AC01}", "\u{20}"]),
-            ("\u{AC01}\u{308}\u{20}", &["\u{AC01}\u{308}", "\u{20}"]),
-            ("\u{AC01}\u{D}", &["\u{AC01}", "\u{D}"]),
-            ("\u{AC01}\u{308}\u{D}", &["\u{AC01}\u{308}", "\u{D}"]),
-            ("\u{AC01}\u{A}", &["\u{AC01}", "\u{A}"]),
-            ("\u{AC01}\u{308}\u{A}", &["\u{AC01}\u{308}", "\u{A}"]),
-            ("\u{AC01}\u{1}", &["\u{AC01}", "\u{1}"]),
-            ("\u{AC01}\u{308}\u{1}", &["\u{AC01}\u{308}", "\u{1}"]),
-            ("\u{AC01}\u{300}", &["\u{AC01}\u{300}"]),
-            ("\u{AC01}\u{308}\u{300}", &["\u{AC01}\u{308}\u{300}"]),
-            ("\u{AC01}\u{1100}", &["\u{AC01}", "\u{1100}"]),
-            ("\u{AC01}\u{308}\u{1100}", &["\u{AC01}\u{308}", "\u{1100}"]),
-            ("\u{AC01}\u{1160}", &["\u{AC01}", "\u{1160}"]),
-            ("\u{AC01}\u{308}\u{1160}", &["\u{AC01}\u{308}", "\u{1160}"]),
-            ("\u{AC01}\u{11A8}", &["\u{AC01}\u{11A8}"]),
-            ("\u{AC01}\u{308}\u{11A8}", &["\u{AC01}\u{308}", "\u{11A8}"]),
-            ("\u{AC01}\u{AC00}", &["\u{AC01}", "\u{AC00}"]),
-            ("\u{AC01}\u{308}\u{AC00}", &["\u{AC01}\u{308}", "\u{AC00}"]),
-            ("\u{AC01}\u{AC01}", &["\u{AC01}", "\u{AC01}"]),
-            ("\u{AC01}\u{308}\u{AC01}", &["\u{AC01}\u{308}", "\u{AC01}"]),
-            ("\u{AC01}\u{1F1E6}", &["\u{AC01}", "\u{1F1E6}"]),
-            ("\u{AC01}\u{308}\u{1F1E6}", &["\u{AC01}\u{308}", "\u{1F1E6}"]),
-            ("\u{AC01}\u{378}", &["\u{AC01}", "\u{378}"]),
-            ("\u{AC01}\u{308}\u{378}", &["\u{AC01}\u{308}", "\u{378}"]),
-            ("\u{1F1E6}\u{20}", &["\u{1F1E6}", "\u{20}"]),
-            ("\u{1F1E6}\u{308}\u{20}", &["\u{1F1E6}\u{308}", "\u{20}"]),
-            ("\u{1F1E6}\u{D}", &["\u{1F1E6}", "\u{D}"]),
-            ("\u{1F1E6}\u{308}\u{D}", &["\u{1F1E6}\u{308}", "\u{D}"]),
-            ("\u{1F1E6}\u{A}", &["\u{1F1E6}", "\u{A}"]),
-            ("\u{1F1E6}\u{308}\u{A}", &["\u{1F1E6}\u{308}", "\u{A}"]),
-            ("\u{1F1E6}\u{1}", &["\u{1F1E6}", "\u{1}"]),
-            ("\u{1F1E6}\u{308}\u{1}", &["\u{1F1E6}\u{308}", "\u{1}"]),
-            ("\u{1F1E6}\u{300}", &["\u{1F1E6}\u{300}"]),
-            ("\u{1F1E6}\u{308}\u{300}", &["\u{1F1E6}\u{308}\u{300}"]),
-            ("\u{1F1E6}\u{1100}", &["\u{1F1E6}", "\u{1100}"]),
-            ("\u{1F1E6}\u{308}\u{1100}", &["\u{1F1E6}\u{308}", "\u{1100}"]),
-            ("\u{1F1E6}\u{1160}", &["\u{1F1E6}", "\u{1160}"]),
-            ("\u{1F1E6}\u{308}\u{1160}", &["\u{1F1E6}\u{308}", "\u{1160}"]),
-            ("\u{1F1E6}\u{11A8}", &["\u{1F1E6}", "\u{11A8}"]),
-            ("\u{1F1E6}\u{308}\u{11A8}", &["\u{1F1E6}\u{308}", "\u{11A8}"]),
-            ("\u{1F1E6}\u{AC00}", &["\u{1F1E6}", "\u{AC00}"]),
-            ("\u{1F1E6}\u{308}\u{AC00}", &["\u{1F1E6}\u{308}", "\u{AC00}"]),
-            ("\u{1F1E6}\u{AC01}", &["\u{1F1E6}", "\u{AC01}"]),
-            ("\u{1F1E6}\u{308}\u{AC01}", &["\u{1F1E6}\u{308}", "\u{AC01}"]),
-            ("\u{1F1E6}\u{1F1E6}", &["\u{1F1E6}\u{1F1E6}"]),
-            ("\u{1F1E6}\u{308}\u{1F1E6}", &["\u{1F1E6}\u{308}", "\u{1F1E6}"]),
-            ("\u{1F1E6}\u{378}", &["\u{1F1E6}", "\u{378}"]),
-            ("\u{1F1E6}\u{308}\u{378}", &["\u{1F1E6}\u{308}", "\u{378}"]),
-            ("\u{378}\u{20}", &["\u{378}", "\u{20}"]),
-            ("\u{378}\u{308}\u{20}", &["\u{378}\u{308}", "\u{20}"]),
-            ("\u{378}\u{D}", &["\u{378}", "\u{D}"]),
-            ("\u{378}\u{308}\u{D}", &["\u{378}\u{308}", "\u{D}"]),
-            ("\u{378}\u{A}", &["\u{378}", "\u{A}"]),
-            ("\u{378}\u{308}\u{A}", &["\u{378}\u{308}", "\u{A}"]),
-            ("\u{378}\u{1}", &["\u{378}", "\u{1}"]),
-            ("\u{378}\u{308}\u{1}", &["\u{378}\u{308}", "\u{1}"]),
-            ("\u{378}\u{300}", &["\u{378}\u{300}"]),
-            ("\u{378}\u{308}\u{300}", &["\u{378}\u{308}\u{300}"]),
-            ("\u{378}\u{1100}", &["\u{378}", "\u{1100}"]),
-            ("\u{378}\u{308}\u{1100}", &["\u{378}\u{308}", "\u{1100}"]),
-            ("\u{378}\u{1160}", &["\u{378}", "\u{1160}"]),
-            ("\u{378}\u{308}\u{1160}", &["\u{378}\u{308}", "\u{1160}"]),
-            ("\u{378}\u{11A8}", &["\u{378}", "\u{11A8}"]),
-            ("\u{378}\u{308}\u{11A8}", &["\u{378}\u{308}", "\u{11A8}"]),
-            ("\u{378}\u{AC00}", &["\u{378}", "\u{AC00}"]),
-            ("\u{378}\u{308}\u{AC00}", &["\u{378}\u{308}", "\u{AC00}"]),
-            ("\u{378}\u{AC01}", &["\u{378}", "\u{AC01}"]),
-            ("\u{378}\u{308}\u{AC01}", &["\u{378}\u{308}", "\u{AC01}"]),
-            ("\u{378}\u{1F1E6}", &["\u{378}", "\u{1F1E6}"]),
-            ("\u{378}\u{308}\u{1F1E6}", &["\u{378}\u{308}", "\u{1F1E6}"]),
-            ("\u{378}\u{378}", &["\u{378}", "\u{378}"]),
-            ("\u{378}\u{308}\u{378}", &["\u{378}\u{308}", "\u{378}"]),
-            ("\u{61}\u{1F1E6}\u{62}", &["\u{61}", "\u{1F1E6}", "\u{62}"]),
-            ("\u{1F1F7}\u{1F1FA}", &["\u{1F1F7}\u{1F1FA}"]),
-            ("\u{1F1F7}\u{1F1FA}\u{1F1F8}", &["\u{1F1F7}\u{1F1FA}\u{1F1F8}"]),
-            ("\u{1F1F7}\u{1F1FA}\u{1F1F8}\u{1F1EA}",
-            &["\u{1F1F7}\u{1F1FA}\u{1F1F8}\u{1F1EA}"]),
-            ("\u{1F1F7}\u{1F1FA}\u{200B}\u{1F1F8}\u{1F1EA}",
-             &["\u{1F1F7}\u{1F1FA}", "\u{200B}", "\u{1F1F8}\u{1F1EA}"]),
-            ("\u{1F1E6}\u{1F1E7}\u{1F1E8}", &["\u{1F1E6}\u{1F1E7}\u{1F1E8}"]),
-            ("\u{1F1E6}\u{200D}\u{1F1E7}\u{1F1E8}", &["\u{1F1E6}\u{200D}",
-             "\u{1F1E7}\u{1F1E8}"]),
-            ("\u{1F1E6}\u{1F1E7}\u{200D}\u{1F1E8}",
-             &["\u{1F1E6}\u{1F1E7}\u{200D}", "\u{1F1E8}"]),
-            ("\u{20}\u{200D}\u{646}", &["\u{20}\u{200D}", "\u{646}"]),
-            ("\u{646}\u{200D}\u{20}", &["\u{646}\u{200D}", "\u{20}"]),
-        ];
-
-        let test_diff: [(_, &[_], &[_]); 23] = [
-            ("\u{20}\u{903}", &["\u{20}\u{903}"], &["\u{20}", "\u{903}"]), ("\u{20}\u{308}\u{903}",
-            &["\u{20}\u{308}\u{903}"], &["\u{20}\u{308}", "\u{903}"]), ("\u{D}\u{308}\u{903}",
-            &["\u{D}", "\u{308}\u{903}"], &["\u{D}", "\u{308}", "\u{903}"]), ("\u{A}\u{308}\u{903}",
-            &["\u{A}", "\u{308}\u{903}"], &["\u{A}", "\u{308}", "\u{903}"]), ("\u{1}\u{308}\u{903}",
-            &["\u{1}", "\u{308}\u{903}"], &["\u{1}", "\u{308}", "\u{903}"]), ("\u{300}\u{903}",
-            &["\u{300}\u{903}"], &["\u{300}", "\u{903}"]), ("\u{300}\u{308}\u{903}",
-            &["\u{300}\u{308}\u{903}"], &["\u{300}\u{308}", "\u{903}"]), ("\u{903}\u{903}",
-            &["\u{903}\u{903}"], &["\u{903}", "\u{903}"]), ("\u{903}\u{308}\u{903}",
-            &["\u{903}\u{308}\u{903}"], &["\u{903}\u{308}", "\u{903}"]), ("\u{1100}\u{903}",
-            &["\u{1100}\u{903}"], &["\u{1100}", "\u{903}"]), ("\u{1100}\u{308}\u{903}",
-            &["\u{1100}\u{308}\u{903}"], &["\u{1100}\u{308}", "\u{903}"]), ("\u{1160}\u{903}",
-            &["\u{1160}\u{903}"], &["\u{1160}", "\u{903}"]), ("\u{1160}\u{308}\u{903}",
-            &["\u{1160}\u{308}\u{903}"], &["\u{1160}\u{308}", "\u{903}"]), ("\u{11A8}\u{903}",
-            &["\u{11A8}\u{903}"], &["\u{11A8}", "\u{903}"]), ("\u{11A8}\u{308}\u{903}",
-            &["\u{11A8}\u{308}\u{903}"], &["\u{11A8}\u{308}", "\u{903}"]), ("\u{AC00}\u{903}",
-            &["\u{AC00}\u{903}"], &["\u{AC00}", "\u{903}"]), ("\u{AC00}\u{308}\u{903}",
-            &["\u{AC00}\u{308}\u{903}"], &["\u{AC00}\u{308}", "\u{903}"]), ("\u{AC01}\u{903}",
-            &["\u{AC01}\u{903}"], &["\u{AC01}", "\u{903}"]), ("\u{AC01}\u{308}\u{903}",
-            &["\u{AC01}\u{308}\u{903}"], &["\u{AC01}\u{308}", "\u{903}"]), ("\u{1F1E6}\u{903}",
-            &["\u{1F1E6}\u{903}"], &["\u{1F1E6}", "\u{903}"]), ("\u{1F1E6}\u{308}\u{903}",
-            &["\u{1F1E6}\u{308}\u{903}"], &["\u{1F1E6}\u{308}", "\u{903}"]), ("\u{378}\u{903}",
-            &["\u{378}\u{903}"], &["\u{378}", "\u{903}"]), ("\u{378}\u{308}\u{903}",
-            &["\u{378}\u{308}\u{903}"], &["\u{378}\u{308}", "\u{903}"]),
-        ];
-
-        for &(s, g) in &test_same[..] {
-            // test forward iterator
-            assert!(order::equals(s.graphemes(true), g.iter().cloned()));
-            assert!(order::equals(s.graphemes(false), g.iter().cloned()));
-
-            // test reverse iterator
-            assert!(order::equals(s.graphemes(true).rev(), g.iter().rev().cloned()));
-            assert!(order::equals(s.graphemes(false).rev(), g.iter().rev().cloned()));
-        }
-
-        for &(s, gt, gf) in &test_diff {
-            // test forward iterator
-            assert!(order::equals(s.graphemes(true), gt.iter().cloned()));
-            assert!(order::equals(s.graphemes(false), gf.iter().cloned()));
-
-            // test reverse iterator
-            assert!(order::equals(s.graphemes(true).rev(), gt.iter().rev().cloned()));
-            assert!(order::equals(s.graphemes(false).rev(), gf.iter().rev().cloned()));
-        }
-
-        // test the indices iterators
-        let s = "a̐éö̲\r\n";
-        let gr_inds = s.grapheme_indices(true).collect::<Vec<(usize, &str)>>();
-        let b: &[_] = &[(0, "a̐"), (3, "é"), (6, "ö̲"), (11, "\r\n")];
-        assert_eq!(gr_inds, b);
-        let gr_inds = s.grapheme_indices(true).rev().collect::<Vec<(usize, &str)>>();
-        let b: &[_] = &[(11, "\r\n"), (6, "ö̲"), (3, "é"), (0, "a̐")];
-        assert_eq!(gr_inds, b);
-        let mut gr_inds_iter = s.grapheme_indices(true);
-        {
-            let gr_inds = gr_inds_iter.by_ref();
-            let e1 = gr_inds.size_hint();
-            assert_eq!(e1, (1, Some(13)));
-            let c = gr_inds.count();
-            assert_eq!(c, 4);
-        }
-        let e2 = gr_inds_iter.size_hint();
-        assert_eq!(e2, (0, Some(0)));
-
-        // make sure the reverse iterator does the right thing with "\n" at beginning of string
-        let s = "\n\r\n\r";
-        let gr = s.graphemes(true).rev().collect::<Vec<&str>>();
-        let b: &[_] = &["\r", "\r\n", "\n"];
-        assert_eq!(gr, b);
+    /// An iterator over the lines of a string, separated by either `\n` or `\r\n`.
+    ///
+    /// As with `.lines()`, this does not include an empty trailing line.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let four_lines = "foo\r\nbar\n\r\nbaz";
+    /// let v: Vec<&str> = four_lines.lines_any().collect();
+    ///
+    /// assert_eq!(v, ["foo", "bar", "", "baz"]);
+    /// ```
+    ///
+    /// Leaving off the trailing character:
+    ///
+    /// ```
+    /// let four_lines = "foo\r\nbar\n\r\nbaz\n";
+    /// let v: Vec<&str> = four_lines.lines_any().collect();
+    ///
+    /// assert_eq!(v, ["foo", "bar", "", "baz"]);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn lines_any(&self) -> LinesAny {
+        core_str::StrExt::lines_any(&self[..])
     }
 
-    #[test]
-    fn test_split_strator() {
-        fn t(s: &str, sep: &str, u: &[&str]) {
-            let v: Vec<&str> = s.split_str(sep).collect();
-            assert_eq!(v, u);
-        }
-        t("--1233345--", "12345", &["--1233345--"]);
-        t("abc::hello::there", "::", &["abc", "hello", "there"]);
-        t("::hello::there", "::", &["", "hello", "there"]);
-        t("hello::there::", "::", &["hello", "there", ""]);
-        t("::hello::there::", "::", &["", "hello", "there", ""]);
-        t("ประเทศไทย中华Việt Nam", "中华", &["ประเทศไทย", "Việt Nam"]);
-        t("zzXXXzzYYYzz", "zz", &["", "XXX", "YYY", ""]);
-        t("zzXXXzYYYz", "XXX", &["zz", "zYYYz"]);
-        t(".XXX.YYY.", ".", &["", "XXX", "YYY", ""]);
-        t("", ".", &[""]);
-        t("zz", "zz", &["",""]);
-        t("ok", "z", &["ok"]);
-        t("zzz", "zz", &["","z"]);
-        t("zzzzz", "zz", &["","","z"]);
-    }
-
-    #[test]
-    fn test_str_default() {
-        use core::default::Default;
-        fn t<S: Default + Str>() {
-            let s: S = Default::default();
-            assert_eq!(s.as_slice(), "");
-        }
-
-        t::<&str>();
-        t::<String>();
+    /// Deprecated: use `s[a .. b]` instead.
+    #[unstable(feature = "collections",
+               reason = "use slice notation [a..b] instead")]
+    #[deprecated(since = "1.0.0", reason = "use slice notation [a..b] instead")]
+    pub fn slice(&self, begin: usize, end: usize) -> &str {
+        &self[begin..end]
     }
 
-    #[test]
-    fn test_str_container() {
-        fn sum_len(v: &[&str]) -> usize {
-            v.iter().map(|x| x.len()).sum()
-        }
-
-        let s = String::from_str("01234");
-        assert_eq!(5, sum_len(&["012", "", "34"]));
-        assert_eq!(5, sum_len(&[&String::from_str("01"),
-                                &String::from_str("2"),
-                                &String::from_str("34"),
-                                &String::from_str("")]));
-        assert_eq!(5, sum_len(&[&s]));
+    /// Deprecated: use `s[a..]` instead.
+    #[unstable(feature = "collections",
+               reason = "use slice notation [a..b] instead")]
+    #[deprecated(since = "1.0.0", reason = "use slice notation [a..] instead")]
+    pub fn slice_from(&self, begin: usize) -> &str {
+        &self[begin..]
     }
 
-    #[test]
-    fn test_str_from_utf8() {
-        let xs = b"hello";
-        assert_eq!(from_utf8(xs), Ok("hello"));
-
-        let xs = "ศไทย中华Việt Nam".as_bytes();
-        assert_eq!(from_utf8(xs), Ok("ศไทย中华Việt Nam"));
-
-        let xs = b"hello\xFF";
-        assert_eq!(from_utf8(xs), Err(Utf8Error::TooShort));
+    /// Deprecated: use `s[..a]` instead.
+    #[unstable(feature = "collections",
+               reason = "use slice notation [a..b] instead")]
+    #[deprecated(since = "1.0.0", reason = "use slice notation [..a] instead")]
+    pub fn slice_to(&self, end: usize) -> &str {
+        &self[..end]
     }
-}
-
-#[cfg(test)]
-mod bench {
-    use super::*;
-    use prelude::{SliceExt, IteratorExt, SliceConcatExt};
-    use test::Bencher;
-    use test::black_box;
-
-    #[bench]
-    fn char_iterator(b: &mut Bencher) {
-        let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
 
-        b.iter(|| s.chars().count());
+    /// Returns a slice of the string from the character range [`begin`..`end`).
+    ///
+    /// That is, start at the `begin`-th code point of the string and continue
+    /// to the `end`-th code point. This does not detect or handle edge cases
+    /// such as leaving a combining character as the first code point of the
+    /// string.
+    ///
+    /// Due to the design of UTF-8, this operation is `O(end)`. See `slice`,
+    /// `slice_to` and `slice_from` for `O(1)` variants that use byte indices
+    /// rather than code point indices.
+    ///
+    /// # Panics
+    ///
+    /// Panics if `begin` > `end` or the either `begin` or `end` are beyond the
+    /// last character of the string.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let s = "Löwe 老虎 Léopard";
+    ///
+    /// assert_eq!(s.slice_chars(0, 4), "Löwe");
+    /// assert_eq!(s.slice_chars(5, 7), "老虎");
+    /// ```
+    #[unstable(feature = "collections",
+               reason = "may have yet to prove its worth")]
+    pub fn slice_chars(&self, begin: usize, end: usize) -> &str {
+        core_str::StrExt::slice_chars(&self[..], begin, end)
     }
 
-    #[bench]
-    fn char_iterator_for(b: &mut Bencher) {
-        let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
-
-        b.iter(|| {
-            for ch in s.chars() { black_box(ch); }
-        });
+    /// Takes a bytewise slice from a string.
+    ///
+    /// Returns the substring from [`begin`..`end`).
+    ///
+    /// # Unsafety
+    ///
+    /// Caller must check both UTF-8 character boundaries and the boundaries of the entire slice as
+    /// well.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let s = "Löwe 老虎 Léopard";
+    ///
+    /// unsafe {
+    ///     assert_eq!(s.slice_unchecked(0, 21), "Löwe 老虎 Léopard");
+    /// }
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &str {
+        core_str::StrExt::slice_unchecked(&self[..], begin, end)
     }
 
-    #[bench]
-    fn char_iterator_ascii(b: &mut Bencher) {
-        let s = "Mary had a little lamb, Little lamb
-        Mary had a little lamb, Little lamb
-        Mary had a little lamb, Little lamb
-        Mary had a little lamb, Little lamb
-        Mary had a little lamb, Little lamb
-        Mary had a little lamb, Little lamb";
-
-        b.iter(|| s.chars().count());
+    /// Returns `true` if the given `&str` is a prefix of the string.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// assert!("banana".starts_with("ba"));
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn starts_with<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool {
+        core_str::StrExt::starts_with(&self[..], pat)
     }
 
-    #[bench]
-    fn char_iterator_rev(b: &mut Bencher) {
-        let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
-
-        b.iter(|| s.chars().rev().count());
+    /// Returns true if the given `&str` is a suffix of the string.
+    ///
+    /// # Examples
+    ///
+    /// ```rust
+    /// assert!("banana".ends_with("nana"));
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn ends_with<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool
+        where P::Searcher: ReverseSearcher<'a>
+    {
+        core_str::StrExt::ends_with(&self[..], pat)
     }
 
-    #[bench]
-    fn char_iterator_rev_for(b: &mut Bencher) {
-        let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
+    /// Returns a string with all pre- and suffixes that match a pattern repeatedly removed.
+    ///
+    /// The pattern can be a simple `&str`, or a closure that determines the split.
+    ///
+    /// # Examples
+    ///
+    /// Simple `&str` patterns:
+    ///
+    /// ```
+    /// assert_eq!("11foo1bar11".trim_matches('1'), "foo1bar");
+    ///
+    /// let x: &[_] = &['1', '2'];
+    /// assert_eq!("12foo1bar12".trim_matches(x), "foo1bar");
+    /// ```
+    ///
+    /// More complex patterns with a lambda:
+    ///
+    /// ```
+    /// assert_eq!("123foo1bar123".trim_matches(|c: char| c.is_numeric()), "foo1bar");
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn trim_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str
+        where P::Searcher: DoubleEndedSearcher<'a>
+    {
+        core_str::StrExt::trim_matches(&self[..], pat)
+    }
 
-        b.iter(|| {
-            for ch in s.chars().rev() { black_box(ch); }
-        });
+    /// Returns a string with all prefixes that match a pattern repeatedly removed.
+    ///
+    /// The pattern can be a simple `&str`, or a closure that determines the split.
+    ///
+    /// # Examples
+    ///
+    /// Simple `&str` patterns:
+    ///
+    /// ```
+    /// assert_eq!("11foo1bar11".trim_left_matches('1'), "foo1bar11");
+    ///
+    /// let x: &[_] = &['1', '2'];
+    /// assert_eq!("12foo1bar12".trim_left_matches(x), "foo1bar12");
+    /// ```
+    ///
+    /// More complex patterns with a lambda:
+    ///
+    /// ```
+    /// assert_eq!("123foo1bar123".trim_left_matches(|c: char| c.is_numeric()), "foo1bar123");
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn trim_left_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str {
+        core_str::StrExt::trim_left_matches(&self[..], pat)
     }
 
-    #[bench]
-    fn char_indicesator(b: &mut Bencher) {
-        let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
-        let len = s.chars().count();
+    /// Returns a string with all suffixes that match a pattern repeatedly removed.
+    ///
+    /// The pattern can be a simple `&str`, or a closure that determines the split.
+    ///
+    /// # Examples
+    ///
+    /// Simple `&str` patterns:
+    ///
+    /// ```
+    /// assert_eq!("11foo1bar11".trim_right_matches('1'), "11foo1bar");
+    /// let x: &[_] = &['1', '2'];
+    /// assert_eq!("12foo1bar12".trim_right_matches(x), "12foo1bar");
+    /// ```
+    ///
+    /// More complex patterns with a lambda:
+    ///
+    /// ```
+    /// assert_eq!("123foo1bar123".trim_right_matches(|c: char| c.is_numeric()), "123foo1bar");
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn trim_right_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str
+        where P::Searcher: ReverseSearcher<'a>
+    {
+        core_str::StrExt::trim_right_matches(&self[..], pat)
+    }
 
-        b.iter(|| assert_eq!(s.char_indices().count(), len));
+    /// Check that `index`-th byte lies at the start and/or end of a UTF-8 code point sequence.
+    ///
+    /// The start and end of the string (when `index == self.len()`) are considered to be
+    /// boundaries.
+    ///
+    /// # Panics
+    ///
+    /// Panics if `index` is greater than `self.len()`.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let s = "Löwe 老虎 Léopard";
+    /// assert!(s.is_char_boundary(0));
+    /// // start of `老`
+    /// assert!(s.is_char_boundary(6));
+    /// assert!(s.is_char_boundary(s.len()));
+    ///
+    /// // second byte of `ö`
+    /// assert!(!s.is_char_boundary(2));
+    ///
+    /// // third byte of `老`
+    /// assert!(!s.is_char_boundary(8));
+    /// ```
+    #[unstable(feature = "collections",
+               reason = "naming is uncertain with container conventions")]
+    pub fn is_char_boundary(&self, index: usize) -> bool {
+        core_str::StrExt::is_char_boundary(&self[..], index)
     }
 
-    #[bench]
-    fn char_indicesator_rev(b: &mut Bencher) {
-        let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
-        let len = s.chars().count();
+    /// Given a byte position, return the next char and its index.
+    ///
+    /// This can be used to iterate over the Unicode characters of a string.
+    ///
+    /// # Panics
+    ///
+    /// If `i` is greater than or equal to the length of the string.
+    /// If `i` is not the index of the beginning of a valid UTF-8 character.
+    ///
+    /// # Examples
+    ///
+    /// This example manually iterates through the characters of a string; this should normally be
+    /// done by `.chars()` or `.char_indices()`.
+    ///
+    /// ```
+    /// use std::str::CharRange;
+    ///
+    /// let s = "中华Việt Nam";
+    /// let mut i = 0;
+    /// while i < s.len() {
+    ///     let CharRange {ch, next} = s.char_range_at(i);
+    ///     println!("{}: {}", i, ch);
+    ///     i = next;
+    /// }
+    /// ```
+    ///
+    /// This outputs:
+    ///
+    /// ```text
+    /// 0: 中
+    /// 3: 华
+    /// 6: V
+    /// 7: i
+    /// 8: ệ
+    /// 11: t
+    /// 12:
+    /// 13: N
+    /// 14: a
+    /// 15: m
+    /// ```
+    #[unstable(feature = "collections",
+               reason = "naming is uncertain with container conventions")]
+    pub fn char_range_at(&self, start: usize) -> CharRange {
+        core_str::StrExt::char_range_at(&self[..], start)
+    }
 
-        b.iter(|| assert_eq!(s.char_indices().rev().count(), len));
+    /// Given a byte position, return the previous `char` and its position.
+    ///
+    /// This function can be used to iterate over a Unicode string in reverse.
+    ///
+    /// Returns 0 for next index if called on start index 0.
+    ///
+    /// # Panics
+    ///
+    /// If `i` is greater than the length of the string.
+    /// If `i` is not an index following a valid UTF-8 character.
+    ///
+    /// # Examples
+    ///
+    /// This example manually iterates through the characters of a string; this should normally be
+    /// done by `.chars().rev()` or `.char_indices()`.
+    ///
+    /// ```
+    /// use std::str::CharRange;
+    ///
+    /// let s = "中华Việt Nam";
+    /// let mut i = s.len();
+    /// while i > 0 {
+    ///     let CharRange {ch, next} = s.char_range_at_reverse(i);
+    ///     println!("{}: {}", i, ch);
+    ///     i = next;
+    /// }
+    /// ```
+    ///
+    /// This outputs:
+    ///
+    /// ```text
+    /// 16: m
+    /// 15: a
+    /// 14: N
+    /// 13:
+    /// 12: t
+    /// 11: ệ
+    /// 8: i
+    /// 7: V
+    /// 6: 华
+    /// 3: 中
+    /// ```
+    #[unstable(feature = "collections",
+               reason = "naming is uncertain with container conventions")]
+    pub fn char_range_at_reverse(&self, start: usize) -> CharRange {
+        core_str::StrExt::char_range_at_reverse(&self[..], start)
     }
 
-    #[bench]
-    fn split_unicode_ascii(b: &mut Bencher) {
-        let s = "ประเทศไทย中华Việt Namประเทศไทย中华Việt Nam";
+    /// Given a byte position, return the `char` at that position.
+    ///
+    /// # Panics
+    ///
+    /// If `i` is greater than or equal to the length of the string.
+    /// If `i` is not the index of the beginning of a valid UTF-8 character.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let s = "abπc";
+    /// assert_eq!(s.char_at(1), 'b');
+    /// assert_eq!(s.char_at(2), 'π');
+    /// ```
+    #[unstable(feature = "collections",
+               reason = "naming is uncertain with container conventions")]
+    pub fn char_at(&self, i: usize) -> char {
+        core_str::StrExt::char_at(&self[..], i)
+    }
 
-        b.iter(|| assert_eq!(s.split('V').count(), 3));
+    /// Given a byte position, return the `char` at that position, counting from the end.
+    ///
+    /// # Panics
+    ///
+    /// If `i` is greater than the length of the string.
+    /// If `i` is not an index following a valid UTF-8 character.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let s = "abπc";
+    /// assert_eq!(s.char_at_reverse(1), 'a');
+    /// assert_eq!(s.char_at_reverse(2), 'b');
+    /// ```
+    #[unstable(feature = "collections",
+               reason = "naming is uncertain with container conventions")]
+    pub fn char_at_reverse(&self, i: usize) -> char {
+        core_str::StrExt::char_at_reverse(&self[..], i)
     }
 
-    #[bench]
-    fn split_ascii(b: &mut Bencher) {
-        let s = "Mary had a little lamb, Little lamb, little-lamb.";
-        let len = s.split(' ').count();
+    /// Convert `self` to a byte slice.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// assert_eq!("bors".as_bytes(), b"bors");
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn as_bytes(&self) -> &[u8] {
+        core_str::StrExt::as_bytes(&self[..])
+    }
 
-        b.iter(|| assert_eq!(s.split(' ').count(), len));
+    /// Returns the byte index of the first character of `self` that matches the pattern, if it
+    /// exists.
+    ///
+    /// Returns `None` if it doesn't exist.
+    ///
+    /// The pattern can be a simple `&str`, or a closure that determines the split.
+    ///
+    /// # Examples
+    ///
+    /// Simple `&str` patterns:
+    ///
+    /// ```
+    /// let s = "Löwe 老虎 Léopard";
+    ///
+    /// assert_eq!(s.find('L'), Some(0));
+    /// assert_eq!(s.find('é'), Some(14));
+    ///
+    /// ```
+    ///
+    /// More complex patterns with a lambda:
+    ///
+    /// ```
+    /// let s = "Löwe 老虎 Léopard";
+    ///
+    /// assert_eq!(s.find(|c: char| c.is_whitespace()), Some(5));
+    /// ```
+    ///
+    /// Not finding the pattern:
+    ///
+    /// ```
+    /// let s = "Löwe 老虎 Léopard";
+    /// let x: &[_] = &['1', '2'];
+    ///
+    /// assert_eq!(s.find(x), None);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn find<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize> {
+        core_str::StrExt::find(&self[..], pat)
     }
 
-    #[bench]
-    fn split_extern_fn(b: &mut Bencher) {
-        let s = "Mary had a little lamb, Little lamb, little-lamb.";
-        let len = s.split(' ').count();
-        fn pred(c: char) -> bool { c == ' ' }
+    /// Returns the byte index of the last character of `self` that matches the pattern, if it
+    /// exists.
+    ///
+    /// Returns `None` if it doesn't exist.
+    ///
+    /// The pattern can be a simple `&str`, or a closure that determines the split.
+    ///
+    /// # Examples
+    ///
+    /// Simple `&str` patterns:
+    ///
+    /// ```
+    /// let s = "Löwe 老虎 Léopard";
+    ///
+    /// assert_eq!(s.rfind('L'), Some(13));
+    /// assert_eq!(s.rfind('é'), Some(14));
+    /// ```
+    ///
+    /// More complex patterns with a lambda:
+    ///
+    /// ```
+    /// let s = "Löwe 老虎 Léopard";
+    ///
+    /// assert_eq!(s.rfind(|c: char| c.is_whitespace()), Some(12));
+    /// ```
+    ///
+    /// Not finding the pattern:
+    ///
+    /// ```
+    /// let s = "Löwe 老虎 Léopard";
+    /// let x: &[_] = &['1', '2'];
+    ///
+    /// assert_eq!(s.rfind(x), None);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn rfind<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize>
+        where P::Searcher: ReverseSearcher<'a>
+    {
+        core_str::StrExt::rfind(&self[..], pat)
+    }
 
-        b.iter(|| assert_eq!(s.split(pred).count(), len));
+    /// Returns the byte index of the first matching substring if it exists.
+    ///
+    /// Returns `None` if it doesn't exist.
+    ///
+    /// The pattern can be a simple `&str`, or a closure that determines the split.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let s = "Löwe 老虎 Léopard";
+    ///
+    /// assert_eq!(s.find_str("老虎 L"), Some(6));
+    /// assert_eq!(s.find_str("muffin man"), None);
+    /// ```
+    #[unstable(feature = "collections")]
+    #[deprecated(since = "1.0.0", reason = "use `find()` with a `&str`")]
+    pub fn find_str<'a, P: Pattern<'a>>(&'a self, needle: P) -> Option<usize> {
+        core_str::StrExt::find_str(&self[..], needle)
     }
 
-    #[bench]
-    fn split_closure(b: &mut Bencher) {
-        let s = "Mary had a little lamb, Little lamb, little-lamb.";
-        let len = s.split(' ').count();
+    /// Retrieves the first character from a `&str` and returns it.
+    ///
+    /// This does not allocate a new string; instead, it returns a slice that points one character
+    /// beyond the character that was shifted.
+    ///
+    /// If the slice does not contain any characters, None is returned instead.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let s = "Löwe 老虎 Léopard";
+    /// let (c, s1) = s.slice_shift_char().unwrap();
+    ///
+    /// assert_eq!(c, 'L');
+    /// assert_eq!(s1, "öwe 老虎 Léopard");
+    ///
+    /// let (c, s2) = s1.slice_shift_char().unwrap();
+    ///
+    /// assert_eq!(c, 'ö');
+    /// assert_eq!(s2, "we 老虎 Léopard");
+    /// ```
+    #[unstable(feature = "collections",
+               reason = "awaiting conventions about shifting and slices")]
+    pub fn slice_shift_char(&self) -> Option<(char, &str)> {
+        core_str::StrExt::slice_shift_char(&self[..])
+    }
 
-        b.iter(|| assert_eq!(s.split(|c: char| c == ' ').count(), len));
+    /// Returns the byte offset of an inner slice relative to an enclosing outer slice.
+    ///
+    /// # Panics
+    ///
+    /// Panics if `inner` is not a direct slice contained within self.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let string = "a\nb\nc";
+    /// let lines: Vec<&str> = string.lines().collect();
+    ///
+    /// assert!(string.subslice_offset(lines[0]) == 0); // &"a"
+    /// assert!(string.subslice_offset(lines[1]) == 2); // &"b"
+    /// assert!(string.subslice_offset(lines[2]) == 4); // &"c"
+    /// ```
+    #[unstable(feature = "collections",
+               reason = "awaiting convention about comparability of arbitrary slices")]
+    pub fn subslice_offset(&self, inner: &str) -> usize {
+        core_str::StrExt::subslice_offset(&self[..], inner)
     }
 
-    #[bench]
-    fn split_slice(b: &mut Bencher) {
-        let s = "Mary had a little lamb, Little lamb, little-lamb.";
-        let len = s.split(' ').count();
+    /// Return an unsafe pointer to the `&str`'s buffer.
+    ///
+    /// The caller must ensure that the string outlives this pointer, and that it is not
+    /// reallocated (e.g. by pushing to the string).
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let s = "Hello";
+    /// let p = s.as_ptr();
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn as_ptr(&self) -> *const u8 {
+        core_str::StrExt::as_ptr(&self[..])
+    }
 
-        let c: &[char] = &[' '];
-        b.iter(|| assert_eq!(s.split(c).count(), len));
+    /// Return an iterator of `u16` over the string encoded as UTF-16.
+    #[unstable(feature = "collections",
+               reason = "this functionality may only be provided by libunicode")]
+    pub fn utf16_units(&self) -> Utf16Units {
+        Utf16Units { encoder: Utf16Encoder::new(self[..].chars()) }
     }
 
-    #[bench]
-    fn bench_connect(b: &mut Bencher) {
-        let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
-        let sep = "→";
-        let v = vec![s, s, s, s, s, s, s, s, s, s];
-        b.iter(|| {
-            assert_eq!(v.connect(sep).len(), s.len() * 10 + sep.len() * 9);
-        })
+    /// Returns the length of `self` in bytes.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// assert_eq!("foo".len(), 3);
+    /// assert_eq!("ƒoo".len(), 4); // fancy f!
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn len(&self) -> usize {
+        core_str::StrExt::len(&self[..])
     }
 
-    #[bench]
-    fn bench_contains_short_short(b: &mut Bencher) {
-        let haystack = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
-        let needle = "sit";
+    /// Returns true if this slice has a length of zero bytes.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// assert!("".is_empty());
+    /// ```
+    #[inline]
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn is_empty(&self) -> bool {
+        core_str::StrExt::is_empty(&self[..])
+    }
 
-        b.iter(|| {
-            assert!(haystack.contains(needle));
-        })
+    /// Parses `self` into the specified type.
+    ///
+    /// # Failure
+    ///
+    /// Will return `Err` if it's not possible to parse `self` into the type.
+    ///
+    /// # Example
+    ///
+    /// ```
+    /// assert_eq!("4".parse::<u32>(), Ok(4));
+    /// ```
+    ///
+    /// Failing:
+    ///
+    /// ```
+    /// assert!("j".parse::<u32>().is_err());
+    /// ```
+    #[inline]
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn parse<F: FromStr>(&self) -> Result<F, F::Err> {
+        core_str::StrExt::parse(&self[..])
     }
 
-    #[bench]
-    fn bench_contains_short_long(b: &mut Bencher) {
-        let haystack = "\
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse quis lorem sit amet dolor \
-ultricies condimentum. Praesent iaculis purus elit, ac malesuada quam malesuada in. Duis sed orci \
-eros. Suspendisse sit amet magna mollis, mollis nunc luctus, imperdiet mi. Integer fringilla non \
-sem ut lacinia. Fusce varius tortor a risus porttitor hendrerit. Morbi mauris dui, ultricies nec \
-tempus vel, gravida nec quam.
+    /// Returns an iterator over the [grapheme clusters][graphemes] of `self`.
+    ///
+    /// [graphemes]: http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries
+    ///
+    /// If `is_extended` is true, the iterator is over the *extended grapheme clusters*;
+    /// otherwise, the iterator is over the *legacy grapheme clusters*.
+    /// [UAX#29](http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries)
+    /// recommends extended grapheme cluster boundaries for general processing.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let gr1 = "a\u{310}e\u{301}o\u{308}\u{332}".graphemes(true).collect::<Vec<&str>>();
+    /// let b: &[_] = &["a\u{310}", "e\u{301}", "o\u{308}\u{332}"];
+    ///
+    /// assert_eq!(gr1.as_slice(), b);
+    ///
+    /// let gr2 = "a\r\nb🇷🇺🇸🇹".graphemes(true).collect::<Vec<&str>>();
+    /// let b: &[_] = &["a", "\r\n", "b", "🇷🇺🇸🇹"];
+    ///
+    /// assert_eq!(gr2.as_slice(), b);
+    /// ```
+    #[unstable(feature = "collections",
+               reason = "this functionality may only be provided by libunicode")]
+    pub fn graphemes(&self, is_extended: bool) -> Graphemes {
+        UnicodeStr::graphemes(&self[..], is_extended)
+    }
 
-In est dui, tincidunt sed tempus interdum, adipiscing laoreet ante. Etiam tempor, tellus quis \
-sagittis interdum, nulla purus mattis sem, quis auctor erat odio ac tellus. In nec nunc sit amet \
-diam volutpat molestie at sed ipsum. Vestibulum laoreet consequat vulputate. Integer accumsan \
-lorem ac dignissim placerat. Suspendisse convallis faucibus lorem. Aliquam erat volutpat. In vel \
-eleifend felis. Sed suscipit nulla lorem, sed mollis est sollicitudin et. Nam fermentum egestas \
-interdum. Curabitur ut nisi justo.
+    /// Returns an iterator over the grapheme clusters of `self` and their byte offsets. See
+    /// `graphemes()` for more information.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let gr_inds = "a̐éö̲\r\n".grapheme_indices(true).collect::<Vec<(usize, &str)>>();
+    /// let b: &[_] = &[(0, "a̐"), (3, "é"), (6, "ö̲"), (11, "\r\n")];
+    ///
+    /// assert_eq!(gr_inds.as_slice(), b);
+    /// ```
+    #[unstable(feature = "collections",
+               reason = "this functionality may only be provided by libunicode")]
+    pub fn grapheme_indices(&self, is_extended: bool) -> GraphemeIndices {
+        UnicodeStr::grapheme_indices(&self[..], is_extended)
+    }
 
-Sed sollicitudin ipsum tellus, ut condimentum leo eleifend nec. Cras ut velit ante. Phasellus nec \
-mollis odio. Mauris molestie erat in arcu mattis, at aliquet dolor vehicula. Quisque malesuada \
-lectus sit amet nisi pretium, a condimentum ipsum porta. Morbi at dapibus diam. Praesent egestas \
-est sed risus elementum, eu rutrum metus ultrices. Etiam fermentum consectetur magna, id rutrum \
-felis accumsan a. Aliquam ut pellentesque libero. Sed mi nulla, lobortis eu tortor id, suscipit \
-ultricies neque. Morbi iaculis sit amet risus at iaculis. Praesent eget ligula quis turpis \
-feugiat suscipit vel non arcu. Interdum et malesuada fames ac ante ipsum primis in faucibus. \
-Aliquam sit amet placerat lorem.
+    /// An iterator over the non-empty words of `self`.
+    ///
+    /// A 'word' is a subsequence separated by any sequence of whitespace. Sequences of whitespace
+    /// are collapsed, so empty "words" are not included.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let some_words = " Mary   had\ta little  \n\t lamb";
+    /// let v: Vec<&str> = some_words.words().collect();
+    ///
+    /// assert_eq!(v, ["Mary", "had", "a", "little", "lamb"]);
+    /// ```
+    #[unstable(feature = "str_words",
+               reason = "the precise algorithm to use is unclear")]
+    pub fn words(&self) -> Words {
+        UnicodeStr::words(&self[..])
+    }
 
-Cras a lacus vel ante posuere elementum. Nunc est leo, bibendum ut facilisis vel, bibendum at \
-mauris. Nullam adipiscing diam vel odio ornare, luctus adipiscing mi luctus. Nulla facilisi. \
-Mauris adipiscing bibendum neque, quis adipiscing lectus tempus et. Sed feugiat erat et nisl \
-lobortis pharetra. Donec vitae erat enim. Nullam sit amet felis et quam lacinia tincidunt. Aliquam \
-suscipit dapibus urna. Sed volutpat urna in magna pulvinar volutpat. Phasellus nec tellus ac diam \
-cursus accumsan.
+    /// Returns a string's displayed width in columns.
+    ///
+    /// Control characters have zero width.
+    ///
+    /// `is_cjk` determines behavior for characters in the Ambiguous category: if `is_cjk` is
+    /// `true`, these are 2 columns wide; otherwise, they are 1. In CJK locales, `is_cjk` should be
+    /// `true`, else it should be `false`.
+    /// [Unicode Standard Annex #11](http://www.unicode.org/reports/tr11/) recommends that these
+    /// characters be treated as 1 column (i.e., `is_cjk = false`) if the locale is unknown.
+    #[unstable(feature = "collections",
+               reason = "this functionality may only be provided by libunicode")]
+    pub fn width(&self, is_cjk: bool) -> usize {
+        UnicodeStr::width(&self[..], is_cjk)
+    }
 
-Nam lectus enim, dapibus non nisi tempor, consectetur convallis massa. Maecenas eleifend dictum \
-feugiat. Etiam quis mauris vel risus luctus mattis a a nunc. Nullam orci quam, imperdiet id \
-vehicula in, porttitor ut nibh. Duis sagittis adipiscing nisl vitae congue. Donec mollis risus eu \
-leo suscipit, varius porttitor nulla porta. Pellentesque ut sem nec nisi euismod vehicula. Nulla \
-malesuada sollicitudin quam eu fermentum.";
-        let needle = "english";
+    /// Returns a `&str` with leading and trailing whitespace removed.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let s = " Hello\tworld\t";
+    /// assert_eq!(s.trim(), "Hello\tworld");
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn trim(&self) -> &str {
+        UnicodeStr::trim(&self[..])
+    }
 
-        b.iter(|| {
-            assert!(!haystack.contains(needle));
-        })
+    /// Returns a `&str` with leading whitespace removed.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let s = " Hello\tworld\t";
+    /// assert_eq!(s.trim_left(), "Hello\tworld\t");
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn trim_left(&self) -> &str {
+        UnicodeStr::trim_left(&self[..])
     }
 
-    #[bench]
-    fn bench_contains_bad_naive(b: &mut Bencher) {
-        let haystack = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
-        let needle = "aaaaaaaab";
+    /// Returns a `&str` with trailing whitespace removed.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let s = " Hello\tworld\t";
+    /// assert_eq!(s.trim_right(), " Hello\tworld");
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn trim_right(&self) -> &str {
+        UnicodeStr::trim_right(&self[..])
+    }
 
-        b.iter(|| {
-            assert!(!haystack.contains(needle));
-        })
+    /// Returns the lowercase equivalent of this string.
+    ///
+    /// # Examples
+    ///
+    /// let s = "HELLO";
+    /// assert_eq!(s.to_lowercase(), "hello");
+    #[unstable(feature = "collections")]
+    pub fn to_lowercase(&self) -> String {
+        let mut s = String::with_capacity(self.len());
+        s.extend(self[..].chars().flat_map(|c| c.to_lowercase()));
+        return s;
     }
-
-    #[bench]
-    fn bench_contains_equal(b: &mut Bencher) {
-        let haystack = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
-        let needle = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
-
-        b.iter(|| {
-            assert!(haystack.contains(needle));
-        })
+
+    /// Returns the uppercase equivalent of this string.
+    ///
+    /// # Examples
+    ///
+    /// let s = "hello";
+    /// assert_eq!(s.to_uppercase(), "HELLO");
+    #[unstable(feature = "collections")]
+    pub fn to_uppercase(&self) -> String {
+        let mut s = String::with_capacity(self.len());
+        s.extend(self[..].chars().flat_map(|c| c.to_uppercase()));
+        return s;
     }
 }
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs
index e7f76698b40..d2bc98096f6 100644
--- a/src/libcollections/string.rs
+++ b/src/libcollections/string.rs
@@ -85,6 +85,7 @@ impl String {
         }
     }
 
+    #[cfg(stage0)]
     /// Creates a new string buffer from the given string.
     ///
     /// # Examples
@@ -100,6 +101,33 @@ impl String {
         String { vec: ::slice::SliceExt::to_vec(string.as_bytes()) }
     }
 
+    #[cfg(not(stage0))]
+    /// Creates a new string buffer from the given string.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let s = String::from_str("hello");
+    /// assert_eq!(s.as_slice(), "hello");
+    /// ```
+    #[inline]
+    #[unstable(feature = "collections",
+               reason = "needs investigation to see if to_string() can match perf")]
+    #[cfg(not(test))]
+    pub fn from_str(string: &str) -> String {
+        String { vec: <[_]>::to_vec(string.as_bytes()) }
+    }
+
+    // HACK(japaric): with cfg(test) the inherent `[T]::to_vec` method, which is required for this
+    // method definition, is not available. Since we don't require this method for testing
+    // purposes, I'll just stub it
+    // NB see the slice::hack module in slice.rs for more information
+    #[inline]
+    #[cfg(test)]
+    pub fn from_str(_: &str) -> String {
+        panic!("not available with cfg(test)");
+    }
+
     /// Returns the vector as a string buffer, if possible, taking care not to
     /// copy it.
     ///
@@ -110,7 +138,7 @@ impl String {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::str::Utf8Error;
     ///
     /// let hello_vec = vec![104, 101, 108, 108, 111];
@@ -136,7 +164,7 @@ impl String {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// let input = b"Hello \xF0\x90\x80World";
     /// let output = String::from_utf8_lossy(input);
     /// assert_eq!(output, "Hello \u{FFFD}World");
@@ -268,7 +296,7 @@ impl String {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// // 𝄞music
     /// let mut v = &mut [0xD834, 0xDD1E, 0x006d, 0x0075,
     ///                   0x0073, 0x0069, 0x0063];
@@ -296,7 +324,7 @@ impl String {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// // 𝄞mus<invalid>ic<invalid>
     /// let v = &[0xD834, 0xDD1E, 0x006d, 0x0075,
     ///           0x0073, 0xDD1E, 0x0069, 0x0063,
@@ -997,450 +1025,3 @@ impl fmt::Write for String {
         Ok(())
     }
 }
-
-#[cfg(test)]
-mod tests {
-    use prelude::*;
-    use test::Bencher;
-
-    use str::Utf8Error;
-    use core::iter::repeat;
-    use super::{as_string, CowString};
-
-    #[test]
-    fn test_as_string() {
-        let x = "foo";
-        assert_eq!(x, &**as_string(x));
-    }
-
-    #[test]
-    fn test_from_str() {
-      let owned: Option<::std::string::String> = "string".parse().ok();
-      assert_eq!(owned.as_ref().map(|s| &**s), Some("string"));
-    }
-
-    #[test]
-    fn test_unsized_to_string() {
-        let s: &str = "abc";
-        let _: String = (*s).to_string();
-    }
-
-    #[test]
-    fn test_from_utf8() {
-        let xs = b"hello".to_vec();
-        assert_eq!(String::from_utf8(xs).unwrap(),
-                   String::from_str("hello"));
-
-        let xs = "ศไทย中华Việt Nam".as_bytes().to_vec();
-        assert_eq!(String::from_utf8(xs).unwrap(),
-                   String::from_str("ศไทย中华Việt Nam"));
-
-        let xs = b"hello\xFF".to_vec();
-        let err = String::from_utf8(xs).err().unwrap();
-        assert_eq!(err.utf8_error(), Utf8Error::TooShort);
-        assert_eq!(err.into_bytes(), b"hello\xff".to_vec());
-    }
-
-    #[test]
-    fn test_from_utf8_lossy() {
-        let xs = b"hello";
-        let ys: CowString = "hello".into_cow();
-        assert_eq!(String::from_utf8_lossy(xs), ys);
-
-        let xs = "ศไทย中华Việt Nam".as_bytes();
-        let ys: CowString = "ศไทย中华Việt Nam".into_cow();
-        assert_eq!(String::from_utf8_lossy(xs), ys);
-
-        let xs = b"Hello\xC2 There\xFF Goodbye";
-        assert_eq!(String::from_utf8_lossy(xs),
-                   String::from_str("Hello\u{FFFD} There\u{FFFD} Goodbye").into_cow());
-
-        let xs = b"Hello\xC0\x80 There\xE6\x83 Goodbye";
-        assert_eq!(String::from_utf8_lossy(xs),
-                   String::from_str("Hello\u{FFFD}\u{FFFD} There\u{FFFD} Goodbye").into_cow());
-
-        let xs = b"\xF5foo\xF5\x80bar";
-        assert_eq!(String::from_utf8_lossy(xs),
-                   String::from_str("\u{FFFD}foo\u{FFFD}\u{FFFD}bar").into_cow());
-
-        let xs = b"\xF1foo\xF1\x80bar\xF1\x80\x80baz";
-        assert_eq!(String::from_utf8_lossy(xs),
-                   String::from_str("\u{FFFD}foo\u{FFFD}bar\u{FFFD}baz").into_cow());
-
-        let xs = b"\xF4foo\xF4\x80bar\xF4\xBFbaz";
-        assert_eq!(String::from_utf8_lossy(xs),
-                   String::from_str("\u{FFFD}foo\u{FFFD}bar\u{FFFD}\u{FFFD}baz").into_cow());
-
-        let xs = b"\xF0\x80\x80\x80foo\xF0\x90\x80\x80bar";
-        assert_eq!(String::from_utf8_lossy(xs), String::from_str("\u{FFFD}\u{FFFD}\u{FFFD}\u{FFFD}\
-                                               foo\u{10000}bar").into_cow());
-
-        // surrogates
-        let xs = b"\xED\xA0\x80foo\xED\xBF\xBFbar";
-        assert_eq!(String::from_utf8_lossy(xs), String::from_str("\u{FFFD}\u{FFFD}\u{FFFD}foo\
-                                               \u{FFFD}\u{FFFD}\u{FFFD}bar").into_cow());
-    }
-
-    #[test]
-    fn test_from_utf16() {
-        let pairs =
-            [(String::from_str("𐍅𐌿𐌻𐍆𐌹𐌻𐌰\n"),
-              vec![0xd800, 0xdf45, 0xd800, 0xdf3f,
-                0xd800, 0xdf3b, 0xd800, 0xdf46,
-                0xd800, 0xdf39, 0xd800, 0xdf3b,
-                0xd800, 0xdf30, 0x000a]),
-
-             (String::from_str("𐐒𐑉𐐮𐑀𐐲𐑋 𐐏𐐲𐑍\n"),
-              vec![0xd801, 0xdc12, 0xd801,
-                0xdc49, 0xd801, 0xdc2e, 0xd801,
-                0xdc40, 0xd801, 0xdc32, 0xd801,
-                0xdc4b, 0x0020, 0xd801, 0xdc0f,
-                0xd801, 0xdc32, 0xd801, 0xdc4d,
-                0x000a]),
-
-             (String::from_str("𐌀𐌖𐌋𐌄𐌑𐌉·𐌌𐌄𐌕𐌄𐌋𐌉𐌑\n"),
-              vec![0xd800, 0xdf00, 0xd800, 0xdf16,
-                0xd800, 0xdf0b, 0xd800, 0xdf04,
-                0xd800, 0xdf11, 0xd800, 0xdf09,
-                0x00b7, 0xd800, 0xdf0c, 0xd800,
-                0xdf04, 0xd800, 0xdf15, 0xd800,
-                0xdf04, 0xd800, 0xdf0b, 0xd800,
-                0xdf09, 0xd800, 0xdf11, 0x000a ]),
-
-             (String::from_str("𐒋𐒘𐒈𐒑𐒛𐒒 𐒕𐒓 𐒈𐒚𐒍 𐒏𐒜𐒒𐒖𐒆 𐒕𐒆\n"),
-              vec![0xd801, 0xdc8b, 0xd801, 0xdc98,
-                0xd801, 0xdc88, 0xd801, 0xdc91,
-                0xd801, 0xdc9b, 0xd801, 0xdc92,
-                0x0020, 0xd801, 0xdc95, 0xd801,
-                0xdc93, 0x0020, 0xd801, 0xdc88,
-                0xd801, 0xdc9a, 0xd801, 0xdc8d,
-                0x0020, 0xd801, 0xdc8f, 0xd801,
-                0xdc9c, 0xd801, 0xdc92, 0xd801,
-                0xdc96, 0xd801, 0xdc86, 0x0020,
-                0xd801, 0xdc95, 0xd801, 0xdc86,
-                0x000a ]),
-             // Issue #12318, even-numbered non-BMP planes
-             (String::from_str("\u{20000}"),
-              vec![0xD840, 0xDC00])];
-
-        for p in &pairs {
-            let (s, u) = (*p).clone();
-            let s_as_utf16 = s.utf16_units().collect::<Vec<u16>>();
-            let u_as_string = String::from_utf16(&u).unwrap();
-
-            assert!(::unicode::str::is_utf16(&u));
-            assert_eq!(s_as_utf16, u);
-
-            assert_eq!(u_as_string, s);
-            assert_eq!(String::from_utf16_lossy(&u), s);
-
-            assert_eq!(String::from_utf16(&s_as_utf16).unwrap(), s);
-            assert_eq!(u_as_string.utf16_units().collect::<Vec<u16>>(), u);
-        }
-    }
-
-    #[test]
-    fn test_utf16_invalid() {
-        // completely positive cases tested above.
-        // lead + eof
-        assert!(String::from_utf16(&[0xD800]).is_err());
-        // lead + lead
-        assert!(String::from_utf16(&[0xD800, 0xD800]).is_err());
-
-        // isolated trail
-        assert!(String::from_utf16(&[0x0061, 0xDC00]).is_err());
-
-        // general
-        assert!(String::from_utf16(&[0xD800, 0xd801, 0xdc8b, 0xD800]).is_err());
-    }
-
-    #[test]
-    fn test_from_utf16_lossy() {
-        // completely positive cases tested above.
-        // lead + eof
-        assert_eq!(String::from_utf16_lossy(&[0xD800]), String::from_str("\u{FFFD}"));
-        // lead + lead
-        assert_eq!(String::from_utf16_lossy(&[0xD800, 0xD800]),
-                   String::from_str("\u{FFFD}\u{FFFD}"));
-
-        // isolated trail
-        assert_eq!(String::from_utf16_lossy(&[0x0061, 0xDC00]), String::from_str("a\u{FFFD}"));
-
-        // general
-        assert_eq!(String::from_utf16_lossy(&[0xD800, 0xd801, 0xdc8b, 0xD800]),
-                   String::from_str("\u{FFFD}𐒋\u{FFFD}"));
-    }
-
-    #[test]
-    fn test_push_bytes() {
-        let mut s = String::from_str("ABC");
-        unsafe {
-            let mv = s.as_mut_vec();
-            mv.push_all(&[b'D']);
-        }
-        assert_eq!(s, "ABCD");
-    }
-
-    #[test]
-    fn test_push_str() {
-        let mut s = String::new();
-        s.push_str("");
-        assert_eq!(&s[0..], "");
-        s.push_str("abc");
-        assert_eq!(&s[0..], "abc");
-        s.push_str("ประเทศไทย中华Việt Nam");
-        assert_eq!(&s[0..], "abcประเทศไทย中华Việt Nam");
-    }
-
-    #[test]
-    fn test_push() {
-        let mut data = String::from_str("ประเทศไทย中");
-        data.push('华');
-        data.push('b'); // 1 byte
-        data.push('¢'); // 2 byte
-        data.push('€'); // 3 byte
-        data.push('𤭢'); // 4 byte
-        assert_eq!(data, "ประเทศไทย中华b¢€𤭢");
-    }
-
-    #[test]
-    fn test_pop() {
-        let mut data = String::from_str("ประเทศไทย中华b¢€𤭢");
-        assert_eq!(data.pop().unwrap(), '𤭢'); // 4 bytes
-        assert_eq!(data.pop().unwrap(), '€'); // 3 bytes
-        assert_eq!(data.pop().unwrap(), '¢'); // 2 bytes
-        assert_eq!(data.pop().unwrap(), 'b'); // 1 bytes
-        assert_eq!(data.pop().unwrap(), '华');
-        assert_eq!(data, "ประเทศไทย中");
-    }
-
-    #[test]
-    fn test_str_truncate() {
-        let mut s = String::from_str("12345");
-        s.truncate(5);
-        assert_eq!(s, "12345");
-        s.truncate(3);
-        assert_eq!(s, "123");
-        s.truncate(0);
-        assert_eq!(s, "");
-
-        let mut s = String::from_str("12345");
-        let p = s.as_ptr();
-        s.truncate(3);
-        s.push_str("6");
-        let p_ = s.as_ptr();
-        assert_eq!(p_, p);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_str_truncate_invalid_len() {
-        let mut s = String::from_str("12345");
-        s.truncate(6);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_str_truncate_split_codepoint() {
-        let mut s = String::from_str("\u{FC}"); // ü
-        s.truncate(1);
-    }
-
-    #[test]
-    fn test_str_clear() {
-        let mut s = String::from_str("12345");
-        s.clear();
-        assert_eq!(s.len(), 0);
-        assert_eq!(s, "");
-    }
-
-    #[test]
-    fn test_str_add() {
-        let a = String::from_str("12345");
-        let b = a + "2";
-        let b = b + "2";
-        assert_eq!(b.len(), 7);
-        assert_eq!(b, "1234522");
-    }
-
-    #[test]
-    fn remove() {
-        let mut s = "ศไทย中华Việt Nam; foobar".to_string();;
-        assert_eq!(s.remove(0), 'ศ');
-        assert_eq!(s.len(), 33);
-        assert_eq!(s, "ไทย中华Việt Nam; foobar");
-        assert_eq!(s.remove(17), 'ệ');
-        assert_eq!(s, "ไทย中华Vit Nam; foobar");
-    }
-
-    #[test] #[should_panic]
-    fn remove_bad() {
-        "ศ".to_string().remove(1);
-    }
-
-    #[test]
-    fn insert() {
-        let mut s = "foobar".to_string();
-        s.insert(0, 'ệ');
-        assert_eq!(s, "ệfoobar");
-        s.insert(6, 'ย');
-        assert_eq!(s, "ệfooยbar");
-    }
-
-    #[test] #[should_panic] fn insert_bad1() { "".to_string().insert(1, 't'); }
-    #[test] #[should_panic] fn insert_bad2() { "ệ".to_string().insert(1, 't'); }
-
-    #[test]
-    fn test_slicing() {
-        let s = "foobar".to_string();
-        assert_eq!("foobar", &s[..]);
-        assert_eq!("foo", &s[..3]);
-        assert_eq!("bar", &s[3..]);
-        assert_eq!("oob", &s[1..4]);
-    }
-
-    #[test]
-    fn test_simple_types() {
-        assert_eq!(1.to_string(), "1");
-        assert_eq!((-1).to_string(), "-1");
-        assert_eq!(200.to_string(), "200");
-        assert_eq!(2.to_string(), "2");
-        assert_eq!(true.to_string(), "true");
-        assert_eq!(false.to_string(), "false");
-        assert_eq!(("hi".to_string()).to_string(), "hi");
-    }
-
-    #[test]
-    fn test_vectors() {
-        let x: Vec<i32> = vec![];
-        assert_eq!(format!("{:?}", x), "[]");
-        assert_eq!(format!("{:?}", vec![1]), "[1]");
-        assert_eq!(format!("{:?}", vec![1, 2, 3]), "[1, 2, 3]");
-        assert!(format!("{:?}", vec![vec![], vec![1], vec![1, 1]]) ==
-               "[[], [1], [1, 1]]");
-    }
-
-    #[test]
-    fn test_from_iterator() {
-        let s = "ศไทย中华Việt Nam".to_string();
-        let t = "ศไทย中华";
-        let u = "Việt Nam";
-
-        let a: String = s.chars().collect();
-        assert_eq!(s, a);
-
-        let mut b = t.to_string();
-        b.extend(u.chars());
-        assert_eq!(s, b);
-
-        let c: String = vec![t, u].into_iter().collect();
-        assert_eq!(s, c);
-
-        let mut d = t.to_string();
-        d.extend(vec![u].into_iter());
-        assert_eq!(s, d);
-    }
-
-    #[bench]
-    fn bench_with_capacity(b: &mut Bencher) {
-        b.iter(|| {
-            String::with_capacity(100)
-        });
-    }
-
-    #[bench]
-    fn bench_push_str(b: &mut Bencher) {
-        let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
-        b.iter(|| {
-            let mut r = String::new();
-            r.push_str(s);
-        });
-    }
-
-    const REPETITIONS: u64 = 10_000;
-
-    #[bench]
-    fn bench_push_str_one_byte(b: &mut Bencher) {
-        b.bytes = REPETITIONS;
-        b.iter(|| {
-            let mut r = String::new();
-            for _ in 0..REPETITIONS {
-                r.push_str("a")
-            }
-        });
-    }
-
-    #[bench]
-    fn bench_push_char_one_byte(b: &mut Bencher) {
-        b.bytes = REPETITIONS;
-        b.iter(|| {
-            let mut r = String::new();
-            for _ in 0..REPETITIONS {
-                r.push('a')
-            }
-        });
-    }
-
-    #[bench]
-    fn bench_push_char_two_bytes(b: &mut Bencher) {
-        b.bytes = REPETITIONS * 2;
-        b.iter(|| {
-            let mut r = String::new();
-            for _ in 0..REPETITIONS {
-                r.push('â')
-            }
-        });
-    }
-
-    #[bench]
-    fn from_utf8_lossy_100_ascii(b: &mut Bencher) {
-        let s = b"Hello there, the quick brown fox jumped over the lazy dog! \
-                  Lorem ipsum dolor sit amet, consectetur. ";
-
-        assert_eq!(100, s.len());
-        b.iter(|| {
-            let _ = String::from_utf8_lossy(s);
-        });
-    }
-
-    #[bench]
-    fn from_utf8_lossy_100_multibyte(b: &mut Bencher) {
-        let s = "𐌀𐌖𐌋𐌄𐌑𐌉ปรدولة الكويتทศไทย中华𐍅𐌿𐌻𐍆𐌹𐌻𐌰".as_bytes();
-        assert_eq!(100, s.len());
-        b.iter(|| {
-            let _ = String::from_utf8_lossy(s);
-        });
-    }
-
-    #[bench]
-    fn from_utf8_lossy_invalid(b: &mut Bencher) {
-        let s = b"Hello\xC0\x80 There\xE6\x83 Goodbye";
-        b.iter(|| {
-            let _ = String::from_utf8_lossy(s);
-        });
-    }
-
-    #[bench]
-    fn from_utf8_lossy_100_invalid(b: &mut Bencher) {
-        let s = repeat(0xf5).take(100).collect::<Vec<_>>();
-        b.iter(|| {
-            let _ = String::from_utf8_lossy(&s);
-        });
-    }
-
-    #[bench]
-    fn bench_exact_size_shrink_to_fit(b: &mut Bencher) {
-        let s = "Hello there, the quick brown fox jumped over the lazy dog! \
-                 Lorem ipsum dolor sit amet, consectetur. ";
-        // ensure our operation produces an exact-size string before we benchmark it
-        let mut r = String::with_capacity(s.len());
-        r.push_str(s);
-        assert_eq!(r.len(), r.capacity());
-        b.iter(|| {
-            let mut r = String::with_capacity(s.len());
-            r.push_str(s);
-            r.shrink_to_fit();
-            r
-        });
-    }
-}
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs
index 8a2c58e0b5d..404179bd484 100644
--- a/src/libcollections/vec.rs
+++ b/src/libcollections/vec.rs
@@ -59,6 +59,7 @@ use core::intrinsics::assume;
 use core::iter::{repeat, FromIterator, IntoIterator};
 use core::marker::PhantomData;
 use core::mem;
+#[cfg(stage0)]
 use core::num::{Int, UnsignedInt};
 use core::ops::{Index, IndexMut, Deref, Add};
 use core::ops;
@@ -632,7 +633,7 @@ impl<T> Vec<T> {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// let mut vec = vec!(1, 2);
     /// vec.push(3);
     /// assert_eq!(vec, [1, 2, 3]);
@@ -670,7 +671,7 @@ impl<T> Vec<T> {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// let mut vec = vec![1, 2, 3];
     /// assert_eq!(vec.pop(), Some(3));
     /// assert_eq!(vec, [1, 2]);
@@ -1282,8 +1283,23 @@ pub fn from_elem<T: Clone>(elem: T, n: usize) -> Vec<T> {
 
 #[unstable(feature = "collections")]
 impl<T:Clone> Clone for Vec<T> {
+    #[cfg(stage0)]
     fn clone(&self) -> Vec<T> { ::slice::SliceExt::to_vec(&**self) }
 
+    #[cfg(not(stage0))]
+    #[cfg(not(test))]
+    fn clone(&self) -> Vec<T> { <[T]>::to_vec(&**self) }
+
+    // HACK(japaric): with cfg(test) the inherent `[T]::to_vec` method, which is required for this
+    // method definition, is not available. Instead use the `slice::to_vec`  function which is only
+    // available with cfg(test)
+    // NB see the slice::hack module in slice.rs for more information
+    #[cfg(not(stage0))]
+    #[cfg(test)]
+    fn clone(&self) -> Vec<T> {
+        ::slice::to_vec(&**self)
+    }
+
     fn clone_from(&mut self, other: &Vec<T>) {
         // drop anything in self that will not be overwritten
         if self.len() > other.len() {
@@ -1946,991 +1962,3 @@ impl<T,U> Drop for PartialVecZeroSized<T,U> {
         }
     }
 }
-
-#[cfg(test)]
-mod tests {
-    use prelude::*;
-    use core::mem::size_of;
-    use core::iter::repeat;
-    use test::Bencher;
-    use super::as_vec;
-
-    struct DropCounter<'a> {
-        count: &'a mut u32
-    }
-
-    #[unsafe_destructor]
-    impl<'a> Drop for DropCounter<'a> {
-        fn drop(&mut self) {
-            *self.count += 1;
-        }
-    }
-
-    #[test]
-    fn test_as_vec() {
-        let xs = [1u8, 2u8, 3u8];
-        assert_eq!(&**as_vec(&xs), xs);
-    }
-
-    #[test]
-    fn test_as_vec_dtor() {
-        let (mut count_x, mut count_y) = (0, 0);
-        {
-            let xs = &[DropCounter { count: &mut count_x }, DropCounter { count: &mut count_y }];
-            assert_eq!(as_vec(xs).len(), 2);
-        }
-        assert_eq!(count_x, 1);
-        assert_eq!(count_y, 1);
-    }
-
-    #[test]
-    fn test_small_vec_struct() {
-        assert!(size_of::<Vec<u8>>() == size_of::<usize>() * 3);
-    }
-
-    #[test]
-    fn test_double_drop() {
-        struct TwoVec<T> {
-            x: Vec<T>,
-            y: Vec<T>
-        }
-
-        let (mut count_x, mut count_y) = (0, 0);
-        {
-            let mut tv = TwoVec {
-                x: Vec::new(),
-                y: Vec::new()
-            };
-            tv.x.push(DropCounter {count: &mut count_x});
-            tv.y.push(DropCounter {count: &mut count_y});
-
-            // If Vec had a drop flag, here is where it would be zeroed.
-            // Instead, it should rely on its internal state to prevent
-            // doing anything significant when dropped multiple times.
-            drop(tv.x);
-
-            // Here tv goes out of scope, tv.y should be dropped, but not tv.x.
-        }
-
-        assert_eq!(count_x, 1);
-        assert_eq!(count_y, 1);
-    }
-
-    #[test]
-    fn test_reserve() {
-        let mut v = Vec::new();
-        assert_eq!(v.capacity(), 0);
-
-        v.reserve(2);
-        assert!(v.capacity() >= 2);
-
-        for i in 0..16 {
-            v.push(i);
-        }
-
-        assert!(v.capacity() >= 16);
-        v.reserve(16);
-        assert!(v.capacity() >= 32);
-
-        v.push(16);
-
-        v.reserve(16);
-        assert!(v.capacity() >= 33)
-    }
-
-    #[test]
-    fn test_extend() {
-        let mut v = Vec::new();
-        let mut w = Vec::new();
-
-        v.extend(0..3);
-        for i in 0..3 { w.push(i) }
-
-        assert_eq!(v, w);
-
-        v.extend(3..10);
-        for i in 3..10 { w.push(i) }
-
-        assert_eq!(v, w);
-    }
-
-    #[test]
-    fn test_slice_from_mut() {
-        let mut values = vec![1, 2, 3, 4, 5];
-        {
-            let slice = &mut values[2 ..];
-            assert!(slice == [3, 4, 5]);
-            for p in slice {
-                *p += 2;
-            }
-        }
-
-        assert!(values == [1, 2, 5, 6, 7]);
-    }
-
-    #[test]
-    fn test_slice_to_mut() {
-        let mut values = vec![1, 2, 3, 4, 5];
-        {
-            let slice = &mut values[.. 2];
-            assert!(slice == [1, 2]);
-            for p in slice {
-                *p += 1;
-            }
-        }
-
-        assert!(values == [2, 3, 3, 4, 5]);
-    }
-
-    #[test]
-    fn test_split_at_mut() {
-        let mut values = vec![1, 2, 3, 4, 5];
-        {
-            let (left, right) = values.split_at_mut(2);
-            {
-                let left: &[_] = left;
-                assert!(&left[..left.len()] == &[1, 2]);
-            }
-            for p in left {
-                *p += 1;
-            }
-
-            {
-                let right: &[_] = right;
-                assert!(&right[..right.len()] == &[3, 4, 5]);
-            }
-            for p in right {
-                *p += 2;
-            }
-        }
-
-        assert_eq!(values, [2, 3, 5, 6, 7]);
-    }
-
-    #[test]
-    fn test_clone() {
-        let v: Vec<i32> = vec![];
-        let w = vec!(1, 2, 3);
-
-        assert_eq!(v, v.clone());
-
-        let z = w.clone();
-        assert_eq!(w, z);
-        // they should be disjoint in memory.
-        assert!(w.as_ptr() != z.as_ptr())
-    }
-
-    #[test]
-    fn test_clone_from() {
-        let mut v = vec!();
-        let three: Vec<Box<_>> = vec!(box 1, box 2, box 3);
-        let two: Vec<Box<_>> = vec!(box 4, box 5);
-        // zero, long
-        v.clone_from(&three);
-        assert_eq!(v, three);
-
-        // equal
-        v.clone_from(&three);
-        assert_eq!(v, three);
-
-        // long, short
-        v.clone_from(&two);
-        assert_eq!(v, two);
-
-        // short, long
-        v.clone_from(&three);
-        assert_eq!(v, three)
-    }
-
-    #[test]
-    fn test_retain() {
-        let mut vec = vec![1, 2, 3, 4];
-        vec.retain(|&x| x % 2 == 0);
-        assert_eq!(vec, [2, 4]);
-    }
-
-    #[test]
-    fn zero_sized_values() {
-        let mut v = Vec::new();
-        assert_eq!(v.len(), 0);
-        v.push(());
-        assert_eq!(v.len(), 1);
-        v.push(());
-        assert_eq!(v.len(), 2);
-        assert_eq!(v.pop(), Some(()));
-        assert_eq!(v.pop(), Some(()));
-        assert_eq!(v.pop(), None);
-
-        assert_eq!(v.iter().count(), 0);
-        v.push(());
-        assert_eq!(v.iter().count(), 1);
-        v.push(());
-        assert_eq!(v.iter().count(), 2);
-
-        for &() in &v {}
-
-        assert_eq!(v.iter_mut().count(), 2);
-        v.push(());
-        assert_eq!(v.iter_mut().count(), 3);
-        v.push(());
-        assert_eq!(v.iter_mut().count(), 4);
-
-        for &mut () in &mut v {}
-        unsafe { v.set_len(0); }
-        assert_eq!(v.iter_mut().count(), 0);
-    }
-
-    #[test]
-    fn test_partition() {
-        assert_eq!(vec![].into_iter().partition(|x: &i32| *x < 3), (vec![], vec![]));
-        assert_eq!(vec![1, 2, 3].into_iter().partition(|x| *x < 4), (vec![1, 2, 3], vec![]));
-        assert_eq!(vec![1, 2, 3].into_iter().partition(|x| *x < 2), (vec![1], vec![2, 3]));
-        assert_eq!(vec![1, 2, 3].into_iter().partition(|x| *x < 0), (vec![], vec![1, 2, 3]));
-    }
-
-    #[test]
-    fn test_zip_unzip() {
-        let z1 = vec![(1, 4), (2, 5), (3, 6)];
-
-        let (left, right): (Vec<_>, Vec<_>) = z1.iter().cloned().unzip();
-
-        assert_eq!((1, 4), (left[0], right[0]));
-        assert_eq!((2, 5), (left[1], right[1]));
-        assert_eq!((3, 6), (left[2], right[2]));
-    }
-
-    #[test]
-    fn test_unsafe_ptrs() {
-        unsafe {
-            // Test on-stack copy-from-buf.
-            let a = [1, 2, 3];
-            let ptr = a.as_ptr();
-            let b = Vec::from_raw_buf(ptr, 3);
-            assert_eq!(b, [1, 2, 3]);
-
-            // Test on-heap copy-from-buf.
-            let c = vec![1, 2, 3, 4, 5];
-            let ptr = c.as_ptr();
-            let d = Vec::from_raw_buf(ptr, 5);
-            assert_eq!(d, [1, 2, 3, 4, 5]);
-        }
-    }
-
-    #[test]
-    fn test_vec_truncate_drop() {
-        static mut drops: u32 = 0;
-        struct Elem(i32);
-        impl Drop for Elem {
-            fn drop(&mut self) {
-                unsafe { drops += 1; }
-            }
-        }
-
-        let mut v = vec![Elem(1), Elem(2), Elem(3), Elem(4), Elem(5)];
-        assert_eq!(unsafe { drops }, 0);
-        v.truncate(3);
-        assert_eq!(unsafe { drops }, 2);
-        v.truncate(0);
-        assert_eq!(unsafe { drops }, 5);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_vec_truncate_fail() {
-        struct BadElem(i32);
-        impl Drop for BadElem {
-            fn drop(&mut self) {
-                let BadElem(ref mut x) = *self;
-                if *x == 0xbadbeef {
-                    panic!("BadElem panic: 0xbadbeef")
-                }
-            }
-        }
-
-        let mut v = vec![BadElem(1), BadElem(2), BadElem(0xbadbeef), BadElem(4)];
-        v.truncate(0);
-    }
-
-    #[test]
-    fn test_index() {
-        let vec = vec![1, 2, 3];
-        assert!(vec[1] == 2);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_index_out_of_bounds() {
-        let vec = vec![1, 2, 3];
-        let _ = vec[3];
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_slice_out_of_bounds_1() {
-        let x = vec![1, 2, 3, 4, 5];
-        &x[-1..];
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_slice_out_of_bounds_2() {
-        let x = vec![1, 2, 3, 4, 5];
-        &x[..6];
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_slice_out_of_bounds_3() {
-        let x = vec![1, 2, 3, 4, 5];
-        &x[-1..4];
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_slice_out_of_bounds_4() {
-        let x = vec![1, 2, 3, 4, 5];
-        &x[1..6];
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_slice_out_of_bounds_5() {
-        let x = vec![1, 2, 3, 4, 5];
-        &x[3..2];
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_swap_remove_empty() {
-        let mut vec= Vec::<i32>::new();
-        vec.swap_remove(0);
-    }
-
-    #[test]
-    fn test_move_iter_unwrap() {
-        let mut vec = Vec::with_capacity(7);
-        vec.push(1);
-        vec.push(2);
-        let ptr = vec.as_ptr();
-        vec = vec.into_iter().into_inner();
-        assert_eq!(vec.as_ptr(), ptr);
-        assert_eq!(vec.capacity(), 7);
-        assert_eq!(vec.len(), 0);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_map_in_place_incompatible_types_fail() {
-        let v = vec![0, 1, 2];
-        v.map_in_place(|_| ());
-    }
-
-    #[test]
-    fn test_map_in_place() {
-        let v = vec![0, 1, 2];
-        assert_eq!(v.map_in_place(|i: u32| i as i32 - 1), [-1, 0, 1]);
-    }
-
-    #[test]
-    fn test_map_in_place_zero_sized() {
-        let v = vec![(), ()];
-        #[derive(PartialEq, Debug)]
-        struct ZeroSized;
-        assert_eq!(v.map_in_place(|_| ZeroSized), [ZeroSized, ZeroSized]);
-    }
-
-    #[test]
-    fn test_map_in_place_zero_drop_count() {
-        use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
-
-        #[derive(Clone, PartialEq, Debug)]
-        struct Nothing;
-        impl Drop for Nothing { fn drop(&mut self) { } }
-
-        #[derive(Clone, PartialEq, Debug)]
-        struct ZeroSized;
-        impl Drop for ZeroSized {
-            fn drop(&mut self) {
-                DROP_COUNTER.fetch_add(1, Ordering::Relaxed);
-            }
-        }
-        const NUM_ELEMENTS: usize = 2;
-        static DROP_COUNTER: AtomicUsize = ATOMIC_USIZE_INIT;
-
-        let v = repeat(Nothing).take(NUM_ELEMENTS).collect::<Vec<_>>();
-
-        DROP_COUNTER.store(0, Ordering::Relaxed);
-
-        let v = v.map_in_place(|_| ZeroSized);
-        assert_eq!(DROP_COUNTER.load(Ordering::Relaxed), 0);
-        drop(v);
-        assert_eq!(DROP_COUNTER.load(Ordering::Relaxed), NUM_ELEMENTS);
-    }
-
-    #[test]
-    fn test_move_items() {
-        let vec = vec![1, 2, 3];
-        let mut vec2 = vec![];
-        for i in vec {
-            vec2.push(i);
-        }
-        assert_eq!(vec2, [1, 2, 3]);
-    }
-
-    #[test]
-    fn test_move_items_reverse() {
-        let vec = vec![1, 2, 3];
-        let mut vec2 = vec![];
-        for i in vec.into_iter().rev() {
-            vec2.push(i);
-        }
-        assert_eq!(vec2, [3, 2, 1]);
-    }
-
-    #[test]
-    fn test_move_items_zero_sized() {
-        let vec = vec![(), (), ()];
-        let mut vec2 = vec![];
-        for i in vec {
-            vec2.push(i);
-        }
-        assert_eq!(vec2, [(), (), ()]);
-    }
-
-    #[test]
-    fn test_drain_items() {
-        let mut vec = vec![1, 2, 3];
-        let mut vec2 = vec![];
-        for i in vec.drain() {
-            vec2.push(i);
-        }
-        assert_eq!(vec, []);
-        assert_eq!(vec2, [ 1, 2, 3 ]);
-    }
-
-    #[test]
-    fn test_drain_items_reverse() {
-        let mut vec = vec![1, 2, 3];
-        let mut vec2 = vec![];
-        for i in vec.drain().rev() {
-            vec2.push(i);
-        }
-        assert_eq!(vec, []);
-        assert_eq!(vec2, [3, 2, 1]);
-    }
-
-    #[test]
-    fn test_drain_items_zero_sized() {
-        let mut vec = vec![(), (), ()];
-        let mut vec2 = vec![];
-        for i in vec.drain() {
-            vec2.push(i);
-        }
-        assert_eq!(vec, []);
-        assert_eq!(vec2, [(), (), ()]);
-    }
-
-    #[test]
-    fn test_into_boxed_slice() {
-        let xs = vec![1, 2, 3];
-        let ys = xs.into_boxed_slice();
-        assert_eq!(&*ys, [1, 2, 3]);
-    }
-
-    #[test]
-    fn test_append() {
-        let mut vec = vec![1, 2, 3];
-        let mut vec2 = vec![4, 5, 6];
-        vec.append(&mut vec2);
-        assert_eq!(vec, [1, 2, 3, 4, 5, 6]);
-        assert_eq!(vec2, []);
-    }
-
-    #[test]
-    fn test_split_off() {
-        let mut vec = vec![1, 2, 3, 4, 5, 6];
-        let vec2 = vec.split_off(4);
-        assert_eq!(vec, [1, 2, 3, 4]);
-        assert_eq!(vec2, [5, 6]);
-    }
-
-    #[bench]
-    fn bench_new(b: &mut Bencher) {
-        b.iter(|| {
-            let v: Vec<u32> = Vec::new();
-            assert_eq!(v.len(), 0);
-            assert_eq!(v.capacity(), 0);
-        })
-    }
-
-    fn do_bench_with_capacity(b: &mut Bencher, src_len: usize) {
-        b.bytes = src_len as u64;
-
-        b.iter(|| {
-            let v: Vec<u32> = Vec::with_capacity(src_len);
-            assert_eq!(v.len(), 0);
-            assert_eq!(v.capacity(), src_len);
-        })
-    }
-
-    #[bench]
-    fn bench_with_capacity_0000(b: &mut Bencher) {
-        do_bench_with_capacity(b, 0)
-    }
-
-    #[bench]
-    fn bench_with_capacity_0010(b: &mut Bencher) {
-        do_bench_with_capacity(b, 10)
-    }
-
-    #[bench]
-    fn bench_with_capacity_0100(b: &mut Bencher) {
-        do_bench_with_capacity(b, 100)
-    }
-
-    #[bench]
-    fn bench_with_capacity_1000(b: &mut Bencher) {
-        do_bench_with_capacity(b, 1000)
-    }
-
-    fn do_bench_from_fn(b: &mut Bencher, src_len: usize) {
-        b.bytes = src_len as u64;
-
-        b.iter(|| {
-            let dst = (0..src_len).collect::<Vec<_>>();
-            assert_eq!(dst.len(), src_len);
-            assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
-        })
-    }
-
-    #[bench]
-    fn bench_from_fn_0000(b: &mut Bencher) {
-        do_bench_from_fn(b, 0)
-    }
-
-    #[bench]
-    fn bench_from_fn_0010(b: &mut Bencher) {
-        do_bench_from_fn(b, 10)
-    }
-
-    #[bench]
-    fn bench_from_fn_0100(b: &mut Bencher) {
-        do_bench_from_fn(b, 100)
-    }
-
-    #[bench]
-    fn bench_from_fn_1000(b: &mut Bencher) {
-        do_bench_from_fn(b, 1000)
-    }
-
-    fn do_bench_from_elem(b: &mut Bencher, src_len: usize) {
-        b.bytes = src_len as u64;
-
-        b.iter(|| {
-            let dst: Vec<usize> = repeat(5).take(src_len).collect();
-            assert_eq!(dst.len(), src_len);
-            assert!(dst.iter().all(|x| *x == 5));
-        })
-    }
-
-    #[bench]
-    fn bench_from_elem_0000(b: &mut Bencher) {
-        do_bench_from_elem(b, 0)
-    }
-
-    #[bench]
-    fn bench_from_elem_0010(b: &mut Bencher) {
-        do_bench_from_elem(b, 10)
-    }
-
-    #[bench]
-    fn bench_from_elem_0100(b: &mut Bencher) {
-        do_bench_from_elem(b, 100)
-    }
-
-    #[bench]
-    fn bench_from_elem_1000(b: &mut Bencher) {
-        do_bench_from_elem(b, 1000)
-    }
-
-    fn do_bench_from_slice(b: &mut Bencher, src_len: usize) {
-        let src: Vec<_> = FromIterator::from_iter(0..src_len);
-
-        b.bytes = src_len as u64;
-
-        b.iter(|| {
-            let dst = src.clone()[..].to_vec();
-            assert_eq!(dst.len(), src_len);
-            assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
-        });
-    }
-
-    #[bench]
-    fn bench_from_slice_0000(b: &mut Bencher) {
-        do_bench_from_slice(b, 0)
-    }
-
-    #[bench]
-    fn bench_from_slice_0010(b: &mut Bencher) {
-        do_bench_from_slice(b, 10)
-    }
-
-    #[bench]
-    fn bench_from_slice_0100(b: &mut Bencher) {
-        do_bench_from_slice(b, 100)
-    }
-
-    #[bench]
-    fn bench_from_slice_1000(b: &mut Bencher) {
-        do_bench_from_slice(b, 1000)
-    }
-
-    fn do_bench_from_iter(b: &mut Bencher, src_len: usize) {
-        let src: Vec<_> = FromIterator::from_iter(0..src_len);
-
-        b.bytes = src_len as u64;
-
-        b.iter(|| {
-            let dst: Vec<_> = FromIterator::from_iter(src.clone().into_iter());
-            assert_eq!(dst.len(), src_len);
-            assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
-        });
-    }
-
-    #[bench]
-    fn bench_from_iter_0000(b: &mut Bencher) {
-        do_bench_from_iter(b, 0)
-    }
-
-    #[bench]
-    fn bench_from_iter_0010(b: &mut Bencher) {
-        do_bench_from_iter(b, 10)
-    }
-
-    #[bench]
-    fn bench_from_iter_0100(b: &mut Bencher) {
-        do_bench_from_iter(b, 100)
-    }
-
-    #[bench]
-    fn bench_from_iter_1000(b: &mut Bencher) {
-        do_bench_from_iter(b, 1000)
-    }
-
-    fn do_bench_extend(b: &mut Bencher, dst_len: usize, src_len: usize) {
-        let dst: Vec<_> = FromIterator::from_iter(0..dst_len);
-        let src: Vec<_> = FromIterator::from_iter(dst_len..dst_len + src_len);
-
-        b.bytes = src_len as u64;
-
-        b.iter(|| {
-            let mut dst = dst.clone();
-            dst.extend(src.clone().into_iter());
-            assert_eq!(dst.len(), dst_len + src_len);
-            assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
-        });
-    }
-
-    #[bench]
-    fn bench_extend_0000_0000(b: &mut Bencher) {
-        do_bench_extend(b, 0, 0)
-    }
-
-    #[bench]
-    fn bench_extend_0000_0010(b: &mut Bencher) {
-        do_bench_extend(b, 0, 10)
-    }
-
-    #[bench]
-    fn bench_extend_0000_0100(b: &mut Bencher) {
-        do_bench_extend(b, 0, 100)
-    }
-
-    #[bench]
-    fn bench_extend_0000_1000(b: &mut Bencher) {
-        do_bench_extend(b, 0, 1000)
-    }
-
-    #[bench]
-    fn bench_extend_0010_0010(b: &mut Bencher) {
-        do_bench_extend(b, 10, 10)
-    }
-
-    #[bench]
-    fn bench_extend_0100_0100(b: &mut Bencher) {
-        do_bench_extend(b, 100, 100)
-    }
-
-    #[bench]
-    fn bench_extend_1000_1000(b: &mut Bencher) {
-        do_bench_extend(b, 1000, 1000)
-    }
-
-    fn do_bench_push_all(b: &mut Bencher, dst_len: usize, src_len: usize) {
-        let dst: Vec<_> = FromIterator::from_iter(0..dst_len);
-        let src: Vec<_> = FromIterator::from_iter(dst_len..dst_len + src_len);
-
-        b.bytes = src_len as u64;
-
-        b.iter(|| {
-            let mut dst = dst.clone();
-            dst.push_all(&src);
-            assert_eq!(dst.len(), dst_len + src_len);
-            assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
-        });
-    }
-
-    #[bench]
-    fn bench_push_all_0000_0000(b: &mut Bencher) {
-        do_bench_push_all(b, 0, 0)
-    }
-
-    #[bench]
-    fn bench_push_all_0000_0010(b: &mut Bencher) {
-        do_bench_push_all(b, 0, 10)
-    }
-
-    #[bench]
-    fn bench_push_all_0000_0100(b: &mut Bencher) {
-        do_bench_push_all(b, 0, 100)
-    }
-
-    #[bench]
-    fn bench_push_all_0000_1000(b: &mut Bencher) {
-        do_bench_push_all(b, 0, 1000)
-    }
-
-    #[bench]
-    fn bench_push_all_0010_0010(b: &mut Bencher) {
-        do_bench_push_all(b, 10, 10)
-    }
-
-    #[bench]
-    fn bench_push_all_0100_0100(b: &mut Bencher) {
-        do_bench_push_all(b, 100, 100)
-    }
-
-    #[bench]
-    fn bench_push_all_1000_1000(b: &mut Bencher) {
-        do_bench_push_all(b, 1000, 1000)
-    }
-
-    fn do_bench_push_all_move(b: &mut Bencher, dst_len: usize, src_len: usize) {
-        let dst: Vec<_> = FromIterator::from_iter(0..dst_len);
-        let src: Vec<_> = FromIterator::from_iter(dst_len..dst_len + src_len);
-
-        b.bytes = src_len as u64;
-
-        b.iter(|| {
-            let mut dst = dst.clone();
-            dst.extend(src.clone().into_iter());
-            assert_eq!(dst.len(), dst_len + src_len);
-            assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
-        });
-    }
-
-    #[bench]
-    fn bench_push_all_move_0000_0000(b: &mut Bencher) {
-        do_bench_push_all_move(b, 0, 0)
-    }
-
-    #[bench]
-    fn bench_push_all_move_0000_0010(b: &mut Bencher) {
-        do_bench_push_all_move(b, 0, 10)
-    }
-
-    #[bench]
-    fn bench_push_all_move_0000_0100(b: &mut Bencher) {
-        do_bench_push_all_move(b, 0, 100)
-    }
-
-    #[bench]
-    fn bench_push_all_move_0000_1000(b: &mut Bencher) {
-        do_bench_push_all_move(b, 0, 1000)
-    }
-
-    #[bench]
-    fn bench_push_all_move_0010_0010(b: &mut Bencher) {
-        do_bench_push_all_move(b, 10, 10)
-    }
-
-    #[bench]
-    fn bench_push_all_move_0100_0100(b: &mut Bencher) {
-        do_bench_push_all_move(b, 100, 100)
-    }
-
-    #[bench]
-    fn bench_push_all_move_1000_1000(b: &mut Bencher) {
-        do_bench_push_all_move(b, 1000, 1000)
-    }
-
-    fn do_bench_clone(b: &mut Bencher, src_len: usize) {
-        let src: Vec<usize> = FromIterator::from_iter(0..src_len);
-
-        b.bytes = src_len as u64;
-
-        b.iter(|| {
-            let dst = src.clone();
-            assert_eq!(dst.len(), src_len);
-            assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
-        });
-    }
-
-    #[bench]
-    fn bench_clone_0000(b: &mut Bencher) {
-        do_bench_clone(b, 0)
-    }
-
-    #[bench]
-    fn bench_clone_0010(b: &mut Bencher) {
-        do_bench_clone(b, 10)
-    }
-
-    #[bench]
-    fn bench_clone_0100(b: &mut Bencher) {
-        do_bench_clone(b, 100)
-    }
-
-    #[bench]
-    fn bench_clone_1000(b: &mut Bencher) {
-        do_bench_clone(b, 1000)
-    }
-
-    fn do_bench_clone_from(b: &mut Bencher, times: usize, dst_len: usize, src_len: usize) {
-        let dst: Vec<_> = FromIterator::from_iter(0..src_len);
-        let src: Vec<_> = FromIterator::from_iter(dst_len..dst_len + src_len);
-
-        b.bytes = (times * src_len) as u64;
-
-        b.iter(|| {
-            let mut dst = dst.clone();
-
-            for _ in 0..times {
-                dst.clone_from(&src);
-
-                assert_eq!(dst.len(), src_len);
-                assert!(dst.iter().enumerate().all(|(i, x)| dst_len + i == *x));
-            }
-        });
-    }
-
-    #[bench]
-    fn bench_clone_from_01_0000_0000(b: &mut Bencher) {
-        do_bench_clone_from(b, 1, 0, 0)
-    }
-
-    #[bench]
-    fn bench_clone_from_01_0000_0010(b: &mut Bencher) {
-        do_bench_clone_from(b, 1, 0, 10)
-    }
-
-    #[bench]
-    fn bench_clone_from_01_0000_0100(b: &mut Bencher) {
-        do_bench_clone_from(b, 1, 0, 100)
-    }
-
-    #[bench]
-    fn bench_clone_from_01_0000_1000(b: &mut Bencher) {
-        do_bench_clone_from(b, 1, 0, 1000)
-    }
-
-    #[bench]
-    fn bench_clone_from_01_0010_0010(b: &mut Bencher) {
-        do_bench_clone_from(b, 1, 10, 10)
-    }
-
-    #[bench]
-    fn bench_clone_from_01_0100_0100(b: &mut Bencher) {
-        do_bench_clone_from(b, 1, 100, 100)
-    }
-
-    #[bench]
-    fn bench_clone_from_01_1000_1000(b: &mut Bencher) {
-        do_bench_clone_from(b, 1, 1000, 1000)
-    }
-
-    #[bench]
-    fn bench_clone_from_01_0010_0100(b: &mut Bencher) {
-        do_bench_clone_from(b, 1, 10, 100)
-    }
-
-    #[bench]
-    fn bench_clone_from_01_0100_1000(b: &mut Bencher) {
-        do_bench_clone_from(b, 1, 100, 1000)
-    }
-
-    #[bench]
-    fn bench_clone_from_01_0010_0000(b: &mut Bencher) {
-        do_bench_clone_from(b, 1, 10, 0)
-    }
-
-    #[bench]
-    fn bench_clone_from_01_0100_0010(b: &mut Bencher) {
-        do_bench_clone_from(b, 1, 100, 10)
-    }
-
-    #[bench]
-    fn bench_clone_from_01_1000_0100(b: &mut Bencher) {
-        do_bench_clone_from(b, 1, 1000, 100)
-    }
-
-    #[bench]
-    fn bench_clone_from_10_0000_0000(b: &mut Bencher) {
-        do_bench_clone_from(b, 10, 0, 0)
-    }
-
-    #[bench]
-    fn bench_clone_from_10_0000_0010(b: &mut Bencher) {
-        do_bench_clone_from(b, 10, 0, 10)
-    }
-
-    #[bench]
-    fn bench_clone_from_10_0000_0100(b: &mut Bencher) {
-        do_bench_clone_from(b, 10, 0, 100)
-    }
-
-    #[bench]
-    fn bench_clone_from_10_0000_1000(b: &mut Bencher) {
-        do_bench_clone_from(b, 10, 0, 1000)
-    }
-
-    #[bench]
-    fn bench_clone_from_10_0010_0010(b: &mut Bencher) {
-        do_bench_clone_from(b, 10, 10, 10)
-    }
-
-    #[bench]
-    fn bench_clone_from_10_0100_0100(b: &mut Bencher) {
-        do_bench_clone_from(b, 10, 100, 100)
-    }
-
-    #[bench]
-    fn bench_clone_from_10_1000_1000(b: &mut Bencher) {
-        do_bench_clone_from(b, 10, 1000, 1000)
-    }
-
-    #[bench]
-    fn bench_clone_from_10_0010_0100(b: &mut Bencher) {
-        do_bench_clone_from(b, 10, 10, 100)
-    }
-
-    #[bench]
-    fn bench_clone_from_10_0100_1000(b: &mut Bencher) {
-        do_bench_clone_from(b, 10, 100, 1000)
-    }
-
-    #[bench]
-    fn bench_clone_from_10_0010_0000(b: &mut Bencher) {
-        do_bench_clone_from(b, 10, 10, 0)
-    }
-
-    #[bench]
-    fn bench_clone_from_10_0100_0010(b: &mut Bencher) {
-        do_bench_clone_from(b, 10, 100, 10)
-    }
-
-    #[bench]
-    fn bench_clone_from_10_1000_0100(b: &mut Bencher) {
-        do_bench_clone_from(b, 10, 1000, 100)
-    }
-}
diff --git a/src/libcollections/vec_deque.rs b/src/libcollections/vec_deque.rs
index 43c9edcaa2b..aefcad49a58 100644
--- a/src/libcollections/vec_deque.rs
+++ b/src/libcollections/vec_deque.rs
@@ -25,6 +25,7 @@ use core::default::Default;
 use core::fmt;
 use core::iter::{self, repeat, FromIterator, IntoIterator, RandomAccessIterator};
 use core::mem;
+#[cfg(stage0)]
 use core::num::{Int, UnsignedInt};
 use core::num::wrapping::WrappingOps;
 use core::ops::{Index, IndexMut};
@@ -200,7 +201,7 @@ impl<T> VecDeque<T> {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::collections::VecDeque;
     ///
     /// let mut buf = VecDeque::new();
@@ -223,7 +224,7 @@ impl<T> VecDeque<T> {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::collections::VecDeque;
     ///
     /// let mut buf = VecDeque::new();
@@ -257,7 +258,7 @@ impl<T> VecDeque<T> {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::collections::VecDeque;
     ///
     /// let mut buf = VecDeque::new();
@@ -512,7 +513,7 @@ impl<T> VecDeque<T> {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::collections::VecDeque;
     ///
     /// let mut buf = VecDeque::new();
@@ -535,7 +536,7 @@ impl<T> VecDeque<T> {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::collections::VecDeque;
     ///
     /// let mut buf = VecDeque::new();
@@ -823,7 +824,7 @@ impl<T> VecDeque<T> {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::collections::VecDeque;
     ///
     /// let mut buf = VecDeque::new();
@@ -848,7 +849,7 @@ impl<T> VecDeque<T> {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::collections::VecDeque;
     ///
     /// let mut buf = VecDeque::new();
@@ -948,7 +949,7 @@ impl<T> VecDeque<T> {
     /// Panics if `i` is greater than ringbuf's length
     ///
     /// # Examples
-    /// ```rust
+    /// ```
     /// use std::collections::VecDeque;
     ///
     /// let mut buf = VecDeque::new();
@@ -1150,7 +1151,7 @@ impl<T> VecDeque<T> {
     /// Returns `None` if `i` is out of bounds.
     ///
     /// # Examples
-    /// ```rust
+    /// ```
     /// use std::collections::VecDeque;
     ///
     /// let mut buf = VecDeque::new();
@@ -1769,138 +1770,14 @@ impl<T: fmt::Debug> fmt::Debug for VecDeque<T> {
 }
 
 #[cfg(test)]
-mod tests {
-    use self::Taggy::*;
-    use self::Taggypar::*;
-    use prelude::*;
-    use core::iter;
-    use std::fmt::Debug;
-    use std::hash::{self, SipHasher};
-    use test::Bencher;
+mod test {
+    use core::iter::{IteratorExt, self};
+    use core::option::Option::Some;
+
     use test;
 
     use super::VecDeque;
 
-    #[test]
-    #[allow(deprecated)]
-    fn test_simple() {
-        let mut d = VecDeque::new();
-        assert_eq!(d.len(), 0);
-        d.push_front(17);
-        d.push_front(42);
-        d.push_back(137);
-        assert_eq!(d.len(), 3);
-        d.push_back(137);
-        assert_eq!(d.len(), 4);
-        assert_eq!(*d.front().unwrap(), 42);
-        assert_eq!(*d.back().unwrap(), 137);
-        let mut i = d.pop_front();
-        assert_eq!(i, Some(42));
-        i = d.pop_back();
-        assert_eq!(i, Some(137));
-        i = d.pop_back();
-        assert_eq!(i, Some(137));
-        i = d.pop_back();
-        assert_eq!(i, Some(17));
-        assert_eq!(d.len(), 0);
-        d.push_back(3);
-        assert_eq!(d.len(), 1);
-        d.push_front(2);
-        assert_eq!(d.len(), 2);
-        d.push_back(4);
-        assert_eq!(d.len(), 3);
-        d.push_front(1);
-        assert_eq!(d.len(), 4);
-        debug!("{}", d[0]);
-        debug!("{}", d[1]);
-        debug!("{}", d[2]);
-        debug!("{}", d[3]);
-        assert_eq!(d[0], 1);
-        assert_eq!(d[1], 2);
-        assert_eq!(d[2], 3);
-        assert_eq!(d[3], 4);
-    }
-
-    #[cfg(test)]
-    fn test_parameterized<T:Clone + PartialEq + Debug>(a: T, b: T, c: T, d: T) {
-        let mut deq = VecDeque::new();
-        assert_eq!(deq.len(), 0);
-        deq.push_front(a.clone());
-        deq.push_front(b.clone());
-        deq.push_back(c.clone());
-        assert_eq!(deq.len(), 3);
-        deq.push_back(d.clone());
-        assert_eq!(deq.len(), 4);
-        assert_eq!((*deq.front().unwrap()).clone(), b.clone());
-        assert_eq!((*deq.back().unwrap()).clone(), d.clone());
-        assert_eq!(deq.pop_front().unwrap(), b.clone());
-        assert_eq!(deq.pop_back().unwrap(), d.clone());
-        assert_eq!(deq.pop_back().unwrap(), c.clone());
-        assert_eq!(deq.pop_back().unwrap(), a.clone());
-        assert_eq!(deq.len(), 0);
-        deq.push_back(c.clone());
-        assert_eq!(deq.len(), 1);
-        deq.push_front(b.clone());
-        assert_eq!(deq.len(), 2);
-        deq.push_back(d.clone());
-        assert_eq!(deq.len(), 3);
-        deq.push_front(a.clone());
-        assert_eq!(deq.len(), 4);
-        assert_eq!(deq[0].clone(), a.clone());
-        assert_eq!(deq[1].clone(), b.clone());
-        assert_eq!(deq[2].clone(), c.clone());
-        assert_eq!(deq[3].clone(), d.clone());
-    }
-
-    #[test]
-    fn test_push_front_grow() {
-        let mut deq = VecDeque::new();
-        for i in 0..66 {
-            deq.push_front(i);
-        }
-        assert_eq!(deq.len(), 66);
-
-        for i in 0..66 {
-            assert_eq!(deq[i], 65 - i);
-        }
-
-        let mut deq = VecDeque::new();
-        for i in 0..66 {
-            deq.push_back(i);
-        }
-
-        for i in 0..66 {
-            assert_eq!(deq[i], i);
-        }
-    }
-
-    #[test]
-    fn test_index() {
-        let mut deq = VecDeque::new();
-        for i in 1..4 {
-            deq.push_front(i);
-        }
-        assert_eq!(deq[1], 2);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_index_out_of_bounds() {
-        let mut deq = VecDeque::new();
-        for i in 1..4 {
-            deq.push_front(i);
-        }
-        deq[3];
-    }
-
-    #[bench]
-    fn bench_new(b: &mut test::Bencher) {
-        b.iter(|| {
-            let ring: VecDeque<i32> = VecDeque::new();
-            test::black_box(ring);
-        })
-    }
-
     #[bench]
     fn bench_push_back_100(b: &mut test::Bencher) {
         let mut deq = VecDeque::with_capacity(101);
@@ -1951,666 +1828,6 @@ mod tests {
         })
     }
 
-    #[bench]
-    fn bench_grow_1025(b: &mut test::Bencher) {
-        b.iter(|| {
-            let mut deq = VecDeque::new();
-            for i in 0..1025 {
-                deq.push_front(i);
-            }
-            test::black_box(deq);
-        })
-    }
-
-    #[bench]
-    fn bench_iter_1000(b: &mut test::Bencher) {
-        let ring: VecDeque<_> = (0..1000).collect();
-
-        b.iter(|| {
-            let mut sum = 0;
-            for &i in &ring {
-                sum += i;
-            }
-            test::black_box(sum);
-        })
-    }
-
-    #[bench]
-    fn bench_mut_iter_1000(b: &mut test::Bencher) {
-        let mut ring: VecDeque<_> = (0..1000).collect();
-
-        b.iter(|| {
-            let mut sum = 0;
-            for i in &mut ring {
-                sum += *i;
-            }
-            test::black_box(sum);
-        })
-    }
-
-    #[derive(Clone, PartialEq, Debug)]
-    enum Taggy {
-        One(i32),
-        Two(i32, i32),
-        Three(i32, i32, i32),
-    }
-
-    #[derive(Clone, PartialEq, Debug)]
-    enum Taggypar<T> {
-        Onepar(T),
-        Twopar(T, T),
-        Threepar(T, T, T),
-    }
-
-    #[derive(Clone, PartialEq, Debug)]
-    struct RecCy {
-        x: i32,
-        y: i32,
-        t: Taggy
-    }
-
-    #[test]
-    fn test_param_int() {
-        test_parameterized::<i32>(5, 72, 64, 175);
-    }
-
-    #[test]
-    fn test_param_taggy() {
-        test_parameterized::<Taggy>(One(1), Two(1, 2), Three(1, 2, 3), Two(17, 42));
-    }
-
-    #[test]
-    fn test_param_taggypar() {
-        test_parameterized::<Taggypar<i32>>(Onepar::<i32>(1),
-                                            Twopar::<i32>(1, 2),
-                                            Threepar::<i32>(1, 2, 3),
-                                            Twopar::<i32>(17, 42));
-    }
-
-    #[test]
-    fn test_param_reccy() {
-        let reccy1 = RecCy { x: 1, y: 2, t: One(1) };
-        let reccy2 = RecCy { x: 345, y: 2, t: Two(1, 2) };
-        let reccy3 = RecCy { x: 1, y: 777, t: Three(1, 2, 3) };
-        let reccy4 = RecCy { x: 19, y: 252, t: Two(17, 42) };
-        test_parameterized::<RecCy>(reccy1, reccy2, reccy3, reccy4);
-    }
-
-    #[test]
-    fn test_with_capacity() {
-        let mut d = VecDeque::with_capacity(0);
-        d.push_back(1);
-        assert_eq!(d.len(), 1);
-        let mut d = VecDeque::with_capacity(50);
-        d.push_back(1);
-        assert_eq!(d.len(), 1);
-    }
-
-    #[test]
-    fn test_with_capacity_non_power_two() {
-        let mut d3 = VecDeque::with_capacity(3);
-        d3.push_back(1);
-
-        // X = None, | = lo
-        // [|1, X, X]
-        assert_eq!(d3.pop_front(), Some(1));
-        // [X, |X, X]
-        assert_eq!(d3.front(), None);
-
-        // [X, |3, X]
-        d3.push_back(3);
-        // [X, |3, 6]
-        d3.push_back(6);
-        // [X, X, |6]
-        assert_eq!(d3.pop_front(), Some(3));
-
-        // Pushing the lo past half way point to trigger
-        // the 'B' scenario for growth
-        // [9, X, |6]
-        d3.push_back(9);
-        // [9, 12, |6]
-        d3.push_back(12);
-
-        d3.push_back(15);
-        // There used to be a bug here about how the
-        // VecDeque made growth assumptions about the
-        // underlying Vec which didn't hold and lead
-        // to corruption.
-        // (Vec grows to next power of two)
-        //good- [9, 12, 15, X, X, X, X, |6]
-        //bug-  [15, 12, X, X, X, |6, X, X]
-        assert_eq!(d3.pop_front(), Some(6));
-
-        // Which leads us to the following state which
-        // would be a failure case.
-        //bug-  [15, 12, X, X, X, X, |X, X]
-        assert_eq!(d3.front(), Some(&9));
-    }
-
-    #[test]
-    fn test_reserve_exact() {
-        let mut d = VecDeque::new();
-        d.push_back(0);
-        d.reserve_exact(50);
-        assert!(d.capacity() >= 51);
-    }
-
-    #[test]
-    fn test_reserve() {
-        let mut d = VecDeque::new();
-        d.push_back(0);
-        d.reserve(50);
-        assert!(d.capacity() >= 51);
-    }
-
-    #[test]
-    fn test_swap() {
-        let mut d: VecDeque<_> = (0..5).collect();
-        d.pop_front();
-        d.swap(0, 3);
-        assert_eq!(d.iter().cloned().collect::<Vec<_>>(), [4, 2, 3, 1]);
-    }
-
-    #[test]
-    fn test_iter() {
-        let mut d = VecDeque::new();
-        assert_eq!(d.iter().next(), None);
-        assert_eq!(d.iter().size_hint(), (0, Some(0)));
-
-        for i in 0..5 {
-            d.push_back(i);
-        }
-        {
-            let b: &[_] = &[&0,&1,&2,&3,&4];
-            assert_eq!(d.iter().collect::<Vec<_>>(), b);
-        }
-
-        for i in 6..9 {
-            d.push_front(i);
-        }
-        {
-            let b: &[_] = &[&8,&7,&6,&0,&1,&2,&3,&4];
-            assert_eq!(d.iter().collect::<Vec<_>>(), b);
-        }
-
-        let mut it = d.iter();
-        let mut len = d.len();
-        loop {
-            match it.next() {
-                None => break,
-                _ => { len -= 1; assert_eq!(it.size_hint(), (len, Some(len))) }
-            }
-        }
-    }
-
-    #[test]
-    fn test_rev_iter() {
-        let mut d = VecDeque::new();
-        assert_eq!(d.iter().rev().next(), None);
-
-        for i in 0..5 {
-            d.push_back(i);
-        }
-        {
-            let b: &[_] = &[&4,&3,&2,&1,&0];
-            assert_eq!(d.iter().rev().collect::<Vec<_>>(), b);
-        }
-
-        for i in 6..9 {
-            d.push_front(i);
-        }
-        let b: &[_] = &[&4,&3,&2,&1,&0,&6,&7,&8];
-        assert_eq!(d.iter().rev().collect::<Vec<_>>(), b);
-    }
-
-    #[test]
-    fn test_mut_rev_iter_wrap() {
-        let mut d = VecDeque::with_capacity(3);
-        assert!(d.iter_mut().rev().next().is_none());
-
-        d.push_back(1);
-        d.push_back(2);
-        d.push_back(3);
-        assert_eq!(d.pop_front(), Some(1));
-        d.push_back(4);
-
-        assert_eq!(d.iter_mut().rev().cloned().collect::<Vec<_>>(),
-                   vec![4, 3, 2]);
-    }
-
-    #[test]
-    fn test_mut_iter() {
-        let mut d = VecDeque::new();
-        assert!(d.iter_mut().next().is_none());
-
-        for i in 0..3 {
-            d.push_front(i);
-        }
-
-        for (i, elt) in d.iter_mut().enumerate() {
-            assert_eq!(*elt, 2 - i);
-            *elt = i;
-        }
-
-        {
-            let mut it = d.iter_mut();
-            assert_eq!(*it.next().unwrap(), 0);
-            assert_eq!(*it.next().unwrap(), 1);
-            assert_eq!(*it.next().unwrap(), 2);
-            assert!(it.next().is_none());
-        }
-    }
-
-    #[test]
-    fn test_mut_rev_iter() {
-        let mut d = VecDeque::new();
-        assert!(d.iter_mut().rev().next().is_none());
-
-        for i in 0..3 {
-            d.push_front(i);
-        }
-
-        for (i, elt) in d.iter_mut().rev().enumerate() {
-            assert_eq!(*elt, i);
-            *elt = i;
-        }
-
-        {
-            let mut it = d.iter_mut().rev();
-            assert_eq!(*it.next().unwrap(), 0);
-            assert_eq!(*it.next().unwrap(), 1);
-            assert_eq!(*it.next().unwrap(), 2);
-            assert!(it.next().is_none());
-        }
-    }
-
-    #[test]
-    fn test_into_iter() {
-
-        // Empty iter
-        {
-            let d: VecDeque<i32> = VecDeque::new();
-            let mut iter = d.into_iter();
-
-            assert_eq!(iter.size_hint(), (0, Some(0)));
-            assert_eq!(iter.next(), None);
-            assert_eq!(iter.size_hint(), (0, Some(0)));
-        }
-
-        // simple iter
-        {
-            let mut d = VecDeque::new();
-            for i in 0..5 {
-                d.push_back(i);
-            }
-
-            let b = vec![0,1,2,3,4];
-            assert_eq!(d.into_iter().collect::<Vec<_>>(), b);
-        }
-
-        // wrapped iter
-        {
-            let mut d = VecDeque::new();
-            for i in 0..5 {
-                d.push_back(i);
-            }
-            for i in 6..9 {
-                d.push_front(i);
-            }
-
-            let b = vec![8,7,6,0,1,2,3,4];
-            assert_eq!(d.into_iter().collect::<Vec<_>>(), b);
-        }
-
-        // partially used
-        {
-            let mut d = VecDeque::new();
-            for i in 0..5 {
-                d.push_back(i);
-            }
-            for i in 6..9 {
-                d.push_front(i);
-            }
-
-            let mut it = d.into_iter();
-            assert_eq!(it.size_hint(), (8, Some(8)));
-            assert_eq!(it.next(), Some(8));
-            assert_eq!(it.size_hint(), (7, Some(7)));
-            assert_eq!(it.next_back(), Some(4));
-            assert_eq!(it.size_hint(), (6, Some(6)));
-            assert_eq!(it.next(), Some(7));
-            assert_eq!(it.size_hint(), (5, Some(5)));
-        }
-    }
-
-    #[test]
-    fn test_drain() {
-
-        // Empty iter
-        {
-            let mut d: VecDeque<i32> = VecDeque::new();
-
-            {
-                let mut iter = d.drain();
-
-                assert_eq!(iter.size_hint(), (0, Some(0)));
-                assert_eq!(iter.next(), None);
-                assert_eq!(iter.size_hint(), (0, Some(0)));
-            }
-
-            assert!(d.is_empty());
-        }
-
-        // simple iter
-        {
-            let mut d = VecDeque::new();
-            for i in 0..5 {
-                d.push_back(i);
-            }
-
-            assert_eq!(d.drain().collect::<Vec<_>>(), [0, 1, 2, 3, 4]);
-            assert!(d.is_empty());
-        }
-
-        // wrapped iter
-        {
-            let mut d = VecDeque::new();
-            for i in 0..5 {
-                d.push_back(i);
-            }
-            for i in 6..9 {
-                d.push_front(i);
-            }
-
-            assert_eq!(d.drain().collect::<Vec<_>>(), [8,7,6,0,1,2,3,4]);
-            assert!(d.is_empty());
-        }
-
-        // partially used
-        {
-            let mut d: VecDeque<_> = VecDeque::new();
-            for i in 0..5 {
-                d.push_back(i);
-            }
-            for i in 6..9 {
-                d.push_front(i);
-            }
-
-            {
-                let mut it = d.drain();
-                assert_eq!(it.size_hint(), (8, Some(8)));
-                assert_eq!(it.next(), Some(8));
-                assert_eq!(it.size_hint(), (7, Some(7)));
-                assert_eq!(it.next_back(), Some(4));
-                assert_eq!(it.size_hint(), (6, Some(6)));
-                assert_eq!(it.next(), Some(7));
-                assert_eq!(it.size_hint(), (5, Some(5)));
-            }
-            assert!(d.is_empty());
-        }
-    }
-
-    #[test]
-    fn test_from_iter() {
-        use core::iter;
-        let v = vec!(1,2,3,4,5,6,7);
-        let deq: VecDeque<_> = v.iter().cloned().collect();
-        let u: Vec<_> = deq.iter().cloned().collect();
-        assert_eq!(u, v);
-
-        let seq = iter::count(0, 2).take(256);
-        let deq: VecDeque<_> = seq.collect();
-        for (i, &x) in deq.iter().enumerate() {
-            assert_eq!(2*i, x);
-        }
-        assert_eq!(deq.len(), 256);
-    }
-
-    #[test]
-    fn test_clone() {
-        let mut d = VecDeque::new();
-        d.push_front(17);
-        d.push_front(42);
-        d.push_back(137);
-        d.push_back(137);
-        assert_eq!(d.len(), 4);
-        let mut e = d.clone();
-        assert_eq!(e.len(), 4);
-        while !d.is_empty() {
-            assert_eq!(d.pop_back(), e.pop_back());
-        }
-        assert_eq!(d.len(), 0);
-        assert_eq!(e.len(), 0);
-    }
-
-    #[test]
-    fn test_eq() {
-        let mut d = VecDeque::new();
-        assert!(d == VecDeque::with_capacity(0));
-        d.push_front(137);
-        d.push_front(17);
-        d.push_front(42);
-        d.push_back(137);
-        let mut e = VecDeque::with_capacity(0);
-        e.push_back(42);
-        e.push_back(17);
-        e.push_back(137);
-        e.push_back(137);
-        assert!(&e == &d);
-        e.pop_back();
-        e.push_back(0);
-        assert!(e != d);
-        e.clear();
-        assert!(e == VecDeque::new());
-    }
-
-    #[test]
-    fn test_hash() {
-      let mut x = VecDeque::new();
-      let mut y = VecDeque::new();
-
-      x.push_back(1);
-      x.push_back(2);
-      x.push_back(3);
-
-      y.push_back(0);
-      y.push_back(1);
-      y.pop_front();
-      y.push_back(2);
-      y.push_back(3);
-
-      assert!(hash::hash::<_, SipHasher>(&x) == hash::hash::<_, SipHasher>(&y));
-    }
-
-    #[test]
-    fn test_ord() {
-        let x = VecDeque::new();
-        let mut y = VecDeque::new();
-        y.push_back(1);
-        y.push_back(2);
-        y.push_back(3);
-        assert!(x < y);
-        assert!(y > x);
-        assert!(x <= x);
-        assert!(x >= x);
-    }
-
-    #[test]
-    fn test_show() {
-        let ringbuf: VecDeque<_> = (0..10).collect();
-        assert_eq!(format!("{:?}", ringbuf), "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
-
-        let ringbuf: VecDeque<_> = vec!["just", "one", "test", "more"].iter()
-                                                                        .cloned()
-                                                                        .collect();
-        assert_eq!(format!("{:?}", ringbuf), "[\"just\", \"one\", \"test\", \"more\"]");
-    }
-
-    #[test]
-    fn test_drop() {
-        static mut drops: i32 = 0;
-        struct Elem;
-        impl Drop for Elem {
-            fn drop(&mut self) {
-                unsafe { drops += 1; }
-            }
-        }
-
-        let mut ring = VecDeque::new();
-        ring.push_back(Elem);
-        ring.push_front(Elem);
-        ring.push_back(Elem);
-        ring.push_front(Elem);
-        drop(ring);
-
-        assert_eq!(unsafe {drops}, 4);
-    }
-
-    #[test]
-    fn test_drop_with_pop() {
-        static mut drops: i32 = 0;
-        struct Elem;
-        impl Drop for Elem {
-            fn drop(&mut self) {
-                unsafe { drops += 1; }
-            }
-        }
-
-        let mut ring = VecDeque::new();
-        ring.push_back(Elem);
-        ring.push_front(Elem);
-        ring.push_back(Elem);
-        ring.push_front(Elem);
-
-        drop(ring.pop_back());
-        drop(ring.pop_front());
-        assert_eq!(unsafe {drops}, 2);
-
-        drop(ring);
-        assert_eq!(unsafe {drops}, 4);
-    }
-
-    #[test]
-    fn test_drop_clear() {
-        static mut drops: i32 = 0;
-        struct Elem;
-        impl Drop for Elem {
-            fn drop(&mut self) {
-                unsafe { drops += 1; }
-            }
-        }
-
-        let mut ring = VecDeque::new();
-        ring.push_back(Elem);
-        ring.push_front(Elem);
-        ring.push_back(Elem);
-        ring.push_front(Elem);
-        ring.clear();
-        assert_eq!(unsafe {drops}, 4);
-
-        drop(ring);
-        assert_eq!(unsafe {drops}, 4);
-    }
-
-    #[test]
-    fn test_reserve_grow() {
-        // test growth path A
-        // [T o o H] -> [T o o H . . . . ]
-        let mut ring = VecDeque::with_capacity(4);
-        for i in 0..3 {
-            ring.push_back(i);
-        }
-        ring.reserve(7);
-        for i in 0..3 {
-            assert_eq!(ring.pop_front(), Some(i));
-        }
-
-        // test growth path B
-        // [H T o o] -> [. T o o H . . . ]
-        let mut ring = VecDeque::with_capacity(4);
-        for i in 0..1 {
-            ring.push_back(i);
-            assert_eq!(ring.pop_front(), Some(i));
-        }
-        for i in 0..3 {
-            ring.push_back(i);
-        }
-        ring.reserve(7);
-        for i in 0..3 {
-            assert_eq!(ring.pop_front(), Some(i));
-        }
-
-        // test growth path C
-        // [o o H T] -> [o o H . . . . T ]
-        let mut ring = VecDeque::with_capacity(4);
-        for i in 0..3 {
-            ring.push_back(i);
-            assert_eq!(ring.pop_front(), Some(i));
-        }
-        for i in 0..3 {
-            ring.push_back(i);
-        }
-        ring.reserve(7);
-        for i in 0..3 {
-            assert_eq!(ring.pop_front(), Some(i));
-        }
-    }
-
-    #[test]
-    fn test_get() {
-        let mut ring = VecDeque::new();
-        ring.push_back(0);
-        assert_eq!(ring.get(0), Some(&0));
-        assert_eq!(ring.get(1), None);
-
-        ring.push_back(1);
-        assert_eq!(ring.get(0), Some(&0));
-        assert_eq!(ring.get(1), Some(&1));
-        assert_eq!(ring.get(2), None);
-
-        ring.push_back(2);
-        assert_eq!(ring.get(0), Some(&0));
-        assert_eq!(ring.get(1), Some(&1));
-        assert_eq!(ring.get(2), Some(&2));
-        assert_eq!(ring.get(3), None);
-
-        assert_eq!(ring.pop_front(), Some(0));
-        assert_eq!(ring.get(0), Some(&1));
-        assert_eq!(ring.get(1), Some(&2));
-        assert_eq!(ring.get(2), None);
-
-        assert_eq!(ring.pop_front(), Some(1));
-        assert_eq!(ring.get(0), Some(&2));
-        assert_eq!(ring.get(1), None);
-
-        assert_eq!(ring.pop_front(), Some(2));
-        assert_eq!(ring.get(0), None);
-        assert_eq!(ring.get(1), None);
-    }
-
-    #[test]
-    fn test_get_mut() {
-        let mut ring = VecDeque::new();
-        for i in 0..3 {
-            ring.push_back(i);
-        }
-
-        match ring.get_mut(1) {
-            Some(x) => *x = -1,
-            None => ()
-        };
-
-        assert_eq!(ring.get_mut(0), Some(&mut 0));
-        assert_eq!(ring.get_mut(1), Some(&mut -1));
-        assert_eq!(ring.get_mut(2), Some(&mut 2));
-        assert_eq!(ring.get_mut(3), None);
-
-        assert_eq!(ring.pop_front(), Some(0));
-        assert_eq!(ring.get_mut(0), Some(&mut -1));
-        assert_eq!(ring.get_mut(1), Some(&mut 2));
-        assert_eq!(ring.get_mut(2), None);
-    }
-
     #[test]
     fn test_swap_front_back_remove() {
         fn test(back: bool) {
@@ -2759,74 +1976,6 @@ mod tests {
     }
 
     #[test]
-    fn test_front() {
-        let mut ring = VecDeque::new();
-        ring.push_back(10);
-        ring.push_back(20);
-        assert_eq!(ring.front(), Some(&10));
-        ring.pop_front();
-        assert_eq!(ring.front(), Some(&20));
-        ring.pop_front();
-        assert_eq!(ring.front(), None);
-    }
-
-    #[test]
-    fn test_as_slices() {
-        let mut ring: VecDeque<i32> = VecDeque::with_capacity(127);
-        let cap = ring.capacity() as i32;
-        let first = cap/2;
-        let last  = cap - first;
-        for i in 0..first {
-            ring.push_back(i);
-
-            let (left, right) = ring.as_slices();
-            let expected: Vec<_> = (0..i+1).collect();
-            assert_eq!(left, expected);
-            assert_eq!(right, []);
-        }
-
-        for j in -last..0 {
-            ring.push_front(j);
-            let (left, right) = ring.as_slices();
-            let expected_left: Vec<_> = (-last..j+1).rev().collect();
-            let expected_right: Vec<_> = (0..first).collect();
-            assert_eq!(left, expected_left);
-            assert_eq!(right, expected_right);
-        }
-
-        assert_eq!(ring.len() as i32, cap);
-        assert_eq!(ring.capacity() as i32, cap);
-    }
-
-    #[test]
-    fn test_as_mut_slices() {
-        let mut ring: VecDeque<i32> = VecDeque::with_capacity(127);
-        let cap = ring.capacity() as i32;
-        let first = cap/2;
-        let last  = cap - first;
-        for i in 0..first {
-            ring.push_back(i);
-
-            let (left, right) = ring.as_mut_slices();
-            let expected: Vec<_> = (0..i+1).collect();
-            assert_eq!(left, expected);
-            assert_eq!(right, []);
-        }
-
-        for j in -last..0 {
-            ring.push_front(j);
-            let (left, right) = ring.as_mut_slices();
-            let expected_left: Vec<_> = (-last..j+1).rev().collect();
-            let expected_right: Vec<_> = (0..first).collect();
-            assert_eq!(left, expected_left);
-            assert_eq!(right, expected_right);
-        }
-
-        assert_eq!(ring.len() as i32, cap);
-        assert_eq!(ring.capacity() as i32, cap);
-    }
-
-    #[test]
     fn test_split_off() {
         // This test checks that every single combination of tail position, length, and
         // split position is tested. Capacity 15 should be large enough to cover every case.
@@ -2863,25 +2012,4 @@ mod tests {
             }
         }
     }
-
-    #[test]
-    fn test_append() {
-        let mut a: VecDeque<_> = vec![1, 2, 3].into_iter().collect();
-        let mut b: VecDeque<_> = vec![4, 5, 6].into_iter().collect();
-
-        // normal append
-        a.append(&mut b);
-        assert_eq!(a.iter().cloned().collect::<Vec<_>>(), [1, 2, 3, 4, 5, 6]);
-        assert_eq!(b.iter().cloned().collect::<Vec<_>>(), []);
-
-        // append nothing to something
-        a.append(&mut b);
-        assert_eq!(a.iter().cloned().collect::<Vec<_>>(), [1, 2, 3, 4, 5, 6]);
-        assert_eq!(b.iter().cloned().collect::<Vec<_>>(), []);
-
-        // append something to nothing
-        b.append(&mut a);
-        assert_eq!(b.iter().cloned().collect::<Vec<_>>(), [1, 2, 3, 4, 5, 6]);
-        assert_eq!(a.iter().cloned().collect::<Vec<_>>(), []);
-    }
 }
diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs
index 431c8d5df8c..6e67d876327 100644
--- a/src/libcollections/vec_map.rs
+++ b/src/libcollections/vec_map.rs
@@ -1004,510 +1004,3 @@ impl<V> Iterator for IntoIter<V> {
 impl<V> DoubleEndedIterator for IntoIter<V> {
     fn next_back(&mut self) -> Option<(usize, V)> { self.iter.next_back() }
 }
-
-#[cfg(test)]
-mod test_map {
-    use prelude::*;
-    use core::hash::{hash, SipHasher};
-
-    use super::VecMap;
-    use super::Entry::{Occupied, Vacant};
-
-    #[test]
-    fn test_get_mut() {
-        let mut m = VecMap::new();
-        assert!(m.insert(1, 12).is_none());
-        assert!(m.insert(2, 8).is_none());
-        assert!(m.insert(5, 14).is_none());
-        let new = 100;
-        match m.get_mut(&5) {
-            None => panic!(), Some(x) => *x = new
-        }
-        assert_eq!(m.get(&5), Some(&new));
-    }
-
-    #[test]
-    fn test_len() {
-        let mut map = VecMap::new();
-        assert_eq!(map.len(), 0);
-        assert!(map.is_empty());
-        assert!(map.insert(5, 20).is_none());
-        assert_eq!(map.len(), 1);
-        assert!(!map.is_empty());
-        assert!(map.insert(11, 12).is_none());
-        assert_eq!(map.len(), 2);
-        assert!(!map.is_empty());
-        assert!(map.insert(14, 22).is_none());
-        assert_eq!(map.len(), 3);
-        assert!(!map.is_empty());
-    }
-
-    #[test]
-    fn test_clear() {
-        let mut map = VecMap::new();
-        assert!(map.insert(5, 20).is_none());
-        assert!(map.insert(11, 12).is_none());
-        assert!(map.insert(14, 22).is_none());
-        map.clear();
-        assert!(map.is_empty());
-        assert!(map.get(&5).is_none());
-        assert!(map.get(&11).is_none());
-        assert!(map.get(&14).is_none());
-    }
-
-    #[test]
-    fn test_insert() {
-        let mut m = VecMap::new();
-        assert_eq!(m.insert(1, 2), None);
-        assert_eq!(m.insert(1, 3), Some(2));
-        assert_eq!(m.insert(1, 4), Some(3));
-    }
-
-    #[test]
-    fn test_remove() {
-        let mut m = VecMap::new();
-        m.insert(1, 2);
-        assert_eq!(m.remove(&1), Some(2));
-        assert_eq!(m.remove(&1), None);
-    }
-
-    #[test]
-    fn test_keys() {
-        let mut map = VecMap::new();
-        map.insert(1, 'a');
-        map.insert(2, 'b');
-        map.insert(3, 'c');
-        let keys: Vec<_> = map.keys().collect();
-        assert_eq!(keys.len(), 3);
-        assert!(keys.contains(&1));
-        assert!(keys.contains(&2));
-        assert!(keys.contains(&3));
-    }
-
-    #[test]
-    fn test_values() {
-        let mut map = VecMap::new();
-        map.insert(1, 'a');
-        map.insert(2, 'b');
-        map.insert(3, 'c');
-        let values: Vec<_> = map.values().cloned().collect();
-        assert_eq!(values.len(), 3);
-        assert!(values.contains(&'a'));
-        assert!(values.contains(&'b'));
-        assert!(values.contains(&'c'));
-    }
-
-    #[test]
-    fn test_iterator() {
-        let mut m = VecMap::new();
-
-        assert!(m.insert(0, 1).is_none());
-        assert!(m.insert(1, 2).is_none());
-        assert!(m.insert(3, 5).is_none());
-        assert!(m.insert(6, 10).is_none());
-        assert!(m.insert(10, 11).is_none());
-
-        let mut it = m.iter();
-        assert_eq!(it.size_hint(), (0, Some(11)));
-        assert_eq!(it.next().unwrap(), (0, &1));
-        assert_eq!(it.size_hint(), (0, Some(10)));
-        assert_eq!(it.next().unwrap(), (1, &2));
-        assert_eq!(it.size_hint(), (0, Some(9)));
-        assert_eq!(it.next().unwrap(), (3, &5));
-        assert_eq!(it.size_hint(), (0, Some(7)));
-        assert_eq!(it.next().unwrap(), (6, &10));
-        assert_eq!(it.size_hint(), (0, Some(4)));
-        assert_eq!(it.next().unwrap(), (10, &11));
-        assert_eq!(it.size_hint(), (0, Some(0)));
-        assert!(it.next().is_none());
-    }
-
-    #[test]
-    fn test_iterator_size_hints() {
-        let mut m = VecMap::new();
-
-        assert!(m.insert(0, 1).is_none());
-        assert!(m.insert(1, 2).is_none());
-        assert!(m.insert(3, 5).is_none());
-        assert!(m.insert(6, 10).is_none());
-        assert!(m.insert(10, 11).is_none());
-
-        assert_eq!(m.iter().size_hint(), (0, Some(11)));
-        assert_eq!(m.iter().rev().size_hint(), (0, Some(11)));
-        assert_eq!(m.iter_mut().size_hint(), (0, Some(11)));
-        assert_eq!(m.iter_mut().rev().size_hint(), (0, Some(11)));
-    }
-
-    #[test]
-    fn test_mut_iterator() {
-        let mut m = VecMap::new();
-
-        assert!(m.insert(0, 1).is_none());
-        assert!(m.insert(1, 2).is_none());
-        assert!(m.insert(3, 5).is_none());
-        assert!(m.insert(6, 10).is_none());
-        assert!(m.insert(10, 11).is_none());
-
-        for (k, v) in &mut m {
-            *v += k as isize;
-        }
-
-        let mut it = m.iter();
-        assert_eq!(it.next().unwrap(), (0, &1));
-        assert_eq!(it.next().unwrap(), (1, &3));
-        assert_eq!(it.next().unwrap(), (3, &8));
-        assert_eq!(it.next().unwrap(), (6, &16));
-        assert_eq!(it.next().unwrap(), (10, &21));
-        assert!(it.next().is_none());
-    }
-
-    #[test]
-    fn test_rev_iterator() {
-        let mut m = VecMap::new();
-
-        assert!(m.insert(0, 1).is_none());
-        assert!(m.insert(1, 2).is_none());
-        assert!(m.insert(3, 5).is_none());
-        assert!(m.insert(6, 10).is_none());
-        assert!(m.insert(10, 11).is_none());
-
-        let mut it = m.iter().rev();
-        assert_eq!(it.next().unwrap(), (10, &11));
-        assert_eq!(it.next().unwrap(), (6, &10));
-        assert_eq!(it.next().unwrap(), (3, &5));
-        assert_eq!(it.next().unwrap(), (1, &2));
-        assert_eq!(it.next().unwrap(), (0, &1));
-        assert!(it.next().is_none());
-    }
-
-    #[test]
-    fn test_mut_rev_iterator() {
-        let mut m = VecMap::new();
-
-        assert!(m.insert(0, 1).is_none());
-        assert!(m.insert(1, 2).is_none());
-        assert!(m.insert(3, 5).is_none());
-        assert!(m.insert(6, 10).is_none());
-        assert!(m.insert(10, 11).is_none());
-
-        for (k, v) in m.iter_mut().rev() {
-            *v += k as isize;
-        }
-
-        let mut it = m.iter();
-        assert_eq!(it.next().unwrap(), (0, &1));
-        assert_eq!(it.next().unwrap(), (1, &3));
-        assert_eq!(it.next().unwrap(), (3, &8));
-        assert_eq!(it.next().unwrap(), (6, &16));
-        assert_eq!(it.next().unwrap(), (10, &21));
-        assert!(it.next().is_none());
-    }
-
-    #[test]
-    fn test_move_iter() {
-        let mut m: VecMap<Box<_>> = VecMap::new();
-        m.insert(1, box 2);
-        let mut called = false;
-        for (k, v) in m {
-            assert!(!called);
-            called = true;
-            assert_eq!(k, 1);
-            assert_eq!(v, box 2);
-        }
-        assert!(called);
-    }
-
-    #[test]
-    fn test_drain_iterator() {
-        let mut map = VecMap::new();
-        map.insert(1, "a");
-        map.insert(3, "c");
-        map.insert(2, "b");
-
-        let vec: Vec<_> = map.drain().collect();
-
-        assert_eq!(vec, [(1, "a"), (2, "b"), (3, "c")]);
-        assert_eq!(map.len(), 0);
-    }
-
-    #[test]
-    fn test_append() {
-        let mut a = VecMap::new();
-        a.insert(1, "a");
-        a.insert(2, "b");
-        a.insert(3, "c");
-
-        let mut b = VecMap::new();
-        b.insert(3, "d");  // Overwrite element from a
-        b.insert(4, "e");
-        b.insert(5, "f");
-
-        a.append(&mut b);
-
-        assert_eq!(a.len(), 5);
-        assert_eq!(b.len(), 0);
-        // Capacity shouldn't change for possible reuse
-        assert!(b.capacity() >= 4);
-
-        assert_eq!(a[1], "a");
-        assert_eq!(a[2], "b");
-        assert_eq!(a[3], "d");
-        assert_eq!(a[4], "e");
-        assert_eq!(a[5], "f");
-    }
-
-    #[test]
-    fn test_split_off() {
-        // Split within the key range
-        let mut a = VecMap::new();
-        a.insert(1, "a");
-        a.insert(2, "b");
-        a.insert(3, "c");
-        a.insert(4, "d");
-
-        let b = a.split_off(3);
-
-        assert_eq!(a.len(), 2);
-        assert_eq!(b.len(), 2);
-
-        assert_eq!(a[1], "a");
-        assert_eq!(a[2], "b");
-
-        assert_eq!(b[3], "c");
-        assert_eq!(b[4], "d");
-
-        // Split at 0
-        a.clear();
-        a.insert(1, "a");
-        a.insert(2, "b");
-        a.insert(3, "c");
-        a.insert(4, "d");
-
-        let b = a.split_off(0);
-
-        assert_eq!(a.len(), 0);
-        assert_eq!(b.len(), 4);
-        assert_eq!(b[1], "a");
-        assert_eq!(b[2], "b");
-        assert_eq!(b[3], "c");
-        assert_eq!(b[4], "d");
-
-        // Split behind max_key
-        a.clear();
-        a.insert(1, "a");
-        a.insert(2, "b");
-        a.insert(3, "c");
-        a.insert(4, "d");
-
-        let b = a.split_off(5);
-
-        assert_eq!(a.len(), 4);
-        assert_eq!(b.len(), 0);
-        assert_eq!(a[1], "a");
-        assert_eq!(a[2], "b");
-        assert_eq!(a[3], "c");
-        assert_eq!(a[4], "d");
-    }
-
-    #[test]
-    fn test_show() {
-        let mut map = VecMap::new();
-        let empty = VecMap::<i32>::new();
-
-        map.insert(1, 2);
-        map.insert(3, 4);
-
-        let map_str = format!("{:?}", map);
-        assert!(map_str == "{1: 2, 3: 4}" || map_str == "{3: 4, 1: 2}");
-        assert_eq!(format!("{:?}", empty), "{}");
-    }
-
-    #[test]
-    fn test_clone() {
-        let mut a = VecMap::new();
-
-        a.insert(1, 'x');
-        a.insert(4, 'y');
-        a.insert(6, 'z');
-
-        assert!(a.clone() == a);
-    }
-
-    #[test]
-    fn test_eq() {
-        let mut a = VecMap::new();
-        let mut b = VecMap::new();
-
-        assert!(a == b);
-        assert!(a.insert(0, 5).is_none());
-        assert!(a != b);
-        assert!(b.insert(0, 4).is_none());
-        assert!(a != b);
-        assert!(a.insert(5, 19).is_none());
-        assert!(a != b);
-        assert!(!b.insert(0, 5).is_none());
-        assert!(a != b);
-        assert!(b.insert(5, 19).is_none());
-        assert!(a == b);
-
-        a = VecMap::new();
-        b = VecMap::with_capacity(1);
-        assert!(a == b);
-    }
-
-    #[test]
-    fn test_lt() {
-        let mut a = VecMap::new();
-        let mut b = VecMap::new();
-
-        assert!(!(a < b) && !(b < a));
-        assert!(b.insert(2, 5).is_none());
-        assert!(a < b);
-        assert!(a.insert(2, 7).is_none());
-        assert!(!(a < b) && b < a);
-        assert!(b.insert(1, 0).is_none());
-        assert!(b < a);
-        assert!(a.insert(0, 6).is_none());
-        assert!(a < b);
-        assert!(a.insert(6, 2).is_none());
-        assert!(a < b && !(b < a));
-    }
-
-    #[test]
-    fn test_ord() {
-        let mut a = VecMap::new();
-        let mut b = VecMap::new();
-
-        assert!(a <= b && a >= b);
-        assert!(a.insert(1, 1).is_none());
-        assert!(a > b && a >= b);
-        assert!(b < a && b <= a);
-        assert!(b.insert(2, 2).is_none());
-        assert!(b > a && b >= a);
-        assert!(a < b && a <= b);
-    }
-
-    #[test]
-    fn test_hash() {
-        let mut x = VecMap::new();
-        let mut y = VecMap::new();
-
-        assert!(hash::<_, SipHasher>(&x) == hash::<_, SipHasher>(&y));
-        x.insert(1, 'a');
-        x.insert(2, 'b');
-        x.insert(3, 'c');
-
-        y.insert(3, 'c');
-        y.insert(2, 'b');
-        y.insert(1, 'a');
-
-        assert!(hash::<_, SipHasher>(&x) == hash::<_, SipHasher>(&y));
-
-        x.insert(1000, 'd');
-        x.remove(&1000);
-
-        assert!(hash::<_, SipHasher>(&x) == hash::<_, SipHasher>(&y));
-    }
-
-    #[test]
-    fn test_from_iter() {
-        let xs = vec![(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e')];
-
-        let map: VecMap<_> = xs.iter().cloned().collect();
-
-        for &(k, v) in &xs {
-            assert_eq!(map.get(&k), Some(&v));
-        }
-    }
-
-    #[test]
-    fn test_index() {
-        let mut map = VecMap::new();
-
-        map.insert(1, 2);
-        map.insert(2, 1);
-        map.insert(3, 4);
-
-        assert_eq!(map[3], 4);
-    }
-
-    #[test]
-    #[should_panic]
-    fn test_index_nonexistent() {
-        let mut map = VecMap::new();
-
-        map.insert(1, 2);
-        map.insert(2, 1);
-        map.insert(3, 4);
-
-        map[4];
-    }
-
-    #[test]
-    fn test_entry(){
-        let xs = [(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)];
-
-        let mut map: VecMap<_> = xs.iter().cloned().collect();
-
-        // Existing key (insert)
-        match map.entry(1) {
-            Vacant(_) => unreachable!(),
-            Occupied(mut view) => {
-                assert_eq!(view.get(), &10);
-                assert_eq!(view.insert(100), 10);
-            }
-        }
-        assert_eq!(map.get(&1).unwrap(), &100);
-        assert_eq!(map.len(), 6);
-
-
-        // Existing key (update)
-        match map.entry(2) {
-            Vacant(_) => unreachable!(),
-            Occupied(mut view) => {
-                let v = view.get_mut();
-                *v *= 10;
-            }
-        }
-        assert_eq!(map.get(&2).unwrap(), &200);
-        assert_eq!(map.len(), 6);
-
-        // Existing key (take)
-        match map.entry(3) {
-            Vacant(_) => unreachable!(),
-            Occupied(view) => {
-                assert_eq!(view.remove(), 30);
-            }
-        }
-        assert_eq!(map.get(&3), None);
-        assert_eq!(map.len(), 5);
-
-
-        // Inexistent key (insert)
-        match map.entry(10) {
-            Occupied(_) => unreachable!(),
-            Vacant(view) => {
-                assert_eq!(*view.insert(1000), 1000);
-            }
-        }
-        assert_eq!(map.get(&10).unwrap(), &1000);
-        assert_eq!(map.len(), 6);
-    }
-}
-
-#[cfg(test)]
-mod bench {
-    use super::VecMap;
-
-    map_insert_rand_bench!{insert_rand_100,    100,    VecMap}
-    map_insert_rand_bench!{insert_rand_10_000, 10_000, VecMap}
-
-    map_insert_seq_bench!{insert_seq_100,    100,    VecMap}
-    map_insert_seq_bench!{insert_seq_10_000, 10_000, VecMap}
-
-    map_find_rand_bench!{find_rand_100,    100,    VecMap}
-    map_find_rand_bench!{find_rand_10_000, 10_000, VecMap}
-
-    map_find_seq_bench!{find_seq_100,    100,    VecMap}
-    map_find_seq_bench!{find_seq_10_000, 10_000, VecMap}
-}
diff --git a/src/libcollections/bench.rs b/src/libcollectionstest/bench.rs
index 107f6031c11..2396a577589 100644
--- a/src/libcollections/bench.rs
+++ b/src/libcollectionstest/bench.rs
@@ -66,11 +66,11 @@ macro_rules! map_find_rand_bench {
     ($name: ident, $n: expr, $map: ident) => (
         #[bench]
         pub fn $name(b: &mut ::test::Bencher) {
-            use std::rand;
             use std::iter::IteratorExt;
             use std::rand::Rng;
+            use std::rand;
+            use std::vec::Vec;
             use test::black_box;
-            use vec::Vec;
 
             let mut map = $map::new();
             let n: usize = $n;
diff --git a/src/libcollectionstest/binary_heap.rs b/src/libcollectionstest/binary_heap.rs
new file mode 100644
index 00000000000..47a366bb1e2
--- /dev/null
+++ b/src/libcollectionstest/binary_heap.rs
@@ -0,0 +1,219 @@
+// Copyright 2013-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::collections::BinaryHeap;
+
+#[test]
+fn test_iterator() {
+    let data = vec![5, 9, 3];
+    let iterout = [9, 5, 3];
+    let heap = BinaryHeap::from_vec(data);
+    let mut i = 0;
+    for el in &heap {
+        assert_eq!(*el, iterout[i]);
+        i += 1;
+    }
+}
+
+#[test]
+fn test_iterator_reverse() {
+    let data = vec![5, 9, 3];
+    let iterout = vec![3, 5, 9];
+    let pq = BinaryHeap::from_vec(data);
+
+    let v: Vec<_> = pq.iter().rev().cloned().collect();
+    assert_eq!(v, iterout);
+}
+
+#[test]
+fn test_move_iter() {
+    let data = vec![5, 9, 3];
+    let iterout = vec![9, 5, 3];
+    let pq = BinaryHeap::from_vec(data);
+
+    let v: Vec<_> = pq.into_iter().collect();
+    assert_eq!(v, iterout);
+}
+
+#[test]
+fn test_move_iter_size_hint() {
+    let data = vec![5, 9];
+    let pq = BinaryHeap::from_vec(data);
+
+    let mut it = pq.into_iter();
+
+    assert_eq!(it.size_hint(), (2, Some(2)));
+    assert_eq!(it.next(), Some(9));
+
+    assert_eq!(it.size_hint(), (1, Some(1)));
+    assert_eq!(it.next(), Some(5));
+
+    assert_eq!(it.size_hint(), (0, Some(0)));
+    assert_eq!(it.next(), None);
+}
+
+#[test]
+fn test_move_iter_reverse() {
+    let data = vec![5, 9, 3];
+    let iterout = vec![3, 5, 9];
+    let pq = BinaryHeap::from_vec(data);
+
+    let v: Vec<_> = pq.into_iter().rev().collect();
+    assert_eq!(v, iterout);
+}
+
+#[test]
+fn test_peek_and_pop() {
+    let data = vec![2, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1];
+    let mut sorted = data.clone();
+    sorted.sort();
+    let mut heap = BinaryHeap::from_vec(data);
+    while !heap.is_empty() {
+        assert_eq!(heap.peek().unwrap(), sorted.last().unwrap());
+        assert_eq!(heap.pop().unwrap(), sorted.pop().unwrap());
+    }
+}
+
+#[test]
+fn test_push() {
+    let mut heap = BinaryHeap::from_vec(vec![2, 4, 9]);
+    assert_eq!(heap.len(), 3);
+    assert!(*heap.peek().unwrap() == 9);
+    heap.push(11);
+    assert_eq!(heap.len(), 4);
+    assert!(*heap.peek().unwrap() == 11);
+    heap.push(5);
+    assert_eq!(heap.len(), 5);
+    assert!(*heap.peek().unwrap() == 11);
+    heap.push(27);
+    assert_eq!(heap.len(), 6);
+    assert!(*heap.peek().unwrap() == 27);
+    heap.push(3);
+    assert_eq!(heap.len(), 7);
+    assert!(*heap.peek().unwrap() == 27);
+    heap.push(103);
+    assert_eq!(heap.len(), 8);
+    assert!(*heap.peek().unwrap() == 103);
+}
+
+#[test]
+fn test_push_unique() {
+    let mut heap = BinaryHeap::<Box<_>>::from_vec(vec![box 2, box 4, box 9]);
+    assert_eq!(heap.len(), 3);
+    assert!(*heap.peek().unwrap() == box 9);
+    heap.push(box 11);
+    assert_eq!(heap.len(), 4);
+    assert!(*heap.peek().unwrap() == box 11);
+    heap.push(box 5);
+    assert_eq!(heap.len(), 5);
+    assert!(*heap.peek().unwrap() == box 11);
+    heap.push(box 27);
+    assert_eq!(heap.len(), 6);
+    assert!(*heap.peek().unwrap() == box 27);
+    heap.push(box 3);
+    assert_eq!(heap.len(), 7);
+    assert!(*heap.peek().unwrap() == box 27);
+    heap.push(box 103);
+    assert_eq!(heap.len(), 8);
+    assert!(*heap.peek().unwrap() == box 103);
+}
+
+#[test]
+fn test_push_pop() {
+    let mut heap = BinaryHeap::from_vec(vec![5, 5, 2, 1, 3]);
+    assert_eq!(heap.len(), 5);
+    assert_eq!(heap.push_pop(6), 6);
+    assert_eq!(heap.len(), 5);
+    assert_eq!(heap.push_pop(0), 5);
+    assert_eq!(heap.len(), 5);
+    assert_eq!(heap.push_pop(4), 5);
+    assert_eq!(heap.len(), 5);
+    assert_eq!(heap.push_pop(1), 4);
+    assert_eq!(heap.len(), 5);
+}
+
+#[test]
+fn test_replace() {
+    let mut heap = BinaryHeap::from_vec(vec![5, 5, 2, 1, 3]);
+    assert_eq!(heap.len(), 5);
+    assert_eq!(heap.replace(6).unwrap(), 5);
+    assert_eq!(heap.len(), 5);
+    assert_eq!(heap.replace(0).unwrap(), 6);
+    assert_eq!(heap.len(), 5);
+    assert_eq!(heap.replace(4).unwrap(), 5);
+    assert_eq!(heap.len(), 5);
+    assert_eq!(heap.replace(1).unwrap(), 4);
+    assert_eq!(heap.len(), 5);
+}
+
+fn check_to_vec(mut data: Vec<i32>) {
+    let heap = BinaryHeap::from_vec(data.clone());
+    let mut v = heap.clone().into_vec();
+    v.sort();
+    data.sort();
+
+    assert_eq!(v, data);
+    assert_eq!(heap.into_sorted_vec(), data);
+}
+
+#[test]
+fn test_to_vec() {
+    check_to_vec(vec![]);
+    check_to_vec(vec![5]);
+    check_to_vec(vec![3, 2]);
+    check_to_vec(vec![2, 3]);
+    check_to_vec(vec![5, 1, 2]);
+    check_to_vec(vec![1, 100, 2, 3]);
+    check_to_vec(vec![1, 3, 5, 7, 9, 2, 4, 6, 8, 0]);
+    check_to_vec(vec![2, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1]);
+    check_to_vec(vec![9, 11, 9, 9, 9, 9, 11, 2, 3, 4, 11, 9, 0, 0, 0, 0]);
+    check_to_vec(vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
+    check_to_vec(vec![10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]);
+    check_to_vec(vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 1, 2]);
+    check_to_vec(vec![5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]);
+}
+
+#[test]
+fn test_empty_pop() {
+    let mut heap = BinaryHeap::<i32>::new();
+    assert!(heap.pop().is_none());
+}
+
+#[test]
+fn test_empty_peek() {
+    let empty = BinaryHeap::<i32>::new();
+    assert!(empty.peek().is_none());
+}
+
+#[test]
+fn test_empty_replace() {
+    let mut heap = BinaryHeap::new();
+    assert!(heap.replace(5).is_none());
+}
+
+#[test]
+fn test_from_iter() {
+    let xs = vec![9, 8, 7, 6, 5, 4, 3, 2, 1];
+
+    let mut q: BinaryHeap<_> = xs.iter().rev().cloned().collect();
+
+    for &x in &xs {
+        assert_eq!(q.pop().unwrap(), x);
+    }
+}
+
+#[test]
+fn test_drain() {
+    let mut q: BinaryHeap<_> = [9, 8, 7, 6, 5, 4, 3, 2, 1].iter().cloned().collect();
+
+    assert_eq!(q.drain().take(5).count(), 5);
+
+    assert!(q.is_empty());
+}
diff --git a/src/libcollectionstest/bit/mod.rs b/src/libcollectionstest/bit/mod.rs
new file mode 100644
index 00000000000..8e06524f2e5
--- /dev/null
+++ b/src/libcollectionstest/bit/mod.rs
@@ -0,0 +1,12 @@
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+mod set;
+mod vec;
diff --git a/src/libcollectionstest/bit/set.rs b/src/libcollectionstest/bit/set.rs
new file mode 100644
index 00000000000..4b4995d5fa7
--- /dev/null
+++ b/src/libcollectionstest/bit/set.rs
@@ -0,0 +1,441 @@
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::cmp::Ordering::{Equal, Greater, Less};
+use std::collections::{BitSet, BitVec};
+use std::iter::range_step;
+
+#[test]
+fn test_bit_set_show() {
+    let mut s = BitSet::new();
+    s.insert(1);
+    s.insert(10);
+    s.insert(50);
+    s.insert(2);
+    assert_eq!("{1, 2, 10, 50}", format!("{:?}", s));
+}
+
+#[test]
+fn test_bit_set_from_usizes() {
+    let usizes = vec![0, 2, 2, 3];
+    let a: BitSet = usizes.into_iter().collect();
+    let mut b = BitSet::new();
+    b.insert(0);
+    b.insert(2);
+    b.insert(3);
+    assert_eq!(a, b);
+}
+
+#[test]
+fn test_bit_set_iterator() {
+    let usizes = vec![0, 2, 2, 3];
+    let bit_vec: BitSet = usizes.into_iter().collect();
+
+    let idxs: Vec<_> = bit_vec.iter().collect();
+    assert_eq!(idxs, [0, 2, 3]);
+
+    let long: BitSet = (0..10000).filter(|&n| n % 2 == 0).collect();
+    let real: Vec<_> = range_step(0, 10000, 2).collect();
+
+    let idxs: Vec<_> = long.iter().collect();
+    assert_eq!(idxs, real);
+}
+
+#[test]
+fn test_bit_set_frombit_vec_init() {
+    let bools = [true, false];
+    let lengths = [10, 64, 100];
+    for &b in &bools {
+        for &l in &lengths {
+            let bitset = BitSet::from_bit_vec(BitVec::from_elem(l, b));
+            assert_eq!(bitset.contains(&1), b);
+            assert_eq!(bitset.contains(&(l-1)), b);
+            assert!(!bitset.contains(&l));
+        }
+    }
+}
+
+#[test]
+fn test_bit_vec_masking() {
+    let b = BitVec::from_elem(140, true);
+    let mut bs = BitSet::from_bit_vec(b);
+    assert!(bs.contains(&139));
+    assert!(!bs.contains(&140));
+    assert!(bs.insert(150));
+    assert!(!bs.contains(&140));
+    assert!(!bs.contains(&149));
+    assert!(bs.contains(&150));
+    assert!(!bs.contains(&151));
+}
+
+#[test]
+fn test_bit_set_basic() {
+    let mut b = BitSet::new();
+    assert!(b.insert(3));
+    assert!(!b.insert(3));
+    assert!(b.contains(&3));
+    assert!(b.insert(4));
+    assert!(!b.insert(4));
+    assert!(b.contains(&3));
+    assert!(b.insert(400));
+    assert!(!b.insert(400));
+    assert!(b.contains(&400));
+    assert_eq!(b.len(), 3);
+}
+
+#[test]
+fn test_bit_set_intersection() {
+    let mut a = BitSet::new();
+    let mut b = BitSet::new();
+
+    assert!(a.insert(11));
+    assert!(a.insert(1));
+    assert!(a.insert(3));
+    assert!(a.insert(77));
+    assert!(a.insert(103));
+    assert!(a.insert(5));
+
+    assert!(b.insert(2));
+    assert!(b.insert(11));
+    assert!(b.insert(77));
+    assert!(b.insert(5));
+    assert!(b.insert(3));
+
+    let expected = [3, 5, 11, 77];
+    let actual: Vec<_> = a.intersection(&b).collect();
+    assert_eq!(actual, expected);
+}
+
+#[test]
+fn test_bit_set_difference() {
+    let mut a = BitSet::new();
+    let mut b = BitSet::new();
+
+    assert!(a.insert(1));
+    assert!(a.insert(3));
+    assert!(a.insert(5));
+    assert!(a.insert(200));
+    assert!(a.insert(500));
+
+    assert!(b.insert(3));
+    assert!(b.insert(200));
+
+    let expected = [1, 5, 500];
+    let actual: Vec<_> = a.difference(&b).collect();
+    assert_eq!(actual, expected);
+}
+
+#[test]
+fn test_bit_set_symmetric_difference() {
+    let mut a = BitSet::new();
+    let mut b = BitSet::new();
+
+    assert!(a.insert(1));
+    assert!(a.insert(3));
+    assert!(a.insert(5));
+    assert!(a.insert(9));
+    assert!(a.insert(11));
+
+    assert!(b.insert(3));
+    assert!(b.insert(9));
+    assert!(b.insert(14));
+    assert!(b.insert(220));
+
+    let expected = [1, 5, 11, 14, 220];
+    let actual: Vec<_> = a.symmetric_difference(&b).collect();
+    assert_eq!(actual, expected);
+}
+
+#[test]
+fn test_bit_set_union() {
+    let mut a = BitSet::new();
+    let mut b = BitSet::new();
+    assert!(a.insert(1));
+    assert!(a.insert(3));
+    assert!(a.insert(5));
+    assert!(a.insert(9));
+    assert!(a.insert(11));
+    assert!(a.insert(160));
+    assert!(a.insert(19));
+    assert!(a.insert(24));
+    assert!(a.insert(200));
+
+    assert!(b.insert(1));
+    assert!(b.insert(5));
+    assert!(b.insert(9));
+    assert!(b.insert(13));
+    assert!(b.insert(19));
+
+    let expected = [1, 3, 5, 9, 11, 13, 19, 24, 160, 200];
+    let actual: Vec<_> = a.union(&b).collect();
+    assert_eq!(actual, expected);
+}
+
+#[test]
+fn test_bit_set_subset() {
+    let mut set1 = BitSet::new();
+    let mut set2 = BitSet::new();
+
+    assert!(set1.is_subset(&set2)); //  {}  {}
+    set2.insert(100);
+    assert!(set1.is_subset(&set2)); //  {}  { 1 }
+    set2.insert(200);
+    assert!(set1.is_subset(&set2)); //  {}  { 1, 2 }
+    set1.insert(200);
+    assert!(set1.is_subset(&set2)); //  { 2 }  { 1, 2 }
+    set1.insert(300);
+    assert!(!set1.is_subset(&set2)); // { 2, 3 }  { 1, 2 }
+    set2.insert(300);
+    assert!(set1.is_subset(&set2)); // { 2, 3 }  { 1, 2, 3 }
+    set2.insert(400);
+    assert!(set1.is_subset(&set2)); // { 2, 3 }  { 1, 2, 3, 4 }
+    set2.remove(&100);
+    assert!(set1.is_subset(&set2)); // { 2, 3 }  { 2, 3, 4 }
+    set2.remove(&300);
+    assert!(!set1.is_subset(&set2)); // { 2, 3 }  { 2, 4 }
+    set1.remove(&300);
+    assert!(set1.is_subset(&set2)); // { 2 }  { 2, 4 }
+}
+
+#[test]
+fn test_bit_set_is_disjoint() {
+    let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
+    let b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01000000]));
+    let c = BitSet::new();
+    let d = BitSet::from_bit_vec(BitVec::from_bytes(&[0b00110000]));
+
+    assert!(!a.is_disjoint(&d));
+    assert!(!d.is_disjoint(&a));
+
+    assert!(a.is_disjoint(&b));
+    assert!(a.is_disjoint(&c));
+    assert!(b.is_disjoint(&a));
+    assert!(b.is_disjoint(&c));
+    assert!(c.is_disjoint(&a));
+    assert!(c.is_disjoint(&b));
+}
+
+#[test]
+fn test_bit_set_union_with() {
+    //a should grow to include larger elements
+    let mut a = BitSet::new();
+    a.insert(0);
+    let mut b = BitSet::new();
+    b.insert(5);
+    let expected = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10000100]));
+    a.union_with(&b);
+    assert_eq!(a, expected);
+
+    // Standard
+    let mut a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
+    let mut b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01100010]));
+    let c = a.clone();
+    a.union_with(&b);
+    b.union_with(&c);
+    assert_eq!(a.len(), 4);
+    assert_eq!(b.len(), 4);
+}
+
+#[test]
+fn test_bit_set_intersect_with() {
+    // Explicitly 0'ed bits
+    let mut a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
+    let mut b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b00000000]));
+    let c = a.clone();
+    a.intersect_with(&b);
+    b.intersect_with(&c);
+    assert!(a.is_empty());
+    assert!(b.is_empty());
+
+    // Uninitialized bits should behave like 0's
+    let mut a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
+    let mut b = BitSet::new();
+    let c = a.clone();
+    a.intersect_with(&b);
+    b.intersect_with(&c);
+    assert!(a.is_empty());
+    assert!(b.is_empty());
+
+    // Standard
+    let mut a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
+    let mut b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01100010]));
+    let c = a.clone();
+    a.intersect_with(&b);
+    b.intersect_with(&c);
+    assert_eq!(a.len(), 2);
+    assert_eq!(b.len(), 2);
+}
+
+#[test]
+fn test_bit_set_difference_with() {
+    // Explicitly 0'ed bits
+    let mut a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b00000000]));
+    let b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
+    a.difference_with(&b);
+    assert!(a.is_empty());
+
+    // Uninitialized bits should behave like 0's
+    let mut a = BitSet::new();
+    let b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b11111111]));
+    a.difference_with(&b);
+    assert!(a.is_empty());
+
+    // Standard
+    let mut a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
+    let mut b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01100010]));
+    let c = a.clone();
+    a.difference_with(&b);
+    b.difference_with(&c);
+    assert_eq!(a.len(), 1);
+    assert_eq!(b.len(), 1);
+}
+
+#[test]
+fn test_bit_set_symmetric_difference_with() {
+    //a should grow to include larger elements
+    let mut a = BitSet::new();
+    a.insert(0);
+    a.insert(1);
+    let mut b = BitSet::new();
+    b.insert(1);
+    b.insert(5);
+    let expected = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10000100]));
+    a.symmetric_difference_with(&b);
+    assert_eq!(a, expected);
+
+    let mut a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
+    let b = BitSet::new();
+    let c = a.clone();
+    a.symmetric_difference_with(&b);
+    assert_eq!(a, c);
+
+    // Standard
+    let mut a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b11100010]));
+    let mut b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101010]));
+    let c = a.clone();
+    a.symmetric_difference_with(&b);
+    b.symmetric_difference_with(&c);
+    assert_eq!(a.len(), 2);
+    assert_eq!(b.len(), 2);
+}
+
+#[test]
+fn test_bit_set_eq() {
+    let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
+    let b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b00000000]));
+    let c = BitSet::new();
+
+    assert!(a == a);
+    assert!(a != b);
+    assert!(a != c);
+    assert!(b == b);
+    assert!(b == c);
+    assert!(c == c);
+}
+
+#[test]
+fn test_bit_set_cmp() {
+    let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
+    let b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b00000000]));
+    let c = BitSet::new();
+
+    assert_eq!(a.cmp(&b), Greater);
+    assert_eq!(a.cmp(&c), Greater);
+    assert_eq!(b.cmp(&a), Less);
+    assert_eq!(b.cmp(&c), Equal);
+    assert_eq!(c.cmp(&a), Less);
+    assert_eq!(c.cmp(&b), Equal);
+}
+
+#[test]
+fn test_bit_vec_remove() {
+    let mut a = BitSet::new();
+
+    assert!(a.insert(1));
+    assert!(a.remove(&1));
+
+    assert!(a.insert(100));
+    assert!(a.remove(&100));
+
+    assert!(a.insert(1000));
+    assert!(a.remove(&1000));
+    a.shrink_to_fit();
+}
+
+#[test]
+fn test_bit_vec_clone() {
+    let mut a = BitSet::new();
+
+    assert!(a.insert(1));
+    assert!(a.insert(100));
+    assert!(a.insert(1000));
+
+    let mut b = a.clone();
+
+    assert!(a == b);
+
+    assert!(b.remove(&1));
+    assert!(a.contains(&1));
+
+    assert!(a.remove(&1000));
+    assert!(b.contains(&1000));
+}
+
+mod bench {
+    use std::collections::{BitSet, BitVec};
+    use std::rand::{Rng, self};
+    use std::u32;
+
+    use test::{Bencher, black_box};
+
+    const BENCH_BITS : usize = 1 << 14;
+
+    fn rng() -> rand::IsaacRng {
+        let seed: &[_] = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
+        rand::SeedableRng::from_seed(seed)
+    }
+
+    #[bench]
+    fn bench_bit_vecset_small(b: &mut Bencher) {
+        let mut r = rng();
+        let mut bit_vec = BitSet::new();
+        b.iter(|| {
+            for _ in 0..100 {
+                bit_vec.insert((r.next_u32() as usize) % u32::BITS as usize);
+            }
+            black_box(&bit_vec);
+        });
+    }
+
+    #[bench]
+    fn bench_bit_vecset_big(b: &mut Bencher) {
+        let mut r = rng();
+        let mut bit_vec = BitSet::new();
+        b.iter(|| {
+            for _ in 0..100 {
+                bit_vec.insert((r.next_u32() as usize) % BENCH_BITS);
+            }
+            black_box(&bit_vec);
+        });
+    }
+
+    #[bench]
+    fn bench_bit_vecset_iter(b: &mut Bencher) {
+        let bit_vec = BitSet::from_bit_vec(BitVec::from_fn(BENCH_BITS,
+                                              |idx| {idx % 3 == 0}));
+        b.iter(|| {
+            let mut sum = 0;
+            for idx in &bit_vec {
+                sum += idx as usize;
+            }
+            sum
+        })
+    }
+}
diff --git a/src/libcollectionstest/bit/vec.rs b/src/libcollectionstest/bit/vec.rs
new file mode 100644
index 00000000000..3826974d1ad
--- /dev/null
+++ b/src/libcollectionstest/bit/vec.rs
@@ -0,0 +1,729 @@
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::collections::BitVec;
+use std::u32;
+
+#[test]
+fn test_to_str() {
+    let zerolen = BitVec::new();
+    assert_eq!(format!("{:?}", zerolen), "");
+
+    let eightbits = BitVec::from_elem(8, false);
+    assert_eq!(format!("{:?}", eightbits), "00000000")
+}
+
+#[test]
+fn test_0_elements() {
+    let act = BitVec::new();
+    let exp = Vec::new();
+    assert!(act.eq_vec(&exp));
+    assert!(act.none() && act.all());
+}
+
+#[test]
+fn test_1_element() {
+    let mut act = BitVec::from_elem(1, false);
+    assert!(act.eq_vec(&[false]));
+    assert!(act.none() && !act.all());
+    act = BitVec::from_elem(1, true);
+    assert!(act.eq_vec(&[true]));
+    assert!(!act.none() && act.all());
+}
+
+#[test]
+fn test_2_elements() {
+    let mut b = BitVec::from_elem(2, false);
+    b.set(0, true);
+    b.set(1, false);
+    assert_eq!(format!("{:?}", b), "10");
+    assert!(!b.none() && !b.all());
+}
+
+#[test]
+fn test_10_elements() {
+    let mut act;
+    // all 0
+
+    act = BitVec::from_elem(10, false);
+    assert!((act.eq_vec(
+                &[false, false, false, false, false, false, false, false, false, false])));
+    assert!(act.none() && !act.all());
+    // all 1
+
+    act = BitVec::from_elem(10, true);
+    assert!((act.eq_vec(&[true, true, true, true, true, true, true, true, true, true])));
+    assert!(!act.none() && act.all());
+    // mixed
+
+    act = BitVec::from_elem(10, false);
+    act.set(0, true);
+    act.set(1, true);
+    act.set(2, true);
+    act.set(3, true);
+    act.set(4, true);
+    assert!((act.eq_vec(&[true, true, true, true, true, false, false, false, false, false])));
+    assert!(!act.none() && !act.all());
+    // mixed
+
+    act = BitVec::from_elem(10, false);
+    act.set(5, true);
+    act.set(6, true);
+    act.set(7, true);
+    act.set(8, true);
+    act.set(9, true);
+    assert!((act.eq_vec(&[false, false, false, false, false, true, true, true, true, true])));
+    assert!(!act.none() && !act.all());
+    // mixed
+
+    act = BitVec::from_elem(10, false);
+    act.set(0, true);
+    act.set(3, true);
+    act.set(6, true);
+    act.set(9, true);
+    assert!((act.eq_vec(&[true, false, false, true, false, false, true, false, false, true])));
+    assert!(!act.none() && !act.all());
+}
+
+#[test]
+fn test_31_elements() {
+    let mut act;
+    // all 0
+
+    act = BitVec::from_elem(31, false);
+    assert!(act.eq_vec(
+            &[false, false, false, false, false, false, false, false, false, false, false,
+              false, false, false, false, false, false, false, false, false, false, false,
+              false, false, false, false, false, false, false, false, false]));
+    assert!(act.none() && !act.all());
+    // all 1
+
+    act = BitVec::from_elem(31, true);
+    assert!(act.eq_vec(
+            &[true, true, true, true, true, true, true, true, true, true, true, true, true,
+              true, true, true, true, true, true, true, true, true, true, true, true, true,
+              true, true, true, true, true]));
+    assert!(!act.none() && act.all());
+    // mixed
+
+    act = BitVec::from_elem(31, false);
+    act.set(0, true);
+    act.set(1, true);
+    act.set(2, true);
+    act.set(3, true);
+    act.set(4, true);
+    act.set(5, true);
+    act.set(6, true);
+    act.set(7, true);
+    assert!(act.eq_vec(
+            &[true, true, true, true, true, true, true, true, false, false, false, false, false,
+              false, false, false, false, false, false, false, false, false, false, false,
+              false, false, false, false, false, false, false]));
+    assert!(!act.none() && !act.all());
+    // mixed
+
+    act = BitVec::from_elem(31, false);
+    act.set(16, true);
+    act.set(17, true);
+    act.set(18, true);
+    act.set(19, true);
+    act.set(20, true);
+    act.set(21, true);
+    act.set(22, true);
+    act.set(23, true);
+    assert!(act.eq_vec(
+            &[false, false, false, false, false, false, false, false, false, false, false,
+              false, false, false, false, false, true, true, true, true, true, true, true, true,
+              false, false, false, false, false, false, false]));
+    assert!(!act.none() && !act.all());
+    // mixed
+
+    act = BitVec::from_elem(31, false);
+    act.set(24, true);
+    act.set(25, true);
+    act.set(26, true);
+    act.set(27, true);
+    act.set(28, true);
+    act.set(29, true);
+    act.set(30, true);
+    assert!(act.eq_vec(
+            &[false, false, false, false, false, false, false, false, false, false, false,
+              false, false, false, false, false, false, false, false, false, false, false,
+              false, false, true, true, true, true, true, true, true]));
+    assert!(!act.none() && !act.all());
+    // mixed
+
+    act = BitVec::from_elem(31, false);
+    act.set(3, true);
+    act.set(17, true);
+    act.set(30, true);
+    assert!(act.eq_vec(
+            &[false, false, false, true, false, false, false, false, false, false, false, false,
+              false, false, false, false, false, true, false, false, false, false, false, false,
+              false, false, false, false, false, false, true]));
+    assert!(!act.none() && !act.all());
+}
+
+#[test]
+fn test_32_elements() {
+    let mut act;
+    // all 0
+
+    act = BitVec::from_elem(32, false);
+    assert!(act.eq_vec(
+            &[false, false, false, false, false, false, false, false, false, false, false,
+              false, false, false, false, false, false, false, false, false, false, false,
+              false, false, false, false, false, false, false, false, false, false]));
+    assert!(act.none() && !act.all());
+    // all 1
+
+    act = BitVec::from_elem(32, true);
+    assert!(act.eq_vec(
+            &[true, true, true, true, true, true, true, true, true, true, true, true, true,
+              true, true, true, true, true, true, true, true, true, true, true, true, true,
+              true, true, true, true, true, true]));
+    assert!(!act.none() && act.all());
+    // mixed
+
+    act = BitVec::from_elem(32, false);
+    act.set(0, true);
+    act.set(1, true);
+    act.set(2, true);
+    act.set(3, true);
+    act.set(4, true);
+    act.set(5, true);
+    act.set(6, true);
+    act.set(7, true);
+    assert!(act.eq_vec(
+            &[true, true, true, true, true, true, true, true, false, false, false, false, false,
+              false, false, false, false, false, false, false, false, false, false, false,
+              false, false, false, false, false, false, false, false]));
+    assert!(!act.none() && !act.all());
+    // mixed
+
+    act = BitVec::from_elem(32, false);
+    act.set(16, true);
+    act.set(17, true);
+    act.set(18, true);
+    act.set(19, true);
+    act.set(20, true);
+    act.set(21, true);
+    act.set(22, true);
+    act.set(23, true);
+    assert!(act.eq_vec(
+            &[false, false, false, false, false, false, false, false, false, false, false,
+              false, false, false, false, false, true, true, true, true, true, true, true, true,
+              false, false, false, false, false, false, false, false]));
+    assert!(!act.none() && !act.all());
+    // mixed
+
+    act = BitVec::from_elem(32, false);
+    act.set(24, true);
+    act.set(25, true);
+    act.set(26, true);
+    act.set(27, true);
+    act.set(28, true);
+    act.set(29, true);
+    act.set(30, true);
+    act.set(31, true);
+    assert!(act.eq_vec(
+            &[false, false, false, false, false, false, false, false, false, false, false,
+              false, false, false, false, false, false, false, false, false, false, false,
+              false, false, true, true, true, true, true, true, true, true]));
+    assert!(!act.none() && !act.all());
+    // mixed
+
+    act = BitVec::from_elem(32, false);
+    act.set(3, true);
+    act.set(17, true);
+    act.set(30, true);
+    act.set(31, true);
+    assert!(act.eq_vec(
+            &[false, false, false, true, false, false, false, false, false, false, false, false,
+              false, false, false, false, false, true, false, false, false, false, false, false,
+              false, false, false, false, false, false, true, true]));
+    assert!(!act.none() && !act.all());
+}
+
+#[test]
+fn test_33_elements() {
+    let mut act;
+    // all 0
+
+    act = BitVec::from_elem(33, false);
+    assert!(act.eq_vec(
+            &[false, false, false, false, false, false, false, false, false, false, false,
+              false, false, false, false, false, false, false, false, false, false, false,
+              false, false, false, false, false, false, false, false, false, false, false]));
+    assert!(act.none() && !act.all());
+    // all 1
+
+    act = BitVec::from_elem(33, true);
+    assert!(act.eq_vec(
+            &[true, true, true, true, true, true, true, true, true, true, true, true, true,
+              true, true, true, true, true, true, true, true, true, true, true, true, true,
+              true, true, true, true, true, true, true]));
+    assert!(!act.none() && act.all());
+    // mixed
+
+    act = BitVec::from_elem(33, false);
+    act.set(0, true);
+    act.set(1, true);
+    act.set(2, true);
+    act.set(3, true);
+    act.set(4, true);
+    act.set(5, true);
+    act.set(6, true);
+    act.set(7, true);
+    assert!(act.eq_vec(
+            &[true, true, true, true, true, true, true, true, false, false, false, false, false,
+              false, false, false, false, false, false, false, false, false, false, false,
+              false, false, false, false, false, false, false, false, false]));
+    assert!(!act.none() && !act.all());
+    // mixed
+
+    act = BitVec::from_elem(33, false);
+    act.set(16, true);
+    act.set(17, true);
+    act.set(18, true);
+    act.set(19, true);
+    act.set(20, true);
+    act.set(21, true);
+    act.set(22, true);
+    act.set(23, true);
+    assert!(act.eq_vec(
+            &[false, false, false, false, false, false, false, false, false, false, false,
+              false, false, false, false, false, true, true, true, true, true, true, true, true,
+              false, false, false, false, false, false, false, false, false]));
+    assert!(!act.none() && !act.all());
+    // mixed
+
+    act = BitVec::from_elem(33, false);
+    act.set(24, true);
+    act.set(25, true);
+    act.set(26, true);
+    act.set(27, true);
+    act.set(28, true);
+    act.set(29, true);
+    act.set(30, true);
+    act.set(31, true);
+    assert!(act.eq_vec(
+            &[false, false, false, false, false, false, false, false, false, false, false,
+              false, false, false, false, false, false, false, false, false, false, false,
+              false, false, true, true, true, true, true, true, true, true, false]));
+    assert!(!act.none() && !act.all());
+    // mixed
+
+    act = BitVec::from_elem(33, false);
+    act.set(3, true);
+    act.set(17, true);
+    act.set(30, true);
+    act.set(31, true);
+    act.set(32, true);
+    assert!(act.eq_vec(
+            &[false, false, false, true, false, false, false, false, false, false, false, false,
+              false, false, false, false, false, true, false, false, false, false, false, false,
+              false, false, false, false, false, false, true, true, true]));
+    assert!(!act.none() && !act.all());
+}
+
+#[test]
+fn test_equal_differing_sizes() {
+    let v0 = BitVec::from_elem(10, false);
+    let v1 = BitVec::from_elem(11, false);
+    assert!(v0 != v1);
+}
+
+#[test]
+fn test_equal_greatly_differing_sizes() {
+    let v0 = BitVec::from_elem(10, false);
+    let v1 = BitVec::from_elem(110, false);
+    assert!(v0 != v1);
+}
+
+#[test]
+fn test_equal_sneaky_small() {
+    let mut a = BitVec::from_elem(1, false);
+    a.set(0, true);
+
+    let mut b = BitVec::from_elem(1, true);
+    b.set(0, true);
+
+    assert_eq!(a, b);
+}
+
+#[test]
+fn test_equal_sneaky_big() {
+    let mut a = BitVec::from_elem(100, false);
+    for i in 0..100 {
+        a.set(i, true);
+    }
+
+    let mut b = BitVec::from_elem(100, true);
+    for i in 0..100 {
+        b.set(i, true);
+    }
+
+    assert_eq!(a, b);
+}
+
+#[test]
+fn test_from_bytes() {
+    let bit_vec = BitVec::from_bytes(&[0b10110110, 0b00000000, 0b11111111]);
+    let str = concat!("10110110", "00000000", "11111111");
+    assert_eq!(format!("{:?}", bit_vec), str);
+}
+
+#[test]
+fn test_to_bytes() {
+    let mut bv = BitVec::from_elem(3, true);
+    bv.set(1, false);
+    assert_eq!(bv.to_bytes(), [0b10100000]);
+
+    let mut bv = BitVec::from_elem(9, false);
+    bv.set(2, true);
+    bv.set(8, true);
+    assert_eq!(bv.to_bytes(), [0b00100000, 0b10000000]);
+}
+
+#[test]
+fn test_from_bools() {
+    let bools = vec![true, false, true, true];
+    let bit_vec: BitVec = bools.iter().map(|n| *n).collect();
+    assert_eq!(format!("{:?}", bit_vec), "1011");
+}
+
+#[test]
+fn test_to_bools() {
+    let bools = vec![false, false, true, false, false, true, true, false];
+    assert_eq!(BitVec::from_bytes(&[0b00100110]).iter().collect::<Vec<bool>>(), bools);
+}
+
+#[test]
+fn test_bit_vec_iterator() {
+    let bools = vec![true, false, true, true];
+    let bit_vec: BitVec = bools.iter().map(|n| *n).collect();
+
+    assert_eq!(bit_vec.iter().collect::<Vec<bool>>(), bools);
+
+    let long: Vec<_> = (0..10000).map(|i| i % 2 == 0).collect();
+    let bit_vec: BitVec = long.iter().map(|n| *n).collect();
+    assert_eq!(bit_vec.iter().collect::<Vec<bool>>(), long)
+}
+
+#[test]
+fn test_small_difference() {
+    let mut b1 = BitVec::from_elem(3, false);
+    let mut b2 = BitVec::from_elem(3, false);
+    b1.set(0, true);
+    b1.set(1, true);
+    b2.set(1, true);
+    b2.set(2, true);
+    assert!(b1.difference(&b2));
+    assert!(b1[0]);
+    assert!(!b1[1]);
+    assert!(!b1[2]);
+}
+
+#[test]
+fn test_big_difference() {
+    let mut b1 = BitVec::from_elem(100, false);
+    let mut b2 = BitVec::from_elem(100, false);
+    b1.set(0, true);
+    b1.set(40, true);
+    b2.set(40, true);
+    b2.set(80, true);
+    assert!(b1.difference(&b2));
+    assert!(b1[0]);
+    assert!(!b1[40]);
+    assert!(!b1[80]);
+}
+
+#[test]
+fn test_small_clear() {
+    let mut b = BitVec::from_elem(14, true);
+    assert!(!b.none() && b.all());
+    b.clear();
+    assert!(b.none() && !b.all());
+}
+
+#[test]
+fn test_big_clear() {
+    let mut b = BitVec::from_elem(140, true);
+    assert!(!b.none() && b.all());
+    b.clear();
+    assert!(b.none() && !b.all());
+}
+
+#[test]
+fn test_bit_vec_lt() {
+    let mut a = BitVec::from_elem(5, false);
+    let mut b = BitVec::from_elem(5, false);
+
+    assert!(!(a < b) && !(b < a));
+    b.set(2, true);
+    assert!(a < b);
+    a.set(3, true);
+    assert!(a < b);
+    a.set(2, true);
+    assert!(!(a < b) && b < a);
+    b.set(0, true);
+    assert!(a < b);
+}
+
+#[test]
+fn test_ord() {
+    let mut a = BitVec::from_elem(5, false);
+    let mut b = BitVec::from_elem(5, false);
+
+    assert!(a <= b && a >= b);
+    a.set(1, true);
+    assert!(a > b && a >= b);
+    assert!(b < a && b <= a);
+    b.set(1, true);
+    b.set(2, true);
+    assert!(b > a && b >= a);
+    assert!(a < b && a <= b);
+}
+
+
+#[test]
+fn test_small_bit_vec_tests() {
+    let v = BitVec::from_bytes(&[0]);
+    assert!(!v.all());
+    assert!(!v.any());
+    assert!(v.none());
+
+    let v = BitVec::from_bytes(&[0b00010100]);
+    assert!(!v.all());
+    assert!(v.any());
+    assert!(!v.none());
+
+    let v = BitVec::from_bytes(&[0xFF]);
+    assert!(v.all());
+    assert!(v.any());
+    assert!(!v.none());
+}
+
+#[test]
+fn test_big_bit_vec_tests() {
+    let v = BitVec::from_bytes(&[ // 88 bits
+        0, 0, 0, 0,
+        0, 0, 0, 0,
+        0, 0, 0]);
+    assert!(!v.all());
+    assert!(!v.any());
+    assert!(v.none());
+
+    let v = BitVec::from_bytes(&[ // 88 bits
+        0, 0, 0b00010100, 0,
+        0, 0, 0, 0b00110100,
+        0, 0, 0]);
+    assert!(!v.all());
+    assert!(v.any());
+    assert!(!v.none());
+
+    let v = BitVec::from_bytes(&[ // 88 bits
+        0xFF, 0xFF, 0xFF, 0xFF,
+        0xFF, 0xFF, 0xFF, 0xFF,
+        0xFF, 0xFF, 0xFF]);
+    assert!(v.all());
+    assert!(v.any());
+    assert!(!v.none());
+}
+
+#[test]
+fn test_bit_vec_push_pop() {
+    let mut s = BitVec::from_elem(5 * u32::BITS as usize - 2, false);
+    assert_eq!(s.len(), 5 * u32::BITS as usize - 2);
+    assert_eq!(s[5 * u32::BITS as usize - 3], false);
+    s.push(true);
+    s.push(true);
+    assert_eq!(s[5 * u32::BITS as usize - 2], true);
+    assert_eq!(s[5 * u32::BITS as usize - 1], true);
+    // Here the internal vector will need to be extended
+    s.push(false);
+    assert_eq!(s[5 * u32::BITS as usize], false);
+    s.push(false);
+    assert_eq!(s[5 * u32::BITS as usize + 1], false);
+    assert_eq!(s.len(), 5 * u32::BITS as usize + 2);
+    // Pop it all off
+    assert_eq!(s.pop(), Some(false));
+    assert_eq!(s.pop(), Some(false));
+    assert_eq!(s.pop(), Some(true));
+    assert_eq!(s.pop(), Some(true));
+    assert_eq!(s.len(), 5 * u32::BITS as usize - 2);
+}
+
+#[test]
+fn test_bit_vec_truncate() {
+    let mut s = BitVec::from_elem(5 * u32::BITS as usize, true);
+
+    assert_eq!(s, BitVec::from_elem(5 * u32::BITS as usize, true));
+    assert_eq!(s.len(), 5 * u32::BITS as usize);
+    s.truncate(4 * u32::BITS as usize);
+    assert_eq!(s, BitVec::from_elem(4 * u32::BITS as usize, true));
+    assert_eq!(s.len(), 4 * u32::BITS as usize);
+    // Truncating to a size > s.len() should be a noop
+    s.truncate(5 * u32::BITS as usize);
+    assert_eq!(s, BitVec::from_elem(4 * u32::BITS as usize, true));
+    assert_eq!(s.len(), 4 * u32::BITS as usize);
+    s.truncate(3 * u32::BITS as usize - 10);
+    assert_eq!(s, BitVec::from_elem(3 * u32::BITS as usize - 10, true));
+    assert_eq!(s.len(), 3 * u32::BITS as usize - 10);
+    s.truncate(0);
+    assert_eq!(s, BitVec::from_elem(0, true));
+    assert_eq!(s.len(), 0);
+}
+
+#[test]
+fn test_bit_vec_reserve() {
+    let mut s = BitVec::from_elem(5 * u32::BITS as usize, true);
+    // Check capacity
+    assert!(s.capacity() >= 5 * u32::BITS as usize);
+    s.reserve(2 * u32::BITS as usize);
+    assert!(s.capacity() >= 7 * u32::BITS as usize);
+    s.reserve(7 * u32::BITS as usize);
+    assert!(s.capacity() >= 12 * u32::BITS as usize);
+    s.reserve_exact(7 * u32::BITS as usize);
+    assert!(s.capacity() >= 12 * u32::BITS as usize);
+    s.reserve(7 * u32::BITS as usize + 1);
+    assert!(s.capacity() >= 12 * u32::BITS as usize + 1);
+    // Check that length hasn't changed
+    assert_eq!(s.len(), 5 * u32::BITS as usize);
+    s.push(true);
+    s.push(false);
+    s.push(true);
+    assert_eq!(s[5 * u32::BITS as usize - 1], true);
+    assert_eq!(s[5 * u32::BITS as usize - 0], true);
+    assert_eq!(s[5 * u32::BITS as usize + 1], false);
+    assert_eq!(s[5 * u32::BITS as usize + 2], true);
+}
+
+#[test]
+fn test_bit_vec_grow() {
+    let mut bit_vec = BitVec::from_bytes(&[0b10110110, 0b00000000, 0b10101010]);
+    bit_vec.grow(32, true);
+    assert_eq!(bit_vec, BitVec::from_bytes(&[0b10110110, 0b00000000, 0b10101010,
+                                 0xFF, 0xFF, 0xFF, 0xFF]));
+    bit_vec.grow(64, false);
+    assert_eq!(bit_vec, BitVec::from_bytes(&[0b10110110, 0b00000000, 0b10101010,
+                                 0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0]));
+    bit_vec.grow(16, true);
+    assert_eq!(bit_vec, BitVec::from_bytes(&[0b10110110, 0b00000000, 0b10101010,
+                                 0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF]));
+}
+
+#[test]
+fn test_bit_vec_extend() {
+    let mut bit_vec = BitVec::from_bytes(&[0b10110110, 0b00000000, 0b11111111]);
+    let ext = BitVec::from_bytes(&[0b01001001, 0b10010010, 0b10111101]);
+    bit_vec.extend(ext.iter());
+    assert_eq!(bit_vec, BitVec::from_bytes(&[0b10110110, 0b00000000, 0b11111111,
+                                 0b01001001, 0b10010010, 0b10111101]));
+}
+
+mod bench {
+    use std::collections::BitVec;
+    use std::u32;
+    use std::rand::{Rng, self};
+
+    use test::{Bencher, black_box};
+
+    const BENCH_BITS : usize = 1 << 14;
+
+    fn rng() -> rand::IsaacRng {
+        let seed: &[_] = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
+        rand::SeedableRng::from_seed(seed)
+    }
+
+    #[bench]
+    fn bench_usize_small(b: &mut Bencher) {
+        let mut r = rng();
+        let mut bit_vec = 0 as usize;
+        b.iter(|| {
+            for _ in 0..100 {
+                bit_vec |= 1 << ((r.next_u32() as usize) % u32::BITS as usize);
+            }
+            black_box(&bit_vec);
+        });
+    }
+
+    #[bench]
+    fn bench_bit_set_big_fixed(b: &mut Bencher) {
+        let mut r = rng();
+        let mut bit_vec = BitVec::from_elem(BENCH_BITS, false);
+        b.iter(|| {
+            for _ in 0..100 {
+                bit_vec.set((r.next_u32() as usize) % BENCH_BITS, true);
+            }
+            black_box(&bit_vec);
+        });
+    }
+
+    #[bench]
+    fn bench_bit_set_big_variable(b: &mut Bencher) {
+        let mut r = rng();
+        let mut bit_vec = BitVec::from_elem(BENCH_BITS, false);
+        b.iter(|| {
+            for _ in 0..100 {
+                bit_vec.set((r.next_u32() as usize) % BENCH_BITS, r.gen());
+            }
+            black_box(&bit_vec);
+        });
+    }
+
+    #[bench]
+    fn bench_bit_set_small(b: &mut Bencher) {
+        let mut r = rng();
+        let mut bit_vec = BitVec::from_elem(u32::BITS as usize, false);
+        b.iter(|| {
+            for _ in 0..100 {
+                bit_vec.set((r.next_u32() as usize) % u32::BITS as usize, true);
+            }
+            black_box(&bit_vec);
+        });
+    }
+
+    #[bench]
+    fn bench_bit_vec_big_union(b: &mut Bencher) {
+        let mut b1 = BitVec::from_elem(BENCH_BITS, false);
+        let b2 = BitVec::from_elem(BENCH_BITS, false);
+        b.iter(|| {
+            b1.union(&b2)
+        })
+    }
+
+    #[bench]
+    fn bench_bit_vec_small_iter(b: &mut Bencher) {
+        let bit_vec = BitVec::from_elem(u32::BITS as usize, false);
+        b.iter(|| {
+            let mut sum = 0;
+            for _ in 0..10 {
+                for pres in &bit_vec {
+                    sum += pres as usize;
+                }
+            }
+            sum
+        })
+    }
+
+    #[bench]
+    fn bench_bit_vec_big_iter(b: &mut Bencher) {
+        let bit_vec = BitVec::from_elem(BENCH_BITS, false);
+        b.iter(|| {
+            let mut sum = 0;
+            for pres in &bit_vec {
+                sum += pres as usize;
+            }
+            sum
+        })
+    }
+}
diff --git a/src/libcollectionstest/btree/map.rs b/src/libcollectionstest/btree/map.rs
new file mode 100644
index 00000000000..10d69c9f5ec
--- /dev/null
+++ b/src/libcollectionstest/btree/map.rs
@@ -0,0 +1,299 @@
+// 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::collections::BTreeMap;
+use std::collections::Bound::{Excluded, Included, Unbounded, self};
+use std::collections::btree_map::Entry::{Occupied, Vacant};
+use std::iter::range_inclusive;
+
+#[test]
+fn test_basic_large() {
+    let mut map = BTreeMap::new();
+    let size = 10000;
+    assert_eq!(map.len(), 0);
+
+    for i in 0..size {
+        assert_eq!(map.insert(i, 10*i), None);
+        assert_eq!(map.len(), i + 1);
+    }
+
+    for i in 0..size {
+        assert_eq!(map.get(&i).unwrap(), &(i*10));
+    }
+
+    for i in size..size*2 {
+        assert_eq!(map.get(&i), None);
+    }
+
+    for i in 0..size {
+        assert_eq!(map.insert(i, 100*i), Some(10*i));
+        assert_eq!(map.len(), size);
+    }
+
+    for i in 0..size {
+        assert_eq!(map.get(&i).unwrap(), &(i*100));
+    }
+
+    for i in 0..size/2 {
+        assert_eq!(map.remove(&(i*2)), Some(i*200));
+        assert_eq!(map.len(), size - i - 1);
+    }
+
+    for i in 0..size/2 {
+        assert_eq!(map.get(&(2*i)), None);
+        assert_eq!(map.get(&(2*i+1)).unwrap(), &(i*200 + 100));
+    }
+
+    for i in 0..size/2 {
+        assert_eq!(map.remove(&(2*i)), None);
+        assert_eq!(map.remove(&(2*i+1)), Some(i*200 + 100));
+        assert_eq!(map.len(), size/2 - i - 1);
+    }
+}
+
+#[test]
+fn test_basic_small() {
+    let mut map = BTreeMap::new();
+    assert_eq!(map.remove(&1), None);
+    assert_eq!(map.get(&1), None);
+    assert_eq!(map.insert(1, 1), None);
+    assert_eq!(map.get(&1), Some(&1));
+    assert_eq!(map.insert(1, 2), Some(1));
+    assert_eq!(map.get(&1), Some(&2));
+    assert_eq!(map.insert(2, 4), None);
+    assert_eq!(map.get(&2), Some(&4));
+    assert_eq!(map.remove(&1), Some(2));
+    assert_eq!(map.remove(&2), Some(4));
+    assert_eq!(map.remove(&1), None);
+}
+
+#[test]
+fn test_iter() {
+    let size = 10000;
+
+    // Forwards
+    let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
+
+    fn test<T>(size: usize, mut iter: T) where T: Iterator<Item=(usize, usize)> {
+        for i in 0..size {
+            assert_eq!(iter.size_hint(), (size - i, Some(size - i)));
+            assert_eq!(iter.next().unwrap(), (i, i));
+        }
+        assert_eq!(iter.size_hint(), (0, Some(0)));
+        assert_eq!(iter.next(), None);
+    }
+    test(size, map.iter().map(|(&k, &v)| (k, v)));
+    test(size, map.iter_mut().map(|(&k, &mut v)| (k, v)));
+    test(size, map.into_iter());
+}
+
+#[test]
+fn test_iter_rev() {
+    let size = 10000;
+
+    // Forwards
+    let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
+
+    fn test<T>(size: usize, mut iter: T) where T: Iterator<Item=(usize, usize)> {
+        for i in 0..size {
+            assert_eq!(iter.size_hint(), (size - i, Some(size - i)));
+            assert_eq!(iter.next().unwrap(), (size - i - 1, size - i - 1));
+        }
+        assert_eq!(iter.size_hint(), (0, Some(0)));
+        assert_eq!(iter.next(), None);
+    }
+    test(size, map.iter().rev().map(|(&k, &v)| (k, v)));
+    test(size, map.iter_mut().rev().map(|(&k, &mut v)| (k, v)));
+    test(size, map.into_iter().rev());
+}
+
+#[test]
+fn test_iter_mixed() {
+    let size = 10000;
+
+    // Forwards
+    let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
+
+    fn test<T>(size: usize, mut iter: T)
+            where T: Iterator<Item=(usize, usize)> + DoubleEndedIterator {
+        for i in 0..size / 4 {
+            assert_eq!(iter.size_hint(), (size - i * 2, Some(size - i * 2)));
+            assert_eq!(iter.next().unwrap(), (i, i));
+            assert_eq!(iter.next_back().unwrap(), (size - i - 1, size - i - 1));
+        }
+        for i in size / 4..size * 3 / 4 {
+            assert_eq!(iter.size_hint(), (size * 3 / 4 - i, Some(size * 3 / 4 - i)));
+            assert_eq!(iter.next().unwrap(), (i, i));
+        }
+        assert_eq!(iter.size_hint(), (0, Some(0)));
+        assert_eq!(iter.next(), None);
+    }
+    test(size, map.iter().map(|(&k, &v)| (k, v)));
+    test(size, map.iter_mut().map(|(&k, &mut v)| (k, v)));
+    test(size, map.into_iter());
+}
+
+#[test]
+fn test_range_small() {
+    let size = 5;
+
+    // Forwards
+    let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
+
+    let mut j = 0;
+    for ((&k, &v), i) in map.range(Included(&2), Unbounded).zip(2..size) {
+        assert_eq!(k, i);
+        assert_eq!(v, i);
+        j += 1;
+    }
+    assert_eq!(j, size - 2);
+}
+
+#[test]
+fn test_range_1000() {
+    let size = 1000;
+    let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
+
+    fn test(map: &BTreeMap<u32, u32>, size: u32, min: Bound<&u32>, max: Bound<&u32>) {
+        let mut kvs = map.range(min, max).map(|(&k, &v)| (k, v));
+        let mut pairs = (0..size).map(|i| (i, i));
+
+        for (kv, pair) in kvs.by_ref().zip(pairs.by_ref()) {
+            assert_eq!(kv, pair);
+        }
+        assert_eq!(kvs.next(), None);
+        assert_eq!(pairs.next(), None);
+    }
+    test(&map, size, Included(&0), Excluded(&size));
+    test(&map, size, Unbounded, Excluded(&size));
+    test(&map, size, Included(&0), Included(&(size - 1)));
+    test(&map, size, Unbounded, Included(&(size - 1)));
+    test(&map, size, Included(&0), Unbounded);
+    test(&map, size, Unbounded, Unbounded);
+}
+
+#[test]
+fn test_range() {
+    let size = 200;
+    let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
+
+    for i in 0..size {
+        for j in i..size {
+            let mut kvs = map.range(Included(&i), Included(&j)).map(|(&k, &v)| (k, v));
+            let mut pairs = range_inclusive(i, j).map(|i| (i, i));
+
+            for (kv, pair) in kvs.by_ref().zip(pairs.by_ref()) {
+                assert_eq!(kv, pair);
+            }
+            assert_eq!(kvs.next(), None);
+            assert_eq!(pairs.next(), None);
+        }
+    }
+}
+
+#[test]
+fn test_entry(){
+    let xs = [(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)];
+
+    let mut map: BTreeMap<_, _> = xs.iter().cloned().collect();
+
+    // Existing key (insert)
+    match map.entry(1) {
+        Vacant(_) => unreachable!(),
+        Occupied(mut view) => {
+            assert_eq!(view.get(), &10);
+            assert_eq!(view.insert(100), 10);
+        }
+    }
+    assert_eq!(map.get(&1).unwrap(), &100);
+    assert_eq!(map.len(), 6);
+
+
+    // Existing key (update)
+    match map.entry(2) {
+        Vacant(_) => unreachable!(),
+        Occupied(mut view) => {
+            let v = view.get_mut();
+            *v *= 10;
+        }
+    }
+    assert_eq!(map.get(&2).unwrap(), &200);
+    assert_eq!(map.len(), 6);
+
+    // Existing key (take)
+    match map.entry(3) {
+        Vacant(_) => unreachable!(),
+        Occupied(view) => {
+            assert_eq!(view.remove(), 30);
+        }
+    }
+    assert_eq!(map.get(&3), None);
+    assert_eq!(map.len(), 5);
+
+
+    // Inexistent key (insert)
+    match map.entry(10) {
+        Occupied(_) => unreachable!(),
+        Vacant(view) => {
+            assert_eq!(*view.insert(1000), 1000);
+        }
+    }
+    assert_eq!(map.get(&10).unwrap(), &1000);
+    assert_eq!(map.len(), 6);
+}
+
+mod bench {
+    use std::collections::BTreeMap;
+    use std::rand::{Rng, weak_rng};
+
+    use test::{Bencher, black_box};
+
+    map_insert_rand_bench!{insert_rand_100,    100,    BTreeMap}
+    map_insert_rand_bench!{insert_rand_10_000, 10_000, BTreeMap}
+
+    map_insert_seq_bench!{insert_seq_100,    100,    BTreeMap}
+    map_insert_seq_bench!{insert_seq_10_000, 10_000, BTreeMap}
+
+    map_find_rand_bench!{find_rand_100,    100,    BTreeMap}
+    map_find_rand_bench!{find_rand_10_000, 10_000, BTreeMap}
+
+    map_find_seq_bench!{find_seq_100,    100,    BTreeMap}
+    map_find_seq_bench!{find_seq_10_000, 10_000, BTreeMap}
+
+    fn bench_iter(b: &mut Bencher, size: i32) {
+        let mut map = BTreeMap::<i32, i32>::new();
+        let mut rng = weak_rng();
+
+        for _ in 0..size {
+            map.insert(rng.gen(), rng.gen());
+        }
+
+        b.iter(|| {
+            for entry in &map {
+                black_box(entry);
+            }
+        });
+    }
+
+    #[bench]
+    pub fn iter_20(b: &mut Bencher) {
+        bench_iter(b, 20);
+    }
+
+    #[bench]
+    pub fn iter_1000(b: &mut Bencher) {
+        bench_iter(b, 1000);
+    }
+
+    #[bench]
+    pub fn iter_100000(b: &mut Bencher) {
+        bench_iter(b, 100000);
+    }
+}
diff --git a/src/libcollectionstest/btree/mod.rs b/src/libcollectionstest/btree/mod.rs
new file mode 100644
index 00000000000..0db48f3ce9e
--- /dev/null
+++ b/src/libcollectionstest/btree/mod.rs
@@ -0,0 +1,12 @@
+// 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 map;
+mod set;
diff --git a/src/libcollectionstest/btree/set.rs b/src/libcollectionstest/btree/set.rs
new file mode 100644
index 00000000000..488f0d756d3
--- /dev/null
+++ b/src/libcollectionstest/btree/set.rs
@@ -0,0 +1,180 @@
+// 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::collections::BTreeSet;
+use std::hash::{SipHasher, self};
+
+#[test]
+fn test_clone_eq() {
+  let mut m = BTreeSet::new();
+
+  m.insert(1);
+  m.insert(2);
+
+  assert!(m.clone() == m);
+}
+
+#[test]
+fn test_hash() {
+  let mut x = BTreeSet::new();
+  let mut y = BTreeSet::new();
+
+  x.insert(1);
+  x.insert(2);
+  x.insert(3);
+
+  y.insert(3);
+  y.insert(2);
+  y.insert(1);
+
+  assert!(hash::hash::<_, SipHasher>(&x) == hash::hash::<_, SipHasher>(&y));
+}
+
+struct Counter<'a, 'b> {
+    i: &'a mut usize,
+    expected: &'b [i32],
+}
+
+impl<'a, 'b, 'c> FnMut<(&'c i32,)> for Counter<'a, 'b> {
+    type Output = bool;
+
+    extern "rust-call" fn call_mut(&mut self, (&x,): (&'c i32,)) -> bool {
+        assert_eq!(x, self.expected[*self.i]);
+        *self.i += 1;
+        true
+    }
+}
+
+fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F) where
+    // FIXME Replace Counter with `Box<FnMut(_) -> _>`
+    F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, Counter) -> bool,
+{
+    let mut set_a = BTreeSet::new();
+    let mut set_b = BTreeSet::new();
+
+    for x in a { assert!(set_a.insert(*x)) }
+    for y in b { assert!(set_b.insert(*y)) }
+
+    let mut i = 0;
+    f(&set_a, &set_b, Counter { i: &mut i, expected: expected });
+    assert_eq!(i, expected.len());
+}
+
+#[test]
+fn test_intersection() {
+    fn check_intersection(a: &[i32], b: &[i32], expected: &[i32]) {
+        check(a, b, expected, |x, y, f| x.intersection(y).all(f))
+    }
+
+    check_intersection(&[], &[], &[]);
+    check_intersection(&[1, 2, 3], &[], &[]);
+    check_intersection(&[], &[1, 2, 3], &[]);
+    check_intersection(&[2], &[1, 2, 3], &[2]);
+    check_intersection(&[1, 2, 3], &[2], &[2]);
+    check_intersection(&[11, 1, 3, 77, 103, 5, -5],
+                       &[2, 11, 77, -9, -42, 5, 3],
+                       &[3, 5, 11, 77]);
+}
+
+#[test]
+fn test_difference() {
+    fn check_difference(a: &[i32], b: &[i32], expected: &[i32]) {
+        check(a, b, expected, |x, y, f| x.difference(y).all(f))
+    }
+
+    check_difference(&[], &[], &[]);
+    check_difference(&[1, 12], &[], &[1, 12]);
+    check_difference(&[], &[1, 2, 3, 9], &[]);
+    check_difference(&[1, 3, 5, 9, 11],
+                     &[3, 9],
+                     &[1, 5, 11]);
+    check_difference(&[-5, 11, 22, 33, 40, 42],
+                     &[-12, -5, 14, 23, 34, 38, 39, 50],
+                     &[11, 22, 33, 40, 42]);
+}
+
+#[test]
+fn test_symmetric_difference() {
+    fn check_symmetric_difference(a: &[i32], b: &[i32], expected: &[i32]) {
+        check(a, b, expected, |x, y, f| x.symmetric_difference(y).all(f))
+    }
+
+    check_symmetric_difference(&[], &[], &[]);
+    check_symmetric_difference(&[1, 2, 3], &[2], &[1, 3]);
+    check_symmetric_difference(&[2], &[1, 2, 3], &[1, 3]);
+    check_symmetric_difference(&[1, 3, 5, 9, 11],
+                               &[-2, 3, 9, 14, 22],
+                               &[-2, 1, 5, 11, 14, 22]);
+}
+
+#[test]
+fn test_union() {
+    fn check_union(a: &[i32], b: &[i32], expected: &[i32]) {
+        check(a, b, expected, |x, y, f| x.union(y).all(f))
+    }
+
+    check_union(&[], &[], &[]);
+    check_union(&[1, 2, 3], &[2], &[1, 2, 3]);
+    check_union(&[2], &[1, 2, 3], &[1, 2, 3]);
+    check_union(&[1, 3, 5, 9, 11, 16, 19, 24],
+                &[-2, 1, 5, 9, 13, 19],
+                &[-2, 1, 3, 5, 9, 11, 13, 16, 19, 24]);
+}
+
+#[test]
+fn test_zip() {
+    let mut x = BTreeSet::new();
+    x.insert(5);
+    x.insert(12);
+    x.insert(11);
+
+    let mut y = BTreeSet::new();
+    y.insert("foo");
+    y.insert("bar");
+
+    let x = x;
+    let y = y;
+    let mut z = x.iter().zip(y.iter());
+
+    // FIXME: #5801: this needs a type hint to compile...
+    let result: Option<(&usize, & &'static str)> = z.next();
+    assert_eq!(result.unwrap(), (&5, &("bar")));
+
+    let result: Option<(&usize, & &'static str)> = z.next();
+    assert_eq!(result.unwrap(), (&11, &("foo")));
+
+    let result: Option<(&usize, & &'static str)> = z.next();
+    assert!(result.is_none());
+}
+
+#[test]
+fn test_from_iter() {
+    let xs = [1, 2, 3, 4, 5, 6, 7, 8, 9];
+
+    let set: BTreeSet<_> = xs.iter().cloned().collect();
+
+    for x in &xs {
+        assert!(set.contains(x));
+    }
+}
+
+#[test]
+fn test_show() {
+    let mut set = BTreeSet::new();
+    let empty = BTreeSet::<i32>::new();
+
+    set.insert(1);
+    set.insert(2);
+
+    let set_str = format!("{:?}", set);
+
+    assert_eq!(set_str, "{1, 2}");
+    assert_eq!(format!("{:?}", empty), "{}");
+}
diff --git a/src/libcollectionstest/enum_set.rs b/src/libcollectionstest/enum_set.rs
new file mode 100644
index 00000000000..f04367147cb
--- /dev/null
+++ b/src/libcollectionstest/enum_set.rs
@@ -0,0 +1,244 @@
+// 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.
+
+use std::mem;
+
+use collections::enum_set::{CLike, EnumSet};
+
+use self::Foo::*;
+
+#[derive(Copy, PartialEq, Debug)]
+#[repr(usize)]
+enum Foo {
+    A, B, C
+}
+
+impl CLike for Foo {
+    fn to_usize(&self) -> usize {
+        *self as usize
+    }
+
+    fn from_usize(v: usize) -> Foo {
+        unsafe { mem::transmute(v) }
+    }
+}
+
+#[test]
+fn test_new() {
+    let e: EnumSet<Foo> = EnumSet::new();
+    assert!(e.is_empty());
+}
+
+#[test]
+fn test_show() {
+    let mut e = EnumSet::new();
+    assert!(format!("{:?}", e) == "{}");
+    e.insert(A);
+    assert!(format!("{:?}", e) == "{A}");
+    e.insert(C);
+    assert!(format!("{:?}", e) == "{A, C}");
+}
+
+#[test]
+fn test_len() {
+    let mut e = EnumSet::new();
+    assert_eq!(e.len(), 0);
+    e.insert(A);
+    e.insert(B);
+    e.insert(C);
+    assert_eq!(e.len(), 3);
+    e.remove(&A);
+    assert_eq!(e.len(), 2);
+    e.clear();
+    assert_eq!(e.len(), 0);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// intersect
+
+#[test]
+fn test_two_empties_do_not_intersect() {
+    let e1: EnumSet<Foo> = EnumSet::new();
+    let e2: EnumSet<Foo> = EnumSet::new();
+    assert!(e1.is_disjoint(&e2));
+}
+
+#[test]
+fn test_empty_does_not_intersect_with_full() {
+    let e1: EnumSet<Foo> = EnumSet::new();
+
+    let mut e2: EnumSet<Foo> = EnumSet::new();
+    e2.insert(A);
+    e2.insert(B);
+    e2.insert(C);
+
+    assert!(e1.is_disjoint(&e2));
+}
+
+#[test]
+fn test_disjoint_intersects() {
+    let mut e1: EnumSet<Foo> = EnumSet::new();
+    e1.insert(A);
+
+    let mut e2: EnumSet<Foo> = EnumSet::new();
+    e2.insert(B);
+
+    assert!(e1.is_disjoint(&e2));
+}
+
+#[test]
+fn test_overlapping_intersects() {
+    let mut e1: EnumSet<Foo> = EnumSet::new();
+    e1.insert(A);
+
+    let mut e2: EnumSet<Foo> = EnumSet::new();
+    e2.insert(A);
+    e2.insert(B);
+
+    assert!(!e1.is_disjoint(&e2));
+}
+
+///////////////////////////////////////////////////////////////////////////
+// contains and contains_elem
+
+#[test]
+fn test_superset() {
+    let mut e1: EnumSet<Foo> = EnumSet::new();
+    e1.insert(A);
+
+    let mut e2: EnumSet<Foo> = EnumSet::new();
+    e2.insert(A);
+    e2.insert(B);
+
+    let mut e3: EnumSet<Foo> = EnumSet::new();
+    e3.insert(C);
+
+    assert!(e1.is_subset(&e2));
+    assert!(e2.is_superset(&e1));
+    assert!(!e3.is_superset(&e2));
+    assert!(!e2.is_superset(&e3))
+}
+
+#[test]
+fn test_contains() {
+    let mut e1: EnumSet<Foo> = EnumSet::new();
+    e1.insert(A);
+    assert!(e1.contains(&A));
+    assert!(!e1.contains(&B));
+    assert!(!e1.contains(&C));
+
+    e1.insert(A);
+    e1.insert(B);
+    assert!(e1.contains(&A));
+    assert!(e1.contains(&B));
+    assert!(!e1.contains(&C));
+}
+
+///////////////////////////////////////////////////////////////////////////
+// iter
+
+#[test]
+fn test_iterator() {
+    let mut e1: EnumSet<Foo> = EnumSet::new();
+
+    let elems: Vec<Foo> = e1.iter().collect();
+    assert!(elems.is_empty());
+
+    e1.insert(A);
+    let elems: Vec<_> = e1.iter().collect();
+    assert_eq!([A], elems);
+
+    e1.insert(C);
+    let elems: Vec<_> = e1.iter().collect();
+    assert_eq!([A,C], elems);
+
+    e1.insert(C);
+    let elems: Vec<_> = e1.iter().collect();
+    assert_eq!([A,C], elems);
+
+    e1.insert(B);
+    let elems: Vec<_> = e1.iter().collect();
+    assert_eq!([A,B,C], elems);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// operators
+
+#[test]
+fn test_operators() {
+    let mut e1: EnumSet<Foo> = EnumSet::new();
+    e1.insert(A);
+    e1.insert(C);
+
+    let mut e2: EnumSet<Foo> = EnumSet::new();
+    e2.insert(B);
+    e2.insert(C);
+
+    let e_union = e1 | e2;
+    let elems: Vec<_> = e_union.iter().collect();
+    assert_eq!([A,B,C], elems);
+
+    let e_intersection = e1 & e2;
+    let elems: Vec<_> = e_intersection.iter().collect();
+    assert_eq!([C], elems);
+
+    // Another way to express intersection
+    let e_intersection = e1 - (e1 - e2);
+    let elems: Vec<_> = e_intersection.iter().collect();
+    assert_eq!([C], elems);
+
+    let e_subtract = e1 - e2;
+    let elems: Vec<_> = e_subtract.iter().collect();
+    assert_eq!([A], elems);
+
+    // Bitwise XOR of two sets, aka symmetric difference
+    let e_symmetric_diff = e1 ^ e2;
+    let elems: Vec<_> = e_symmetric_diff.iter().collect();
+    assert_eq!([A,B], elems);
+
+    // Another way to express symmetric difference
+    let e_symmetric_diff = (e1 - e2) | (e2 - e1);
+    let elems: Vec<_> = e_symmetric_diff.iter().collect();
+    assert_eq!([A,B], elems);
+
+    // Yet another way to express symmetric difference
+    let e_symmetric_diff = (e1 | e2) - (e1 & e2);
+    let elems: Vec<_> = e_symmetric_diff.iter().collect();
+    assert_eq!([A,B], elems);
+}
+
+#[test]
+#[should_panic]
+fn test_overflow() {
+    #[allow(dead_code)]
+    #[derive(Copy)]
+    #[repr(usize)]
+    enum Bar {
+        V00, V01, V02, V03, V04, V05, V06, V07, V08, V09,
+        V10, V11, V12, V13, V14, V15, V16, V17, V18, V19,
+        V20, V21, V22, V23, V24, V25, V26, V27, V28, V29,
+        V30, V31, V32, V33, V34, V35, V36, V37, V38, V39,
+        V40, V41, V42, V43, V44, V45, V46, V47, V48, V49,
+        V50, V51, V52, V53, V54, V55, V56, V57, V58, V59,
+        V60, V61, V62, V63, V64, V65, V66, V67, V68, V69,
+    }
+
+    impl CLike for Bar {
+        fn to_usize(&self) -> usize {
+            *self as usize
+        }
+
+        fn from_usize(v: usize) -> Bar {
+            unsafe { mem::transmute(v) }
+        }
+    }
+    let mut set = EnumSet::new();
+    set.insert(Bar::V64);
+}
diff --git a/src/libcollectionstest/fmt.rs b/src/libcollectionstest/fmt.rs
new file mode 100644
index 00000000000..9a9aa71b58b
--- /dev/null
+++ b/src/libcollectionstest/fmt.rs
@@ -0,0 +1,17 @@
+// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::fmt;
+
+#[test]
+fn test_format() {
+    let s = fmt::format(format_args!("Hello, {}!", "world"));
+    assert_eq!(s.as_slice(), "Hello, world!");
+}
diff --git a/src/libcollectionstest/lib.rs b/src/libcollectionstest/lib.rs
new file mode 100644
index 00000000000..7f029340d25
--- /dev/null
+++ b/src/libcollectionstest/lib.rs
@@ -0,0 +1,43 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![allow(deprecated)]
+#![feature(box_syntax)]
+#![feature(collections)]
+#![feature(core)]
+#![feature(hash)]
+#![feature(rand)]
+#![feature(rustc_private)]
+#![feature(str_words)]
+#![feature(test)]
+#![feature(unboxed_closures)]
+#![feature(unicode)]
+#![feature(unsafe_destructor)]
+
+#[macro_use] extern crate log;
+
+extern crate collections;
+extern crate test;
+extern crate unicode;
+
+#[cfg(test)] #[macro_use] mod bench;
+
+mod binary_heap;
+mod bit;
+mod btree;
+mod enum_set;
+mod fmt;
+mod linked_list;
+mod slice;
+mod str;
+mod string;
+mod vec_deque;
+mod vec_map;
+mod vec;
diff --git a/src/libcollectionstest/linked_list.rs b/src/libcollectionstest/linked_list.rs
new file mode 100644
index 00000000000..fd73938095f
--- /dev/null
+++ b/src/libcollectionstest/linked_list.rs
@@ -0,0 +1,397 @@
+// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::collections::LinkedList;
+use std::hash::{SipHasher, self};
+
+use test;
+
+#[test]
+fn test_basic() {
+    let mut m = LinkedList::<Box<_>>::new();
+    assert_eq!(m.pop_front(), None);
+    assert_eq!(m.pop_back(), None);
+    assert_eq!(m.pop_front(), None);
+    m.push_front(box 1);
+    assert_eq!(m.pop_front(), Some(box 1));
+    m.push_back(box 2);
+    m.push_back(box 3);
+    assert_eq!(m.len(), 2);
+    assert_eq!(m.pop_front(), Some(box 2));
+    assert_eq!(m.pop_front(), Some(box 3));
+    assert_eq!(m.len(), 0);
+    assert_eq!(m.pop_front(), None);
+    m.push_back(box 1);
+    m.push_back(box 3);
+    m.push_back(box 5);
+    m.push_back(box 7);
+    assert_eq!(m.pop_front(), Some(box 1));
+
+    let mut n = LinkedList::new();
+    n.push_front(2);
+    n.push_front(3);
+    {
+        assert_eq!(n.front().unwrap(), &3);
+        let x = n.front_mut().unwrap();
+        assert_eq!(*x, 3);
+        *x = 0;
+    }
+    {
+        assert_eq!(n.back().unwrap(), &2);
+        let y = n.back_mut().unwrap();
+        assert_eq!(*y, 2);
+        *y = 1;
+    }
+    assert_eq!(n.pop_front(), Some(0));
+    assert_eq!(n.pop_front(), Some(1));
+}
+
+#[cfg(test)]
+fn generate_test() -> LinkedList<i32> {
+    list_from(&[0,1,2,3,4,5,6])
+}
+
+#[cfg(test)]
+fn list_from<T: Clone>(v: &[T]) -> LinkedList<T> {
+    v.iter().cloned().collect()
+}
+
+#[test]
+fn test_split_off() {
+    // singleton
+    {
+        let mut m = LinkedList::new();
+        m.push_back(1);
+
+        let p = m.split_off(0);
+        assert_eq!(m.len(), 0);
+        assert_eq!(p.len(), 1);
+        assert_eq!(p.back(), Some(&1));
+        assert_eq!(p.front(), Some(&1));
+    }
+
+    // not singleton, forwards
+    {
+        let u = vec![1,2,3,4,5];
+        let mut m = list_from(&u);
+        let mut n = m.split_off(2);
+        assert_eq!(m.len(), 2);
+        assert_eq!(n.len(), 3);
+        for elt in 1..3 {
+            assert_eq!(m.pop_front(), Some(elt));
+        }
+        for elt in 3..6 {
+            assert_eq!(n.pop_front(), Some(elt));
+        }
+    }
+    // not singleton, backwards
+    {
+        let u = vec![1,2,3,4,5];
+        let mut m = list_from(&u);
+        let mut n = m.split_off(4);
+        assert_eq!(m.len(), 4);
+        assert_eq!(n.len(), 1);
+        for elt in 1..5 {
+            assert_eq!(m.pop_front(), Some(elt));
+        }
+        for elt in 5..6 {
+            assert_eq!(n.pop_front(), Some(elt));
+        }
+    }
+
+    // no-op on the last index
+    {
+        let mut m = LinkedList::new();
+        m.push_back(1);
+
+        let p = m.split_off(1);
+        assert_eq!(m.len(), 1);
+        assert_eq!(p.len(), 0);
+        assert_eq!(m.back(), Some(&1));
+        assert_eq!(m.front(), Some(&1));
+    }
+
+}
+
+#[test]
+fn test_iterator() {
+    let m = generate_test();
+    for (i, elt) in m.iter().enumerate() {
+        assert_eq!(i as i32, *elt);
+    }
+    let mut n = LinkedList::new();
+    assert_eq!(n.iter().next(), None);
+    n.push_front(4);
+    let mut it = n.iter();
+    assert_eq!(it.size_hint(), (1, Some(1)));
+    assert_eq!(it.next().unwrap(), &4);
+    assert_eq!(it.size_hint(), (0, Some(0)));
+    assert_eq!(it.next(), None);
+}
+
+#[test]
+fn test_iterator_clone() {
+    let mut n = LinkedList::new();
+    n.push_back(2);
+    n.push_back(3);
+    n.push_back(4);
+    let mut it = n.iter();
+    it.next();
+    let mut jt = it.clone();
+    assert_eq!(it.next(), jt.next());
+    assert_eq!(it.next_back(), jt.next_back());
+    assert_eq!(it.next(), jt.next());
+}
+
+#[test]
+fn test_iterator_double_end() {
+    let mut n = LinkedList::new();
+    assert_eq!(n.iter().next(), None);
+    n.push_front(4);
+    n.push_front(5);
+    n.push_front(6);
+    let mut it = n.iter();
+    assert_eq!(it.size_hint(), (3, Some(3)));
+    assert_eq!(it.next().unwrap(), &6);
+    assert_eq!(it.size_hint(), (2, Some(2)));
+    assert_eq!(it.next_back().unwrap(), &4);
+    assert_eq!(it.size_hint(), (1, Some(1)));
+    assert_eq!(it.next_back().unwrap(), &5);
+    assert_eq!(it.next_back(), None);
+    assert_eq!(it.next(), None);
+}
+
+#[test]
+fn test_rev_iter() {
+    let m = generate_test();
+    for (i, elt) in m.iter().rev().enumerate() {
+        assert_eq!((6 - i) as i32, *elt);
+    }
+    let mut n = LinkedList::new();
+    assert_eq!(n.iter().rev().next(), None);
+    n.push_front(4);
+    let mut it = n.iter().rev();
+    assert_eq!(it.size_hint(), (1, Some(1)));
+    assert_eq!(it.next().unwrap(), &4);
+    assert_eq!(it.size_hint(), (0, Some(0)));
+    assert_eq!(it.next(), None);
+}
+
+#[test]
+fn test_mut_iter() {
+    let mut m = generate_test();
+    let mut len = m.len();
+    for (i, elt) in m.iter_mut().enumerate() {
+        assert_eq!(i as i32, *elt);
+        len -= 1;
+    }
+    assert_eq!(len, 0);
+    let mut n = LinkedList::new();
+    assert!(n.iter_mut().next().is_none());
+    n.push_front(4);
+    n.push_back(5);
+    let mut it = n.iter_mut();
+    assert_eq!(it.size_hint(), (2, Some(2)));
+    assert!(it.next().is_some());
+    assert!(it.next().is_some());
+    assert_eq!(it.size_hint(), (0, Some(0)));
+    assert!(it.next().is_none());
+}
+
+#[test]
+fn test_iterator_mut_double_end() {
+    let mut n = LinkedList::new();
+    assert!(n.iter_mut().next_back().is_none());
+    n.push_front(4);
+    n.push_front(5);
+    n.push_front(6);
+    let mut it = n.iter_mut();
+    assert_eq!(it.size_hint(), (3, Some(3)));
+    assert_eq!(*it.next().unwrap(), 6);
+    assert_eq!(it.size_hint(), (2, Some(2)));
+    assert_eq!(*it.next_back().unwrap(), 4);
+    assert_eq!(it.size_hint(), (1, Some(1)));
+    assert_eq!(*it.next_back().unwrap(), 5);
+    assert!(it.next_back().is_none());
+    assert!(it.next().is_none());
+}
+
+#[test]
+fn test_mut_rev_iter() {
+    let mut m = generate_test();
+    for (i, elt) in m.iter_mut().rev().enumerate() {
+        assert_eq!((6 - i) as i32, *elt);
+    }
+    let mut n = LinkedList::new();
+    assert!(n.iter_mut().rev().next().is_none());
+    n.push_front(4);
+    let mut it = n.iter_mut().rev();
+    assert!(it.next().is_some());
+    assert!(it.next().is_none());
+}
+
+#[test]
+fn test_eq() {
+    let mut n = list_from(&[]);
+    let mut m = list_from(&[]);
+    assert!(n == m);
+    n.push_front(1);
+    assert!(n != m);
+    m.push_back(1);
+    assert!(n == m);
+
+    let n = list_from(&[2,3,4]);
+    let m = list_from(&[1,2,3]);
+    assert!(n != m);
+}
+
+#[test]
+fn test_hash() {
+  let mut x = LinkedList::new();
+  let mut y = LinkedList::new();
+
+  assert!(hash::hash::<_, SipHasher>(&x) == hash::hash::<_, SipHasher>(&y));
+
+  x.push_back(1);
+  x.push_back(2);
+  x.push_back(3);
+
+  y.push_front(3);
+  y.push_front(2);
+  y.push_front(1);
+
+  assert!(hash::hash::<_, SipHasher>(&x) == hash::hash::<_, SipHasher>(&y));
+}
+
+#[test]
+fn test_ord() {
+    let n = list_from(&[]);
+    let m = list_from(&[1,2,3]);
+    assert!(n < m);
+    assert!(m > n);
+    assert!(n <= n);
+    assert!(n >= n);
+}
+
+#[test]
+fn test_ord_nan() {
+    let nan = 0.0f64/0.0;
+    let n = list_from(&[nan]);
+    let m = list_from(&[nan]);
+    assert!(!(n < m));
+    assert!(!(n > m));
+    assert!(!(n <= m));
+    assert!(!(n >= m));
+
+    let n = list_from(&[nan]);
+    let one = list_from(&[1.0f64]);
+    assert!(!(n < one));
+    assert!(!(n > one));
+    assert!(!(n <= one));
+    assert!(!(n >= one));
+
+    let u = list_from(&[1.0f64,2.0,nan]);
+    let v = list_from(&[1.0f64,2.0,3.0]);
+    assert!(!(u < v));
+    assert!(!(u > v));
+    assert!(!(u <= v));
+    assert!(!(u >= v));
+
+    let s = list_from(&[1.0f64,2.0,4.0,2.0]);
+    let t = list_from(&[1.0f64,2.0,3.0,2.0]);
+    assert!(!(s < t));
+    assert!(s > one);
+    assert!(!(s <= one));
+    assert!(s >= one);
+}
+
+#[test]
+fn test_show() {
+    let list: LinkedList<_> = (0..10).collect();
+    assert_eq!(format!("{:?}", list), "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
+
+    let list: LinkedList<_> = vec!["just", "one", "test", "more"].iter().cloned().collect();
+    assert_eq!(format!("{:?}", list), "[\"just\", \"one\", \"test\", \"more\"]");
+}
+
+#[bench]
+fn bench_collect_into(b: &mut test::Bencher) {
+    let v = &[0; 64];
+    b.iter(|| {
+        let _: LinkedList<_> = v.iter().cloned().collect();
+    })
+}
+
+#[bench]
+fn bench_push_front(b: &mut test::Bencher) {
+    let mut m: LinkedList<_> = LinkedList::new();
+    b.iter(|| {
+        m.push_front(0);
+    })
+}
+
+#[bench]
+fn bench_push_back(b: &mut test::Bencher) {
+    let mut m: LinkedList<_> = LinkedList::new();
+    b.iter(|| {
+        m.push_back(0);
+    })
+}
+
+#[bench]
+fn bench_push_back_pop_back(b: &mut test::Bencher) {
+    let mut m: LinkedList<_> = LinkedList::new();
+    b.iter(|| {
+        m.push_back(0);
+        m.pop_back();
+    })
+}
+
+#[bench]
+fn bench_push_front_pop_front(b: &mut test::Bencher) {
+    let mut m: LinkedList<_> = LinkedList::new();
+    b.iter(|| {
+        m.push_front(0);
+        m.pop_front();
+    })
+}
+
+#[bench]
+fn bench_iter(b: &mut test::Bencher) {
+    let v = &[0; 128];
+    let m: LinkedList<_> = v.iter().cloned().collect();
+    b.iter(|| {
+        assert!(m.iter().count() == 128);
+    })
+}
+#[bench]
+fn bench_iter_mut(b: &mut test::Bencher) {
+    let v = &[0; 128];
+    let mut m: LinkedList<_> = v.iter().cloned().collect();
+    b.iter(|| {
+        assert!(m.iter_mut().count() == 128);
+    })
+}
+#[bench]
+fn bench_iter_rev(b: &mut test::Bencher) {
+    let v = &[0; 128];
+    let m: LinkedList<_> = v.iter().cloned().collect();
+    b.iter(|| {
+        assert!(m.iter().rev().count() == 128);
+    })
+}
+#[bench]
+fn bench_iter_mut_rev(b: &mut test::Bencher) {
+    let v = &[0; 128];
+    let mut m: LinkedList<_> = v.iter().cloned().collect();
+    b.iter(|| {
+        assert!(m.iter_mut().rev().count() == 128);
+    })
+}
diff --git a/src/libcollectionstest/slice.rs b/src/libcollectionstest/slice.rs
new file mode 100644
index 00000000000..0c3c82eea78
--- /dev/null
+++ b/src/libcollectionstest/slice.rs
@@ -0,0 +1,1571 @@
+// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::cmp::Ordering::{Equal, Greater, Less};
+use std::default::Default;
+use std::iter::RandomAccessIterator;
+use std::mem;
+use std::rand::{Rng, thread_rng};
+use std::rc::Rc;
+use std::slice::ElementSwaps;
+
+fn square(n: usize) -> usize { n * n }
+
+fn is_odd(n: &usize) -> bool { *n % 2 == 1 }
+
+#[test]
+fn test_from_fn() {
+    // Test on-stack from_fn.
+    let mut v: Vec<_> = (0..3).map(square).collect();
+    {
+        let v = v;
+        assert_eq!(v.len(), 3);
+        assert_eq!(v[0], 0);
+        assert_eq!(v[1], 1);
+        assert_eq!(v[2], 4);
+    }
+
+    // Test on-heap from_fn.
+    v = (0..5).map(square).collect();
+    {
+        let v = v;
+        assert_eq!(v.len(), 5);
+        assert_eq!(v[0], 0);
+        assert_eq!(v[1], 1);
+        assert_eq!(v[2], 4);
+        assert_eq!(v[3], 9);
+        assert_eq!(v[4], 16);
+    }
+}
+
+#[test]
+fn test_from_elem() {
+    // Test on-stack from_elem.
+    let mut v = vec![10, 10];
+    {
+        let v = v;
+        assert_eq!(v.len(), 2);
+        assert_eq!(v[0], 10);
+        assert_eq!(v[1], 10);
+    }
+
+    // Test on-heap from_elem.
+    v = vec![20; 6];
+    {
+        let v = v.as_slice();
+        assert_eq!(v[0], 20);
+        assert_eq!(v[1], 20);
+        assert_eq!(v[2], 20);
+        assert_eq!(v[3], 20);
+        assert_eq!(v[4], 20);
+        assert_eq!(v[5], 20);
+    }
+}
+
+#[test]
+fn test_is_empty() {
+    let xs: [i32; 0] = [];
+    assert!(xs.is_empty());
+    assert!(![0].is_empty());
+}
+
+#[test]
+fn test_len_divzero() {
+    type Z = [i8; 0];
+    let v0 : &[Z] = &[];
+    let v1 : &[Z] = &[[]];
+    let v2 : &[Z] = &[[], []];
+    assert_eq!(mem::size_of::<Z>(), 0);
+    assert_eq!(v0.len(), 0);
+    assert_eq!(v1.len(), 1);
+    assert_eq!(v2.len(), 2);
+}
+
+#[test]
+fn test_get() {
+    let mut a = vec![11];
+    assert_eq!(a.get(1), None);
+    a = vec![11, 12];
+    assert_eq!(a.get(1).unwrap(), &12);
+    a = vec![11, 12, 13];
+    assert_eq!(a.get(1).unwrap(), &12);
+}
+
+#[test]
+fn test_first() {
+    let mut a = vec![];
+    assert_eq!(a.first(), None);
+    a = vec![11];
+    assert_eq!(a.first().unwrap(), &11);
+    a = vec![11, 12];
+    assert_eq!(a.first().unwrap(), &11);
+}
+
+#[test]
+fn test_first_mut() {
+    let mut a = vec![];
+    assert_eq!(a.first_mut(), None);
+    a = vec![11];
+    assert_eq!(*a.first_mut().unwrap(), 11);
+    a = vec![11, 12];
+    assert_eq!(*a.first_mut().unwrap(), 11);
+}
+
+#[test]
+fn test_tail() {
+    let mut a = vec![11];
+    let b: &[i32] = &[];
+    assert_eq!(a.tail(), b);
+    a = vec![11, 12];
+    let b: &[i32] = &[12];
+    assert_eq!(a.tail(), b);
+}
+
+#[test]
+fn test_tail_mut() {
+    let mut a = vec![11];
+    let b: &mut [i32] = &mut [];
+    assert!(a.tail_mut() == b);
+    a = vec![11, 12];
+    let b: &mut [_] = &mut [12];
+    assert!(a.tail_mut() == b);
+}
+
+#[test]
+#[should_panic]
+fn test_tail_empty() {
+    let a = Vec::<i32>::new();
+    a.tail();
+}
+
+#[test]
+#[should_panic]
+fn test_tail_mut_empty() {
+    let mut a = Vec::<i32>::new();
+    a.tail_mut();
+}
+
+#[test]
+fn test_init() {
+    let mut a = vec![11];
+    let b: &[i32] = &[];
+    assert_eq!(a.init(), b);
+    a = vec![11, 12];
+    let b: &[_] = &[11];
+    assert_eq!(a.init(), b);
+}
+
+#[test]
+fn test_init_mut() {
+    let mut a = vec![11];
+    let b: &mut [i32] = &mut [];
+    assert!(a.init_mut() == b);
+    a = vec![11, 12];
+    let b: &mut [_] = &mut [11];
+    assert!(a.init_mut() == b);
+}
+
+#[test]
+#[should_panic]
+fn test_init_empty() {
+    let a = Vec::<i32>::new();
+    a.init();
+}
+
+#[test]
+#[should_panic]
+fn test_init_mut_empty() {
+    let mut a = Vec::<i32>::new();
+    a.init_mut();
+}
+
+#[test]
+fn test_last() {
+    let mut a = vec![];
+    assert_eq!(a.last(), None);
+    a = vec![11];
+    assert_eq!(a.last().unwrap(), &11);
+    a = vec![11, 12];
+    assert_eq!(a.last().unwrap(), &12);
+}
+
+#[test]
+fn test_last_mut() {
+    let mut a = vec![];
+    assert_eq!(a.last_mut(), None);
+    a = vec![11];
+    assert_eq!(*a.last_mut().unwrap(), 11);
+    a = vec![11, 12];
+    assert_eq!(*a.last_mut().unwrap(), 12);
+}
+
+#[test]
+fn test_slice() {
+    // Test fixed length vector.
+    let vec_fixed = [1, 2, 3, 4];
+    let v_a = vec_fixed[1..vec_fixed.len()].to_vec();
+    assert_eq!(v_a.len(), 3);
+
+    assert_eq!(v_a[0], 2);
+    assert_eq!(v_a[1], 3);
+    assert_eq!(v_a[2], 4);
+
+    // Test on stack.
+    let vec_stack: &[_] = &[1, 2, 3];
+    let v_b = vec_stack[1..3].to_vec();
+    assert_eq!(v_b.len(), 2);
+
+    assert_eq!(v_b[0], 2);
+    assert_eq!(v_b[1], 3);
+
+    // Test `Box<[T]>`
+    let vec_unique = vec![1, 2, 3, 4, 5, 6];
+    let v_d = vec_unique[1..6].to_vec();
+    assert_eq!(v_d.len(), 5);
+
+    assert_eq!(v_d[0], 2);
+    assert_eq!(v_d[1], 3);
+    assert_eq!(v_d[2], 4);
+    assert_eq!(v_d[3], 5);
+    assert_eq!(v_d[4], 6);
+}
+
+#[test]
+fn test_slice_from() {
+    let vec: &[_] = &[1, 2, 3, 4];
+    assert_eq!(&vec[..], vec);
+    let b: &[_] = &[3, 4];
+    assert_eq!(&vec[2..], b);
+    let b: &[_] = &[];
+    assert_eq!(&vec[4..], b);
+}
+
+#[test]
+fn test_slice_to() {
+    let vec: &[_] = &[1, 2, 3, 4];
+    assert_eq!(&vec[..4], vec);
+    let b: &[_] = &[1, 2];
+    assert_eq!(&vec[..2], b);
+    let b: &[_] = &[];
+    assert_eq!(&vec[..0], b);
+}
+
+
+#[test]
+fn test_pop() {
+    let mut v = vec![5];
+    let e = v.pop();
+    assert_eq!(v.len(), 0);
+    assert_eq!(e, Some(5));
+    let f = v.pop();
+    assert_eq!(f, None);
+    let g = v.pop();
+    assert_eq!(g, None);
+}
+
+#[test]
+fn test_swap_remove() {
+    let mut v = vec![1, 2, 3, 4, 5];
+    let mut e = v.swap_remove(0);
+    assert_eq!(e, 1);
+    assert_eq!(v, [5, 2, 3, 4]);
+    e = v.swap_remove(3);
+    assert_eq!(e, 4);
+    assert_eq!(v, [5, 2, 3]);
+}
+
+#[test]
+#[should_panic]
+fn test_swap_remove_fail() {
+    let mut v = vec![1];
+    let _ = v.swap_remove(0);
+    let _ = v.swap_remove(0);
+}
+
+#[test]
+fn test_swap_remove_noncopyable() {
+    // Tests that we don't accidentally run destructors twice.
+    let mut v: Vec<Box<_>> = Vec::new();
+    v.push(box 0u8);
+    v.push(box 0u8);
+    v.push(box 0u8);
+    let mut _e = v.swap_remove(0);
+    assert_eq!(v.len(), 2);
+    _e = v.swap_remove(1);
+    assert_eq!(v.len(), 1);
+    _e = v.swap_remove(0);
+    assert_eq!(v.len(), 0);
+}
+
+#[test]
+fn test_push() {
+    // Test on-stack push().
+    let mut v = vec![];
+    v.push(1);
+    assert_eq!(v.len(), 1);
+    assert_eq!(v[0], 1);
+
+    // Test on-heap push().
+    v.push(2);
+    assert_eq!(v.len(), 2);
+    assert_eq!(v[0], 1);
+    assert_eq!(v[1], 2);
+}
+
+#[test]
+fn test_truncate() {
+    let mut v: Vec<Box<_>> = vec![box 6,box 5,box 4];
+    v.truncate(1);
+    let v = v;
+    assert_eq!(v.len(), 1);
+    assert_eq!(*(v[0]), 6);
+    // If the unsafe block didn't drop things properly, we blow up here.
+}
+
+#[test]
+fn test_clear() {
+    let mut v: Vec<Box<_>> = vec![box 6,box 5,box 4];
+    v.clear();
+    assert_eq!(v.len(), 0);
+    // If the unsafe block didn't drop things properly, we blow up here.
+}
+
+#[test]
+fn test_dedup() {
+    fn case(a: Vec<i32>, b: Vec<i32>) {
+        let mut v = a;
+        v.dedup();
+        assert_eq!(v, b);
+    }
+    case(vec![], vec![]);
+    case(vec![1], vec![1]);
+    case(vec![1,1], vec![1]);
+    case(vec![1,2,3], vec![1,2,3]);
+    case(vec![1,1,2,3], vec![1,2,3]);
+    case(vec![1,2,2,3], vec![1,2,3]);
+    case(vec![1,2,3,3], vec![1,2,3]);
+    case(vec![1,1,2,2,2,3,3], vec![1,2,3]);
+}
+
+#[test]
+fn test_dedup_unique() {
+    let mut v0: Vec<Box<_>> = vec![box 1, box 1, box 2, box 3];
+    v0.dedup();
+    let mut v1: Vec<Box<_>> = vec![box 1, box 2, box 2, box 3];
+    v1.dedup();
+    let mut v2: Vec<Box<_>> = vec![box 1, box 2, box 3, box 3];
+    v2.dedup();
+    /*
+     * If the boxed pointers were leaked or otherwise misused, valgrind
+     * and/or rt should raise errors.
+     */
+}
+
+#[test]
+fn test_dedup_shared() {
+    let mut v0: Vec<Box<_>> = vec![box 1, box 1, box 2, box 3];
+    v0.dedup();
+    let mut v1: Vec<Box<_>> = vec![box 1, box 2, box 2, box 3];
+    v1.dedup();
+    let mut v2: Vec<Box<_>> = vec![box 1, box 2, box 3, box 3];
+    v2.dedup();
+    /*
+     * If the pointers were leaked or otherwise misused, valgrind and/or
+     * rt should raise errors.
+     */
+}
+
+#[test]
+fn test_retain() {
+    let mut v = vec![1, 2, 3, 4, 5];
+    v.retain(is_odd);
+    assert_eq!(v, [1, 3, 5]);
+}
+
+#[test]
+fn test_element_swaps() {
+    let mut v = [1, 2, 3];
+    for (i, (a, b)) in ElementSwaps::new(v.len()).enumerate() {
+        v.swap(a, b);
+        match i {
+            0 => assert!(v == [1, 3, 2]),
+            1 => assert!(v == [3, 1, 2]),
+            2 => assert!(v == [3, 2, 1]),
+            3 => assert!(v == [2, 3, 1]),
+            4 => assert!(v == [2, 1, 3]),
+            5 => assert!(v == [1, 2, 3]),
+            _ => panic!(),
+        }
+    }
+}
+
+#[test]
+fn test_lexicographic_permutations() {
+    let v : &mut[_] = &mut[1, 2, 3, 4, 5];
+    assert!(v.prev_permutation() == false);
+    assert!(v.next_permutation());
+    let b: &mut[_] = &mut[1, 2, 3, 5, 4];
+    assert!(v == b);
+    assert!(v.prev_permutation());
+    let b: &mut[_] = &mut[1, 2, 3, 4, 5];
+    assert!(v == b);
+    assert!(v.next_permutation());
+    assert!(v.next_permutation());
+    let b: &mut[_] = &mut[1, 2, 4, 3, 5];
+    assert!(v == b);
+    assert!(v.next_permutation());
+    let b: &mut[_] = &mut[1, 2, 4, 5, 3];
+    assert!(v == b);
+
+    let v : &mut[_] = &mut[1, 0, 0, 0];
+    assert!(v.next_permutation() == false);
+    assert!(v.prev_permutation());
+    let b: &mut[_] = &mut[0, 1, 0, 0];
+    assert!(v == b);
+    assert!(v.prev_permutation());
+    let b: &mut[_] = &mut[0, 0, 1, 0];
+    assert!(v == b);
+    assert!(v.prev_permutation());
+    let b: &mut[_] = &mut[0, 0, 0, 1];
+    assert!(v == b);
+    assert!(v.prev_permutation() == false);
+}
+
+#[test]
+fn test_lexicographic_permutations_empty_and_short() {
+    let empty : &mut[i32] = &mut[];
+    assert!(empty.next_permutation() == false);
+    let b: &mut[i32] = &mut[];
+    assert!(empty == b);
+    assert!(empty.prev_permutation() == false);
+    assert!(empty == b);
+
+    let one_elem : &mut[_] = &mut[4];
+    assert!(one_elem.prev_permutation() == false);
+    let b: &mut[_] = &mut[4];
+    assert!(one_elem == b);
+    assert!(one_elem.next_permutation() == false);
+    assert!(one_elem == b);
+
+    let two_elem : &mut[_] = &mut[1, 2];
+    assert!(two_elem.prev_permutation() == false);
+    let b : &mut[_] = &mut[1, 2];
+    let c : &mut[_] = &mut[2, 1];
+    assert!(two_elem == b);
+    assert!(two_elem.next_permutation());
+    assert!(two_elem == c);
+    assert!(two_elem.next_permutation() == false);
+    assert!(two_elem == c);
+    assert!(two_elem.prev_permutation());
+    assert!(two_elem == b);
+    assert!(two_elem.prev_permutation() == false);
+    assert!(two_elem == b);
+}
+
+#[test]
+fn test_position_elem() {
+    assert!([].position_elem(&1).is_none());
+
+    let v1 = vec![1, 2, 3, 3, 2, 5];
+    assert_eq!(v1.position_elem(&1), Some(0));
+    assert_eq!(v1.position_elem(&2), Some(1));
+    assert_eq!(v1.position_elem(&5), Some(5));
+    assert!(v1.position_elem(&4).is_none());
+}
+
+#[test]
+fn test_binary_search() {
+    assert_eq!([1,2,3,4,5].binary_search(&5).ok(), Some(4));
+    assert_eq!([1,2,3,4,5].binary_search(&4).ok(), Some(3));
+    assert_eq!([1,2,3,4,5].binary_search(&3).ok(), Some(2));
+    assert_eq!([1,2,3,4,5].binary_search(&2).ok(), Some(1));
+    assert_eq!([1,2,3,4,5].binary_search(&1).ok(), Some(0));
+
+    assert_eq!([2,4,6,8,10].binary_search(&1).ok(), None);
+    assert_eq!([2,4,6,8,10].binary_search(&5).ok(), None);
+    assert_eq!([2,4,6,8,10].binary_search(&4).ok(), Some(1));
+    assert_eq!([2,4,6,8,10].binary_search(&10).ok(), Some(4));
+
+    assert_eq!([2,4,6,8].binary_search(&1).ok(), None);
+    assert_eq!([2,4,6,8].binary_search(&5).ok(), None);
+    assert_eq!([2,4,6,8].binary_search(&4).ok(), Some(1));
+    assert_eq!([2,4,6,8].binary_search(&8).ok(), Some(3));
+
+    assert_eq!([2,4,6].binary_search(&1).ok(), None);
+    assert_eq!([2,4,6].binary_search(&5).ok(), None);
+    assert_eq!([2,4,6].binary_search(&4).ok(), Some(1));
+    assert_eq!([2,4,6].binary_search(&6).ok(), Some(2));
+
+    assert_eq!([2,4].binary_search(&1).ok(), None);
+    assert_eq!([2,4].binary_search(&5).ok(), None);
+    assert_eq!([2,4].binary_search(&2).ok(), Some(0));
+    assert_eq!([2,4].binary_search(&4).ok(), Some(1));
+
+    assert_eq!([2].binary_search(&1).ok(), None);
+    assert_eq!([2].binary_search(&5).ok(), None);
+    assert_eq!([2].binary_search(&2).ok(), Some(0));
+
+    assert_eq!([].binary_search(&1).ok(), None);
+    assert_eq!([].binary_search(&5).ok(), None);
+
+    assert!([1,1,1,1,1].binary_search(&1).ok() != None);
+    assert!([1,1,1,1,2].binary_search(&1).ok() != None);
+    assert!([1,1,1,2,2].binary_search(&1).ok() != None);
+    assert!([1,1,2,2,2].binary_search(&1).ok() != None);
+    assert_eq!([1,2,2,2,2].binary_search(&1).ok(), Some(0));
+
+    assert_eq!([1,2,3,4,5].binary_search(&6).ok(), None);
+    assert_eq!([1,2,3,4,5].binary_search(&0).ok(), None);
+}
+
+#[test]
+fn test_reverse() {
+    let mut v = vec![10, 20];
+    assert_eq!(v[0], 10);
+    assert_eq!(v[1], 20);
+    v.reverse();
+    assert_eq!(v[0], 20);
+    assert_eq!(v[1], 10);
+
+    let mut v3 = Vec::<i32>::new();
+    v3.reverse();
+    assert!(v3.is_empty());
+}
+
+#[test]
+fn test_sort() {
+    for len in 4..25 {
+        for _ in 0..100 {
+            let mut v: Vec<_> = thread_rng().gen_iter::<i32>().take(len).collect();
+            let mut v1 = v.clone();
+
+            v.sort();
+            assert!(v.windows(2).all(|w| w[0] <= w[1]));
+
+            v1.sort_by(|a, b| a.cmp(b));
+            assert!(v1.windows(2).all(|w| w[0] <= w[1]));
+
+            v1.sort_by(|a, b| b.cmp(a));
+            assert!(v1.windows(2).all(|w| w[0] >= w[1]));
+        }
+    }
+
+    // shouldn't panic
+    let mut v: [i32; 0] = [];
+    v.sort();
+
+    let mut v = [0xDEADBEEFu64];
+    v.sort();
+    assert!(v == [0xDEADBEEF]);
+}
+
+#[test]
+fn test_sort_stability() {
+    for len in 4..25 {
+        for _ in 0..10 {
+            let mut counts = [0; 10];
+
+            // create a vector like [(6, 1), (5, 1), (6, 2), ...],
+            // where the first item of each tuple is random, but
+            // the second item represents which occurrence of that
+            // number this element is, i.e. the second elements
+            // will occur in sorted order.
+            let mut v: Vec<_> = (0..len).map(|_| {
+                    let n = thread_rng().gen::<usize>() % 10;
+                    counts[n] += 1;
+                    (n, counts[n])
+                }).collect();
+
+            // only sort on the first element, so an unstable sort
+            // may mix up the counts.
+            v.sort_by(|&(a,_), &(b,_)| a.cmp(&b));
+
+            // this comparison includes the count (the second item
+            // of the tuple), so elements with equal first items
+            // will need to be ordered with increasing
+            // counts... i.e. exactly asserting that this sort is
+            // stable.
+            assert!(v.windows(2).all(|w| w[0] <= w[1]));
+        }
+    }
+}
+
+#[test]
+fn test_concat() {
+    let v: [Vec<i32>; 0] = [];
+    let c = v.concat();
+    assert_eq!(c, []);
+    let d = [vec![1], vec![2, 3]].concat();
+    assert_eq!(d, [1, 2, 3]);
+
+    let v: &[&[_]] = &[&[1], &[2, 3]];
+    assert_eq!(v.connect(&0), [1, 0, 2, 3]);
+    let v: &[&[_]] = &[&[1], &[2], &[3]];
+    assert_eq!(v.connect(&0), [1, 0, 2, 0, 3]);
+}
+
+#[test]
+fn test_connect() {
+    let v: [Vec<i32>; 0] = [];
+    assert_eq!(v.connect(&0), []);
+    assert_eq!([vec![1], vec![2, 3]].connect(&0), [1, 0, 2, 3]);
+    assert_eq!([vec![1], vec![2], vec![3]].connect(&0), [1, 0, 2, 0, 3]);
+
+    let v: [&[_]; 2] = [&[1], &[2, 3]];
+    assert_eq!(v.connect(&0), [1, 0, 2, 3]);
+    let v: [&[_]; 3] = [&[1], &[2], &[3]];
+    assert_eq!(v.connect(&0), [1, 0, 2, 0, 3]);
+}
+
+#[test]
+fn test_insert() {
+    let mut a = vec![1, 2, 4];
+    a.insert(2, 3);
+    assert_eq!(a, [1, 2, 3, 4]);
+
+    let mut a = vec![1, 2, 3];
+    a.insert(0, 0);
+    assert_eq!(a, [0, 1, 2, 3]);
+
+    let mut a = vec![1, 2, 3];
+    a.insert(3, 4);
+    assert_eq!(a, [1, 2, 3, 4]);
+
+    let mut a = vec![];
+    a.insert(0, 1);
+    assert_eq!(a, [1]);
+}
+
+#[test]
+#[should_panic]
+fn test_insert_oob() {
+    let mut a = vec![1, 2, 3];
+    a.insert(4, 5);
+}
+
+#[test]
+fn test_remove() {
+    let mut a = vec![1, 2, 3, 4];
+
+    assert_eq!(a.remove(2), 3);
+    assert_eq!(a, [1, 2, 4]);
+
+    assert_eq!(a.remove(2), 4);
+    assert_eq!(a, [1, 2]);
+
+    assert_eq!(a.remove(0), 1);
+    assert_eq!(a, [2]);
+
+    assert_eq!(a.remove(0), 2);
+    assert_eq!(a, []);
+}
+
+#[test]
+#[should_panic]
+fn test_remove_fail() {
+    let mut a = vec![1];
+    let _ = a.remove(0);
+    let _ = a.remove(0);
+}
+
+#[test]
+fn test_capacity() {
+    let mut v = vec![0];
+    v.reserve_exact(10);
+    assert!(v.capacity() >= 11);
+}
+
+#[test]
+fn test_slice_2() {
+    let v = vec![1, 2, 3, 4, 5];
+    let v = v.slice(1, 3);
+    assert_eq!(v.len(), 2);
+    assert_eq!(v[0], 2);
+    assert_eq!(v[1], 3);
+}
+
+#[test]
+#[should_panic]
+fn test_permute_fail() {
+    let v: [(Box<_>, Rc<_>); 4] =
+        [(box 0, Rc::new(0)), (box 0, Rc::new(0)),
+         (box 0, Rc::new(0)), (box 0, Rc::new(0))];
+    let mut i = 0;
+    for _ in v.permutations() {
+        if i == 2 {
+            panic!()
+        }
+        i += 1;
+    }
+}
+
+#[test]
+fn test_total_ord() {
+    let c = &[1, 2, 3];
+    [1, 2, 3, 4][..].cmp(c) == Greater;
+    let c = &[1, 2, 3, 4];
+    [1, 2, 3][..].cmp(c) == Less;
+    let c = &[1, 2, 3, 6];
+    [1, 2, 3, 4][..].cmp(c) == Equal;
+    let c = &[1, 2, 3, 4, 5, 6];
+    [1, 2, 3, 4, 5, 5, 5, 5][..].cmp(c) == Less;
+    let c = &[1, 2, 3, 4];
+    [2, 2][..].cmp(c) == Greater;
+}
+
+#[test]
+fn test_iterator() {
+    let xs = [1, 2, 5, 10, 11];
+    let mut it = xs.iter();
+    assert_eq!(it.size_hint(), (5, Some(5)));
+    assert_eq!(it.next().unwrap(), &1);
+    assert_eq!(it.size_hint(), (4, Some(4)));
+    assert_eq!(it.next().unwrap(), &2);
+    assert_eq!(it.size_hint(), (3, Some(3)));
+    assert_eq!(it.next().unwrap(), &5);
+    assert_eq!(it.size_hint(), (2, Some(2)));
+    assert_eq!(it.next().unwrap(), &10);
+    assert_eq!(it.size_hint(), (1, Some(1)));
+    assert_eq!(it.next().unwrap(), &11);
+    assert_eq!(it.size_hint(), (0, Some(0)));
+    assert!(it.next().is_none());
+}
+
+#[test]
+fn test_random_access_iterator() {
+    let xs = [1, 2, 5, 10, 11];
+    let mut it = xs.iter();
+
+    assert_eq!(it.indexable(), 5);
+    assert_eq!(it.idx(0).unwrap(), &1);
+    assert_eq!(it.idx(2).unwrap(), &5);
+    assert_eq!(it.idx(4).unwrap(), &11);
+    assert!(it.idx(5).is_none());
+
+    assert_eq!(it.next().unwrap(), &1);
+    assert_eq!(it.indexable(), 4);
+    assert_eq!(it.idx(0).unwrap(), &2);
+    assert_eq!(it.idx(3).unwrap(), &11);
+    assert!(it.idx(4).is_none());
+
+    assert_eq!(it.next().unwrap(), &2);
+    assert_eq!(it.indexable(), 3);
+    assert_eq!(it.idx(1).unwrap(), &10);
+    assert!(it.idx(3).is_none());
+
+    assert_eq!(it.next().unwrap(), &5);
+    assert_eq!(it.indexable(), 2);
+    assert_eq!(it.idx(1).unwrap(), &11);
+
+    assert_eq!(it.next().unwrap(), &10);
+    assert_eq!(it.indexable(), 1);
+    assert_eq!(it.idx(0).unwrap(), &11);
+    assert!(it.idx(1).is_none());
+
+    assert_eq!(it.next().unwrap(), &11);
+    assert_eq!(it.indexable(), 0);
+    assert!(it.idx(0).is_none());
+
+    assert!(it.next().is_none());
+}
+
+#[test]
+fn test_iter_size_hints() {
+    let mut xs = [1, 2, 5, 10, 11];
+    assert_eq!(xs.iter().size_hint(), (5, Some(5)));
+    assert_eq!(xs.iter_mut().size_hint(), (5, Some(5)));
+}
+
+#[test]
+fn test_iter_clone() {
+    let xs = [1, 2, 5];
+    let mut it = xs.iter();
+    it.next();
+    let mut jt = it.clone();
+    assert_eq!(it.next(), jt.next());
+    assert_eq!(it.next(), jt.next());
+    assert_eq!(it.next(), jt.next());
+}
+
+#[test]
+fn test_mut_iterator() {
+    let mut xs = [1, 2, 3, 4, 5];
+    for x in &mut xs {
+        *x += 1;
+    }
+    assert!(xs == [2, 3, 4, 5, 6])
+}
+
+#[test]
+fn test_rev_iterator() {
+
+    let xs = [1, 2, 5, 10, 11];
+    let ys = [11, 10, 5, 2, 1];
+    let mut i = 0;
+    for &x in xs.iter().rev() {
+        assert_eq!(x, ys[i]);
+        i += 1;
+    }
+    assert_eq!(i, 5);
+}
+
+#[test]
+fn test_mut_rev_iterator() {
+    let mut xs = [1, 2, 3, 4, 5];
+    for (i,x) in xs.iter_mut().rev().enumerate() {
+        *x += i;
+    }
+    assert!(xs == [5, 5, 5, 5, 5])
+}
+
+#[test]
+fn test_move_iterator() {
+    let xs = vec![1,2,3,4,5];
+    assert_eq!(xs.into_iter().fold(0, |a: usize, b: usize| 10*a + b), 12345);
+}
+
+#[test]
+fn test_move_rev_iterator() {
+    let xs = vec![1,2,3,4,5];
+    assert_eq!(xs.into_iter().rev().fold(0, |a: usize, b: usize| 10*a + b), 54321);
+}
+
+#[test]
+fn test_splitator() {
+    let xs = &[1,2,3,4,5];
+
+    let splits: &[&[_]] = &[&[1], &[3], &[5]];
+    assert_eq!(xs.split(|x| *x % 2 == 0).collect::<Vec<_>>(),
+               splits);
+    let splits: &[&[_]] = &[&[], &[2,3,4,5]];
+    assert_eq!(xs.split(|x| *x == 1).collect::<Vec<_>>(),
+               splits);
+    let splits: &[&[_]] = &[&[1,2,3,4], &[]];
+    assert_eq!(xs.split(|x| *x == 5).collect::<Vec<_>>(),
+               splits);
+    let splits: &[&[_]] = &[&[1,2,3,4,5]];
+    assert_eq!(xs.split(|x| *x == 10).collect::<Vec<_>>(),
+               splits);
+    let splits: &[&[_]] = &[&[], &[], &[], &[], &[], &[]];
+    assert_eq!(xs.split(|_| true).collect::<Vec<&[i32]>>(),
+               splits);
+
+    let xs: &[i32] = &[];
+    let splits: &[&[i32]] = &[&[]];
+    assert_eq!(xs.split(|x| *x == 5).collect::<Vec<&[i32]>>(), splits);
+}
+
+#[test]
+fn test_splitnator() {
+    let xs = &[1,2,3,4,5];
+
+    let splits: &[&[_]] = &[&[1,2,3,4,5]];
+    assert_eq!(xs.splitn(0, |x| *x % 2 == 0).collect::<Vec<_>>(),
+               splits);
+    let splits: &[&[_]] = &[&[1], &[3,4,5]];
+    assert_eq!(xs.splitn(1, |x| *x % 2 == 0).collect::<Vec<_>>(),
+               splits);
+    let splits: &[&[_]] = &[&[], &[], &[], &[4,5]];
+    assert_eq!(xs.splitn(3, |_| true).collect::<Vec<_>>(),
+               splits);
+
+    let xs: &[i32] = &[];
+    let splits: &[&[i32]] = &[&[]];
+    assert_eq!(xs.splitn(1, |x| *x == 5).collect::<Vec<_>>(), splits);
+}
+
+#[test]
+fn test_splitnator_mut() {
+    let xs = &mut [1,2,3,4,5];
+
+    let splits: &[&mut[_]] = &[&mut [1,2,3,4,5]];
+    assert_eq!(xs.splitn_mut(0, |x| *x % 2 == 0).collect::<Vec<_>>(),
+               splits);
+    let splits: &[&mut[_]] = &[&mut [1], &mut [3,4,5]];
+    assert_eq!(xs.splitn_mut(1, |x| *x % 2 == 0).collect::<Vec<_>>(),
+               splits);
+    let splits: &[&mut[_]] = &[&mut [], &mut [], &mut [], &mut [4,5]];
+    assert_eq!(xs.splitn_mut(3, |_| true).collect::<Vec<_>>(),
+               splits);
+
+    let xs: &mut [i32] = &mut [];
+    let splits: &[&mut[i32]] = &[&mut []];
+    assert_eq!(xs.splitn_mut(1, |x| *x == 5).collect::<Vec<_>>(),
+               splits);
+}
+
+#[test]
+fn test_rsplitator() {
+    let xs = &[1,2,3,4,5];
+
+    let splits: &[&[_]] = &[&[5], &[3], &[1]];
+    assert_eq!(xs.split(|x| *x % 2 == 0).rev().collect::<Vec<_>>(),
+               splits);
+    let splits: &[&[_]] = &[&[2,3,4,5], &[]];
+    assert_eq!(xs.split(|x| *x == 1).rev().collect::<Vec<_>>(),
+               splits);
+    let splits: &[&[_]] = &[&[], &[1,2,3,4]];
+    assert_eq!(xs.split(|x| *x == 5).rev().collect::<Vec<_>>(),
+               splits);
+    let splits: &[&[_]] = &[&[1,2,3,4,5]];
+    assert_eq!(xs.split(|x| *x == 10).rev().collect::<Vec<_>>(),
+               splits);
+
+    let xs: &[i32] = &[];
+    let splits: &[&[i32]] = &[&[]];
+    assert_eq!(xs.split(|x| *x == 5).rev().collect::<Vec<&[i32]>>(), splits);
+}
+
+#[test]
+fn test_rsplitnator() {
+    let xs = &[1,2,3,4,5];
+
+    let splits: &[&[_]] = &[&[1,2,3,4,5]];
+    assert_eq!(xs.rsplitn(0, |x| *x % 2 == 0).collect::<Vec<_>>(),
+               splits);
+    let splits: &[&[_]] = &[&[5], &[1,2,3]];
+    assert_eq!(xs.rsplitn(1, |x| *x % 2 == 0).collect::<Vec<_>>(),
+               splits);
+    let splits: &[&[_]] = &[&[], &[], &[], &[1,2]];
+    assert_eq!(xs.rsplitn(3, |_| true).collect::<Vec<_>>(),
+               splits);
+
+    let xs: &[i32]  = &[];
+    let splits: &[&[i32]] = &[&[]];
+    assert_eq!(xs.rsplitn(1, |x| *x == 5).collect::<Vec<&[i32]>>(), splits);
+}
+
+#[test]
+fn test_windowsator() {
+    let v = &[1,2,3,4];
+
+    let wins: &[&[_]] = &[&[1,2], &[2,3], &[3,4]];
+    assert_eq!(v.windows(2).collect::<Vec<_>>(), wins);
+
+    let wins: &[&[_]] = &[&[1,2,3], &[2,3,4]];
+    assert_eq!(v.windows(3).collect::<Vec<_>>(), wins);
+    assert!(v.windows(6).next().is_none());
+
+    let wins: &[&[_]] = &[&[3,4], &[2,3], &[1,2]];
+    assert_eq!(v.windows(2).rev().collect::<Vec<&[_]>>(), wins);
+    let mut it = v.windows(2);
+    assert_eq!(it.indexable(), 3);
+    let win: &[_] = &[1,2];
+    assert_eq!(it.idx(0).unwrap(), win);
+    let win: &[_] = &[2,3];
+    assert_eq!(it.idx(1).unwrap(), win);
+    let win: &[_] = &[3,4];
+    assert_eq!(it.idx(2).unwrap(), win);
+    assert_eq!(it.idx(3), None);
+}
+
+#[test]
+#[should_panic]
+fn test_windowsator_0() {
+    let v = &[1,2,3,4];
+    let _it = v.windows(0);
+}
+
+#[test]
+fn test_chunksator() {
+    let v = &[1,2,3,4,5];
+
+    assert_eq!(v.chunks(2).len(), 3);
+
+    let chunks: &[&[_]] = &[&[1,2], &[3,4], &[5]];
+    assert_eq!(v.chunks(2).collect::<Vec<_>>(), chunks);
+    let chunks: &[&[_]] = &[&[1,2,3], &[4,5]];
+    assert_eq!(v.chunks(3).collect::<Vec<_>>(), chunks);
+    let chunks: &[&[_]] = &[&[1,2,3,4,5]];
+    assert_eq!(v.chunks(6).collect::<Vec<_>>(), chunks);
+
+    let chunks: &[&[_]] = &[&[5], &[3,4], &[1,2]];
+    assert_eq!(v.chunks(2).rev().collect::<Vec<_>>(), chunks);
+    let mut it = v.chunks(2);
+    assert_eq!(it.indexable(), 3);
+
+    let chunk: &[_] = &[1,2];
+    assert_eq!(it.idx(0).unwrap(), chunk);
+    let chunk: &[_] = &[3,4];
+    assert_eq!(it.idx(1).unwrap(), chunk);
+    let chunk: &[_] = &[5];
+    assert_eq!(it.idx(2).unwrap(), chunk);
+    assert_eq!(it.idx(3), None);
+}
+
+#[test]
+#[should_panic]
+fn test_chunksator_0() {
+    let v = &[1,2,3,4];
+    let _it = v.chunks(0);
+}
+
+#[test]
+fn test_move_from() {
+    let mut a = [1,2,3,4,5];
+    let b = vec![6,7,8];
+    assert_eq!(a.move_from(b, 0, 3), 3);
+    assert!(a == [6,7,8,4,5]);
+    let mut a = [7,2,8,1];
+    let b = vec![3,1,4,1,5,9];
+    assert_eq!(a.move_from(b, 0, 6), 4);
+    assert!(a == [3,1,4,1]);
+    let mut a = [1,2,3,4];
+    let b = vec![5,6,7,8,9,0];
+    assert_eq!(a.move_from(b, 2, 3), 1);
+    assert!(a == [7,2,3,4]);
+    let mut a = [1,2,3,4,5];
+    let b = vec![5,6,7,8,9,0];
+    assert_eq!(a[2..4].move_from(b,1,6), 2);
+    assert!(a == [1,2,6,7,5]);
+}
+
+#[test]
+fn test_reverse_part() {
+    let mut values = [1,2,3,4,5];
+    values[1..4].reverse();
+    assert!(values == [1,4,3,2,5]);
+}
+
+#[test]
+fn test_show() {
+    macro_rules! test_show_vec {
+        ($x:expr, $x_str:expr) => ({
+            let (x, x_str) = ($x, $x_str);
+            assert_eq!(format!("{:?}", x), x_str);
+            assert_eq!(format!("{:?}", x), x_str);
+        })
+    }
+    let empty = Vec::<i32>::new();
+    test_show_vec!(empty, "[]");
+    test_show_vec!(vec![1], "[1]");
+    test_show_vec!(vec![1, 2, 3], "[1, 2, 3]");
+    test_show_vec!(vec![vec![], vec![1], vec![1, 1]],
+                   "[[], [1], [1, 1]]");
+
+    let empty_mut: &mut [i32] = &mut[];
+    test_show_vec!(empty_mut, "[]");
+    let v = &mut[1];
+    test_show_vec!(v, "[1]");
+    let v = &mut[1, 2, 3];
+    test_show_vec!(v, "[1, 2, 3]");
+    let v: &mut[&mut[_]] = &mut[&mut[], &mut[1], &mut[1, 1]];
+    test_show_vec!(v, "[[], [1], [1, 1]]");
+}
+
+#[test]
+fn test_vec_default() {
+    macro_rules! t {
+        ($ty:ty) => {{
+            let v: $ty = Default::default();
+            assert!(v.is_empty());
+        }}
+    }
+
+    t!(&[i32]);
+    t!(Vec<i32>);
+}
+
+#[test]
+fn test_bytes_set_memory() {
+    use std::slice::bytes::MutableByteVector;
+
+    let mut values = [1,2,3,4,5];
+    values[0..5].set_memory(0xAB);
+    assert!(values == [0xAB, 0xAB, 0xAB, 0xAB, 0xAB]);
+    values[2..4].set_memory(0xFF);
+    assert!(values == [0xAB, 0xAB, 0xFF, 0xFF, 0xAB]);
+}
+
+#[test]
+#[should_panic]
+fn test_overflow_does_not_cause_segfault() {
+    let mut v = vec![];
+    v.reserve_exact(-1);
+    v.push(1);
+    v.push(2);
+}
+
+#[test]
+#[should_panic]
+fn test_overflow_does_not_cause_segfault_managed() {
+    let mut v = vec![Rc::new(1)];
+    v.reserve_exact(-1);
+    v.push(Rc::new(2));
+}
+
+#[test]
+fn test_mut_split_at() {
+    let mut values = [1u8,2,3,4,5];
+    {
+        let (left, right) = values.split_at_mut(2);
+        {
+            let left: &[_] = left;
+            assert!(left[..left.len()] == [1, 2]);
+        }
+        for p in left {
+            *p += 1;
+        }
+
+        {
+            let right: &[_] = right;
+            assert!(right[..right.len()] == [3, 4, 5]);
+        }
+        for p in right {
+            *p += 2;
+        }
+    }
+
+    assert!(values == [2, 3, 5, 6, 7]);
+}
+
+#[derive(Clone, PartialEq)]
+struct Foo;
+
+#[test]
+fn test_iter_zero_sized() {
+    let mut v = vec![Foo, Foo, Foo];
+    assert_eq!(v.len(), 3);
+    let mut cnt = 0;
+
+    for f in &v {
+        assert!(*f == Foo);
+        cnt += 1;
+    }
+    assert_eq!(cnt, 3);
+
+    for f in &v[1..3] {
+        assert!(*f == Foo);
+        cnt += 1;
+    }
+    assert_eq!(cnt, 5);
+
+    for f in &mut v {
+        assert!(*f == Foo);
+        cnt += 1;
+    }
+    assert_eq!(cnt, 8);
+
+    for f in v {
+        assert!(f == Foo);
+        cnt += 1;
+    }
+    assert_eq!(cnt, 11);
+
+    let xs: [Foo; 3] = [Foo, Foo, Foo];
+    cnt = 0;
+    for f in &xs {
+        assert!(*f == Foo);
+        cnt += 1;
+    }
+    assert!(cnt == 3);
+}
+
+#[test]
+fn test_shrink_to_fit() {
+    let mut xs = vec![0, 1, 2, 3];
+    for i in 4..100 {
+        xs.push(i)
+    }
+    assert_eq!(xs.capacity(), 128);
+    xs.shrink_to_fit();
+    assert_eq!(xs.capacity(), 100);
+    assert_eq!(xs, (0..100).collect::<Vec<_>>());
+}
+
+#[test]
+fn test_starts_with() {
+    assert!(b"foobar".starts_with(b"foo"));
+    assert!(!b"foobar".starts_with(b"oob"));
+    assert!(!b"foobar".starts_with(b"bar"));
+    assert!(!b"foo".starts_with(b"foobar"));
+    assert!(!b"bar".starts_with(b"foobar"));
+    assert!(b"foobar".starts_with(b"foobar"));
+    let empty: &[u8] = &[];
+    assert!(empty.starts_with(empty));
+    assert!(!empty.starts_with(b"foo"));
+    assert!(b"foobar".starts_with(empty));
+}
+
+#[test]
+fn test_ends_with() {
+    assert!(b"foobar".ends_with(b"bar"));
+    assert!(!b"foobar".ends_with(b"oba"));
+    assert!(!b"foobar".ends_with(b"foo"));
+    assert!(!b"foo".ends_with(b"foobar"));
+    assert!(!b"bar".ends_with(b"foobar"));
+    assert!(b"foobar".ends_with(b"foobar"));
+    let empty: &[u8] = &[];
+    assert!(empty.ends_with(empty));
+    assert!(!empty.ends_with(b"foo"));
+    assert!(b"foobar".ends_with(empty));
+}
+
+#[test]
+fn test_mut_splitator() {
+    let mut xs = [0,1,0,2,3,0,0,4,5,0];
+    assert_eq!(xs.split_mut(|x| *x == 0).count(), 6);
+    for slice in xs.split_mut(|x| *x == 0) {
+        slice.reverse();
+    }
+    assert!(xs == [0,1,0,3,2,0,0,5,4,0]);
+
+    let mut xs = [0,1,0,2,3,0,0,4,5,0,6,7];
+    for slice in xs.split_mut(|x| *x == 0).take(5) {
+        slice.reverse();
+    }
+    assert!(xs == [0,1,0,3,2,0,0,5,4,0,6,7]);
+}
+
+#[test]
+fn test_mut_splitator_rev() {
+    let mut xs = [1,2,0,3,4,0,0,5,6,0];
+    for slice in xs.split_mut(|x| *x == 0).rev().take(4) {
+        slice.reverse();
+    }
+    assert!(xs == [1,2,0,4,3,0,0,6,5,0]);
+}
+
+#[test]
+fn test_get_mut() {
+    let mut v = [0,1,2];
+    assert_eq!(v.get_mut(3), None);
+    v.get_mut(1).map(|e| *e = 7);
+    assert_eq!(v[1], 7);
+    let mut x = 2;
+    assert_eq!(v.get_mut(2), Some(&mut x));
+}
+
+#[test]
+fn test_mut_chunks() {
+    let mut v = [0, 1, 2, 3, 4, 5, 6];
+    assert_eq!(v.chunks_mut(2).len(), 4);
+    for (i, chunk) in v.chunks_mut(3).enumerate() {
+        for x in chunk {
+            *x = i as u8;
+        }
+    }
+    let result = [0, 0, 0, 1, 1, 1, 2];
+    assert!(v == result);
+}
+
+#[test]
+fn test_mut_chunks_rev() {
+    let mut v = [0, 1, 2, 3, 4, 5, 6];
+    for (i, chunk) in v.chunks_mut(3).rev().enumerate() {
+        for x in chunk {
+            *x = i as u8;
+        }
+    }
+    let result = [2, 2, 2, 1, 1, 1, 0];
+    assert!(v == result);
+}
+
+#[test]
+#[should_panic]
+fn test_mut_chunks_0() {
+    let mut v = [1, 2, 3, 4];
+    let _it = v.chunks_mut(0);
+}
+
+#[test]
+fn test_mut_last() {
+    let mut x = [1, 2, 3, 4, 5];
+    let h = x.last_mut();
+    assert_eq!(*h.unwrap(), 5);
+
+    let y: &mut [i32] = &mut [];
+    assert!(y.last_mut().is_none());
+}
+
+#[test]
+fn test_to_vec() {
+    let xs: Box<_> = box [1, 2, 3];
+    let ys = xs.to_vec();
+    assert_eq!(ys, [1, 2, 3]);
+}
+
+mod bench {
+    use std::iter::repeat;
+    use std::{mem, ptr};
+    use std::rand::{Rng, weak_rng};
+
+    use test::{Bencher, black_box};
+
+    #[bench]
+    fn iterator(b: &mut Bencher) {
+        // peculiar numbers to stop LLVM from optimising the summation
+        // out.
+        let v: Vec<_> = (0..100).map(|i| i ^ (i << 1) ^ (i >> 1)).collect();
+
+        b.iter(|| {
+            let mut sum = 0;
+            for x in &v {
+                sum += *x;
+            }
+            // sum == 11806, to stop dead code elimination.
+            if sum == 0 {panic!()}
+        })
+    }
+
+    #[bench]
+    fn mut_iterator(b: &mut Bencher) {
+        let mut v: Vec<_> = repeat(0).take(100).collect();
+
+        b.iter(|| {
+            let mut i = 0;
+            for x in &mut v {
+                *x = i;
+                i += 1;
+            }
+        })
+    }
+
+    #[bench]
+    fn concat(b: &mut Bencher) {
+        let xss: Vec<Vec<i32>> =
+            (0..100).map(|i| (0..i).collect()).collect();
+        b.iter(|| {
+            xss.concat();
+        });
+    }
+
+    #[bench]
+    fn connect(b: &mut Bencher) {
+        let xss: Vec<Vec<i32>> =
+            (0..100).map(|i| (0..i).collect()).collect();
+        b.iter(|| {
+            xss.connect(&0)
+        });
+    }
+
+    #[bench]
+    fn push(b: &mut Bencher) {
+        let mut vec = Vec::<i32>::new();
+        b.iter(|| {
+            vec.push(0);
+            black_box(&vec);
+        });
+    }
+
+    #[bench]
+    fn starts_with_same_vector(b: &mut Bencher) {
+        let vec: Vec<_> = (0..100).collect();
+        b.iter(|| {
+            vec.starts_with(&vec)
+        })
+    }
+
+    #[bench]
+    fn starts_with_single_element(b: &mut Bencher) {
+        let vec: Vec<_> = vec![0];
+        b.iter(|| {
+            vec.starts_with(&vec)
+        })
+    }
+
+    #[bench]
+    fn starts_with_diff_one_element_at_end(b: &mut Bencher) {
+        let vec: Vec<_> = (0..100).collect();
+        let mut match_vec: Vec<_> = (0..99).collect();
+        match_vec.push(0);
+        b.iter(|| {
+            vec.starts_with(&match_vec)
+        })
+    }
+
+    #[bench]
+    fn ends_with_same_vector(b: &mut Bencher) {
+        let vec: Vec<_> = (0..100).collect();
+        b.iter(|| {
+            vec.ends_with(&vec)
+        })
+    }
+
+    #[bench]
+    fn ends_with_single_element(b: &mut Bencher) {
+        let vec: Vec<_> = vec![0];
+        b.iter(|| {
+            vec.ends_with(&vec)
+        })
+    }
+
+    #[bench]
+    fn ends_with_diff_one_element_at_beginning(b: &mut Bencher) {
+        let vec: Vec<_> = (0..100).collect();
+        let mut match_vec: Vec<_> = (0..100).collect();
+        match_vec[0] = 200;
+        b.iter(|| {
+            vec.starts_with(&match_vec)
+        })
+    }
+
+    #[bench]
+    fn contains_last_element(b: &mut Bencher) {
+        let vec: Vec<_> = (0..100).collect();
+        b.iter(|| {
+            vec.contains(&99)
+        })
+    }
+
+    #[bench]
+    fn zero_1kb_from_elem(b: &mut Bencher) {
+        b.iter(|| {
+            repeat(0u8).take(1024).collect::<Vec<_>>()
+        });
+    }
+
+    #[bench]
+    fn zero_1kb_set_memory(b: &mut Bencher) {
+        b.iter(|| {
+            let mut v = Vec::<u8>::with_capacity(1024);
+            unsafe {
+                let vp = v.as_mut_ptr();
+                ptr::set_memory(vp, 0, 1024);
+                v.set_len(1024);
+            }
+            v
+        });
+    }
+
+    #[bench]
+    fn zero_1kb_loop_set(b: &mut Bencher) {
+        b.iter(|| {
+            let mut v = Vec::<u8>::with_capacity(1024);
+            unsafe {
+                v.set_len(1024);
+            }
+            for i in 0..1024 {
+                v[i] = 0;
+            }
+        });
+    }
+
+    #[bench]
+    fn zero_1kb_mut_iter(b: &mut Bencher) {
+        b.iter(|| {
+            let mut v = Vec::<u8>::with_capacity(1024);
+            unsafe {
+                v.set_len(1024);
+            }
+            for x in &mut v {
+                *x = 0;
+            }
+            v
+        });
+    }
+
+    #[bench]
+    fn random_inserts(b: &mut Bencher) {
+        let mut rng = weak_rng();
+        b.iter(|| {
+            let mut v: Vec<_> = repeat((0, 0)).take(30).collect();
+            for _ in 0..100 {
+                let l = v.len();
+                v.insert(rng.gen::<usize>() % (l + 1),
+                         (1, 1));
+            }
+        })
+    }
+    #[bench]
+    fn random_removes(b: &mut Bencher) {
+        let mut rng = weak_rng();
+        b.iter(|| {
+            let mut v: Vec<_> = repeat((0, 0)).take(130).collect();
+            for _ in 0..100 {
+                let l = v.len();
+                v.remove(rng.gen::<usize>() % l);
+            }
+        })
+    }
+
+    #[bench]
+    fn sort_random_small(b: &mut Bencher) {
+        let mut rng = weak_rng();
+        b.iter(|| {
+            let mut v: Vec<_> = rng.gen_iter::<u64>().take(5).collect();
+            v.sort();
+        });
+        b.bytes = 5 * mem::size_of::<u64>() as u64;
+    }
+
+    #[bench]
+    fn sort_random_medium(b: &mut Bencher) {
+        let mut rng = weak_rng();
+        b.iter(|| {
+            let mut v: Vec<_> = rng.gen_iter::<u64>().take(100).collect();
+            v.sort();
+        });
+        b.bytes = 100 * mem::size_of::<u64>() as u64;
+    }
+
+    #[bench]
+    fn sort_random_large(b: &mut Bencher) {
+        let mut rng = weak_rng();
+        b.iter(|| {
+            let mut v: Vec<_> = rng.gen_iter::<u64>().take(10000).collect();
+            v.sort();
+        });
+        b.bytes = 10000 * mem::size_of::<u64>() as u64;
+    }
+
+    #[bench]
+    fn sort_sorted(b: &mut Bencher) {
+        let mut v: Vec<_> = (0..10000).collect();
+        b.iter(|| {
+            v.sort();
+        });
+        b.bytes = (v.len() * mem::size_of_val(&v[0])) as u64;
+    }
+
+    type BigSortable = (u64, u64, u64, u64);
+
+    #[bench]
+    fn sort_big_random_small(b: &mut Bencher) {
+        let mut rng = weak_rng();
+        b.iter(|| {
+            let mut v = rng.gen_iter::<BigSortable>().take(5)
+                           .collect::<Vec<BigSortable>>();
+            v.sort();
+        });
+        b.bytes = 5 * mem::size_of::<BigSortable>() as u64;
+    }
+
+    #[bench]
+    fn sort_big_random_medium(b: &mut Bencher) {
+        let mut rng = weak_rng();
+        b.iter(|| {
+            let mut v = rng.gen_iter::<BigSortable>().take(100)
+                           .collect::<Vec<BigSortable>>();
+            v.sort();
+        });
+        b.bytes = 100 * mem::size_of::<BigSortable>() as u64;
+    }
+
+    #[bench]
+    fn sort_big_random_large(b: &mut Bencher) {
+        let mut rng = weak_rng();
+        b.iter(|| {
+            let mut v = rng.gen_iter::<BigSortable>().take(10000)
+                           .collect::<Vec<BigSortable>>();
+            v.sort();
+        });
+        b.bytes = 10000 * mem::size_of::<BigSortable>() as u64;
+    }
+
+    #[bench]
+    fn sort_big_sorted(b: &mut Bencher) {
+        let mut v: Vec<BigSortable> = (0..10000).map(|i| (i, i, i, i)).collect();
+        b.iter(|| {
+            v.sort();
+        });
+        b.bytes = (v.len() * mem::size_of_val(&v[0])) as u64;
+    }
+}
diff --git a/src/libcollectionstest/str.rs b/src/libcollectionstest/str.rs
new file mode 100644
index 00000000000..79c2d719862
--- /dev/null
+++ b/src/libcollectionstest/str.rs
@@ -0,0 +1,1668 @@
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::cmp::Ordering::{Equal, Greater, Less};
+use std::iter::AdditiveIterator;
+use std::str::{Utf8Error, from_utf8};
+
+#[test]
+fn test_le() {
+    assert!("" <= "");
+    assert!("" <= "foo");
+    assert!("foo" <= "foo");
+    assert!("foo" != "bar");
+}
+
+#[test]
+fn test_len() {
+    assert_eq!("".len(), 0);
+    assert_eq!("hello world".len(), 11);
+    assert_eq!("\x63".len(), 1);
+    assert_eq!("\u{a2}".len(), 2);
+    assert_eq!("\u{3c0}".len(), 2);
+    assert_eq!("\u{2620}".len(), 3);
+    assert_eq!("\u{1d11e}".len(), 4);
+
+    assert_eq!("".chars().count(), 0);
+    assert_eq!("hello world".chars().count(), 11);
+    assert_eq!("\x63".chars().count(), 1);
+    assert_eq!("\u{a2}".chars().count(), 1);
+    assert_eq!("\u{3c0}".chars().count(), 1);
+    assert_eq!("\u{2620}".chars().count(), 1);
+    assert_eq!("\u{1d11e}".chars().count(), 1);
+    assert_eq!("ประเทศไทย中华Việt Nam".chars().count(), 19);
+
+    assert_eq!("hello".width(false), 10);
+    assert_eq!("hello".width(true), 10);
+    assert_eq!("\0\0\0\0\0".width(false), 0);
+    assert_eq!("\0\0\0\0\0".width(true), 0);
+    assert_eq!("".width(false), 0);
+    assert_eq!("".width(true), 0);
+    assert_eq!("\u{2081}\u{2082}\u{2083}\u{2084}".width(false), 4);
+    assert_eq!("\u{2081}\u{2082}\u{2083}\u{2084}".width(true), 8);
+}
+
+#[test]
+fn test_find() {
+    assert_eq!("hello".find('l'), Some(2));
+    assert_eq!("hello".find(|c:char| c == 'o'), Some(4));
+    assert!("hello".find('x').is_none());
+    assert!("hello".find(|c:char| c == 'x').is_none());
+    assert_eq!("ประเทศไทย中华Việt Nam".find('华'), Some(30));
+    assert_eq!("ประเทศไทย中华Việt Nam".find(|c: char| c == '华'), Some(30));
+}
+
+#[test]
+fn test_rfind() {
+    assert_eq!("hello".rfind('l'), Some(3));
+    assert_eq!("hello".rfind(|c:char| c == 'o'), Some(4));
+    assert!("hello".rfind('x').is_none());
+    assert!("hello".rfind(|c:char| c == 'x').is_none());
+    assert_eq!("ประเทศไทย中华Việt Nam".rfind('华'), Some(30));
+    assert_eq!("ประเทศไทย中华Việt Nam".rfind(|c: char| c == '华'), Some(30));
+}
+
+#[test]
+fn test_collect() {
+    let empty = String::from_str("");
+    let s: String = empty.chars().collect();
+    assert_eq!(empty, s);
+    let data = String::from_str("ประเทศไทย中");
+    let s: String = data.chars().collect();
+    assert_eq!(data, s);
+}
+
+#[test]
+fn test_into_bytes() {
+    let data = String::from_str("asdf");
+    let buf = data.into_bytes();
+    assert_eq!(b"asdf", buf);
+}
+
+#[test]
+fn test_find_str() {
+    // byte positions
+    assert_eq!("".find_str(""), Some(0));
+    assert!("banana".find_str("apple pie").is_none());
+
+    let data = "abcabc";
+    assert_eq!(data[0..6].find_str("ab"), Some(0));
+    assert_eq!(data[2..6].find_str("ab"), Some(3 - 2));
+    assert!(data[2..4].find_str("ab").is_none());
+
+    let string = "ประเทศไทย中华Việt Nam";
+    let mut data = String::from_str(string);
+    data.push_str(string);
+    assert!(data.find_str("ไท华").is_none());
+    assert_eq!(data[0..43].find_str(""), Some(0));
+    assert_eq!(data[6..43].find_str(""), Some(6 - 6));
+
+    assert_eq!(data[0..43].find_str("ประ"), Some( 0));
+    assert_eq!(data[0..43].find_str("ทศไ"), Some(12));
+    assert_eq!(data[0..43].find_str("ย中"), Some(24));
+    assert_eq!(data[0..43].find_str("iệt"), Some(34));
+    assert_eq!(data[0..43].find_str("Nam"), Some(40));
+
+    assert_eq!(data[43..86].find_str("ประ"), Some(43 - 43));
+    assert_eq!(data[43..86].find_str("ทศไ"), Some(55 - 43));
+    assert_eq!(data[43..86].find_str("ย中"), Some(67 - 43));
+    assert_eq!(data[43..86].find_str("iệt"), Some(77 - 43));
+    assert_eq!(data[43..86].find_str("Nam"), Some(83 - 43));
+}
+
+#[test]
+fn test_slice_chars() {
+    fn t(a: &str, b: &str, start: usize) {
+        assert_eq!(a.slice_chars(start, start + b.chars().count()), b);
+    }
+    t("", "", 0);
+    t("hello", "llo", 2);
+    t("hello", "el", 1);
+    t("αβλ", "β", 1);
+    t("αβλ", "", 3);
+    assert_eq!("ะเทศไท", "ประเทศไทย中华Việt Nam".slice_chars(2, 8));
+}
+
+fn s(x: &str) -> String { x.to_string() }
+
+macro_rules! test_concat {
+    ($expected: expr, $string: expr) => {
+        {
+            let s: String = $string.concat();
+            assert_eq!($expected, s);
+        }
+    }
+}
+
+#[test]
+fn test_concat_for_different_types() {
+    test_concat!("ab", vec![s("a"), s("b")]);
+    test_concat!("ab", vec!["a", "b"]);
+    test_concat!("ab", vec!["a", "b"]);
+    test_concat!("ab", vec![s("a"), s("b")]);
+}
+
+#[test]
+fn test_concat_for_different_lengths() {
+    let empty: &[&str] = &[];
+    test_concat!("", empty);
+    test_concat!("a", ["a"]);
+    test_concat!("ab", ["a", "b"]);
+    test_concat!("abc", ["", "a", "bc"]);
+}
+
+macro_rules! test_connect {
+    ($expected: expr, $string: expr, $delim: expr) => {
+        {
+            let s = $string.connect($delim);
+            assert_eq!($expected, s);
+        }
+    }
+}
+
+#[test]
+fn test_connect_for_different_types() {
+    test_connect!("a-b", ["a", "b"], "-");
+    let hyphen = "-".to_string();
+    test_connect!("a-b", [s("a"), s("b")], &*hyphen);
+    test_connect!("a-b", vec!["a", "b"], &*hyphen);
+    test_connect!("a-b", &*vec!["a", "b"], "-");
+    test_connect!("a-b", vec![s("a"), s("b")], "-");
+}
+
+#[test]
+fn test_connect_for_different_lengths() {
+    let empty: &[&str] = &[];
+    test_connect!("", empty, "-");
+    test_connect!("a", ["a"], "-");
+    test_connect!("a-b", ["a", "b"], "-");
+    test_connect!("-a-bc", ["", "a", "bc"], "-");
+}
+
+#[test]
+fn test_unsafe_slice() {
+    assert_eq!("ab", unsafe {"abc".slice_unchecked(0, 2)});
+    assert_eq!("bc", unsafe {"abc".slice_unchecked(1, 3)});
+    assert_eq!("", unsafe {"abc".slice_unchecked(1, 1)});
+    fn a_million_letter_a() -> String {
+        let mut i = 0;
+        let mut rs = String::new();
+        while i < 100000 {
+            rs.push_str("aaaaaaaaaa");
+            i += 1;
+        }
+        rs
+    }
+    fn half_a_million_letter_a() -> String {
+        let mut i = 0;
+        let mut rs = String::new();
+        while i < 100000 {
+            rs.push_str("aaaaa");
+            i += 1;
+        }
+        rs
+    }
+    let letters = a_million_letter_a();
+    assert!(half_a_million_letter_a() ==
+        unsafe {String::from_str(letters.slice_unchecked(
+                                 0,
+                                 500000))});
+}
+
+#[test]
+fn test_starts_with() {
+    assert!(("".starts_with("")));
+    assert!(("abc".starts_with("")));
+    assert!(("abc".starts_with("a")));
+    assert!((!"a".starts_with("abc")));
+    assert!((!"".starts_with("abc")));
+    assert!((!"ödd".starts_with("-")));
+    assert!(("ödd".starts_with("öd")));
+}
+
+#[test]
+fn test_ends_with() {
+    assert!(("".ends_with("")));
+    assert!(("abc".ends_with("")));
+    assert!(("abc".ends_with("c")));
+    assert!((!"a".ends_with("abc")));
+    assert!((!"".ends_with("abc")));
+    assert!((!"ddö".ends_with("-")));
+    assert!(("ddö".ends_with("dö")));
+}
+
+#[test]
+fn test_is_empty() {
+    assert!("".is_empty());
+    assert!(!"a".is_empty());
+}
+
+#[test]
+fn test_replace() {
+    let a = "a";
+    assert_eq!("".replace(a, "b"), String::from_str(""));
+    assert_eq!("a".replace(a, "b"), String::from_str("b"));
+    assert_eq!("ab".replace(a, "b"), String::from_str("bb"));
+    let test = "test";
+    assert!(" test test ".replace(test, "toast") ==
+        String::from_str(" toast toast "));
+    assert_eq!(" test test ".replace(test, ""), String::from_str("   "));
+}
+
+#[test]
+fn test_replace_2a() {
+    let data = "ประเทศไทย中华";
+    let repl = "دولة الكويت";
+
+    let a = "ประเ";
+    let a2 = "دولة الكويتทศไทย中华";
+    assert_eq!(data.replace(a, repl), a2);
+}
+
+#[test]
+fn test_replace_2b() {
+    let data = "ประเทศไทย中华";
+    let repl = "دولة الكويت";
+
+    let b = "ะเ";
+    let b2 = "ปรدولة الكويتทศไทย中华";
+    assert_eq!(data.replace(b, repl), b2);
+}
+
+#[test]
+fn test_replace_2c() {
+    let data = "ประเทศไทย中华";
+    let repl = "دولة الكويت";
+
+    let c = "中华";
+    let c2 = "ประเทศไทยدولة الكويت";
+    assert_eq!(data.replace(c, repl), c2);
+}
+
+#[test]
+fn test_replace_2d() {
+    let data = "ประเทศไทย中华";
+    let repl = "دولة الكويت";
+
+    let d = "ไท华";
+    assert_eq!(data.replace(d, repl), data);
+}
+
+#[test]
+fn test_slice() {
+    assert_eq!("ab", "abc".slice(0, 2));
+    assert_eq!("bc", "abc".slice(1, 3));
+    assert_eq!("", "abc".slice(1, 1));
+    assert_eq!("\u{65e5}", "\u{65e5}\u{672c}".slice(0, 3));
+
+    let data = "ประเทศไทย中华";
+    assert_eq!("ป", data.slice(0, 3));
+    assert_eq!("ร", data.slice(3, 6));
+    assert_eq!("", data.slice(3, 3));
+    assert_eq!("华", data.slice(30, 33));
+
+    fn a_million_letter_x() -> String {
+        let mut i = 0;
+        let mut rs = String::new();
+        while i < 100000 {
+            rs.push_str("华华华华华华华华华华");
+            i += 1;
+        }
+        rs
+    }
+    fn half_a_million_letter_x() -> String {
+        let mut i = 0;
+        let mut rs = String::new();
+        while i < 100000 {
+            rs.push_str("华华华华华");
+            i += 1;
+        }
+        rs
+    }
+    let letters = a_million_letter_x();
+    assert!(half_a_million_letter_x() ==
+        String::from_str(letters.slice(0, 3 * 500000)));
+}
+
+#[test]
+fn test_slice_2() {
+    let ss = "中华Việt Nam";
+
+    assert_eq!("华", ss.slice(3, 6));
+    assert_eq!("Việt Nam", ss.slice(6, 16));
+
+    assert_eq!("ab", "abc".slice(0, 2));
+    assert_eq!("bc", "abc".slice(1, 3));
+    assert_eq!("", "abc".slice(1, 1));
+
+    assert_eq!("中", ss.slice(0, 3));
+    assert_eq!("华V", ss.slice(3, 7));
+    assert_eq!("", ss.slice(3, 3));
+    /*0: 中
+      3: 华
+      6: V
+      7: i
+      8: ệ
+     11: t
+     12:
+     13: N
+     14: a
+     15: m */
+}
+
+#[test]
+#[should_panic]
+fn test_slice_fail() {
+    "中华Việt Nam".slice(0, 2);
+}
+
+#[test]
+fn test_slice_from() {
+    assert_eq!("abcd".slice_from(0), "abcd");
+    assert_eq!("abcd".slice_from(2), "cd");
+    assert_eq!("abcd".slice_from(4), "");
+}
+#[test]
+fn test_slice_to() {
+    assert_eq!("abcd".slice_to(0), "");
+    assert_eq!("abcd".slice_to(2), "ab");
+    assert_eq!("abcd".slice_to(4), "abcd");
+}
+
+#[test]
+fn test_trim_left_matches() {
+    let v: &[char] = &[];
+    assert_eq!(" *** foo *** ".trim_left_matches(v), " *** foo *** ");
+    let chars: &[char] = &['*', ' '];
+    assert_eq!(" *** foo *** ".trim_left_matches(chars), "foo *** ");
+    assert_eq!(" ***  *** ".trim_left_matches(chars), "");
+    assert_eq!("foo *** ".trim_left_matches(chars), "foo *** ");
+
+    assert_eq!("11foo1bar11".trim_left_matches('1'), "foo1bar11");
+    let chars: &[char] = &['1', '2'];
+    assert_eq!("12foo1bar12".trim_left_matches(chars), "foo1bar12");
+    assert_eq!("123foo1bar123".trim_left_matches(|c: char| c.is_numeric()), "foo1bar123");
+}
+
+#[test]
+fn test_trim_right_matches() {
+    let v: &[char] = &[];
+    assert_eq!(" *** foo *** ".trim_right_matches(v), " *** foo *** ");
+    let chars: &[char] = &['*', ' '];
+    assert_eq!(" *** foo *** ".trim_right_matches(chars), " *** foo");
+    assert_eq!(" ***  *** ".trim_right_matches(chars), "");
+    assert_eq!(" *** foo".trim_right_matches(chars), " *** foo");
+
+    assert_eq!("11foo1bar11".trim_right_matches('1'), "11foo1bar");
+    let chars: &[char] = &['1', '2'];
+    assert_eq!("12foo1bar12".trim_right_matches(chars), "12foo1bar");
+    assert_eq!("123foo1bar123".trim_right_matches(|c: char| c.is_numeric()), "123foo1bar");
+}
+
+#[test]
+fn test_trim_matches() {
+    let v: &[char] = &[];
+    assert_eq!(" *** foo *** ".trim_matches(v), " *** foo *** ");
+    let chars: &[char] = &['*', ' '];
+    assert_eq!(" *** foo *** ".trim_matches(chars), "foo");
+    assert_eq!(" ***  *** ".trim_matches(chars), "");
+    assert_eq!("foo".trim_matches(chars), "foo");
+
+    assert_eq!("11foo1bar11".trim_matches('1'), "foo1bar");
+    let chars: &[char] = &['1', '2'];
+    assert_eq!("12foo1bar12".trim_matches(chars), "foo1bar");
+    assert_eq!("123foo1bar123".trim_matches(|c: char| c.is_numeric()), "foo1bar");
+}
+
+#[test]
+fn test_trim_left() {
+    assert_eq!("".trim_left(), "");
+    assert_eq!("a".trim_left(), "a");
+    assert_eq!("    ".trim_left(), "");
+    assert_eq!("     blah".trim_left(), "blah");
+    assert_eq!("   \u{3000}  wut".trim_left(), "wut");
+    assert_eq!("hey ".trim_left(), "hey ");
+}
+
+#[test]
+fn test_trim_right() {
+    assert_eq!("".trim_right(), "");
+    assert_eq!("a".trim_right(), "a");
+    assert_eq!("    ".trim_right(), "");
+    assert_eq!("blah     ".trim_right(), "blah");
+    assert_eq!("wut   \u{3000}  ".trim_right(), "wut");
+    assert_eq!(" hey".trim_right(), " hey");
+}
+
+#[test]
+fn test_trim() {
+    assert_eq!("".trim(), "");
+    assert_eq!("a".trim(), "a");
+    assert_eq!("    ".trim(), "");
+    assert_eq!("    blah     ".trim(), "blah");
+    assert_eq!("\nwut   \u{3000}  ".trim(), "wut");
+    assert_eq!(" hey dude ".trim(), "hey dude");
+}
+
+#[test]
+fn test_is_whitespace() {
+    assert!("".chars().all(|c| c.is_whitespace()));
+    assert!(" ".chars().all(|c| c.is_whitespace()));
+    assert!("\u{2009}".chars().all(|c| c.is_whitespace())); // Thin space
+    assert!("  \n\t   ".chars().all(|c| c.is_whitespace()));
+    assert!(!"   _   ".chars().all(|c| c.is_whitespace()));
+}
+
+#[test]
+fn test_slice_shift_char() {
+    let data = "ประเทศไทย中";
+    assert_eq!(data.slice_shift_char(), Some(('ป', "ระเทศไทย中")));
+}
+
+#[test]
+fn test_slice_shift_char_2() {
+    let empty = "";
+    assert_eq!(empty.slice_shift_char(), None);
+}
+
+#[test]
+fn test_is_utf8() {
+    // deny overlong encodings
+    assert!(from_utf8(&[0xc0, 0x80]).is_err());
+    assert!(from_utf8(&[0xc0, 0xae]).is_err());
+    assert!(from_utf8(&[0xe0, 0x80, 0x80]).is_err());
+    assert!(from_utf8(&[0xe0, 0x80, 0xaf]).is_err());
+    assert!(from_utf8(&[0xe0, 0x81, 0x81]).is_err());
+    assert!(from_utf8(&[0xf0, 0x82, 0x82, 0xac]).is_err());
+    assert!(from_utf8(&[0xf4, 0x90, 0x80, 0x80]).is_err());
+
+    // deny surrogates
+    assert!(from_utf8(&[0xED, 0xA0, 0x80]).is_err());
+    assert!(from_utf8(&[0xED, 0xBF, 0xBF]).is_err());
+
+    assert!(from_utf8(&[0xC2, 0x80]).is_ok());
+    assert!(from_utf8(&[0xDF, 0xBF]).is_ok());
+    assert!(from_utf8(&[0xE0, 0xA0, 0x80]).is_ok());
+    assert!(from_utf8(&[0xED, 0x9F, 0xBF]).is_ok());
+    assert!(from_utf8(&[0xEE, 0x80, 0x80]).is_ok());
+    assert!(from_utf8(&[0xEF, 0xBF, 0xBF]).is_ok());
+    assert!(from_utf8(&[0xF0, 0x90, 0x80, 0x80]).is_ok());
+    assert!(from_utf8(&[0xF4, 0x8F, 0xBF, 0xBF]).is_ok());
+}
+
+#[test]
+fn test_is_utf16() {
+    use unicode::str::is_utf16;
+
+    macro_rules! pos {
+        ($($e:expr),*) => { { $(assert!(is_utf16($e));)* } }
+    }
+
+    // non-surrogates
+    pos!(&[0x0000],
+         &[0x0001, 0x0002],
+         &[0xD7FF],
+         &[0xE000]);
+
+    // surrogate pairs (randomly generated with Python 3's
+    // .encode('utf-16be'))
+    pos!(&[0xdb54, 0xdf16, 0xd880, 0xdee0, 0xdb6a, 0xdd45],
+         &[0xd91f, 0xdeb1, 0xdb31, 0xdd84, 0xd8e2, 0xde14],
+         &[0xdb9f, 0xdc26, 0xdb6f, 0xde58, 0xd850, 0xdfae]);
+
+    // mixtures (also random)
+    pos!(&[0xd921, 0xdcc2, 0x002d, 0x004d, 0xdb32, 0xdf65],
+         &[0xdb45, 0xdd2d, 0x006a, 0xdacd, 0xddfe, 0x0006],
+         &[0x0067, 0xd8ff, 0xddb7, 0x000f, 0xd900, 0xdc80]);
+
+    // negative tests
+    macro_rules! neg {
+        ($($e:expr),*) => { { $(assert!(!is_utf16($e));)* } }
+    }
+
+    neg!(
+        // surrogate + regular unit
+        &[0xdb45, 0x0000],
+        // surrogate + lead surrogate
+        &[0xd900, 0xd900],
+        // unterminated surrogate
+        &[0xd8ff],
+        // trail surrogate without a lead
+        &[0xddb7]);
+
+    // random byte sequences that Python 3's .decode('utf-16be')
+    // failed on
+    neg!(&[0x5b3d, 0x0141, 0xde9e, 0x8fdc, 0xc6e7],
+         &[0xdf5a, 0x82a5, 0x62b9, 0xb447, 0x92f3],
+         &[0xda4e, 0x42bc, 0x4462, 0xee98, 0xc2ca],
+         &[0xbe00, 0xb04a, 0x6ecb, 0xdd89, 0xe278],
+         &[0x0465, 0xab56, 0xdbb6, 0xa893, 0x665e],
+         &[0x6b7f, 0x0a19, 0x40f4, 0xa657, 0xdcc5],
+         &[0x9b50, 0xda5e, 0x24ec, 0x03ad, 0x6dee],
+         &[0x8d17, 0xcaa7, 0xf4ae, 0xdf6e, 0xbed7],
+         &[0xdaee, 0x2584, 0x7d30, 0xa626, 0x121a],
+         &[0xd956, 0x4b43, 0x7570, 0xccd6, 0x4f4a],
+         &[0x9dcf, 0x1b49, 0x4ba5, 0xfce9, 0xdffe],
+         &[0x6572, 0xce53, 0xb05a, 0xf6af, 0xdacf],
+         &[0x1b90, 0x728c, 0x9906, 0xdb68, 0xf46e],
+         &[0x1606, 0xbeca, 0xbe76, 0x860f, 0xdfa5],
+         &[0x8b4f, 0xde7a, 0xd220, 0x9fac, 0x2b6f],
+         &[0xb8fe, 0xebbe, 0xda32, 0x1a5f, 0x8b8b],
+         &[0x934b, 0x8956, 0xc434, 0x1881, 0xddf7],
+         &[0x5a95, 0x13fc, 0xf116, 0xd89b, 0x93f9],
+         &[0xd640, 0x71f1, 0xdd7d, 0x77eb, 0x1cd8],
+         &[0x348b, 0xaef0, 0xdb2c, 0xebf1, 0x1282],
+         &[0x50d7, 0xd824, 0x5010, 0xb369, 0x22ea]);
+}
+
+#[test]
+fn test_as_bytes() {
+    // no null
+    let v = [
+        224, 184, 168, 224, 185, 132, 224, 184, 151, 224, 184, 162, 228,
+        184, 173, 229, 141, 142, 86, 105, 225, 187, 135, 116, 32, 78, 97,
+        109
+    ];
+    let b: &[u8] = &[];
+    assert_eq!("".as_bytes(), b);
+    assert_eq!("abc".as_bytes(), b"abc");
+    assert_eq!("ศไทย中华Việt Nam".as_bytes(), v);
+}
+
+#[test]
+#[should_panic]
+fn test_as_bytes_fail() {
+    // Don't double free. (I'm not sure if this exercises the
+    // original problem code path anymore.)
+    let s = String::from_str("");
+    let _bytes = s.as_bytes();
+    panic!();
+}
+
+#[test]
+fn test_as_ptr() {
+    let buf = "hello".as_ptr();
+    unsafe {
+        assert_eq!(*buf.offset(0), b'h');
+        assert_eq!(*buf.offset(1), b'e');
+        assert_eq!(*buf.offset(2), b'l');
+        assert_eq!(*buf.offset(3), b'l');
+        assert_eq!(*buf.offset(4), b'o');
+    }
+}
+
+#[test]
+fn test_subslice_offset() {
+    let a = "kernelsprite";
+    let b = &a[7..a.len()];
+    let c = &a[0..a.len() - 6];
+    assert_eq!(a.subslice_offset(b), 7);
+    assert_eq!(a.subslice_offset(c), 0);
+
+    let string = "a\nb\nc";
+    let lines: Vec<&str> = string.lines().collect();
+    assert_eq!(string.subslice_offset(lines[0]), 0);
+    assert_eq!(string.subslice_offset(lines[1]), 2);
+    assert_eq!(string.subslice_offset(lines[2]), 4);
+}
+
+#[test]
+#[should_panic]
+fn test_subslice_offset_2() {
+    let a = "alchemiter";
+    let b = "cruxtruder";
+    a.subslice_offset(b);
+}
+
+#[test]
+fn vec_str_conversions() {
+    let s1: String = String::from_str("All mimsy were the borogoves");
+
+    let v: Vec<u8> = s1.as_bytes().to_vec();
+    let s2: String = String::from_str(from_utf8(&v).unwrap());
+    let mut i = 0;
+    let n1 = s1.len();
+    let n2 = v.len();
+    assert_eq!(n1, n2);
+    while i < n1 {
+        let a: u8 = s1.as_bytes()[i];
+        let b: u8 = s2.as_bytes()[i];
+        debug!("{}", a);
+        debug!("{}", b);
+        assert_eq!(a, b);
+        i += 1;
+    }
+}
+
+#[test]
+fn test_contains() {
+    assert!("abcde".contains("bcd"));
+    assert!("abcde".contains("abcd"));
+    assert!("abcde".contains("bcde"));
+    assert!("abcde".contains(""));
+    assert!("".contains(""));
+    assert!(!"abcde".contains("def"));
+    assert!(!"".contains("a"));
+
+    let data = "ประเทศไทย中华Việt Nam";
+    assert!(data.contains("ประเ"));
+    assert!(data.contains("ะเ"));
+    assert!(data.contains("中华"));
+    assert!(!data.contains("ไท华"));
+}
+
+#[test]
+fn test_contains_char() {
+    assert!("abc".contains_char('b'));
+    assert!("a".contains_char('a'));
+    assert!(!"abc".contains_char('d'));
+    assert!(!"".contains_char('a'));
+}
+
+#[test]
+fn test_char_at() {
+    let s = "ศไทย中华Việt Nam";
+    let v = vec!['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
+    let mut pos = 0;
+    for ch in &v {
+        assert!(s.char_at(pos) == *ch);
+        pos += ch.to_string().len();
+    }
+}
+
+#[test]
+fn test_char_at_reverse() {
+    let s = "ศไทย中华Việt Nam";
+    let v = vec!['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
+    let mut pos = s.len();
+    for ch in v.iter().rev() {
+        assert!(s.char_at_reverse(pos) == *ch);
+        pos -= ch.to_string().len();
+    }
+}
+
+#[test]
+fn test_escape_unicode() {
+    assert_eq!("abc".escape_unicode(),
+               String::from_str("\\u{61}\\u{62}\\u{63}"));
+    assert_eq!("a c".escape_unicode(),
+               String::from_str("\\u{61}\\u{20}\\u{63}"));
+    assert_eq!("\r\n\t".escape_unicode(),
+               String::from_str("\\u{d}\\u{a}\\u{9}"));
+    assert_eq!("'\"\\".escape_unicode(),
+               String::from_str("\\u{27}\\u{22}\\u{5c}"));
+    assert_eq!("\x00\x01\u{fe}\u{ff}".escape_unicode(),
+               String::from_str("\\u{0}\\u{1}\\u{fe}\\u{ff}"));
+    assert_eq!("\u{100}\u{ffff}".escape_unicode(),
+               String::from_str("\\u{100}\\u{ffff}"));
+    assert_eq!("\u{10000}\u{10ffff}".escape_unicode(),
+               String::from_str("\\u{10000}\\u{10ffff}"));
+    assert_eq!("ab\u{fb00}".escape_unicode(),
+               String::from_str("\\u{61}\\u{62}\\u{fb00}"));
+    assert_eq!("\u{1d4ea}\r".escape_unicode(),
+               String::from_str("\\u{1d4ea}\\u{d}"));
+}
+
+#[test]
+fn test_escape_default() {
+    assert_eq!("abc".escape_default(), String::from_str("abc"));
+    assert_eq!("a c".escape_default(), String::from_str("a c"));
+    assert_eq!("\r\n\t".escape_default(), String::from_str("\\r\\n\\t"));
+    assert_eq!("'\"\\".escape_default(), String::from_str("\\'\\\"\\\\"));
+    assert_eq!("\u{100}\u{ffff}".escape_default(),
+               String::from_str("\\u{100}\\u{ffff}"));
+    assert_eq!("\u{10000}\u{10ffff}".escape_default(),
+               String::from_str("\\u{10000}\\u{10ffff}"));
+    assert_eq!("ab\u{fb00}".escape_default(),
+               String::from_str("ab\\u{fb00}"));
+    assert_eq!("\u{1d4ea}\r".escape_default(),
+               String::from_str("\\u{1d4ea}\\r"));
+}
+
+#[test]
+fn test_total_ord() {
+    "1234".cmp("123") == Greater;
+    "123".cmp("1234") == Less;
+    "1234".cmp("1234") == Equal;
+    "12345555".cmp("123456") == Less;
+    "22".cmp("1234") == Greater;
+}
+
+#[test]
+fn test_char_range_at() {
+    let data = "b¢€𤭢𤭢€¢b";
+    assert_eq!('b', data.char_range_at(0).ch);
+    assert_eq!('¢', data.char_range_at(1).ch);
+    assert_eq!('€', data.char_range_at(3).ch);
+    assert_eq!('𤭢', data.char_range_at(6).ch);
+    assert_eq!('𤭢', data.char_range_at(10).ch);
+    assert_eq!('€', data.char_range_at(14).ch);
+    assert_eq!('¢', data.char_range_at(17).ch);
+    assert_eq!('b', data.char_range_at(19).ch);
+}
+
+#[test]
+fn test_char_range_at_reverse_underflow() {
+    assert_eq!("abc".char_range_at_reverse(0).next, 0);
+}
+
+#[test]
+fn test_iterator() {
+    let s = "ศไทย中华Việt Nam";
+    let v = ['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
+
+    let mut pos = 0;
+    let it = s.chars();
+
+    for c in it {
+        assert_eq!(c, v[pos]);
+        pos += 1;
+    }
+    assert_eq!(pos, v.len());
+}
+
+#[test]
+fn test_rev_iterator() {
+    let s = "ศไทย中华Việt Nam";
+    let v = ['m', 'a', 'N', ' ', 't', 'ệ','i','V','华','中','ย','ท','ไ','ศ'];
+
+    let mut pos = 0;
+    let it = s.chars().rev();
+
+    for c in it {
+        assert_eq!(c, v[pos]);
+        pos += 1;
+    }
+    assert_eq!(pos, v.len());
+}
+
+#[test]
+fn test_chars_decoding() {
+    let mut bytes = [0; 4];
+    for c in (0..0x110000).filter_map(::std::char::from_u32) {
+        let len = c.encode_utf8(&mut bytes).unwrap_or(0);
+        let s = ::std::str::from_utf8(&bytes[..len]).unwrap();
+        if Some(c) != s.chars().next() {
+            panic!("character {:x}={} does not decode correctly", c as u32, c);
+        }
+    }
+}
+
+#[test]
+fn test_chars_rev_decoding() {
+    let mut bytes = [0; 4];
+    for c in (0..0x110000).filter_map(::std::char::from_u32) {
+        let len = c.encode_utf8(&mut bytes).unwrap_or(0);
+        let s = ::std::str::from_utf8(&bytes[..len]).unwrap();
+        if Some(c) != s.chars().rev().next() {
+            panic!("character {:x}={} does not decode correctly", c as u32, c);
+        }
+    }
+}
+
+#[test]
+fn test_iterator_clone() {
+    let s = "ศไทย中华Việt Nam";
+    let mut it = s.chars();
+    it.next();
+    assert!(it.clone().zip(it).all(|(x,y)| x == y));
+}
+
+#[test]
+fn test_bytesator() {
+    let s = "ศไทย中华Việt Nam";
+    let v = [
+        224, 184, 168, 224, 185, 132, 224, 184, 151, 224, 184, 162, 228,
+        184, 173, 229, 141, 142, 86, 105, 225, 187, 135, 116, 32, 78, 97,
+        109
+    ];
+    let mut pos = 0;
+
+    for b in s.bytes() {
+        assert_eq!(b, v[pos]);
+        pos += 1;
+    }
+}
+
+#[test]
+fn test_bytes_revator() {
+    let s = "ศไทย中华Việt Nam";
+    let v = [
+        224, 184, 168, 224, 185, 132, 224, 184, 151, 224, 184, 162, 228,
+        184, 173, 229, 141, 142, 86, 105, 225, 187, 135, 116, 32, 78, 97,
+        109
+    ];
+    let mut pos = v.len();
+
+    for b in s.bytes().rev() {
+        pos -= 1;
+        assert_eq!(b, v[pos]);
+    }
+}
+
+#[test]
+fn test_char_indicesator() {
+    let s = "ศไทย中华Việt Nam";
+    let p = [0, 3, 6, 9, 12, 15, 18, 19, 20, 23, 24, 25, 26, 27];
+    let v = ['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
+
+    let mut pos = 0;
+    let it = s.char_indices();
+
+    for c in it {
+        assert_eq!(c, (p[pos], v[pos]));
+        pos += 1;
+    }
+    assert_eq!(pos, v.len());
+    assert_eq!(pos, p.len());
+}
+
+#[test]
+fn test_char_indices_revator() {
+    let s = "ศไทย中华Việt Nam";
+    let p = [27, 26, 25, 24, 23, 20, 19, 18, 15, 12, 9, 6, 3, 0];
+    let v = ['m', 'a', 'N', ' ', 't', 'ệ','i','V','华','中','ย','ท','ไ','ศ'];
+
+    let mut pos = 0;
+    let it = s.char_indices().rev();
+
+    for c in it {
+        assert_eq!(c, (p[pos], v[pos]));
+        pos += 1;
+    }
+    assert_eq!(pos, v.len());
+    assert_eq!(pos, p.len());
+}
+
+#[test]
+fn test_splitn_char_iterator() {
+    let data = "\nMäry häd ä little lämb\nLittle lämb\n";
+
+    let split: Vec<&str> = data.splitn(3, ' ').collect();
+    assert_eq!(split, ["\nMäry", "häd", "ä", "little lämb\nLittle lämb\n"]);
+
+    let split: Vec<&str> = data.splitn(3, |c: char| c == ' ').collect();
+    assert_eq!(split, ["\nMäry", "häd", "ä", "little lämb\nLittle lämb\n"]);
+
+    // Unicode
+    let split: Vec<&str> = data.splitn(3, 'ä').collect();
+    assert_eq!(split, ["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]);
+
+    let split: Vec<&str> = data.splitn(3, |c: char| c == 'ä').collect();
+    assert_eq!(split, ["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]);
+}
+
+#[test]
+fn test_split_char_iterator_no_trailing() {
+    let data = "\nMäry häd ä little lämb\nLittle lämb\n";
+
+    let split: Vec<&str> = data.split('\n').collect();
+    assert_eq!(split, ["", "Märy häd ä little lämb", "Little lämb", ""]);
+
+    let split: Vec<&str> = data.split_terminator('\n').collect();
+    assert_eq!(split, ["", "Märy häd ä little lämb", "Little lämb"]);
+}
+
+#[test]
+fn test_words() {
+    let data = "\n \tMäry   häd\tä  little lämb\nLittle lämb\n";
+    let words: Vec<&str> = data.words().collect();
+    assert_eq!(words, ["Märy", "häd", "ä", "little", "lämb", "Little", "lämb"])
+}
+
+#[test]
+fn test_nfd_chars() {
+    macro_rules! t {
+        ($input: expr, $expected: expr) => {
+            assert_eq!($input.nfd_chars().collect::<String>(), $expected);
+        }
+    }
+    t!("abc", "abc");
+    t!("\u{1e0b}\u{1c4}", "d\u{307}\u{1c4}");
+    t!("\u{2026}", "\u{2026}");
+    t!("\u{2126}", "\u{3a9}");
+    t!("\u{1e0b}\u{323}", "d\u{323}\u{307}");
+    t!("\u{1e0d}\u{307}", "d\u{323}\u{307}");
+    t!("a\u{301}", "a\u{301}");
+    t!("\u{301}a", "\u{301}a");
+    t!("\u{d4db}", "\u{1111}\u{1171}\u{11b6}");
+    t!("\u{ac1c}", "\u{1100}\u{1162}");
+}
+
+#[test]
+fn test_nfkd_chars() {
+    macro_rules! t {
+        ($input: expr, $expected: expr) => {
+            assert_eq!($input.nfkd_chars().collect::<String>(), $expected);
+        }
+    }
+    t!("abc", "abc");
+    t!("\u{1e0b}\u{1c4}", "d\u{307}DZ\u{30c}");
+    t!("\u{2026}", "...");
+    t!("\u{2126}", "\u{3a9}");
+    t!("\u{1e0b}\u{323}", "d\u{323}\u{307}");
+    t!("\u{1e0d}\u{307}", "d\u{323}\u{307}");
+    t!("a\u{301}", "a\u{301}");
+    t!("\u{301}a", "\u{301}a");
+    t!("\u{d4db}", "\u{1111}\u{1171}\u{11b6}");
+    t!("\u{ac1c}", "\u{1100}\u{1162}");
+}
+
+#[test]
+fn test_nfc_chars() {
+    macro_rules! t {
+        ($input: expr, $expected: expr) => {
+            assert_eq!($input.nfc_chars().collect::<String>(), $expected);
+        }
+    }
+    t!("abc", "abc");
+    t!("\u{1e0b}\u{1c4}", "\u{1e0b}\u{1c4}");
+    t!("\u{2026}", "\u{2026}");
+    t!("\u{2126}", "\u{3a9}");
+    t!("\u{1e0b}\u{323}", "\u{1e0d}\u{307}");
+    t!("\u{1e0d}\u{307}", "\u{1e0d}\u{307}");
+    t!("a\u{301}", "\u{e1}");
+    t!("\u{301}a", "\u{301}a");
+    t!("\u{d4db}", "\u{d4db}");
+    t!("\u{ac1c}", "\u{ac1c}");
+    t!("a\u{300}\u{305}\u{315}\u{5ae}b", "\u{e0}\u{5ae}\u{305}\u{315}b");
+}
+
+#[test]
+fn test_nfkc_chars() {
+    macro_rules! t {
+        ($input: expr, $expected: expr) => {
+            assert_eq!($input.nfkc_chars().collect::<String>(), $expected);
+        }
+    }
+    t!("abc", "abc");
+    t!("\u{1e0b}\u{1c4}", "\u{1e0b}D\u{17d}");
+    t!("\u{2026}", "...");
+    t!("\u{2126}", "\u{3a9}");
+    t!("\u{1e0b}\u{323}", "\u{1e0d}\u{307}");
+    t!("\u{1e0d}\u{307}", "\u{1e0d}\u{307}");
+    t!("a\u{301}", "\u{e1}");
+    t!("\u{301}a", "\u{301}a");
+    t!("\u{d4db}", "\u{d4db}");
+    t!("\u{ac1c}", "\u{ac1c}");
+    t!("a\u{300}\u{305}\u{315}\u{5ae}b", "\u{e0}\u{5ae}\u{305}\u{315}b");
+}
+
+#[test]
+fn test_lines() {
+    let data = "\nMäry häd ä little lämb\n\nLittle lämb\n";
+    let lines: Vec<&str> = data.lines().collect();
+    assert_eq!(lines, ["", "Märy häd ä little lämb", "", "Little lämb"]);
+
+    let data = "\nMäry häd ä little lämb\n\nLittle lämb"; // no trailing \n
+    let lines: Vec<&str> = data.lines().collect();
+    assert_eq!(lines, ["", "Märy häd ä little lämb", "", "Little lämb"]);
+}
+
+#[test]
+fn test_graphemes() {
+    use std::iter::order;
+
+    // official Unicode test data
+    // from http://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt
+    let test_same: [(_, &[_]); 325] = [
+        ("\u{20}\u{20}", &["\u{20}", "\u{20}"]),
+        ("\u{20}\u{308}\u{20}", &["\u{20}\u{308}", "\u{20}"]),
+        ("\u{20}\u{D}", &["\u{20}", "\u{D}"]),
+        ("\u{20}\u{308}\u{D}", &["\u{20}\u{308}", "\u{D}"]),
+        ("\u{20}\u{A}", &["\u{20}", "\u{A}"]),
+        ("\u{20}\u{308}\u{A}", &["\u{20}\u{308}", "\u{A}"]),
+        ("\u{20}\u{1}", &["\u{20}", "\u{1}"]),
+        ("\u{20}\u{308}\u{1}", &["\u{20}\u{308}", "\u{1}"]),
+        ("\u{20}\u{300}", &["\u{20}\u{300}"]),
+        ("\u{20}\u{308}\u{300}", &["\u{20}\u{308}\u{300}"]),
+        ("\u{20}\u{1100}", &["\u{20}", "\u{1100}"]),
+        ("\u{20}\u{308}\u{1100}", &["\u{20}\u{308}", "\u{1100}"]),
+        ("\u{20}\u{1160}", &["\u{20}", "\u{1160}"]),
+        ("\u{20}\u{308}\u{1160}", &["\u{20}\u{308}", "\u{1160}"]),
+        ("\u{20}\u{11A8}", &["\u{20}", "\u{11A8}"]),
+        ("\u{20}\u{308}\u{11A8}", &["\u{20}\u{308}", "\u{11A8}"]),
+        ("\u{20}\u{AC00}", &["\u{20}", "\u{AC00}"]),
+        ("\u{20}\u{308}\u{AC00}", &["\u{20}\u{308}", "\u{AC00}"]),
+        ("\u{20}\u{AC01}", &["\u{20}", "\u{AC01}"]),
+        ("\u{20}\u{308}\u{AC01}", &["\u{20}\u{308}", "\u{AC01}"]),
+        ("\u{20}\u{1F1E6}", &["\u{20}", "\u{1F1E6}"]),
+        ("\u{20}\u{308}\u{1F1E6}", &["\u{20}\u{308}", "\u{1F1E6}"]),
+        ("\u{20}\u{378}", &["\u{20}", "\u{378}"]),
+        ("\u{20}\u{308}\u{378}", &["\u{20}\u{308}", "\u{378}"]),
+        ("\u{D}\u{20}", &["\u{D}", "\u{20}"]),
+        ("\u{D}\u{308}\u{20}", &["\u{D}", "\u{308}", "\u{20}"]),
+        ("\u{D}\u{D}", &["\u{D}", "\u{D}"]),
+        ("\u{D}\u{308}\u{D}", &["\u{D}", "\u{308}", "\u{D}"]),
+        ("\u{D}\u{A}", &["\u{D}\u{A}"]),
+        ("\u{D}\u{308}\u{A}", &["\u{D}", "\u{308}", "\u{A}"]),
+        ("\u{D}\u{1}", &["\u{D}", "\u{1}"]),
+        ("\u{D}\u{308}\u{1}", &["\u{D}", "\u{308}", "\u{1}"]),
+        ("\u{D}\u{300}", &["\u{D}", "\u{300}"]),
+        ("\u{D}\u{308}\u{300}", &["\u{D}", "\u{308}\u{300}"]),
+        ("\u{D}\u{903}", &["\u{D}", "\u{903}"]),
+        ("\u{D}\u{1100}", &["\u{D}", "\u{1100}"]),
+        ("\u{D}\u{308}\u{1100}", &["\u{D}", "\u{308}", "\u{1100}"]),
+        ("\u{D}\u{1160}", &["\u{D}", "\u{1160}"]),
+        ("\u{D}\u{308}\u{1160}", &["\u{D}", "\u{308}", "\u{1160}"]),
+        ("\u{D}\u{11A8}", &["\u{D}", "\u{11A8}"]),
+        ("\u{D}\u{308}\u{11A8}", &["\u{D}", "\u{308}", "\u{11A8}"]),
+        ("\u{D}\u{AC00}", &["\u{D}", "\u{AC00}"]),
+        ("\u{D}\u{308}\u{AC00}", &["\u{D}", "\u{308}", "\u{AC00}"]),
+        ("\u{D}\u{AC01}", &["\u{D}", "\u{AC01}"]),
+        ("\u{D}\u{308}\u{AC01}", &["\u{D}", "\u{308}", "\u{AC01}"]),
+        ("\u{D}\u{1F1E6}", &["\u{D}", "\u{1F1E6}"]),
+        ("\u{D}\u{308}\u{1F1E6}", &["\u{D}", "\u{308}", "\u{1F1E6}"]),
+        ("\u{D}\u{378}", &["\u{D}", "\u{378}"]),
+        ("\u{D}\u{308}\u{378}", &["\u{D}", "\u{308}", "\u{378}"]),
+        ("\u{A}\u{20}", &["\u{A}", "\u{20}"]),
+        ("\u{A}\u{308}\u{20}", &["\u{A}", "\u{308}", "\u{20}"]),
+        ("\u{A}\u{D}", &["\u{A}", "\u{D}"]),
+        ("\u{A}\u{308}\u{D}", &["\u{A}", "\u{308}", "\u{D}"]),
+        ("\u{A}\u{A}", &["\u{A}", "\u{A}"]),
+        ("\u{A}\u{308}\u{A}", &["\u{A}", "\u{308}", "\u{A}"]),
+        ("\u{A}\u{1}", &["\u{A}", "\u{1}"]),
+        ("\u{A}\u{308}\u{1}", &["\u{A}", "\u{308}", "\u{1}"]),
+        ("\u{A}\u{300}", &["\u{A}", "\u{300}"]),
+        ("\u{A}\u{308}\u{300}", &["\u{A}", "\u{308}\u{300}"]),
+        ("\u{A}\u{903}", &["\u{A}", "\u{903}"]),
+        ("\u{A}\u{1100}", &["\u{A}", "\u{1100}"]),
+        ("\u{A}\u{308}\u{1100}", &["\u{A}", "\u{308}", "\u{1100}"]),
+        ("\u{A}\u{1160}", &["\u{A}", "\u{1160}"]),
+        ("\u{A}\u{308}\u{1160}", &["\u{A}", "\u{308}", "\u{1160}"]),
+        ("\u{A}\u{11A8}", &["\u{A}", "\u{11A8}"]),
+        ("\u{A}\u{308}\u{11A8}", &["\u{A}", "\u{308}", "\u{11A8}"]),
+        ("\u{A}\u{AC00}", &["\u{A}", "\u{AC00}"]),
+        ("\u{A}\u{308}\u{AC00}", &["\u{A}", "\u{308}", "\u{AC00}"]),
+        ("\u{A}\u{AC01}", &["\u{A}", "\u{AC01}"]),
+        ("\u{A}\u{308}\u{AC01}", &["\u{A}", "\u{308}", "\u{AC01}"]),
+        ("\u{A}\u{1F1E6}", &["\u{A}", "\u{1F1E6}"]),
+        ("\u{A}\u{308}\u{1F1E6}", &["\u{A}", "\u{308}", "\u{1F1E6}"]),
+        ("\u{A}\u{378}", &["\u{A}", "\u{378}"]),
+        ("\u{A}\u{308}\u{378}", &["\u{A}", "\u{308}", "\u{378}"]),
+        ("\u{1}\u{20}", &["\u{1}", "\u{20}"]),
+        ("\u{1}\u{308}\u{20}", &["\u{1}", "\u{308}", "\u{20}"]),
+        ("\u{1}\u{D}", &["\u{1}", "\u{D}"]),
+        ("\u{1}\u{308}\u{D}", &["\u{1}", "\u{308}", "\u{D}"]),
+        ("\u{1}\u{A}", &["\u{1}", "\u{A}"]),
+        ("\u{1}\u{308}\u{A}", &["\u{1}", "\u{308}", "\u{A}"]),
+        ("\u{1}\u{1}", &["\u{1}", "\u{1}"]),
+        ("\u{1}\u{308}\u{1}", &["\u{1}", "\u{308}", "\u{1}"]),
+        ("\u{1}\u{300}", &["\u{1}", "\u{300}"]),
+        ("\u{1}\u{308}\u{300}", &["\u{1}", "\u{308}\u{300}"]),
+        ("\u{1}\u{903}", &["\u{1}", "\u{903}"]),
+        ("\u{1}\u{1100}", &["\u{1}", "\u{1100}"]),
+        ("\u{1}\u{308}\u{1100}", &["\u{1}", "\u{308}", "\u{1100}"]),
+        ("\u{1}\u{1160}", &["\u{1}", "\u{1160}"]),
+        ("\u{1}\u{308}\u{1160}", &["\u{1}", "\u{308}", "\u{1160}"]),
+        ("\u{1}\u{11A8}", &["\u{1}", "\u{11A8}"]),
+        ("\u{1}\u{308}\u{11A8}", &["\u{1}", "\u{308}", "\u{11A8}"]),
+        ("\u{1}\u{AC00}", &["\u{1}", "\u{AC00}"]),
+        ("\u{1}\u{308}\u{AC00}", &["\u{1}", "\u{308}", "\u{AC00}"]),
+        ("\u{1}\u{AC01}", &["\u{1}", "\u{AC01}"]),
+        ("\u{1}\u{308}\u{AC01}", &["\u{1}", "\u{308}", "\u{AC01}"]),
+        ("\u{1}\u{1F1E6}", &["\u{1}", "\u{1F1E6}"]),
+        ("\u{1}\u{308}\u{1F1E6}", &["\u{1}", "\u{308}", "\u{1F1E6}"]),
+        ("\u{1}\u{378}", &["\u{1}", "\u{378}"]),
+        ("\u{1}\u{308}\u{378}", &["\u{1}", "\u{308}", "\u{378}"]),
+        ("\u{300}\u{20}", &["\u{300}", "\u{20}"]),
+        ("\u{300}\u{308}\u{20}", &["\u{300}\u{308}", "\u{20}"]),
+        ("\u{300}\u{D}", &["\u{300}", "\u{D}"]),
+        ("\u{300}\u{308}\u{D}", &["\u{300}\u{308}", "\u{D}"]),
+        ("\u{300}\u{A}", &["\u{300}", "\u{A}"]),
+        ("\u{300}\u{308}\u{A}", &["\u{300}\u{308}", "\u{A}"]),
+        ("\u{300}\u{1}", &["\u{300}", "\u{1}"]),
+        ("\u{300}\u{308}\u{1}", &["\u{300}\u{308}", "\u{1}"]),
+        ("\u{300}\u{300}", &["\u{300}\u{300}"]),
+        ("\u{300}\u{308}\u{300}", &["\u{300}\u{308}\u{300}"]),
+        ("\u{300}\u{1100}", &["\u{300}", "\u{1100}"]),
+        ("\u{300}\u{308}\u{1100}", &["\u{300}\u{308}", "\u{1100}"]),
+        ("\u{300}\u{1160}", &["\u{300}", "\u{1160}"]),
+        ("\u{300}\u{308}\u{1160}", &["\u{300}\u{308}", "\u{1160}"]),
+        ("\u{300}\u{11A8}", &["\u{300}", "\u{11A8}"]),
+        ("\u{300}\u{308}\u{11A8}", &["\u{300}\u{308}", "\u{11A8}"]),
+        ("\u{300}\u{AC00}", &["\u{300}", "\u{AC00}"]),
+        ("\u{300}\u{308}\u{AC00}", &["\u{300}\u{308}", "\u{AC00}"]),
+        ("\u{300}\u{AC01}", &["\u{300}", "\u{AC01}"]),
+        ("\u{300}\u{308}\u{AC01}", &["\u{300}\u{308}", "\u{AC01}"]),
+        ("\u{300}\u{1F1E6}", &["\u{300}", "\u{1F1E6}"]),
+        ("\u{300}\u{308}\u{1F1E6}", &["\u{300}\u{308}", "\u{1F1E6}"]),
+        ("\u{300}\u{378}", &["\u{300}", "\u{378}"]),
+        ("\u{300}\u{308}\u{378}", &["\u{300}\u{308}", "\u{378}"]),
+        ("\u{903}\u{20}", &["\u{903}", "\u{20}"]),
+        ("\u{903}\u{308}\u{20}", &["\u{903}\u{308}", "\u{20}"]),
+        ("\u{903}\u{D}", &["\u{903}", "\u{D}"]),
+        ("\u{903}\u{308}\u{D}", &["\u{903}\u{308}", "\u{D}"]),
+        ("\u{903}\u{A}", &["\u{903}", "\u{A}"]),
+        ("\u{903}\u{308}\u{A}", &["\u{903}\u{308}", "\u{A}"]),
+        ("\u{903}\u{1}", &["\u{903}", "\u{1}"]),
+        ("\u{903}\u{308}\u{1}", &["\u{903}\u{308}", "\u{1}"]),
+        ("\u{903}\u{300}", &["\u{903}\u{300}"]),
+        ("\u{903}\u{308}\u{300}", &["\u{903}\u{308}\u{300}"]),
+        ("\u{903}\u{1100}", &["\u{903}", "\u{1100}"]),
+        ("\u{903}\u{308}\u{1100}", &["\u{903}\u{308}", "\u{1100}"]),
+        ("\u{903}\u{1160}", &["\u{903}", "\u{1160}"]),
+        ("\u{903}\u{308}\u{1160}", &["\u{903}\u{308}", "\u{1160}"]),
+        ("\u{903}\u{11A8}", &["\u{903}", "\u{11A8}"]),
+        ("\u{903}\u{308}\u{11A8}", &["\u{903}\u{308}", "\u{11A8}"]),
+        ("\u{903}\u{AC00}", &["\u{903}", "\u{AC00}"]),
+        ("\u{903}\u{308}\u{AC00}", &["\u{903}\u{308}", "\u{AC00}"]),
+        ("\u{903}\u{AC01}", &["\u{903}", "\u{AC01}"]),
+        ("\u{903}\u{308}\u{AC01}", &["\u{903}\u{308}", "\u{AC01}"]),
+        ("\u{903}\u{1F1E6}", &["\u{903}", "\u{1F1E6}"]),
+        ("\u{903}\u{308}\u{1F1E6}", &["\u{903}\u{308}", "\u{1F1E6}"]),
+        ("\u{903}\u{378}", &["\u{903}", "\u{378}"]),
+        ("\u{903}\u{308}\u{378}", &["\u{903}\u{308}", "\u{378}"]),
+        ("\u{1100}\u{20}", &["\u{1100}", "\u{20}"]),
+        ("\u{1100}\u{308}\u{20}", &["\u{1100}\u{308}", "\u{20}"]),
+        ("\u{1100}\u{D}", &["\u{1100}", "\u{D}"]),
+        ("\u{1100}\u{308}\u{D}", &["\u{1100}\u{308}", "\u{D}"]),
+        ("\u{1100}\u{A}", &["\u{1100}", "\u{A}"]),
+        ("\u{1100}\u{308}\u{A}", &["\u{1100}\u{308}", "\u{A}"]),
+        ("\u{1100}\u{1}", &["\u{1100}", "\u{1}"]),
+        ("\u{1100}\u{308}\u{1}", &["\u{1100}\u{308}", "\u{1}"]),
+        ("\u{1100}\u{300}", &["\u{1100}\u{300}"]),
+        ("\u{1100}\u{308}\u{300}", &["\u{1100}\u{308}\u{300}"]),
+        ("\u{1100}\u{1100}", &["\u{1100}\u{1100}"]),
+        ("\u{1100}\u{308}\u{1100}", &["\u{1100}\u{308}", "\u{1100}"]),
+        ("\u{1100}\u{1160}", &["\u{1100}\u{1160}"]),
+        ("\u{1100}\u{308}\u{1160}", &["\u{1100}\u{308}", "\u{1160}"]),
+        ("\u{1100}\u{11A8}", &["\u{1100}", "\u{11A8}"]),
+        ("\u{1100}\u{308}\u{11A8}", &["\u{1100}\u{308}", "\u{11A8}"]),
+        ("\u{1100}\u{AC00}", &["\u{1100}\u{AC00}"]),
+        ("\u{1100}\u{308}\u{AC00}", &["\u{1100}\u{308}", "\u{AC00}"]),
+        ("\u{1100}\u{AC01}", &["\u{1100}\u{AC01}"]),
+        ("\u{1100}\u{308}\u{AC01}", &["\u{1100}\u{308}", "\u{AC01}"]),
+        ("\u{1100}\u{1F1E6}", &["\u{1100}", "\u{1F1E6}"]),
+        ("\u{1100}\u{308}\u{1F1E6}", &["\u{1100}\u{308}", "\u{1F1E6}"]),
+        ("\u{1100}\u{378}", &["\u{1100}", "\u{378}"]),
+        ("\u{1100}\u{308}\u{378}", &["\u{1100}\u{308}", "\u{378}"]),
+        ("\u{1160}\u{20}", &["\u{1160}", "\u{20}"]),
+        ("\u{1160}\u{308}\u{20}", &["\u{1160}\u{308}", "\u{20}"]),
+        ("\u{1160}\u{D}", &["\u{1160}", "\u{D}"]),
+        ("\u{1160}\u{308}\u{D}", &["\u{1160}\u{308}", "\u{D}"]),
+        ("\u{1160}\u{A}", &["\u{1160}", "\u{A}"]),
+        ("\u{1160}\u{308}\u{A}", &["\u{1160}\u{308}", "\u{A}"]),
+        ("\u{1160}\u{1}", &["\u{1160}", "\u{1}"]),
+        ("\u{1160}\u{308}\u{1}", &["\u{1160}\u{308}", "\u{1}"]),
+        ("\u{1160}\u{300}", &["\u{1160}\u{300}"]),
+        ("\u{1160}\u{308}\u{300}", &["\u{1160}\u{308}\u{300}"]),
+        ("\u{1160}\u{1100}", &["\u{1160}", "\u{1100}"]),
+        ("\u{1160}\u{308}\u{1100}", &["\u{1160}\u{308}", "\u{1100}"]),
+        ("\u{1160}\u{1160}", &["\u{1160}\u{1160}"]),
+        ("\u{1160}\u{308}\u{1160}", &["\u{1160}\u{308}", "\u{1160}"]),
+        ("\u{1160}\u{11A8}", &["\u{1160}\u{11A8}"]),
+        ("\u{1160}\u{308}\u{11A8}", &["\u{1160}\u{308}", "\u{11A8}"]),
+        ("\u{1160}\u{AC00}", &["\u{1160}", "\u{AC00}"]),
+        ("\u{1160}\u{308}\u{AC00}", &["\u{1160}\u{308}", "\u{AC00}"]),
+        ("\u{1160}\u{AC01}", &["\u{1160}", "\u{AC01}"]),
+        ("\u{1160}\u{308}\u{AC01}", &["\u{1160}\u{308}", "\u{AC01}"]),
+        ("\u{1160}\u{1F1E6}", &["\u{1160}", "\u{1F1E6}"]),
+        ("\u{1160}\u{308}\u{1F1E6}", &["\u{1160}\u{308}", "\u{1F1E6}"]),
+        ("\u{1160}\u{378}", &["\u{1160}", "\u{378}"]),
+        ("\u{1160}\u{308}\u{378}", &["\u{1160}\u{308}", "\u{378}"]),
+        ("\u{11A8}\u{20}", &["\u{11A8}", "\u{20}"]),
+        ("\u{11A8}\u{308}\u{20}", &["\u{11A8}\u{308}", "\u{20}"]),
+        ("\u{11A8}\u{D}", &["\u{11A8}", "\u{D}"]),
+        ("\u{11A8}\u{308}\u{D}", &["\u{11A8}\u{308}", "\u{D}"]),
+        ("\u{11A8}\u{A}", &["\u{11A8}", "\u{A}"]),
+        ("\u{11A8}\u{308}\u{A}", &["\u{11A8}\u{308}", "\u{A}"]),
+        ("\u{11A8}\u{1}", &["\u{11A8}", "\u{1}"]),
+        ("\u{11A8}\u{308}\u{1}", &["\u{11A8}\u{308}", "\u{1}"]),
+        ("\u{11A8}\u{300}", &["\u{11A8}\u{300}"]),
+        ("\u{11A8}\u{308}\u{300}", &["\u{11A8}\u{308}\u{300}"]),
+        ("\u{11A8}\u{1100}", &["\u{11A8}", "\u{1100}"]),
+        ("\u{11A8}\u{308}\u{1100}", &["\u{11A8}\u{308}", "\u{1100}"]),
+        ("\u{11A8}\u{1160}", &["\u{11A8}", "\u{1160}"]),
+        ("\u{11A8}\u{308}\u{1160}", &["\u{11A8}\u{308}", "\u{1160}"]),
+        ("\u{11A8}\u{11A8}", &["\u{11A8}\u{11A8}"]),
+        ("\u{11A8}\u{308}\u{11A8}", &["\u{11A8}\u{308}", "\u{11A8}"]),
+        ("\u{11A8}\u{AC00}", &["\u{11A8}", "\u{AC00}"]),
+        ("\u{11A8}\u{308}\u{AC00}", &["\u{11A8}\u{308}", "\u{AC00}"]),
+        ("\u{11A8}\u{AC01}", &["\u{11A8}", "\u{AC01}"]),
+        ("\u{11A8}\u{308}\u{AC01}", &["\u{11A8}\u{308}", "\u{AC01}"]),
+        ("\u{11A8}\u{1F1E6}", &["\u{11A8}", "\u{1F1E6}"]),
+        ("\u{11A8}\u{308}\u{1F1E6}", &["\u{11A8}\u{308}", "\u{1F1E6}"]),
+        ("\u{11A8}\u{378}", &["\u{11A8}", "\u{378}"]),
+        ("\u{11A8}\u{308}\u{378}", &["\u{11A8}\u{308}", "\u{378}"]),
+        ("\u{AC00}\u{20}", &["\u{AC00}", "\u{20}"]),
+        ("\u{AC00}\u{308}\u{20}", &["\u{AC00}\u{308}", "\u{20}"]),
+        ("\u{AC00}\u{D}", &["\u{AC00}", "\u{D}"]),
+        ("\u{AC00}\u{308}\u{D}", &["\u{AC00}\u{308}", "\u{D}"]),
+        ("\u{AC00}\u{A}", &["\u{AC00}", "\u{A}"]),
+        ("\u{AC00}\u{308}\u{A}", &["\u{AC00}\u{308}", "\u{A}"]),
+        ("\u{AC00}\u{1}", &["\u{AC00}", "\u{1}"]),
+        ("\u{AC00}\u{308}\u{1}", &["\u{AC00}\u{308}", "\u{1}"]),
+        ("\u{AC00}\u{300}", &["\u{AC00}\u{300}"]),
+        ("\u{AC00}\u{308}\u{300}", &["\u{AC00}\u{308}\u{300}"]),
+        ("\u{AC00}\u{1100}", &["\u{AC00}", "\u{1100}"]),
+        ("\u{AC00}\u{308}\u{1100}", &["\u{AC00}\u{308}", "\u{1100}"]),
+        ("\u{AC00}\u{1160}", &["\u{AC00}\u{1160}"]),
+        ("\u{AC00}\u{308}\u{1160}", &["\u{AC00}\u{308}", "\u{1160}"]),
+        ("\u{AC00}\u{11A8}", &["\u{AC00}\u{11A8}"]),
+        ("\u{AC00}\u{308}\u{11A8}", &["\u{AC00}\u{308}", "\u{11A8}"]),
+        ("\u{AC00}\u{AC00}", &["\u{AC00}", "\u{AC00}"]),
+        ("\u{AC00}\u{308}\u{AC00}", &["\u{AC00}\u{308}", "\u{AC00}"]),
+        ("\u{AC00}\u{AC01}", &["\u{AC00}", "\u{AC01}"]),
+        ("\u{AC00}\u{308}\u{AC01}", &["\u{AC00}\u{308}", "\u{AC01}"]),
+        ("\u{AC00}\u{1F1E6}", &["\u{AC00}", "\u{1F1E6}"]),
+        ("\u{AC00}\u{308}\u{1F1E6}", &["\u{AC00}\u{308}", "\u{1F1E6}"]),
+        ("\u{AC00}\u{378}", &["\u{AC00}", "\u{378}"]),
+        ("\u{AC00}\u{308}\u{378}", &["\u{AC00}\u{308}", "\u{378}"]),
+        ("\u{AC01}\u{20}", &["\u{AC01}", "\u{20}"]),
+        ("\u{AC01}\u{308}\u{20}", &["\u{AC01}\u{308}", "\u{20}"]),
+        ("\u{AC01}\u{D}", &["\u{AC01}", "\u{D}"]),
+        ("\u{AC01}\u{308}\u{D}", &["\u{AC01}\u{308}", "\u{D}"]),
+        ("\u{AC01}\u{A}", &["\u{AC01}", "\u{A}"]),
+        ("\u{AC01}\u{308}\u{A}", &["\u{AC01}\u{308}", "\u{A}"]),
+        ("\u{AC01}\u{1}", &["\u{AC01}", "\u{1}"]),
+        ("\u{AC01}\u{308}\u{1}", &["\u{AC01}\u{308}", "\u{1}"]),
+        ("\u{AC01}\u{300}", &["\u{AC01}\u{300}"]),
+        ("\u{AC01}\u{308}\u{300}", &["\u{AC01}\u{308}\u{300}"]),
+        ("\u{AC01}\u{1100}", &["\u{AC01}", "\u{1100}"]),
+        ("\u{AC01}\u{308}\u{1100}", &["\u{AC01}\u{308}", "\u{1100}"]),
+        ("\u{AC01}\u{1160}", &["\u{AC01}", "\u{1160}"]),
+        ("\u{AC01}\u{308}\u{1160}", &["\u{AC01}\u{308}", "\u{1160}"]),
+        ("\u{AC01}\u{11A8}", &["\u{AC01}\u{11A8}"]),
+        ("\u{AC01}\u{308}\u{11A8}", &["\u{AC01}\u{308}", "\u{11A8}"]),
+        ("\u{AC01}\u{AC00}", &["\u{AC01}", "\u{AC00}"]),
+        ("\u{AC01}\u{308}\u{AC00}", &["\u{AC01}\u{308}", "\u{AC00}"]),
+        ("\u{AC01}\u{AC01}", &["\u{AC01}", "\u{AC01}"]),
+        ("\u{AC01}\u{308}\u{AC01}", &["\u{AC01}\u{308}", "\u{AC01}"]),
+        ("\u{AC01}\u{1F1E6}", &["\u{AC01}", "\u{1F1E6}"]),
+        ("\u{AC01}\u{308}\u{1F1E6}", &["\u{AC01}\u{308}", "\u{1F1E6}"]),
+        ("\u{AC01}\u{378}", &["\u{AC01}", "\u{378}"]),
+        ("\u{AC01}\u{308}\u{378}", &["\u{AC01}\u{308}", "\u{378}"]),
+        ("\u{1F1E6}\u{20}", &["\u{1F1E6}", "\u{20}"]),
+        ("\u{1F1E6}\u{308}\u{20}", &["\u{1F1E6}\u{308}", "\u{20}"]),
+        ("\u{1F1E6}\u{D}", &["\u{1F1E6}", "\u{D}"]),
+        ("\u{1F1E6}\u{308}\u{D}", &["\u{1F1E6}\u{308}", "\u{D}"]),
+        ("\u{1F1E6}\u{A}", &["\u{1F1E6}", "\u{A}"]),
+        ("\u{1F1E6}\u{308}\u{A}", &["\u{1F1E6}\u{308}", "\u{A}"]),
+        ("\u{1F1E6}\u{1}", &["\u{1F1E6}", "\u{1}"]),
+        ("\u{1F1E6}\u{308}\u{1}", &["\u{1F1E6}\u{308}", "\u{1}"]),
+        ("\u{1F1E6}\u{300}", &["\u{1F1E6}\u{300}"]),
+        ("\u{1F1E6}\u{308}\u{300}", &["\u{1F1E6}\u{308}\u{300}"]),
+        ("\u{1F1E6}\u{1100}", &["\u{1F1E6}", "\u{1100}"]),
+        ("\u{1F1E6}\u{308}\u{1100}", &["\u{1F1E6}\u{308}", "\u{1100}"]),
+        ("\u{1F1E6}\u{1160}", &["\u{1F1E6}", "\u{1160}"]),
+        ("\u{1F1E6}\u{308}\u{1160}", &["\u{1F1E6}\u{308}", "\u{1160}"]),
+        ("\u{1F1E6}\u{11A8}", &["\u{1F1E6}", "\u{11A8}"]),
+        ("\u{1F1E6}\u{308}\u{11A8}", &["\u{1F1E6}\u{308}", "\u{11A8}"]),
+        ("\u{1F1E6}\u{AC00}", &["\u{1F1E6}", "\u{AC00}"]),
+        ("\u{1F1E6}\u{308}\u{AC00}", &["\u{1F1E6}\u{308}", "\u{AC00}"]),
+        ("\u{1F1E6}\u{AC01}", &["\u{1F1E6}", "\u{AC01}"]),
+        ("\u{1F1E6}\u{308}\u{AC01}", &["\u{1F1E6}\u{308}", "\u{AC01}"]),
+        ("\u{1F1E6}\u{1F1E6}", &["\u{1F1E6}\u{1F1E6}"]),
+        ("\u{1F1E6}\u{308}\u{1F1E6}", &["\u{1F1E6}\u{308}", "\u{1F1E6}"]),
+        ("\u{1F1E6}\u{378}", &["\u{1F1E6}", "\u{378}"]),
+        ("\u{1F1E6}\u{308}\u{378}", &["\u{1F1E6}\u{308}", "\u{378}"]),
+        ("\u{378}\u{20}", &["\u{378}", "\u{20}"]),
+        ("\u{378}\u{308}\u{20}", &["\u{378}\u{308}", "\u{20}"]),
+        ("\u{378}\u{D}", &["\u{378}", "\u{D}"]),
+        ("\u{378}\u{308}\u{D}", &["\u{378}\u{308}", "\u{D}"]),
+        ("\u{378}\u{A}", &["\u{378}", "\u{A}"]),
+        ("\u{378}\u{308}\u{A}", &["\u{378}\u{308}", "\u{A}"]),
+        ("\u{378}\u{1}", &["\u{378}", "\u{1}"]),
+        ("\u{378}\u{308}\u{1}", &["\u{378}\u{308}", "\u{1}"]),
+        ("\u{378}\u{300}", &["\u{378}\u{300}"]),
+        ("\u{378}\u{308}\u{300}", &["\u{378}\u{308}\u{300}"]),
+        ("\u{378}\u{1100}", &["\u{378}", "\u{1100}"]),
+        ("\u{378}\u{308}\u{1100}", &["\u{378}\u{308}", "\u{1100}"]),
+        ("\u{378}\u{1160}", &["\u{378}", "\u{1160}"]),
+        ("\u{378}\u{308}\u{1160}", &["\u{378}\u{308}", "\u{1160}"]),
+        ("\u{378}\u{11A8}", &["\u{378}", "\u{11A8}"]),
+        ("\u{378}\u{308}\u{11A8}", &["\u{378}\u{308}", "\u{11A8}"]),
+        ("\u{378}\u{AC00}", &["\u{378}", "\u{AC00}"]),
+        ("\u{378}\u{308}\u{AC00}", &["\u{378}\u{308}", "\u{AC00}"]),
+        ("\u{378}\u{AC01}", &["\u{378}", "\u{AC01}"]),
+        ("\u{378}\u{308}\u{AC01}", &["\u{378}\u{308}", "\u{AC01}"]),
+        ("\u{378}\u{1F1E6}", &["\u{378}", "\u{1F1E6}"]),
+        ("\u{378}\u{308}\u{1F1E6}", &["\u{378}\u{308}", "\u{1F1E6}"]),
+        ("\u{378}\u{378}", &["\u{378}", "\u{378}"]),
+        ("\u{378}\u{308}\u{378}", &["\u{378}\u{308}", "\u{378}"]),
+        ("\u{61}\u{1F1E6}\u{62}", &["\u{61}", "\u{1F1E6}", "\u{62}"]),
+        ("\u{1F1F7}\u{1F1FA}", &["\u{1F1F7}\u{1F1FA}"]),
+        ("\u{1F1F7}\u{1F1FA}\u{1F1F8}", &["\u{1F1F7}\u{1F1FA}\u{1F1F8}"]),
+        ("\u{1F1F7}\u{1F1FA}\u{1F1F8}\u{1F1EA}",
+        &["\u{1F1F7}\u{1F1FA}\u{1F1F8}\u{1F1EA}"]),
+        ("\u{1F1F7}\u{1F1FA}\u{200B}\u{1F1F8}\u{1F1EA}",
+         &["\u{1F1F7}\u{1F1FA}", "\u{200B}", "\u{1F1F8}\u{1F1EA}"]),
+        ("\u{1F1E6}\u{1F1E7}\u{1F1E8}", &["\u{1F1E6}\u{1F1E7}\u{1F1E8}"]),
+        ("\u{1F1E6}\u{200D}\u{1F1E7}\u{1F1E8}", &["\u{1F1E6}\u{200D}",
+         "\u{1F1E7}\u{1F1E8}"]),
+        ("\u{1F1E6}\u{1F1E7}\u{200D}\u{1F1E8}",
+         &["\u{1F1E6}\u{1F1E7}\u{200D}", "\u{1F1E8}"]),
+        ("\u{20}\u{200D}\u{646}", &["\u{20}\u{200D}", "\u{646}"]),
+        ("\u{646}\u{200D}\u{20}", &["\u{646}\u{200D}", "\u{20}"]),
+    ];
+
+    let test_diff: [(_, &[_], &[_]); 23] = [
+        ("\u{20}\u{903}", &["\u{20}\u{903}"], &["\u{20}", "\u{903}"]), ("\u{20}\u{308}\u{903}",
+        &["\u{20}\u{308}\u{903}"], &["\u{20}\u{308}", "\u{903}"]), ("\u{D}\u{308}\u{903}",
+        &["\u{D}", "\u{308}\u{903}"], &["\u{D}", "\u{308}", "\u{903}"]), ("\u{A}\u{308}\u{903}",
+        &["\u{A}", "\u{308}\u{903}"], &["\u{A}", "\u{308}", "\u{903}"]), ("\u{1}\u{308}\u{903}",
+        &["\u{1}", "\u{308}\u{903}"], &["\u{1}", "\u{308}", "\u{903}"]), ("\u{300}\u{903}",
+        &["\u{300}\u{903}"], &["\u{300}", "\u{903}"]), ("\u{300}\u{308}\u{903}",
+        &["\u{300}\u{308}\u{903}"], &["\u{300}\u{308}", "\u{903}"]), ("\u{903}\u{903}",
+        &["\u{903}\u{903}"], &["\u{903}", "\u{903}"]), ("\u{903}\u{308}\u{903}",
+        &["\u{903}\u{308}\u{903}"], &["\u{903}\u{308}", "\u{903}"]), ("\u{1100}\u{903}",
+        &["\u{1100}\u{903}"], &["\u{1100}", "\u{903}"]), ("\u{1100}\u{308}\u{903}",
+        &["\u{1100}\u{308}\u{903}"], &["\u{1100}\u{308}", "\u{903}"]), ("\u{1160}\u{903}",
+        &["\u{1160}\u{903}"], &["\u{1160}", "\u{903}"]), ("\u{1160}\u{308}\u{903}",
+        &["\u{1160}\u{308}\u{903}"], &["\u{1160}\u{308}", "\u{903}"]), ("\u{11A8}\u{903}",
+        &["\u{11A8}\u{903}"], &["\u{11A8}", "\u{903}"]), ("\u{11A8}\u{308}\u{903}",
+        &["\u{11A8}\u{308}\u{903}"], &["\u{11A8}\u{308}", "\u{903}"]), ("\u{AC00}\u{903}",
+        &["\u{AC00}\u{903}"], &["\u{AC00}", "\u{903}"]), ("\u{AC00}\u{308}\u{903}",
+        &["\u{AC00}\u{308}\u{903}"], &["\u{AC00}\u{308}", "\u{903}"]), ("\u{AC01}\u{903}",
+        &["\u{AC01}\u{903}"], &["\u{AC01}", "\u{903}"]), ("\u{AC01}\u{308}\u{903}",
+        &["\u{AC01}\u{308}\u{903}"], &["\u{AC01}\u{308}", "\u{903}"]), ("\u{1F1E6}\u{903}",
+        &["\u{1F1E6}\u{903}"], &["\u{1F1E6}", "\u{903}"]), ("\u{1F1E6}\u{308}\u{903}",
+        &["\u{1F1E6}\u{308}\u{903}"], &["\u{1F1E6}\u{308}", "\u{903}"]), ("\u{378}\u{903}",
+        &["\u{378}\u{903}"], &["\u{378}", "\u{903}"]), ("\u{378}\u{308}\u{903}",
+        &["\u{378}\u{308}\u{903}"], &["\u{378}\u{308}", "\u{903}"]),
+    ];
+
+    for &(s, g) in &test_same[..] {
+        // test forward iterator
+        assert!(order::equals(s.graphemes(true), g.iter().cloned()));
+        assert!(order::equals(s.graphemes(false), g.iter().cloned()));
+
+        // test reverse iterator
+        assert!(order::equals(s.graphemes(true).rev(), g.iter().rev().cloned()));
+        assert!(order::equals(s.graphemes(false).rev(), g.iter().rev().cloned()));
+    }
+
+    for &(s, gt, gf) in &test_diff {
+        // test forward iterator
+        assert!(order::equals(s.graphemes(true), gt.iter().cloned()));
+        assert!(order::equals(s.graphemes(false), gf.iter().cloned()));
+
+        // test reverse iterator
+        assert!(order::equals(s.graphemes(true).rev(), gt.iter().rev().cloned()));
+        assert!(order::equals(s.graphemes(false).rev(), gf.iter().rev().cloned()));
+    }
+
+    // test the indices iterators
+    let s = "a̐éö̲\r\n";
+    let gr_inds = s.grapheme_indices(true).collect::<Vec<(usize, &str)>>();
+    let b: &[_] = &[(0, "a̐"), (3, "é"), (6, "ö̲"), (11, "\r\n")];
+    assert_eq!(gr_inds, b);
+    let gr_inds = s.grapheme_indices(true).rev().collect::<Vec<(usize, &str)>>();
+    let b: &[_] = &[(11, "\r\n"), (6, "ö̲"), (3, "é"), (0, "a̐")];
+    assert_eq!(gr_inds, b);
+    let mut gr_inds_iter = s.grapheme_indices(true);
+    {
+        let gr_inds = gr_inds_iter.by_ref();
+        let e1 = gr_inds.size_hint();
+        assert_eq!(e1, (1, Some(13)));
+        let c = gr_inds.count();
+        assert_eq!(c, 4);
+    }
+    let e2 = gr_inds_iter.size_hint();
+    assert_eq!(e2, (0, Some(0)));
+
+    // make sure the reverse iterator does the right thing with "\n" at beginning of string
+    let s = "\n\r\n\r";
+    let gr = s.graphemes(true).rev().collect::<Vec<&str>>();
+    let b: &[_] = &["\r", "\r\n", "\n"];
+    assert_eq!(gr, b);
+}
+
+#[test]
+fn test_split_strator() {
+    fn t(s: &str, sep: &str, u: &[&str]) {
+        let v: Vec<&str> = s.split_str(sep).collect();
+        assert_eq!(v, u);
+    }
+    t("--1233345--", "12345", &["--1233345--"]);
+    t("abc::hello::there", "::", &["abc", "hello", "there"]);
+    t("::hello::there", "::", &["", "hello", "there"]);
+    t("hello::there::", "::", &["hello", "there", ""]);
+    t("::hello::there::", "::", &["", "hello", "there", ""]);
+    t("ประเทศไทย中华Việt Nam", "中华", &["ประเทศไทย", "Việt Nam"]);
+    t("zzXXXzzYYYzz", "zz", &["", "XXX", "YYY", ""]);
+    t("zzXXXzYYYz", "XXX", &["zz", "zYYYz"]);
+    t(".XXX.YYY.", ".", &["", "XXX", "YYY", ""]);
+    t("", ".", &[""]);
+    t("zz", "zz", &["",""]);
+    t("ok", "z", &["ok"]);
+    t("zzz", "zz", &["","z"]);
+    t("zzzzz", "zz", &["","","z"]);
+}
+
+#[test]
+fn test_str_default() {
+    use std::default::Default;
+
+    fn t<S: Default + Str>() {
+        let s: S = Default::default();
+        assert_eq!(s.as_slice(), "");
+    }
+
+    t::<&str>();
+    t::<String>();
+}
+
+#[test]
+fn test_str_container() {
+    fn sum_len(v: &[&str]) -> usize {
+        v.iter().map(|x| x.len()).sum()
+    }
+
+    let s = String::from_str("01234");
+    assert_eq!(5, sum_len(&["012", "", "34"]));
+    assert_eq!(5, sum_len(&[&String::from_str("01"),
+                            &String::from_str("2"),
+                            &String::from_str("34"),
+                            &String::from_str("")]));
+    assert_eq!(5, sum_len(&[&s]));
+}
+
+#[test]
+fn test_str_from_utf8() {
+    let xs = b"hello";
+    assert_eq!(from_utf8(xs), Ok("hello"));
+
+    let xs = "ศไทย中华Việt Nam".as_bytes();
+    assert_eq!(from_utf8(xs), Ok("ศไทย中华Việt Nam"));
+
+    let xs = b"hello\xFF";
+    assert_eq!(from_utf8(xs), Err(Utf8Error::TooShort));
+}
+
+mod bench {
+    use test::{Bencher, black_box};
+
+    #[bench]
+    fn char_iterator(b: &mut Bencher) {
+        let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
+
+        b.iter(|| s.chars().count());
+    }
+
+    #[bench]
+    fn char_iterator_for(b: &mut Bencher) {
+        let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
+
+        b.iter(|| {
+            for ch in s.chars() { black_box(ch); }
+        });
+    }
+
+    #[bench]
+    fn char_iterator_ascii(b: &mut Bencher) {
+        let s = "Mary had a little lamb, Little lamb
+        Mary had a little lamb, Little lamb
+        Mary had a little lamb, Little lamb
+        Mary had a little lamb, Little lamb
+        Mary had a little lamb, Little lamb
+        Mary had a little lamb, Little lamb";
+
+        b.iter(|| s.chars().count());
+    }
+
+    #[bench]
+    fn char_iterator_rev(b: &mut Bencher) {
+        let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
+
+        b.iter(|| s.chars().rev().count());
+    }
+
+    #[bench]
+    fn char_iterator_rev_for(b: &mut Bencher) {
+        let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
+
+        b.iter(|| {
+            for ch in s.chars().rev() { black_box(ch); }
+        });
+    }
+
+    #[bench]
+    fn char_indicesator(b: &mut Bencher) {
+        let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
+        let len = s.chars().count();
+
+        b.iter(|| assert_eq!(s.char_indices().count(), len));
+    }
+
+    #[bench]
+    fn char_indicesator_rev(b: &mut Bencher) {
+        let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
+        let len = s.chars().count();
+
+        b.iter(|| assert_eq!(s.char_indices().rev().count(), len));
+    }
+
+    #[bench]
+    fn split_unicode_ascii(b: &mut Bencher) {
+        let s = "ประเทศไทย中华Việt Namประเทศไทย中华Việt Nam";
+
+        b.iter(|| assert_eq!(s.split('V').count(), 3));
+    }
+
+    #[bench]
+    fn split_ascii(b: &mut Bencher) {
+        let s = "Mary had a little lamb, Little lamb, little-lamb.";
+        let len = s.split(' ').count();
+
+        b.iter(|| assert_eq!(s.split(' ').count(), len));
+    }
+
+    #[bench]
+    fn split_extern_fn(b: &mut Bencher) {
+        let s = "Mary had a little lamb, Little lamb, little-lamb.";
+        let len = s.split(' ').count();
+        fn pred(c: char) -> bool { c == ' ' }
+
+        b.iter(|| assert_eq!(s.split(pred).count(), len));
+    }
+
+    #[bench]
+    fn split_closure(b: &mut Bencher) {
+        let s = "Mary had a little lamb, Little lamb, little-lamb.";
+        let len = s.split(' ').count();
+
+        b.iter(|| assert_eq!(s.split(|c: char| c == ' ').count(), len));
+    }
+
+    #[bench]
+    fn split_slice(b: &mut Bencher) {
+        let s = "Mary had a little lamb, Little lamb, little-lamb.";
+        let len = s.split(' ').count();
+
+        let c: &[char] = &[' '];
+        b.iter(|| assert_eq!(s.split(c).count(), len));
+    }
+
+    #[bench]
+    fn bench_connect(b: &mut Bencher) {
+        let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
+        let sep = "→";
+        let v = vec![s, s, s, s, s, s, s, s, s, s];
+        b.iter(|| {
+            assert_eq!(v.connect(sep).len(), s.len() * 10 + sep.len() * 9);
+        })
+    }
+
+    #[bench]
+    fn bench_contains_short_short(b: &mut Bencher) {
+        let haystack = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
+        let needle = "sit";
+
+        b.iter(|| {
+            assert!(haystack.contains(needle));
+        })
+    }
+
+    #[bench]
+    fn bench_contains_short_long(b: &mut Bencher) {
+        let haystack = "\
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse quis lorem sit amet dolor \
+ultricies condimentum. Praesent iaculis purus elit, ac malesuada quam malesuada in. Duis sed orci \
+eros. Suspendisse sit amet magna mollis, mollis nunc luctus, imperdiet mi. Integer fringilla non \
+sem ut lacinia. Fusce varius tortor a risus porttitor hendrerit. Morbi mauris dui, ultricies nec \
+tempus vel, gravida nec quam.
+
+In est dui, tincidunt sed tempus interdum, adipiscing laoreet ante. Etiam tempor, tellus quis \
+sagittis interdum, nulla purus mattis sem, quis auctor erat odio ac tellus. In nec nunc sit amet \
+diam volutpat molestie at sed ipsum. Vestibulum laoreet consequat vulputate. Integer accumsan \
+lorem ac dignissim placerat. Suspendisse convallis faucibus lorem. Aliquam erat volutpat. In vel \
+eleifend felis. Sed suscipit nulla lorem, sed mollis est sollicitudin et. Nam fermentum egestas \
+interdum. Curabitur ut nisi justo.
+
+Sed sollicitudin ipsum tellus, ut condimentum leo eleifend nec. Cras ut velit ante. Phasellus nec \
+mollis odio. Mauris molestie erat in arcu mattis, at aliquet dolor vehicula. Quisque malesuada \
+lectus sit amet nisi pretium, a condimentum ipsum porta. Morbi at dapibus diam. Praesent egestas \
+est sed risus elementum, eu rutrum metus ultrices. Etiam fermentum consectetur magna, id rutrum \
+felis accumsan a. Aliquam ut pellentesque libero. Sed mi nulla, lobortis eu tortor id, suscipit \
+ultricies neque. Morbi iaculis sit amet risus at iaculis. Praesent eget ligula quis turpis \
+feugiat suscipit vel non arcu. Interdum et malesuada fames ac ante ipsum primis in faucibus. \
+Aliquam sit amet placerat lorem.
+
+Cras a lacus vel ante posuere elementum. Nunc est leo, bibendum ut facilisis vel, bibendum at \
+mauris. Nullam adipiscing diam vel odio ornare, luctus adipiscing mi luctus. Nulla facilisi. \
+Mauris adipiscing bibendum neque, quis adipiscing lectus tempus et. Sed feugiat erat et nisl \
+lobortis pharetra. Donec vitae erat enim. Nullam sit amet felis et quam lacinia tincidunt. Aliquam \
+suscipit dapibus urna. Sed volutpat urna in magna pulvinar volutpat. Phasellus nec tellus ac diam \
+cursus accumsan.
+
+Nam lectus enim, dapibus non nisi tempor, consectetur convallis massa. Maecenas eleifend dictum \
+feugiat. Etiam quis mauris vel risus luctus mattis a a nunc. Nullam orci quam, imperdiet id \
+vehicula in, porttitor ut nibh. Duis sagittis adipiscing nisl vitae congue. Donec mollis risus eu \
+leo suscipit, varius porttitor nulla porta. Pellentesque ut sem nec nisi euismod vehicula. Nulla \
+malesuada sollicitudin quam eu fermentum.";
+        let needle = "english";
+
+        b.iter(|| {
+            assert!(!haystack.contains(needle));
+        })
+    }
+
+    #[bench]
+    fn bench_contains_bad_naive(b: &mut Bencher) {
+        let haystack = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
+        let needle = "aaaaaaaab";
+
+        b.iter(|| {
+            assert!(!haystack.contains(needle));
+        })
+    }
+
+    #[bench]
+    fn bench_contains_equal(b: &mut Bencher) {
+        let haystack = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
+        let needle = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
+
+        b.iter(|| {
+            assert!(haystack.contains(needle));
+        })
+    }
+}
diff --git a/src/libcollectionstest/string.rs b/src/libcollectionstest/string.rs
new file mode 100644
index 00000000000..4768d5e92ac
--- /dev/null
+++ b/src/libcollectionstest/string.rs
@@ -0,0 +1,453 @@
+// 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::borrow::IntoCow;
+use std::iter::repeat;
+use std::str::Utf8Error;
+use std::string::{CowString, as_string};
+
+use test::Bencher;
+
+#[test]
+fn test_as_string() {
+    let x = "foo";
+    assert_eq!(x, &**as_string(x));
+}
+
+#[test]
+fn test_from_str() {
+  let owned: Option<::std::string::String> = "string".parse().ok();
+  assert_eq!(owned.as_ref().map(|s| &**s), Some("string"));
+}
+
+#[test]
+fn test_unsized_to_string() {
+    let s: &str = "abc";
+    let _: String = (*s).to_string();
+}
+
+#[test]
+fn test_from_utf8() {
+    let xs = b"hello".to_vec();
+    assert_eq!(String::from_utf8(xs).unwrap(),
+               String::from_str("hello"));
+
+    let xs = "ศไทย中华Việt Nam".as_bytes().to_vec();
+    assert_eq!(String::from_utf8(xs).unwrap(),
+               String::from_str("ศไทย中华Việt Nam"));
+
+    let xs = b"hello\xFF".to_vec();
+    let err = String::from_utf8(xs).err().unwrap();
+    assert_eq!(err.utf8_error(), Utf8Error::TooShort);
+    assert_eq!(err.into_bytes(), b"hello\xff".to_vec());
+}
+
+#[test]
+fn test_from_utf8_lossy() {
+    let xs = b"hello";
+    let ys: CowString = "hello".into_cow();
+    assert_eq!(String::from_utf8_lossy(xs), ys);
+
+    let xs = "ศไทย中华Việt Nam".as_bytes();
+    let ys: CowString = "ศไทย中华Việt Nam".into_cow();
+    assert_eq!(String::from_utf8_lossy(xs), ys);
+
+    let xs = b"Hello\xC2 There\xFF Goodbye";
+    assert_eq!(String::from_utf8_lossy(xs),
+               String::from_str("Hello\u{FFFD} There\u{FFFD} Goodbye").into_cow());
+
+    let xs = b"Hello\xC0\x80 There\xE6\x83 Goodbye";
+    assert_eq!(String::from_utf8_lossy(xs),
+               String::from_str("Hello\u{FFFD}\u{FFFD} There\u{FFFD} Goodbye").into_cow());
+
+    let xs = b"\xF5foo\xF5\x80bar";
+    assert_eq!(String::from_utf8_lossy(xs),
+               String::from_str("\u{FFFD}foo\u{FFFD}\u{FFFD}bar").into_cow());
+
+    let xs = b"\xF1foo\xF1\x80bar\xF1\x80\x80baz";
+    assert_eq!(String::from_utf8_lossy(xs),
+               String::from_str("\u{FFFD}foo\u{FFFD}bar\u{FFFD}baz").into_cow());
+
+    let xs = b"\xF4foo\xF4\x80bar\xF4\xBFbaz";
+    assert_eq!(String::from_utf8_lossy(xs),
+               String::from_str("\u{FFFD}foo\u{FFFD}bar\u{FFFD}\u{FFFD}baz").into_cow());
+
+    let xs = b"\xF0\x80\x80\x80foo\xF0\x90\x80\x80bar";
+    assert_eq!(String::from_utf8_lossy(xs), String::from_str("\u{FFFD}\u{FFFD}\u{FFFD}\u{FFFD}\
+                                           foo\u{10000}bar").into_cow());
+
+    // surrogates
+    let xs = b"\xED\xA0\x80foo\xED\xBF\xBFbar";
+    assert_eq!(String::from_utf8_lossy(xs), String::from_str("\u{FFFD}\u{FFFD}\u{FFFD}foo\
+                                           \u{FFFD}\u{FFFD}\u{FFFD}bar").into_cow());
+}
+
+#[test]
+fn test_from_utf16() {
+    let pairs =
+        [(String::from_str("𐍅𐌿𐌻𐍆𐌹𐌻𐌰\n"),
+          vec![0xd800, 0xdf45, 0xd800, 0xdf3f,
+            0xd800, 0xdf3b, 0xd800, 0xdf46,
+            0xd800, 0xdf39, 0xd800, 0xdf3b,
+            0xd800, 0xdf30, 0x000a]),
+
+         (String::from_str("𐐒𐑉𐐮𐑀𐐲𐑋 𐐏𐐲𐑍\n"),
+          vec![0xd801, 0xdc12, 0xd801,
+            0xdc49, 0xd801, 0xdc2e, 0xd801,
+            0xdc40, 0xd801, 0xdc32, 0xd801,
+            0xdc4b, 0x0020, 0xd801, 0xdc0f,
+            0xd801, 0xdc32, 0xd801, 0xdc4d,
+            0x000a]),
+
+         (String::from_str("𐌀𐌖𐌋𐌄𐌑𐌉·𐌌𐌄𐌕𐌄𐌋𐌉𐌑\n"),
+          vec![0xd800, 0xdf00, 0xd800, 0xdf16,
+            0xd800, 0xdf0b, 0xd800, 0xdf04,
+            0xd800, 0xdf11, 0xd800, 0xdf09,
+            0x00b7, 0xd800, 0xdf0c, 0xd800,
+            0xdf04, 0xd800, 0xdf15, 0xd800,
+            0xdf04, 0xd800, 0xdf0b, 0xd800,
+            0xdf09, 0xd800, 0xdf11, 0x000a ]),
+
+         (String::from_str("𐒋𐒘𐒈𐒑𐒛𐒒 𐒕𐒓 𐒈𐒚𐒍 𐒏𐒜𐒒𐒖𐒆 𐒕𐒆\n"),
+          vec![0xd801, 0xdc8b, 0xd801, 0xdc98,
+            0xd801, 0xdc88, 0xd801, 0xdc91,
+            0xd801, 0xdc9b, 0xd801, 0xdc92,
+            0x0020, 0xd801, 0xdc95, 0xd801,
+            0xdc93, 0x0020, 0xd801, 0xdc88,
+            0xd801, 0xdc9a, 0xd801, 0xdc8d,
+            0x0020, 0xd801, 0xdc8f, 0xd801,
+            0xdc9c, 0xd801, 0xdc92, 0xd801,
+            0xdc96, 0xd801, 0xdc86, 0x0020,
+            0xd801, 0xdc95, 0xd801, 0xdc86,
+            0x000a ]),
+         // Issue #12318, even-numbered non-BMP planes
+         (String::from_str("\u{20000}"),
+          vec![0xD840, 0xDC00])];
+
+    for p in &pairs {
+        let (s, u) = (*p).clone();
+        let s_as_utf16 = s.utf16_units().collect::<Vec<u16>>();
+        let u_as_string = String::from_utf16(&u).unwrap();
+
+        assert!(::unicode::str::is_utf16(&u));
+        assert_eq!(s_as_utf16, u);
+
+        assert_eq!(u_as_string, s);
+        assert_eq!(String::from_utf16_lossy(&u), s);
+
+        assert_eq!(String::from_utf16(&s_as_utf16).unwrap(), s);
+        assert_eq!(u_as_string.utf16_units().collect::<Vec<u16>>(), u);
+    }
+}
+
+#[test]
+fn test_utf16_invalid() {
+    // completely positive cases tested above.
+    // lead + eof
+    assert!(String::from_utf16(&[0xD800]).is_err());
+    // lead + lead
+    assert!(String::from_utf16(&[0xD800, 0xD800]).is_err());
+
+    // isolated trail
+    assert!(String::from_utf16(&[0x0061, 0xDC00]).is_err());
+
+    // general
+    assert!(String::from_utf16(&[0xD800, 0xd801, 0xdc8b, 0xD800]).is_err());
+}
+
+#[test]
+fn test_from_utf16_lossy() {
+    // completely positive cases tested above.
+    // lead + eof
+    assert_eq!(String::from_utf16_lossy(&[0xD800]), String::from_str("\u{FFFD}"));
+    // lead + lead
+    assert_eq!(String::from_utf16_lossy(&[0xD800, 0xD800]),
+               String::from_str("\u{FFFD}\u{FFFD}"));
+
+    // isolated trail
+    assert_eq!(String::from_utf16_lossy(&[0x0061, 0xDC00]), String::from_str("a\u{FFFD}"));
+
+    // general
+    assert_eq!(String::from_utf16_lossy(&[0xD800, 0xd801, 0xdc8b, 0xD800]),
+               String::from_str("\u{FFFD}𐒋\u{FFFD}"));
+}
+
+#[test]
+fn test_push_bytes() {
+    let mut s = String::from_str("ABC");
+    unsafe {
+        let mv = s.as_mut_vec();
+        mv.push_all(&[b'D']);
+    }
+    assert_eq!(s, "ABCD");
+}
+
+#[test]
+fn test_push_str() {
+    let mut s = String::new();
+    s.push_str("");
+    assert_eq!(&s[0..], "");
+    s.push_str("abc");
+    assert_eq!(&s[0..], "abc");
+    s.push_str("ประเทศไทย中华Việt Nam");
+    assert_eq!(&s[0..], "abcประเทศไทย中华Việt Nam");
+}
+
+#[test]
+fn test_push() {
+    let mut data = String::from_str("ประเทศไทย中");
+    data.push('华');
+    data.push('b'); // 1 byte
+    data.push('¢'); // 2 byte
+    data.push('€'); // 3 byte
+    data.push('𤭢'); // 4 byte
+    assert_eq!(data, "ประเทศไทย中华b¢€𤭢");
+}
+
+#[test]
+fn test_pop() {
+    let mut data = String::from_str("ประเทศไทย中华b¢€𤭢");
+    assert_eq!(data.pop().unwrap(), '𤭢'); // 4 bytes
+    assert_eq!(data.pop().unwrap(), '€'); // 3 bytes
+    assert_eq!(data.pop().unwrap(), '¢'); // 2 bytes
+    assert_eq!(data.pop().unwrap(), 'b'); // 1 bytes
+    assert_eq!(data.pop().unwrap(), '华');
+    assert_eq!(data, "ประเทศไทย中");
+}
+
+#[test]
+fn test_str_truncate() {
+    let mut s = String::from_str("12345");
+    s.truncate(5);
+    assert_eq!(s, "12345");
+    s.truncate(3);
+    assert_eq!(s, "123");
+    s.truncate(0);
+    assert_eq!(s, "");
+
+    let mut s = String::from_str("12345");
+    let p = s.as_ptr();
+    s.truncate(3);
+    s.push_str("6");
+    let p_ = s.as_ptr();
+    assert_eq!(p_, p);
+}
+
+#[test]
+#[should_panic]
+fn test_str_truncate_invalid_len() {
+    let mut s = String::from_str("12345");
+    s.truncate(6);
+}
+
+#[test]
+#[should_panic]
+fn test_str_truncate_split_codepoint() {
+    let mut s = String::from_str("\u{FC}"); // ü
+    s.truncate(1);
+}
+
+#[test]
+fn test_str_clear() {
+    let mut s = String::from_str("12345");
+    s.clear();
+    assert_eq!(s.len(), 0);
+    assert_eq!(s, "");
+}
+
+#[test]
+fn test_str_add() {
+    let a = String::from_str("12345");
+    let b = a + "2";
+    let b = b + "2";
+    assert_eq!(b.len(), 7);
+    assert_eq!(b, "1234522");
+}
+
+#[test]
+fn remove() {
+    let mut s = "ศไทย中华Việt Nam; foobar".to_string();;
+    assert_eq!(s.remove(0), 'ศ');
+    assert_eq!(s.len(), 33);
+    assert_eq!(s, "ไทย中华Việt Nam; foobar");
+    assert_eq!(s.remove(17), 'ệ');
+    assert_eq!(s, "ไทย中华Vit Nam; foobar");
+}
+
+#[test] #[should_panic]
+fn remove_bad() {
+    "ศ".to_string().remove(1);
+}
+
+#[test]
+fn insert() {
+    let mut s = "foobar".to_string();
+    s.insert(0, 'ệ');
+    assert_eq!(s, "ệfoobar");
+    s.insert(6, 'ย');
+    assert_eq!(s, "ệfooยbar");
+}
+
+#[test] #[should_panic] fn insert_bad1() { "".to_string().insert(1, 't'); }
+#[test] #[should_panic] fn insert_bad2() { "ệ".to_string().insert(1, 't'); }
+
+#[test]
+fn test_slicing() {
+    let s = "foobar".to_string();
+    assert_eq!("foobar", &s[..]);
+    assert_eq!("foo", &s[..3]);
+    assert_eq!("bar", &s[3..]);
+    assert_eq!("oob", &s[1..4]);
+}
+
+#[test]
+fn test_simple_types() {
+    assert_eq!(1.to_string(), "1");
+    assert_eq!((-1).to_string(), "-1");
+    assert_eq!(200.to_string(), "200");
+    assert_eq!(2.to_string(), "2");
+    assert_eq!(true.to_string(), "true");
+    assert_eq!(false.to_string(), "false");
+    assert_eq!(("hi".to_string()).to_string(), "hi");
+}
+
+#[test]
+fn test_vectors() {
+    let x: Vec<i32> = vec![];
+    assert_eq!(format!("{:?}", x), "[]");
+    assert_eq!(format!("{:?}", vec![1]), "[1]");
+    assert_eq!(format!("{:?}", vec![1, 2, 3]), "[1, 2, 3]");
+    assert!(format!("{:?}", vec![vec![], vec![1], vec![1, 1]]) ==
+           "[[], [1], [1, 1]]");
+}
+
+#[test]
+fn test_from_iterator() {
+    let s = "ศไทย中华Việt Nam".to_string();
+    let t = "ศไทย中华";
+    let u = "Việt Nam";
+
+    let a: String = s.chars().collect();
+    assert_eq!(s, a);
+
+    let mut b = t.to_string();
+    b.extend(u.chars());
+    assert_eq!(s, b);
+
+    let c: String = vec![t, u].into_iter().collect();
+    assert_eq!(s, c);
+
+    let mut d = t.to_string();
+    d.extend(vec![u].into_iter());
+    assert_eq!(s, d);
+}
+
+#[bench]
+fn bench_with_capacity(b: &mut Bencher) {
+    b.iter(|| {
+        String::with_capacity(100)
+    });
+}
+
+#[bench]
+fn bench_push_str(b: &mut Bencher) {
+    let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
+    b.iter(|| {
+        let mut r = String::new();
+        r.push_str(s);
+    });
+}
+
+const REPETITIONS: u64 = 10_000;
+
+#[bench]
+fn bench_push_str_one_byte(b: &mut Bencher) {
+    b.bytes = REPETITIONS;
+    b.iter(|| {
+        let mut r = String::new();
+        for _ in 0..REPETITIONS {
+            r.push_str("a")
+        }
+    });
+}
+
+#[bench]
+fn bench_push_char_one_byte(b: &mut Bencher) {
+    b.bytes = REPETITIONS;
+    b.iter(|| {
+        let mut r = String::new();
+        for _ in 0..REPETITIONS {
+            r.push('a')
+        }
+    });
+}
+
+#[bench]
+fn bench_push_char_two_bytes(b: &mut Bencher) {
+    b.bytes = REPETITIONS * 2;
+    b.iter(|| {
+        let mut r = String::new();
+        for _ in 0..REPETITIONS {
+            r.push('â')
+        }
+    });
+}
+
+#[bench]
+fn from_utf8_lossy_100_ascii(b: &mut Bencher) {
+    let s = b"Hello there, the quick brown fox jumped over the lazy dog! \
+              Lorem ipsum dolor sit amet, consectetur. ";
+
+    assert_eq!(100, s.len());
+    b.iter(|| {
+        let _ = String::from_utf8_lossy(s);
+    });
+}
+
+#[bench]
+fn from_utf8_lossy_100_multibyte(b: &mut Bencher) {
+    let s = "𐌀𐌖𐌋𐌄𐌑𐌉ปรدولة الكويتทศไทย中华𐍅𐌿𐌻𐍆𐌹𐌻𐌰".as_bytes();
+    assert_eq!(100, s.len());
+    b.iter(|| {
+        let _ = String::from_utf8_lossy(s);
+    });
+}
+
+#[bench]
+fn from_utf8_lossy_invalid(b: &mut Bencher) {
+    let s = b"Hello\xC0\x80 There\xE6\x83 Goodbye";
+    b.iter(|| {
+        let _ = String::from_utf8_lossy(s);
+    });
+}
+
+#[bench]
+fn from_utf8_lossy_100_invalid(b: &mut Bencher) {
+    let s = repeat(0xf5).take(100).collect::<Vec<_>>();
+    b.iter(|| {
+        let _ = String::from_utf8_lossy(&s);
+    });
+}
+
+#[bench]
+fn bench_exact_size_shrink_to_fit(b: &mut Bencher) {
+    let s = "Hello there, the quick brown fox jumped over the lazy dog! \
+             Lorem ipsum dolor sit amet, consectetur. ";
+    // ensure our operation produces an exact-size string before we benchmark it
+    let mut r = String::with_capacity(s.len());
+    r.push_str(s);
+    assert_eq!(r.len(), r.capacity());
+    b.iter(|| {
+        let mut r = String::with_capacity(s.len());
+        r.push_str(s);
+        r.shrink_to_fit();
+        r
+    });
+}
diff --git a/src/libcollectionstest/vec.rs b/src/libcollectionstest/vec.rs
new file mode 100644
index 00000000000..2923bea9828
--- /dev/null
+++ b/src/libcollectionstest/vec.rs
@@ -0,0 +1,994 @@
+// 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::iter::{FromIterator, repeat};
+use std::mem::size_of;
+use std::vec::as_vec;
+
+use test::Bencher;
+
+struct DropCounter<'a> {
+    count: &'a mut u32
+}
+
+#[unsafe_destructor]
+impl<'a> Drop for DropCounter<'a> {
+    fn drop(&mut self) {
+        *self.count += 1;
+    }
+}
+
+#[test]
+fn test_as_vec() {
+    let xs = [1u8, 2u8, 3u8];
+    assert_eq!(&**as_vec(&xs), xs);
+}
+
+#[test]
+fn test_as_vec_dtor() {
+    let (mut count_x, mut count_y) = (0, 0);
+    {
+        let xs = &[DropCounter { count: &mut count_x }, DropCounter { count: &mut count_y }];
+        assert_eq!(as_vec(xs).len(), 2);
+    }
+    assert_eq!(count_x, 1);
+    assert_eq!(count_y, 1);
+}
+
+#[test]
+fn test_small_vec_struct() {
+    assert!(size_of::<Vec<u8>>() == size_of::<usize>() * 3);
+}
+
+#[test]
+fn test_double_drop() {
+    struct TwoVec<T> {
+        x: Vec<T>,
+        y: Vec<T>
+    }
+
+    let (mut count_x, mut count_y) = (0, 0);
+    {
+        let mut tv = TwoVec {
+            x: Vec::new(),
+            y: Vec::new()
+        };
+        tv.x.push(DropCounter {count: &mut count_x});
+        tv.y.push(DropCounter {count: &mut count_y});
+
+        // If Vec had a drop flag, here is where it would be zeroed.
+        // Instead, it should rely on its internal state to prevent
+        // doing anything significant when dropped multiple times.
+        drop(tv.x);
+
+        // Here tv goes out of scope, tv.y should be dropped, but not tv.x.
+    }
+
+    assert_eq!(count_x, 1);
+    assert_eq!(count_y, 1);
+}
+
+#[test]
+fn test_reserve() {
+    let mut v = Vec::new();
+    assert_eq!(v.capacity(), 0);
+
+    v.reserve(2);
+    assert!(v.capacity() >= 2);
+
+    for i in 0..16 {
+        v.push(i);
+    }
+
+    assert!(v.capacity() >= 16);
+    v.reserve(16);
+    assert!(v.capacity() >= 32);
+
+    v.push(16);
+
+    v.reserve(16);
+    assert!(v.capacity() >= 33)
+}
+
+#[test]
+fn test_extend() {
+    let mut v = Vec::new();
+    let mut w = Vec::new();
+
+    v.extend(0..3);
+    for i in 0..3 { w.push(i) }
+
+    assert_eq!(v, w);
+
+    v.extend(3..10);
+    for i in 3..10 { w.push(i) }
+
+    assert_eq!(v, w);
+}
+
+#[test]
+fn test_slice_from_mut() {
+    let mut values = vec![1, 2, 3, 4, 5];
+    {
+        let slice = &mut values[2 ..];
+        assert!(slice == [3, 4, 5]);
+        for p in slice {
+            *p += 2;
+        }
+    }
+
+    assert!(values == [1, 2, 5, 6, 7]);
+}
+
+#[test]
+fn test_slice_to_mut() {
+    let mut values = vec![1, 2, 3, 4, 5];
+    {
+        let slice = &mut values[.. 2];
+        assert!(slice == [1, 2]);
+        for p in slice {
+            *p += 1;
+        }
+    }
+
+    assert!(values == [2, 3, 3, 4, 5]);
+}
+
+#[test]
+fn test_split_at_mut() {
+    let mut values = vec![1, 2, 3, 4, 5];
+    {
+        let (left, right) = values.split_at_mut(2);
+        {
+            let left: &[_] = left;
+            assert!(&left[..left.len()] == &[1, 2]);
+        }
+        for p in left {
+            *p += 1;
+        }
+
+        {
+            let right: &[_] = right;
+            assert!(&right[..right.len()] == &[3, 4, 5]);
+        }
+        for p in right {
+            *p += 2;
+        }
+    }
+
+    assert_eq!(values, [2, 3, 5, 6, 7]);
+}
+
+#[test]
+fn test_clone() {
+    let v: Vec<i32> = vec![];
+    let w = vec!(1, 2, 3);
+
+    assert_eq!(v, v.clone());
+
+    let z = w.clone();
+    assert_eq!(w, z);
+    // they should be disjoint in memory.
+    assert!(w.as_ptr() != z.as_ptr())
+}
+
+#[test]
+fn test_clone_from() {
+    let mut v = vec!();
+    let three: Vec<Box<_>> = vec!(box 1, box 2, box 3);
+    let two: Vec<Box<_>> = vec!(box 4, box 5);
+    // zero, long
+    v.clone_from(&three);
+    assert_eq!(v, three);
+
+    // equal
+    v.clone_from(&three);
+    assert_eq!(v, three);
+
+    // long, short
+    v.clone_from(&two);
+    assert_eq!(v, two);
+
+    // short, long
+    v.clone_from(&three);
+    assert_eq!(v, three)
+}
+
+#[test]
+fn test_retain() {
+    let mut vec = vec![1, 2, 3, 4];
+    vec.retain(|&x| x % 2 == 0);
+    assert_eq!(vec, [2, 4]);
+}
+
+#[test]
+fn zero_sized_values() {
+    let mut v = Vec::new();
+    assert_eq!(v.len(), 0);
+    v.push(());
+    assert_eq!(v.len(), 1);
+    v.push(());
+    assert_eq!(v.len(), 2);
+    assert_eq!(v.pop(), Some(()));
+    assert_eq!(v.pop(), Some(()));
+    assert_eq!(v.pop(), None);
+
+    assert_eq!(v.iter().count(), 0);
+    v.push(());
+    assert_eq!(v.iter().count(), 1);
+    v.push(());
+    assert_eq!(v.iter().count(), 2);
+
+    for &() in &v {}
+
+    assert_eq!(v.iter_mut().count(), 2);
+    v.push(());
+    assert_eq!(v.iter_mut().count(), 3);
+    v.push(());
+    assert_eq!(v.iter_mut().count(), 4);
+
+    for &mut () in &mut v {}
+    unsafe { v.set_len(0); }
+    assert_eq!(v.iter_mut().count(), 0);
+}
+
+#[test]
+fn test_partition() {
+    assert_eq!(vec![].into_iter().partition(|x: &i32| *x < 3), (vec![], vec![]));
+    assert_eq!(vec![1, 2, 3].into_iter().partition(|x| *x < 4), (vec![1, 2, 3], vec![]));
+    assert_eq!(vec![1, 2, 3].into_iter().partition(|x| *x < 2), (vec![1], vec![2, 3]));
+    assert_eq!(vec![1, 2, 3].into_iter().partition(|x| *x < 0), (vec![], vec![1, 2, 3]));
+}
+
+#[test]
+fn test_zip_unzip() {
+    let z1 = vec![(1, 4), (2, 5), (3, 6)];
+
+    let (left, right): (Vec<_>, Vec<_>) = z1.iter().cloned().unzip();
+
+    assert_eq!((1, 4), (left[0], right[0]));
+    assert_eq!((2, 5), (left[1], right[1]));
+    assert_eq!((3, 6), (left[2], right[2]));
+}
+
+#[test]
+fn test_unsafe_ptrs() {
+    unsafe {
+        // Test on-stack copy-from-buf.
+        let a = [1, 2, 3];
+        let ptr = a.as_ptr();
+        let b = Vec::from_raw_buf(ptr, 3);
+        assert_eq!(b, [1, 2, 3]);
+
+        // Test on-heap copy-from-buf.
+        let c = vec![1, 2, 3, 4, 5];
+        let ptr = c.as_ptr();
+        let d = Vec::from_raw_buf(ptr, 5);
+        assert_eq!(d, [1, 2, 3, 4, 5]);
+    }
+}
+
+#[test]
+fn test_vec_truncate_drop() {
+    static mut drops: u32 = 0;
+    struct Elem(i32);
+    impl Drop for Elem {
+        fn drop(&mut self) {
+            unsafe { drops += 1; }
+        }
+    }
+
+    let mut v = vec![Elem(1), Elem(2), Elem(3), Elem(4), Elem(5)];
+    assert_eq!(unsafe { drops }, 0);
+    v.truncate(3);
+    assert_eq!(unsafe { drops }, 2);
+    v.truncate(0);
+    assert_eq!(unsafe { drops }, 5);
+}
+
+#[test]
+#[should_panic]
+fn test_vec_truncate_fail() {
+    struct BadElem(i32);
+    impl Drop for BadElem {
+        fn drop(&mut self) {
+            let BadElem(ref mut x) = *self;
+            if *x == 0xbadbeef {
+                panic!("BadElem panic: 0xbadbeef")
+            }
+        }
+    }
+
+    let mut v = vec![BadElem(1), BadElem(2), BadElem(0xbadbeef), BadElem(4)];
+    v.truncate(0);
+}
+
+#[test]
+fn test_index() {
+    let vec = vec![1, 2, 3];
+    assert!(vec[1] == 2);
+}
+
+#[test]
+#[should_panic]
+fn test_index_out_of_bounds() {
+    let vec = vec![1, 2, 3];
+    let _ = vec[3];
+}
+
+#[test]
+#[should_panic]
+fn test_slice_out_of_bounds_1() {
+    let x = vec![1, 2, 3, 4, 5];
+    &x[-1..];
+}
+
+#[test]
+#[should_panic]
+fn test_slice_out_of_bounds_2() {
+    let x = vec![1, 2, 3, 4, 5];
+    &x[..6];
+}
+
+#[test]
+#[should_panic]
+fn test_slice_out_of_bounds_3() {
+    let x = vec![1, 2, 3, 4, 5];
+    &x[-1..4];
+}
+
+#[test]
+#[should_panic]
+fn test_slice_out_of_bounds_4() {
+    let x = vec![1, 2, 3, 4, 5];
+    &x[1..6];
+}
+
+#[test]
+#[should_panic]
+fn test_slice_out_of_bounds_5() {
+    let x = vec![1, 2, 3, 4, 5];
+    &x[3..2];
+}
+
+#[test]
+#[should_panic]
+fn test_swap_remove_empty() {
+    let mut vec= Vec::<i32>::new();
+    vec.swap_remove(0);
+}
+
+#[test]
+fn test_move_iter_unwrap() {
+    let mut vec = Vec::with_capacity(7);
+    vec.push(1);
+    vec.push(2);
+    let ptr = vec.as_ptr();
+    vec = vec.into_iter().into_inner();
+    assert_eq!(vec.as_ptr(), ptr);
+    assert_eq!(vec.capacity(), 7);
+    assert_eq!(vec.len(), 0);
+}
+
+#[test]
+#[should_panic]
+fn test_map_in_place_incompatible_types_fail() {
+    let v = vec![0, 1, 2];
+    v.map_in_place(|_| ());
+}
+
+#[test]
+fn test_map_in_place() {
+    let v = vec![0, 1, 2];
+    assert_eq!(v.map_in_place(|i: u32| i as i32 - 1), [-1, 0, 1]);
+}
+
+#[test]
+fn test_map_in_place_zero_sized() {
+    let v = vec![(), ()];
+    #[derive(PartialEq, Debug)]
+    struct ZeroSized;
+    assert_eq!(v.map_in_place(|_| ZeroSized), [ZeroSized, ZeroSized]);
+}
+
+#[test]
+fn test_map_in_place_zero_drop_count() {
+    use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
+
+    #[derive(Clone, PartialEq, Debug)]
+    struct Nothing;
+    impl Drop for Nothing { fn drop(&mut self) { } }
+
+    #[derive(Clone, PartialEq, Debug)]
+    struct ZeroSized;
+    impl Drop for ZeroSized {
+        fn drop(&mut self) {
+            DROP_COUNTER.fetch_add(1, Ordering::Relaxed);
+        }
+    }
+    const NUM_ELEMENTS: usize = 2;
+    static DROP_COUNTER: AtomicUsize = ATOMIC_USIZE_INIT;
+
+    let v = repeat(Nothing).take(NUM_ELEMENTS).collect::<Vec<_>>();
+
+    DROP_COUNTER.store(0, Ordering::Relaxed);
+
+    let v = v.map_in_place(|_| ZeroSized);
+    assert_eq!(DROP_COUNTER.load(Ordering::Relaxed), 0);
+    drop(v);
+    assert_eq!(DROP_COUNTER.load(Ordering::Relaxed), NUM_ELEMENTS);
+}
+
+#[test]
+fn test_move_items() {
+    let vec = vec![1, 2, 3];
+    let mut vec2 = vec![];
+    for i in vec {
+        vec2.push(i);
+    }
+    assert_eq!(vec2, [1, 2, 3]);
+}
+
+#[test]
+fn test_move_items_reverse() {
+    let vec = vec![1, 2, 3];
+    let mut vec2 = vec![];
+    for i in vec.into_iter().rev() {
+        vec2.push(i);
+    }
+    assert_eq!(vec2, [3, 2, 1]);
+}
+
+#[test]
+fn test_move_items_zero_sized() {
+    let vec = vec![(), (), ()];
+    let mut vec2 = vec![];
+    for i in vec {
+        vec2.push(i);
+    }
+    assert_eq!(vec2, [(), (), ()]);
+}
+
+#[test]
+fn test_drain_items() {
+    let mut vec = vec![1, 2, 3];
+    let mut vec2 = vec![];
+    for i in vec.drain() {
+        vec2.push(i);
+    }
+    assert_eq!(vec, []);
+    assert_eq!(vec2, [ 1, 2, 3 ]);
+}
+
+#[test]
+fn test_drain_items_reverse() {
+    let mut vec = vec![1, 2, 3];
+    let mut vec2 = vec![];
+    for i in vec.drain().rev() {
+        vec2.push(i);
+    }
+    assert_eq!(vec, []);
+    assert_eq!(vec2, [3, 2, 1]);
+}
+
+#[test]
+fn test_drain_items_zero_sized() {
+    let mut vec = vec![(), (), ()];
+    let mut vec2 = vec![];
+    for i in vec.drain() {
+        vec2.push(i);
+    }
+    assert_eq!(vec, []);
+    assert_eq!(vec2, [(), (), ()]);
+}
+
+#[test]
+fn test_into_boxed_slice() {
+    let xs = vec![1, 2, 3];
+    let ys = xs.into_boxed_slice();
+    assert_eq!(&*ys, [1, 2, 3]);
+}
+
+#[test]
+fn test_append() {
+    let mut vec = vec![1, 2, 3];
+    let mut vec2 = vec![4, 5, 6];
+    vec.append(&mut vec2);
+    assert_eq!(vec, [1, 2, 3, 4, 5, 6]);
+    assert_eq!(vec2, []);
+}
+
+#[test]
+fn test_split_off() {
+    let mut vec = vec![1, 2, 3, 4, 5, 6];
+    let vec2 = vec.split_off(4);
+    assert_eq!(vec, [1, 2, 3, 4]);
+    assert_eq!(vec2, [5, 6]);
+}
+
+#[bench]
+fn bench_new(b: &mut Bencher) {
+    b.iter(|| {
+        let v: Vec<u32> = Vec::new();
+        assert_eq!(v.len(), 0);
+        assert_eq!(v.capacity(), 0);
+    })
+}
+
+fn do_bench_with_capacity(b: &mut Bencher, src_len: usize) {
+    b.bytes = src_len as u64;
+
+    b.iter(|| {
+        let v: Vec<u32> = Vec::with_capacity(src_len);
+        assert_eq!(v.len(), 0);
+        assert_eq!(v.capacity(), src_len);
+    })
+}
+
+#[bench]
+fn bench_with_capacity_0000(b: &mut Bencher) {
+    do_bench_with_capacity(b, 0)
+}
+
+#[bench]
+fn bench_with_capacity_0010(b: &mut Bencher) {
+    do_bench_with_capacity(b, 10)
+}
+
+#[bench]
+fn bench_with_capacity_0100(b: &mut Bencher) {
+    do_bench_with_capacity(b, 100)
+}
+
+#[bench]
+fn bench_with_capacity_1000(b: &mut Bencher) {
+    do_bench_with_capacity(b, 1000)
+}
+
+fn do_bench_from_fn(b: &mut Bencher, src_len: usize) {
+    b.bytes = src_len as u64;
+
+    b.iter(|| {
+        let dst = (0..src_len).collect::<Vec<_>>();
+        assert_eq!(dst.len(), src_len);
+        assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
+    })
+}
+
+#[bench]
+fn bench_from_fn_0000(b: &mut Bencher) {
+    do_bench_from_fn(b, 0)
+}
+
+#[bench]
+fn bench_from_fn_0010(b: &mut Bencher) {
+    do_bench_from_fn(b, 10)
+}
+
+#[bench]
+fn bench_from_fn_0100(b: &mut Bencher) {
+    do_bench_from_fn(b, 100)
+}
+
+#[bench]
+fn bench_from_fn_1000(b: &mut Bencher) {
+    do_bench_from_fn(b, 1000)
+}
+
+fn do_bench_from_elem(b: &mut Bencher, src_len: usize) {
+    b.bytes = src_len as u64;
+
+    b.iter(|| {
+        let dst: Vec<usize> = repeat(5).take(src_len).collect();
+        assert_eq!(dst.len(), src_len);
+        assert!(dst.iter().all(|x| *x == 5));
+    })
+}
+
+#[bench]
+fn bench_from_elem_0000(b: &mut Bencher) {
+    do_bench_from_elem(b, 0)
+}
+
+#[bench]
+fn bench_from_elem_0010(b: &mut Bencher) {
+    do_bench_from_elem(b, 10)
+}
+
+#[bench]
+fn bench_from_elem_0100(b: &mut Bencher) {
+    do_bench_from_elem(b, 100)
+}
+
+#[bench]
+fn bench_from_elem_1000(b: &mut Bencher) {
+    do_bench_from_elem(b, 1000)
+}
+
+fn do_bench_from_slice(b: &mut Bencher, src_len: usize) {
+    let src: Vec<_> = FromIterator::from_iter(0..src_len);
+
+    b.bytes = src_len as u64;
+
+    b.iter(|| {
+        let dst = src.clone()[..].to_vec();
+        assert_eq!(dst.len(), src_len);
+        assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
+    });
+}
+
+#[bench]
+fn bench_from_slice_0000(b: &mut Bencher) {
+    do_bench_from_slice(b, 0)
+}
+
+#[bench]
+fn bench_from_slice_0010(b: &mut Bencher) {
+    do_bench_from_slice(b, 10)
+}
+
+#[bench]
+fn bench_from_slice_0100(b: &mut Bencher) {
+    do_bench_from_slice(b, 100)
+}
+
+#[bench]
+fn bench_from_slice_1000(b: &mut Bencher) {
+    do_bench_from_slice(b, 1000)
+}
+
+fn do_bench_from_iter(b: &mut Bencher, src_len: usize) {
+    let src: Vec<_> = FromIterator::from_iter(0..src_len);
+
+    b.bytes = src_len as u64;
+
+    b.iter(|| {
+        let dst: Vec<_> = FromIterator::from_iter(src.clone().into_iter());
+        assert_eq!(dst.len(), src_len);
+        assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
+    });
+}
+
+#[bench]
+fn bench_from_iter_0000(b: &mut Bencher) {
+    do_bench_from_iter(b, 0)
+}
+
+#[bench]
+fn bench_from_iter_0010(b: &mut Bencher) {
+    do_bench_from_iter(b, 10)
+}
+
+#[bench]
+fn bench_from_iter_0100(b: &mut Bencher) {
+    do_bench_from_iter(b, 100)
+}
+
+#[bench]
+fn bench_from_iter_1000(b: &mut Bencher) {
+    do_bench_from_iter(b, 1000)
+}
+
+fn do_bench_extend(b: &mut Bencher, dst_len: usize, src_len: usize) {
+    let dst: Vec<_> = FromIterator::from_iter(0..dst_len);
+    let src: Vec<_> = FromIterator::from_iter(dst_len..dst_len + src_len);
+
+    b.bytes = src_len as u64;
+
+    b.iter(|| {
+        let mut dst = dst.clone();
+        dst.extend(src.clone().into_iter());
+        assert_eq!(dst.len(), dst_len + src_len);
+        assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
+    });
+}
+
+#[bench]
+fn bench_extend_0000_0000(b: &mut Bencher) {
+    do_bench_extend(b, 0, 0)
+}
+
+#[bench]
+fn bench_extend_0000_0010(b: &mut Bencher) {
+    do_bench_extend(b, 0, 10)
+}
+
+#[bench]
+fn bench_extend_0000_0100(b: &mut Bencher) {
+    do_bench_extend(b, 0, 100)
+}
+
+#[bench]
+fn bench_extend_0000_1000(b: &mut Bencher) {
+    do_bench_extend(b, 0, 1000)
+}
+
+#[bench]
+fn bench_extend_0010_0010(b: &mut Bencher) {
+    do_bench_extend(b, 10, 10)
+}
+
+#[bench]
+fn bench_extend_0100_0100(b: &mut Bencher) {
+    do_bench_extend(b, 100, 100)
+}
+
+#[bench]
+fn bench_extend_1000_1000(b: &mut Bencher) {
+    do_bench_extend(b, 1000, 1000)
+}
+
+fn do_bench_push_all(b: &mut Bencher, dst_len: usize, src_len: usize) {
+    let dst: Vec<_> = FromIterator::from_iter(0..dst_len);
+    let src: Vec<_> = FromIterator::from_iter(dst_len..dst_len + src_len);
+
+    b.bytes = src_len as u64;
+
+    b.iter(|| {
+        let mut dst = dst.clone();
+        dst.push_all(&src);
+        assert_eq!(dst.len(), dst_len + src_len);
+        assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
+    });
+}
+
+#[bench]
+fn bench_push_all_0000_0000(b: &mut Bencher) {
+    do_bench_push_all(b, 0, 0)
+}
+
+#[bench]
+fn bench_push_all_0000_0010(b: &mut Bencher) {
+    do_bench_push_all(b, 0, 10)
+}
+
+#[bench]
+fn bench_push_all_0000_0100(b: &mut Bencher) {
+    do_bench_push_all(b, 0, 100)
+}
+
+#[bench]
+fn bench_push_all_0000_1000(b: &mut Bencher) {
+    do_bench_push_all(b, 0, 1000)
+}
+
+#[bench]
+fn bench_push_all_0010_0010(b: &mut Bencher) {
+    do_bench_push_all(b, 10, 10)
+}
+
+#[bench]
+fn bench_push_all_0100_0100(b: &mut Bencher) {
+    do_bench_push_all(b, 100, 100)
+}
+
+#[bench]
+fn bench_push_all_1000_1000(b: &mut Bencher) {
+    do_bench_push_all(b, 1000, 1000)
+}
+
+fn do_bench_push_all_move(b: &mut Bencher, dst_len: usize, src_len: usize) {
+    let dst: Vec<_> = FromIterator::from_iter(0..dst_len);
+    let src: Vec<_> = FromIterator::from_iter(dst_len..dst_len + src_len);
+
+    b.bytes = src_len as u64;
+
+    b.iter(|| {
+        let mut dst = dst.clone();
+        dst.extend(src.clone().into_iter());
+        assert_eq!(dst.len(), dst_len + src_len);
+        assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
+    });
+}
+
+#[bench]
+fn bench_push_all_move_0000_0000(b: &mut Bencher) {
+    do_bench_push_all_move(b, 0, 0)
+}
+
+#[bench]
+fn bench_push_all_move_0000_0010(b: &mut Bencher) {
+    do_bench_push_all_move(b, 0, 10)
+}
+
+#[bench]
+fn bench_push_all_move_0000_0100(b: &mut Bencher) {
+    do_bench_push_all_move(b, 0, 100)
+}
+
+#[bench]
+fn bench_push_all_move_0000_1000(b: &mut Bencher) {
+    do_bench_push_all_move(b, 0, 1000)
+}
+
+#[bench]
+fn bench_push_all_move_0010_0010(b: &mut Bencher) {
+    do_bench_push_all_move(b, 10, 10)
+}
+
+#[bench]
+fn bench_push_all_move_0100_0100(b: &mut Bencher) {
+    do_bench_push_all_move(b, 100, 100)
+}
+
+#[bench]
+fn bench_push_all_move_1000_1000(b: &mut Bencher) {
+    do_bench_push_all_move(b, 1000, 1000)
+}
+
+fn do_bench_clone(b: &mut Bencher, src_len: usize) {
+    let src: Vec<usize> = FromIterator::from_iter(0..src_len);
+
+    b.bytes = src_len as u64;
+
+    b.iter(|| {
+        let dst = src.clone();
+        assert_eq!(dst.len(), src_len);
+        assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
+    });
+}
+
+#[bench]
+fn bench_clone_0000(b: &mut Bencher) {
+    do_bench_clone(b, 0)
+}
+
+#[bench]
+fn bench_clone_0010(b: &mut Bencher) {
+    do_bench_clone(b, 10)
+}
+
+#[bench]
+fn bench_clone_0100(b: &mut Bencher) {
+    do_bench_clone(b, 100)
+}
+
+#[bench]
+fn bench_clone_1000(b: &mut Bencher) {
+    do_bench_clone(b, 1000)
+}
+
+fn do_bench_clone_from(b: &mut Bencher, times: usize, dst_len: usize, src_len: usize) {
+    let dst: Vec<_> = FromIterator::from_iter(0..src_len);
+    let src: Vec<_> = FromIterator::from_iter(dst_len..dst_len + src_len);
+
+    b.bytes = (times * src_len) as u64;
+
+    b.iter(|| {
+        let mut dst = dst.clone();
+
+        for _ in 0..times {
+            dst.clone_from(&src);
+
+            assert_eq!(dst.len(), src_len);
+            assert!(dst.iter().enumerate().all(|(i, x)| dst_len + i == *x));
+        }
+    });
+}
+
+#[bench]
+fn bench_clone_from_01_0000_0000(b: &mut Bencher) {
+    do_bench_clone_from(b, 1, 0, 0)
+}
+
+#[bench]
+fn bench_clone_from_01_0000_0010(b: &mut Bencher) {
+    do_bench_clone_from(b, 1, 0, 10)
+}
+
+#[bench]
+fn bench_clone_from_01_0000_0100(b: &mut Bencher) {
+    do_bench_clone_from(b, 1, 0, 100)
+}
+
+#[bench]
+fn bench_clone_from_01_0000_1000(b: &mut Bencher) {
+    do_bench_clone_from(b, 1, 0, 1000)
+}
+
+#[bench]
+fn bench_clone_from_01_0010_0010(b: &mut Bencher) {
+    do_bench_clone_from(b, 1, 10, 10)
+}
+
+#[bench]
+fn bench_clone_from_01_0100_0100(b: &mut Bencher) {
+    do_bench_clone_from(b, 1, 100, 100)
+}
+
+#[bench]
+fn bench_clone_from_01_1000_1000(b: &mut Bencher) {
+    do_bench_clone_from(b, 1, 1000, 1000)
+}
+
+#[bench]
+fn bench_clone_from_01_0010_0100(b: &mut Bencher) {
+    do_bench_clone_from(b, 1, 10, 100)
+}
+
+#[bench]
+fn bench_clone_from_01_0100_1000(b: &mut Bencher) {
+    do_bench_clone_from(b, 1, 100, 1000)
+}
+
+#[bench]
+fn bench_clone_from_01_0010_0000(b: &mut Bencher) {
+    do_bench_clone_from(b, 1, 10, 0)
+}
+
+#[bench]
+fn bench_clone_from_01_0100_0010(b: &mut Bencher) {
+    do_bench_clone_from(b, 1, 100, 10)
+}
+
+#[bench]
+fn bench_clone_from_01_1000_0100(b: &mut Bencher) {
+    do_bench_clone_from(b, 1, 1000, 100)
+}
+
+#[bench]
+fn bench_clone_from_10_0000_0000(b: &mut Bencher) {
+    do_bench_clone_from(b, 10, 0, 0)
+}
+
+#[bench]
+fn bench_clone_from_10_0000_0010(b: &mut Bencher) {
+    do_bench_clone_from(b, 10, 0, 10)
+}
+
+#[bench]
+fn bench_clone_from_10_0000_0100(b: &mut Bencher) {
+    do_bench_clone_from(b, 10, 0, 100)
+}
+
+#[bench]
+fn bench_clone_from_10_0000_1000(b: &mut Bencher) {
+    do_bench_clone_from(b, 10, 0, 1000)
+}
+
+#[bench]
+fn bench_clone_from_10_0010_0010(b: &mut Bencher) {
+    do_bench_clone_from(b, 10, 10, 10)
+}
+
+#[bench]
+fn bench_clone_from_10_0100_0100(b: &mut Bencher) {
+    do_bench_clone_from(b, 10, 100, 100)
+}
+
+#[bench]
+fn bench_clone_from_10_1000_1000(b: &mut Bencher) {
+    do_bench_clone_from(b, 10, 1000, 1000)
+}
+
+#[bench]
+fn bench_clone_from_10_0010_0100(b: &mut Bencher) {
+    do_bench_clone_from(b, 10, 10, 100)
+}
+
+#[bench]
+fn bench_clone_from_10_0100_1000(b: &mut Bencher) {
+    do_bench_clone_from(b, 10, 100, 1000)
+}
+
+#[bench]
+fn bench_clone_from_10_0010_0000(b: &mut Bencher) {
+    do_bench_clone_from(b, 10, 10, 0)
+}
+
+#[bench]
+fn bench_clone_from_10_0100_0010(b: &mut Bencher) {
+    do_bench_clone_from(b, 10, 100, 10)
+}
+
+#[bench]
+fn bench_clone_from_10_1000_0100(b: &mut Bencher) {
+    do_bench_clone_from(b, 10, 1000, 100)
+}
diff --git a/src/libcollectionstest/vec_deque.rs b/src/libcollectionstest/vec_deque.rs
new file mode 100644
index 00000000000..38f358c1505
--- /dev/null
+++ b/src/libcollectionstest/vec_deque.rs
@@ -0,0 +1,888 @@
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::collections::VecDeque;
+use std::fmt::Debug;
+use std::hash::{SipHasher, self};
+
+use test;
+
+use self::Taggy::*;
+use self::Taggypar::*;
+
+#[test]
+#[allow(deprecated)]
+fn test_simple() {
+    let mut d = VecDeque::new();
+    assert_eq!(d.len(), 0);
+    d.push_front(17);
+    d.push_front(42);
+    d.push_back(137);
+    assert_eq!(d.len(), 3);
+    d.push_back(137);
+    assert_eq!(d.len(), 4);
+    assert_eq!(*d.front().unwrap(), 42);
+    assert_eq!(*d.back().unwrap(), 137);
+    let mut i = d.pop_front();
+    assert_eq!(i, Some(42));
+    i = d.pop_back();
+    assert_eq!(i, Some(137));
+    i = d.pop_back();
+    assert_eq!(i, Some(137));
+    i = d.pop_back();
+    assert_eq!(i, Some(17));
+    assert_eq!(d.len(), 0);
+    d.push_back(3);
+    assert_eq!(d.len(), 1);
+    d.push_front(2);
+    assert_eq!(d.len(), 2);
+    d.push_back(4);
+    assert_eq!(d.len(), 3);
+    d.push_front(1);
+    assert_eq!(d.len(), 4);
+    debug!("{}", d[0]);
+    debug!("{}", d[1]);
+    debug!("{}", d[2]);
+    debug!("{}", d[3]);
+    assert_eq!(d[0], 1);
+    assert_eq!(d[1], 2);
+    assert_eq!(d[2], 3);
+    assert_eq!(d[3], 4);
+}
+
+#[cfg(test)]
+fn test_parameterized<T:Clone + PartialEq + Debug>(a: T, b: T, c: T, d: T) {
+    let mut deq = VecDeque::new();
+    assert_eq!(deq.len(), 0);
+    deq.push_front(a.clone());
+    deq.push_front(b.clone());
+    deq.push_back(c.clone());
+    assert_eq!(deq.len(), 3);
+    deq.push_back(d.clone());
+    assert_eq!(deq.len(), 4);
+    assert_eq!((*deq.front().unwrap()).clone(), b.clone());
+    assert_eq!((*deq.back().unwrap()).clone(), d.clone());
+    assert_eq!(deq.pop_front().unwrap(), b.clone());
+    assert_eq!(deq.pop_back().unwrap(), d.clone());
+    assert_eq!(deq.pop_back().unwrap(), c.clone());
+    assert_eq!(deq.pop_back().unwrap(), a.clone());
+    assert_eq!(deq.len(), 0);
+    deq.push_back(c.clone());
+    assert_eq!(deq.len(), 1);
+    deq.push_front(b.clone());
+    assert_eq!(deq.len(), 2);
+    deq.push_back(d.clone());
+    assert_eq!(deq.len(), 3);
+    deq.push_front(a.clone());
+    assert_eq!(deq.len(), 4);
+    assert_eq!(deq[0].clone(), a.clone());
+    assert_eq!(deq[1].clone(), b.clone());
+    assert_eq!(deq[2].clone(), c.clone());
+    assert_eq!(deq[3].clone(), d.clone());
+}
+
+#[test]
+fn test_push_front_grow() {
+    let mut deq = VecDeque::new();
+    for i in 0..66 {
+        deq.push_front(i);
+    }
+    assert_eq!(deq.len(), 66);
+
+    for i in 0..66 {
+        assert_eq!(deq[i], 65 - i);
+    }
+
+    let mut deq = VecDeque::new();
+    for i in 0..66 {
+        deq.push_back(i);
+    }
+
+    for i in 0..66 {
+        assert_eq!(deq[i], i);
+    }
+}
+
+#[test]
+fn test_index() {
+    let mut deq = VecDeque::new();
+    for i in 1..4 {
+        deq.push_front(i);
+    }
+    assert_eq!(deq[1], 2);
+}
+
+#[test]
+#[should_panic]
+fn test_index_out_of_bounds() {
+    let mut deq = VecDeque::new();
+    for i in 1..4 {
+        deq.push_front(i);
+    }
+    deq[3];
+}
+
+#[bench]
+fn bench_new(b: &mut test::Bencher) {
+    b.iter(|| {
+        let ring: VecDeque<i32> = VecDeque::new();
+        test::black_box(ring);
+    })
+}
+
+#[bench]
+fn bench_grow_1025(b: &mut test::Bencher) {
+    b.iter(|| {
+        let mut deq = VecDeque::new();
+        for i in 0..1025 {
+            deq.push_front(i);
+        }
+        test::black_box(deq);
+    })
+}
+
+#[bench]
+fn bench_iter_1000(b: &mut test::Bencher) {
+    let ring: VecDeque<_> = (0..1000).collect();
+
+    b.iter(|| {
+        let mut sum = 0;
+        for &i in &ring {
+            sum += i;
+        }
+        test::black_box(sum);
+    })
+}
+
+#[bench]
+fn bench_mut_iter_1000(b: &mut test::Bencher) {
+    let mut ring: VecDeque<_> = (0..1000).collect();
+
+    b.iter(|| {
+        let mut sum = 0;
+        for i in &mut ring {
+            sum += *i;
+        }
+        test::black_box(sum);
+    })
+}
+
+#[derive(Clone, PartialEq, Debug)]
+enum Taggy {
+    One(i32),
+    Two(i32, i32),
+    Three(i32, i32, i32),
+}
+
+#[derive(Clone, PartialEq, Debug)]
+enum Taggypar<T> {
+    Onepar(T),
+    Twopar(T, T),
+    Threepar(T, T, T),
+}
+
+#[derive(Clone, PartialEq, Debug)]
+struct RecCy {
+    x: i32,
+    y: i32,
+    t: Taggy
+}
+
+#[test]
+fn test_param_int() {
+    test_parameterized::<i32>(5, 72, 64, 175);
+}
+
+#[test]
+fn test_param_taggy() {
+    test_parameterized::<Taggy>(One(1), Two(1, 2), Three(1, 2, 3), Two(17, 42));
+}
+
+#[test]
+fn test_param_taggypar() {
+    test_parameterized::<Taggypar<i32>>(Onepar::<i32>(1),
+                                        Twopar::<i32>(1, 2),
+                                        Threepar::<i32>(1, 2, 3),
+                                        Twopar::<i32>(17, 42));
+}
+
+#[test]
+fn test_param_reccy() {
+    let reccy1 = RecCy { x: 1, y: 2, t: One(1) };
+    let reccy2 = RecCy { x: 345, y: 2, t: Two(1, 2) };
+    let reccy3 = RecCy { x: 1, y: 777, t: Three(1, 2, 3) };
+    let reccy4 = RecCy { x: 19, y: 252, t: Two(17, 42) };
+    test_parameterized::<RecCy>(reccy1, reccy2, reccy3, reccy4);
+}
+
+#[test]
+fn test_with_capacity() {
+    let mut d = VecDeque::with_capacity(0);
+    d.push_back(1);
+    assert_eq!(d.len(), 1);
+    let mut d = VecDeque::with_capacity(50);
+    d.push_back(1);
+    assert_eq!(d.len(), 1);
+}
+
+#[test]
+fn test_with_capacity_non_power_two() {
+    let mut d3 = VecDeque::with_capacity(3);
+    d3.push_back(1);
+
+    // X = None, | = lo
+    // [|1, X, X]
+    assert_eq!(d3.pop_front(), Some(1));
+    // [X, |X, X]
+    assert_eq!(d3.front(), None);
+
+    // [X, |3, X]
+    d3.push_back(3);
+    // [X, |3, 6]
+    d3.push_back(6);
+    // [X, X, |6]
+    assert_eq!(d3.pop_front(), Some(3));
+
+    // Pushing the lo past half way point to trigger
+    // the 'B' scenario for growth
+    // [9, X, |6]
+    d3.push_back(9);
+    // [9, 12, |6]
+    d3.push_back(12);
+
+    d3.push_back(15);
+    // There used to be a bug here about how the
+    // VecDeque made growth assumptions about the
+    // underlying Vec which didn't hold and lead
+    // to corruption.
+    // (Vec grows to next power of two)
+    //good- [9, 12, 15, X, X, X, X, |6]
+    //bug-  [15, 12, X, X, X, |6, X, X]
+    assert_eq!(d3.pop_front(), Some(6));
+
+    // Which leads us to the following state which
+    // would be a failure case.
+    //bug-  [15, 12, X, X, X, X, |X, X]
+    assert_eq!(d3.front(), Some(&9));
+}
+
+#[test]
+fn test_reserve_exact() {
+    let mut d = VecDeque::new();
+    d.push_back(0);
+    d.reserve_exact(50);
+    assert!(d.capacity() >= 51);
+}
+
+#[test]
+fn test_reserve() {
+    let mut d = VecDeque::new();
+    d.push_back(0);
+    d.reserve(50);
+    assert!(d.capacity() >= 51);
+}
+
+#[test]
+fn test_swap() {
+    let mut d: VecDeque<_> = (0..5).collect();
+    d.pop_front();
+    d.swap(0, 3);
+    assert_eq!(d.iter().cloned().collect::<Vec<_>>(), [4, 2, 3, 1]);
+}
+
+#[test]
+fn test_iter() {
+    let mut d = VecDeque::new();
+    assert_eq!(d.iter().next(), None);
+    assert_eq!(d.iter().size_hint(), (0, Some(0)));
+
+    for i in 0..5 {
+        d.push_back(i);
+    }
+    {
+        let b: &[_] = &[&0,&1,&2,&3,&4];
+        assert_eq!(d.iter().collect::<Vec<_>>(), b);
+    }
+
+    for i in 6..9 {
+        d.push_front(i);
+    }
+    {
+        let b: &[_] = &[&8,&7,&6,&0,&1,&2,&3,&4];
+        assert_eq!(d.iter().collect::<Vec<_>>(), b);
+    }
+
+    let mut it = d.iter();
+    let mut len = d.len();
+    loop {
+        match it.next() {
+            None => break,
+            _ => { len -= 1; assert_eq!(it.size_hint(), (len, Some(len))) }
+        }
+    }
+}
+
+#[test]
+fn test_rev_iter() {
+    let mut d = VecDeque::new();
+    assert_eq!(d.iter().rev().next(), None);
+
+    for i in 0..5 {
+        d.push_back(i);
+    }
+    {
+        let b: &[_] = &[&4,&3,&2,&1,&0];
+        assert_eq!(d.iter().rev().collect::<Vec<_>>(), b);
+    }
+
+    for i in 6..9 {
+        d.push_front(i);
+    }
+    let b: &[_] = &[&4,&3,&2,&1,&0,&6,&7,&8];
+    assert_eq!(d.iter().rev().collect::<Vec<_>>(), b);
+}
+
+#[test]
+fn test_mut_rev_iter_wrap() {
+    let mut d = VecDeque::with_capacity(3);
+    assert!(d.iter_mut().rev().next().is_none());
+
+    d.push_back(1);
+    d.push_back(2);
+    d.push_back(3);
+    assert_eq!(d.pop_front(), Some(1));
+    d.push_back(4);
+
+    assert_eq!(d.iter_mut().rev().cloned().collect::<Vec<_>>(),
+               vec![4, 3, 2]);
+}
+
+#[test]
+fn test_mut_iter() {
+    let mut d = VecDeque::new();
+    assert!(d.iter_mut().next().is_none());
+
+    for i in 0..3 {
+        d.push_front(i);
+    }
+
+    for (i, elt) in d.iter_mut().enumerate() {
+        assert_eq!(*elt, 2 - i);
+        *elt = i;
+    }
+
+    {
+        let mut it = d.iter_mut();
+        assert_eq!(*it.next().unwrap(), 0);
+        assert_eq!(*it.next().unwrap(), 1);
+        assert_eq!(*it.next().unwrap(), 2);
+        assert!(it.next().is_none());
+    }
+}
+
+#[test]
+fn test_mut_rev_iter() {
+    let mut d = VecDeque::new();
+    assert!(d.iter_mut().rev().next().is_none());
+
+    for i in 0..3 {
+        d.push_front(i);
+    }
+
+    for (i, elt) in d.iter_mut().rev().enumerate() {
+        assert_eq!(*elt, i);
+        *elt = i;
+    }
+
+    {
+        let mut it = d.iter_mut().rev();
+        assert_eq!(*it.next().unwrap(), 0);
+        assert_eq!(*it.next().unwrap(), 1);
+        assert_eq!(*it.next().unwrap(), 2);
+        assert!(it.next().is_none());
+    }
+}
+
+#[test]
+fn test_into_iter() {
+
+    // Empty iter
+    {
+        let d: VecDeque<i32> = VecDeque::new();
+        let mut iter = d.into_iter();
+
+        assert_eq!(iter.size_hint(), (0, Some(0)));
+        assert_eq!(iter.next(), None);
+        assert_eq!(iter.size_hint(), (0, Some(0)));
+    }
+
+    // simple iter
+    {
+        let mut d = VecDeque::new();
+        for i in 0..5 {
+            d.push_back(i);
+        }
+
+        let b = vec![0,1,2,3,4];
+        assert_eq!(d.into_iter().collect::<Vec<_>>(), b);
+    }
+
+    // wrapped iter
+    {
+        let mut d = VecDeque::new();
+        for i in 0..5 {
+            d.push_back(i);
+        }
+        for i in 6..9 {
+            d.push_front(i);
+        }
+
+        let b = vec![8,7,6,0,1,2,3,4];
+        assert_eq!(d.into_iter().collect::<Vec<_>>(), b);
+    }
+
+    // partially used
+    {
+        let mut d = VecDeque::new();
+        for i in 0..5 {
+            d.push_back(i);
+        }
+        for i in 6..9 {
+            d.push_front(i);
+        }
+
+        let mut it = d.into_iter();
+        assert_eq!(it.size_hint(), (8, Some(8)));
+        assert_eq!(it.next(), Some(8));
+        assert_eq!(it.size_hint(), (7, Some(7)));
+        assert_eq!(it.next_back(), Some(4));
+        assert_eq!(it.size_hint(), (6, Some(6)));
+        assert_eq!(it.next(), Some(7));
+        assert_eq!(it.size_hint(), (5, Some(5)));
+    }
+}
+
+#[test]
+fn test_drain() {
+
+    // Empty iter
+    {
+        let mut d: VecDeque<i32> = VecDeque::new();
+
+        {
+            let mut iter = d.drain();
+
+            assert_eq!(iter.size_hint(), (0, Some(0)));
+            assert_eq!(iter.next(), None);
+            assert_eq!(iter.size_hint(), (0, Some(0)));
+        }
+
+        assert!(d.is_empty());
+    }
+
+    // simple iter
+    {
+        let mut d = VecDeque::new();
+        for i in 0..5 {
+            d.push_back(i);
+        }
+
+        assert_eq!(d.drain().collect::<Vec<_>>(), [0, 1, 2, 3, 4]);
+        assert!(d.is_empty());
+    }
+
+    // wrapped iter
+    {
+        let mut d = VecDeque::new();
+        for i in 0..5 {
+            d.push_back(i);
+        }
+        for i in 6..9 {
+            d.push_front(i);
+        }
+
+        assert_eq!(d.drain().collect::<Vec<_>>(), [8,7,6,0,1,2,3,4]);
+        assert!(d.is_empty());
+    }
+
+    // partially used
+    {
+        let mut d: VecDeque<_> = VecDeque::new();
+        for i in 0..5 {
+            d.push_back(i);
+        }
+        for i in 6..9 {
+            d.push_front(i);
+        }
+
+        {
+            let mut it = d.drain();
+            assert_eq!(it.size_hint(), (8, Some(8)));
+            assert_eq!(it.next(), Some(8));
+            assert_eq!(it.size_hint(), (7, Some(7)));
+            assert_eq!(it.next_back(), Some(4));
+            assert_eq!(it.size_hint(), (6, Some(6)));
+            assert_eq!(it.next(), Some(7));
+            assert_eq!(it.size_hint(), (5, Some(5)));
+        }
+        assert!(d.is_empty());
+    }
+}
+
+#[test]
+fn test_from_iter() {
+    use std::iter;
+
+    let v = vec!(1,2,3,4,5,6,7);
+    let deq: VecDeque<_> = v.iter().cloned().collect();
+    let u: Vec<_> = deq.iter().cloned().collect();
+    assert_eq!(u, v);
+
+    let seq = iter::count(0, 2).take(256);
+    let deq: VecDeque<_> = seq.collect();
+    for (i, &x) in deq.iter().enumerate() {
+        assert_eq!(2*i, x);
+    }
+    assert_eq!(deq.len(), 256);
+}
+
+#[test]
+fn test_clone() {
+    let mut d = VecDeque::new();
+    d.push_front(17);
+    d.push_front(42);
+    d.push_back(137);
+    d.push_back(137);
+    assert_eq!(d.len(), 4);
+    let mut e = d.clone();
+    assert_eq!(e.len(), 4);
+    while !d.is_empty() {
+        assert_eq!(d.pop_back(), e.pop_back());
+    }
+    assert_eq!(d.len(), 0);
+    assert_eq!(e.len(), 0);
+}
+
+#[test]
+fn test_eq() {
+    let mut d = VecDeque::new();
+    assert!(d == VecDeque::with_capacity(0));
+    d.push_front(137);
+    d.push_front(17);
+    d.push_front(42);
+    d.push_back(137);
+    let mut e = VecDeque::with_capacity(0);
+    e.push_back(42);
+    e.push_back(17);
+    e.push_back(137);
+    e.push_back(137);
+    assert!(&e == &d);
+    e.pop_back();
+    e.push_back(0);
+    assert!(e != d);
+    e.clear();
+    assert!(e == VecDeque::new());
+}
+
+#[test]
+fn test_hash() {
+  let mut x = VecDeque::new();
+  let mut y = VecDeque::new();
+
+  x.push_back(1);
+  x.push_back(2);
+  x.push_back(3);
+
+  y.push_back(0);
+  y.push_back(1);
+  y.pop_front();
+  y.push_back(2);
+  y.push_back(3);
+
+  assert!(hash::hash::<_, SipHasher>(&x) == hash::hash::<_, SipHasher>(&y));
+}
+
+#[test]
+fn test_ord() {
+    let x = VecDeque::new();
+    let mut y = VecDeque::new();
+    y.push_back(1);
+    y.push_back(2);
+    y.push_back(3);
+    assert!(x < y);
+    assert!(y > x);
+    assert!(x <= x);
+    assert!(x >= x);
+}
+
+#[test]
+fn test_show() {
+    let ringbuf: VecDeque<_> = (0..10).collect();
+    assert_eq!(format!("{:?}", ringbuf), "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
+
+    let ringbuf: VecDeque<_> = vec!["just", "one", "test", "more"].iter()
+                                                                    .cloned()
+                                                                    .collect();
+    assert_eq!(format!("{:?}", ringbuf), "[\"just\", \"one\", \"test\", \"more\"]");
+}
+
+#[test]
+fn test_drop() {
+    static mut drops: i32 = 0;
+    struct Elem;
+    impl Drop for Elem {
+        fn drop(&mut self) {
+            unsafe { drops += 1; }
+        }
+    }
+
+    let mut ring = VecDeque::new();
+    ring.push_back(Elem);
+    ring.push_front(Elem);
+    ring.push_back(Elem);
+    ring.push_front(Elem);
+    drop(ring);
+
+    assert_eq!(unsafe {drops}, 4);
+}
+
+#[test]
+fn test_drop_with_pop() {
+    static mut drops: i32 = 0;
+    struct Elem;
+    impl Drop for Elem {
+        fn drop(&mut self) {
+            unsafe { drops += 1; }
+        }
+    }
+
+    let mut ring = VecDeque::new();
+    ring.push_back(Elem);
+    ring.push_front(Elem);
+    ring.push_back(Elem);
+    ring.push_front(Elem);
+
+    drop(ring.pop_back());
+    drop(ring.pop_front());
+    assert_eq!(unsafe {drops}, 2);
+
+    drop(ring);
+    assert_eq!(unsafe {drops}, 4);
+}
+
+#[test]
+fn test_drop_clear() {
+    static mut drops: i32 = 0;
+    struct Elem;
+    impl Drop for Elem {
+        fn drop(&mut self) {
+            unsafe { drops += 1; }
+        }
+    }
+
+    let mut ring = VecDeque::new();
+    ring.push_back(Elem);
+    ring.push_front(Elem);
+    ring.push_back(Elem);
+    ring.push_front(Elem);
+    ring.clear();
+    assert_eq!(unsafe {drops}, 4);
+
+    drop(ring);
+    assert_eq!(unsafe {drops}, 4);
+}
+
+#[test]
+fn test_reserve_grow() {
+    // test growth path A
+    // [T o o H] -> [T o o H . . . . ]
+    let mut ring = VecDeque::with_capacity(4);
+    for i in 0..3 {
+        ring.push_back(i);
+    }
+    ring.reserve(7);
+    for i in 0..3 {
+        assert_eq!(ring.pop_front(), Some(i));
+    }
+
+    // test growth path B
+    // [H T o o] -> [. T o o H . . . ]
+    let mut ring = VecDeque::with_capacity(4);
+    for i in 0..1 {
+        ring.push_back(i);
+        assert_eq!(ring.pop_front(), Some(i));
+    }
+    for i in 0..3 {
+        ring.push_back(i);
+    }
+    ring.reserve(7);
+    for i in 0..3 {
+        assert_eq!(ring.pop_front(), Some(i));
+    }
+
+    // test growth path C
+    // [o o H T] -> [o o H . . . . T ]
+    let mut ring = VecDeque::with_capacity(4);
+    for i in 0..3 {
+        ring.push_back(i);
+        assert_eq!(ring.pop_front(), Some(i));
+    }
+    for i in 0..3 {
+        ring.push_back(i);
+    }
+    ring.reserve(7);
+    for i in 0..3 {
+        assert_eq!(ring.pop_front(), Some(i));
+    }
+}
+
+#[test]
+fn test_get() {
+    let mut ring = VecDeque::new();
+    ring.push_back(0);
+    assert_eq!(ring.get(0), Some(&0));
+    assert_eq!(ring.get(1), None);
+
+    ring.push_back(1);
+    assert_eq!(ring.get(0), Some(&0));
+    assert_eq!(ring.get(1), Some(&1));
+    assert_eq!(ring.get(2), None);
+
+    ring.push_back(2);
+    assert_eq!(ring.get(0), Some(&0));
+    assert_eq!(ring.get(1), Some(&1));
+    assert_eq!(ring.get(2), Some(&2));
+    assert_eq!(ring.get(3), None);
+
+    assert_eq!(ring.pop_front(), Some(0));
+    assert_eq!(ring.get(0), Some(&1));
+    assert_eq!(ring.get(1), Some(&2));
+    assert_eq!(ring.get(2), None);
+
+    assert_eq!(ring.pop_front(), Some(1));
+    assert_eq!(ring.get(0), Some(&2));
+    assert_eq!(ring.get(1), None);
+
+    assert_eq!(ring.pop_front(), Some(2));
+    assert_eq!(ring.get(0), None);
+    assert_eq!(ring.get(1), None);
+}
+
+#[test]
+fn test_get_mut() {
+    let mut ring = VecDeque::new();
+    for i in 0..3 {
+        ring.push_back(i);
+    }
+
+    match ring.get_mut(1) {
+        Some(x) => *x = -1,
+        None => ()
+    };
+
+    assert_eq!(ring.get_mut(0), Some(&mut 0));
+    assert_eq!(ring.get_mut(1), Some(&mut -1));
+    assert_eq!(ring.get_mut(2), Some(&mut 2));
+    assert_eq!(ring.get_mut(3), None);
+
+    assert_eq!(ring.pop_front(), Some(0));
+    assert_eq!(ring.get_mut(0), Some(&mut -1));
+    assert_eq!(ring.get_mut(1), Some(&mut 2));
+    assert_eq!(ring.get_mut(2), None);
+}
+
+#[test]
+fn test_front() {
+    let mut ring = VecDeque::new();
+    ring.push_back(10);
+    ring.push_back(20);
+    assert_eq!(ring.front(), Some(&10));
+    ring.pop_front();
+    assert_eq!(ring.front(), Some(&20));
+    ring.pop_front();
+    assert_eq!(ring.front(), None);
+}
+
+#[test]
+fn test_as_slices() {
+    let mut ring: VecDeque<i32> = VecDeque::with_capacity(127);
+    let cap = ring.capacity() as i32;
+    let first = cap/2;
+    let last  = cap - first;
+    for i in 0..first {
+        ring.push_back(i);
+
+        let (left, right) = ring.as_slices();
+        let expected: Vec<_> = (0..i+1).collect();
+        assert_eq!(left, expected);
+        assert_eq!(right, []);
+    }
+
+    for j in -last..0 {
+        ring.push_front(j);
+        let (left, right) = ring.as_slices();
+        let expected_left: Vec<_> = (-last..j+1).rev().collect();
+        let expected_right: Vec<_> = (0..first).collect();
+        assert_eq!(left, expected_left);
+        assert_eq!(right, expected_right);
+    }
+
+    assert_eq!(ring.len() as i32, cap);
+    assert_eq!(ring.capacity() as i32, cap);
+}
+
+#[test]
+fn test_as_mut_slices() {
+    let mut ring: VecDeque<i32> = VecDeque::with_capacity(127);
+    let cap = ring.capacity() as i32;
+    let first = cap/2;
+    let last  = cap - first;
+    for i in 0..first {
+        ring.push_back(i);
+
+        let (left, right) = ring.as_mut_slices();
+        let expected: Vec<_> = (0..i+1).collect();
+        assert_eq!(left, expected);
+        assert_eq!(right, []);
+    }
+
+    for j in -last..0 {
+        ring.push_front(j);
+        let (left, right) = ring.as_mut_slices();
+        let expected_left: Vec<_> = (-last..j+1).rev().collect();
+        let expected_right: Vec<_> = (0..first).collect();
+        assert_eq!(left, expected_left);
+        assert_eq!(right, expected_right);
+    }
+
+    assert_eq!(ring.len() as i32, cap);
+    assert_eq!(ring.capacity() as i32, cap);
+}
+
+#[test]
+fn test_append() {
+    let mut a: VecDeque<_> = vec![1, 2, 3].into_iter().collect();
+    let mut b: VecDeque<_> = vec![4, 5, 6].into_iter().collect();
+
+    // normal append
+    a.append(&mut b);
+    assert_eq!(a.iter().cloned().collect::<Vec<_>>(), [1, 2, 3, 4, 5, 6]);
+    assert_eq!(b.iter().cloned().collect::<Vec<_>>(), []);
+
+    // append nothing to something
+    a.append(&mut b);
+    assert_eq!(a.iter().cloned().collect::<Vec<_>>(), [1, 2, 3, 4, 5, 6]);
+    assert_eq!(b.iter().cloned().collect::<Vec<_>>(), []);
+
+    // append something to nothing
+    b.append(&mut a);
+    assert_eq!(b.iter().cloned().collect::<Vec<_>>(), [1, 2, 3, 4, 5, 6]);
+    assert_eq!(a.iter().cloned().collect::<Vec<_>>(), []);
+}
diff --git a/src/libcollectionstest/vec_map.rs b/src/libcollectionstest/vec_map.rs
new file mode 100644
index 00000000000..112b4c03e20
--- /dev/null
+++ b/src/libcollectionstest/vec_map.rs
@@ -0,0 +1,510 @@
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::collections::VecMap;
+use std::collections::vec_map::Entry::{Occupied, Vacant};
+use std::hash::{SipHasher, hash};
+
+#[test]
+fn test_get_mut() {
+    let mut m = VecMap::new();
+    assert!(m.insert(1, 12).is_none());
+    assert!(m.insert(2, 8).is_none());
+    assert!(m.insert(5, 14).is_none());
+    let new = 100;
+    match m.get_mut(&5) {
+        None => panic!(), Some(x) => *x = new
+    }
+    assert_eq!(m.get(&5), Some(&new));
+}
+
+#[test]
+fn test_len() {
+    let mut map = VecMap::new();
+    assert_eq!(map.len(), 0);
+    assert!(map.is_empty());
+    assert!(map.insert(5, 20).is_none());
+    assert_eq!(map.len(), 1);
+    assert!(!map.is_empty());
+    assert!(map.insert(11, 12).is_none());
+    assert_eq!(map.len(), 2);
+    assert!(!map.is_empty());
+    assert!(map.insert(14, 22).is_none());
+    assert_eq!(map.len(), 3);
+    assert!(!map.is_empty());
+}
+
+#[test]
+fn test_clear() {
+    let mut map = VecMap::new();
+    assert!(map.insert(5, 20).is_none());
+    assert!(map.insert(11, 12).is_none());
+    assert!(map.insert(14, 22).is_none());
+    map.clear();
+    assert!(map.is_empty());
+    assert!(map.get(&5).is_none());
+    assert!(map.get(&11).is_none());
+    assert!(map.get(&14).is_none());
+}
+
+#[test]
+fn test_insert() {
+    let mut m = VecMap::new();
+    assert_eq!(m.insert(1, 2), None);
+    assert_eq!(m.insert(1, 3), Some(2));
+    assert_eq!(m.insert(1, 4), Some(3));
+}
+
+#[test]
+fn test_remove() {
+    let mut m = VecMap::new();
+    m.insert(1, 2);
+    assert_eq!(m.remove(&1), Some(2));
+    assert_eq!(m.remove(&1), None);
+}
+
+#[test]
+fn test_keys() {
+    let mut map = VecMap::new();
+    map.insert(1, 'a');
+    map.insert(2, 'b');
+    map.insert(3, 'c');
+    let keys: Vec<_> = map.keys().collect();
+    assert_eq!(keys.len(), 3);
+    assert!(keys.contains(&1));
+    assert!(keys.contains(&2));
+    assert!(keys.contains(&3));
+}
+
+#[test]
+fn test_values() {
+    let mut map = VecMap::new();
+    map.insert(1, 'a');
+    map.insert(2, 'b');
+    map.insert(3, 'c');
+    let values: Vec<_> = map.values().cloned().collect();
+    assert_eq!(values.len(), 3);
+    assert!(values.contains(&'a'));
+    assert!(values.contains(&'b'));
+    assert!(values.contains(&'c'));
+}
+
+#[test]
+fn test_iterator() {
+    let mut m = VecMap::new();
+
+    assert!(m.insert(0, 1).is_none());
+    assert!(m.insert(1, 2).is_none());
+    assert!(m.insert(3, 5).is_none());
+    assert!(m.insert(6, 10).is_none());
+    assert!(m.insert(10, 11).is_none());
+
+    let mut it = m.iter();
+    assert_eq!(it.size_hint(), (0, Some(11)));
+    assert_eq!(it.next().unwrap(), (0, &1));
+    assert_eq!(it.size_hint(), (0, Some(10)));
+    assert_eq!(it.next().unwrap(), (1, &2));
+    assert_eq!(it.size_hint(), (0, Some(9)));
+    assert_eq!(it.next().unwrap(), (3, &5));
+    assert_eq!(it.size_hint(), (0, Some(7)));
+    assert_eq!(it.next().unwrap(), (6, &10));
+    assert_eq!(it.size_hint(), (0, Some(4)));
+    assert_eq!(it.next().unwrap(), (10, &11));
+    assert_eq!(it.size_hint(), (0, Some(0)));
+    assert!(it.next().is_none());
+}
+
+#[test]
+fn test_iterator_size_hints() {
+    let mut m = VecMap::new();
+
+    assert!(m.insert(0, 1).is_none());
+    assert!(m.insert(1, 2).is_none());
+    assert!(m.insert(3, 5).is_none());
+    assert!(m.insert(6, 10).is_none());
+    assert!(m.insert(10, 11).is_none());
+
+    assert_eq!(m.iter().size_hint(), (0, Some(11)));
+    assert_eq!(m.iter().rev().size_hint(), (0, Some(11)));
+    assert_eq!(m.iter_mut().size_hint(), (0, Some(11)));
+    assert_eq!(m.iter_mut().rev().size_hint(), (0, Some(11)));
+}
+
+#[test]
+fn test_mut_iterator() {
+    let mut m = VecMap::new();
+
+    assert!(m.insert(0, 1).is_none());
+    assert!(m.insert(1, 2).is_none());
+    assert!(m.insert(3, 5).is_none());
+    assert!(m.insert(6, 10).is_none());
+    assert!(m.insert(10, 11).is_none());
+
+    for (k, v) in &mut m {
+        *v += k as isize;
+    }
+
+    let mut it = m.iter();
+    assert_eq!(it.next().unwrap(), (0, &1));
+    assert_eq!(it.next().unwrap(), (1, &3));
+    assert_eq!(it.next().unwrap(), (3, &8));
+    assert_eq!(it.next().unwrap(), (6, &16));
+    assert_eq!(it.next().unwrap(), (10, &21));
+    assert!(it.next().is_none());
+}
+
+#[test]
+fn test_rev_iterator() {
+    let mut m = VecMap::new();
+
+    assert!(m.insert(0, 1).is_none());
+    assert!(m.insert(1, 2).is_none());
+    assert!(m.insert(3, 5).is_none());
+    assert!(m.insert(6, 10).is_none());
+    assert!(m.insert(10, 11).is_none());
+
+    let mut it = m.iter().rev();
+    assert_eq!(it.next().unwrap(), (10, &11));
+    assert_eq!(it.next().unwrap(), (6, &10));
+    assert_eq!(it.next().unwrap(), (3, &5));
+    assert_eq!(it.next().unwrap(), (1, &2));
+    assert_eq!(it.next().unwrap(), (0, &1));
+    assert!(it.next().is_none());
+}
+
+#[test]
+fn test_mut_rev_iterator() {
+    let mut m = VecMap::new();
+
+    assert!(m.insert(0, 1).is_none());
+    assert!(m.insert(1, 2).is_none());
+    assert!(m.insert(3, 5).is_none());
+    assert!(m.insert(6, 10).is_none());
+    assert!(m.insert(10, 11).is_none());
+
+    for (k, v) in m.iter_mut().rev() {
+        *v += k as isize;
+    }
+
+    let mut it = m.iter();
+    assert_eq!(it.next().unwrap(), (0, &1));
+    assert_eq!(it.next().unwrap(), (1, &3));
+    assert_eq!(it.next().unwrap(), (3, &8));
+    assert_eq!(it.next().unwrap(), (6, &16));
+    assert_eq!(it.next().unwrap(), (10, &21));
+    assert!(it.next().is_none());
+}
+
+#[test]
+fn test_move_iter() {
+    let mut m: VecMap<Box<_>> = VecMap::new();
+    m.insert(1, box 2);
+    let mut called = false;
+    for (k, v) in m {
+        assert!(!called);
+        called = true;
+        assert_eq!(k, 1);
+        assert_eq!(v, box 2);
+    }
+    assert!(called);
+}
+
+#[test]
+fn test_drain_iterator() {
+    let mut map = VecMap::new();
+    map.insert(1, "a");
+    map.insert(3, "c");
+    map.insert(2, "b");
+
+    let vec: Vec<_> = map.drain().collect();
+
+    assert_eq!(vec, [(1, "a"), (2, "b"), (3, "c")]);
+    assert_eq!(map.len(), 0);
+}
+
+#[test]
+fn test_append() {
+    let mut a = VecMap::new();
+    a.insert(1, "a");
+    a.insert(2, "b");
+    a.insert(3, "c");
+
+    let mut b = VecMap::new();
+    b.insert(3, "d");  // Overwrite element from a
+    b.insert(4, "e");
+    b.insert(5, "f");
+
+    a.append(&mut b);
+
+    assert_eq!(a.len(), 5);
+    assert_eq!(b.len(), 0);
+    // Capacity shouldn't change for possible reuse
+    assert!(b.capacity() >= 4);
+
+    assert_eq!(a[1], "a");
+    assert_eq!(a[2], "b");
+    assert_eq!(a[3], "d");
+    assert_eq!(a[4], "e");
+    assert_eq!(a[5], "f");
+}
+
+#[test]
+fn test_split_off() {
+    // Split within the key range
+    let mut a = VecMap::new();
+    a.insert(1, "a");
+    a.insert(2, "b");
+    a.insert(3, "c");
+    a.insert(4, "d");
+
+    let b = a.split_off(3);
+
+    assert_eq!(a.len(), 2);
+    assert_eq!(b.len(), 2);
+
+    assert_eq!(a[1], "a");
+    assert_eq!(a[2], "b");
+
+    assert_eq!(b[3], "c");
+    assert_eq!(b[4], "d");
+
+    // Split at 0
+    a.clear();
+    a.insert(1, "a");
+    a.insert(2, "b");
+    a.insert(3, "c");
+    a.insert(4, "d");
+
+    let b = a.split_off(0);
+
+    assert_eq!(a.len(), 0);
+    assert_eq!(b.len(), 4);
+    assert_eq!(b[1], "a");
+    assert_eq!(b[2], "b");
+    assert_eq!(b[3], "c");
+    assert_eq!(b[4], "d");
+
+    // Split behind max_key
+    a.clear();
+    a.insert(1, "a");
+    a.insert(2, "b");
+    a.insert(3, "c");
+    a.insert(4, "d");
+
+    let b = a.split_off(5);
+
+    assert_eq!(a.len(), 4);
+    assert_eq!(b.len(), 0);
+    assert_eq!(a[1], "a");
+    assert_eq!(a[2], "b");
+    assert_eq!(a[3], "c");
+    assert_eq!(a[4], "d");
+}
+
+#[test]
+fn test_show() {
+    let mut map = VecMap::new();
+    let empty = VecMap::<i32>::new();
+
+    map.insert(1, 2);
+    map.insert(3, 4);
+
+    let map_str = format!("{:?}", map);
+    assert!(map_str == "{1: 2, 3: 4}" || map_str == "{3: 4, 1: 2}");
+    assert_eq!(format!("{:?}", empty), "{}");
+}
+
+#[test]
+fn test_clone() {
+    let mut a = VecMap::new();
+
+    a.insert(1, 'x');
+    a.insert(4, 'y');
+    a.insert(6, 'z');
+
+    assert!(a.clone() == a);
+}
+
+#[test]
+fn test_eq() {
+    let mut a = VecMap::new();
+    let mut b = VecMap::new();
+
+    assert!(a == b);
+    assert!(a.insert(0, 5).is_none());
+    assert!(a != b);
+    assert!(b.insert(0, 4).is_none());
+    assert!(a != b);
+    assert!(a.insert(5, 19).is_none());
+    assert!(a != b);
+    assert!(!b.insert(0, 5).is_none());
+    assert!(a != b);
+    assert!(b.insert(5, 19).is_none());
+    assert!(a == b);
+
+    a = VecMap::new();
+    b = VecMap::with_capacity(1);
+    assert!(a == b);
+}
+
+#[test]
+fn test_lt() {
+    let mut a = VecMap::new();
+    let mut b = VecMap::new();
+
+    assert!(!(a < b) && !(b < a));
+    assert!(b.insert(2, 5).is_none());
+    assert!(a < b);
+    assert!(a.insert(2, 7).is_none());
+    assert!(!(a < b) && b < a);
+    assert!(b.insert(1, 0).is_none());
+    assert!(b < a);
+    assert!(a.insert(0, 6).is_none());
+    assert!(a < b);
+    assert!(a.insert(6, 2).is_none());
+    assert!(a < b && !(b < a));
+}
+
+#[test]
+fn test_ord() {
+    let mut a = VecMap::new();
+    let mut b = VecMap::new();
+
+    assert!(a <= b && a >= b);
+    assert!(a.insert(1, 1).is_none());
+    assert!(a > b && a >= b);
+    assert!(b < a && b <= a);
+    assert!(b.insert(2, 2).is_none());
+    assert!(b > a && b >= a);
+    assert!(a < b && a <= b);
+}
+
+#[test]
+fn test_hash() {
+    let mut x = VecMap::new();
+    let mut y = VecMap::new();
+
+    assert!(hash::<_, SipHasher>(&x) == hash::<_, SipHasher>(&y));
+    x.insert(1, 'a');
+    x.insert(2, 'b');
+    x.insert(3, 'c');
+
+    y.insert(3, 'c');
+    y.insert(2, 'b');
+    y.insert(1, 'a');
+
+    assert!(hash::<_, SipHasher>(&x) == hash::<_, SipHasher>(&y));
+
+    x.insert(1000, 'd');
+    x.remove(&1000);
+
+    assert!(hash::<_, SipHasher>(&x) == hash::<_, SipHasher>(&y));
+}
+
+#[test]
+fn test_from_iter() {
+    let xs = vec![(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e')];
+
+    let map: VecMap<_> = xs.iter().cloned().collect();
+
+    for &(k, v) in &xs {
+        assert_eq!(map.get(&k), Some(&v));
+    }
+}
+
+#[test]
+fn test_index() {
+    let mut map = VecMap::new();
+
+    map.insert(1, 2);
+    map.insert(2, 1);
+    map.insert(3, 4);
+
+    assert_eq!(map[3], 4);
+}
+
+#[test]
+#[should_panic]
+fn test_index_nonexistent() {
+    let mut map = VecMap::new();
+
+    map.insert(1, 2);
+    map.insert(2, 1);
+    map.insert(3, 4);
+
+    map[4];
+}
+
+#[test]
+fn test_entry(){
+    let xs = [(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)];
+
+    let mut map: VecMap<_> = xs.iter().cloned().collect();
+
+    // Existing key (insert)
+    match map.entry(1) {
+        Vacant(_) => unreachable!(),
+        Occupied(mut view) => {
+            assert_eq!(view.get(), &10);
+            assert_eq!(view.insert(100), 10);
+        }
+    }
+    assert_eq!(map.get(&1).unwrap(), &100);
+    assert_eq!(map.len(), 6);
+
+
+    // Existing key (update)
+    match map.entry(2) {
+        Vacant(_) => unreachable!(),
+        Occupied(mut view) => {
+            let v = view.get_mut();
+            *v *= 10;
+        }
+    }
+    assert_eq!(map.get(&2).unwrap(), &200);
+    assert_eq!(map.len(), 6);
+
+    // Existing key (take)
+    match map.entry(3) {
+        Vacant(_) => unreachable!(),
+        Occupied(view) => {
+            assert_eq!(view.remove(), 30);
+        }
+    }
+    assert_eq!(map.get(&3), None);
+    assert_eq!(map.len(), 5);
+
+
+    // Inexistent key (insert)
+    match map.entry(10) {
+        Occupied(_) => unreachable!(),
+        Vacant(view) => {
+            assert_eq!(*view.insert(1000), 1000);
+        }
+    }
+    assert_eq!(map.get(&10).unwrap(), &1000);
+    assert_eq!(map.len(), 6);
+}
+
+mod bench {
+    use std::collections::VecMap;
+
+    map_insert_rand_bench!{insert_rand_100,    100,    VecMap}
+    map_insert_rand_bench!{insert_rand_10_000, 10_000, VecMap}
+
+    map_insert_seq_bench!{insert_seq_100,    100,    VecMap}
+    map_insert_seq_bench!{insert_seq_10_000, 10_000, VecMap}
+
+    map_find_rand_bench!{find_rand_100,    100,    VecMap}
+    map_find_rand_bench!{find_rand_10_000, 10_000, VecMap}
+
+    map_find_seq_bench!{find_seq_100,    100,    VecMap}
+    map_find_seq_bench!{find_seq_10_000, 10_000, VecMap}
+}
diff --git a/src/libcore/default.rs b/src/libcore/default.rs
index 7f46d9cbe50..910cf805f39 100644
--- a/src/libcore/default.rs
+++ b/src/libcore/default.rs
@@ -164,4 +164,3 @@ default_impl! { i64, 0 }
 
 default_impl! { f32, 0.0f32 }
 default_impl! { f64, 0.0f64 }
-
diff --git a/src/libcore/finally.rs b/src/libcore/finally.rs
index 74806e52d26..19cd34cdb09 100644
--- a/src/libcore/finally.rs
+++ b/src/libcore/finally.rs
@@ -107,4 +107,3 @@ impl<'a, A, F> Drop for Finallyalizer<'a, A, F> where F: FnMut(&mut A) {
         (self.dtor)(self.mutate);
     }
 }
-
diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs
index 6575bac501f..6dcae9879a0 100644
--- a/src/libcore/macros.rs
+++ b/src/libcore/macros.rs
@@ -216,7 +216,7 @@ macro_rules! writeln {
 ///
 /// Match arms:
 ///
-/// ```rust
+/// ```
 /// fn foo(x: Option<int>) {
 ///     match x {
 ///         Some(n) if n >= 0 => println!("Some(Non-negative)"),
@@ -229,7 +229,7 @@ macro_rules! writeln {
 ///
 /// Iterators:
 ///
-/// ```rust
+/// ```
 /// fn divide_by_three(x: u32) -> u32 { // one of the poorest implementations of x/3
 ///     for i in std::iter::count(0, 1) {
 ///         if 3*i < i { panic!("u32 overflow"); }
diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs
index d596a06709c..1b866501b8e 100644
--- a/src/libcore/marker.rs
+++ b/src/libcore/marker.rs
@@ -310,7 +310,7 @@ impl<T:?Sized> MarkerTrait for T { }
 ///
 /// Therefore, we can model a method like this as follows:
 ///
-/// ```rust
+/// ```
 /// use std::marker::PhantomFn;
 /// trait Even : PhantomFn<Self> { }
 /// ```
@@ -318,7 +318,7 @@ impl<T:?Sized> MarkerTrait for T { }
 /// Another equivalent, but clearer, option would be to use
 /// `MarkerTrait`:
 ///
-/// ```rust
+/// ```
 /// use std::marker::MarkerTrait;
 /// trait Even : MarkerTrait { }
 /// ```
diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs
index 2aa8ec0c548..551f97ead12 100644
--- a/src/libcore/mem.rs
+++ b/src/libcore/mem.rs
@@ -251,7 +251,7 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
 /// `self.buf`. But `replace` can be used to disassociate the original value of `self.buf` from
 /// `self`, allowing it to be returned:
 ///
-/// ```rust
+/// ```
 /// use std::mem;
 /// # struct Buffer<T> { buf: Vec<T> }
 /// impl<T> Buffer<T> {
diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs
index 0d8e3044ecc..ae1b5f65eeb 100644
--- a/src/libcore/num/f32.rs
+++ b/src/libcore/num/f32.rs
@@ -281,7 +281,7 @@ impl Float for f32 {
 
     /// The fractional part of the number, satisfying:
     ///
-    /// ```rust
+    /// ```
     /// use core::num::Float;
     ///
     /// let x = 1.65f32;
diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs
index d7e91058a46..4a73c1e8fcf 100644
--- a/src/libcore/num/f64.rs
+++ b/src/libcore/num/f64.rs
@@ -288,7 +288,7 @@ impl Float for f64 {
 
     /// The fractional part of the number, satisfying:
     ///
-    /// ```rust
+    /// ```
     /// use core::num::Float;
     ///
     /// let x = 1.65f64;
diff --git a/src/libcore/num/float_macros.rs b/src/libcore/num/float_macros.rs
index 20300d29fa0..b3adef53dab 100644
--- a/src/libcore/num/float_macros.rs
+++ b/src/libcore/num/float_macros.rs
@@ -18,4 +18,3 @@ macro_rules! assert_approx_eq {
                 "{} is not approximately equal to {}", *a, *b);
     })
 }
-
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index 6170092c8d1..a77f9709600 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -84,7 +84,7 @@ pub trait Int
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::num::Int;
     ///
     /// let n = 0b01001100u8;
@@ -99,7 +99,7 @@ pub trait Int
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::num::Int;
     ///
     /// let n = 0b01001100u8;
@@ -118,7 +118,7 @@ pub trait Int
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::num::Int;
     ///
     /// let n = 0b0101000u16;
@@ -134,7 +134,7 @@ pub trait Int
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::num::Int;
     ///
     /// let n = 0b0101000u16;
@@ -150,7 +150,7 @@ pub trait Int
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::num::Int;
     ///
     /// let n = 0x0123456789ABCDEFu64;
@@ -167,7 +167,7 @@ pub trait Int
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::num::Int;
     ///
     /// let n = 0x0123456789ABCDEFu64;
@@ -183,7 +183,7 @@ pub trait Int
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::num::Int;
     ///
     /// let n = 0x0123456789ABCDEFu64;
@@ -200,7 +200,7 @@ pub trait Int
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::num::Int;
     ///
     /// let n = 0x0123456789ABCDEFu64;
@@ -223,7 +223,7 @@ pub trait Int
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::num::Int;
     ///
     /// let n = 0x0123456789ABCDEFu64;
@@ -246,7 +246,7 @@ pub trait Int
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::num::Int;
     ///
     /// let n = 0x0123456789ABCDEFu64;
@@ -269,7 +269,7 @@ pub trait Int
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::num::Int;
     ///
     /// let n = 0x0123456789ABCDEFu64;
@@ -291,7 +291,7 @@ pub trait Int
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::num::Int;
     ///
     /// assert_eq!(5u16.checked_add(65530), Some(65535));
@@ -305,7 +305,7 @@ pub trait Int
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::num::Int;
     ///
     /// assert_eq!((-127i8).checked_sub(1), Some(-128));
@@ -319,7 +319,7 @@ pub trait Int
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::num::Int;
     ///
     /// assert_eq!(5u8.checked_mul(51), Some(255));
@@ -333,7 +333,7 @@ pub trait Int
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::num::Int;
     ///
     /// assert_eq!((-127i8).checked_div(-1), Some(127));
@@ -371,7 +371,7 @@ pub trait Int
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::num::Int;
     ///
     /// assert_eq!(2.pow(4), 16);
@@ -708,6 +708,7 @@ signed_int_impl! { i32 }
 signed_int_impl! { i64 }
 signed_int_impl! { int }
 
+#[cfg(stage0)]
 /// A built-in unsigned integer.
 #[stable(feature = "rust1", since = "1.0.0")]
 pub trait UnsignedInt: Int + WrappingOps {
@@ -742,21 +743,1010 @@ pub trait UnsignedInt: Int + WrappingOps {
     }
 }
 
+#[cfg(stage0)]
 #[stable(feature = "rust1", since = "1.0.0")]
 impl UnsignedInt for uint {}
 
+#[cfg(stage0)]
 #[stable(feature = "rust1", since = "1.0.0")]
 impl UnsignedInt for u8 {}
 
+#[cfg(stage0)]
 #[stable(feature = "rust1", since = "1.0.0")]
 impl UnsignedInt for u16 {}
 
+#[cfg(stage0)]
 #[stable(feature = "rust1", since = "1.0.0")]
 impl UnsignedInt for u32 {}
 
+#[cfg(stage0)]
 #[stable(feature = "rust1", since = "1.0.0")]
 impl UnsignedInt for u64 {}
 
+// NB(japaric) I added this module to avoid adding several `cfg(not(stage0))`, and avoid name
+// clashes between macros. We should move all the items inside this module into the outer scope
+// once the `Int` trait is removed
+#[cfg(not(stage0))]
+mod inherent {
+    use intrinsics;
+    use mem::size_of;
+    use option::Option::{self, Some, None};
+
+    use super::wrapping::{OverflowingOps, WrappingOps};
+
+    // `Int` + `SignedInt` implemented for signed integers
+    macro_rules! int_impl {
+        ($T:ty = $ActualT:ty, $UnsignedT:ty, $BITS:expr,
+         $add_with_overflow:path,
+         $sub_with_overflow:path,
+         $mul_with_overflow:path) => {
+            /// Returns the `0` value of this integer type.
+            // FIXME (#5527): Should be an associated constant
+            #[unstable(feature = "core",
+                       reason = "unsure about its place in the world")]
+            #[inline]
+            pub fn zero() -> $T { 0 }
+
+            /// Returns the `1` value of this integer type.
+            // FIXME (#5527): Should be an associated constant
+            #[unstable(feature = "core",
+                       reason = "unsure about its place in the world")]
+            #[inline]
+            pub fn one() -> $T { 1 }
+
+            /// Returns the smallest value that can be represented by this integer type.
+            // FIXME (#5527): Should be and associated constant
+            #[unstable(feature = "core",
+                       reason = "unsure about its place in the world")]
+            #[inline]
+            pub fn min_value() -> $T { (-1 as $T) << ($BITS - 1) }
+
+            /// Returns the largest value that can be represented by this integer type.
+            // FIXME (#5527): Should be and associated constant
+            #[unstable(feature = "core",
+                       reason = "unsure about its place in the world")]
+            #[inline]
+            pub fn max_value() -> $T { let min: $T = <$T>::min_value(); !min }
+
+            /// Returns the number of ones in the binary representation of `self`.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0b01001100u8;
+            ///
+            /// assert_eq!(n.count_ones(), 3);
+            /// ```
+            #[unstable(feature = "core",
+                       reason = "pending integer conventions")]
+            #[inline]
+            pub fn count_ones(self) -> u32 { (self as $UnsignedT).count_ones() }
+
+            /// Returns the number of zeros in the binary representation of `self`.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0b01001100u8;
+            ///
+            /// assert_eq!(n.count_zeros(), 5);
+            /// ```
+            #[unstable(feature = "core",
+                       reason = "pending integer conventions")]
+            #[inline]
+            pub fn count_zeros(self) -> u32 {
+                (!self).count_ones()
+            }
+
+            /// Returns the number of leading zeros in the binary representation
+            /// of `self`.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0b0101000u16;
+            ///
+            /// assert_eq!(n.leading_zeros(), 10);
+            /// ```
+            #[unstable(feature = "core",
+                       reason = "pending integer conventions")]
+            #[inline]
+            pub fn leading_zeros(self) -> u32 { (self as $UnsignedT).leading_zeros() }
+
+            /// Returns the number of trailing zeros in the binary representation
+            /// of `self`.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0b0101000u16;
+            ///
+            /// assert_eq!(n.trailing_zeros(), 3);
+            /// ```
+            #[unstable(feature = "core",
+                       reason = "pending integer conventions")]
+            #[inline]
+            pub fn trailing_zeros(self) -> u32 { (self as $UnsignedT).trailing_zeros() }
+
+            /// Shifts the bits to the left by a specified amount amount, `n`, wrapping
+            /// the truncated bits to the end of the resulting integer.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0x0123456789ABCDEFu64;
+            /// let m = 0x3456789ABCDEF012u64;
+            ///
+            /// assert_eq!(n.rotate_left(12), m);
+            /// ```
+            #[unstable(feature = "core",
+                       reason = "pending integer conventions")]
+            #[inline]
+            pub fn rotate_left(self, n: u32) -> $T { (self as $UnsignedT).rotate_left(n) as $T }
+
+            /// Shifts the bits to the right by a specified amount amount, `n`, wrapping
+            /// the truncated bits to the beginning of the resulting integer.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0x0123456789ABCDEFu64;
+            /// let m = 0xDEF0123456789ABCu64;
+            ///
+            /// assert_eq!(n.rotate_right(12), m);
+            /// ```
+            #[unstable(feature = "core",
+                       reason = "pending integer conventions")]
+            #[inline]
+            pub fn rotate_right(self, n: u32) -> $T { (self as $UnsignedT).rotate_right(n) as $T }
+
+            /// Reverses the byte order of the integer.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0x0123456789ABCDEFu64;
+            /// let m = 0xEFCDAB8967452301u64;
+            ///
+            /// assert_eq!(n.swap_bytes(), m);
+            /// ```
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn swap_bytes(self) -> $T { (self as $UnsignedT).swap_bytes() as $T }
+
+            /// Convert an integer from big endian to the target's endianness.
+            ///
+            /// On big endian this is a no-op. On little endian the bytes are swapped.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0x0123456789ABCDEFu64;
+            ///
+            /// if cfg!(target_endian = "big") {
+            ///     assert_eq!(Int::from_be(n), n)
+            /// } else {
+            ///     assert_eq!(Int::from_be(n), n.swap_bytes())
+            /// }
+            /// ```
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn from_be(x: $T) -> $T {
+                if cfg!(target_endian = "big") { x } else { x.swap_bytes() }
+            }
+
+            /// Convert an integer from little endian to the target's endianness.
+            ///
+            /// On little endian this is a no-op. On big endian the bytes are swapped.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0x0123456789ABCDEFu64;
+            ///
+            /// if cfg!(target_endian = "little") {
+            ///     assert_eq!(Int::from_le(n), n)
+            /// } else {
+            ///     assert_eq!(Int::from_le(n), n.swap_bytes())
+            /// }
+            /// ```
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn from_le(x: $T) -> $T {
+                if cfg!(target_endian = "little") { x } else { x.swap_bytes() }
+            }
+
+            /// Convert `self` to big endian from the target's endianness.
+            ///
+            /// On big endian this is a no-op. On little endian the bytes are swapped.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0x0123456789ABCDEFu64;
+            ///
+            /// if cfg!(target_endian = "big") {
+            ///     assert_eq!(n.to_be(), n)
+            /// } else {
+            ///     assert_eq!(n.to_be(), n.swap_bytes())
+            /// }
+            /// ```
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn to_be(self) -> $T { // or not to be?
+                if cfg!(target_endian = "big") { self } else { self.swap_bytes() }
+            }
+
+            /// Convert `self` to little endian from the target's endianness.
+            ///
+            /// On little endian this is a no-op. On big endian the bytes are swapped.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0x0123456789ABCDEFu64;
+            ///
+            /// if cfg!(target_endian = "little") {
+            ///     assert_eq!(n.to_le(), n)
+            /// } else {
+            ///     assert_eq!(n.to_le(), n.swap_bytes())
+            /// }
+            /// ```
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn to_le(self) -> $T {
+                if cfg!(target_endian = "little") { self } else { self.swap_bytes() }
+            }
+
+            /// Checked integer addition. Computes `self + other`, returning `None` if
+            /// overflow occurred.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// assert_eq!(5u16.checked_add(65530), Some(65535));
+            /// assert_eq!(6u16.checked_add(65530), None);
+            /// ```
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn checked_add(self, other: $T) -> Option<$T> {
+                checked_op!($T, $ActualT, $add_with_overflow, self, other)
+            }
+
+            /// Checked integer subtraction. Computes `self - other`, returning `None`
+            /// if underflow occurred.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// assert_eq!((-127i8).checked_sub(1), Some(-128));
+            /// assert_eq!((-128i8).checked_sub(1), None);
+            /// ```
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn checked_sub(self, other: $T) -> Option<$T> {
+                checked_op!($T, $ActualT, $sub_with_overflow, self, other)
+            }
+
+            /// Checked integer multiplication. Computes `self * other`, returning
+            /// `None` if underflow or overflow occurred.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// assert_eq!(5u8.checked_mul(51), Some(255));
+            /// assert_eq!(5u8.checked_mul(52), None);
+            /// ```
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn checked_mul(self, other: $T) -> Option<$T> {
+                checked_op!($T, $ActualT, $mul_with_overflow, self, other)
+            }
+
+            /// Checked integer division. Computes `self / other`, returning `None` if
+            /// `other == 0` or the operation results in underflow or overflow.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// assert_eq!((-127i8).checked_div(-1), Some(127));
+            /// assert_eq!((-128i8).checked_div(-1), None);
+            /// assert_eq!((1i8).checked_div(0), None);
+            /// ```
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn checked_div(self, v: $T) -> Option<$T> {
+                match v {
+                    0   => None,
+                   -1 if self == <$T>::min_value()
+                        => None,
+                    v   => Some(self / v),
+                }
+            }
+
+            /// Saturating integer addition. Computes `self + other`, saturating at
+            /// the numeric bounds instead of overflowing.
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn saturating_add(self, other: $T) -> $T {
+                match self.checked_add(other) {
+                    Some(x)                       => x,
+                    None if other >= <$T>::zero() => <$T>::max_value(),
+                    None                          => <$T>::min_value(),
+                }
+            }
+
+            /// Saturating integer subtraction. Computes `self - other`, saturating at
+            /// the numeric bounds instead of overflowing.
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn saturating_sub(self, other: $T) -> $T {
+                match self.checked_sub(other) {
+                    Some(x)                      => x,
+                    None if other >= <$T>::zero() => <$T>::min_value(),
+                    None                          => <$T>::max_value(),
+                }
+            }
+
+            /// Raises self to the power of `exp`, using exponentiation by squaring.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// assert_eq!(2.pow(4), 16);
+            /// ```
+            #[unstable(feature = "core",
+                       reason = "pending integer conventions")]
+            #[inline]
+            pub fn pow(self, mut exp: u32) -> $T {
+                let mut base = self;
+                let mut acc = <$T>::one();
+
+                let mut prev_base = self;
+                let mut base_oflo = false;
+                while exp > 0 {
+                    if (exp & 1) == 1 {
+                        if base_oflo {
+                            // ensure overflow occurs in the same manner it
+                            // would have otherwise (i.e. signal any exception
+                            // it would have otherwise).
+                            acc = acc * (prev_base * prev_base);
+                        } else {
+                            acc = acc * base;
+                        }
+                    }
+                    prev_base = base;
+                    let (new_base, new_base_oflo) = base.overflowing_mul(base);
+                    base = new_base;
+                    base_oflo = new_base_oflo;
+                    exp /= 2;
+                }
+                acc
+            }
+
+            /// Computes the absolute value of `self`. `Int::min_value()` will be
+            /// returned if the number is `Int::min_value()`.
+            #[unstable(feature = "core", reason = "overflow in debug builds?")]
+            #[inline]
+            pub fn abs(self) -> $T {
+                if self.is_negative() { -self } else { self }
+            }
+
+            /// Returns a number representing sign of `self`.
+            ///
+            /// - `0` if the number is zero
+            /// - `1` if the number is positive
+            /// - `-1` if the number is negative
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn signum(self) -> $T {
+                match self {
+                    n if n > 0 =>  1,
+                    0          =>  0,
+                    _          => -1,
+                }
+            }
+
+            /// Returns `true` if `self` is positive and `false` if the number
+            /// is zero or negative.
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn is_positive(self) -> bool { self > 0 }
+
+            /// Returns `true` if `self` is negative and `false` if the number
+            /// is zero or positive.
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn is_negative(self) -> bool { self < 0 }
+        }
+    }
+
+    #[lang = "i8"]
+    impl i8 {
+        int_impl! { i8 = i8, u8, 8,
+            intrinsics::i8_add_with_overflow,
+            intrinsics::i8_sub_with_overflow,
+            intrinsics::i8_mul_with_overflow }
+    }
+
+    #[lang = "i16"]
+    impl i16 {
+        int_impl! { i16 = i16, u16, 16,
+            intrinsics::i16_add_with_overflow,
+            intrinsics::i16_sub_with_overflow,
+            intrinsics::i16_mul_with_overflow }
+    }
+
+    #[lang = "i32"]
+    impl i32 {
+        int_impl! { i32 = i32, u32, 32,
+            intrinsics::i32_add_with_overflow,
+            intrinsics::i32_sub_with_overflow,
+            intrinsics::i32_mul_with_overflow }
+    }
+
+    #[lang = "i64"]
+    impl i64 {
+        int_impl! { i64 = i64, u64, 64,
+            intrinsics::i64_add_with_overflow,
+            intrinsics::i64_sub_with_overflow,
+            intrinsics::i64_mul_with_overflow }
+    }
+
+    #[cfg(target_pointer_width = "32")]
+    #[lang = "isize"]
+    impl isize {
+        int_impl! { int = i32, u32, 32,
+            intrinsics::i32_add_with_overflow,
+            intrinsics::i32_sub_with_overflow,
+            intrinsics::i32_mul_with_overflow }
+    }
+
+    #[cfg(target_pointer_width = "64")]
+    #[lang = "isize"]
+    impl isize {
+        int_impl! { int = i64, u64, 64,
+            intrinsics::i64_add_with_overflow,
+            intrinsics::i64_sub_with_overflow,
+            intrinsics::i64_mul_with_overflow }
+    }
+
+    // `Int` + `UnsignedInt` implemented for signed integers
+    macro_rules! uint_impl {
+        ($T:ty = $ActualT:ty, $BITS:expr,
+         $ctpop:path,
+         $ctlz:path,
+         $cttz:path,
+         $bswap:path,
+         $add_with_overflow:path,
+         $sub_with_overflow:path,
+         $mul_with_overflow:path) => {
+            /// Returns the `0` value of this integer type.
+            // FIXME (#5527): Should be an associated constant
+            #[unstable(feature = "core",
+                       reason = "unsure about its place in the world")]
+            #[inline]
+            pub fn zero() -> $T { 0 }
+
+            /// Returns the `1` value of this integer type.
+            // FIXME (#5527): Should be an associated constant
+            #[unstable(feature = "core",
+                       reason = "unsure about its place in the world")]
+            #[inline]
+            pub fn one() -> $T { 1 }
+
+            /// Returns the smallest value that can be represented by this integer type.
+            // FIXME (#5527): Should be and associated constant
+            #[unstable(feature = "core",
+                       reason = "unsure about its place in the world")]
+            #[inline]
+            pub fn min_value() -> $T { 0 }
+
+            /// Returns the largest value that can be represented by this integer type.
+            // FIXME (#5527): Should be and associated constant
+            #[unstable(feature = "core",
+                       reason = "unsure about its place in the world")]
+            #[inline]
+            pub fn max_value() -> $T { -1 }
+
+            /// Returns the number of ones in the binary representation of `self`.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0b01001100u8;
+            ///
+            /// assert_eq!(n.count_ones(), 3);
+            /// ```
+            #[unstable(feature = "core",
+                       reason = "pending integer conventions")]
+            #[inline]
+            pub fn count_ones(self) -> u32 { unsafe { $ctpop(self as $ActualT) as u32 } }
+
+            /// Returns the number of zeros in the binary representation of `self`.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0b01001100u8;
+            ///
+            /// assert_eq!(n.count_zeros(), 5);
+            /// ```
+            #[unstable(feature = "core",
+                       reason = "pending integer conventions")]
+            #[inline]
+            pub fn count_zeros(self) -> u32 {
+                (!self).count_ones()
+            }
+
+            /// Returns the number of leading zeros in the binary representation
+            /// of `self`.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0b0101000u16;
+            ///
+            /// assert_eq!(n.leading_zeros(), 10);
+            /// ```
+            #[unstable(feature = "core",
+                       reason = "pending integer conventions")]
+            #[inline]
+            pub fn leading_zeros(self) -> u32 { unsafe { $ctlz(self as $ActualT) as u32 } }
+
+            /// Returns the number of trailing zeros in the binary representation
+            /// of `self`.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0b0101000u16;
+            ///
+            /// assert_eq!(n.trailing_zeros(), 3);
+            /// ```
+            #[unstable(feature = "core",
+                       reason = "pending integer conventions")]
+            #[inline]
+            pub fn trailing_zeros(self) -> u32 { unsafe { $cttz(self as $ActualT) as u32 } }
+
+            /// Shifts the bits to the left by a specified amount amount, `n`, wrapping
+            /// the truncated bits to the end of the resulting integer.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0x0123456789ABCDEFu64;
+            /// let m = 0x3456789ABCDEF012u64;
+            ///
+            /// assert_eq!(n.rotate_left(12), m);
+            /// ```
+            #[unstable(feature = "core",
+                       reason = "pending integer conventions")]
+            #[inline]
+            pub fn rotate_left(self, n: u32) -> $T {
+                // Protect against undefined behaviour for over-long bit shifts
+                let n = n % $BITS;
+                (self << n) | (self >> (($BITS - n) % $BITS))
+            }
+
+            /// Shifts the bits to the right by a specified amount amount, `n`, wrapping
+            /// the truncated bits to the beginning of the resulting integer.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0x0123456789ABCDEFu64;
+            /// let m = 0xDEF0123456789ABCu64;
+            ///
+            /// assert_eq!(n.rotate_right(12), m);
+            /// ```
+            #[unstable(feature = "core",
+                       reason = "pending integer conventions")]
+            #[inline]
+            pub fn rotate_right(self, n: u32) -> $T {
+                // Protect against undefined behaviour for over-long bit shifts
+                let n = n % $BITS;
+                (self >> n) | (self << (($BITS - n) % $BITS))
+            }
+
+            /// Reverses the byte order of the integer.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0x0123456789ABCDEFu64;
+            /// let m = 0xEFCDAB8967452301u64;
+            ///
+            /// assert_eq!(n.swap_bytes(), m);
+            /// ```
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn swap_bytes(self) -> $T { unsafe { $bswap(self as $ActualT) as $T } }
+
+            /// Convert an integer from big endian to the target's endianness.
+            ///
+            /// On big endian this is a no-op. On little endian the bytes are swapped.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0x0123456789ABCDEFu64;
+            ///
+            /// if cfg!(target_endian = "big") {
+            ///     assert_eq!(Int::from_be(n), n)
+            /// } else {
+            ///     assert_eq!(Int::from_be(n), n.swap_bytes())
+            /// }
+            /// ```
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn from_be(x: $T) -> $T {
+                if cfg!(target_endian = "big") { x } else { x.swap_bytes() }
+            }
+
+            /// Convert an integer from little endian to the target's endianness.
+            ///
+            /// On little endian this is a no-op. On big endian the bytes are swapped.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0x0123456789ABCDEFu64;
+            ///
+            /// if cfg!(target_endian = "little") {
+            ///     assert_eq!(Int::from_le(n), n)
+            /// } else {
+            ///     assert_eq!(Int::from_le(n), n.swap_bytes())
+            /// }
+            /// ```
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn from_le(x: $T) -> $T {
+                if cfg!(target_endian = "little") { x } else { x.swap_bytes() }
+            }
+
+            /// Convert `self` to big endian from the target's endianness.
+            ///
+            /// On big endian this is a no-op. On little endian the bytes are swapped.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0x0123456789ABCDEFu64;
+            ///
+            /// if cfg!(target_endian = "big") {
+            ///     assert_eq!(n.to_be(), n)
+            /// } else {
+            ///     assert_eq!(n.to_be(), n.swap_bytes())
+            /// }
+            /// ```
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn to_be(self) -> $T { // or not to be?
+                if cfg!(target_endian = "big") { self } else { self.swap_bytes() }
+            }
+
+            /// Convert `self` to little endian from the target's endianness.
+            ///
+            /// On little endian this is a no-op. On big endian the bytes are swapped.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// let n = 0x0123456789ABCDEFu64;
+            ///
+            /// if cfg!(target_endian = "little") {
+            ///     assert_eq!(n.to_le(), n)
+            /// } else {
+            ///     assert_eq!(n.to_le(), n.swap_bytes())
+            /// }
+            /// ```
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn to_le(self) -> $T {
+                if cfg!(target_endian = "little") { self } else { self.swap_bytes() }
+            }
+
+            /// Checked integer addition. Computes `self + other`, returning `None` if
+            /// overflow occurred.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// assert_eq!(5u16.checked_add(65530), Some(65535));
+            /// assert_eq!(6u16.checked_add(65530), None);
+            /// ```
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn checked_add(self, other: $T) -> Option<$T> {
+                checked_op!($T, $ActualT, $add_with_overflow, self, other)
+            }
+
+            /// Checked integer subtraction. Computes `self - other`, returning `None`
+            /// if underflow occurred.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// assert_eq!((-127i8).checked_sub(1), Some(-128));
+            /// assert_eq!((-128i8).checked_sub(1), None);
+            /// ```
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn checked_sub(self, other: $T) -> Option<$T> {
+                checked_op!($T, $ActualT, $sub_with_overflow, self, other)
+            }
+
+            /// Checked integer multiplication. Computes `self * other`, returning
+            /// `None` if underflow or overflow occurred.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// assert_eq!(5u8.checked_mul(51), Some(255));
+            /// assert_eq!(5u8.checked_mul(52), None);
+            /// ```
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn checked_mul(self, other: $T) -> Option<$T> {
+                checked_op!($T, $ActualT, $mul_with_overflow, self, other)
+            }
+
+            /// Checked integer division. Computes `self / other`, returning `None` if
+            /// `other == 0` or the operation results in underflow or overflow.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// assert_eq!((-127i8).checked_div(-1), Some(127));
+            /// assert_eq!((-128i8).checked_div(-1), None);
+            /// assert_eq!((1i8).checked_div(0), None);
+            /// ```
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn checked_div(self, v: $T) -> Option<$T> {
+                match v {
+                    0 => None,
+                    v => Some(self / v),
+                }
+            }
+
+            /// Saturating integer addition. Computes `self + other`, saturating at
+            /// the numeric bounds instead of overflowing.
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn saturating_add(self, other: $T) -> $T {
+                match self.checked_add(other) {
+                    Some(x)                       => x,
+                    None if other >= <$T>::zero() => <$T>::max_value(),
+                    None                          => <$T>::min_value(),
+                }
+            }
+
+            /// Saturating integer subtraction. Computes `self - other`, saturating at
+            /// the numeric bounds instead of overflowing.
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn saturating_sub(self, other: $T) -> $T {
+                match self.checked_sub(other) {
+                    Some(x)                       => x,
+                    None if other >= <$T>::zero() => <$T>::min_value(),
+                    None                          => <$T>::max_value(),
+                }
+            }
+
+            /// Raises self to the power of `exp`, using exponentiation by squaring.
+            ///
+            /// # Examples
+            ///
+            /// ```rust
+            /// use std::num::Int;
+            ///
+            /// assert_eq!(2.pow(4), 16);
+            /// ```
+            #[unstable(feature = "core",
+                       reason = "pending integer conventions")]
+            #[inline]
+            pub fn pow(self, mut exp: u32) -> $T {
+                let mut base = self;
+                let mut acc = <$T>::one();
+
+                let mut prev_base = self;
+                let mut base_oflo = false;
+                while exp > 0 {
+                    if (exp & 1) == 1 {
+                        if base_oflo {
+                            // ensure overflow occurs in the same manner it
+                            // would have otherwise (i.e. signal any exception
+                            // it would have otherwise).
+                            acc = acc * (prev_base * prev_base);
+                        } else {
+                            acc = acc * base;
+                        }
+                    }
+                    prev_base = base;
+                    let (new_base, new_base_oflo) = base.overflowing_mul(base);
+                    base = new_base;
+                    base_oflo = new_base_oflo;
+                    exp /= 2;
+                }
+                acc
+            }
+
+            /// Returns `true` iff `self == 2^k` for some `k`.
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn is_power_of_two(self) -> bool {
+                (self.wrapping_sub(<$T>::one())) & self == <$T>::zero() && !(self == <$T>::zero())
+            }
+
+            /// Returns the smallest power of two greater than or equal to `self`.
+            /// Unspecified behavior on overflow.
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[inline]
+            pub fn next_power_of_two(self) -> $T {
+                let bits = size_of::<$T>() * 8;
+                let one: $T = <$T>::one();
+                one << ((bits - self.wrapping_sub(one).leading_zeros() as usize) % bits)
+            }
+
+            /// Returns the smallest power of two greater than or equal to `n`. If the
+            /// next power of two is greater than the type's maximum value, `None` is
+            /// returned, otherwise the power of two is wrapped in `Some`.
+            #[stable(feature = "rust1", since = "1.0.0")]
+            pub fn checked_next_power_of_two(self) -> Option<$T> {
+                let npot = self.next_power_of_two();
+                if npot >= self {
+                    Some(npot)
+                } else {
+                    None
+                }
+            }
+        }
+    }
+
+    /// Swapping a single byte is a no-op. This is marked as `unsafe` for
+    /// consistency with the other `bswap` intrinsics.
+    unsafe fn bswap8(x: u8) -> u8 { x }
+
+    #[lang = "u8"]
+    impl u8 {
+        uint_impl! { u8 = u8, 8,
+            intrinsics::ctpop8,
+            intrinsics::ctlz8,
+            intrinsics::cttz8,
+            bswap8,
+            intrinsics::u8_add_with_overflow,
+            intrinsics::u8_sub_with_overflow,
+            intrinsics::u8_mul_with_overflow }
+    }
+
+    #[lang = "u16"]
+    impl u16 {
+        uint_impl! { u16 = u16, 16,
+            intrinsics::ctpop16,
+            intrinsics::ctlz16,
+            intrinsics::cttz16,
+            intrinsics::bswap16,
+            intrinsics::u16_add_with_overflow,
+            intrinsics::u16_sub_with_overflow,
+            intrinsics::u16_mul_with_overflow }
+    }
+
+    #[lang = "u32"]
+    impl u32 {
+        uint_impl! { u32 = u32, 32,
+            intrinsics::ctpop32,
+            intrinsics::ctlz32,
+            intrinsics::cttz32,
+            intrinsics::bswap32,
+            intrinsics::u32_add_with_overflow,
+            intrinsics::u32_sub_with_overflow,
+            intrinsics::u32_mul_with_overflow }
+    }
+
+
+    #[lang = "u64"]
+    impl u64 {
+        uint_impl! { u64 = u64, 64,
+            intrinsics::ctpop64,
+            intrinsics::ctlz64,
+            intrinsics::cttz64,
+            intrinsics::bswap64,
+            intrinsics::u64_add_with_overflow,
+            intrinsics::u64_sub_with_overflow,
+            intrinsics::u64_mul_with_overflow }
+    }
+
+    #[cfg(target_pointer_width = "32")]
+    #[lang = "usize"]
+    impl usize {
+        uint_impl! { uint = u32, 32,
+            intrinsics::ctpop32,
+            intrinsics::ctlz32,
+            intrinsics::cttz32,
+            intrinsics::bswap32,
+            intrinsics::u32_add_with_overflow,
+            intrinsics::u32_sub_with_overflow,
+            intrinsics::u32_mul_with_overflow }
+    }
+
+    #[cfg(target_pointer_width = "64")]
+    #[lang = "usize"]
+    impl usize {
+        uint_impl! { uint = u64, 64,
+            intrinsics::ctpop64,
+            intrinsics::ctlz64,
+            intrinsics::cttz64,
+            intrinsics::bswap64,
+            intrinsics::u64_add_with_overflow,
+            intrinsics::u64_sub_with_overflow,
+            intrinsics::u64_mul_with_overflow }
+    }
+}
+
 /// A generic trait for converting a value to a number.
 #[unstable(feature = "core", reason = "trait is likely to be removed")]
 pub trait ToPrimitive {
diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs
index 077b44f2dd2..6324e8fa874 100644
--- a/src/libcore/ops.rs
+++ b/src/libcore/ops.rs
@@ -78,7 +78,7 @@ use fmt;
 /// A trivial implementation of `Drop`. The `drop` method is called when `_x` goes
 /// out of scope, and therefore `main` prints `Dropping!`.
 ///
-/// ```rust
+/// ```
 /// struct HasDrop;
 ///
 /// impl Drop for HasDrop {
@@ -162,7 +162,7 @@ macro_rules! forward_ref_binop {
 /// A trivial implementation of `Add`. When `Foo + Foo` happens, it ends up
 /// calling `add`, and therefore, `main` prints `Adding!`.
 ///
-/// ```rust
+/// ```
 /// use std::ops::Add;
 ///
 /// #[derive(Copy)]
@@ -216,7 +216,7 @@ add_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
 /// A trivial implementation of `Sub`. When `Foo - Foo` happens, it ends up
 /// calling `sub`, and therefore, `main` prints `Subtracting!`.
 ///
-/// ```rust
+/// ```
 /// use std::ops::Sub;
 ///
 /// #[derive(Copy)]
@@ -270,7 +270,7 @@ sub_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
 /// A trivial implementation of `Mul`. When `Foo * Foo` happens, it ends up
 /// calling `mul`, and therefore, `main` prints `Multiplying!`.
 ///
-/// ```rust
+/// ```
 /// use std::ops::Mul;
 ///
 /// #[derive(Copy)]
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index 2dd8bf67220..455c68d4319 100644
--- a/src/libcore/option.rs
+++ b/src/libcore/option.rs
@@ -897,7 +897,7 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
     /// Here is an example which increments every integer in a vector,
     /// checking for overflow:
     ///
-    /// ```rust
+    /// ```
     /// use std::u16;
     ///
     /// let v = vec!(1, 2);
diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs
index 6c79233da68..fb793a62390 100644
--- a/src/libcore/prelude.rs
+++ b/src/libcore/prelude.rs
@@ -42,6 +42,7 @@ pub use iter::{Extend, IteratorExt};
 pub use iter::{Iterator, DoubleEndedIterator};
 pub use iter::{ExactSizeIterator};
 pub use option::Option::{self, Some, None};
+#[cfg(stage0)]
 pub use ptr::{PtrExt, MutPtrExt};
 pub use result::Result::{self, Ok, Err};
 pub use slice::{AsSlice, SliceExt};
diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs
index 32123a8271c..f28c26d1798 100644
--- a/src/libcore/ptr.rs
+++ b/src/libcore/ptr.rs
@@ -262,6 +262,7 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
     intrinsics::move_val_init(&mut *dst, src)
 }
 
+#[cfg(stage0)]
 /// Methods on raw pointers
 #[stable(feature = "rust1", since = "1.0.0")]
 pub trait PtrExt {
@@ -298,6 +299,7 @@ pub trait PtrExt {
     unsafe fn offset(self, count: isize) -> Self where Self::Target: Sized;
 }
 
+#[cfg(stage0)]
 /// Methods on mutable raw pointers
 #[stable(feature = "rust1", since = "1.0.0")]
 pub trait MutPtrExt {
@@ -317,6 +319,7 @@ pub trait MutPtrExt {
     unsafe fn as_mut<'a>(&self) -> Option<&'a mut Self::Target>;
 }
 
+#[cfg(stage0)]
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: ?Sized> PtrExt for *const T {
     type Target = T;
@@ -344,6 +347,7 @@ impl<T: ?Sized> PtrExt for *const T {
     }
 }
 
+#[cfg(stage0)]
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: ?Sized> PtrExt for *mut T {
     type Target = T;
@@ -371,6 +375,7 @@ impl<T: ?Sized> PtrExt for *mut T {
     }
 }
 
+#[cfg(stage0)]
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: ?Sized> MutPtrExt for *mut T {
     type Target = T;
@@ -388,6 +393,119 @@ impl<T: ?Sized> MutPtrExt for *mut T {
     }
 }
 
+#[cfg(not(stage0))]
+#[stable(feature = "rust1", since = "1.0.0")]
+#[lang = "const_ptr"]
+impl<T: ?Sized> *const T {
+    /// Returns true if the pointer is null.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn is_null(self) -> bool {
+        self == 0 as *const T
+    }
+
+    /// Returns `None` if the pointer is null, or else returns a reference to
+    /// the value wrapped in `Some`.
+    ///
+    /// # Safety
+    ///
+    /// While this method and its mutable counterpart are useful for
+    /// null-safety, it is important to note that this is still an unsafe
+    /// operation because the returned value could be pointing to invalid
+    /// memory.
+    #[unstable(feature = "core",
+               reason = "Option is not clearly the right return type, and we may want \
+                         to tie the return lifetime to a borrow of the raw pointer")]
+    #[inline]
+    pub unsafe fn as_ref<'a>(&self) -> Option<&'a T> {
+        if self.is_null() {
+            None
+        } else {
+            Some(&**self)
+        }
+    }
+
+    /// Calculates the offset from a pointer. `count` is in units of T; e.g. a
+    /// `count` of 3 represents a pointer offset of `3 * sizeof::<T>()` bytes.
+    ///
+    /// # Safety
+    ///
+    /// The offset must be in-bounds of the object, or one-byte-past-the-end.
+    /// Otherwise `offset` invokes Undefined Behaviour, regardless of whether
+    /// the pointer is used.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub unsafe fn offset(self, count: isize) -> *const T where T: Sized {
+        intrinsics::offset(self, count)
+    }
+}
+
+#[cfg(not(stage0))]
+#[stable(feature = "rust1", since = "1.0.0")]
+#[lang = "mut_ptr"]
+impl<T: ?Sized> *mut T {
+    /// Returns true if the pointer is null.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn is_null(self) -> bool {
+        self == 0 as *mut T
+    }
+
+    /// Returns `None` if the pointer is null, or else returns a reference to
+    /// the value wrapped in `Some`.
+    ///
+    /// # Safety
+    ///
+    /// While this method and its mutable counterpart are useful for
+    /// null-safety, it is important to note that this is still an unsafe
+    /// operation because the returned value could be pointing to invalid
+    /// memory.
+    #[unstable(feature = "core",
+               reason = "Option is not clearly the right return type, and we may want \
+                         to tie the return lifetime to a borrow of the raw pointer")]
+    #[inline]
+    pub unsafe fn as_ref<'a>(&self) -> Option<&'a T> {
+        if self.is_null() {
+            None
+        } else {
+            Some(&**self)
+        }
+    }
+
+    /// Calculates the offset from a pointer. `count` is in units of T; e.g. a
+    /// `count` of 3 represents a pointer offset of `3 * sizeof::<T>()` bytes.
+    ///
+    /// # Safety
+    ///
+    /// The offset must be in-bounds of the object, or one-byte-past-the-end.
+    /// Otherwise `offset` invokes Undefined Behaviour, regardless of whether
+    /// the pointer is used.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub unsafe fn offset(self, count: isize) -> *mut T where T: Sized {
+        intrinsics::offset(self, count) as *mut T
+    }
+
+    /// Returns `None` if the pointer is null, or else returns a mutable
+    /// reference to the value wrapped in `Some`.
+    ///
+    /// # Safety
+    ///
+    /// As with `as_ref`, this is unsafe because it cannot verify the validity
+    /// of the returned pointer.
+    #[unstable(feature = "core",
+               reason = "return value does not necessarily convey all possible \
+                         information")]
+    #[inline]
+    pub unsafe fn as_mut<'a>(&self) -> Option<&'a mut T> {
+        if self.is_null() {
+            None
+        } else {
+            Some(&mut **self)
+        }
+    }
+}
+
 // Equality for pointers
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: ?Sized> PartialEq for *const T {
diff --git a/src/libcore/result.rs b/src/libcore/result.rs
index 9fba9a4d8ec..fee8caa04c4 100644
--- a/src/libcore/result.rs
+++ b/src/libcore/result.rs
@@ -896,7 +896,7 @@ impl<A, E, V: FromIterator<A>> FromIterator<Result<A, E>> for Result<V, E> {
     /// Here is an example which increments every integer in a vector,
     /// checking for overflow:
     ///
-    /// ```rust
+    /// ```
     /// use std::u32;
     ///
     /// let v = vec!(1, 2);
diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs
index 62cffa9b86e..b1576c0d377 100644
--- a/src/libcore/slice.rs
+++ b/src/libcore/slice.rs
@@ -49,6 +49,7 @@ use option::Option::{None, Some};
 use result::Result;
 use result::Result::{Ok, Err};
 use ptr;
+#[cfg(stage0)]
 use ptr::PtrExt;
 use mem;
 use mem::size_of;
@@ -1448,7 +1449,7 @@ pub fn mut_ref_slice<'a, A>(s: &'a mut A) -> &'a mut [A] {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::slice;
 ///
 /// // manifest a slice out of thin air!
@@ -1491,7 +1492,7 @@ pub unsafe fn from_raw_parts_mut<'a, T>(p: *mut T, len: usize) -> &'a mut [T] {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::slice;
 ///
 /// // manifest a slice out of thin air!
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs
index 6f72890d96f..bd46b093b76 100644
--- a/src/libcore/str/mod.rs
+++ b/src/libcore/str/mod.rs
@@ -30,6 +30,7 @@ use mem;
 use num::Int;
 use ops::{Fn, FnMut};
 use option::Option::{self, None, Some};
+#[cfg(stage0)]
 use ptr::PtrExt;
 use raw::{Repr, Slice};
 use result::Result::{self, Ok, Err};
@@ -139,7 +140,7 @@ impl FromStr for bool {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::str::FromStr;
     ///
     /// assert_eq!(FromStr::from_str("true"), Ok(true));
@@ -150,7 +151,7 @@ impl FromStr for bool {
     /// Note, in many cases, the StrExt::parse() which is based on
     /// this FromStr::from_str() is more proper.
     ///
-    /// ```rust
+    /// ```
     /// assert_eq!("true".parse(), Ok(true));
     /// assert_eq!("false".parse(), Ok(false));
     /// assert!("not even a boolean".parse::<bool>().is_err());
@@ -1185,7 +1186,7 @@ mod traits {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// let s = "Löwe 老虎 Léopard";
     /// assert_eq!(&s[0 .. 1], "L");
     ///
diff --git a/src/libcoretest/intrinsics.rs b/src/libcoretest/intrinsics.rs
index b836f5f3f69..c99fb8c197d 100644
--- a/src/libcoretest/intrinsics.rs
+++ b/src/libcoretest/intrinsics.rs
@@ -28,4 +28,3 @@ fn test_typeid_unsized_types() {
     assert_eq!(TypeId::of::<Y>(), TypeId::of::<Y>());
     assert!(TypeId::of::<X>() != TypeId::of::<Y>());
 }
-
diff --git a/src/libflate/lib.rs b/src/libflate/lib.rs
index 100a9e36e86..695c71c73ed 100644
--- a/src/libflate/lib.rs
+++ b/src/libflate/lib.rs
@@ -25,7 +25,6 @@
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/nightly/")]
 
-#![feature(int_uint)]
 #![feature(libc)]
 #![feature(staged_api)]
 #![feature(unique)]
@@ -35,13 +34,33 @@
 extern crate libc;
 
 use libc::{c_void, size_t, c_int};
+use std::fmt;
 use std::ops::Deref;
 use std::ptr::Unique;
 use std::slice;
 
+#[derive(Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
+pub struct Error {
+    _unused: (),
+}
+
+impl Error {
+    fn new() -> Error {
+        Error {
+            _unused: (),
+        }
+    }
+}
+
+impl fmt::Debug for Error {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        "decompression error".fmt(f)
+    }
+}
+
 pub struct Bytes {
     ptr: Unique<u8>,
-    len: uint,
+    len: usize,
 }
 
 impl Deref for Bytes {
@@ -78,55 +97,56 @@ const LZ_NORM: c_int = 0x80;  // LZ with 128 probes, "normal"
 const TINFL_FLAG_PARSE_ZLIB_HEADER: c_int = 0x1; // parse zlib header and adler32 checksum
 const TDEFL_WRITE_ZLIB_HEADER: c_int = 0x01000; // write zlib header and adler32 checksum
 
-fn deflate_bytes_internal(bytes: &[u8], flags: c_int) -> Option<Bytes> {
+fn deflate_bytes_internal(bytes: &[u8], flags: c_int) -> Bytes {
     unsafe {
-        let mut outsz : size_t = 0;
+        let mut outsz: size_t = 0;
         let res = tdefl_compress_mem_to_heap(bytes.as_ptr() as *const _,
                                              bytes.len() as size_t,
                                              &mut outsz,
                                              flags);
-        if !res.is_null() {
-            let res = Unique::new(res as *mut u8);
-            Some(Bytes { ptr: res, len: outsz as uint })
-        } else {
-            None
+        assert!(!res.is_null());
+        Bytes {
+            ptr: Unique::new(res as *mut u8),
+            len: outsz as usize,
         }
     }
 }
 
 /// Compress a buffer, without writing any sort of header on the output.
-pub fn deflate_bytes(bytes: &[u8]) -> Option<Bytes> {
+pub fn deflate_bytes(bytes: &[u8]) -> Bytes {
     deflate_bytes_internal(bytes, LZ_NORM)
 }
 
 /// Compress a buffer, using a header that zlib can understand.
-pub fn deflate_bytes_zlib(bytes: &[u8]) -> Option<Bytes> {
+pub fn deflate_bytes_zlib(bytes: &[u8]) -> Bytes {
     deflate_bytes_internal(bytes, LZ_NORM | TDEFL_WRITE_ZLIB_HEADER)
 }
 
-fn inflate_bytes_internal(bytes: &[u8], flags: c_int) -> Option<Bytes> {
+fn inflate_bytes_internal(bytes: &[u8], flags: c_int) -> Result<Bytes,Error> {
     unsafe {
-        let mut outsz : size_t = 0;
+        let mut outsz: size_t = 0;
         let res = tinfl_decompress_mem_to_heap(bytes.as_ptr() as *const _,
                                                bytes.len() as size_t,
                                                &mut outsz,
                                                flags);
         if !res.is_null() {
-            let res = Unique::new(res as *mut u8);
-            Some(Bytes { ptr: res, len: outsz as uint })
+            Ok(Bytes {
+                ptr: Unique::new(res as *mut u8),
+                len: outsz as usize,
+            })
         } else {
-            None
+            Err(Error::new())
         }
     }
 }
 
 /// Decompress a buffer, without parsing any sort of header on the input.
-pub fn inflate_bytes(bytes: &[u8]) -> Option<Bytes> {
+pub fn inflate_bytes(bytes: &[u8]) -> Result<Bytes,Error> {
     inflate_bytes_internal(bytes, 0)
 }
 
 /// Decompress a buffer that starts with a zlib header.
-pub fn inflate_bytes_zlib(bytes: &[u8]) -> Option<Bytes> {
+pub fn inflate_bytes_zlib(bytes: &[u8]) -> Result<Bytes,Error> {
     inflate_bytes_internal(bytes, TINFL_FLAG_PARSE_ZLIB_HEADER)
 }
 
@@ -140,7 +160,7 @@ mod tests {
     #[test]
     fn test_flate_round_trip() {
         let mut r = rand::thread_rng();
-        let mut words = vec!();
+        let mut words = vec![];
         for _ in 0..20 {
             let range = r.gen_range(1, 10);
             let v = r.gen_iter::<u8>().take(range).collect::<Vec<u8>>();
@@ -153,8 +173,8 @@ mod tests {
             }
             debug!("de/inflate of {} bytes of random word-sequences",
                    input.len());
-            let cmp = deflate_bytes(&input).expect("deflation failed");
-            let out = inflate_bytes(&cmp).expect("inflation failed");
+            let cmp = deflate_bytes(&input);
+            let out = inflate_bytes(&cmp).unwrap();
             debug!("{} bytes deflated to {} ({:.1}% size)",
                    input.len(), cmp.len(),
                    100.0 * ((cmp.len() as f64) / (input.len() as f64)));
@@ -164,9 +184,9 @@ mod tests {
 
     #[test]
     fn test_zlib_flate() {
-        let bytes = vec!(1, 2, 3, 4, 5);
-        let deflated = deflate_bytes(&bytes).expect("deflation failed");
-        let inflated = inflate_bytes(&deflated).expect("inflation failed");
+        let bytes = vec![1, 2, 3, 4, 5];
+        let deflated = deflate_bytes(&bytes);
+        let inflated = inflate_bytes(&deflated).unwrap();
         assert_eq!(&*inflated, &*bytes);
     }
 }
diff --git a/src/liblibc/lib.rs b/src/liblibc/lib.rs
index 11aba40afad..82c54004e99 100644
--- a/src/liblibc/lib.rs
+++ b/src/liblibc/lib.rs
@@ -3298,7 +3298,7 @@ pub mod consts {
             pub const MAP_DENYWRITE : c_int = 0x0800;
             pub const MAP_EXECUTABLE : c_int = 0x01000;
             pub const MAP_LOCKED : c_int = 0x02000;
-            pub const MAP_NONRESERVE : c_int = 0x04000;
+            pub const MAP_NORESERVE : c_int = 0x04000;
             pub const MAP_POPULATE : c_int = 0x08000;
             pub const MAP_NONBLOCK : c_int = 0x010000;
             pub const MAP_STACK : c_int = 0x020000;
@@ -3325,7 +3325,7 @@ pub mod consts {
             pub const MAP_DENYWRITE : c_int = 0x02000;
             pub const MAP_EXECUTABLE : c_int = 0x04000;
             pub const MAP_LOCKED : c_int = 0x08000;
-            pub const MAP_NONRESERVE : c_int = 0x0400;
+            pub const MAP_NORESERVE : c_int = 0x0400;
             pub const MAP_POPULATE : c_int = 0x010000;
             pub const MAP_NONBLOCK : c_int = 0x020000;
             pub const MAP_STACK : c_int = 0x040000;
diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs
index b03d77db4ec..c634a46888e 100644
--- a/src/liblog/lib.rs
+++ b/src/liblog/lib.rs
@@ -175,7 +175,6 @@
 #![feature(int_uint)]
 #![feature(core)]
 #![feature(std_misc)]
-#![feature(io)]
 
 use std::boxed;
 use std::cell::RefCell;
diff --git a/src/liblog/macros.rs b/src/liblog/macros.rs
index 1aee6e0be2e..80eb1601035 100644
--- a/src/liblog/macros.rs
+++ b/src/liblog/macros.rs
@@ -197,4 +197,3 @@ macro_rules! log_enabled {
         ::log::mod_enabled(lvl, module_path!())
     })
 }
-
diff --git a/src/librand/distributions/exponential.rs b/src/librand/distributions/exponential.rs
index 6820d9c5c48..3180f03cfd3 100644
--- a/src/librand/distributions/exponential.rs
+++ b/src/librand/distributions/exponential.rs
@@ -59,7 +59,7 @@ impl Rand for Exp1 {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::rand;
 /// use std::rand::distributions::{Exp, IndependentSample};
 ///
diff --git a/src/librand/distributions/gamma.rs b/src/librand/distributions/gamma.rs
index 6659bf0f3ee..8eaac203fb4 100644
--- a/src/librand/distributions/gamma.rs
+++ b/src/librand/distributions/gamma.rs
@@ -39,7 +39,7 @@ use super::{IndependentSample, Sample, Exp};
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::rand;
 /// use std::rand::distributions::{IndependentSample, Gamma};
 ///
@@ -186,7 +186,7 @@ impl IndependentSample<f64> for GammaLargeShape {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::rand;
 /// use std::rand::distributions::{ChiSquared, IndependentSample};
 ///
@@ -243,7 +243,7 @@ impl IndependentSample<f64> for ChiSquared {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::rand;
 /// use std::rand::distributions::{FisherF, IndependentSample};
 ///
@@ -287,7 +287,7 @@ impl IndependentSample<f64> for FisherF {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::rand;
 /// use std::rand::distributions::{StudentT, IndependentSample};
 ///
diff --git a/src/librand/distributions/mod.rs b/src/librand/distributions/mod.rs
index 79b176a4ffd..a46709932e2 100644
--- a/src/librand/distributions/mod.rs
+++ b/src/librand/distributions/mod.rs
@@ -93,7 +93,7 @@ pub struct Weighted<T> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::rand;
 /// use std::rand::distributions::{Weighted, WeightedChoice, IndependentSample};
 ///
@@ -123,7 +123,7 @@ impl<'a, T: Clone> WeightedChoice<'a, T> {
         // strictly speaking, this is subsumed by the total weight == 0 case
         assert!(!items.is_empty(), "WeightedChoice::new called with no items");
 
-        let mut running_total = 0;
+        let mut running_total = 0_usize;
 
         // we convert the list from individual weights to cumulative
         // weights so we can binary search. This *could* drop elements
diff --git a/src/librand/distributions/normal.rs b/src/librand/distributions/normal.rs
index aeca477fb94..d07964624bf 100644
--- a/src/librand/distributions/normal.rs
+++ b/src/librand/distributions/normal.rs
@@ -75,7 +75,7 @@ impl Rand for StandardNormal {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::rand;
 /// use std::rand::distributions::{Normal, IndependentSample};
 ///
@@ -123,7 +123,7 @@ impl IndependentSample<f64> for Normal {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::rand;
 /// use std::rand::distributions::{LogNormal, IndependentSample};
 ///
diff --git a/src/librand/distributions/range.rs b/src/librand/distributions/range.rs
index 9a2576a87fc..4086e149e78 100644
--- a/src/librand/distributions/range.rs
+++ b/src/librand/distributions/range.rs
@@ -35,7 +35,7 @@ use distributions::{Sample, IndependentSample};
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::rand::distributions::{IndependentSample, Range};
 ///
 /// fn main() {
diff --git a/src/librand/lib.rs b/src/librand/lib.rs
index c5ff8ffe457..5e52a176c9e 100644
--- a/src/librand/lib.rs
+++ b/src/librand/lib.rs
@@ -148,7 +148,7 @@ pub trait Rng : Sized {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::rand::{thread_rng, Rng};
     ///
     /// let mut v = [0; 13579];
@@ -183,7 +183,7 @@ pub trait Rng : Sized {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::rand::{thread_rng, Rng};
     ///
     /// let mut rng = thread_rng();
@@ -228,7 +228,7 @@ pub trait Rng : Sized {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::rand::{thread_rng, Rng};
     ///
     /// let mut rng = thread_rng();
@@ -246,7 +246,7 @@ pub trait Rng : Sized {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::rand::{thread_rng, Rng};
     ///
     /// let mut rng = thread_rng();
@@ -260,7 +260,7 @@ pub trait Rng : Sized {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::rand::{thread_rng, Rng};
     ///
     /// let s: String = thread_rng().gen_ascii_chars().take(10).collect();
@@ -296,7 +296,7 @@ pub trait Rng : Sized {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::rand::{thread_rng, Rng};
     ///
     /// let mut rng = thread_rng();
@@ -359,7 +359,7 @@ pub trait SeedableRng<Seed>: Rng {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::rand::{Rng, SeedableRng, StdRng};
     ///
     /// let seed: &[_] = &[1, 2, 3, 4];
@@ -374,7 +374,7 @@ pub trait SeedableRng<Seed>: Rng {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::rand::{Rng, SeedableRng, StdRng};
     ///
     /// let seed: &[_] = &[1, 2, 3, 4];
@@ -478,7 +478,8 @@ impl Rand for XorShiftRng {
 /// `[0,1)`.
 ///
 /// # Examples
-/// ```rust
+///
+/// ```
 /// use std::rand::{random, Open01};
 ///
 /// let Open01(val) = random::<Open01<f32>>();
@@ -495,7 +496,7 @@ pub struct Open01<F>(pub F);
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::rand::{random, Closed01};
 ///
 /// let Closed01(val) = random::<Closed01<f32>>();
diff --git a/src/librand/reseeding.rs b/src/librand/reseeding.rs
index f39021d4a5f..81e65da37fc 100644
--- a/src/librand/reseeding.rs
+++ b/src/librand/reseeding.rs
@@ -102,7 +102,7 @@ impl<S, R: SeedableRng<S>, Rsdr: Reseeder<R> + Default>
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::rand::{Rng, SeedableRng, StdRng};
 /// use std::rand::reseeding::{Reseeder, ReseedingRng};
 ///
diff --git a/src/librustc/README.txt b/src/librustc/README.txt
index 37097764f71..9b364768208 100644
--- a/src/librustc/README.txt
+++ b/src/librustc/README.txt
@@ -40,7 +40,7 @@ crates is preferable):
   driver that orchestrates all the other passes and various other bits
   of miscellany. In general it contains code that runs towards the
   end of the compilation process.
-  
+
 Roughly speaking the "order" of the three crates is as follows:
 
     libsyntax -> librustc -> librustc_trans
diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs
index 133bef30e40..70303bb3410 100644
--- a/src/librustc/diagnostics.rs
+++ b/src/librustc/diagnostics.rs
@@ -132,4 +132,3 @@ register_diagnostics! {
 }
 
 __build_diagnostic_array! { DIAGNOSTICS }
-
diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs
index 8486bf782b0..e466dc8a3a0 100644
--- a/src/librustc/metadata/loader.rs
+++ b/src/librustc/metadata/loader.rs
@@ -784,8 +784,8 @@ fn get_metadata_section_imp(is_osx: bool, filename: &Path) -> Result<MetadataBlo
                        csz - vlen);
                 let bytes = slice::from_raw_parts(cvbuf1, csz - vlen);
                 match flate::inflate_bytes(bytes) {
-                    Some(inflated) => return Ok(MetadataVec(inflated)),
-                    None => {}
+                    Ok(inflated) => return Ok(MetadataVec(inflated)),
+                    Err(_) => {}
                 }
             }
             llvm::LLVMMoveToNextSection(si.llsi);
diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs
index b33839f33e8..d1a946d933f 100644
--- a/src/librustc/metadata/tydecode.rs
+++ b/src/librustc/metadata/tydecode.rs
@@ -963,4 +963,3 @@ fn parse_region_bounds_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F)
         }
     }
 }
-
diff --git a/src/librustc/middle/cfg/graphviz.rs b/src/librustc/middle/cfg/graphviz.rs
index 0c5eca3c129..ac6524dad80 100644
--- a/src/librustc/middle/cfg/graphviz.rs
+++ b/src/librustc/middle/cfg/graphviz.rs
@@ -124,4 +124,3 @@ impl<'a, 'ast> dot::GraphWalk<'a, Node<'a>, Edge<'a>> for LabelledCFG<'a, 'ast>
     fn source(&'a self, edge: &Edge<'a>) -> Node<'a> { self.cfg.source(edge) }
     fn target(&'a self, edge: &Edge<'a>) -> Node<'a> { self.cfg.target(edge) }
 }
-
diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs
index 6c140d73be0..313f034021f 100644
--- a/src/librustc/middle/check_match.rs
+++ b/src/librustc/middle/check_match.rs
@@ -27,6 +27,7 @@ use middle::ty;
 use std::cmp::Ordering;
 use std::fmt;
 use std::iter::{range_inclusive, AdditiveIterator, FromIterator, IntoIterator, repeat};
+#[cfg(stage0)]
 use std::num::Float;
 use std::slice;
 use syntax::ast::{self, DUMMY_NODE_ID, NodeId, Pat};
diff --git a/src/librustc/middle/fast_reject.rs b/src/librustc/middle/fast_reject.rs
index 063845c6c34..f9bdc5dc313 100644
--- a/src/librustc/middle/fast_reject.rs
+++ b/src/librustc/middle/fast_reject.rs
@@ -96,4 +96,3 @@ pub fn simplify_type(tcx: &ty::ctxt,
         ty::ty_infer(_) | ty::ty_err => None,
     }
 }
-
diff --git a/src/librustc/middle/infer/resolve.rs b/src/librustc/middle/infer/resolve.rs
index 547696c0c4c..b9025d01068 100644
--- a/src/librustc/middle/infer/resolve.rs
+++ b/src/librustc/middle/infer/resolve.rs
@@ -112,4 +112,3 @@ impl<'a, 'tcx> ty_fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
         }
     }
 }
-
diff --git a/src/librustc/middle/infer/sub.rs b/src/librustc/middle/infer/sub.rs
index 5a141d52f62..8ab063686d4 100644
--- a/src/librustc/middle/infer/sub.rs
+++ b/src/librustc/middle/infer/sub.rs
@@ -138,4 +138,3 @@ impl<'f, 'tcx> Combine<'tcx> for Sub<'f, 'tcx> {
         self.higher_ranked_sub(a, b)
     }
 }
-
diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs
index 3525d46a1f2..1ad4611dc9e 100644
--- a/src/librustc/middle/lang_items.rs
+++ b/src/librustc/middle/lang_items.rs
@@ -239,6 +239,24 @@ pub fn collect_language_items(krate: &ast::Crate,
 
 lets_do_this! {
 //  Variant name,                    Name,                      Method name;
+    CharImplItem,                    "char",                    char_impl;
+    StrImplItem,                     "str",                     str_impl;
+    SliceImplItem,                   "slice",                   slice_impl;
+    ConstPtrImplItem,                "const_ptr",               const_ptr_impl;
+    MutPtrImplItem,                  "mut_ptr",                 mut_ptr_impl;
+    I8ImplItem,                      "i8",                      i8_impl;
+    I16ImplItem,                     "i16",                     i16_impl;
+    I32ImplItem,                     "i32",                     i32_impl;
+    I64ImplItem,                     "i64",                     i64_impl;
+    IsizeImplItem,                   "isize",                   isize_impl;
+    U8ImplItem,                      "u8",                      u8_impl;
+    U16ImplItem,                     "u16",                     u16_impl;
+    U32ImplItem,                     "u32",                     u32_impl;
+    U64ImplItem,                     "u64",                     u64_impl;
+    UsizeImplItem,                   "usize",                   usize_impl;
+    F32ImplItem,                     "f32",                     f32_impl;
+    F64ImplItem,                     "f64",                     f64_impl;
+
     SendTraitLangItem,               "send",                    send_trait;
     SizedTraitLangItem,              "sized",                   sized_trait;
     CopyTraitLangItem,               "copy",                    copy_trait;
diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs
index 1f02f13a4a1..a57ea3759de 100644
--- a/src/librustc/middle/mem_categorization.rs
+++ b/src/librustc/middle/mem_categorization.rs
@@ -1635,4 +1635,3 @@ impl<'tcx> UserString<'tcx> for Upvar {
         format!("captured outer variable in an `{}` closure", kind)
     }
 }
-
diff --git a/src/librustc/middle/traits/project.rs b/src/librustc/middle/traits/project.rs
index b9a863f4fe4..6b66d7227d3 100644
--- a/src/librustc/middle/traits/project.rs
+++ b/src/librustc/middle/traits/project.rs
@@ -535,7 +535,7 @@ fn assemble_candidates_from_param_env<'cx,'tcx>(
 /// In the case of a nested projection like <<A as Foo>::FooT as Bar>::BarT, we may find
 /// that the definition of `Foo` has some clues:
 ///
-/// ```rust
+/// ```
 /// trait Foo {
 ///     type FooT : Bar<BarT=i32>
 /// }
diff --git a/src/librustc/middle/traits/util.rs b/src/librustc/middle/traits/util.rs
index 4527985302a..88b721ce958 100644
--- a/src/librustc/middle/traits/util.rs
+++ b/src/librustc/middle/traits/util.rs
@@ -568,5 +568,3 @@ impl<'tcx> fmt::Debug for super::MismatchedProjectionTypes<'tcx> {
         write!(f, "MismatchedProjectionTypes(..)")
     }
 }
-
-
diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs
index 90a488f1b86..8cc188e5df5 100644
--- a/src/librustc/middle/ty.rs
+++ b/src/librustc/middle/ty.rs
@@ -789,6 +789,9 @@ pub struct ctxt<'tcx> {
     /// is used for lazy resolution of traits.
     pub populated_external_traits: RefCell<DefIdSet>,
 
+    /// The set of external primitive inherent implementations that have been read.
+    pub populated_external_primitive_impls: RefCell<DefIdSet>,
+
     /// Borrows
     pub upvar_capture_map: RefCell<UpvarCaptureMap>,
 
@@ -2600,6 +2603,7 @@ pub fn mk_ctxt<'tcx>(s: Session,
         used_mut_nodes: RefCell::new(NodeSet()),
         populated_external_types: RefCell::new(DefIdSet()),
         populated_external_traits: RefCell::new(DefIdSet()),
+        populated_external_primitive_impls: RefCell::new(DefIdSet()),
         upvar_capture_map: RefCell::new(FnvHashMap()),
         extern_const_statics: RefCell::new(DefIdMap()),
         extern_const_variants: RefCell::new(DefIdMap()),
@@ -5992,6 +5996,25 @@ pub fn record_trait_implementation(tcx: &ctxt,
     tcx.trait_impls.borrow_mut().insert(trait_def_id, Rc::new(RefCell::new(vec!(impl_def_id))));
 }
 
+/// Load primitive inherent implementations if necessary
+pub fn populate_implementations_for_primitive_if_necessary(tcx: &ctxt, lang_def_id: ast::DefId) {
+    if lang_def_id.krate == LOCAL_CRATE {
+        return
+    }
+    if tcx.populated_external_primitive_impls.borrow().contains(&lang_def_id) {
+        return
+    }
+
+    debug!("populate_implementations_for_primitive_if_necessary: searching for {:?}", lang_def_id);
+
+    let impl_items = csearch::get_impl_items(&tcx.sess.cstore, lang_def_id);
+
+    // Store the implementation info.
+    tcx.impl_items.borrow_mut().insert(lang_def_id, impl_items);
+
+    tcx.populated_external_primitive_impls.borrow_mut().insert(lang_def_id);
+}
+
 /// Populates the type context with all the implementations for the given type
 /// if necessary.
 pub fn populate_implementations_for_type_if_necessary(tcx: &ctxt,
diff --git a/src/librustc/middle/ty_walk.rs b/src/librustc/middle/ty_walk.rs
index 5b5eac45178..1069d1282ea 100644
--- a/src/librustc/middle/ty_walk.rs
+++ b/src/librustc/middle/ty_walk.rs
@@ -82,7 +82,7 @@ impl<'tcx> TypeWalker<'tcx> {
     ///
     /// Example: Imagine you are walking `Foo<Bar<int>, uint>`.
     ///
-    /// ```rust
+    /// ```
     /// let mut iter: TypeWalker = ...;
     /// iter.next(); // yields Foo
     /// iter.next(); // yields Bar<int>
diff --git a/src/librustc_back/archive.rs b/src/librustc_back/archive.rs
index ed44bf89529..aec8ac38a5a 100644
--- a/src/librustc_back/archive.rs
+++ b/src/librustc_back/archive.rs
@@ -324,4 +324,3 @@ impl<'a> ArchiveBuilder<'a> {
         Ok(())
     }
 }
-
diff --git a/src/librustc_back/target/dragonfly_base.rs b/src/librustc_back/target/dragonfly_base.rs
index 79d79b7e736..a56621ff97e 100644
--- a/src/librustc_back/target/dragonfly_base.rs
+++ b/src/librustc_back/target/dragonfly_base.rs
@@ -32,4 +32,3 @@ pub fn opts() -> TargetOptions {
         .. Default::default()
     }
 }
-
diff --git a/src/librustc_back/target/freebsd_base.rs b/src/librustc_back/target/freebsd_base.rs
index ab8398fc605..dcf1a12f2c9 100644
--- a/src/librustc_back/target/freebsd_base.rs
+++ b/src/librustc_back/target/freebsd_base.rs
@@ -27,4 +27,3 @@ pub fn opts() -> TargetOptions {
         .. Default::default()
     }
 }
-
diff --git a/src/librustc_back/target/openbsd_base.rs b/src/librustc_back/target/openbsd_base.rs
index 759147b939c..0f2ab32be24 100644
--- a/src/librustc_back/target/openbsd_base.rs
+++ b/src/librustc_back/target/openbsd_base.rs
@@ -30,4 +30,3 @@ pub fn opts() -> TargetOptions {
         .. Default::default()
     }
 }
-
diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs
index 1cbbcad9550..e62300098f6 100644
--- a/src/librustc_resolve/build_reduced_graph.rs
+++ b/src/librustc_resolve/build_reduced_graph.rs
@@ -14,16 +14,17 @@
 //! any imports resolved.
 
 use {DefModifiers, PUBLIC, IMPORTABLE};
-use ImportDirective;
-use ImportDirectiveSubclass::{self, SingleImport, GlobImport};
-use ImportResolution;
+use resolve_imports::ImportDirective;
+use resolve_imports::ImportDirectiveSubclass::{self, SingleImport, GlobImport};
+use resolve_imports::ImportResolution;
 use Module;
 use ModuleKind::*;
 use Namespace::{TypeNS, ValueNS};
 use NameBindings;
+use {names_to_string, module_to_string};
 use ParentLink::{self, ModuleParentLink, BlockParentLink};
 use Resolver;
-use Shadowable;
+use resolve_imports::Shadowable;
 use TypeNsDef;
 
 use self::DuplicateCheckingMode::*;
@@ -371,8 +372,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
 
             ItemExternCrate(_) => {
                 // n.b. we don't need to look at the path option here, because cstore already did
-                for &crate_id in self.session.cstore
-                                     .find_extern_mod_stmt_cnum(item.id).iter() {
+                if let Some(crate_id) = self.session.cstore.find_extern_mod_stmt_cnum(item.id) {
                     let def_id = DefId { krate: crate_id, node: 0 };
                     self.external_exports.insert(def_id);
                     let parent_link = ModuleParentLink(parent.downgrade(), name);
@@ -382,7 +382,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
                                                               false,
                                                               true));
                     debug!("(build reduced graph for item) found extern `{}`",
-                            self.module_to_string(&*external_module));
+                            module_to_string(&*external_module));
                     self.check_for_conflicts_between_external_crates(&**parent, name, sp);
                     parent.external_module_children.borrow_mut()
                           .insert(name, external_module.clone());
@@ -400,7 +400,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
                                             Some(def_id),
                                             NormalModuleKind,
                                             false,
-                                            item.vis == ast::Public,
+                                            is_public,
                                             sp);
 
                 name_bindings.get_module()
@@ -432,8 +432,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
             // These items live in the type namespace.
             ItemTy(..) => {
                 let name_bindings =
-                    self.add_child(name, parent, ForbidDuplicateTypesAndModules,
-                                   sp);
+                    self.add_child(name, parent, ForbidDuplicateTypesAndModules, sp);
 
                 name_bindings.define_type(DefTy(local_def(item.id), false), sp,
                                           modifiers);
@@ -517,7 +516,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
                                             Some(local_def(item.id)),
                                             TraitModuleKind,
                                             false,
-                                            item.vis == ast::Public,
+                                            is_public,
                                             sp);
                 let module_parent = name_bindings.get_module();
 
@@ -636,8 +635,8 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
                            name: Name,
                            new_parent: &Rc<Module>) {
         debug!("(building reduced graph for \
-                external crate) building external def, priv {:?}",
-               vis);
+                external crate) building external def {}, priv {:?}",
+               final_ident, vis);
         let is_public = vis == ast::Public;
         let modifiers = if is_public { PUBLIC } else { DefModifiers::empty() } | IMPORTABLE;
         let is_exported = is_public && match new_parent.def_id.get() {
@@ -667,7 +666,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
               Some(_) | None => {
                 debug!("(building reduced graph for \
                         external crate) building module \
-                        {}", final_ident);
+                        {} {}", final_ident, is_public);
                 let parent_link = self.get_parent_link(new_parent, name);
 
                 child_name_bindings.define_module(parent_link,
@@ -838,7 +837,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
     /// Builds the reduced graph rooted at the given external module.
     fn populate_external_module(&mut self, module: &Rc<Module>) {
         debug!("(populating external module) attempting to populate {}",
-               self.module_to_string(&**module));
+               module_to_string(&**module));
 
         let def_id = match module.def_id.get() {
             None => {
@@ -904,18 +903,14 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
 
         match subclass {
             SingleImport(target, _) => {
-                debug!("(building import directive) building import \
-                        directive: {}::{}",
-                       self.names_to_string(&module_.imports.borrow().last().unwrap().
-                                                             module_path),
+                debug!("(building import directive) building import directive: {}::{}",
+                       names_to_string(&module_.imports.borrow().last().unwrap().module_path),
                        token::get_name(target));
 
-                let mut import_resolutions = module_.import_resolutions
-                                                    .borrow_mut();
+                let mut import_resolutions = module_.import_resolutions.borrow_mut();
                 match import_resolutions.get_mut(&target) {
                     Some(resolution) => {
-                        debug!("(building import directive) bumping \
-                                reference");
+                        debug!("(building import directive) bumping reference");
                         resolution.outstanding_references += 1;
 
                         // the source of this name is different now
diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index 124aa392435..c586faae6e8 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -24,7 +24,9 @@ register_diagnostics! {
     E0258, // import conflicts with existing submodule
     E0259, // an extern crate has already been imported into this module
     E0260, // name conflicts with an external crate that has been imported into this module
-    E0317 // user-defined types or type parameters cannot shadow the primitive types
+    E0317, // user-defined types or type parameters cannot shadow the primitive types
+    E0364, // item is private
+    E0365  // item is private
 }
 
 __build_diagnostic_array! { DIAGNOSTICS }
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index e49fdc9c5d3..67e9f71551a 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -1,4 +1,4 @@
-// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -38,7 +38,6 @@ use self::PatternBindingMode::*;
 use self::Namespace::*;
 use self::NamespaceResult::*;
 use self::NameDefinition::*;
-use self::ImportDirectiveSubclass::*;
 use self::ResolveResult::*;
 use self::FallbackSuggestion::*;
 use self::TypeParameters::*;
@@ -98,6 +97,10 @@ use std::mem::replace;
 use std::rc::{Rc, Weak};
 use std::usize;
 
+use resolve_imports::{Target, ImportDirective, ImportResolution};
+use resolve_imports::Shadowable;
+
+
 // NB: This module needs to be declared first so diagnostics are
 // registered before they are used.
 pub mod diagnostics;
@@ -105,6 +108,7 @@ pub mod diagnostics;
 mod check_unused;
 mod record_exports;
 mod build_reduced_graph;
+mod resolve_imports;
 
 #[derive(Copy)]
 struct BindingInfo {
@@ -253,13 +257,6 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> {
     }
 }
 
-/// Contains data for specific types of import directives.
-#[derive(Copy,Debug)]
-enum ImportDirectiveSubclass {
-    SingleImport(Name /* target */, Name /* source */),
-    GlobImport
-}
-
 type ErrorMessage = Option<(Span, String)>;
 
 enum ResolveResult<T> {
@@ -366,144 +363,6 @@ impl Rib {
     }
 }
 
-/// Whether an import can be shadowed by another import.
-#[derive(Debug,PartialEq,Clone,Copy)]
-enum Shadowable {
-    Always,
-    Never
-}
-
-/// One import directive.
-#[derive(Debug)]
-struct ImportDirective {
-    module_path: Vec<Name>,
-    subclass: ImportDirectiveSubclass,
-    span: Span,
-    id: NodeId,
-    is_public: bool, // see note in ImportResolution about how to use this
-    shadowable: Shadowable,
-}
-
-impl ImportDirective {
-    fn new(module_path: Vec<Name> ,
-           subclass: ImportDirectiveSubclass,
-           span: Span,
-           id: NodeId,
-           is_public: bool,
-           shadowable: Shadowable)
-           -> ImportDirective {
-        ImportDirective {
-            module_path: module_path,
-            subclass: subclass,
-            span: span,
-            id: id,
-            is_public: is_public,
-            shadowable: shadowable,
-        }
-    }
-}
-
-/// The item that an import resolves to.
-#[derive(Clone,Debug)]
-struct Target {
-    target_module: Rc<Module>,
-    bindings: Rc<NameBindings>,
-    shadowable: Shadowable,
-}
-
-impl Target {
-    fn new(target_module: Rc<Module>,
-           bindings: Rc<NameBindings>,
-           shadowable: Shadowable)
-           -> Target {
-        Target {
-            target_module: target_module,
-            bindings: bindings,
-            shadowable: shadowable,
-        }
-    }
-}
-
-/// An ImportResolution represents a particular `use` directive.
-#[derive(Debug)]
-struct ImportResolution {
-    /// Whether this resolution came from a `use` or a `pub use`. Note that this
-    /// should *not* be used whenever resolution is being performed, this is
-    /// only looked at for glob imports statements currently. Privacy testing
-    /// occurs during a later phase of compilation.
-    is_public: bool,
-
-    // The number of outstanding references to this name. When this reaches
-    // zero, outside modules can count on the targets being correct. Before
-    // then, all bets are off; future imports could override this name.
-    outstanding_references: uint,
-
-    /// The value that this `use` directive names, if there is one.
-    value_target: Option<Target>,
-    /// The source node of the `use` directive leading to the value target
-    /// being non-none
-    value_id: NodeId,
-
-    /// The type that this `use` directive names, if there is one.
-    type_target: Option<Target>,
-    /// The source node of the `use` directive leading to the type target
-    /// being non-none
-    type_id: NodeId,
-}
-
-impl ImportResolution {
-    fn new(id: NodeId, is_public: bool) -> ImportResolution {
-        ImportResolution {
-            type_id: id,
-            value_id: id,
-            outstanding_references: 0,
-            value_target: None,
-            type_target: None,
-            is_public: is_public,
-        }
-    }
-
-    fn target_for_namespace(&self, namespace: Namespace)
-                                -> Option<Target> {
-        match namespace {
-            TypeNS  => self.type_target.clone(),
-            ValueNS => self.value_target.clone(),
-        }
-    }
-
-    fn id(&self, namespace: Namespace) -> NodeId {
-        match namespace {
-            TypeNS  => self.type_id,
-            ValueNS => self.value_id,
-        }
-    }
-
-    fn shadowable(&self, namespace: Namespace) -> Shadowable {
-        let target = self.target_for_namespace(namespace);
-        if target.is_none() {
-            return Shadowable::Always;
-        }
-
-        target.unwrap().shadowable
-    }
-
-    fn set_target_and_id(&mut self,
-                         namespace: Namespace,
-                         target: Option<Target>,
-                         id: NodeId) {
-        match namespace {
-            TypeNS  => {
-                self.type_target = target;
-                self.type_id = id;
-            }
-            ValueNS => {
-                self.value_target = target;
-                self.value_id = id;
-            }
-        }
-    }
-}
-
 /// The link from a module up to its nearest parent node.
 #[derive(Clone,Debug)]
 enum ParentLink {
@@ -855,6 +714,19 @@ impl NameBindings {
             None
         }
     }
+
+    fn is_public(&self, namespace: Namespace) -> bool {
+        match namespace {
+            TypeNS  => {
+                let type_def = self.type_def.borrow();
+                type_def.as_ref().unwrap().modifiers.contains(PUBLIC)
+            }
+            ValueNS => {
+                let value_def = self.value_def.borrow();
+                value_def.as_ref().unwrap().modifiers.contains(PUBLIC)
+            }
+        }
+    }
 }
 
 /// Interns the names of the primitive types.
@@ -963,7 +835,6 @@ enum FallbackChecks {
     OnlyTraitAndStatics
 }
 
-
 impl<'a, 'tcx> Resolver<'a, 'tcx> {
     fn new(session: &'a Session,
            ast_map: &'a ast_map::Map<'tcx>,
@@ -1023,151 +894,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
         }
     }
 
-    // Import resolution
-    //
-    // This is a fixed-point algorithm. We resolve imports until our efforts
-    // are stymied by an unresolved import; then we bail out of the current
-    // module and continue. We terminate successfully once no more imports
-    // remain or unsuccessfully when no forward progress in resolving imports
-    // is made.
-
-    /// Resolves all imports for the crate. This method performs the fixed-
-    /// point iteration.
-    fn resolve_imports(&mut self) {
-        let mut i = 0;
-        let mut prev_unresolved_imports = 0;
-        loop {
-            debug!("(resolving imports) iteration {}, {} imports left",
-                   i, self.unresolved_imports);
-
-            let module_root = self.graph_root.get_module();
-            self.resolve_imports_for_module_subtree(module_root.clone());
-
-            if self.unresolved_imports == 0 {
-                debug!("(resolving imports) success");
-                break;
-            }
-
-            if self.unresolved_imports == prev_unresolved_imports {
-                self.report_unresolved_imports(module_root);
-                break;
-            }
-
-            i += 1;
-            prev_unresolved_imports = self.unresolved_imports;
-        }
-    }
-
-    /// Attempts to resolve imports for the given module and all of its
-    /// submodules.
-    fn resolve_imports_for_module_subtree(&mut self, module_: Rc<Module>) {
-        debug!("(resolving imports for module subtree) resolving {}",
-               self.module_to_string(&*module_));
-        let orig_module = replace(&mut self.current_module, module_.clone());
-        self.resolve_imports_for_module(module_.clone());
-        self.current_module = orig_module;
-
-        build_reduced_graph::populate_module_if_necessary(self, &module_);
-        for (_, child_node) in &*module_.children.borrow() {
-            match child_node.get_module_if_available() {
-                None => {
-                    // Nothing to do.
-                }
-                Some(child_module) => {
-                    self.resolve_imports_for_module_subtree(child_module);
-                }
-            }
-        }
-
-        for (_, child_module) in &*module_.anonymous_children.borrow() {
-            self.resolve_imports_for_module_subtree(child_module.clone());
-        }
-    }
-
-    /// Attempts to resolve imports for the given module only.
-    fn resolve_imports_for_module(&mut self, module: Rc<Module>) {
-        if module.all_imports_resolved() {
-            debug!("(resolving imports for module) all imports resolved for \
-                   {}",
-                   self.module_to_string(&*module));
-            return;
-        }
-
-        let imports = module.imports.borrow();
-        let import_count = imports.len();
-        while module.resolved_import_count.get() < import_count {
-            let import_index = module.resolved_import_count.get();
-            let import_directive = &(*imports)[import_index];
-            match self.resolve_import_for_module(module.clone(),
-                                                 import_directive) {
-                Failed(err) => {
-                    let (span, help) = match err {
-                        Some((span, msg)) => (span, format!(". {}", msg)),
-                        None => (import_directive.span, String::new())
-                    };
-                    let msg = format!("unresolved import `{}`{}",
-                                      self.import_path_to_string(
-                                          &import_directive.module_path,
-                                          import_directive.subclass),
-                                      help);
-                    self.resolve_error(span, &msg[..]);
-                }
-                Indeterminate => break, // Bail out. We'll come around next time.
-                Success(()) => () // Good. Continue.
-            }
-
-            module.resolved_import_count
-                  .set(module.resolved_import_count.get() + 1);
-        }
-    }
-
-    fn names_to_string(&self, names: &[Name]) -> String {
-        let mut first = true;
-        let mut result = String::new();
-        for name in names {
-            if first {
-                first = false
-            } else {
-                result.push_str("::")
-            }
-            result.push_str(&token::get_name(*name));
-        };
-        result
-    }
-
-    fn path_names_to_string(&self, path: &Path, depth: usize) -> String {
-        let names: Vec<ast::Name> = path.segments[..path.segments.len()-depth]
-                                        .iter()
-                                        .map(|seg| seg.identifier.name)
-                                        .collect();
-        self.names_to_string(&names[..])
-    }
-
-    fn import_directive_subclass_to_string(&mut self,
-                                        subclass: ImportDirectiveSubclass)
-                                        -> String {
-        match subclass {
-            SingleImport(_, source) => {
-                token::get_name(source).to_string()
-            }
-            GlobImport => "*".to_string()
-        }
-    }
-
-    fn import_path_to_string(&mut self,
-                          names: &[Name],
-                          subclass: ImportDirectiveSubclass)
-                          -> String {
-        if names.is_empty() {
-            self.import_directive_subclass_to_string(subclass)
-        } else {
-            (format!("{}::{}",
-                     self.names_to_string(names),
-                     self.import_directive_subclass_to_string(
-                         subclass))).to_string()
-        }
-    }
-
     #[inline]
     fn record_import_use(&mut self, import_id: NodeId, name: Name) {
         if !self.make_glob_map {
@@ -1191,102 +917,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
         }
     }
 
-    /// Attempts to resolve the given import. The return value indicates
-    /// failure if we're certain the name does not exist, indeterminate if we
-    /// don't know whether the name exists at the moment due to other
-    /// currently-unresolved imports, or success if we know the name exists.
-    /// If successful, the resolved bindings are written into the module.
-    fn resolve_import_for_module(&mut self,
-                                 module_: Rc<Module>,
-                                 import_directive: &ImportDirective)
-                                 -> ResolveResult<()> {
-        let mut resolution_result = Failed(None);
-        let module_path = &import_directive.module_path;
-
-        debug!("(resolving import for module) resolving import `{}::...` in `{}`",
-               self.names_to_string(&module_path[..]),
-               self.module_to_string(&*module_));
-
-        // First, resolve the module path for the directive, if necessary.
-        let container = if module_path.len() == 0 {
-            // Use the crate root.
-            Some((self.graph_root.get_module(), LastMod(AllPublic)))
-        } else {
-            match self.resolve_module_path(module_.clone(),
-                                           &module_path[..],
-                                           DontUseLexicalScope,
-                                           import_directive.span,
-                                           ImportSearch) {
-                Failed(err) => {
-                    resolution_result = Failed(err);
-                    None
-                },
-                Indeterminate => {
-                    resolution_result = Indeterminate;
-                    None
-                }
-                Success(container) => Some(container),
-            }
-        };
-
-        match container {
-            None => {}
-            Some((containing_module, lp)) => {
-                // We found the module that the target is contained
-                // within. Attempt to resolve the import within it.
-
-                match import_directive.subclass {
-                    SingleImport(target, source) => {
-                        resolution_result =
-                            self.resolve_single_import(&*module_,
-                                                       containing_module,
-                                                       target,
-                                                       source,
-                                                       import_directive,
-                                                       lp);
-                    }
-                    GlobImport => {
-                        resolution_result =
-                            self.resolve_glob_import(&*module_,
-                                                     containing_module,
-                                                     import_directive,
-                                                     lp);
-                    }
-                }
-            }
-        }
-
-        // Decrement the count of unresolved imports.
-        match resolution_result {
-            Success(()) => {
-                assert!(self.unresolved_imports >= 1);
-                self.unresolved_imports -= 1;
-            }
-            _ => {
-                // Nothing to do here; just return the error.
-            }
-        }
-
-        // Decrement the count of unresolved globs if necessary. But only if
-        // the resolution result is indeterminate -- otherwise we'll stop
-        // processing imports here. (See the loop in
-        // resolve_imports_for_module.)
-
-        if !resolution_result.indeterminate() {
-            match import_directive.subclass {
-                GlobImport => {
-                    assert!(module_.glob_count.get() >= 1);
-                    module_.glob_count.set(module_.glob_count.get() - 1);
-                }
-                SingleImport(..) => {
-                    // Ignore.
-                }
-            }
-        }
-
-        return resolution_result;
-    }
-
     fn create_name_bindings_from_module(module: Rc<Module>) -> NameBindings {
         NameBindings {
             type_def: RefCell::new(Some(TypeNsDef {
@@ -1299,604 +929,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
         }
     }
 
-    fn resolve_single_import(&mut self,
-                             module_: &Module,
-                             containing_module: Rc<Module>,
-                             target: Name,
-                             source: Name,
-                             directive: &ImportDirective,
-                             lp: LastPrivate)
-                                 -> ResolveResult<()> {
-        debug!("(resolving single import) resolving `{}` = `{}::{}` from \
-                `{}` id {}, last private {:?}",
-               token::get_name(target),
-               self.module_to_string(&*containing_module),
-               token::get_name(source),
-               self.module_to_string(module_),
-               directive.id,
-               lp);
-
-        let lp = match lp {
-            LastMod(lp) => lp,
-            LastImport {..} => {
-                self.session
-                    .span_bug(directive.span,
-                              "not expecting Import here, must be LastMod")
-            }
-        };
-
-        // We need to resolve both namespaces for this to succeed.
-        //
-
-        let mut value_result = UnknownResult;
-        let mut type_result = UnknownResult;
-
-        // Search for direct children of the containing module.
-        build_reduced_graph::populate_module_if_necessary(self, &containing_module);
-
-        match containing_module.children.borrow().get(&source) {
-            None => {
-                // Continue.
-            }
-            Some(ref child_name_bindings) => {
-                if child_name_bindings.defined_in_namespace(ValueNS) {
-                    debug!("(resolving single import) found value binding");
-                    value_result = BoundResult(containing_module.clone(),
-                                               (*child_name_bindings).clone());
-                }
-                if child_name_bindings.defined_in_namespace(TypeNS) {
-                    debug!("(resolving single import) found type binding");
-                    type_result = BoundResult(containing_module.clone(),
-                                              (*child_name_bindings).clone());
-                }
-            }
-        }
-
-        // Unless we managed to find a result in both namespaces (unlikely),
-        // search imports as well.
-        let mut value_used_reexport = false;
-        let mut type_used_reexport = false;
-        match (value_result.clone(), type_result.clone()) {
-            (BoundResult(..), BoundResult(..)) => {} // Continue.
-            _ => {
-                // If there is an unresolved glob at this point in the
-                // containing module, bail out. We don't know enough to be
-                // able to resolve this import.
-
-                if containing_module.glob_count.get() > 0 {
-                    debug!("(resolving single import) unresolved glob; \
-                            bailing out");
-                    return Indeterminate;
-                }
-
-                // Now search the exported imports within the containing module.
-                match containing_module.import_resolutions.borrow().get(&source) {
-                    None => {
-                        debug!("(resolving single import) no import");
-                        // The containing module definitely doesn't have an
-                        // exported import with the name in question. We can
-                        // therefore accurately report that the names are
-                        // unbound.
-
-                        if value_result.is_unknown() {
-                            value_result = UnboundResult;
-                        }
-                        if type_result.is_unknown() {
-                            type_result = UnboundResult;
-                        }
-                    }
-                    Some(import_resolution)
-                            if import_resolution.outstanding_references == 0 => {
-
-                        fn get_binding(this: &mut Resolver,
-                                       import_resolution: &ImportResolution,
-                                       namespace: Namespace,
-                                       source: &Name)
-                                    -> NamespaceResult {
-
-                            // Import resolutions must be declared with "pub"
-                            // in order to be exported.
-                            if !import_resolution.is_public {
-                                return UnboundResult;
-                            }
-
-                            match import_resolution.
-                                    target_for_namespace(namespace) {
-                                None => {
-                                    return UnboundResult;
-                                }
-                                Some(Target {
-                                    target_module,
-                                    bindings,
-                                    shadowable: _
-                                }) => {
-                                    debug!("(resolving single import) found \
-                                            import in ns {:?}", namespace);
-                                    let id = import_resolution.id(namespace);
-                                    // track used imports and extern crates as well
-                                    this.used_imports.insert((id, namespace));
-                                    this.record_import_use(id, *source);
-                                    match target_module.def_id.get() {
-                                        Some(DefId{krate: kid, ..}) => {
-                                            this.used_crates.insert(kid);
-                                        },
-                                        _ => {}
-                                    }
-                                    return BoundResult(target_module, bindings);
-                                }
-                            }
-                        }
-
-                        // The name is an import which has been fully
-                        // resolved. We can, therefore, just follow it.
-                        if value_result.is_unknown() {
-                            value_result = get_binding(self,
-                                                       import_resolution,
-                                                       ValueNS,
-                                                       &source);
-                            value_used_reexport = import_resolution.is_public;
-                        }
-                        if type_result.is_unknown() {
-                            type_result = get_binding(self,
-                                                      import_resolution,
-                                                      TypeNS,
-                                                      &source);
-                            type_used_reexport = import_resolution.is_public;
-                        }
-
-                    }
-                    Some(_) => {
-                        // If containing_module is the same module whose import we are resolving
-                        // and there it has an unresolved import with the same name as `source`,
-                        // then the user is actually trying to import an item that is declared
-                        // in the same scope
-                        //
-                        // e.g
-                        // use self::submodule;
-                        // pub mod submodule;
-                        //
-                        // In this case we continue as if we resolved the import and let the
-                        // check_for_conflicts_between_imports_and_items call below handle
-                        // the conflict
-                        match (module_.def_id.get(),  containing_module.def_id.get()) {
-                            (Some(id1), Some(id2)) if id1 == id2  => {
-                                if value_result.is_unknown() {
-                                    value_result = UnboundResult;
-                                }
-                                if type_result.is_unknown() {
-                                    type_result = UnboundResult;
-                                }
-                            }
-                            _ =>  {
-                                // The import is unresolved. Bail out.
-                                debug!("(resolving single import) unresolved import; \
-                                        bailing out");
-                                return Indeterminate;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-
-        // If we didn't find a result in the type namespace, search the
-        // external modules.
-        let mut value_used_public = false;
-        let mut type_used_public = false;
-        match type_result {
-            BoundResult(..) => {}
-            _ => {
-                match containing_module.external_module_children.borrow_mut()
-                                       .get(&source).cloned() {
-                    None => {} // Continue.
-                    Some(module) => {
-                        debug!("(resolving single import) found external \
-                                module");
-                        // track the module as used.
-                        match module.def_id.get() {
-                            Some(DefId{krate: kid, ..}) => { self.used_crates.insert(kid); },
-                            _ => {}
-                        }
-                        let name_bindings =
-                            Rc::new(Resolver::create_name_bindings_from_module(
-                                module));
-                        type_result = BoundResult(containing_module.clone(),
-                                                  name_bindings);
-                        type_used_public = true;
-                    }
-                }
-            }
-        }
-
-        // We've successfully resolved the import. Write the results in.
-        let mut import_resolutions = module_.import_resolutions.borrow_mut();
-        let import_resolution = &mut (*import_resolutions)[target];
-        {
-            let mut check_and_write_import = |namespace, result: &_, used_public: &mut bool| {
-                let namespace_name = match namespace {
-                    TypeNS => "type",
-                    ValueNS => "value",
-                };
-
-                match *result {
-                    BoundResult(ref target_module, ref name_bindings) => {
-                        debug!("(resolving single import) found {:?} target: {:?}",
-                               namespace_name,
-                               name_bindings.def_for_namespace(namespace));
-                        self.check_for_conflicting_import(
-                            &import_resolution.target_for_namespace(namespace),
-                            directive.span,
-                            target,
-                            namespace);
-
-                        self.check_that_import_is_importable(
-                            &**name_bindings,
-                            directive.span,
-                            target,
-                            namespace);
-
-                        let target = Some(Target::new(target_module.clone(),
-                                                      name_bindings.clone(),
-                                                      directive.shadowable));
-                        import_resolution.set_target_and_id(namespace, target, directive.id);
-                        import_resolution.is_public = directive.is_public;
-                        *used_public = name_bindings.defined_in_public_namespace(namespace);
-                    }
-                    UnboundResult => { /* Continue. */ }
-                    UnknownResult => {
-                        panic!("{:?} result should be known at this point", namespace_name);
-                    }
-                }
-            };
-            check_and_write_import(ValueNS, &value_result, &mut value_used_public);
-            check_and_write_import(TypeNS, &type_result, &mut type_used_public);
-        }
-
-        self.check_for_conflicts_between_imports_and_items(
-            module_,
-            import_resolution,
-            directive.span,
-            target);
-
-        if value_result.is_unbound() && type_result.is_unbound() {
-            let msg = format!("There is no `{}` in `{}`",
-                              token::get_name(source),
-                              self.module_to_string(&*containing_module));
-            return Failed(Some((directive.span, msg)));
-        }
-        let value_used_public = value_used_reexport || value_used_public;
-        let type_used_public = type_used_reexport || type_used_public;
-
-        assert!(import_resolution.outstanding_references >= 1);
-        import_resolution.outstanding_references -= 1;
-
-        // record what this import resolves to for later uses in documentation,
-        // this may resolve to either a value or a type, but for documentation
-        // purposes it's good enough to just favor one over the other.
-        let value_def_and_priv = import_resolution.value_target.as_ref().map(|target| {
-            let def = target.bindings.def_for_namespace(ValueNS).unwrap();
-            (def, if value_used_public { lp } else { DependsOn(def.def_id()) })
-        });
-        let type_def_and_priv = import_resolution.type_target.as_ref().map(|target| {
-            let def = target.bindings.def_for_namespace(TypeNS).unwrap();
-            (def, if type_used_public { lp } else { DependsOn(def.def_id()) })
-        });
-
-        let import_lp = LastImport {
-            value_priv: value_def_and_priv.map(|(_, p)| p),
-            value_used: Used,
-            type_priv: type_def_and_priv.map(|(_, p)| p),
-            type_used: Used
-        };
-
-        if let Some((def, _)) = value_def_and_priv {
-            self.def_map.borrow_mut().insert(directive.id, PathResolution {
-                base_def: def,
-                last_private: import_lp,
-                depth: 0
-            });
-        }
-        if let Some((def, _)) = type_def_and_priv {
-            self.def_map.borrow_mut().insert(directive.id, PathResolution {
-                base_def: def,
-                last_private: import_lp,
-                depth: 0
-            });
-        }
-
-        debug!("(resolving single import) successfully resolved import");
-        return Success(());
-    }
-
-    // Resolves a glob import. Note that this function cannot fail; it either
-    // succeeds or bails out (as importing * from an empty module or a module
-    // that exports nothing is valid). containing_module is the module we are
-    // actually importing, i.e., `foo` in `use foo::*`.
-    fn resolve_glob_import(&mut self,
-                           module_: &Module,
-                           containing_module: Rc<Module>,
-                           import_directive: &ImportDirective,
-                           lp: LastPrivate)
-                           -> ResolveResult<()> {
-        let id = import_directive.id;
-        let is_public = import_directive.is_public;
-
-        // This function works in a highly imperative manner; it eagerly adds
-        // everything it can to the list of import resolutions of the module
-        // node.
-        debug!("(resolving glob import) resolving glob import {}", id);
-
-        // We must bail out if the node has unresolved imports of any kind
-        // (including globs).
-        if !(*containing_module).all_imports_resolved() {
-            debug!("(resolving glob import) target module has unresolved \
-                    imports; bailing out");
-            return Indeterminate;
-        }
-
-        assert_eq!(containing_module.glob_count.get(), 0);
-
-        // Add all resolved imports from the containing module.
-        let import_resolutions = containing_module.import_resolutions.borrow();
-        for (ident, target_import_resolution) in &*import_resolutions {
-            debug!("(resolving glob import) writing module resolution \
-                    {} into `{}`",
-                   token::get_name(*ident),
-                   self.module_to_string(module_));
-
-            if !target_import_resolution.is_public {
-                debug!("(resolving glob import) nevermind, just kidding");
-                continue
-            }
-
-            // Here we merge two import resolutions.
-            let mut import_resolutions = module_.import_resolutions.borrow_mut();
-            match import_resolutions.get_mut(ident) {
-                Some(dest_import_resolution) => {
-                    // Merge the two import resolutions at a finer-grained
-                    // level.
-
-                    match target_import_resolution.value_target {
-                        None => {
-                            // Continue.
-                        }
-                        Some(ref value_target) => {
-                            self.check_for_conflicting_import(&dest_import_resolution.value_target,
-                                                              import_directive.span,
-                                                              *ident,
-                                                              ValueNS);
-                            dest_import_resolution.value_target = Some(value_target.clone());
-                        }
-                    }
-                    match target_import_resolution.type_target {
-                        None => {
-                            // Continue.
-                        }
-                        Some(ref type_target) => {
-                            self.check_for_conflicting_import(&dest_import_resolution.type_target,
-                                                              import_directive.span,
-                                                              *ident,
-                                                              TypeNS);
-                            dest_import_resolution.type_target = Some(type_target.clone());
-                        }
-                    }
-                    dest_import_resolution.is_public = is_public;
-                    continue;
-                }
-                None => {}
-            }
-
-            // Simple: just copy the old import resolution.
-            let mut new_import_resolution = ImportResolution::new(id, is_public);
-            new_import_resolution.value_target =
-                target_import_resolution.value_target.clone();
-            new_import_resolution.type_target =
-                target_import_resolution.type_target.clone();
-
-            import_resolutions.insert(*ident, new_import_resolution);
-        }
-
-        // Add all children from the containing module.
-        build_reduced_graph::populate_module_if_necessary(self, &containing_module);
-
-        for (&name, name_bindings) in &*containing_module.children.borrow() {
-            self.merge_import_resolution(module_,
-                                         containing_module.clone(),
-                                         import_directive,
-                                         name,
-                                         name_bindings.clone());
-
-        }
-
-        // Add external module children from the containing module.
-        for (&name, module) in &*containing_module.external_module_children.borrow() {
-            let name_bindings =
-                Rc::new(Resolver::create_name_bindings_from_module(module.clone()));
-            self.merge_import_resolution(module_,
-                                         containing_module.clone(),
-                                         import_directive,
-                                         name,
-                                         name_bindings);
-        }
-
-        // Record the destination of this import
-        if let Some(did) = containing_module.def_id.get() {
-            self.def_map.borrow_mut().insert(id, PathResolution {
-                base_def: DefMod(did),
-                last_private: lp,
-                depth: 0
-            });
-        }
-
-        debug!("(resolving glob import) successfully resolved import");
-        return Success(());
-    }
-
-    fn merge_import_resolution(&mut self,
-                               module_: &Module,
-                               containing_module: Rc<Module>,
-                               import_directive: &ImportDirective,
-                               name: Name,
-                               name_bindings: Rc<NameBindings>) {
-        let id = import_directive.id;
-        let is_public = import_directive.is_public;
-
-        let mut import_resolutions = module_.import_resolutions.borrow_mut();
-        let dest_import_resolution = import_resolutions.entry(name).get().unwrap_or_else(
-            |vacant_entry| {
-                // Create a new import resolution from this child.
-                vacant_entry.insert(ImportResolution::new(id, is_public))
-            });
-
-        debug!("(resolving glob import) writing resolution `{}` in `{}` \
-               to `{}`",
-               &token::get_name(name),
-               self.module_to_string(&*containing_module),
-               self.module_to_string(module_));
-
-        // Merge the child item into the import resolution.
-        {
-            let mut merge_child_item = |namespace| {
-                if name_bindings.defined_in_namespace_with(namespace, IMPORTABLE | PUBLIC) {
-                    let namespace_name = match namespace {
-                        TypeNS => "type",
-                        ValueNS => "value",
-                    };
-                    debug!("(resolving glob import) ... for {} target", namespace_name);
-                    if dest_import_resolution.shadowable(namespace) == Shadowable::Never {
-                        let msg = format!("a {} named `{}` has already been imported \
-                                           in this module",
-                                          namespace_name,
-                                          &token::get_name(name));
-                        span_err!(self.session, import_directive.span, E0251, "{}", msg);
-                    } else {
-                        let target = Target::new(containing_module.clone(),
-                                                 name_bindings.clone(),
-                                                 import_directive.shadowable);
-                        dest_import_resolution.set_target_and_id(namespace,
-                                                                 Some(target),
-                                                                 id);
-                    }
-                }
-            };
-            merge_child_item(ValueNS);
-            merge_child_item(TypeNS);
-        }
-
-        dest_import_resolution.is_public = is_public;
-
-        self.check_for_conflicts_between_imports_and_items(
-            module_,
-            dest_import_resolution,
-            import_directive.span,
-            name);
-    }
-
-    /// Checks that imported names and items don't have the same name.
-    fn check_for_conflicting_import(&mut self,
-                                    target: &Option<Target>,
-                                    import_span: Span,
-                                    name: Name,
-                                    namespace: Namespace) {
-        debug!("check_for_conflicting_import: {}; target exists: {}",
-               &token::get_name(name),
-               target.is_some());
-
-        match *target {
-            Some(ref target) if target.shadowable != Shadowable::Always => {
-                let msg = format!("a {} named `{}` has already been imported \
-                                   in this module",
-                                  match namespace {
-                                    TypeNS => "type",
-                                    ValueNS => "value",
-                                  },
-                                  &token::get_name(name));
-                span_err!(self.session, import_span, E0252, "{}", &msg[..]);
-            }
-            Some(_) | None => {}
-        }
-    }
-
-    /// Checks that an import is actually importable
-    fn check_that_import_is_importable(&mut self,
-                                       name_bindings: &NameBindings,
-                                       import_span: Span,
-                                       name: Name,
-                                       namespace: Namespace) {
-        if !name_bindings.defined_in_namespace_with(namespace, IMPORTABLE) {
-            let msg = format!("`{}` is not directly importable",
-                              token::get_name(name));
-            span_err!(self.session, import_span, E0253, "{}", &msg[..]);
-        }
-    }
-
-    /// Checks that imported names and items don't have the same name.
-    fn check_for_conflicts_between_imports_and_items(&mut self,
-                                                     module: &Module,
-                                                     import_resolution:
-                                                     &ImportResolution,
-                                                     import_span: Span,
-                                                     name: Name) {
-        // First, check for conflicts between imports and `extern crate`s.
-        if module.external_module_children
-                 .borrow()
-                 .contains_key(&name) {
-            match import_resolution.type_target {
-                Some(ref target) if target.shadowable != Shadowable::Always => {
-                    let msg = format!("import `{0}` conflicts with imported \
-                                       crate in this module \
-                                       (maybe you meant `use {0}::*`?)",
-                                      &token::get_name(name));
-                    span_err!(self.session, import_span, E0254, "{}", &msg[..]);
-                }
-                Some(_) | None => {}
-            }
-        }
-
-        // Check for item conflicts.
-        let children = module.children.borrow();
-        let name_bindings = match children.get(&name) {
-            None => {
-                // There can't be any conflicts.
-                return
-            }
-            Some(ref name_bindings) => (*name_bindings).clone(),
-        };
-
-        match import_resolution.value_target {
-            Some(ref target) if target.shadowable != Shadowable::Always => {
-                if let Some(ref value) = *name_bindings.value_def.borrow() {
-                    span_err!(self.session, import_span, E0255,
-                              "import `{}` conflicts with value in this module",
-                              &token::get_name(name));
-                    if let Some(span) = value.value_span {
-                        self.session.span_note(span, "conflicting value here");
-                    }
-                }
-            }
-            Some(_) | None => {}
-        }
-
-        match import_resolution.type_target {
-            Some(ref target) if target.shadowable != Shadowable::Always => {
-                if let Some(ref ty) = *name_bindings.type_def.borrow() {
-                    let (what, note) = if ty.module_def.is_some() {
-                        ("existing submodule", "note conflicting module here")
-                    } else {
-                        ("type in this module", "note conflicting type here")
-                    };
-                    span_err!(self.session, import_span, E0256,
-                              "import `{}` conflicts with {}",
-                              &token::get_name(name), what);
-                    if let Some(span) = ty.type_span {
-                        self.session.span_note(span, note);
-                    }
-                }
-            }
-            Some(_) | None => {}
-        }
-    }
-
     /// Checks that the names of external crates don't collide with other
     /// external crates.
     fn check_for_conflicts_between_external_crates(&self,
@@ -1964,7 +996,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                                               false) {
                 Failed(None) => {
                     let segment_name = token::get_name(name);
-                    let module_name = self.module_to_string(&*search_module);
+                    let module_name = module_to_string(&*search_module);
                     let mut span = span;
                     let msg = if "???" == &module_name[..] {
                         span.hi = span.lo + Pos::from_usize(segment_name.len());
@@ -1972,10 +1004,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                         match search_parent_externals(name,
                                                      &self.current_module) {
                             Some(module) => {
-                                let path_str = self.names_to_string(module_path);
-                                let target_mod_str = self.module_to_string(&*module);
+                                let path_str = names_to_string(module_path);
+                                let target_mod_str = module_to_string(&*module);
                                 let current_mod_str =
-                                    self.module_to_string(&*self.current_module);
+                                    module_to_string(&*self.current_module);
 
                                 let prefix = if target_mod_str == current_mod_str {
                                     "self::".to_string()
@@ -2066,8 +1098,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
         assert!(module_path_len > 0);
 
         debug!("(resolving module path for import) processing `{}` rooted at `{}`",
-               self.names_to_string(module_path),
-               self.module_to_string(&*module_));
+               names_to_string(module_path),
+               module_to_string(&*module_));
 
         // Resolve the module prefix, if any.
         let module_prefix_result = self.resolve_module_prefix(module_.clone(),
@@ -2078,7 +1110,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
         let last_private;
         match module_prefix_result {
             Failed(None) => {
-                let mpath = self.names_to_string(module_path);
+                let mpath = names_to_string(module_path);
                 let mpath = &mpath[..];
                 match mpath.rfind(':') {
                     Some(idx) => {
@@ -2161,7 +1193,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                 namespace {:?} in `{}`",
                token::get_name(name),
                namespace,
-               self.module_to_string(&*module_));
+               module_to_string(&*module_));
 
         // The current module node is handled specially. First, check for
         // its immediate children.
@@ -2398,7 +1430,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                 break
             }
             debug!("(resolving module prefix) resolving `super` at {}",
-                   self.module_to_string(&*containing_module));
+                   module_to_string(&*containing_module));
             match self.get_nearest_normal_module_parent(containing_module) {
                 None => return Failed(None),
                 Some(new_module) => {
@@ -2409,7 +1441,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
         }
 
         debug!("(resolving module prefix) finished resolving prefix at {}",
-               self.module_to_string(&*containing_module));
+               module_to_string(&*containing_module));
 
         return Success(PrefixFound(containing_module, i));
     }
@@ -2429,7 +1461,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                               -> ResolveResult<(Target, bool)> {
         debug!("(resolving name in module) resolving `{}` in `{}`",
                &token::get_name(name),
-               self.module_to_string(&*module_));
+               module_to_string(&*module_));
 
         // First, check the direct children of the module.
         build_reduced_graph::populate_module_if_necessary(self, &module_);
@@ -2583,7 +1615,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                     None => {
                         debug!("!!! (with scope) didn't find `{}` in `{}`",
                                token::get_name(name),
-                               self.module_to_string(&*orig_module));
+                               module_to_string(&*orig_module));
                     }
                     Some(name_bindings) => {
                         match (*name_bindings).get_module_if_available() {
@@ -2591,7 +1623,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                                 debug!("!!! (with scope) didn't find module \
                                         for `{}` in `{}`",
                                        token::get_name(name),
-                                       self.module_to_string(&*orig_module));
+                                       module_to_string(&*orig_module));
                             }
                             Some(module_) => {
                                 self.current_module = module_;
@@ -2970,7 +2002,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
             } else {
                 self.resolve_error(trait_path.span,
                     &format!("`{}` is not a trait",
-                             self.path_names_to_string(trait_path, path_depth)));
+                             path_names_to_string(trait_path, path_depth)));
 
                 // If it's a typedef, give a note
                 if let DefTy(..) = path_res.base_def {
@@ -2981,7 +2013,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
             }
         } else {
             let msg = format!("use of undeclared trait name `{}`",
-                              self.path_names_to_string(trait_path, path_depth));
+                              path_names_to_string(trait_path, path_depth));
             self.resolve_error(trait_path.span, &msg);
             Err(())
         }
@@ -3097,7 +2129,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
         // If there is a TraitRef in scope for an impl, then the method must be in the trait.
         if let Some((did, ref trait_ref)) = self.current_trait_ref {
             if !self.trait_item_map.contains_key(&(name, did)) {
-                let path_str = self.path_names_to_string(&trait_ref.path, 0);
+                let path_str = path_names_to_string(&trait_ref.path, 0);
                 self.resolve_error(span,
                                     &format!("method `{}` is not a member of trait `{}`",
                                             token::get_name(name),
@@ -3279,7 +2311,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                         // Write the result into the def map.
                         debug!("(resolving type) writing resolution for `{}` \
                                 (id {}) = {:?}",
-                               self.path_names_to_string(path, 0),
+                               path_names_to_string(path, 0),
                                ty.id, def);
                         self.record_def(ty.id, def);
                     }
@@ -3294,7 +2326,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                         };
 
                         let msg = format!("use of undeclared {} `{}`", kind,
-                                          self.path_names_to_string(path, 0));
+                                          path_names_to_string(path, 0));
                         self.resolve_error(ty.span, &msg[..]);
                     }
                 }
@@ -3465,7 +2497,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                             debug!("(resolving pattern) didn't find struct \
                                     def: {:?}", result);
                             let msg = format!("`{}` does not name a structure",
-                                              self.path_names_to_string(path, 0));
+                                              path_names_to_string(path, 0));
                             self.resolve_error(path.span, &msg[..]);
                         }
                     }
@@ -3718,7 +2750,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                     Some((span, msg)) => (span, msg),
                     None => {
                         let msg = format!("Use of undeclared type or module `{}`",
-                                          self.names_to_string(&module_path));
+                                          names_to_string(&module_path));
                         (span, msg)
                     }
                 };
@@ -3778,7 +2810,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                     Some((span, msg)) => (span, msg),
                     None => {
                         let msg = format!("Use of undeclared module `::{}`",
-                                          self.names_to_string(&module_path[..]));
+                                          names_to_string(&module_path[..]));
                         (span, msg)
                     }
                 };
@@ -3998,7 +3030,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
             if let Some(binding) = module.children.borrow().get(&name) {
                 if let Some(DefMethod(did, _)) = binding.def_for_namespace(ValueNS) {
                     if is_static_method(self, did) {
-                        return StaticMethod(self.path_names_to_string(&path, 0))
+                        return StaticMethod(path_names_to_string(&path, 0))
                     }
                     if self.current_trait_ref.is_some() {
                         return TraitItem;
@@ -4013,7 +3045,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
         if let Some((trait_did, ref trait_ref)) = self.current_trait_ref {
             if let Some(&did) = self.trait_item_map.get(&(name, trait_did)) {
                 if is_static_method(self, did) {
-                    return TraitMethod(self.path_names_to_string(&trait_ref.path, 0));
+                    return TraitMethod(path_names_to_string(&trait_ref.path, 0));
                 } else {
                     return TraitItem;
                 }
@@ -4105,7 +3137,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                 if let Some(path_res) = resolution {
                     // Check if struct variant
                     if let DefVariant(_, _, true) = path_res.base_def {
-                        let path_name = self.path_names_to_string(path, 0);
+                        let path_name = path_names_to_string(path, 0);
                         self.resolve_error(expr.span,
                                 &format!("`{}` is a struct variant name, but \
                                           this expression \
@@ -4123,7 +3155,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                     } else {
                         // Write the result into the def map.
                         debug!("(resolving expr) resolved `{}`",
-                               self.path_names_to_string(path, 0));
+                               path_names_to_string(path, 0));
 
                         // Partial resolutions will need the set of traits in scope,
                         // so they can be completed during typeck.
@@ -4140,7 +3172,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                     // (The pattern matching def_tys where the id is in self.structs
                     // matches on regular structs while excluding tuple- and enum-like
                     // structs, which wouldn't result in this error.)
-                    let path_name = self.path_names_to_string(path, 0);
+                    let path_name = path_names_to_string(path, 0);
                     let type_res = self.with_no_errors(|this| {
                         this.resolve_path(expr.id, path, 0, TypeNS, false)
                     });
@@ -4227,7 +3259,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                     None => {
                         debug!("(resolving expression) didn't find struct def",);
                         let msg = format!("`{}` does not name a structure",
-                                          self.path_names_to_string(path, 0));
+                                          path_names_to_string(path, 0));
                         self.resolve_error(path.span, &msg[..]);
                     }
                 }
@@ -4417,36 +3449,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
     // hit.
     //
 
-    /// A somewhat inefficient routine to obtain the name of a module.
-    fn module_to_string(&self, module: &Module) -> String {
-        let mut names = Vec::new();
-
-        fn collect_mod(names: &mut Vec<ast::Name>, module: &Module) {
-            match module.parent_link {
-                NoParentLink => {}
-                ModuleParentLink(ref module, name) => {
-                    names.push(name);
-                    collect_mod(names, &*module.upgrade().unwrap());
-                }
-                BlockParentLink(ref module, _) => {
-                    // danger, shouldn't be ident?
-                    names.push(special_idents::opaque.name);
-                    collect_mod(names, &*module.upgrade().unwrap());
-                }
-            }
-        }
-        collect_mod(&mut names, module);
-
-        if names.len() == 0 {
-            return "???".to_string();
-        }
-        self.names_to_string(&names.into_iter().rev()
-                                  .collect::<Vec<ast::Name>>())
-    }
-
     #[allow(dead_code)]   // useful for debugging
     fn dump_module(&mut self, module_: Rc<Module>) {
-        debug!("Dump of module `{}`:", self.module_to_string(&*module_));
+        debug!("Dump of module `{}`:", module_to_string(&*module_));
 
         debug!("Children:");
         build_reduced_graph::populate_module_if_necessary(self, &module_);
@@ -4480,6 +3485,56 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
     }
 }
 
+
+fn names_to_string(names: &[Name]) -> String {
+    let mut first = true;
+    let mut result = String::new();
+    for name in names {
+        if first {
+            first = false
+        } else {
+            result.push_str("::")
+        }
+        result.push_str(&token::get_name(*name));
+    };
+    result
+}
+
+fn path_names_to_string(path: &Path, depth: usize) -> String {
+    let names: Vec<ast::Name> = path.segments[..path.segments.len()-depth]
+                                    .iter()
+                                    .map(|seg| seg.identifier.name)
+                                    .collect();
+    names_to_string(&names[..])
+}
+
+/// A somewhat inefficient routine to obtain the name of a module.
+fn module_to_string(module: &Module) -> String {
+    let mut names = Vec::new();
+
+    fn collect_mod(names: &mut Vec<ast::Name>, module: &Module) {
+        match module.parent_link {
+            NoParentLink => {}
+            ModuleParentLink(ref module, name) => {
+                names.push(name);
+                collect_mod(names, &*module.upgrade().unwrap());
+            }
+            BlockParentLink(ref module, _) => {
+                // danger, shouldn't be ident?
+                names.push(special_idents::opaque.name);
+                collect_mod(names, &*module.upgrade().unwrap());
+            }
+        }
+    }
+    collect_mod(&mut names, module);
+
+    if names.len() == 0 {
+        return "???".to_string();
+    }
+    names_to_string(&names.into_iter().rev().collect::<Vec<ast::Name>>())
+}
+
+
 pub struct CrateMap {
     pub def_map: DefMap,
     pub freevars: RefCell<FreevarMap>,
@@ -4507,7 +3562,7 @@ pub fn resolve_crate<'a, 'tcx>(session: &'a Session,
     build_reduced_graph::build_reduced_graph(&mut resolver, krate);
     session.abort_if_errors();
 
-    resolver.resolve_imports();
+    resolve_imports::resolve_imports(&mut resolver);
     session.abort_if_errors();
 
     record_exports::record(&mut resolver);
diff --git a/src/librustc_resolve/record_exports.rs b/src/librustc_resolve/record_exports.rs
index 5d025f40d32..e953b6398f9 100644
--- a/src/librustc_resolve/record_exports.rs
+++ b/src/librustc_resolve/record_exports.rs
@@ -22,6 +22,7 @@ use {Module, NameBindings, Resolver};
 use Namespace::{self, TypeNS, ValueNS};
 
 use build_reduced_graph;
+use module_to_string;
 
 use rustc::middle::def::Export;
 use syntax::ast;
@@ -60,19 +61,19 @@ impl<'a, 'b, 'tcx> ExportRecorder<'a, 'b, 'tcx> {
                 // OK. Continue.
                 debug!("(recording exports for module subtree) recording \
                         exports for local module `{}`",
-                       self.module_to_string(&*module_));
+                       module_to_string(&*module_));
             }
             None => {
                 // Record exports for the root module.
                 debug!("(recording exports for module subtree) recording \
                         exports for root module `{}`",
-                       self.module_to_string(&*module_));
+                       module_to_string(&*module_));
             }
             Some(_) => {
                 // Bail out.
                 debug!("(recording exports for module subtree) not recording \
                         exports for `{}`",
-                       self.module_to_string(&*module_));
+                       module_to_string(&*module_));
                 return;
             }
         }
@@ -133,13 +134,13 @@ impl<'a, 'b, 'tcx> ExportRecorder<'a, 'b, 'tcx> {
     fn add_exports_for_module(&mut self,
                               exports: &mut Vec<Export>,
                               module_: &Module) {
-        for (name, importresolution) in &*module_.import_resolutions.borrow() {
-            if !importresolution.is_public {
+        for (name, import_resolution) in &*module_.import_resolutions.borrow() {
+            if !import_resolution.is_public {
                 continue
             }
             let xs = [TypeNS, ValueNS];
             for &ns in &xs {
-                match importresolution.target_for_namespace(ns) {
+                match import_resolution.target_for_namespace(ns) {
                     Some(target) => {
                         debug!("(computing exports) maybe export '{}'",
                                token::get_name(*name));
diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs
new file mode 100644
index 00000000000..737ec71cab3
--- /dev/null
+++ b/src/librustc_resolve/resolve_imports.rs
@@ -0,0 +1,1021 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use self::ImportDirectiveSubclass::*;
+
+use {PUBLIC, IMPORTABLE};
+use Module;
+use Namespace::{self, TypeNS, ValueNS};
+use NameBindings;
+use NamespaceResult::{BoundResult, UnboundResult, UnknownResult};
+use NamespaceResult;
+use NameSearchType;
+use ResolveResult;
+use Resolver;
+use UseLexicalScopeFlag;
+use {names_to_string, module_to_string};
+
+use build_reduced_graph;
+
+use rustc::middle::def::*;
+use rustc::middle::privacy::*;
+
+use syntax::ast::{DefId, NodeId, Name};
+use syntax::attr::AttrMetaMethods;
+use syntax::parse::token;
+use syntax::codemap::Span;
+
+use std::mem::replace;
+use std::rc::Rc;
+
+
+/// Contains data for specific types of import directives.
+#[derive(Copy,Debug)]
+pub enum ImportDirectiveSubclass {
+    SingleImport(Name /* target */, Name /* source */),
+    GlobImport
+}
+
+/// Whether an import can be shadowed by another import.
+#[derive(Debug,PartialEq,Clone,Copy)]
+pub enum Shadowable {
+    Always,
+    Never
+}
+
+/// One import directive.
+#[derive(Debug)]
+pub struct ImportDirective {
+    pub module_path: Vec<Name>,
+    pub subclass: ImportDirectiveSubclass,
+    pub span: Span,
+    pub id: NodeId,
+    pub is_public: bool, // see note in ImportResolution about how to use this
+    pub shadowable: Shadowable,
+}
+
+impl ImportDirective {
+    pub fn new(module_path: Vec<Name> ,
+           subclass: ImportDirectiveSubclass,
+           span: Span,
+           id: NodeId,
+           is_public: bool,
+           shadowable: Shadowable)
+           -> ImportDirective {
+        ImportDirective {
+            module_path: module_path,
+            subclass: subclass,
+            span: span,
+            id: id,
+            is_public: is_public,
+            shadowable: shadowable,
+        }
+    }
+}
+
+/// The item that an import resolves to.
+#[derive(Clone,Debug)]
+pub struct Target {
+    pub target_module: Rc<Module>,
+    pub bindings: Rc<NameBindings>,
+    pub shadowable: Shadowable,
+}
+
+impl Target {
+    pub fn new(target_module: Rc<Module>,
+           bindings: Rc<NameBindings>,
+           shadowable: Shadowable)
+           -> Target {
+        Target {
+            target_module: target_module,
+            bindings: bindings,
+            shadowable: shadowable,
+        }
+    }
+}
+
+/// An ImportResolution represents a particular `use` directive.
+#[derive(Debug)]
+pub struct ImportResolution {
+    /// Whether this resolution came from a `use` or a `pub use`. Note that this
+    /// should *not* be used whenever resolution is being performed. Privacy
+    /// testing occurs during a later phase of compilation.
+    pub is_public: bool,
+
+    // The number of outstanding references to this name. When this reaches
+    // zero, outside modules can count on the targets being correct. Before
+    // then, all bets are off; future imports could override this name.
+    // Note that this is usually either 0 or 1 - shadowing is forbidden the only
+    // way outstanding_references is > 1 in a legal program is if the name is
+    // used in both namespaces.
+    pub outstanding_references: uint,
+
+    /// The value that this `use` directive names, if there is one.
+    pub value_target: Option<Target>,
+    /// The source node of the `use` directive leading to the value target
+    /// being non-none
+    pub value_id: NodeId,
+
+    /// The type that this `use` directive names, if there is one.
+    pub type_target: Option<Target>,
+    /// The source node of the `use` directive leading to the type target
+    /// being non-none
+    pub type_id: NodeId,
+}
+
+impl ImportResolution {
+    pub fn new(id: NodeId, is_public: bool) -> ImportResolution {
+        ImportResolution {
+            type_id: id,
+            value_id: id,
+            outstanding_references: 0,
+            value_target: None,
+            type_target: None,
+            is_public: is_public,
+        }
+    }
+
+    pub fn target_for_namespace(&self, namespace: Namespace)
+                                -> Option<Target> {
+        match namespace {
+            TypeNS  => self.type_target.clone(),
+            ValueNS => self.value_target.clone(),
+        }
+    }
+
+    pub fn id(&self, namespace: Namespace) -> NodeId {
+        match namespace {
+            TypeNS  => self.type_id,
+            ValueNS => self.value_id,
+        }
+    }
+
+    pub fn shadowable(&self, namespace: Namespace) -> Shadowable {
+        let target = self.target_for_namespace(namespace);
+        if target.is_none() {
+            return Shadowable::Always;
+        }
+
+        target.unwrap().shadowable
+    }
+
+    pub fn set_target_and_id(&mut self,
+                         namespace: Namespace,
+                         target: Option<Target>,
+                         id: NodeId) {
+        match namespace {
+            TypeNS  => {
+                self.type_target = target;
+                self.type_id = id;
+            }
+            ValueNS => {
+                self.value_target = target;
+                self.value_id = id;
+            }
+        }
+    }
+}
+
+
+struct ImportResolver<'a, 'b:'a, 'tcx:'b> {
+    resolver: &'a mut Resolver<'b, 'tcx>
+}
+
+impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
+    // Import resolution
+    //
+    // This is a fixed-point algorithm. We resolve imports until our efforts
+    // are stymied by an unresolved import; then we bail out of the current
+    // module and continue. We terminate successfully once no more imports
+    // remain or unsuccessfully when no forward progress in resolving imports
+    // is made.
+
+    /// Resolves all imports for the crate. This method performs the fixed-
+    /// point iteration.
+    fn resolve_imports(&mut self) {
+        let mut i = 0;
+        let mut prev_unresolved_imports = 0;
+        loop {
+            debug!("(resolving imports) iteration {}, {} imports left",
+                   i, self.resolver.unresolved_imports);
+
+            let module_root = self.resolver.graph_root.get_module();
+            self.resolve_imports_for_module_subtree(module_root.clone());
+
+            if self.resolver.unresolved_imports == 0 {
+                debug!("(resolving imports) success");
+                break;
+            }
+
+            if self.resolver.unresolved_imports == prev_unresolved_imports {
+                self.resolver.report_unresolved_imports(module_root);
+                break;
+            }
+
+            i += 1;
+            prev_unresolved_imports = self.resolver.unresolved_imports;
+        }
+    }
+
+    /// Attempts to resolve imports for the given module and all of its
+    /// submodules.
+    fn resolve_imports_for_module_subtree(&mut self, module_: Rc<Module>) {
+        debug!("(resolving imports for module subtree) resolving {}",
+               module_to_string(&*module_));
+        let orig_module = replace(&mut self.resolver.current_module, module_.clone());
+        self.resolve_imports_for_module(module_.clone());
+        self.resolver.current_module = orig_module;
+
+        build_reduced_graph::populate_module_if_necessary(self.resolver, &module_);
+        for (_, child_node) in &*module_.children.borrow() {
+            match child_node.get_module_if_available() {
+                None => {
+                    // Nothing to do.
+                }
+                Some(child_module) => {
+                    self.resolve_imports_for_module_subtree(child_module);
+                }
+            }
+        }
+
+        for (_, child_module) in &*module_.anonymous_children.borrow() {
+            self.resolve_imports_for_module_subtree(child_module.clone());
+        }
+    }
+
+    /// Attempts to resolve imports for the given module only.
+    fn resolve_imports_for_module(&mut self, module: Rc<Module>) {
+        if module.all_imports_resolved() {
+            debug!("(resolving imports for module) all imports resolved for \
+                   {}",
+                   module_to_string(&*module));
+            return;
+        }
+
+        let imports = module.imports.borrow();
+        let import_count = imports.len();
+        while module.resolved_import_count.get() < import_count {
+            let import_index = module.resolved_import_count.get();
+            let import_directive = &(*imports)[import_index];
+            match self.resolve_import_for_module(module.clone(),
+                                                 import_directive) {
+                ResolveResult::Failed(err) => {
+                    let (span, help) = match err {
+                        Some((span, msg)) => (span, format!(". {}", msg)),
+                        None => (import_directive.span, String::new())
+                    };
+                    let msg = format!("unresolved import `{}`{}",
+                                      import_path_to_string(
+                                          &import_directive.module_path,
+                                          import_directive.subclass),
+                                      help);
+                    self.resolver.resolve_error(span, &msg[..]);
+                }
+                ResolveResult::Indeterminate => break, // Bail out. We'll come around next time.
+                ResolveResult::Success(()) => () // Good. Continue.
+            }
+
+            module.resolved_import_count
+                  .set(module.resolved_import_count.get() + 1);
+        }
+    }
+
+    /// Attempts to resolve the given import. The return value indicates
+    /// failure if we're certain the name does not exist, indeterminate if we
+    /// don't know whether the name exists at the moment due to other
+    /// currently-unresolved imports, or success if we know the name exists.
+    /// If successful, the resolved bindings are written into the module.
+    fn resolve_import_for_module(&mut self,
+                                 module_: Rc<Module>,
+                                 import_directive: &ImportDirective)
+                                 -> ResolveResult<()> {
+        let mut resolution_result = ResolveResult::Failed(None);
+        let module_path = &import_directive.module_path;
+
+        debug!("(resolving import for module) resolving import `{}::...` in `{}`",
+               names_to_string(&module_path[..]),
+               module_to_string(&*module_));
+
+        // First, resolve the module path for the directive, if necessary.
+        let container = if module_path.len() == 0 {
+            // Use the crate root.
+            Some((self.resolver.graph_root.get_module(), LastMod(AllPublic)))
+        } else {
+            match self.resolver.resolve_module_path(module_.clone(),
+                                                    &module_path[..],
+                                                    UseLexicalScopeFlag::DontUseLexicalScope,
+                                                    import_directive.span,
+                                                    NameSearchType::ImportSearch) {
+                ResolveResult::Failed(err) => {
+                    resolution_result = ResolveResult::Failed(err);
+                    None
+                },
+                ResolveResult::Indeterminate => {
+                    resolution_result = ResolveResult::Indeterminate;
+                    None
+                }
+                ResolveResult::Success(container) => Some(container),
+            }
+        };
+
+        match container {
+            None => {}
+            Some((containing_module, lp)) => {
+                // We found the module that the target is contained
+                // within. Attempt to resolve the import within it.
+
+                match import_directive.subclass {
+                    SingleImport(target, source) => {
+                        resolution_result =
+                            self.resolve_single_import(&module_,
+                                                       containing_module,
+                                                       target,
+                                                       source,
+                                                       import_directive,
+                                                       lp);
+                    }
+                    GlobImport => {
+                        resolution_result =
+                            self.resolve_glob_import(&module_,
+                                                     containing_module,
+                                                     import_directive,
+                                                     lp);
+                    }
+                }
+            }
+        }
+
+        // Decrement the count of unresolved imports.
+        match resolution_result {
+            ResolveResult::Success(()) => {
+                assert!(self.resolver.unresolved_imports >= 1);
+                self.resolver.unresolved_imports -= 1;
+            }
+            _ => {
+                // Nothing to do here; just return the error.
+            }
+        }
+
+        // Decrement the count of unresolved globs if necessary. But only if
+        // the resolution result is indeterminate -- otherwise we'll stop
+        // processing imports here. (See the loop in
+        // resolve_imports_for_module).
+
+        if !resolution_result.indeterminate() {
+            match import_directive.subclass {
+                GlobImport => {
+                    assert!(module_.glob_count.get() >= 1);
+                    module_.glob_count.set(module_.glob_count.get() - 1);
+                }
+                SingleImport(..) => {
+                    // Ignore.
+                }
+            }
+        }
+
+        return resolution_result;
+    }
+
+    fn resolve_single_import(&mut self,
+                             module_: &Module,
+                             target_module: Rc<Module>,
+                             target: Name,
+                             source: Name,
+                             directive: &ImportDirective,
+                             lp: LastPrivate)
+                             -> ResolveResult<()> {
+        debug!("(resolving single import) resolving `{}` = `{}::{}` from \
+                `{}` id {}, last private {:?}",
+               token::get_name(target),
+               module_to_string(&*target_module),
+               token::get_name(source),
+               module_to_string(module_),
+               directive.id,
+               lp);
+
+        let lp = match lp {
+            LastMod(lp) => lp,
+            LastImport {..} => {
+                self.resolver.session
+                    .span_bug(directive.span,
+                              "not expecting Import here, must be LastMod")
+            }
+        };
+
+        // We need to resolve both namespaces for this to succeed.
+        //
+
+        let mut value_result = UnknownResult;
+        let mut type_result = UnknownResult;
+
+        // Search for direct children of the containing module.
+        build_reduced_graph::populate_module_if_necessary(self.resolver, &target_module);
+
+        match target_module.children.borrow().get(&source) {
+            None => {
+                // Continue.
+            }
+            Some(ref child_name_bindings) => {
+                // pub_err makes sure we don't give the same error twice.
+                let mut pub_err = false;
+                if child_name_bindings.defined_in_namespace(ValueNS) {
+                    debug!("(resolving single import) found value binding");
+                    value_result = BoundResult(target_module.clone(),
+                                               (*child_name_bindings).clone());
+                    if directive.is_public && !child_name_bindings.is_public(ValueNS) {
+                        let msg = format!("`{}` is private", token::get_name(source));
+                        span_err!(self.resolver.session, directive.span, E0364, "{}", &msg);
+                        pub_err = true;
+                    }
+                }
+                if child_name_bindings.defined_in_namespace(TypeNS) {
+                    debug!("(resolving single import) found type binding");
+                    type_result = BoundResult(target_module.clone(),
+                                              (*child_name_bindings).clone());
+                    if !pub_err && directive.is_public && !child_name_bindings.is_public(TypeNS) {
+                        let msg = format!("`{}` is private", token::get_name(source));
+                        span_err!(self.resolver.session, directive.span, E0365, "{}", &msg);
+                    }
+                }
+            }
+        }
+
+        // Unless we managed to find a result in both namespaces (unlikely),
+        // search imports as well.
+        let mut value_used_reexport = false;
+        let mut type_used_reexport = false;
+        match (value_result.clone(), type_result.clone()) {
+            (BoundResult(..), BoundResult(..)) => {} // Continue.
+            _ => {
+                // If there is an unresolved glob at this point in the
+                // containing module, bail out. We don't know enough to be
+                // able to resolve this import.
+
+                if target_module.glob_count.get() > 0 {
+                    debug!("(resolving single import) unresolved glob; \
+                            bailing out");
+                    return ResolveResult::Indeterminate;
+                }
+
+                // Now search the exported imports within the containing module.
+                match target_module.import_resolutions.borrow().get(&source) {
+                    None => {
+                        debug!("(resolving single import) no import");
+                        // The containing module definitely doesn't have an
+                        // exported import with the name in question. We can
+                        // therefore accurately report that the names are
+                        // unbound.
+
+                        if value_result.is_unknown() {
+                            value_result = UnboundResult;
+                        }
+                        if type_result.is_unknown() {
+                            type_result = UnboundResult;
+                        }
+                    }
+                    Some(import_resolution)
+                            if import_resolution.outstanding_references == 0 => {
+
+                        fn get_binding(this: &mut Resolver,
+                                       import_resolution: &ImportResolution,
+                                       namespace: Namespace,
+                                       source: &Name)
+                                    -> NamespaceResult {
+
+                            // Import resolutions must be declared with "pub"
+                            // in order to be exported.
+                            if !import_resolution.is_public {
+                                return UnboundResult;
+                            }
+
+                            match import_resolution.target_for_namespace(namespace) {
+                                None => {
+                                    return UnboundResult;
+                                }
+                                Some(Target {
+                                    target_module,
+                                    bindings,
+                                    shadowable: _
+                                }) => {
+                                    debug!("(resolving single import) found \
+                                            import in ns {:?}", namespace);
+                                    let id = import_resolution.id(namespace);
+                                    // track used imports and extern crates as well
+                                    this.used_imports.insert((id, namespace));
+                                    this.record_import_use(id, *source);
+                                    match target_module.def_id.get() {
+                                        Some(DefId{krate: kid, ..}) => {
+                                            this.used_crates.insert(kid);
+                                        },
+                                        _ => {}
+                                    }
+                                    return BoundResult(target_module, bindings);
+                                }
+                            }
+                        }
+
+                        // The name is an import which has been fully
+                        // resolved. We can, therefore, just follow it.
+                        if value_result.is_unknown() {
+                            value_result = get_binding(self.resolver,
+                                                       import_resolution,
+                                                       ValueNS,
+                                                       &source);
+                            value_used_reexport = import_resolution.is_public;
+                        }
+                        if type_result.is_unknown() {
+                            type_result = get_binding(self.resolver,
+                                                      import_resolution,
+                                                      TypeNS,
+                                                      &source);
+                            type_used_reexport = import_resolution.is_public;
+                        }
+
+                    }
+                    Some(_) => {
+                        // If target_module is the same module whose import we are resolving
+                        // and there it has an unresolved import with the same name as `source`,
+                        // then the user is actually trying to import an item that is declared
+                        // in the same scope
+                        //
+                        // e.g
+                        // use self::submodule;
+                        // pub mod submodule;
+                        //
+                        // In this case we continue as if we resolved the import and let the
+                        // check_for_conflicts_between_imports_and_items call below handle
+                        // the conflict
+                        match (module_.def_id.get(),  target_module.def_id.get()) {
+                            (Some(id1), Some(id2)) if id1 == id2  => {
+                                if value_result.is_unknown() {
+                                    value_result = UnboundResult;
+                                }
+                                if type_result.is_unknown() {
+                                    type_result = UnboundResult;
+                                }
+                            }
+                            _ =>  {
+                                // The import is unresolved. Bail out.
+                                debug!("(resolving single import) unresolved import; \
+                                        bailing out");
+                                return ResolveResult::Indeterminate;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        let mut value_used_public = false;
+        let mut type_used_public = false;
+
+        // If we didn't find a result in the type namespace, search the
+        // external modules.
+        match type_result {
+            BoundResult(..) => {}
+            _ => {
+                match target_module.external_module_children.borrow_mut().get(&source).cloned() {
+                    None => {} // Continue.
+                    Some(module) => {
+                        debug!("(resolving single import) found external module");
+                        // track the module as used.
+                        match module.def_id.get() {
+                            Some(DefId{krate: kid, ..}) => {
+                                self.resolver.used_crates.insert(kid);
+                            }
+                            _ => {}
+                        }
+                        let name_bindings =
+                            Rc::new(Resolver::create_name_bindings_from_module(module));
+                        type_result = BoundResult(target_module.clone(), name_bindings);
+                        type_used_public = true;
+                    }
+                }
+            }
+        }
+
+        // We've successfully resolved the import. Write the results in.
+        let mut import_resolutions = module_.import_resolutions.borrow_mut();
+        let import_resolution = &mut (*import_resolutions)[target];
+
+        {
+            let mut check_and_write_import = |namespace, result: &_, used_public: &mut bool| {
+                let namespace_name = match namespace {
+                    TypeNS => "type",
+                    ValueNS => "value",
+                };
+
+                match *result {
+                    BoundResult(ref target_module, ref name_bindings) => {
+                        debug!("(resolving single import) found {:?} target: {:?}",
+                               namespace_name,
+                               name_bindings.def_for_namespace(namespace));
+                        self.check_for_conflicting_import(
+                            &import_resolution.target_for_namespace(namespace),
+                            directive.span,
+                            target,
+                            namespace);
+
+                        self.check_that_import_is_importable(
+                            &**name_bindings,
+                            directive.span,
+                            target,
+                            namespace);
+
+                        let target = Some(Target::new(target_module.clone(),
+                                                      name_bindings.clone(),
+                                                      directive.shadowable));
+                        import_resolution.set_target_and_id(namespace, target, directive.id);
+                        import_resolution.is_public = directive.is_public;
+                        *used_public = name_bindings.defined_in_public_namespace(namespace);
+                    }
+                    UnboundResult => { /* Continue. */ }
+                    UnknownResult => {
+                        panic!("{:?} result should be known at this point", namespace_name);
+                    }
+                }
+            };
+            check_and_write_import(ValueNS, &value_result, &mut value_used_public);
+            check_and_write_import(TypeNS, &type_result, &mut type_used_public);
+        }
+
+        self.check_for_conflicts_between_imports_and_items(
+            module_,
+            import_resolution,
+            directive.span,
+            target);
+
+        if value_result.is_unbound() && type_result.is_unbound() {
+            let msg = format!("There is no `{}` in `{}`",
+                              token::get_name(source),
+                              module_to_string(&target_module));
+            return ResolveResult::Failed(Some((directive.span, msg)));
+        }
+        let value_used_public = value_used_reexport || value_used_public;
+        let type_used_public = type_used_reexport || type_used_public;
+
+        assert!(import_resolution.outstanding_references >= 1);
+        import_resolution.outstanding_references -= 1;
+
+        // Record what this import resolves to for later uses in documentation,
+        // this may resolve to either a value or a type, but for documentation
+        // purposes it's good enough to just favor one over the other.
+        let value_def_and_priv = import_resolution.value_target.as_ref().map(|target| {
+            let def = target.bindings.def_for_namespace(ValueNS).unwrap();
+            (def, if value_used_public { lp } else { DependsOn(def.def_id()) })
+        });
+        let type_def_and_priv = import_resolution.type_target.as_ref().map(|target| {
+            let def = target.bindings.def_for_namespace(TypeNS).unwrap();
+            (def, if type_used_public { lp } else { DependsOn(def.def_id()) })
+        });
+
+        let import_lp = LastImport {
+            value_priv: value_def_and_priv.map(|(_, p)| p),
+            value_used: Used,
+            type_priv: type_def_and_priv.map(|(_, p)| p),
+            type_used: Used
+        };
+
+        if let Some((def, _)) = value_def_and_priv {
+            self.resolver.def_map.borrow_mut().insert(directive.id, PathResolution {
+                base_def: def,
+                last_private: import_lp,
+                depth: 0
+            });
+        }
+        if let Some((def, _)) = type_def_and_priv {
+            self.resolver.def_map.borrow_mut().insert(directive.id, PathResolution {
+                base_def: def,
+                last_private: import_lp,
+                depth: 0
+            });
+        }
+
+        debug!("(resolving single import) successfully resolved import");
+        return ResolveResult::Success(());
+    }
+
+    // Resolves a glob import. Note that this function cannot fail; it either
+    // succeeds or bails out (as importing * from an empty module or a module
+    // that exports nothing is valid). target_module is the module we are
+    // actually importing, i.e., `foo` in `use foo::*`.
+    fn resolve_glob_import(&mut self,
+                           module_: &Module,
+                           target_module: Rc<Module>,
+                           import_directive: &ImportDirective,
+                           lp: LastPrivate)
+                           -> ResolveResult<()> {
+        let id = import_directive.id;
+        let is_public = import_directive.is_public;
+
+        // This function works in a highly imperative manner; it eagerly adds
+        // everything it can to the list of import resolutions of the module
+        // node.
+        debug!("(resolving glob import) resolving glob import {}", id);
+
+        // We must bail out if the node has unresolved imports of any kind
+        // (including globs).
+        if !(*target_module).all_imports_resolved() {
+            debug!("(resolving glob import) target module has unresolved \
+                    imports; bailing out");
+            return ResolveResult::Indeterminate;
+        }
+
+        assert_eq!(target_module.glob_count.get(), 0);
+
+        // Add all resolved imports from the containing module.
+        let import_resolutions = target_module.import_resolutions.borrow();
+        for (ident, target_import_resolution) in &*import_resolutions {
+            debug!("(resolving glob import) writing module resolution \
+                    {} into `{}`",
+                   token::get_name(*ident),
+                   module_to_string(module_));
+
+            if !target_import_resolution.is_public {
+                debug!("(resolving glob import) nevermind, just kidding");
+                continue
+            }
+
+            // Here we merge two import resolutions.
+            let mut import_resolutions = module_.import_resolutions.borrow_mut();
+            match import_resolutions.get_mut(ident) {
+                Some(dest_import_resolution) => {
+                    // Merge the two import resolutions at a finer-grained
+                    // level.
+
+                    match target_import_resolution.value_target {
+                        None => {
+                            // Continue.
+                        }
+                        Some(ref value_target) => {
+                            self.check_for_conflicting_import(&dest_import_resolution.value_target,
+                                                              import_directive.span,
+                                                              *ident,
+                                                              ValueNS);
+                            dest_import_resolution.value_target = Some(value_target.clone());
+                        }
+                    }
+                    match target_import_resolution.type_target {
+                        None => {
+                            // Continue.
+                        }
+                        Some(ref type_target) => {
+                            self.check_for_conflicting_import(&dest_import_resolution.type_target,
+                                                              import_directive.span,
+                                                              *ident,
+                                                              TypeNS);
+                            dest_import_resolution.type_target = Some(type_target.clone());
+                        }
+                    }
+                    dest_import_resolution.is_public = is_public;
+                    continue;
+                }
+                None => {}
+            }
+
+            // Simple: just copy the old import resolution.
+            let mut new_import_resolution = ImportResolution::new(id, is_public);
+            new_import_resolution.value_target =
+                target_import_resolution.value_target.clone();
+            new_import_resolution.type_target =
+                target_import_resolution.type_target.clone();
+
+            import_resolutions.insert(*ident, new_import_resolution);
+        }
+
+        // Add all children from the containing module.
+        build_reduced_graph::populate_module_if_necessary(self.resolver, &target_module);
+
+        for (&name, name_bindings) in &*target_module.children.borrow() {
+            self.merge_import_resolution(module_,
+                                         target_module.clone(),
+                                         import_directive,
+                                         name,
+                                         name_bindings.clone());
+
+        }
+
+        // Add external module children from the containing module.
+        for (&name, module) in &*target_module.external_module_children.borrow() {
+            let name_bindings =
+                Rc::new(Resolver::create_name_bindings_from_module(module.clone()));
+            self.merge_import_resolution(module_,
+                                         target_module.clone(),
+                                         import_directive,
+                                         name,
+                                         name_bindings);
+        }
+
+        // Record the destination of this import
+        if let Some(did) = target_module.def_id.get() {
+            self.resolver.def_map.borrow_mut().insert(id, PathResolution {
+                base_def: DefMod(did),
+                last_private: lp,
+                depth: 0
+            });
+        }
+
+        debug!("(resolving glob import) successfully resolved import");
+        return ResolveResult::Success(());
+    }
+
+    fn merge_import_resolution(&mut self,
+                               module_: &Module,
+                               containing_module: Rc<Module>,
+                               import_directive: &ImportDirective,
+                               name: Name,
+                               name_bindings: Rc<NameBindings>) {
+        let id = import_directive.id;
+        let is_public = import_directive.is_public;
+
+        let mut import_resolutions = module_.import_resolutions.borrow_mut();
+        let dest_import_resolution = import_resolutions.entry(name).get().unwrap_or_else(
+            |vacant_entry| {
+                // Create a new import resolution from this child.
+                vacant_entry.insert(ImportResolution::new(id, is_public))
+            });
+
+        debug!("(resolving glob import) writing resolution `{}` in `{}` \
+               to `{}`",
+               &token::get_name(name),
+               module_to_string(&*containing_module),
+               module_to_string(module_));
+
+        // Merge the child item into the import resolution.
+        {
+            let mut merge_child_item = |namespace| {
+                if name_bindings.defined_in_namespace_with(namespace, IMPORTABLE | PUBLIC) {
+                    let namespace_name = match namespace {
+                        TypeNS => "type",
+                        ValueNS => "value",
+                    };
+                    debug!("(resolving glob import) ... for {} target", namespace_name);
+                    if dest_import_resolution.shadowable(namespace) == Shadowable::Never {
+                        let msg = format!("a {} named `{}` has already been imported \
+                                           in this module",
+                                          namespace_name,
+                                          &token::get_name(name));
+                        span_err!(self.resolver.session, import_directive.span, E0251, "{}", msg);
+                    } else {
+                        let target = Target::new(containing_module.clone(),
+                                                 name_bindings.clone(),
+                                                 import_directive.shadowable);
+                        dest_import_resolution.set_target_and_id(namespace,
+                                                                 Some(target),
+                                                                 id);
+                    }
+                }
+            };
+            merge_child_item(ValueNS);
+            merge_child_item(TypeNS);
+        }
+
+        dest_import_resolution.is_public = is_public;
+
+        self.check_for_conflicts_between_imports_and_items(
+            module_,
+            dest_import_resolution,
+            import_directive.span,
+            name);
+    }
+
+    /// Checks that imported names and items don't have the same name.
+    fn check_for_conflicting_import(&mut self,
+                                    target: &Option<Target>,
+                                    import_span: Span,
+                                    name: Name,
+                                    namespace: Namespace) {
+        debug!("check_for_conflicting_import: {}; target exists: {}",
+               &token::get_name(name),
+               target.is_some());
+
+        match *target {
+            Some(ref target) if target.shadowable != Shadowable::Always => {
+                let msg = format!("a {} named `{}` has already been imported \
+                                   in this module",
+                                  match namespace {
+                                    TypeNS => "type",
+                                    ValueNS => "value",
+                                  },
+                                  &token::get_name(name));
+                span_err!(self.resolver.session, import_span, E0252, "{}", &msg[..]);
+            }
+            Some(_) | None => {}
+        }
+    }
+
+    /// Checks that an import is actually importable
+    fn check_that_import_is_importable(&mut self,
+                                       name_bindings: &NameBindings,
+                                       import_span: Span,
+                                       name: Name,
+                                       namespace: Namespace) {
+        if !name_bindings.defined_in_namespace_with(namespace, IMPORTABLE) {
+            let msg = format!("`{}` is not directly importable",
+                              token::get_name(name));
+            span_err!(self.resolver.session, import_span, E0253, "{}", &msg[..]);
+        }
+    }
+
+    /// Checks that imported names and items don't have the same name.
+    fn check_for_conflicts_between_imports_and_items(&mut self,
+                                                     module: &Module,
+                                                     import_resolution:
+                                                     &ImportResolution,
+                                                     import_span: Span,
+                                                     name: Name) {
+        // First, check for conflicts between imports and `extern crate`s.
+        if module.external_module_children
+                 .borrow()
+                 .contains_key(&name) {
+            match import_resolution.type_target {
+                Some(ref target) if target.shadowable != Shadowable::Always => {
+                    let msg = format!("import `{0}` conflicts with imported \
+                                       crate in this module \
+                                       (maybe you meant `use {0}::*`?)",
+                                      &token::get_name(name));
+                    span_err!(self.resolver.session, import_span, E0254, "{}", &msg[..]);
+                }
+                Some(_) | None => {}
+            }
+        }
+
+        // Check for item conflicts.
+        let children = module.children.borrow();
+        let name_bindings = match children.get(&name) {
+            None => {
+                // There can't be any conflicts.
+                return
+            }
+            Some(ref name_bindings) => (*name_bindings).clone(),
+        };
+
+        match import_resolution.value_target {
+            Some(ref target) if target.shadowable != Shadowable::Always => {
+                if let Some(ref value) = *name_bindings.value_def.borrow() {
+                    span_err!(self.resolver.session, import_span, E0255,
+                              "import `{}` conflicts with value in this module",
+                              &token::get_name(name));
+                    if let Some(span) = value.value_span {
+                        self.resolver.session.span_note(span, "conflicting value here");
+                    }
+                }
+            }
+            Some(_) | None => {}
+        }
+
+        match import_resolution.type_target {
+            Some(ref target) if target.shadowable != Shadowable::Always => {
+                if let Some(ref ty) = *name_bindings.type_def.borrow() {
+                    let (what, note) = if ty.module_def.is_some() {
+                        ("existing submodule", "note conflicting module here")
+                    } else {
+                        ("type in this module", "note conflicting type here")
+                    };
+                    span_err!(self.resolver.session, import_span, E0256,
+                              "import `{}` conflicts with {}",
+                              &token::get_name(name), what);
+                    if let Some(span) = ty.type_span {
+                        self.resolver.session.span_note(span, note);
+                    }
+                }
+            }
+            Some(_) | None => {}
+        }
+    }
+}
+
+fn import_path_to_string(names: &[Name],
+                         subclass: ImportDirectiveSubclass)
+                         -> String {
+    if names.is_empty() {
+        import_directive_subclass_to_string(subclass)
+    } else {
+        (format!("{}::{}",
+                 names_to_string(names),
+                 import_directive_subclass_to_string(subclass))).to_string()
+    }
+}
+
+fn import_directive_subclass_to_string(subclass: ImportDirectiveSubclass) -> String {
+    match subclass {
+        SingleImport(_, source) => {
+            token::get_name(source).to_string()
+        }
+        GlobImport => "*".to_string()
+    }
+}
+
+pub fn resolve_imports(resolver: &mut Resolver) {
+    let mut import_resolver = ImportResolver {
+        resolver: resolver,
+    };
+    import_resolver.resolve_imports();
+}
diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs
index 3087a8ea45d..34a23f3efac 100644
--- a/src/librustc_trans/back/link.rs
+++ b/src/librustc_trans/back/link.rs
@@ -626,12 +626,7 @@ fn link_rlib<'a>(sess: &'a Session,
                                                  e))
                 }
 
-                let bc_data_deflated = match flate::deflate_bytes(&bc_data[..]) {
-                    Some(compressed) => compressed,
-                    None => sess.fatal(&format!("failed to compress bytecode \
-                                                 from {}",
-                                                 bc_filename.display()))
-                };
+                let bc_data_deflated = flate::deflate_bytes(&bc_data[..]);
 
                 let mut bc_file_deflated = match fs::File::create(&bc_deflated_filename) {
                     Ok(file) => file,
diff --git a/src/librustc_trans/back/lto.rs b/src/librustc_trans/back/lto.rs
index 219f48f78dc..a3ab863c4ec 100644
--- a/src/librustc_trans/back/lto.rs
+++ b/src/librustc_trans/back/lto.rs
@@ -95,8 +95,8 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
                             (link::RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET + data_size as uint)];
 
                         match flate::inflate_bytes(compressed_data) {
-                            Some(inflated) => inflated,
-                            None => {
+                            Ok(inflated) => inflated,
+                            Err(_) => {
                                 sess.fatal(&format!("failed to decompress bc of `{}`",
                                                    name))
                             }
@@ -111,8 +111,8 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
                 // the object must be in the old, pre-versioning format, so simply
                 // inflate everything and let LLVM decide if it can make sense of it
                     match flate::inflate_bytes(bc_encoded) {
-                        Some(bc) => bc,
-                        None => {
+                        Ok(bc) => bc,
+                        Err(_) => {
                             sess.fatal(&format!("failed to decompress bc of `{}`",
                                                name))
                         }
diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs
index ccf24f7e859..e9f58ec53df 100644
--- a/src/librustc_trans/trans/base.rs
+++ b/src/librustc_trans/trans/base.rs
@@ -2974,10 +2974,7 @@ pub fn write_metadata(cx: &SharedCrateContext, krate: &ast::Crate) -> Vec<u8> {
     let encode_parms = crate_ctxt_to_encode_parms(cx, encode_inlined_item);
     let metadata = encoder::encode_metadata(encode_parms, krate);
     let mut compressed = encoder::metadata_encoding_version.to_vec();
-    compressed.push_all(&match flate::deflate_bytes(&metadata) {
-        Some(compressed) => compressed,
-        None => cx.sess().fatal("failed to compress metadata"),
-    });
+    compressed.push_all(&flate::deflate_bytes(&metadata));
     let llmeta = C_bytes_in_context(cx.metadata_llcx(), &compressed[..]);
     let llconst = C_struct_in_context(cx.metadata_llcx(), &[llmeta], false);
     let name = format!("rust_metadata_{}_{}",
diff --git a/src/librustc_trans/trans/callee.rs b/src/librustc_trans/trans/callee.rs
index 861233bafdf..cf36ec1f3ed 100644
--- a/src/librustc_trans/trans/callee.rs
+++ b/src/librustc_trans/trans/callee.rs
@@ -253,7 +253,7 @@ fn trans_fn_ref_with_substs_to_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 /// Translates an adapter that implements the `Fn` trait for a fn
 /// pointer. This is basically the equivalent of something like:
 ///
-/// ```rust
+/// ```
 /// impl<'a> Fn(&'a int) -> &'a int for fn(&int) -> &int {
 ///     extern "rust-abi" fn call(&self, args: (&'a int,)) -> &'a int {
 ///         (*self)(args.0)
diff --git a/src/librustc_trans/trans/closure.rs b/src/librustc_trans/trans/closure.rs
index 7fa26a7c128..c1bc7219ad8 100644
--- a/src/librustc_trans/trans/closure.rs
+++ b/src/librustc_trans/trans/closure.rs
@@ -259,4 +259,3 @@ pub fn trans_closure_expr<'a, 'tcx>(dest: Dest<'a, 'tcx>,
 
     Some(bcx)
 }
-
diff --git a/src/librustc_trans/trans/llrepr.rs b/src/librustc_trans/trans/llrepr.rs
index de0f714276d..6dd56679797 100644
--- a/src/librustc_trans/trans/llrepr.rs
+++ b/src/librustc_trans/trans/llrepr.rs
@@ -34,5 +34,3 @@ impl LlvmRepr for ValueRef {
         ccx.tn().val_to_string(*self)
     }
 }
-
-
diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs
index 0d4edc01a4c..32f91a175f3 100644
--- a/src/librustc_typeck/check/closure.rs
+++ b/src/librustc_typeck/check/closure.rs
@@ -248,5 +248,3 @@ fn self_type_matches_expected_vid<'a,'tcx>(
         _ => None,
     }
 }
-
-
diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs
index 302bcfc0602..bc581a6af41 100644
--- a/src/librustc_typeck/check/method/probe.rs
+++ b/src/librustc_typeck/check/method/probe.rs
@@ -289,11 +289,87 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
             ty::ty_param(p) => {
                 self.assemble_inherent_candidates_from_param(self_ty, p);
             }
+            ty::ty_char => {
+                let lang_def_id = self.tcx().lang_items.char_impl();
+                self.assemble_inherent_impl_for_primitive(lang_def_id);
+            }
+            ty::ty_str => {
+                let lang_def_id = self.tcx().lang_items.str_impl();
+                self.assemble_inherent_impl_for_primitive(lang_def_id);
+            }
+            ty::ty_vec(_, None) => {
+                let lang_def_id = self.tcx().lang_items.slice_impl();
+                self.assemble_inherent_impl_for_primitive(lang_def_id);
+            }
+            ty::ty_ptr(ty::mt { ty: _, mutbl: ast::MutImmutable }) => {
+                let lang_def_id = self.tcx().lang_items.const_ptr_impl();
+                self.assemble_inherent_impl_for_primitive(lang_def_id);
+            }
+            ty::ty_ptr(ty::mt { ty: _, mutbl: ast::MutMutable }) => {
+                let lang_def_id = self.tcx().lang_items.mut_ptr_impl();
+                self.assemble_inherent_impl_for_primitive(lang_def_id);
+            }
+            ty::ty_int(ast::TyI8) => {
+                let lang_def_id = self.tcx().lang_items.i8_impl();
+                self.assemble_inherent_impl_for_primitive(lang_def_id);
+            }
+            ty::ty_int(ast::TyI16) => {
+                let lang_def_id = self.tcx().lang_items.i16_impl();
+                self.assemble_inherent_impl_for_primitive(lang_def_id);
+            }
+            ty::ty_int(ast::TyI32) => {
+                let lang_def_id = self.tcx().lang_items.i32_impl();
+                self.assemble_inherent_impl_for_primitive(lang_def_id);
+            }
+            ty::ty_int(ast::TyI64) => {
+                let lang_def_id = self.tcx().lang_items.i64_impl();
+                self.assemble_inherent_impl_for_primitive(lang_def_id);
+            }
+            ty::ty_int(ast::TyIs(_)) => {
+                let lang_def_id = self.tcx().lang_items.isize_impl();
+                self.assemble_inherent_impl_for_primitive(lang_def_id);
+            }
+            ty::ty_uint(ast::TyU8) => {
+                let lang_def_id = self.tcx().lang_items.u8_impl();
+                self.assemble_inherent_impl_for_primitive(lang_def_id);
+            }
+            ty::ty_uint(ast::TyU16) => {
+                let lang_def_id = self.tcx().lang_items.u16_impl();
+                self.assemble_inherent_impl_for_primitive(lang_def_id);
+            }
+            ty::ty_uint(ast::TyU32) => {
+                let lang_def_id = self.tcx().lang_items.u32_impl();
+                self.assemble_inherent_impl_for_primitive(lang_def_id);
+            }
+            ty::ty_uint(ast::TyU64) => {
+                let lang_def_id = self.tcx().lang_items.u64_impl();
+                self.assemble_inherent_impl_for_primitive(lang_def_id);
+            }
+            ty::ty_uint(ast::TyUs(_)) => {
+                let lang_def_id = self.tcx().lang_items.usize_impl();
+                self.assemble_inherent_impl_for_primitive(lang_def_id);
+            }
+            ty::ty_float(ast::TyF32) => {
+                let lang_def_id = self.tcx().lang_items.f32_impl();
+                self.assemble_inherent_impl_for_primitive(lang_def_id);
+            }
+            ty::ty_float(ast::TyF64) => {
+                let lang_def_id = self.tcx().lang_items.f64_impl();
+                self.assemble_inherent_impl_for_primitive(lang_def_id);
+            }
             _ => {
             }
         }
     }
 
+    fn assemble_inherent_impl_for_primitive(&mut self, lang_def_id: Option<ast::DefId>) {
+        if let Some(impl_def_id) = lang_def_id {
+            ty::populate_implementations_for_primitive_if_necessary(self.tcx(), impl_def_id);
+
+            self.assemble_inherent_impl_probe(impl_def_id);
+        }
+    }
+
     fn assemble_inherent_impl_candidates_for_type(&mut self, def_id: ast::DefId) {
         // Read the inherent implementation candidates for this type from the
         // metadata if necessary.
diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs
index f452c8488ce..17fc2aad286 100644
--- a/src/librustc_typeck/check/upvar.rs
+++ b/src/librustc_typeck/check/upvar.rs
@@ -556,5 +556,3 @@ impl<'a,'tcx> euv::Delegate<'tcx> for AdjustBorrowKind<'a,'tcx> {
         self.adjust_upvar_borrow_kind_for_mut(assignee_cmt);
     }
 }
-
-
diff --git a/src/librustc_typeck/check/vtable.rs b/src/librustc_typeck/check/vtable.rs
index 630530cf11f..963be9aa2e2 100644
--- a/src/librustc_typeck/check/vtable.rs
+++ b/src/librustc_typeck/check/vtable.rs
@@ -302,4 +302,3 @@ pub fn select_new_fcx_obligations(fcx: &FnCtxt) {
         Err(errors) => { report_fulfillment_errors(fcx.infcx(), &errors); }
     }
 }
-
diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs
index 5dfe80cfcb2..ab694d26b15 100644
--- a/src/librustc_typeck/coherence/orphan.rs
+++ b/src/librustc_typeck/coherence/orphan.rs
@@ -16,6 +16,7 @@ use middle::ty;
 use syntax::ast::{Item, ItemImpl};
 use syntax::ast;
 use syntax::ast_util;
+use syntax::codemap::Span;
 use syntax::visit;
 use util::ppaux::{Repr, UserString};
 
@@ -38,6 +39,23 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
         }
     }
 
+    fn check_primitive_impl(&self,
+                            impl_def_id: ast::DefId,
+                            lang_def_id: Option<ast::DefId>,
+                            lang: &str,
+                            ty: &str,
+                            span: Span) {
+        match lang_def_id {
+            Some(lang_def_id) if lang_def_id == impl_def_id => { /* OK */ },
+            _ => {
+                self.tcx.sess.span_err(
+                    span,
+                    &format!("only a single inherent implementation marked with `#[lang = \"{}\"]` \
+                              is allowed for the `{}` primitive", lang, ty));
+            }
+        }
+    }
+
     /// Checks exactly one impl for orphan rules and other such
     /// restrictions.  In this fn, it can happen that multiple errors
     /// apply to a specific impl, so just return after reporting one
@@ -62,6 +80,125 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
                     ty::ty_uniq(..) => {
                         self.check_def_id(item, self.tcx.lang_items.owned_box().unwrap());
                     }
+                    ty::ty_char => {
+                        self.check_primitive_impl(def_id,
+                                                  self.tcx.lang_items.char_impl(),
+                                                  "char",
+                                                  "char",
+                                                  item.span);
+                    }
+                    ty::ty_str => {
+                        self.check_primitive_impl(def_id,
+                                                  self.tcx.lang_items.str_impl(),
+                                                  "str",
+                                                  "str",
+                                                  item.span);
+                    }
+                    ty::ty_vec(_, None) => {
+                        self.check_primitive_impl(def_id,
+                                                  self.tcx.lang_items.slice_impl(),
+                                                  "slice",
+                                                  "[T]",
+                                                  item.span);
+                    }
+                    ty::ty_ptr(ty::mt { ty: _, mutbl: ast::MutImmutable }) => {
+                        self.check_primitive_impl(def_id,
+                                                  self.tcx.lang_items.const_ptr_impl(),
+                                                  "const_ptr",
+                                                  "*const T",
+                                                  item.span);
+                    }
+                    ty::ty_ptr(ty::mt { ty: _, mutbl: ast::MutMutable }) => {
+                        self.check_primitive_impl(def_id,
+                                                  self.tcx.lang_items.mut_ptr_impl(),
+                                                  "mut_ptr",
+                                                  "*mut T",
+                                                  item.span);
+                    }
+                    ty::ty_int(ast::TyI8) => {
+                        self.check_primitive_impl(def_id,
+                                                  self.tcx.lang_items.i8_impl(),
+                                                  "i8",
+                                                  "i8",
+                                                  item.span);
+                    }
+                    ty::ty_int(ast::TyI16) => {
+                        self.check_primitive_impl(def_id,
+                                                  self.tcx.lang_items.i16_impl(),
+                                                  "i16",
+                                                  "i16",
+                                                  item.span);
+                    }
+                    ty::ty_int(ast::TyI32) => {
+                        self.check_primitive_impl(def_id,
+                                                  self.tcx.lang_items.i32_impl(),
+                                                  "i32",
+                                                  "i32",
+                                                  item.span);
+                    }
+                    ty::ty_int(ast::TyI64) => {
+                        self.check_primitive_impl(def_id,
+                                                  self.tcx.lang_items.i64_impl(),
+                                                  "i64",
+                                                  "i64",
+                                                  item.span);
+                    }
+                    ty::ty_int(ast::TyIs(_)) => {
+                        self.check_primitive_impl(def_id,
+                                                  self.tcx.lang_items.isize_impl(),
+                                                  "isize",
+                                                  "isize",
+                                                  item.span);
+                    }
+                    ty::ty_uint(ast::TyU8) => {
+                        self.check_primitive_impl(def_id,
+                                                  self.tcx.lang_items.u8_impl(),
+                                                  "u8",
+                                                  "u8",
+                                                  item.span);
+                    }
+                    ty::ty_uint(ast::TyU16) => {
+                        self.check_primitive_impl(def_id,
+                                                  self.tcx.lang_items.u16_impl(),
+                                                  "u16",
+                                                  "u16",
+                                                  item.span);
+                    }
+                    ty::ty_uint(ast::TyU32) => {
+                        self.check_primitive_impl(def_id,
+                                                  self.tcx.lang_items.u32_impl(),
+                                                  "u32",
+                                                  "u32",
+                                                  item.span);
+                    }
+                    ty::ty_uint(ast::TyU64) => {
+                        self.check_primitive_impl(def_id,
+                                                  self.tcx.lang_items.u64_impl(),
+                                                  "u64",
+                                                  "u64",
+                                                  item.span);
+                    }
+                    ty::ty_uint(ast::TyUs(_)) => {
+                        self.check_primitive_impl(def_id,
+                                                  self.tcx.lang_items.usize_impl(),
+                                                  "usize",
+                                                  "usize",
+                                                  item.span);
+                    }
+                    ty::ty_float(ast::TyF32) => {
+                        self.check_primitive_impl(def_id,
+                                                  self.tcx.lang_items.f32_impl(),
+                                                  "f32",
+                                                  "f32",
+                                                  item.span);
+                    }
+                    ty::ty_float(ast::TyF64) => {
+                        self.check_primitive_impl(def_id,
+                                                  self.tcx.lang_items.f64_impl(),
+                                                  "f64",
+                                                  "f64",
+                                                  item.span);
+                    }
                     _ => {
                         span_err!(self.tcx.sess, item.span, E0118,
                                   "no base type found for inherent implementation; \
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs
index 03fa269ccf8..396d060de9e 100644
--- a/src/librustc_typeck/diagnostics.rs
+++ b/src/librustc_typeck/diagnostics.rs
@@ -181,4 +181,3 @@ register_diagnostics! {
 }
 
 __build_diagnostic_array! { DIAGNOSTICS }
-
diff --git a/src/librustc_typeck/variance.rs b/src/librustc_typeck/variance.rs
index 9b27128ce2f..ac1ff29e7f5 100644
--- a/src/librustc_typeck/variance.rs
+++ b/src/librustc_typeck/variance.rs
@@ -1350,4 +1350,3 @@ fn glb(v1: ty::Variance, v2: ty::Variance) -> ty::Variance {
         (x, ty::Bivariant) | (ty::Bivariant, x) => x,
     }
 }
-
diff --git a/src/librustdoc/html/item_type.rs b/src/librustdoc/html/item_type.rs
index 1d63f01be52..d2385702a73 100644
--- a/src/librustdoc/html/item_type.rs
+++ b/src/librustdoc/html/item_type.rs
@@ -111,4 +111,3 @@ impl fmt::Display for ItemType {
         self.to_static_str().fmt(f)
     }
 }
-
diff --git a/src/librustdoc/html/static/Heuristica-LICENSE.txt b/src/librustdoc/html/static/Heuristica-LICENSE.txt
index 9693dc1db2d..dd85e40e645 100644
--- a/src/librustdoc/html/static/Heuristica-LICENSE.txt
+++ b/src/librustdoc/html/static/Heuristica-LICENSE.txt
@@ -1,7 +1,7 @@
 Copyright 1989, 1991 Adobe Systems Incorporated. All rights reserved.
 Utopia is either a registered trademark or trademark of Adobe Systems
 Incorporated in the United States and/or other countries. Used under
-license. 
+license.
 
 Copyright 2006 Han The Thanh, Vntopia font family, http://vntex.sf.net
 
@@ -26,7 +26,7 @@ with others.
 
 The OFL allows the licensed fonts to be used, studied, modified and
 redistributed freely as long as they are not sold by themselves. The
-fonts, including any derivative works, can be bundled, embedded, 
+fonts, including any derivative works, can be bundled, embedded,
 redistributed and/or sold with any software provided that any reserved
 names are not used by derivative works. The fonts and derivatives,
 however, cannot be released under any other type of license. The
diff --git a/src/librustdoc/html/static/SourceCodePro-LICENSE.txt b/src/librustdoc/html/static/SourceCodePro-LICENSE.txt
index 1177330426d..07542572e33 100644
--- a/src/librustdoc/html/static/SourceCodePro-LICENSE.txt
+++ b/src/librustdoc/html/static/SourceCodePro-LICENSE.txt
@@ -18,7 +18,7 @@ with others.
 
 The OFL allows the licensed fonts to be used, studied, modified and
 redistributed freely as long as they are not sold by themselves. The
-fonts, including any derivative works, can be bundled, embedded, 
+fonts, including any derivative works, can be bundled, embedded,
 redistributed and/or sold with any software provided that any reserved
 names are not used by derivative works. The fonts and derivatives,
 however, cannot be released under any other type of license. The
diff --git a/src/librustdoc/html/static/SourceSerifPro-LICENSE.txt b/src/librustdoc/html/static/SourceSerifPro-LICENSE.txt
index 14b54813758..b77d653ad4f 100644
--- a/src/librustdoc/html/static/SourceSerifPro-LICENSE.txt
+++ b/src/librustdoc/html/static/SourceSerifPro-LICENSE.txt
@@ -18,7 +18,7 @@ with others.
 
 The OFL allows the licensed fonts to be used, studied, modified and
 redistributed freely as long as they are not sold by themselves. The
-fonts, including any derivative works, can be bundled, embedded, 
+fonts, including any derivative works, can be bundled, embedded,
 redistributed and/or sold with any software provided that any reserved
 names are not used by derivative works. The fonts and derivatives,
 however, cannot be released under any other type of license. The
diff --git a/src/librustdoc/html/static/playpen.js b/src/librustdoc/html/static/playpen.js
index 8fb979875cd..06b3c4e42d6 100644
--- a/src/librustdoc/html/static/playpen.js
+++ b/src/librustdoc/html/static/playpen.js
@@ -25,4 +25,3 @@
         });
     }
 }());
-
diff --git a/src/libserialize/hex.rs b/src/libserialize/hex.rs
index 26994a6d79d..1f8d45a007d 100644
--- a/src/libserialize/hex.rs
+++ b/src/libserialize/hex.rs
@@ -31,7 +31,7 @@ impl ToHex for [u8] {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// extern crate serialize;
     /// use serialize::hex::ToHex;
     ///
@@ -100,7 +100,7 @@ impl FromHex for str {
     ///
     /// This converts a string literal to hexadecimal and back.
     ///
-    /// ```rust
+    /// ```
     /// extern crate serialize;
     /// use serialize::hex::{FromHex, ToHex};
     ///
diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs
index d0ef89e811b..366b90cfbfd 100644
--- a/src/libserialize/json.rs
+++ b/src/libserialize/json.rs
@@ -204,6 +204,7 @@ use std::io::prelude::*;
 use std::io;
 use std::mem::{swap};
 use std::num::FpCategory as Fp;
+#[cfg(stage0)]
 use std::num::{Float, Int};
 use std::ops::Index;
 use std::str::FromStr;
@@ -2622,7 +2623,6 @@ mod tests {
                 StackElement, Stack, Decoder, Encoder, EncoderError};
     use std::{i64, u64, f32, f64};
     use std::collections::BTreeMap;
-    use std::num::Float;
     use std::string;
 
     #[derive(RustcDecodable, Eq, PartialEq, Debug)]
diff --git a/src/libstd/bool.rs b/src/libstd/bool.rs
index 0d8b233a169..df703b3e43e 100644
--- a/src/libstd/bool.rs
+++ b/src/libstd/bool.rs
@@ -12,4 +12,3 @@
 
 #![doc(primitive = "bool")]
 #![stable(feature = "rust1", since = "1.0.0")]
-
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs
index 18f86901b8f..6f8151c2b9f 100644
--- a/src/libstd/collections/hash/map.rs
+++ b/src/libstd/collections/hash/map.rs
@@ -23,6 +23,7 @@ use hash::{Hash, SipHasher};
 use iter::{self, Iterator, ExactSizeIterator, IntoIterator, IteratorExt, FromIterator, Extend, Map};
 use marker::Sized;
 use mem::{self, replace};
+#[cfg(stage0)]
 use num::{Int, UnsignedInt};
 use ops::{Deref, FnMut, Index, IndexMut};
 use option::Option::{self, Some, None};
@@ -217,6 +218,11 @@ fn test_resize_policy() {
 /// It is required that the keys implement the `Eq` and `Hash` traits, although
 /// this can frequently be achieved by using `#[derive(Eq, Hash)]`.
 ///
+/// It is a logic error for a key to be modified in such a way that the key's
+/// hash, as determined by the `Hash` trait, or its equality, as determined by
+/// the `Eq` trait, changes while it is in the map. This is normally only
+/// possible through `Cell`, `RefCell`, global state, I/O, or unsafe code.
+///
 /// Relevant papers/articles:
 ///
 /// 1. Pedro Celis. ["Robin Hood Hashing"](https://cs.uwaterloo.ca/research/tr/1986/CS-86-14.pdf)
diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs
index 35115ad77fe..de3f080de82 100644
--- a/src/libstd/collections/hash/set.rs
+++ b/src/libstd/collections/hash/set.rs
@@ -38,6 +38,12 @@ use super::state::HashState;
 /// HashMap where the value is (). As with the `HashMap` type, a `HashSet`
 /// requires that the elements implement the `Eq` and `Hash` traits.
 ///
+/// It is a logic error for an item to be modified in such a way that the
+/// item's hash, as determined by the `Hash` trait, or its equality, as
+/// determined by the `Eq` trait, changes while it is in the set. This is
+/// normally only possible through `Cell`, `RefCell`, global state, I/O, or
+/// unsafe code.
+///
 /// # Examples
 ///
 /// ```
diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs
index 69fd0a57d5f..cba46859f34 100644
--- a/src/libstd/collections/hash/table.rs
+++ b/src/libstd/collections/hash/table.rs
@@ -19,12 +19,16 @@ use iter::{Iterator, IteratorExt, ExactSizeIterator, count};
 use marker::{Copy, Send, Sync, Sized, self};
 use mem::{min_align_of, size_of};
 use mem;
+#[cfg(stage0)]
 use num::{Int, UnsignedInt};
 use num::wrapping::{OverflowingOps, WrappingOps};
 use ops::{Deref, DerefMut, Drop};
 use option::Option;
 use option::Option::{Some, None};
+#[cfg(stage0)]
 use ptr::{self, PtrExt, Unique};
+#[cfg(not(stage0))]
+use ptr::{self, Unique};
 use rt::heap::{allocate, deallocate, EMPTY};
 use collections::hash_state::HashState;
 
diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs
index 90373441edc..d06b027adf6 100644
--- a/src/libstd/dynamic_lib.rs
+++ b/src/libstd/dynamic_lib.rs
@@ -272,7 +272,9 @@ mod dl {
     use ptr;
     use result::Result;
     use result::Result::{Ok, Err};
+    #[cfg(stage0)]
     use slice::SliceExt;
+    #[cfg(stage0)]
     use str::StrExt;
     use str;
     use string::String;
diff --git a/src/libstd/env.rs b/src/libstd/env.rs
index 27f78906ec2..4b6fbe01f76 100644
--- a/src/libstd/env.rs
+++ b/src/libstd/env.rs
@@ -41,7 +41,7 @@ use sys::os as os_imp;
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::env;
 ///
 /// // We assume that we are in a valid directory.
@@ -58,7 +58,7 @@ pub fn current_dir() -> io::Result<PathBuf> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::env;
 /// use std::path::Path;
 ///
@@ -102,7 +102,7 @@ pub struct VarsOs { inner: os_imp::Env }
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::env;
 ///
 /// // We will iterate through the references to the element returned by
@@ -125,7 +125,7 @@ pub fn vars() -> Vars {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::env;
 ///
 /// // We will iterate through the references to the element returned by
@@ -166,7 +166,7 @@ impl Iterator for VarsOs {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::env;
 ///
 /// let key = "HOME";
@@ -188,7 +188,7 @@ pub fn var<K: ?Sized>(key: &K) -> Result<String, VarError> where K: AsOsStr {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::env;
 ///
 /// let key = "HOME";
@@ -246,7 +246,7 @@ impl Error for VarError {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::env;
 ///
 /// let key = "KEY";
@@ -282,7 +282,7 @@ pub struct SplitPaths<'a> { inner: os_imp::SplitPaths<'a> }
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::env;
 ///
 /// let key = "PATH";
@@ -326,7 +326,7 @@ pub struct JoinPathsError {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::env;
 /// use std::path::PathBuf;
 ///
@@ -374,7 +374,7 @@ impl Error for JoinPathsError {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::env;
 ///
 /// match env::home_dir() {
@@ -416,7 +416,7 @@ pub fn temp_dir() -> PathBuf {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::env;
 ///
 /// match env::current_exe() {
@@ -481,7 +481,7 @@ pub struct ArgsOs { inner: os_imp::Args }
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::env;
 ///
 /// // Prints each argument on a separate line
@@ -503,7 +503,7 @@ pub fn args() -> Args {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::env;
 ///
 /// // Prints each argument on a separate line
diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs
index 677894ba6e4..48526f2bf2d 100644
--- a/src/libstd/ffi/c_str.rs
+++ b/src/libstd/ffi/c_str.rs
@@ -22,7 +22,11 @@ use old_io;
 use ops::Deref;
 use option::Option::{self, Some, None};
 use result::Result::{self, Ok, Err};
+#[cfg(stage0)]
 use slice::{self, SliceExt};
+#[cfg(not(stage0))]
+use slice;
+#[cfg(stage0)]
 use str::StrExt;
 use string::String;
 use vec::Vec;
diff --git a/src/libstd/fs/mod.rs b/src/libstd/fs/mod.rs
index d072d1f102b..ba89b3a0ea6 100644
--- a/src/libstd/fs/mod.rs
+++ b/src/libstd/fs/mod.rs
@@ -473,7 +473,7 @@ pub fn rename<P: AsPath, Q: AsPath>(from: P, to: Q) -> io::Result<()> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::fs;
 ///
 /// fs::copy("foo.txt", "bar.txt");
@@ -540,7 +540,7 @@ pub fn read_link<P: AsPath>(path: P) -> io::Result<PathBuf> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::fs;
 ///
 /// fs::create_dir("/some/dir");
@@ -576,7 +576,7 @@ pub fn create_dir_all<P: AsPath>(path: P) -> io::Result<()> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::fs;
 ///
 /// fs::remove_dir("/some/dir");
@@ -627,7 +627,7 @@ pub fn remove_dir_all<P: AsPath>(path: P) -> io::Result<()> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::io;
 /// use std::fs::{self, PathExt, DirEntry};
 /// use std::path::Path;
diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs
index 03416eb86a0..73dcf058e45 100644
--- a/src/libstd/io/buffered.rs
+++ b/src/libstd/io/buffered.rs
@@ -118,15 +118,16 @@ impl<R> fmt::Debug for BufReader<R> where R: fmt::Debug {
 /// `BufWriter` keeps an in memory buffer of data and writes it to the
 /// underlying `Write` in large, infrequent batches.
 ///
-/// This writer will be flushed when it is dropped.
+/// The buffer will be written out when the writer is dropped.
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct BufWriter<W> {
     inner: Option<W>,
     buf: Vec<u8>,
 }
 
-/// An error returned by `into_inner` which indicates whether a flush error
-/// happened or not.
+/// An error returned by `into_inner` which combines an error that
+/// happened while writing out the buffer, and the buffered writer object
+/// which may be used to recover from the condition.
 #[derive(Debug)]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct IntoInnerError<W>(W, Error);
@@ -155,7 +156,7 @@ impl<W: Write> BufWriter<W> {
             match self.inner.as_mut().unwrap().write(&self.buf[written..]) {
                 Ok(0) => {
                     ret = Err(Error::new(ErrorKind::WriteZero,
-                                         "failed to flush", None));
+                                         "failed to write the buffered data", None));
                     break;
                 }
                 Ok(n) => written += n,
@@ -190,7 +191,7 @@ impl<W: Write> BufWriter<W> {
 
     /// Unwraps this `BufWriter`, returning the underlying writer.
     ///
-    /// The buffer is flushed before returning the writer.
+    /// The buffer is written out before returning the writer.
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn into_inner(mut self) -> Result<W, IntoInnerError<BufWriter<W>>> {
         match self.flush_buf() {
@@ -239,14 +240,14 @@ impl<W: Write> Drop for BufWriter<W> {
 impl<W> IntoInnerError<W> {
     /// Returns the error which caused the call to `into_inner` to fail.
     ///
-    /// This error was returned when attempting to flush the internal buffer.
+    /// This error was returned when attempting to write the internal buffer.
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn error(&self) -> &Error { &self.1 }
 
-    /// Returns the underlying `BufWriter` instance which generated the error.
+    /// Returns the buffered writer instance which generated the error.
     ///
-    /// The returned object can be used to retry a flush or re-inspect the
-    /// buffer.
+    /// The returned object can be used for error recovery, such as
+    /// re-inspecting the buffer.
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn into_inner(self) -> W { self.0 }
 }
@@ -273,7 +274,7 @@ impl<W> fmt::Display for IntoInnerError<W> {
 /// Wraps a Writer and buffers output to it, flushing whenever a newline
 /// (`0x0a`, `'\n'`) is detected.
 ///
-/// This writer will be flushed when it is dropped.
+/// The buffer will be written out when the writer is dropped.
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct LineWriter<W> {
     inner: BufWriter<W>,
@@ -307,7 +308,7 @@ impl<W: Write> LineWriter<W> {
 
     /// Unwraps this `LineWriter`, returning the underlying writer.
     ///
-    /// The internal buffer is flushed before returning the writer.
+    /// The internal buffer is written out before returning the writer.
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn into_inner(self) -> Result<W, IntoInnerError<LineWriter<W>>> {
         self.inner.into_inner().map_err(|IntoInnerError(buf, e)| {
@@ -364,7 +365,7 @@ impl<W: Read> Read for InternalBufWriter<W> {
 /// call. A `BufStream` keeps in memory buffers of data, making large,
 /// infrequent calls to `read` and `write` on the underlying `Read+Write`.
 ///
-/// The output half will be flushed when this stream is dropped.
+/// The output buffer will be written out when this stream is dropped.
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct BufStream<S> {
     inner: BufReader<InternalBufWriter<S>>
@@ -410,8 +411,8 @@ impl<S: Read + Write> BufStream<S> {
 
     /// Unwraps this `BufStream`, returning the underlying stream.
     ///
-    /// The internal buffer is flushed before returning the stream. Any leftover
-    /// data in the read buffer is lost.
+    /// The internal write buffer is written out before returning the stream.
+    /// Any leftover data in the read buffer is lost.
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn into_inner(self) -> Result<S, IntoInnerError<BufStream<S>>> {
         let BufReader { inner: InternalBufWriter(w), buf } = self.inner;
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs
index 35ef375174a..d1231f549bb 100644
--- a/src/libstd/io/mod.rs
+++ b/src/libstd/io/mod.rs
@@ -20,12 +20,19 @@ use iter::Iterator;
 use marker::Sized;
 use ops::{Drop, FnOnce};
 use option::Option::{self, Some, None};
+#[cfg(stage0)]
 use ptr::PtrExt;
 use result::Result::{Ok, Err};
 use result;
+#[cfg(stage0)]
 use slice::{self, SliceExt};
+#[cfg(not(stage0))]
+use slice;
 use string::String;
+#[cfg(stage0)]
 use str::{self, StrExt};
+#[cfg(not(stage0))]
+use str;
 use vec::Vec;
 
 pub use self::buffered::{BufReader, BufWriter, BufStream, LineWriter};
@@ -356,7 +363,7 @@ pub trait Write {
     ///
     /// It is considered an error if not all bytes could be written due to
     /// I/O errors or EOF being reached.
-    #[unstable(feature = "io", reason = "waiting for RFC 950")]
+    #[stable(feature = "rust1", since = "1.0.0")]
     fn flush(&mut self) -> Result<()>;
 
     /// Attempts to write an entire buffer into this write.
diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs
index 7378f43f757..e1ef3062794 100644
--- a/src/libstd/macros.rs
+++ b/src/libstd/macros.rs
@@ -182,7 +182,7 @@ pub mod builtin {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::fmt;
     ///
     /// let s = fmt::format(format_args!("hello {}", "world"));
@@ -205,7 +205,7 @@ pub mod builtin {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// let path: &'static str = env!("PATH");
     /// println!("the $PATH variable at the time of compiling was: {}", path);
     /// ```
@@ -224,7 +224,7 @@ pub mod builtin {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// let key: Option<&'static str> = option_env!("SECRET_KEY");
     /// println!("the secret key might be: {:?}", key);
     /// ```
@@ -372,7 +372,7 @@ pub mod builtin {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// mod test {
     ///     pub fn foo() {
     ///         assert!(module_path!().ends_with("test"));
@@ -395,7 +395,7 @@ pub mod builtin {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// let my_directory = if cfg!(windows) {
     ///     "windows-specific-directory"
     /// } else {
diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs
index 101aae3eb24..702f81db8e2 100644
--- a/src/libstd/net/addr.rs
+++ b/src/libstd/net/addr.rs
@@ -15,150 +15,220 @@ use hash;
 use io;
 use libc::{self, socklen_t, sa_family_t};
 use mem;
-use net::{IpAddr, lookup_host, ntoh, hton};
+use net::{lookup_host, ntoh, hton, Ipv4Addr, Ipv6Addr};
 use option;
 use sys_common::{FromInner, AsInner, IntoInner};
 use vec;
 
-/// Representation of a socket address for networking applications
+/// Representation of a socket address for networking applications.
 ///
-/// A socket address consists of at least an (ip, port) pair and may also
-/// contain other information depending on the protocol.
-#[derive(Copy, Clone, PartialEq, Eq, Hash)]
-pub struct SocketAddr {
-    repr: Repr,
+/// A socket address can either represent the IPv4 or IPv6 protocol and is
+/// paired with at least a port number as well. Each protocol may have more
+/// specific information about the address available to it as well.
+#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
+#[stable(feature = "rust1", since = "1.0.0")]
+pub enum SocketAddr {
+    /// An IPv4 socket address which is a (ip, port) combination.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    V4(SocketAddrV4),
+    /// An IPv6 socket address
+    #[stable(feature = "rust1", since = "1.0.0")]
+    V6(SocketAddrV6),
 }
 
+/// An IPv4 socket address which is a (ip, port) combination.
 #[derive(Copy)]
-enum Repr {
-    V4(libc::sockaddr_in),
-    V6(libc::sockaddr_in6),
-}
+#[stable(feature = "rust1", since = "1.0.0")]
+pub struct SocketAddrV4 { inner: libc::sockaddr_in }
+
+/// An IPv6 socket address
+#[derive(Copy)]
+#[stable(feature = "rust1", since = "1.0.0")]
+pub struct SocketAddrV6 { inner: libc::sockaddr_in6 }
 
 impl SocketAddr {
+    /// Gets the port number associated with this socket address
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn port(&self) -> u16 {
+        match *self {
+            SocketAddr::V4(ref a) => a.port(),
+            SocketAddr::V6(ref a) => a.port(),
+        }
+    }
+}
+
+impl SocketAddrV4 {
     /// Creates a new socket address from the (ip, port) pair.
-    pub fn new(ip: IpAddr, port: u16) -> SocketAddr {
-        let repr = match ip {
-            IpAddr::V4(ref ip) => {
-                Repr::V4(libc::sockaddr_in {
-                    sin_family: libc::AF_INET as sa_family_t,
-                    sin_port: hton(port),
-                    sin_addr: *ip.as_inner(),
-                    .. unsafe { mem::zeroed() }
-                })
-            }
-            IpAddr::V6(ref ip) => {
-                Repr::V6(libc::sockaddr_in6 {
-                    sin6_family: libc::AF_INET6 as sa_family_t,
-                    sin6_port: hton(port),
-                    sin6_addr: *ip.as_inner(),
-                    .. unsafe { mem::zeroed() }
-                })
-            }
-        };
-        SocketAddr { repr: repr }
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn new(ip: Ipv4Addr, port: u16) -> SocketAddrV4 {
+        SocketAddrV4 {
+            inner: libc::sockaddr_in {
+                sin_family: libc::AF_INET as sa_family_t,
+                sin_port: hton(port),
+                sin_addr: *ip.as_inner(),
+                .. unsafe { mem::zeroed() }
+            },
+        }
     }
 
     /// Gets the IP address associated with this socket address.
-    pub fn ip(&self) -> IpAddr {
-        match self.repr {
-            Repr::V4(ref sa) => IpAddr::V4(FromInner::from_inner(sa.sin_addr)),
-            Repr::V6(ref sa) => IpAddr::V6(FromInner::from_inner(sa.sin6_addr)),
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn ip(&self) -> &Ipv4Addr {
+        unsafe {
+            &*(&self.inner.sin_addr as *const libc::in_addr as *const Ipv4Addr)
         }
     }
 
     /// Gets the port number associated with this socket address
-    pub fn port(&self) -> u16 {
-        match self.repr {
-            Repr::V4(ref sa) => ntoh(sa.sin_port),
-            Repr::V6(ref sa) => ntoh(sa.sin6_port),
-        }
-    }
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn port(&self) -> u16 { ntoh(self.inner.sin_port) }
+}
 
-    fn set_port(&mut self, port: u16) {
-        match self.repr {
-            Repr::V4(ref mut sa) => sa.sin_port = hton(port),
-            Repr::V6(ref mut sa) => sa.sin6_port = hton(port),
+impl SocketAddrV6 {
+    /// Creates a new socket address from the ip/port/flowinfo/scope_id
+    /// components.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn new(ip: Ipv6Addr, port: u16, flowinfo: u32, scope_id: u32)
+               -> SocketAddrV6 {
+        SocketAddrV6 {
+            inner: libc::sockaddr_in6 {
+                sin6_family: libc::AF_INET6 as sa_family_t,
+                sin6_port: hton(port),
+                sin6_addr: *ip.as_inner(),
+                sin6_flowinfo: hton(flowinfo),
+                sin6_scope_id: hton(scope_id),
+                .. unsafe { mem::zeroed() }
+            },
         }
     }
-}
 
-#[stable(feature = "rust1", since = "1.0.0")]
-impl fmt::Display for SocketAddr {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        match self.repr {
-            Repr::V4(_) => write!(f, "{}:{}", self.ip(), self.port()),
-            Repr::V6(_) => write!(f, "[{}]:{}", self.ip(), self.port()),
+    /// Gets the IP address associated with this socket address.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn ip(&self) -> &Ipv6Addr {
+        unsafe {
+            &*(&self.inner.sin6_addr as *const libc::in6_addr as *const Ipv6Addr)
         }
     }
+
+    /// Gets the port number associated with this socket address
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn port(&self) -> u16 { ntoh(self.inner.sin6_port) }
+
+    /// Gets scope ID associated with this address, corresponding to the
+    /// `sin6_flowinfo` field in C.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn flowinfo(&self) -> u32 { ntoh(self.inner.sin6_flowinfo) }
+
+    /// Gets scope ID associated with this address, corresponding to the
+    /// `sin6_scope_id` field in C.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn scope_id(&self) -> u32 { ntoh(self.inner.sin6_scope_id) }
 }
 
-impl FromInner<libc::sockaddr_in> for SocketAddr {
-    fn from_inner(addr: libc::sockaddr_in) -> SocketAddr {
-        SocketAddr { repr: Repr::V4(addr) }
+impl FromInner<libc::sockaddr_in> for SocketAddrV4 {
+    fn from_inner(addr: libc::sockaddr_in) -> SocketAddrV4 {
+        SocketAddrV4 { inner: addr }
     }
 }
 
-impl FromInner<libc::sockaddr_in6> for SocketAddr {
-    fn from_inner(addr: libc::sockaddr_in6) -> SocketAddr {
-        SocketAddr { repr: Repr::V6(addr) }
+impl FromInner<libc::sockaddr_in6> for SocketAddrV6 {
+    fn from_inner(addr: libc::sockaddr_in6) -> SocketAddrV6 {
+        SocketAddrV6 { inner: addr }
     }
 }
 
 impl<'a> IntoInner<(*const libc::sockaddr, socklen_t)> for &'a SocketAddr {
     fn into_inner(self) -> (*const libc::sockaddr, socklen_t) {
-        match self.repr {
-            Repr::V4(ref a) => {
+        match *self {
+            SocketAddr::V4(ref a) => {
                 (a as *const _ as *const _, mem::size_of_val(a) as socklen_t)
             }
-            Repr::V6(ref a) => {
+            SocketAddr::V6(ref a) => {
                 (a as *const _ as *const _, mem::size_of_val(a) as socklen_t)
             }
         }
     }
 }
 
-impl fmt::Debug for SocketAddr {
+#[stable(feature = "rust1", since = "1.0.0")]
+impl fmt::Display for SocketAddr {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        match *self {
+            SocketAddr::V4(ref a) => a.fmt(f),
+            SocketAddr::V6(ref a) => a.fmt(f),
+        }
+    }
+}
+
+#[stable(feature = "rust1", since = "1.0.0")]
+impl fmt::Display for SocketAddrV4 {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        write!(f, "{}:{}", self.ip(), self.port())
+    }
+}
+
+#[stable(feature = "rust1", since = "1.0.0")]
+impl fmt::Debug for SocketAddrV4 {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         fmt::Display::fmt(self, fmt)
     }
 }
 
-impl Clone for Repr {
-    fn clone(&self) -> Repr { *self }
+#[stable(feature = "rust1", since = "1.0.0")]
+impl fmt::Display for SocketAddrV6 {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        write!(f, "[{}]:{}", self.ip(), self.port())
+    }
 }
 
-impl PartialEq for Repr {
-    fn eq(&self, other: &Repr) -> bool {
-        match (*self, *other) {
-            (Repr::V4(ref a), Repr::V4(ref b)) => {
-                a.sin_port == b.sin_port &&
-                    a.sin_addr.s_addr == b.sin_addr.s_addr
-            }
-            (Repr::V6(ref a), Repr::V6(ref b)) => {
-                a.sin6_port == b.sin6_port &&
-                    a.sin6_addr.s6_addr == b.sin6_addr.s6_addr &&
-                    a.sin6_flowinfo == b.sin6_flowinfo &&
-                    a.sin6_scope_id == b.sin6_scope_id
-            }
-            _ => false,
-        }
+#[stable(feature = "rust1", since = "1.0.0")]
+impl fmt::Debug for SocketAddrV6 {
+    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+        fmt::Display::fmt(self, fmt)
+    }
+}
+
+#[stable(feature = "rust1", since = "1.0.0")]
+impl Clone for SocketAddrV4 {
+    fn clone(&self) -> SocketAddrV4 { *self }
+}
+#[stable(feature = "rust1", since = "1.0.0")]
+impl Clone for SocketAddrV6 {
+    fn clone(&self) -> SocketAddrV6 { *self }
+}
+
+#[stable(feature = "rust1", since = "1.0.0")]
+impl PartialEq for SocketAddrV4 {
+    fn eq(&self, other: &SocketAddrV4) -> bool {
+        self.inner.sin_port == other.inner.sin_port &&
+            self.inner.sin_addr.s_addr == other.inner.sin_addr.s_addr
     }
 }
-impl Eq for Repr {}
+#[stable(feature = "rust1", since = "1.0.0")]
+impl PartialEq for SocketAddrV6 {
+    fn eq(&self, other: &SocketAddrV6) -> bool {
+        self.inner.sin6_port == other.inner.sin6_port &&
+            self.inner.sin6_addr.s6_addr == other.inner.sin6_addr.s6_addr &&
+            self.inner.sin6_flowinfo == other.inner.sin6_flowinfo &&
+            self.inner.sin6_scope_id == other.inner.sin6_scope_id
+    }
+}
+#[stable(feature = "rust1", since = "1.0.0")]
+impl Eq for SocketAddrV4 {}
+#[stable(feature = "rust1", since = "1.0.0")]
+impl Eq for SocketAddrV6 {}
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl hash::Hash for Repr {
+impl hash::Hash for SocketAddrV4 {
     fn hash<H: hash::Hasher>(&self, s: &mut H) {
-        match *self {
-            Repr::V4(ref a) => {
-                (a.sin_family, a.sin_port, a.sin_addr.s_addr).hash(s)
-            }
-            Repr::V6(ref a) => {
-                (a.sin6_family, a.sin6_port, &a.sin6_addr.s6_addr,
-                 a.sin6_flowinfo, a.sin6_scope_id).hash(s)
-            }
-        }
+        (self.inner.sin_port, self.inner.sin_addr.s_addr).hash(s)
+    }
+}
+#[stable(feature = "rust1", since = "1.0.0")]
+impl hash::Hash for SocketAddrV6 {
+    fn hash<H: hash::Hasher>(&self, s: &mut H) {
+        (self.inner.sin6_port, &self.inner.sin6_addr.s6_addr,
+         self.inner.sin6_flowinfo, self.inner.sin6_scope_id).hash(s)
     }
 }
 
@@ -168,12 +238,13 @@ impl hash::Hash for Repr {
 /// This trait is used for generic address resolution when constructing network
 /// objects.  By default it is implemented for the following types:
 ///
-///  * `SocketAddr` - `to_socket_addrs` is identity function.
+///  * `SocketAddr`, `SocketAddrV4`, `SocketAddrV6` - `to_socket_addrs` is
+///    identity function.
 ///
-///  * `(IpAddr, u16)` - `to_socket_addrs` constructs `SocketAddr` trivially.
+///  * `(IpvNAddr, u16)` - `to_socket_addrs` constructs `SocketAddr` trivially.
 ///
 ///  * `(&str, u16)` - the string should be either a string representation of an
-///    IP address expected by `FromStr` implementation for `IpAddr` or a host
+///    IP address expected by `FromStr` implementation for `IpvNAddr` or a host
 ///    name.
 ///
 ///  * `&str` - the string should be either a string representation of a
@@ -192,18 +263,18 @@ impl hash::Hash for Repr {
 /// Some examples:
 ///
 /// ```no_run
-/// use std::net::{IpAddr, SocketAddr, TcpStream, UdpSocket, TcpListener};
+/// use std::net::{SocketAddrV4, TcpStream, UdpSocket, TcpListener, Ipv4Addr};
 ///
 /// fn main() {
-///     let ip = IpAddr::new_v4(127, 0, 0, 1);
+///     let ip = Ipv4Addr::new(127, 0, 0, 1);
 ///     let port = 12345;
 ///
 ///     // The following lines are equivalent modulo possible "localhost" name
 ///     // resolution differences
-///     let tcp_s = TcpStream::connect(&SocketAddr::new(ip, port));
-///     let tcp_s = TcpStream::connect(&(ip, port));
-///     let tcp_s = TcpStream::connect(&("127.0.0.1", port));
-///     let tcp_s = TcpStream::connect(&("localhost", port));
+///     let tcp_s = TcpStream::connect(SocketAddrV4::new(ip, port));
+///     let tcp_s = TcpStream::connect((ip, port));
+///     let tcp_s = TcpStream::connect(("127.0.0.1", port));
+///     let tcp_s = TcpStream::connect(("localhost", port));
 ///     let tcp_s = TcpStream::connect("127.0.0.1:12345");
 ///     let tcp_s = TcpStream::connect("localhost:12345");
 ///
@@ -211,13 +282,15 @@ impl hash::Hash for Repr {
 ///     // behave similarly
 ///     let tcp_l = TcpListener::bind("localhost:12345");
 ///
-///     let mut udp_s = UdpSocket::bind(&("127.0.0.1", port)).unwrap();
-///     udp_s.send_to(&[7], &(ip, 23451));
+///     let mut udp_s = UdpSocket::bind(("127.0.0.1", port)).unwrap();
+///     udp_s.send_to(&[7], (ip, 23451));
 /// }
 /// ```
+#[stable(feature = "rust1", since = "1.0.0")]
 pub trait ToSocketAddrs {
     /// Returned iterator over socket addresses which this type may correspond
     /// to.
+    #[stable(feature = "rust1", since = "1.0.0")]
     type Iter: Iterator<Item=SocketAddr>;
 
     /// Converts this object to an iterator of resolved `SocketAddr`s.
@@ -231,9 +304,11 @@ pub trait ToSocketAddrs {
     /// # Errors
     ///
     /// Any errors encountered during resolution will be returned as an `Err`.
+    #[stable(feature = "rust1", since = "1.0.0")]
     fn to_socket_addrs(&self) -> io::Result<Self::Iter>;
 }
 
+#[stable(feature = "rust1", since = "1.0.0")]
 impl ToSocketAddrs for SocketAddr {
     type Iter = option::IntoIter<SocketAddr>;
     fn to_socket_addrs(&self) -> io::Result<option::IntoIter<SocketAddr>> {
@@ -241,31 +316,72 @@ impl ToSocketAddrs for SocketAddr {
     }
 }
 
-impl ToSocketAddrs for (IpAddr, u16) {
+#[stable(feature = "rust1", since = "1.0.0")]
+impl ToSocketAddrs for SocketAddrV4 {
+    type Iter = option::IntoIter<SocketAddr>;
+    fn to_socket_addrs(&self) -> io::Result<option::IntoIter<SocketAddr>> {
+        SocketAddr::V4(*self).to_socket_addrs()
+    }
+}
+
+#[stable(feature = "rust1", since = "1.0.0")]
+impl ToSocketAddrs for SocketAddrV6 {
+    type Iter = option::IntoIter<SocketAddr>;
+    fn to_socket_addrs(&self) -> io::Result<option::IntoIter<SocketAddr>> {
+        SocketAddr::V6(*self).to_socket_addrs()
+    }
+}
+
+#[stable(feature = "rust1", since = "1.0.0")]
+impl ToSocketAddrs for (Ipv4Addr, u16) {
+    type Iter = option::IntoIter<SocketAddr>;
+    fn to_socket_addrs(&self) -> io::Result<option::IntoIter<SocketAddr>> {
+        let (ip, port) = *self;
+        SocketAddrV4::new(ip, port).to_socket_addrs()
+    }
+}
+
+#[stable(feature = "rust1", since = "1.0.0")]
+impl ToSocketAddrs for (Ipv6Addr, u16) {
     type Iter = option::IntoIter<SocketAddr>;
     fn to_socket_addrs(&self) -> io::Result<option::IntoIter<SocketAddr>> {
         let (ip, port) = *self;
-        Ok(Some(SocketAddr::new(ip, port)).into_iter())
+        SocketAddrV6::new(ip, port, 0, 0).to_socket_addrs()
     }
 }
 
 fn resolve_socket_addr(s: &str, p: u16) -> io::Result<vec::IntoIter<SocketAddr>> {
     let ips = try!(lookup_host(s));
     let v: Vec<_> = try!(ips.map(|a| {
-        a.map(|mut a| { a.set_port(p); a })
+        a.map(|a| {
+            match a {
+                SocketAddr::V4(ref a) => {
+                    SocketAddr::V4(SocketAddrV4::new(*a.ip(), p))
+                }
+                SocketAddr::V6(ref a) => {
+                    SocketAddr::V6(SocketAddrV6::new(*a.ip(), p, a.flowinfo(),
+                                                     a.scope_id()))
+                }
+            }
+        })
     }).collect());
     Ok(v.into_iter())
 }
 
+#[stable(feature = "rust1", since = "1.0.0")]
 impl<'a> ToSocketAddrs for (&'a str, u16) {
     type Iter = vec::IntoIter<SocketAddr>;
     fn to_socket_addrs(&self) -> io::Result<vec::IntoIter<SocketAddr>> {
         let (host, port) = *self;
 
-        // try to parse the host as a regular IpAddr first
-        match host.parse().ok() {
-            Some(addr) => return Ok(vec![SocketAddr::new(addr, port)].into_iter()),
-            None => {}
+        // try to parse the host as a regular IP address first
+        if let Ok(addr) = host.parse::<Ipv4Addr>() {
+            let addr = SocketAddrV4::new(addr, port);
+            return Ok(vec![SocketAddr::V4(addr)].into_iter())
+        }
+        if let Ok(addr) = host.parse::<Ipv6Addr>() {
+            let addr = SocketAddrV6::new(addr, port, 0, 0);
+            return Ok(vec![SocketAddr::V6(addr)].into_iter())
         }
 
         resolve_socket_addr(host, port)
@@ -273,6 +389,7 @@ impl<'a> ToSocketAddrs for (&'a str, u16) {
 }
 
 // accepts strings like 'localhost:12345'
+#[stable(feature = "rust1", since = "1.0.0")]
 impl ToSocketAddrs for str {
     type Iter = vec::IntoIter<SocketAddr>;
     fn to_socket_addrs(&self) -> io::Result<vec::IntoIter<SocketAddr>> {
@@ -322,16 +439,16 @@ mod tests {
         assert_eq!(Ok(Ipv4Addr::new(0, 0, 0, 0)), "0.0.0.0".parse());
 
         // out of range
-        let none: Option<IpAddr> = "256.0.0.1".parse().ok();
+        let none: Option<Ipv4Addr> = "256.0.0.1".parse().ok();
         assert_eq!(None, none);
         // too short
-        let none: Option<IpAddr> = "255.0.0".parse().ok();
+        let none: Option<Ipv4Addr> = "255.0.0".parse().ok();
         assert_eq!(None, none);
         // too long
-        let none: Option<IpAddr> = "255.0.0.1.2".parse().ok();
+        let none: Option<Ipv4Addr> = "255.0.0.1.2".parse().ok();
         assert_eq!(None, none);
         // no number between dots
-        let none: Option<IpAddr> = "255.0..1".parse().ok();
+        let none: Option<Ipv4Addr> = "255.0..1".parse().ok();
         assert_eq!(None, none);
     }
 
@@ -347,19 +464,19 @@ mod tests {
                 "2a02:6b8::11:11".parse());
 
         // too long group
-        let none: Option<IpAddr> = "::00000".parse().ok();
+        let none: Option<Ipv6Addr> = "::00000".parse().ok();
         assert_eq!(None, none);
         // too short
-        let none: Option<IpAddr> = "1:2:3:4:5:6:7".parse().ok();
+        let none: Option<Ipv6Addr> = "1:2:3:4:5:6:7".parse().ok();
         assert_eq!(None, none);
         // too long
-        let none: Option<IpAddr> = "1:2:3:4:5:6:7:8:9".parse().ok();
+        let none: Option<Ipv6Addr> = "1:2:3:4:5:6:7:8:9".parse().ok();
         assert_eq!(None, none);
         // triple colon
-        let none: Option<IpAddr> = "1:2:::6:7:8".parse().ok();
+        let none: Option<Ipv6Addr> = "1:2:::6:7:8".parse().ok();
         assert_eq!(None, none);
         // two double colons
-        let none: Option<IpAddr> = "1:2::6::8".parse().ok();
+        let none: Option<Ipv6Addr> = "1:2::6::8".parse().ok();
         assert_eq!(None, none);
     }
 
@@ -375,24 +492,24 @@ mod tests {
                 "2001:db8:122:c000:2:2100:192.0.2.33".parse());
 
         // colon after v4
-        let none: Option<IpAddr> = "::127.0.0.1:".parse().ok();
+        let none: Option<Ipv4Addr> = "::127.0.0.1:".parse().ok();
         assert_eq!(None, none);
         // not enough groups
-        let none: Option<IpAddr> = "1.2.3.4.5:127.0.0.1".parse().ok();
+        let none: Option<Ipv6Addr> = "1.2.3.4.5:127.0.0.1".parse().ok();
         assert_eq!(None, none);
         // too many groups
-        let none: Option<IpAddr> = "1.2.3.4.5:6:7:127.0.0.1".parse().ok();
+        let none: Option<Ipv6Addr> = "1.2.3.4.5:6:7:127.0.0.1".parse().ok();
         assert_eq!(None, none);
     }
 
     #[test]
     fn test_from_str_socket_addr() {
-        assert_eq!(Ok(SocketAddr::new(IpAddr::new_v4(77, 88, 21, 11), 80)),
-                "77.88.21.11:80".parse());
-        assert_eq!(Ok(SocketAddr::new(IpAddr::new_v6(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), 53)),
-                "[2a02:6b8:0:1::1]:53".parse());
-        assert_eq!(Ok(SocketAddr::new(IpAddr::new_v6(0, 0, 0, 0, 0, 0, 0x7F00, 1), 22)),
-                "[::127.0.0.1]:22".parse());
+        assert_eq!(Ok(sa4(Ipv4Addr::new(77, 88, 21, 11), 80)),
+                   "77.88.21.11:80".parse());
+        assert_eq!(Ok(sa6(Ipv6Addr::new(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), 53)),
+                   "[2a02:6b8:0:1::1]:53".parse());
+        assert_eq!(Ok(sa6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0x7F00, 1), 22)),
+                   "[::127.0.0.1]:22".parse());
 
         // without port
         let none: Option<SocketAddr> = "127.0.0.1".parse().ok();
@@ -555,39 +672,47 @@ mod tests {
 
     #[test]
     fn to_socket_addr_socketaddr() {
-        let a = SocketAddr::new(IpAddr::new_v4(77, 88, 21, 11), 12345);
+        let a = sa4(Ipv4Addr::new(77, 88, 21, 11), 12345);
         assert_eq!(Ok(vec![a]), tsa(a));
     }
 
+    fn sa4(a: Ipv4Addr, p: u16) -> SocketAddr {
+        SocketAddr::V4(SocketAddrV4::new(a, p))
+    }
+
+    fn sa6(a: Ipv6Addr, p: u16) -> SocketAddr {
+        SocketAddr::V6(SocketAddrV6::new(a, p, 0, 0))
+    }
+
     #[test]
     fn to_socket_addr_ipaddr_u16() {
-        let a = IpAddr::new_v4(77, 88, 21, 11);
+        let a = Ipv4Addr::new(77, 88, 21, 11);
         let p = 12345;
-        let e = SocketAddr::new(a, p);
+        let e = SocketAddr::V4(SocketAddrV4::new(a, p));
         assert_eq!(Ok(vec![e]), tsa((a, p)));
     }
 
     #[test]
     fn to_socket_addr_str_u16() {
-        let a = SocketAddr::new(IpAddr::new_v4(77, 88, 21, 11), 24352);
+        let a = sa4(Ipv4Addr::new(77, 88, 21, 11), 24352);
         assert_eq!(Ok(vec![a]), tsa(("77.88.21.11", 24352)));
 
-        let a = SocketAddr::new(IpAddr::new_v6(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), 53);
+        let a = sa6(Ipv6Addr::new(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), 53);
         assert_eq!(Ok(vec![a]), tsa(("2a02:6b8:0:1::1", 53)));
 
-        let a = SocketAddr::new(IpAddr::new_v4(127, 0, 0, 1), 23924);
+        let a = sa4(Ipv4Addr::new(127, 0, 0, 1), 23924);
         assert!(tsa(("localhost", 23924)).unwrap().contains(&a));
     }
 
     #[test]
     fn to_socket_addr_str() {
-        let a = SocketAddr::new(IpAddr::new_v4(77, 88, 21, 11), 24352);
+        let a = sa4(Ipv4Addr::new(77, 88, 21, 11), 24352);
         assert_eq!(Ok(vec![a]), tsa("77.88.21.11:24352"));
 
-        let a = SocketAddr::new(IpAddr::new_v6(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), 53);
+        let a = sa6(Ipv6Addr::new(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), 53);
         assert_eq!(Ok(vec![a]), tsa("[2a02:6b8:0:1::1]:53"));
 
-        let a = SocketAddr::new(IpAddr::new_v4(127, 0, 0, 1), 23924);
+        let a = sa4(Ipv4Addr::new(127, 0, 0, 1), 23924);
         assert!(tsa("localhost:23924").unwrap().contains(&a));
     }
 
diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs
index c502a94ba69..c5f2ae53d22 100644
--- a/src/libstd/net/ip.rs
+++ b/src/libstd/net/ip.rs
@@ -8,6 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![unstable(feature = "ip", reason = "extra functionality has not been \
+                                      scrutinized to the level that it should \
+                                      be stable")]
+
 use prelude::v1::*;
 
 use cmp::Ordering;
@@ -19,12 +23,14 @@ use net::{hton, ntoh};
 
 /// Representation of an IPv4 address.
 #[derive(Copy)]
+#[stable(feature = "rust1", since = "1.0.0")]
 pub struct Ipv4Addr {
     inner: libc::in_addr,
 }
 
 /// Representation of an IPv6 address.
 #[derive(Copy)]
+#[stable(feature = "rust1", since = "1.0.0")]
 pub struct Ipv6Addr {
     inner: libc::in6_addr,
 }
@@ -41,46 +47,11 @@ pub enum Ipv6MulticastScope {
     Global
 }
 
-/// Enumeration of possible IP addresses
-#[derive(Copy, PartialEq, Eq, Clone, Hash, Debug)]
-pub enum IpAddr {
-    /// An IPv4 address.
-    V4(Ipv4Addr),
-    /// An IPv6 address.
-    V6(Ipv6Addr)
-}
-
-impl IpAddr {
-    /// Create a new IpAddr that contains an IPv4 address.
-    ///
-    /// The result will represent the IP address a.b.c.d
-    pub fn new_v4(a: u8, b: u8, c: u8, d: u8) -> IpAddr {
-        IpAddr::V4(Ipv4Addr::new(a, b, c, d))
-    }
-
-    /// Create a new IpAddr that contains an IPv6 address.
-    ///
-    /// The result will represent the IP address a:b:c:d:e:f
-    pub fn new_v6(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16,
-                  h: u16) -> IpAddr {
-        IpAddr::V6(Ipv6Addr::new(a, b, c, d, e, f, g, h))
-    }
-}
-
-#[stable(feature = "rust1", since = "1.0.0")]
-impl fmt::Display for IpAddr {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        match *self {
-            IpAddr::V4(v4) => v4.fmt(f),
-            IpAddr::V6(v6) => v6.fmt(f)
-        }
-    }
-}
-
 impl Ipv4Addr {
     /// Create a new IPv4 address from four eight-bit octets.
     ///
     /// The result will represent the IP address a.b.c.d
+    #[stable(feature = "rust1", since = "1.0.0")]
     pub fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr {
         Ipv4Addr {
             inner: libc::in_addr {
@@ -93,6 +64,7 @@ impl Ipv4Addr {
     }
 
     /// Returns the four eight-bit integers that make up this address
+    #[stable(feature = "rust1", since = "1.0.0")]
     pub fn octets(&self) -> [u8; 4] {
         let bits = ntoh(self.inner.s_addr);
         [(bits >> 24) as u8, (bits >> 16) as u8, (bits >> 8) as u8, bits as u8]
@@ -148,6 +120,7 @@ impl Ipv4Addr {
     /// Convert this address to an IPv4-compatible IPv6 address
     ///
     /// a.b.c.d becomes ::a.b.c.d
+    #[stable(feature = "rust1", since = "1.0.0")]
     pub fn to_ipv6_compatible(&self) -> Ipv6Addr {
         Ipv6Addr::new(0, 0, 0, 0, 0, 0,
                       ((self.octets()[0] as u16) << 8) | self.octets()[1] as u16,
@@ -157,6 +130,7 @@ impl Ipv4Addr {
     /// Convert this address to an IPv4-mapped IPv6 address
     ///
     /// a.b.c.d becomes ::ffff:a.b.c.d
+    #[stable(feature = "rust1", since = "1.0.0")]
     pub fn to_ipv6_mapped(&self) -> Ipv6Addr {
         Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff,
                       ((self.octets()[0] as u16) << 8) | self.octets()[1] as u16,
@@ -165,6 +139,7 @@ impl Ipv4Addr {
 
 }
 
+#[stable(feature = "rust1", since = "1.0.0")]
 impl fmt::Display for Ipv4Addr {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         let octets = self.octets();
@@ -172,21 +147,26 @@ impl fmt::Display for Ipv4Addr {
     }
 }
 
+#[stable(feature = "rust1", since = "1.0.0")]
 impl fmt::Debug for Ipv4Addr {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         fmt::Display::fmt(self, fmt)
     }
 }
 
+#[stable(feature = "rust1", since = "1.0.0")]
 impl Clone for Ipv4Addr {
     fn clone(&self) -> Ipv4Addr { *self }
 }
 
+#[stable(feature = "rust1", since = "1.0.0")]
 impl PartialEq for Ipv4Addr {
     fn eq(&self, other: &Ipv4Addr) -> bool {
         self.inner.s_addr == other.inner.s_addr
     }
 }
+
+#[stable(feature = "rust1", since = "1.0.0")]
 impl Eq for Ipv4Addr {}
 
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -196,12 +176,14 @@ impl hash::Hash for Ipv4Addr {
     }
 }
 
+#[stable(feature = "rust1", since = "1.0.0")]
 impl PartialOrd for Ipv4Addr {
     fn partial_cmp(&self, other: &Ipv4Addr) -> Option<Ordering> {
         Some(self.cmp(other))
     }
 }
 
+#[stable(feature = "rust1", since = "1.0.0")]
 impl Ord for Ipv4Addr {
     fn cmp(&self, other: &Ipv4Addr) -> Ordering {
         self.inner.s_addr.cmp(&other.inner.s_addr)
@@ -221,6 +203,7 @@ impl Ipv6Addr {
     /// Create a new IPv6 address from eight 16-bit segments.
     ///
     /// The result will represent the IP address a:b:c:d:e:f
+    #[stable(feature = "rust1", since = "1.0.0")]
     pub fn new(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16,
                h: u16) -> Ipv6Addr {
         Ipv6Addr {
@@ -232,6 +215,7 @@ impl Ipv6Addr {
     }
 
     /// Return the eight 16-bit segments that make up this address
+    #[stable(feature = "rust1", since = "1.0.0")]
     pub fn segments(&self) -> [u16; 8] {
         [ntoh(self.inner.s6_addr[0]),
          ntoh(self.inner.s6_addr[1]),
@@ -324,6 +308,7 @@ impl Ipv6Addr {
     /// neither IPv4-compatible or IPv4-mapped.
     ///
     /// ::a.b.c.d and ::ffff:a.b.c.d become a.b.c.d
+    #[stable(feature = "rust1", since = "1.0.0")]
     pub fn to_ipv4(&self) -> Option<Ipv4Addr> {
         match self.segments() {
             [0, 0, 0, 0, 0, f, g, h] if f == 0 || f == 0xffff => {
@@ -335,6 +320,7 @@ impl Ipv6Addr {
     }
 }
 
+#[stable(feature = "rust1", since = "1.0.0")]
 impl fmt::Display for Ipv6Addr {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         match self.segments() {
@@ -405,21 +391,26 @@ impl fmt::Display for Ipv6Addr {
     }
 }
 
+#[stable(feature = "rust1", since = "1.0.0")]
 impl fmt::Debug for Ipv6Addr {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         fmt::Display::fmt(self, fmt)
     }
 }
 
+#[stable(feature = "rust1", since = "1.0.0")]
 impl Clone for Ipv6Addr {
     fn clone(&self) -> Ipv6Addr { *self }
 }
 
+#[stable(feature = "rust1", since = "1.0.0")]
 impl PartialEq for Ipv6Addr {
     fn eq(&self, other: &Ipv6Addr) -> bool {
         self.inner.s6_addr == other.inner.s6_addr
     }
 }
+
+#[stable(feature = "rust1", since = "1.0.0")]
 impl Eq for Ipv6Addr {}
 
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -429,12 +420,14 @@ impl hash::Hash for Ipv6Addr {
     }
 }
 
+#[stable(feature = "rust1", since = "1.0.0")]
 impl PartialOrd for Ipv6Addr {
     fn partial_cmp(&self, other: &Ipv6Addr) -> Option<Ordering> {
         Some(self.cmp(other))
     }
 }
 
+#[stable(feature = "rust1", since = "1.0.0")]
 impl Ord for Ipv6Addr {
     fn cmp(&self, other: &Ipv6Addr) -> Ordering {
         self.inner.s6_addr.cmp(&other.inner.s6_addr)
diff --git a/src/libstd/net/mod.rs b/src/libstd/net/mod.rs
index 95920d8d2b6..36f36af73e1 100644
--- a/src/libstd/net/mod.rs
+++ b/src/libstd/net/mod.rs
@@ -13,7 +13,7 @@
 //! > **NOTE**: This module is very much a work in progress and is under active
 //! > development.
 
-#![unstable(feature = "net")]
+#![stable(feature = "rust1", since = "1.0.0")]
 
 use prelude::v1::*;
 
@@ -21,8 +21,8 @@ use io::{self, Error, ErrorKind};
 use num::Int;
 use sys_common::net2 as net_imp;
 
-pub use self::ip::{IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope};
-pub use self::addr::{SocketAddr, ToSocketAddrs};
+pub use self::ip::{Ipv4Addr, Ipv6Addr, Ipv6MulticastScope};
+pub use self::addr::{SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs};
 pub use self::tcp::{TcpStream, TcpListener};
 pub use self::udp::UdpSocket;
 
@@ -36,23 +36,27 @@ mod parser;
 /// Possible values which can be passed to the `shutdown` method of `TcpStream`
 /// and `UdpSocket`.
 #[derive(Copy, Clone, PartialEq)]
+#[stable(feature = "rust1", since = "1.0.0")]
 pub enum Shutdown {
     /// Indicates that the reading portion of this stream/socket should be shut
     /// down. All currently blocked and future reads will return `Ok(0)`.
+    #[stable(feature = "rust1", since = "1.0.0")]
     Read,
     /// Indicates that the writing portion of this stream/socket should be shut
     /// down. All currently blocked and future writes will return an error.
+    #[stable(feature = "rust1", since = "1.0.0")]
     Write,
     /// Shut down both the reading and writing portions of this stream.
     ///
     /// See `Shutdown::Read` and `Shutdown::Write` for more information.
-    Both
+    #[stable(feature = "rust1", since = "1.0.0")]
+    Both,
 }
 
 fn hton<I: Int>(i: I) -> I { i.to_be() }
 fn ntoh<I: Int>(i: I) -> I { Int::from_be(i) }
 
-fn each_addr<A: ToSocketAddrs + ?Sized, F, T>(addr: &A, mut f: F) -> io::Result<T>
+fn each_addr<A: ToSocketAddrs, F, T>(addr: A, mut f: F) -> io::Result<T>
     where F: FnMut(&SocketAddr) -> io::Result<T>
 {
     let mut last_err = None;
@@ -69,8 +73,10 @@ fn each_addr<A: ToSocketAddrs + ?Sized, F, T>(addr: &A, mut f: F) -> io::Result<
 }
 
 /// An iterator over `SocketAddr` values returned from a host lookup operation.
+#[stable(feature = "rust1", since = "1.0.0")]
 pub struct LookupHost(net_imp::LookupHost);
 
+#[stable(feature = "rust1", since = "1.0.0")]
 impl Iterator for LookupHost {
     type Item = io::Result<SocketAddr>;
     fn next(&mut self) -> Option<io::Result<SocketAddr>> { self.0.next() }
@@ -93,6 +99,7 @@ impl Iterator for LookupHost {
 /// # Ok(())
 /// # }
 /// ```
+#[stable(feature = "rust1", since = "1.0.0")]
 pub fn lookup_host(host: &str) -> io::Result<LookupHost> {
     net_imp::lookup_host(host).map(LookupHost)
 }
diff --git a/src/libstd/net/parser.rs b/src/libstd/net/parser.rs
index aa54a432d62..9843a152718 100644
--- a/src/libstd/net/parser.rs
+++ b/src/libstd/net/parser.rs
@@ -16,7 +16,7 @@
 use prelude::v1::*;
 
 use str::FromStr;
-use net::{Ipv4Addr, Ipv6Addr, IpAddr, SocketAddr};
+use net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
 
 struct Parser<'a> {
     // parsing as ASCII, so can use byte array
@@ -24,6 +24,11 @@ struct Parser<'a> {
     pos: usize,
 }
 
+enum IpAddr {
+    V4(Ipv4Addr),
+    V6(Ipv6Addr),
+}
+
 impl<'a> Parser<'a> {
     fn new(s: &'a str) -> Parser<'a> {
         Parser {
@@ -281,18 +286,13 @@ impl<'a> Parser<'a> {
         let port  = |p: &mut Parser| p.read_number(10, 5, 0x10000).map(|n| n as u16);
 
         // host, colon, port
-        self.read_seq_3::<IpAddr, char, u16, _, _, _>(ip_addr, colon, port)
-                .map(|t| match t { (ip, _, port) => SocketAddr::new(ip, port) })
-    }
-}
-
-impl FromStr for IpAddr {
-    type Err = ParseError;
-    fn from_str(s: &str) -> Result<IpAddr, ParseError> {
-        match Parser::new(s).read_till_eof(|p| p.read_ip_addr()) {
-            Some(s) => Ok(s),
-            None => Err(ParseError),
-        }
+        self.read_seq_3(ip_addr, colon, port).map(|t| {
+            let (ip, _, port): (IpAddr, char, u16) = t;
+            match ip {
+                IpAddr::V4(ip) => SocketAddr::V4(SocketAddrV4::new(ip, port)),
+                IpAddr::V6(ip) => SocketAddr::V6(SocketAddrV6::new(ip, port, 0, 0)),
+            }
+        })
     }
 }
 
diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs
index 76c04835473..501ba2dc2c1 100644
--- a/src/libstd/net/tcp.rs
+++ b/src/libstd/net/tcp.rs
@@ -8,6 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![unstable(feature = "tcp", reason = "remaining functions have not been \
+                                       scrutinized enough to be stabilized")]
+
 use prelude::v1::*;
 use io::prelude::*;
 
@@ -35,6 +38,7 @@ use sys_common::AsInner;
 ///     let _ = stream.read(&mut [0; 128]); // ignore here too
 /// } // the stream is closed here
 /// ```
+#[stable(feature = "rust1", since = "1.0.0")]
 pub struct TcpStream(net_imp::TcpStream);
 
 /// A structure representing a socket server.
@@ -67,12 +71,14 @@ pub struct TcpStream(net_imp::TcpStream);
 /// // close the socket server
 /// drop(listener);
 /// ```
+#[stable(feature = "rust1", since = "1.0.0")]
 pub struct TcpListener(net_imp::TcpListener);
 
 /// An infinite iterator over the connections from a `TcpListener`.
 ///
 /// This iterator will infinitely yield `Some` of the accepted connections. It
 /// is equivalent to calling `accept` in a loop.
+#[stable(feature = "rust1", since = "1.0.0")]
 pub struct Incoming<'a> { listener: &'a TcpListener }
 
 impl TcpStream {
@@ -81,25 +87,36 @@ impl TcpStream {
     /// `addr` is an address of the remote host. Anything which implements
     /// `ToSocketAddrs` trait can be supplied for the address; see this trait
     /// documentation for concrete examples.
-    pub fn connect<A: ToSocketAddrs + ?Sized>(addr: &A) -> io::Result<TcpStream> {
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn connect<A: ToSocketAddrs>(addr: A) -> io::Result<TcpStream> {
         super::each_addr(addr, net_imp::TcpStream::connect).map(TcpStream)
     }
 
     /// Returns the socket address of the remote peer of this TCP connection.
+    #[stable(feature = "rust1", since = "1.0.0")]
     pub fn peer_addr(&self) -> io::Result<SocketAddr> {
         self.0.peer_addr()
     }
 
     /// Returns the socket address of the local half of this TCP connection.
+    #[unstable(feature = "net")]
+    #[deprecated(since = "1.0.0", reason = "renamed to local_addr")]
     pub fn socket_addr(&self) -> io::Result<SocketAddr> {
         self.0.socket_addr()
     }
 
+    /// Returns the socket address of the local half of this TCP connection.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn local_addr(&self) -> io::Result<SocketAddr> {
+        self.0.socket_addr()
+    }
+
     /// Shut down the read, write, or both halves of this connection.
     ///
     /// This function will cause all pending and future I/O on the specified
     /// portions to return immediately with an appropriate value (see the
     /// documentation of `Shutdown`).
+    #[stable(feature = "rust1", since = "1.0.0")]
     pub fn shutdown(&self, how: Shutdown) -> io::Result<()> {
         self.0.shutdown(how)
     }
@@ -110,6 +127,7 @@ impl TcpStream {
     /// object references. Both handles will read and write the same stream of
     /// data, and options set on one stream will be propagated to the other
     /// stream.
+    #[stable(feature = "rust1", since = "1.0.0")]
     pub fn try_clone(&self) -> io::Result<TcpStream> {
         self.0.duplicate().map(TcpStream)
     }
@@ -129,16 +147,20 @@ impl TcpStream {
     }
 }
 
+#[stable(feature = "rust1", since = "1.0.0")]
 impl Read for TcpStream {
     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { self.0.read(buf) }
 }
+#[stable(feature = "rust1", since = "1.0.0")]
 impl Write for TcpStream {
     fn write(&mut self, buf: &[u8]) -> io::Result<usize> { self.0.write(buf) }
     fn flush(&mut self) -> io::Result<()> { Ok(()) }
 }
+#[stable(feature = "rust1", since = "1.0.0")]
 impl<'a> Read for &'a TcpStream {
     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { self.0.read(buf) }
 }
+#[stable(feature = "rust1", since = "1.0.0")]
 impl<'a> Write for &'a TcpStream {
     fn write(&mut self, buf: &[u8]) -> io::Result<usize> { self.0.write(buf) }
     fn flush(&mut self) -> io::Result<()> { Ok(()) }
@@ -160,11 +182,20 @@ impl TcpListener {
     ///
     /// The address type can be any implementer of `ToSocketAddrs` trait. See
     /// its documentation for concrete examples.
-    pub fn bind<A: ToSocketAddrs + ?Sized>(addr: &A) -> io::Result<TcpListener> {
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn bind<A: ToSocketAddrs>(addr: A) -> io::Result<TcpListener> {
         super::each_addr(addr, net_imp::TcpListener::bind).map(TcpListener)
     }
 
     /// Returns the local socket address of this listener.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn local_addr(&self) -> io::Result<SocketAddr> {
+        self.0.socket_addr()
+    }
+
+    /// Deprecated, renamed to local_addr
+    #[unstable(feature = "net")]
+    #[deprecated(since = "1.0.0", reason = "renamed to local_addr")]
     pub fn socket_addr(&self) -> io::Result<SocketAddr> {
         self.0.socket_addr()
     }
@@ -174,6 +205,7 @@ impl TcpListener {
     /// The returned `TcpListener` is a reference to the same socket that this
     /// object references. Both handles can be used to accept incoming
     /// connections and options set on one listener will affect the other.
+    #[stable(feature = "rust1", since = "1.0.0")]
     pub fn try_clone(&self) -> io::Result<TcpListener> {
         self.0.duplicate().map(TcpListener)
     }
@@ -183,6 +215,7 @@ impl TcpListener {
     /// This function will block the calling thread until a new TCP connection
     /// is established. When established, the corresponding `TcpStream` and the
     /// remote peer's address will be returned.
+    #[stable(feature = "rust1", since = "1.0.0")]
     pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> {
         self.0.accept().map(|(a, b)| (TcpStream(a), b))
     }
@@ -192,11 +225,13 @@ impl TcpListener {
     ///
     /// The returned iterator will never returned `None` and will also not yield
     /// the peer's `SocketAddr` structure.
+    #[stable(feature = "rust1", since = "1.0.0")]
     pub fn incoming(&self) -> Incoming {
         Incoming { listener: self }
     }
 }
 
+#[stable(feature = "rust1", since = "1.0.0")]
 impl<'a> Iterator for Incoming<'a> {
     type Item = io::Result<TcpStream>;
     fn next(&mut self) -> Option<io::Result<TcpStream>> {
diff --git a/src/libstd/net/test.rs b/src/libstd/net/test.rs
index dbebede9f50..3d42472f0fc 100644
--- a/src/libstd/net/test.rs
+++ b/src/libstd/net/test.rs
@@ -11,19 +11,20 @@
 use prelude::v1::*;
 
 use env;
-use net::{SocketAddr, IpAddr};
+use net::{SocketAddr, SocketAddrV4, SocketAddrV6, Ipv4Addr, Ipv6Addr};
 use sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
 
 static PORT: AtomicUsize = ATOMIC_USIZE_INIT;
 
 pub fn next_test_ip4() -> SocketAddr {
-    SocketAddr::new(IpAddr::new_v4(127, 0, 0, 1),
-                    PORT.fetch_add(1, Ordering::SeqCst) as u16 + base_port())
+    let port = PORT.fetch_add(1, Ordering::SeqCst) as u16 + base_port();
+    SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), port))
 }
 
 pub fn next_test_ip6() -> SocketAddr {
-    SocketAddr::new(IpAddr::new_v6(0, 0, 0, 0, 0, 0, 0, 1),
-                    PORT.fetch_add(1, Ordering::SeqCst) as u16 + base_port())
+    let port = PORT.fetch_add(1, Ordering::SeqCst) as u16 + base_port();
+    SocketAddr::V6(SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1),
+                                     port, 0, 0))
 }
 
 // The bots run multiple builds at the same time, and these builds
diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs
index 041e6551ff5..1ace1957526 100644
--- a/src/libstd/net/udp.rs
+++ b/src/libstd/net/udp.rs
@@ -8,10 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![unstable(feature = "udp", reason = "remaining functions have not been \
+                                       scrutinized enough to be stabilized")]
+
 use prelude::v1::*;
 
 use io::{self, Error, ErrorKind};
-use net::{ToSocketAddrs, SocketAddr, IpAddr};
+use net::{ToSocketAddrs, SocketAddr};
 use sys_common::net2 as net_imp;
 use sys_common::AsInner;
 
@@ -41,6 +44,7 @@ use sys_common::AsInner;
 /// # Ok(())
 /// # }
 /// ```
+#[stable(feature = "rust1", since = "1.0.0")]
 pub struct UdpSocket(net_imp::UdpSocket);
 
 impl UdpSocket {
@@ -48,12 +52,14 @@ impl UdpSocket {
     ///
     /// Address type can be any implementor of `ToSocketAddr` trait. See its
     /// documentation for concrete examples.
-    pub fn bind<A: ToSocketAddrs + ?Sized>(addr: &A) -> io::Result<UdpSocket> {
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn bind<A: ToSocketAddrs>(addr: A) -> io::Result<UdpSocket> {
         super::each_addr(addr, net_imp::UdpSocket::bind).map(UdpSocket)
     }
 
     /// Receives data from the socket. On success, returns the number of bytes
     /// read and the address from whence the data came.
+    #[stable(feature = "rust1", since = "1.0.0")]
     pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
         self.0.recv_from(buf)
     }
@@ -63,8 +69,9 @@ impl UdpSocket {
     ///
     /// Address type can be any implementor of `ToSocketAddrs` trait. See its
     /// documentation for concrete examples.
-    pub fn send_to<A: ToSocketAddrs + ?Sized>(&self, buf: &[u8], addr: &A)
-                                              -> io::Result<usize> {
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn send_to<A: ToSocketAddrs>(&self, buf: &[u8], addr: A)
+                                     -> io::Result<usize> {
         match try!(addr.to_socket_addrs()).next() {
             Some(addr) => self.0.send_to(buf, &addr),
             None => Err(Error::new(ErrorKind::InvalidInput,
@@ -73,15 +80,24 @@ impl UdpSocket {
     }
 
     /// Returns the socket address that this socket was created from.
+    #[unstable(feature = "net")]
+    #[deprecated(since = "1.0.0", reason = "renamed to local_addr")]
     pub fn socket_addr(&self) -> io::Result<SocketAddr> {
         self.0.socket_addr()
     }
 
+    /// Returns the socket address that this socket was created from.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn local_addr(&self) -> io::Result<SocketAddr> {
+        self.0.socket_addr()
+    }
+
     /// Create a new independently owned handle to the underlying socket.
     ///
     /// The returned `UdpSocket` is a reference to the same socket that this
     /// object references. Both handles will read and write the same port, and
     /// options set on one socket will be propagated to the other.
+    #[stable(feature = "rust1", since = "1.0.0")]
     pub fn try_clone(&self) -> io::Result<UdpSocket> {
         self.0.duplicate().map(UdpSocket)
     }
@@ -99,12 +115,12 @@ impl UdpSocket {
     }
 
     /// Joins a multicast IP address (becomes a member of it)
-    pub fn join_multicast(&self, multi: &IpAddr) -> io::Result<()> {
+    pub fn join_multicast(&self, multi: &SocketAddr) -> io::Result<()> {
         self.0.join_multicast(multi)
     }
 
     /// Leaves a multicast IP address (drops membership from it)
-    pub fn leave_multicast(&self, multi: &IpAddr) -> io::Result<()> {
+    pub fn leave_multicast(&self, multi: &SocketAddr) -> io::Result<()> {
         self.0.leave_multicast(multi)
     }
 
@@ -151,7 +167,7 @@ mod tests {
     #[cfg_attr(any(windows, target_os = "android"), ignore)]
     #[test]
     fn bind_error() {
-        let addr = SocketAddr::new(IpAddr::new_v4(0, 0, 0, 0), 1);
+        let addr = SocketAddrV4::new(Ipv4Addr::new(0, 0, 0, 0), 1);
         match UdpSocket::bind(&addr) {
             Ok(..) => panic!(),
             Err(e) => assert_eq!(e.kind(), ErrorKind::PermissionDenied),
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs
index 969dd35ba22..a7825c4f93a 100644
--- a/src/libstd/num/f32.rs
+++ b/src/libstd/num/f32.rs
@@ -357,6 +357,1236 @@ impl Float for f32 {
     }
 }
 
+#[cfg(not(stage0))]
+#[cfg(not(test))]
+#[lang = "f32"]
+#[stable(feature = "rust1", since = "1.0.0")]
+impl f32 {
+    // inlined methods from `num::Float`
+    /// Returns the `NaN` value.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let nan: f32 = Float::nan();
+    ///
+    /// assert!(nan.is_nan());
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn nan() -> f32 { num::Float::nan() }
+
+    /// Returns the infinite value.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f32;
+    ///
+    /// let infinity: f32 = Float::infinity();
+    ///
+    /// assert!(infinity.is_infinite());
+    /// assert!(!infinity.is_finite());
+    /// assert!(infinity > f32::MAX);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn infinity() -> f32 { num::Float::infinity() }
+
+    /// Returns the negative infinite value.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f32;
+    ///
+    /// let neg_infinity: f32 = Float::neg_infinity();
+    ///
+    /// assert!(neg_infinity.is_infinite());
+    /// assert!(!neg_infinity.is_finite());
+    /// assert!(neg_infinity < f32::MIN);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn neg_infinity() -> f32 { num::Float::neg_infinity() }
+
+    /// Returns `0.0`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let inf: f32 = Float::infinity();
+    /// let zero: f32 = Float::zero();
+    /// let neg_zero: f32 = Float::neg_zero();
+    ///
+    /// assert_eq!(zero, neg_zero);
+    /// assert_eq!(7.0f32/inf, zero);
+    /// assert_eq!(zero * 10.0, zero);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn zero() -> f32 { num::Float::zero() }
+
+    /// Returns `-0.0`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let inf: f32 = Float::infinity();
+    /// let zero: f32 = Float::zero();
+    /// let neg_zero: f32 = Float::neg_zero();
+    ///
+    /// assert_eq!(zero, neg_zero);
+    /// assert_eq!(7.0f32/inf, zero);
+    /// assert_eq!(zero * 10.0, zero);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn neg_zero() -> f32 { num::Float::neg_zero() }
+
+    /// Returns `1.0`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let one: f32 = Float::one();
+    ///
+    /// assert_eq!(one, 1.0f32);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn one() -> f32 { num::Float::one() }
+
+    // FIXME (#5527): These should be associated constants
+
+    /// Deprecated: use `std::f32::MANTISSA_DIGITS` or `std::f64::MANTISSA_DIGITS`
+    /// instead.
+    #[unstable(feature = "std_misc")]
+    #[deprecated(since = "1.0.0",
+                 reason = "use `std::f32::MANTISSA_DIGITS` or \
+                           `std::f64::MANTISSA_DIGITS` as appropriate")]
+    #[allow(deprecated)]
+    #[inline]
+    pub fn mantissa_digits(unused_self: Option<f32>) -> uint {
+        num::Float::mantissa_digits(unused_self)
+    }
+
+    /// Deprecated: use `std::f32::DIGITS` or `std::f64::DIGITS` instead.
+    #[unstable(feature = "std_misc")]
+    #[deprecated(since = "1.0.0",
+                 reason = "use `std::f32::DIGITS` or `std::f64::DIGITS` as appropriate")]
+    #[allow(deprecated)]
+    #[inline]
+    pub fn digits(unused_self: Option<f32>) -> uint { num::Float::digits(unused_self) }
+
+    /// Deprecated: use `std::f32::EPSILON` or `std::f64::EPSILON` instead.
+    #[unstable(feature = "std_misc")]
+    #[deprecated(since = "1.0.0",
+                 reason = "use `std::f32::EPSILON` or `std::f64::EPSILON` as appropriate")]
+    #[allow(deprecated)]
+    #[inline]
+    pub fn epsilon() -> f32 { num::Float::epsilon() }
+
+    /// Deprecated: use `std::f32::MIN_EXP` or `std::f64::MIN_EXP` instead.
+    #[unstable(feature = "std_misc")]
+    #[deprecated(since = "1.0.0",
+                 reason = "use `std::f32::MIN_EXP` or `std::f64::MIN_EXP` as appropriate")]
+    #[allow(deprecated)]
+    #[inline]
+    pub fn min_exp(unused_self: Option<f32>) -> int { num::Float::min_exp(unused_self) }
+
+    /// Deprecated: use `std::f32::MAX_EXP` or `std::f64::MAX_EXP` instead.
+    #[unstable(feature = "std_misc")]
+    #[deprecated(since = "1.0.0",
+                 reason = "use `std::f32::MAX_EXP` or `std::f64::MAX_EXP` as appropriate")]
+    #[allow(deprecated)]
+    #[inline]
+    pub fn max_exp(unused_self: Option<f32>) -> int { num::Float::max_exp(unused_self) }
+
+    /// Deprecated: use `std::f32::MIN_10_EXP` or `std::f64::MIN_10_EXP` instead.
+    #[unstable(feature = "std_misc")]
+    #[deprecated(since = "1.0.0",
+                 reason = "use `std::f32::MIN_10_EXP` or `std::f64::MIN_10_EXP` as appropriate")]
+    #[allow(deprecated)]
+    #[inline]
+    pub fn min_10_exp(unused_self: Option<f32>) -> int { num::Float::min_10_exp(unused_self) }
+
+    /// Deprecated: use `std::f32::MAX_10_EXP` or `std::f64::MAX_10_EXP` instead.
+    #[unstable(feature = "std_misc")]
+    #[deprecated(since = "1.0.0",
+                 reason = "use `std::f32::MAX_10_EXP` or `std::f64::MAX_10_EXP` as appropriate")]
+    #[allow(deprecated)]
+    #[inline]
+    pub fn max_10_exp(unused_self: Option<f32>) -> int { num::Float::max_10_exp(unused_self) }
+
+    /// Returns the smallest finite value that this type can represent.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let x: f64 = Float::min_value();
+    ///
+    /// assert_eq!(x, f64::MIN);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    #[allow(deprecated)]
+    pub fn min_value() -> f32 { num::Float::min_value() }
+
+    /// Returns the smallest normalized positive number that this type can represent.
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    #[allow(deprecated)]
+    pub fn min_pos_value(unused_self: Option<f32>) -> f32 { num::Float::min_pos_value(unused_self) }
+
+    /// Returns the largest finite value that this type can represent.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let x: f64 = Float::max_value();
+    /// assert_eq!(x, f64::MAX);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    #[allow(deprecated)]
+    pub fn max_value() -> f32 { num::Float::max_value() }
+
+    /// Returns `true` if this value is `NaN` and false otherwise.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let nan = f64::NAN;
+    /// let f = 7.0;
+    ///
+    /// assert!(nan.is_nan());
+    /// assert!(!f.is_nan());
+    /// ```
+    #[unstable(feature = "std_misc", reason = "position is undecided")]
+    #[inline]
+    pub fn is_nan(self) -> bool { num::Float::is_nan(self) }
+
+    /// Returns `true` if this value is positive infinity or negative infinity and
+    /// false otherwise.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f32;
+    ///
+    /// let f = 7.0f32;
+    /// let inf: f32 = Float::infinity();
+    /// let neg_inf: f32 = Float::neg_infinity();
+    /// let nan: f32 = f32::NAN;
+    ///
+    /// assert!(!f.is_infinite());
+    /// assert!(!nan.is_infinite());
+    ///
+    /// assert!(inf.is_infinite());
+    /// assert!(neg_inf.is_infinite());
+    /// ```
+    #[unstable(feature = "std_misc", reason = "position is undecided")]
+    #[inline]
+    pub fn is_infinite(self) -> bool { num::Float::is_infinite(self) }
+
+    /// Returns `true` if this number is neither infinite nor `NaN`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f32;
+    ///
+    /// let f = 7.0f32;
+    /// let inf: f32 = Float::infinity();
+    /// let neg_inf: f32 = Float::neg_infinity();
+    /// let nan: f32 = f32::NAN;
+    ///
+    /// assert!(f.is_finite());
+    ///
+    /// assert!(!nan.is_finite());
+    /// assert!(!inf.is_finite());
+    /// assert!(!neg_inf.is_finite());
+    /// ```
+    #[unstable(feature = "std_misc", reason = "position is undecided")]
+    #[inline]
+    pub fn is_finite(self) -> bool { num::Float::is_finite(self) }
+
+    /// Returns `true` if the number is neither zero, infinite,
+    /// [subnormal][subnormal], or `NaN`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f32;
+    ///
+    /// let min = f32::MIN_POSITIVE; // 1.17549435e-38f32
+    /// let max = f32::MAX;
+    /// let lower_than_min = 1.0e-40_f32;
+    /// let zero = 0.0f32;
+    ///
+    /// assert!(min.is_normal());
+    /// assert!(max.is_normal());
+    ///
+    /// assert!(!zero.is_normal());
+    /// assert!(!f32::NAN.is_normal());
+    /// assert!(!f32::INFINITY.is_normal());
+    /// // Values between `0` and `min` are Subnormal.
+    /// assert!(!lower_than_min.is_normal());
+    /// ```
+    /// [subnormal]: http://en.wikipedia.org/wiki/Denormal_number
+    #[unstable(feature = "std_misc", reason = "position is undecided")]
+    #[inline]
+    pub fn is_normal(self) -> bool { num::Float::is_normal(self) }
+
+    /// Returns the floating point category of the number. If only one property
+    /// is going to be tested, it is generally faster to use the specific
+    /// predicate instead.
+    ///
+    /// ```
+    /// use std::num::{Float, FpCategory};
+    /// use std::f32;
+    ///
+    /// let num = 12.4f32;
+    /// let inf = f32::INFINITY;
+    ///
+    /// assert_eq!(num.classify(), FpCategory::Normal);
+    /// assert_eq!(inf.classify(), FpCategory::Infinite);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn classify(self) -> FpCategory { num::Float::classify(self) }
+
+    /// Returns the mantissa, base 2 exponent, and sign as integers, respectively.
+    /// The original number can be recovered by `sign * mantissa * 2 ^ exponent`.
+    /// The floating point encoding is documented in the [Reference][floating-point].
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let num = 2.0f32;
+    ///
+    /// // (8388608, -22, 1)
+    /// let (mantissa, exponent, sign) = num.integer_decode();
+    /// let sign_f = sign as f32;
+    /// let mantissa_f = mantissa as f32;
+    /// let exponent_f = num.powf(exponent as f32);
+    ///
+    /// // 1 * 8388608 * 2^(-22) == 2
+    /// let abs_difference = (sign_f * mantissa_f * exponent_f - num).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    /// [floating-point]: ../../../../../reference.html#machine-types
+    #[unstable(feature = "std_misc", reason = "signature is undecided")]
+    #[inline]
+    pub fn integer_decode(self) -> (u64, i16, i8) { num::Float::integer_decode(self) }
+
+    /// Returns the largest integer less than or equal to a number.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let f = 3.99;
+    /// let g = 3.0;
+    ///
+    /// assert_eq!(f.floor(), 3.0);
+    /// assert_eq!(g.floor(), 3.0);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn floor(self) -> f32 { num::Float::floor(self) }
+
+    /// Returns the smallest integer greater than or equal to a number.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let f = 3.01;
+    /// let g = 4.0;
+    ///
+    /// assert_eq!(f.ceil(), 4.0);
+    /// assert_eq!(g.ceil(), 4.0);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn ceil(self) -> f32 { num::Float::ceil(self) }
+
+    /// Returns the nearest integer to a number. Round half-way cases away from
+    /// `0.0`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let f = 3.3;
+    /// let g = -3.3;
+    ///
+    /// assert_eq!(f.round(), 3.0);
+    /// assert_eq!(g.round(), -3.0);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn round(self) -> f32 { num::Float::round(self) }
+
+    /// Return the integer part of a number.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let f = 3.3;
+    /// let g = -3.7;
+    ///
+    /// assert_eq!(f.trunc(), 3.0);
+    /// assert_eq!(g.trunc(), -3.0);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn trunc(self) -> f32 { num::Float::trunc(self) }
+
+    /// Returns the fractional part of a number.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 3.5;
+    /// let y = -3.5;
+    /// let abs_difference_x = (x.fract() - 0.5).abs();
+    /// let abs_difference_y = (y.fract() - (-0.5)).abs();
+    ///
+    /// assert!(abs_difference_x < 1e-10);
+    /// assert!(abs_difference_y < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn fract(self) -> f32 { num::Float::fract(self) }
+
+    /// Computes the absolute value of `self`. Returns `Float::nan()` if the
+    /// number is `Float::nan()`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let x = 3.5;
+    /// let y = -3.5;
+    ///
+    /// let abs_difference_x = (x.abs() - x).abs();
+    /// let abs_difference_y = (y.abs() - (-y)).abs();
+    ///
+    /// assert!(abs_difference_x < 1e-10);
+    /// assert!(abs_difference_y < 1e-10);
+    ///
+    /// assert!(f64::NAN.abs().is_nan());
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn abs(self) -> f32 { num::Float::abs(self) }
+
+    /// Returns a number that represents the sign of `self`.
+    ///
+    /// - `1.0` if the number is positive, `+0.0` or `Float::infinity()`
+    /// - `-1.0` if the number is negative, `-0.0` or `Float::neg_infinity()`
+    /// - `Float::nan()` if the number is `Float::nan()`
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let f = 3.5;
+    ///
+    /// assert_eq!(f.signum(), 1.0);
+    /// assert_eq!(f64::NEG_INFINITY.signum(), -1.0);
+    ///
+    /// assert!(f64::NAN.signum().is_nan());
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn signum(self) -> f32 { num::Float::signum(self) }
+
+    /// Returns `true` if `self` is positive, including `+0.0` and
+    /// `Float::infinity()`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let nan: f64 = f64::NAN;
+    ///
+    /// let f = 7.0;
+    /// let g = -7.0;
+    ///
+    /// assert!(f.is_positive());
+    /// assert!(!g.is_positive());
+    /// // Requires both tests to determine if is `NaN`
+    /// assert!(!nan.is_positive() && !nan.is_negative());
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn is_positive(self) -> bool { num::Float::is_positive(self) }
+
+    /// Returns `true` if `self` is negative, including `-0.0` and
+    /// `Float::neg_infinity()`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let nan = f64::NAN;
+    ///
+    /// let f = 7.0;
+    /// let g = -7.0;
+    ///
+    /// assert!(!f.is_negative());
+    /// assert!(g.is_negative());
+    /// // Requires both tests to determine if is `NaN`.
+    /// assert!(!nan.is_positive() && !nan.is_negative());
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn is_negative(self) -> bool { num::Float::is_negative(self) }
+
+    /// Fused multiply-add. Computes `(self * a) + b` with only one rounding
+    /// error. This produces a more accurate result with better performance than
+    /// a separate multiplication operation followed by an add.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let m = 10.0;
+    /// let x = 4.0;
+    /// let b = 60.0;
+    ///
+    /// // 100.0
+    /// let abs_difference = (m.mul_add(x, b) - (m*x + b)).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn mul_add(self, a: f32, b: f32) -> f32 { num::Float::mul_add(self, a, b) }
+
+    /// Take the reciprocal (inverse) of a number, `1/x`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 2.0;
+    /// let abs_difference = (x.recip() - (1.0/x)).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn recip(self) -> f32 { num::Float::recip(self) }
+
+    /// Raise a number to an integer power.
+    ///
+    /// Using this function is generally faster than using `powf`
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 2.0;
+    /// let abs_difference = (x.powi(2) - x*x).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn powi(self, n: i32) -> f32 { num::Float::powi(self, n) }
+
+    /// Raise a number to a floating point power.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 2.0;
+    /// let abs_difference = (x.powf(2.0) - x*x).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn powf(self, n: f32) -> f32 { num::Float::powf(self, n) }
+
+    /// Take the square root of a number.
+    ///
+    /// Returns NaN if `self` is a negative number.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let positive = 4.0;
+    /// let negative = -4.0;
+    ///
+    /// let abs_difference = (positive.sqrt() - 2.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// assert!(negative.sqrt().is_nan());
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn sqrt(self) -> f32 { num::Float::sqrt(self) }
+
+
+    /// Take the reciprocal (inverse) square root of a number, `1/sqrt(x)`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let f = 4.0;
+    ///
+    /// let abs_difference = (f.rsqrt() - 0.5).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn rsqrt(self) -> f32 { num::Float::rsqrt(self) }
+
+    /// Returns `e^(self)`, (the exponential function).
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let one = 1.0;
+    /// // e^1
+    /// let e = one.exp();
+    ///
+    /// // ln(e) - 1 == 0
+    /// let abs_difference = (e.ln() - 1.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn exp(self) -> f32 { num::Float::exp(self) }
+
+    /// Returns `2^(self)`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let f = 2.0;
+    ///
+    /// // 2^2 - 4 == 0
+    /// let abs_difference = (f.exp2() - 4.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn exp2(self) -> f32 { num::Float::exp2(self) }
+
+    /// Returns the natural logarithm of the number.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let one = 1.0;
+    /// // e^1
+    /// let e = one.exp();
+    ///
+    /// // ln(e) - 1 == 0
+    /// let abs_difference = (e.ln() - 1.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn ln(self) -> f32 { num::Float::ln(self) }
+
+    /// Returns the logarithm of the number with respect to an arbitrary base.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let ten = 10.0;
+    /// let two = 2.0;
+    ///
+    /// // log10(10) - 1 == 0
+    /// let abs_difference_10 = (ten.log(10.0) - 1.0).abs();
+    ///
+    /// // log2(2) - 1 == 0
+    /// let abs_difference_2 = (two.log(2.0) - 1.0).abs();
+    ///
+    /// assert!(abs_difference_10 < 1e-10);
+    /// assert!(abs_difference_2 < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn log(self, base: f32) -> f32 { num::Float::log(self, base) }
+
+    /// Returns the base 2 logarithm of the number.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let two = 2.0;
+    ///
+    /// // log2(2) - 1 == 0
+    /// let abs_difference = (two.log2() - 1.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn log2(self) -> f32 { num::Float::log2(self) }
+
+    /// Returns the base 10 logarithm of the number.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let ten = 10.0;
+    ///
+    /// // log10(10) - 1 == 0
+    /// let abs_difference = (ten.log10() - 1.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn log10(self) -> f32 { num::Float::log10(self) }
+
+    /// Convert radians to degrees.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64::consts;
+    ///
+    /// let angle = consts::PI;
+    ///
+    /// let abs_difference = (angle.to_degrees() - 180.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc", reason = "desirability is unclear")]
+    #[inline]
+    pub fn to_degrees(self) -> f32 { num::Float::to_degrees(self) }
+
+    /// Convert degrees to radians.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64::consts;
+    ///
+    /// let angle = 180.0;
+    ///
+    /// let abs_difference = (angle.to_radians() - consts::PI).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc", reason = "desirability is unclear")]
+    #[inline]
+    pub fn to_radians(self) -> f32 { num::Float::to_radians(self) }
+
+    /// Constructs a floating point number of `x*2^exp`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// // 3*2^2 - 12 == 0
+    /// let abs_difference = (Float::ldexp(3.0, 2) - 12.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "pending integer conventions")]
+    #[inline]
+    pub fn ldexp(x: f32, exp: int) -> f32 {
+        unsafe { cmath::ldexpf(x, exp as c_int) }
+    }
+
+    /// Breaks the number into a normalized fraction and a base-2 exponent,
+    /// satisfying:
+    ///
+    ///  * `self = x * 2^exp`
+    ///  * `0.5 <= abs(x) < 1.0`
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 4.0;
+    ///
+    /// // (1/2)*2^3 -> 1 * 8/2 -> 4.0
+    /// let f = x.frexp();
+    /// let abs_difference_0 = (f.0 - 0.5).abs();
+    /// let abs_difference_1 = (f.1 as f64 - 3.0).abs();
+    ///
+    /// assert!(abs_difference_0 < 1e-10);
+    /// assert!(abs_difference_1 < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "pending integer conventions")]
+    #[inline]
+    pub fn frexp(self) -> (f32, int) {
+        unsafe {
+            let mut exp = 0;
+            let x = cmath::frexpf(self, &mut exp);
+            (x, exp as int)
+        }
+    }
+
+    /// Returns the next representable floating-point value in the direction of
+    /// `other`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 1.0f32;
+    ///
+    /// let abs_diff = (x.next_after(2.0) - 1.00000011920928955078125_f32).abs();
+    ///
+    /// assert!(abs_diff < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn next_after(self, other: f32) -> f32 {
+        unsafe { cmath::nextafterf(self, other) }
+    }
+
+    /// Returns the maximum of the two numbers.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 1.0;
+    /// let y = 2.0;
+    ///
+    /// assert_eq!(x.max(y), y);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn max(self, other: f32) -> f32 {
+        unsafe { cmath::fmaxf(self, other) }
+    }
+
+    /// Returns the minimum of the two numbers.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 1.0;
+    /// let y = 2.0;
+    ///
+    /// assert_eq!(x.min(y), x);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn min(self, other: f32) -> f32 {
+        unsafe { cmath::fminf(self, other) }
+    }
+
+    /// The positive difference of two numbers.
+    ///
+    /// * If `self <= other`: `0:0`
+    /// * Else: `self - other`
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 3.0;
+    /// let y = -3.0;
+    ///
+    /// let abs_difference_x = (x.abs_sub(1.0) - 2.0).abs();
+    /// let abs_difference_y = (y.abs_sub(1.0) - 0.0).abs();
+    ///
+    /// assert!(abs_difference_x < 1e-10);
+    /// assert!(abs_difference_y < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc", reason = "may be renamed")]
+    #[inline]
+    pub fn abs_sub(self, other: f32) -> f32 {
+        unsafe { cmath::fdimf(self, other) }
+    }
+
+    /// Take the cubic root of a number.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 8.0;
+    ///
+    /// // x^(1/3) - 2 == 0
+    /// let abs_difference = (x.cbrt() - 2.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc", reason = "may be renamed")]
+    #[inline]
+    pub fn cbrt(self) -> f32 {
+        unsafe { cmath::cbrtf(self) }
+    }
+
+    /// Calculate the length of the hypotenuse of a right-angle triangle given
+    /// legs of length `x` and `y`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 2.0;
+    /// let y = 3.0;
+    ///
+    /// // sqrt(x^2 + y^2)
+    /// let abs_difference = (x.hypot(y) - (x.powi(2) + y.powi(2)).sqrt()).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn hypot(self, other: f32) -> f32 {
+        unsafe { cmath::hypotf(self, other) }
+    }
+
+    /// Computes the sine of a number (in radians).
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let x = f64::consts::PI/2.0;
+    ///
+    /// let abs_difference = (x.sin() - 1.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn sin(self) -> f32 {
+        unsafe { intrinsics::sinf32(self) }
+    }
+
+    /// Computes the cosine of a number (in radians).
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let x = 2.0*f64::consts::PI;
+    ///
+    /// let abs_difference = (x.cos() - 1.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn cos(self) -> f32 {
+        unsafe { intrinsics::cosf32(self) }
+    }
+
+    /// Computes the tangent of a number (in radians).
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let x = f64::consts::PI/4.0;
+    /// let abs_difference = (x.tan() - 1.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-14);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn tan(self) -> f32 {
+        unsafe { cmath::tanf(self) }
+    }
+
+    /// Computes the arcsine of a number. Return value is in radians in
+    /// the range [-pi/2, pi/2] or NaN if the number is outside the range
+    /// [-1, 1].
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let f = f64::consts::PI / 2.0;
+    ///
+    /// // asin(sin(pi/2))
+    /// let abs_difference = (f.sin().asin() - f64::consts::PI / 2.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn asin(self) -> f32 {
+        unsafe { cmath::asinf(self) }
+    }
+
+    /// Computes the arccosine of a number. Return value is in radians in
+    /// the range [0, pi] or NaN if the number is outside the range
+    /// [-1, 1].
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let f = f64::consts::PI / 4.0;
+    ///
+    /// // acos(cos(pi/4))
+    /// let abs_difference = (f.cos().acos() - f64::consts::PI / 4.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn acos(self) -> f32 {
+        unsafe { cmath::acosf(self) }
+    }
+
+    /// Computes the arctangent of a number. Return value is in radians in the
+    /// range [-pi/2, pi/2];
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let f = 1.0;
+    ///
+    /// // atan(tan(1))
+    /// let abs_difference = (f.tan().atan() - 1.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn atan(self) -> f32 {
+        unsafe { cmath::atanf(self) }
+    }
+
+    /// Computes the four quadrant arctangent of `self` (`y`) and `other` (`x`).
+    ///
+    /// * `x = 0`, `y = 0`: `0`
+    /// * `x >= 0`: `arctan(y/x)` -> `[-pi/2, pi/2]`
+    /// * `y >= 0`: `arctan(y/x) + pi` -> `(pi/2, pi]`
+    /// * `y < 0`: `arctan(y/x) - pi` -> `(-pi, -pi/2)`
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let pi = f64::consts::PI;
+    /// // All angles from horizontal right (+x)
+    /// // 45 deg counter-clockwise
+    /// let x1 = 3.0;
+    /// let y1 = -3.0;
+    ///
+    /// // 135 deg clockwise
+    /// let x2 = -3.0;
+    /// let y2 = 3.0;
+    ///
+    /// let abs_difference_1 = (y1.atan2(x1) - (-pi/4.0)).abs();
+    /// let abs_difference_2 = (y2.atan2(x2) - 3.0*pi/4.0).abs();
+    ///
+    /// assert!(abs_difference_1 < 1e-10);
+    /// assert!(abs_difference_2 < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn atan2(self, other: f32) -> f32 {
+        unsafe { cmath::atan2f(self, other) }
+    }
+
+    /// Simultaneously computes the sine and cosine of the number, `x`. Returns
+    /// `(sin(x), cos(x))`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let x = f64::consts::PI/4.0;
+    /// let f = x.sin_cos();
+    ///
+    /// let abs_difference_0 = (f.0 - x.sin()).abs();
+    /// let abs_difference_1 = (f.1 - x.cos()).abs();
+    ///
+    /// assert!(abs_difference_0 < 1e-10);
+    /// assert!(abs_difference_0 < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn sin_cos(self) -> (f32, f32) {
+        (self.sin(), self.cos())
+    }
+
+    /// Returns `e^(self) - 1` in a way that is accurate even if the
+    /// number is close to zero.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 7.0;
+    ///
+    /// // e^(ln(7)) - 1
+    /// let abs_difference = (x.ln().exp_m1() - 6.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc", reason = "may be renamed")]
+    #[inline]
+    pub fn exp_m1(self) -> f32 {
+        unsafe { cmath::expm1f(self) }
+    }
+
+    /// Returns `ln(1+n)` (natural logarithm) more accurately than if
+    /// the operations were performed separately.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let x = f64::consts::E - 1.0;
+    ///
+    /// // ln(1 + (e - 1)) == ln(e) == 1
+    /// let abs_difference = (x.ln_1p() - 1.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc", reason = "may be renamed")]
+    #[inline]
+    pub fn ln_1p(self) -> f32 {
+        unsafe { cmath::log1pf(self) }
+    }
+
+    /// Hyperbolic sine function.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let e = f64::consts::E;
+    /// let x = 1.0;
+    ///
+    /// let f = x.sinh();
+    /// // Solving sinh() at 1 gives `(e^2-1)/(2e)`
+    /// let g = (e*e - 1.0)/(2.0*e);
+    /// let abs_difference = (f - g).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn sinh(self) -> f32 {
+        unsafe { cmath::sinhf(self) }
+    }
+
+    /// Hyperbolic cosine function.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let e = f64::consts::E;
+    /// let x = 1.0;
+    /// let f = x.cosh();
+    /// // Solving cosh() at 1 gives this result
+    /// let g = (e*e + 1.0)/(2.0*e);
+    /// let abs_difference = (f - g).abs();
+    ///
+    /// // Same result
+    /// assert!(abs_difference < 1.0e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn cosh(self) -> f32 {
+        unsafe { cmath::coshf(self) }
+    }
+
+    /// Hyperbolic tangent function.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let e = f64::consts::E;
+    /// let x = 1.0;
+    ///
+    /// let f = x.tanh();
+    /// // Solving tanh() at 1 gives `(1 - e^(-2))/(1 + e^(-2))`
+    /// let g = (1.0 - e.powi(-2))/(1.0 + e.powi(-2));
+    /// let abs_difference = (f - g).abs();
+    ///
+    /// assert!(abs_difference < 1.0e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn tanh(self) -> f32 {
+        unsafe { cmath::tanhf(self) }
+    }
+
+    /// Inverse hyperbolic sine function.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 1.0;
+    /// let f = x.sinh().asinh();
+    ///
+    /// let abs_difference = (f - x).abs();
+    ///
+    /// assert!(abs_difference < 1.0e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn asinh(self) -> f32 {
+        match self {
+            NEG_INFINITY => NEG_INFINITY,
+            x => (x + ((x * x) + 1.0).sqrt()).ln(),
+        }
+    }
+
+    /// Inverse hyperbolic cosine function.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 1.0;
+    /// let f = x.cosh().acosh();
+    ///
+    /// let abs_difference = (f - x).abs();
+    ///
+    /// assert!(abs_difference < 1.0e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn acosh(self) -> f32 {
+        match self {
+            x if x < 1.0 => Float::nan(),
+            x => (x + ((x * x) - 1.0).sqrt()).ln(),
+        }
+    }
+
+    /// Inverse hyperbolic tangent function.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let e = f64::consts::E;
+    /// let f = e.tanh().atanh();
+    ///
+    /// let abs_difference = (f - e).abs();
+    ///
+    /// assert!(abs_difference < 1.0e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn atanh(self) -> f32 {
+        0.5 * ((2.0 * self) / (1.0 - self)).ln_1p()
+    }
+}
+
 //
 // Section: String Conversions
 //
diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs
index 95065b59678..f3978cae485 100644
--- a/src/libstd/num/f64.rs
+++ b/src/libstd/num/f64.rs
@@ -366,6 +366,1235 @@ impl Float for f64 {
     }
 }
 
+#[cfg(not(stage0))]
+#[cfg(not(test))]
+#[lang = "f64"]
+#[stable(feature = "rust1", since = "1.0.0")]
+impl f64 {
+    // inlined methods from `num::Float`
+    /// Returns the `NaN` value.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let nan: f32 = Float::nan();
+    ///
+    /// assert!(nan.is_nan());
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn nan() -> f64 { num::Float::nan() }
+
+    /// Returns the infinite value.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f32;
+    ///
+    /// let infinity: f32 = Float::infinity();
+    ///
+    /// assert!(infinity.is_infinite());
+    /// assert!(!infinity.is_finite());
+    /// assert!(infinity > f32::MAX);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn infinity() -> f64 { num::Float::infinity() }
+
+    /// Returns the negative infinite value.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f32;
+    ///
+    /// let neg_infinity: f32 = Float::neg_infinity();
+    ///
+    /// assert!(neg_infinity.is_infinite());
+    /// assert!(!neg_infinity.is_finite());
+    /// assert!(neg_infinity < f32::MIN);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn neg_infinity() -> f64 { num::Float::neg_infinity() }
+
+    /// Returns `0.0`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let inf: f32 = Float::infinity();
+    /// let zero: f32 = Float::zero();
+    /// let neg_zero: f32 = Float::neg_zero();
+    ///
+    /// assert_eq!(zero, neg_zero);
+    /// assert_eq!(7.0f32/inf, zero);
+    /// assert_eq!(zero * 10.0, zero);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn zero() -> f64 { num::Float::zero() }
+
+    /// Returns `-0.0`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let inf: f32 = Float::infinity();
+    /// let zero: f32 = Float::zero();
+    /// let neg_zero: f32 = Float::neg_zero();
+    ///
+    /// assert_eq!(zero, neg_zero);
+    /// assert_eq!(7.0f32/inf, zero);
+    /// assert_eq!(zero * 10.0, zero);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn neg_zero() -> f64 { num::Float::neg_zero() }
+
+    /// Returns `1.0`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let one: f32 = Float::one();
+    ///
+    /// assert_eq!(one, 1.0f32);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn one() -> f64 { num::Float::one() }
+
+    // FIXME (#5527): These should be associated constants
+
+    /// Deprecated: use `std::f32::MANTISSA_DIGITS` or `std::f64::MANTISSA_DIGITS`
+    /// instead.
+    #[unstable(feature = "std_misc")]
+    #[deprecated(since = "1.0.0",
+                 reason = "use `std::f32::MANTISSA_DIGITS` or \
+                           `std::f64::MANTISSA_DIGITS` as appropriate")]
+    #[allow(deprecated)]
+    #[inline]
+    pub fn mantissa_digits(unused_self: Option<f64>) -> uint {
+        num::Float::mantissa_digits(unused_self)
+    }
+
+    /// Deprecated: use `std::f32::DIGITS` or `std::f64::DIGITS` instead.
+    #[unstable(feature = "std_misc")]
+    #[deprecated(since = "1.0.0",
+                 reason = "use `std::f32::DIGITS` or `std::f64::DIGITS` as appropriate")]
+    #[allow(deprecated)]
+    #[inline]
+    pub fn digits(unused_self: Option<f64>) -> uint { num::Float::digits(unused_self) }
+
+    /// Deprecated: use `std::f32::EPSILON` or `std::f64::EPSILON` instead.
+    #[unstable(feature = "std_misc")]
+    #[deprecated(since = "1.0.0",
+                 reason = "use `std::f32::EPSILON` or `std::f64::EPSILON` as appropriate")]
+    #[allow(deprecated)]
+    #[inline]
+    pub fn epsilon() -> f64 { num::Float::epsilon() }
+
+    /// Deprecated: use `std::f32::MIN_EXP` or `std::f64::MIN_EXP` instead.
+    #[unstable(feature = "std_misc")]
+    #[deprecated(since = "1.0.0",
+                 reason = "use `std::f32::MIN_EXP` or `std::f64::MIN_EXP` as appropriate")]
+    #[allow(deprecated)]
+    #[inline]
+    pub fn min_exp(unused_self: Option<f64>) -> int { num::Float::min_exp(unused_self) }
+
+    /// Deprecated: use `std::f32::MAX_EXP` or `std::f64::MAX_EXP` instead.
+    #[unstable(feature = "std_misc")]
+    #[deprecated(since = "1.0.0",
+                 reason = "use `std::f32::MAX_EXP` or `std::f64::MAX_EXP` as appropriate")]
+    #[allow(deprecated)]
+    #[inline]
+    pub fn max_exp(unused_self: Option<f64>) -> int { num::Float::max_exp(unused_self) }
+
+    /// Deprecated: use `std::f32::MIN_10_EXP` or `std::f64::MIN_10_EXP` instead.
+    #[unstable(feature = "std_misc")]
+    #[deprecated(since = "1.0.0",
+                 reason = "use `std::f32::MIN_10_EXP` or `std::f64::MIN_10_EXP` as appropriate")]
+    #[allow(deprecated)]
+    #[inline]
+    pub fn min_10_exp(unused_self: Option<f64>) -> int { num::Float::min_10_exp(unused_self) }
+
+    /// Deprecated: use `std::f32::MAX_10_EXP` or `std::f64::MAX_10_EXP` instead.
+    #[unstable(feature = "std_misc")]
+    #[deprecated(since = "1.0.0",
+                 reason = "use `std::f32::MAX_10_EXP` or `std::f64::MAX_10_EXP` as appropriate")]
+    #[allow(deprecated)]
+    #[inline]
+    pub fn max_10_exp(unused_self: Option<f64>) -> int { num::Float::max_10_exp(unused_self) }
+
+    /// Returns the smallest finite value that this type can represent.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let x: f64 = Float::min_value();
+    ///
+    /// assert_eq!(x, f64::MIN);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    #[allow(deprecated)]
+    pub fn min_value() -> f64 { num::Float::min_value() }
+
+    /// Returns the smallest normalized positive number that this type can represent.
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    #[allow(deprecated)]
+    pub fn min_pos_value(unused_self: Option<f64>) -> f64 { num::Float::min_pos_value(unused_self) }
+
+    /// Returns the largest finite value that this type can represent.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let x: f64 = Float::max_value();
+    /// assert_eq!(x, f64::MAX);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    #[allow(deprecated)]
+    pub fn max_value() -> f64 { num::Float::max_value() }
+
+    /// Returns `true` if this value is `NaN` and false otherwise.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let nan = f64::NAN;
+    /// let f = 7.0;
+    ///
+    /// assert!(nan.is_nan());
+    /// assert!(!f.is_nan());
+    /// ```
+    #[unstable(feature = "std_misc", reason = "position is undecided")]
+    #[inline]
+    pub fn is_nan(self) -> bool { num::Float::is_nan(self) }
+
+    /// Returns `true` if this value is positive infinity or negative infinity and
+    /// false otherwise.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f32;
+    ///
+    /// let f = 7.0f32;
+    /// let inf: f32 = Float::infinity();
+    /// let neg_inf: f32 = Float::neg_infinity();
+    /// let nan: f32 = f32::NAN;
+    ///
+    /// assert!(!f.is_infinite());
+    /// assert!(!nan.is_infinite());
+    ///
+    /// assert!(inf.is_infinite());
+    /// assert!(neg_inf.is_infinite());
+    /// ```
+    #[unstable(feature = "std_misc", reason = "position is undecided")]
+    #[inline]
+    pub fn is_infinite(self) -> bool { num::Float::is_infinite(self) }
+
+    /// Returns `true` if this number is neither infinite nor `NaN`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f32;
+    ///
+    /// let f = 7.0f32;
+    /// let inf: f32 = Float::infinity();
+    /// let neg_inf: f32 = Float::neg_infinity();
+    /// let nan: f32 = f32::NAN;
+    ///
+    /// assert!(f.is_finite());
+    ///
+    /// assert!(!nan.is_finite());
+    /// assert!(!inf.is_finite());
+    /// assert!(!neg_inf.is_finite());
+    /// ```
+    #[unstable(feature = "std_misc", reason = "position is undecided")]
+    #[inline]
+    pub fn is_finite(self) -> bool { num::Float::is_finite(self) }
+
+    /// Returns `true` if the number is neither zero, infinite,
+    /// [subnormal][subnormal], or `NaN`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f32;
+    ///
+    /// let min = f32::MIN_POSITIVE; // 1.17549435e-38f32
+    /// let max = f32::MAX;
+    /// let lower_than_min = 1.0e-40_f32;
+    /// let zero = 0.0f32;
+    ///
+    /// assert!(min.is_normal());
+    /// assert!(max.is_normal());
+    ///
+    /// assert!(!zero.is_normal());
+    /// assert!(!f32::NAN.is_normal());
+    /// assert!(!f32::INFINITY.is_normal());
+    /// // Values between `0` and `min` are Subnormal.
+    /// assert!(!lower_than_min.is_normal());
+    /// ```
+    /// [subnormal]: http://en.wikipedia.org/wiki/Denormal_number
+    #[unstable(feature = "std_misc", reason = "position is undecided")]
+    #[inline]
+    pub fn is_normal(self) -> bool { num::Float::is_normal(self) }
+
+    /// Returns the floating point category of the number. If only one property
+    /// is going to be tested, it is generally faster to use the specific
+    /// predicate instead.
+    ///
+    /// ```
+    /// use std::num::{Float, FpCategory};
+    /// use std::f32;
+    ///
+    /// let num = 12.4f32;
+    /// let inf = f32::INFINITY;
+    ///
+    /// assert_eq!(num.classify(), FpCategory::Normal);
+    /// assert_eq!(inf.classify(), FpCategory::Infinite);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn classify(self) -> FpCategory { num::Float::classify(self) }
+
+    /// Returns the mantissa, base 2 exponent, and sign as integers, respectively.
+    /// The original number can be recovered by `sign * mantissa * 2 ^ exponent`.
+    /// The floating point encoding is documented in the [Reference][floating-point].
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let num = 2.0f32;
+    ///
+    /// // (8388608, -22, 1)
+    /// let (mantissa, exponent, sign) = num.integer_decode();
+    /// let sign_f = sign as f32;
+    /// let mantissa_f = mantissa as f32;
+    /// let exponent_f = num.powf(exponent as f32);
+    ///
+    /// // 1 * 8388608 * 2^(-22) == 2
+    /// let abs_difference = (sign_f * mantissa_f * exponent_f - num).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    /// [floating-point]: ../../../../../reference.html#machine-types
+    #[unstable(feature = "std_misc", reason = "signature is undecided")]
+    #[inline]
+    pub fn integer_decode(self) -> (u64, i16, i8) { num::Float::integer_decode(self) }
+
+    /// Returns the largest integer less than or equal to a number.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let f = 3.99;
+    /// let g = 3.0;
+    ///
+    /// assert_eq!(f.floor(), 3.0);
+    /// assert_eq!(g.floor(), 3.0);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn floor(self) -> f64 { num::Float::floor(self) }
+
+    /// Returns the smallest integer greater than or equal to a number.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let f = 3.01;
+    /// let g = 4.0;
+    ///
+    /// assert_eq!(f.ceil(), 4.0);
+    /// assert_eq!(g.ceil(), 4.0);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn ceil(self) -> f64 { num::Float::ceil(self) }
+
+    /// Returns the nearest integer to a number. Round half-way cases away from
+    /// `0.0`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let f = 3.3;
+    /// let g = -3.3;
+    ///
+    /// assert_eq!(f.round(), 3.0);
+    /// assert_eq!(g.round(), -3.0);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn round(self) -> f64 { num::Float::round(self) }
+
+    /// Return the integer part of a number.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let f = 3.3;
+    /// let g = -3.7;
+    ///
+    /// assert_eq!(f.trunc(), 3.0);
+    /// assert_eq!(g.trunc(), -3.0);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn trunc(self) -> f64 { num::Float::trunc(self) }
+
+    /// Returns the fractional part of a number.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 3.5;
+    /// let y = -3.5;
+    /// let abs_difference_x = (x.fract() - 0.5).abs();
+    /// let abs_difference_y = (y.fract() - (-0.5)).abs();
+    ///
+    /// assert!(abs_difference_x < 1e-10);
+    /// assert!(abs_difference_y < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn fract(self) -> f64 { num::Float::fract(self) }
+
+    /// Computes the absolute value of `self`. Returns `Float::nan()` if the
+    /// number is `Float::nan()`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let x = 3.5;
+    /// let y = -3.5;
+    ///
+    /// let abs_difference_x = (x.abs() - x).abs();
+    /// let abs_difference_y = (y.abs() - (-y)).abs();
+    ///
+    /// assert!(abs_difference_x < 1e-10);
+    /// assert!(abs_difference_y < 1e-10);
+    ///
+    /// assert!(f64::NAN.abs().is_nan());
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn abs(self) -> f64 { num::Float::abs(self) }
+
+    /// Returns a number that represents the sign of `self`.
+    ///
+    /// - `1.0` if the number is positive, `+0.0` or `Float::infinity()`
+    /// - `-1.0` if the number is negative, `-0.0` or `Float::neg_infinity()`
+    /// - `Float::nan()` if the number is `Float::nan()`
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let f = 3.5;
+    ///
+    /// assert_eq!(f.signum(), 1.0);
+    /// assert_eq!(f64::NEG_INFINITY.signum(), -1.0);
+    ///
+    /// assert!(f64::NAN.signum().is_nan());
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn signum(self) -> f64 { num::Float::signum(self) }
+
+    /// Returns `true` if `self` is positive, including `+0.0` and
+    /// `Float::infinity()`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let nan: f64 = f64::NAN;
+    ///
+    /// let f = 7.0;
+    /// let g = -7.0;
+    ///
+    /// assert!(f.is_positive());
+    /// assert!(!g.is_positive());
+    /// // Requires both tests to determine if is `NaN`
+    /// assert!(!nan.is_positive() && !nan.is_negative());
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn is_positive(self) -> bool { num::Float::is_positive(self) }
+
+    /// Returns `true` if `self` is negative, including `-0.0` and
+    /// `Float::neg_infinity()`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let nan = f64::NAN;
+    ///
+    /// let f = 7.0;
+    /// let g = -7.0;
+    ///
+    /// assert!(!f.is_negative());
+    /// assert!(g.is_negative());
+    /// // Requires both tests to determine if is `NaN`.
+    /// assert!(!nan.is_positive() && !nan.is_negative());
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn is_negative(self) -> bool { num::Float::is_negative(self) }
+
+    /// Fused multiply-add. Computes `(self * a) + b` with only one rounding
+    /// error. This produces a more accurate result with better performance than
+    /// a separate multiplication operation followed by an add.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let m = 10.0;
+    /// let x = 4.0;
+    /// let b = 60.0;
+    ///
+    /// // 100.0
+    /// let abs_difference = (m.mul_add(x, b) - (m*x + b)).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn mul_add(self, a: f64, b: f64) -> f64 { num::Float::mul_add(self, a, b) }
+
+    /// Take the reciprocal (inverse) of a number, `1/x`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 2.0;
+    /// let abs_difference = (x.recip() - (1.0/x)).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn recip(self) -> f64 { num::Float::recip(self) }
+
+    /// Raise a number to an integer power.
+    ///
+    /// Using this function is generally faster than using `powf`
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 2.0;
+    /// let abs_difference = (x.powi(2) - x*x).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn powi(self, n: i32) -> f64 { num::Float::powi(self, n) }
+
+    /// Raise a number to a floating point power.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 2.0;
+    /// let abs_difference = (x.powf(2.0) - x*x).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn powf(self, n: f64) -> f64 { num::Float::powf(self, n) }
+
+    /// Take the square root of a number.
+    ///
+    /// Returns NaN if `self` is a negative number.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let positive = 4.0;
+    /// let negative = -4.0;
+    ///
+    /// let abs_difference = (positive.sqrt() - 2.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// assert!(negative.sqrt().is_nan());
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn sqrt(self) -> f64 { num::Float::sqrt(self) }
+
+    /// Take the reciprocal (inverse) square root of a number, `1/sqrt(x)`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let f = 4.0;
+    ///
+    /// let abs_difference = (f.rsqrt() - 0.5).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn rsqrt(self) -> f64 { num::Float::rsqrt(self) }
+
+    /// Returns `e^(self)`, (the exponential function).
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let one = 1.0;
+    /// // e^1
+    /// let e = one.exp();
+    ///
+    /// // ln(e) - 1 == 0
+    /// let abs_difference = (e.ln() - 1.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn exp(self) -> f64 { num::Float::exp(self) }
+
+    /// Returns `2^(self)`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let f = 2.0;
+    ///
+    /// // 2^2 - 4 == 0
+    /// let abs_difference = (f.exp2() - 4.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn exp2(self) -> f64 { num::Float::exp2(self) }
+
+    /// Returns the natural logarithm of the number.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let one = 1.0;
+    /// // e^1
+    /// let e = one.exp();
+    ///
+    /// // ln(e) - 1 == 0
+    /// let abs_difference = (e.ln() - 1.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn ln(self) -> f64 { num::Float::ln(self) }
+
+    /// Returns the logarithm of the number with respect to an arbitrary base.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let ten = 10.0;
+    /// let two = 2.0;
+    ///
+    /// // log10(10) - 1 == 0
+    /// let abs_difference_10 = (ten.log(10.0) - 1.0).abs();
+    ///
+    /// // log2(2) - 1 == 0
+    /// let abs_difference_2 = (two.log(2.0) - 1.0).abs();
+    ///
+    /// assert!(abs_difference_10 < 1e-10);
+    /// assert!(abs_difference_2 < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn log(self, base: f64) -> f64 { num::Float::log(self, base) }
+
+    /// Returns the base 2 logarithm of the number.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let two = 2.0;
+    ///
+    /// // log2(2) - 1 == 0
+    /// let abs_difference = (two.log2() - 1.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn log2(self) -> f64 { num::Float::log2(self) }
+
+    /// Returns the base 10 logarithm of the number.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let ten = 10.0;
+    ///
+    /// // log10(10) - 1 == 0
+    /// let abs_difference = (ten.log10() - 1.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn log10(self) -> f64 { num::Float::log10(self) }
+
+    /// Convert radians to degrees.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64::consts;
+    ///
+    /// let angle = consts::PI;
+    ///
+    /// let abs_difference = (angle.to_degrees() - 180.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc", reason = "desirability is unclear")]
+    #[inline]
+    pub fn to_degrees(self) -> f64 { num::Float::to_degrees(self) }
+
+    /// Convert degrees to radians.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64::consts;
+    ///
+    /// let angle = 180.0;
+    ///
+    /// let abs_difference = (angle.to_radians() - consts::PI).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc", reason = "desirability is unclear")]
+    #[inline]
+    pub fn to_radians(self) -> f64 { num::Float::to_radians(self) }
+
+    /// Constructs a floating point number of `x*2^exp`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// // 3*2^2 - 12 == 0
+    /// let abs_difference = (Float::ldexp(3.0, 2) - 12.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "pending integer conventions")]
+    #[inline]
+    pub fn ldexp(x: f64, exp: int) -> f64 {
+        unsafe { cmath::ldexp(x, exp as c_int) }
+    }
+
+    /// Breaks the number into a normalized fraction and a base-2 exponent,
+    /// satisfying:
+    ///
+    ///  * `self = x * 2^exp`
+    ///  * `0.5 <= abs(x) < 1.0`
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 4.0;
+    ///
+    /// // (1/2)*2^3 -> 1 * 8/2 -> 4.0
+    /// let f = x.frexp();
+    /// let abs_difference_0 = (f.0 - 0.5).abs();
+    /// let abs_difference_1 = (f.1 as f64 - 3.0).abs();
+    ///
+    /// assert!(abs_difference_0 < 1e-10);
+    /// assert!(abs_difference_1 < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "pending integer conventions")]
+    #[inline]
+    pub fn frexp(self) -> (f64, int) {
+        unsafe {
+            let mut exp = 0;
+            let x = cmath::frexp(self, &mut exp);
+            (x, exp as int)
+        }
+    }
+
+    /// Returns the next representable floating-point value in the direction of
+    /// `other`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 1.0f32;
+    ///
+    /// let abs_diff = (x.next_after(2.0) - 1.00000011920928955078125_f32).abs();
+    ///
+    /// assert!(abs_diff < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn next_after(self, other: f64) -> f64 {
+        unsafe { cmath::nextafter(self, other) }
+    }
+
+    /// Returns the maximum of the two numbers.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 1.0;
+    /// let y = 2.0;
+    ///
+    /// assert_eq!(x.max(y), y);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn max(self, other: f64) -> f64 {
+        unsafe { cmath::fmax(self, other) }
+    }
+
+    /// Returns the minimum of the two numbers.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 1.0;
+    /// let y = 2.0;
+    ///
+    /// assert_eq!(x.min(y), x);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn min(self, other: f64) -> f64 {
+        unsafe { cmath::fmin(self, other) }
+    }
+
+    /// The positive difference of two numbers.
+    ///
+    /// * If `self <= other`: `0:0`
+    /// * Else: `self - other`
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 3.0;
+    /// let y = -3.0;
+    ///
+    /// let abs_difference_x = (x.abs_sub(1.0) - 2.0).abs();
+    /// let abs_difference_y = (y.abs_sub(1.0) - 0.0).abs();
+    ///
+    /// assert!(abs_difference_x < 1e-10);
+    /// assert!(abs_difference_y < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc", reason = "may be renamed")]
+    #[inline]
+    pub fn abs_sub(self, other: f64) -> f64 {
+        unsafe { cmath::fdim(self, other) }
+    }
+
+    /// Take the cubic root of a number.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 8.0;
+    ///
+    /// // x^(1/3) - 2 == 0
+    /// let abs_difference = (x.cbrt() - 2.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc", reason = "may be renamed")]
+    #[inline]
+    pub fn cbrt(self) -> f64 {
+        unsafe { cmath::cbrt(self) }
+    }
+
+    /// Calculate the length of the hypotenuse of a right-angle triangle given
+    /// legs of length `x` and `y`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 2.0;
+    /// let y = 3.0;
+    ///
+    /// // sqrt(x^2 + y^2)
+    /// let abs_difference = (x.hypot(y) - (x.powi(2) + y.powi(2)).sqrt()).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc",
+               reason = "unsure about its place in the world")]
+    #[inline]
+    pub fn hypot(self, other: f64) -> f64 {
+        unsafe { cmath::hypot(self, other) }
+    }
+
+    /// Computes the sine of a number (in radians).
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let x = f64::consts::PI/2.0;
+    ///
+    /// let abs_difference = (x.sin() - 1.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn sin(self) -> f64 {
+        unsafe { intrinsics::sinf64(self) }
+    }
+
+    /// Computes the cosine of a number (in radians).
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let x = 2.0*f64::consts::PI;
+    ///
+    /// let abs_difference = (x.cos() - 1.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn cos(self) -> f64 {
+        unsafe { intrinsics::cosf64(self) }
+    }
+
+    /// Computes the tangent of a number (in radians).
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let x = f64::consts::PI/4.0;
+    /// let abs_difference = (x.tan() - 1.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-14);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn tan(self) -> f64 {
+        unsafe { cmath::tan(self) }
+    }
+
+    /// Computes the arcsine of a number. Return value is in radians in
+    /// the range [-pi/2, pi/2] or NaN if the number is outside the range
+    /// [-1, 1].
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let f = f64::consts::PI / 2.0;
+    ///
+    /// // asin(sin(pi/2))
+    /// let abs_difference = (f.sin().asin() - f64::consts::PI / 2.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn asin(self) -> f64 {
+        unsafe { cmath::asin(self) }
+    }
+
+    /// Computes the arccosine of a number. Return value is in radians in
+    /// the range [0, pi] or NaN if the number is outside the range
+    /// [-1, 1].
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let f = f64::consts::PI / 4.0;
+    ///
+    /// // acos(cos(pi/4))
+    /// let abs_difference = (f.cos().acos() - f64::consts::PI / 4.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn acos(self) -> f64 {
+        unsafe { cmath::acos(self) }
+    }
+
+    /// Computes the arctangent of a number. Return value is in radians in the
+    /// range [-pi/2, pi/2];
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let f = 1.0;
+    ///
+    /// // atan(tan(1))
+    /// let abs_difference = (f.tan().atan() - 1.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn atan(self) -> f64 {
+        unsafe { cmath::atan(self) }
+    }
+
+    /// Computes the four quadrant arctangent of `self` (`y`) and `other` (`x`).
+    ///
+    /// * `x = 0`, `y = 0`: `0`
+    /// * `x >= 0`: `arctan(y/x)` -> `[-pi/2, pi/2]`
+    /// * `y >= 0`: `arctan(y/x) + pi` -> `(pi/2, pi]`
+    /// * `y < 0`: `arctan(y/x) - pi` -> `(-pi, -pi/2)`
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let pi = f64::consts::PI;
+    /// // All angles from horizontal right (+x)
+    /// // 45 deg counter-clockwise
+    /// let x1 = 3.0;
+    /// let y1 = -3.0;
+    ///
+    /// // 135 deg clockwise
+    /// let x2 = -3.0;
+    /// let y2 = 3.0;
+    ///
+    /// let abs_difference_1 = (y1.atan2(x1) - (-pi/4.0)).abs();
+    /// let abs_difference_2 = (y2.atan2(x2) - 3.0*pi/4.0).abs();
+    ///
+    /// assert!(abs_difference_1 < 1e-10);
+    /// assert!(abs_difference_2 < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn atan2(self, other: f64) -> f64 {
+        unsafe { cmath::atan2(self, other) }
+    }
+
+    /// Simultaneously computes the sine and cosine of the number, `x`. Returns
+    /// `(sin(x), cos(x))`.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let x = f64::consts::PI/4.0;
+    /// let f = x.sin_cos();
+    ///
+    /// let abs_difference_0 = (f.0 - x.sin()).abs();
+    /// let abs_difference_1 = (f.1 - x.cos()).abs();
+    ///
+    /// assert!(abs_difference_0 < 1e-10);
+    /// assert!(abs_difference_0 < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn sin_cos(self) -> (f64, f64) {
+        (self.sin(), self.cos())
+    }
+
+    /// Returns `e^(self) - 1` in a way that is accurate even if the
+    /// number is close to zero.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 7.0;
+    ///
+    /// // e^(ln(7)) - 1
+    /// let abs_difference = (x.ln().exp_m1() - 6.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc", reason = "may be renamed")]
+    #[inline]
+    pub fn exp_m1(self) -> f64 {
+        unsafe { cmath::expm1(self) }
+    }
+
+    /// Returns `ln(1+n)` (natural logarithm) more accurately than if
+    /// the operations were performed separately.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let x = f64::consts::E - 1.0;
+    ///
+    /// // ln(1 + (e - 1)) == ln(e) == 1
+    /// let abs_difference = (x.ln_1p() - 1.0).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[unstable(feature = "std_misc", reason = "may be renamed")]
+    #[inline]
+    pub fn ln_1p(self) -> f64 {
+        unsafe { cmath::log1p(self) }
+    }
+
+    /// Hyperbolic sine function.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let e = f64::consts::E;
+    /// let x = 1.0;
+    ///
+    /// let f = x.sinh();
+    /// // Solving sinh() at 1 gives `(e^2-1)/(2e)`
+    /// let g = (e*e - 1.0)/(2.0*e);
+    /// let abs_difference = (f - g).abs();
+    ///
+    /// assert!(abs_difference < 1e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn sinh(self) -> f64 {
+        unsafe { cmath::sinh(self) }
+    }
+
+    /// Hyperbolic cosine function.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let e = f64::consts::E;
+    /// let x = 1.0;
+    /// let f = x.cosh();
+    /// // Solving cosh() at 1 gives this result
+    /// let g = (e*e + 1.0)/(2.0*e);
+    /// let abs_difference = (f - g).abs();
+    ///
+    /// // Same result
+    /// assert!(abs_difference < 1.0e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn cosh(self) -> f64 {
+        unsafe { cmath::cosh(self) }
+    }
+
+    /// Hyperbolic tangent function.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let e = f64::consts::E;
+    /// let x = 1.0;
+    ///
+    /// let f = x.tanh();
+    /// // Solving tanh() at 1 gives `(1 - e^(-2))/(1 + e^(-2))`
+    /// let g = (1.0 - e.powi(-2))/(1.0 + e.powi(-2));
+    /// let abs_difference = (f - g).abs();
+    ///
+    /// assert!(abs_difference < 1.0e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn tanh(self) -> f64 {
+        unsafe { cmath::tanh(self) }
+    }
+
+    /// Inverse hyperbolic sine function.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 1.0;
+    /// let f = x.sinh().asinh();
+    ///
+    /// let abs_difference = (f - x).abs();
+    ///
+    /// assert!(abs_difference < 1.0e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn asinh(self) -> f64 {
+        match self {
+            NEG_INFINITY => NEG_INFINITY,
+            x => (x + ((x * x) + 1.0).sqrt()).ln(),
+        }
+    }
+
+    /// Inverse hyperbolic cosine function.
+    ///
+    /// ```
+    /// use std::num::Float;
+    ///
+    /// let x = 1.0;
+    /// let f = x.cosh().acosh();
+    ///
+    /// let abs_difference = (f - x).abs();
+    ///
+    /// assert!(abs_difference < 1.0e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn acosh(self) -> f64 {
+        match self {
+            x if x < 1.0 => Float::nan(),
+            x => (x + ((x * x) - 1.0).sqrt()).ln(),
+        }
+    }
+
+    /// Inverse hyperbolic tangent function.
+    ///
+    /// ```
+    /// use std::num::Float;
+    /// use std::f64;
+    ///
+    /// let e = f64::consts::E;
+    /// let f = e.tanh().atanh();
+    ///
+    /// let abs_difference = (f - e).abs();
+    ///
+    /// assert!(abs_difference < 1.0e-10);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    #[inline]
+    pub fn atanh(self) -> f64 {
+        0.5 * ((2.0 * self) / (1.0 - self)).ln_1p()
+    }
+}
+
 //
 // Section: String Conversions
 //
diff --git a/src/libstd/num/float_macros.rs b/src/libstd/num/float_macros.rs
index 2b730cd6f9a..ece7af9c152 100644
--- a/src/libstd/num/float_macros.rs
+++ b/src/libstd/num/float_macros.rs
@@ -11,6 +11,7 @@
 #![unstable(feature = "std_misc")]
 #![doc(hidden)]
 
+#[cfg(stage0)]
 macro_rules! assert_approx_eq {
     ($a:expr, $b:expr) => ({
         use num::Float;
@@ -19,3 +20,12 @@ macro_rules! assert_approx_eq {
                 "{} is not approximately equal to {}", *a, *b);
     })
 }
+
+#[cfg(not(stage0))]
+macro_rules! assert_approx_eq {
+    ($a:expr, $b:expr) => ({
+        let (a, b) = (&$a, &$b);
+        assert!((*a - *b).abs() < 1.0e-6,
+                "{} is not approximately equal to {}", *a, *b);
+    })
+}
diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs
index 35d973d2d4e..599f3f02a8b 100644
--- a/src/libstd/num/mod.rs
+++ b/src/libstd/num/mod.rs
@@ -23,7 +23,10 @@ use marker::Copy;
 use clone::Clone;
 use cmp::{PartialOrd, PartialEq};
 
+#[cfg(stage0)]
 pub use core::num::{Int, SignedInt, UnsignedInt};
+#[cfg(not(stage0))]
+pub use core::num::{Int, SignedInt};
 pub use core::num::{cast, FromPrimitive, NumCast, ToPrimitive};
 pub use core::num::{from_int, from_i8, from_i16, from_i32, from_i64};
 pub use core::num::{from_uint, from_u8, from_u16, from_u32, from_u64};
diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs
index 5fdd42dbc7a..ea1e05df85f 100644
--- a/src/libstd/num/strconv.rs
+++ b/src/libstd/num/strconv.rs
@@ -16,11 +16,16 @@ use self::ExponentFormat::*;
 use self::SignificantDigits::*;
 use self::SignFormat::*;
 
+#[cfg(stage0)]
 use char::{self, CharExt};
+#[cfg(not(stage0))]
+use char;
 use num::{self, Int, Float, ToPrimitive};
 use num::FpCategory as Fp;
 use ops::FnMut;
+#[cfg(stage0)]
 use slice::SliceExt;
+#[cfg(stage0)]
 use str::StrExt;
 use string::String;
 use vec::Vec;
diff --git a/src/libstd/old_io/buffered.rs b/src/libstd/old_io/buffered.rs
index 3ee73f5ff60..82a48a72499 100644
--- a/src/libstd/old_io/buffered.rs
+++ b/src/libstd/old_io/buffered.rs
@@ -20,6 +20,7 @@ use ops::Drop;
 use option::Option;
 use option::Option::{Some, None};
 use result::Result::Ok;
+#[cfg(stage0)]
 use slice::{SliceExt};
 use slice;
 use vec::Vec;
@@ -33,7 +34,7 @@ use vec::Vec;
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::old_io::{BufferedReader, File};
 ///
 /// let file = File::open(&Path::new("message.txt"));
@@ -136,7 +137,7 @@ impl<R: Reader> Reader for BufferedReader<R> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::old_io::{BufferedWriter, File};
 ///
 /// let file = File::create(&Path::new("message.txt")).unwrap();
@@ -322,7 +323,7 @@ impl<W: Reader> Reader for InternalBufferedWriter<W> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// # #![allow(unused_must_use)]
 /// use std::old_io::{BufferedStream, File};
 ///
diff --git a/src/libstd/old_io/comm_adapters.rs b/src/libstd/old_io/comm_adapters.rs
index 72ba653a986..33928d638e0 100644
--- a/src/libstd/old_io/comm_adapters.rs
+++ b/src/libstd/old_io/comm_adapters.rs
@@ -14,7 +14,10 @@ use sync::mpsc::{Sender, Receiver};
 use old_io;
 use option::Option::{None, Some};
 use result::Result::{Ok, Err};
+#[cfg(stage0)]
 use slice::{bytes, SliceExt};
+#[cfg(not(stage0))]
+use slice::bytes;
 use super::{Buffer, Reader, Writer, IoResult};
 use vec::Vec;
 
diff --git a/src/libstd/old_io/extensions.rs b/src/libstd/old_io/extensions.rs
index ec30121d78d..a81275952c5 100644
--- a/src/libstd/old_io/extensions.rs
+++ b/src/libstd/old_io/extensions.rs
@@ -26,8 +26,10 @@ use num::Int;
 use ops::FnOnce;
 use option::Option;
 use option::Option::{Some, None};
+#[cfg(stage0)]
 use ptr::PtrExt;
 use result::Result::{Ok, Err};
+#[cfg(stage0)]
 use slice::SliceExt;
 
 /// An iterator that reads a single byte on each iteration,
@@ -162,6 +164,7 @@ pub fn u64_to_be_bytes<T, F>(n: u64, size: uint, f: F) -> T where
 ///           32-bit value is parsed.
 pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
     use ptr::{copy_nonoverlapping_memory};
+    #[cfg(stage0)]
     use slice::SliceExt;
 
     assert!(size <= 8);
diff --git a/src/libstd/old_io/fs.rs b/src/libstd/old_io/fs.rs
index b0116bd4efd..ff3af380b7d 100644
--- a/src/libstd/old_io/fs.rs
+++ b/src/libstd/old_io/fs.rs
@@ -64,6 +64,7 @@ use option::Option::{Some, None};
 use old_path::{Path, GenericPath};
 use old_path;
 use result::Result::{Err, Ok};
+#[cfg(stage0)]
 use slice::SliceExt;
 use string::String;
 use vec::Vec;
@@ -175,7 +176,7 @@ impl File {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::old_io::File;
     ///
     /// let contents = File::open(&Path::new("foo.txt")).read_to_end();
@@ -194,7 +195,7 @@ impl File {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// # #![allow(unused_must_use)]
     /// use std::old_io::File;
     ///
@@ -285,7 +286,7 @@ impl File {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// # #![allow(unused_must_use)]
 /// use std::old_io::fs;
 ///
@@ -316,7 +317,7 @@ pub fn unlink(path: &Path) -> IoResult<()> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::old_io::fs;
 ///
 /// let p = Path::new("/some/file/path.txt");
@@ -358,7 +359,7 @@ pub fn lstat(path: &Path) -> IoResult<FileStat> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// # #![allow(unused_must_use)]
 /// use std::old_io::fs;
 ///
@@ -386,7 +387,7 @@ pub fn rename(from: &Path, to: &Path) -> IoResult<()> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// # #![allow(unused_must_use)]
 /// use std::old_io::fs;
 ///
@@ -436,7 +437,7 @@ pub fn copy(from: &Path, to: &Path) -> IoResult<()> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// # #![allow(unused_must_use)]
 /// use std::old_io;
 /// use std::old_io::fs;
@@ -507,7 +508,7 @@ pub fn readlink(path: &Path) -> IoResult<Path> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// # #![allow(unused_must_use)]
 /// use std::old_io;
 /// use std::old_io::fs;
@@ -531,7 +532,7 @@ pub fn mkdir(path: &Path, mode: FilePermission) -> IoResult<()> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// # #![allow(unused_must_use)]
 /// use std::old_io::fs;
 ///
@@ -555,7 +556,7 @@ pub fn rmdir(path: &Path) -> IoResult<()> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::old_io::fs::PathExtensions;
 /// use std::old_io::fs;
 /// use std::old_io;
diff --git a/src/libstd/old_io/mem.rs b/src/libstd/old_io/mem.rs
index 2445da9ea3b..72774334c13 100644
--- a/src/libstd/old_io/mem.rs
+++ b/src/libstd/old_io/mem.rs
@@ -17,7 +17,10 @@ use option::Option::None;
 use result::Result::{Err, Ok};
 use old_io;
 use old_io::{Reader, Writer, Seek, Buffer, IoError, SeekStyle, IoResult};
+#[cfg(stage0)]
 use slice::{self, SliceExt};
+#[cfg(not(stage0))]
+use slice;
 use vec::Vec;
 
 const BUF_CAPACITY: uint = 128;
@@ -53,7 +56,7 @@ impl Writer for Vec<u8> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// # #![allow(unused_must_use)]
 /// use std::old_io::MemWriter;
 ///
@@ -113,7 +116,7 @@ impl Writer for MemWriter {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// # #![allow(unused_must_use)]
 /// use std::old_io::MemReader;
 ///
@@ -243,7 +246,7 @@ impl<'a> Buffer for &'a [u8] {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// # #![allow(unused_must_use)]
 /// use std::old_io::BufWriter;
 ///
@@ -315,7 +318,7 @@ impl<'a> Seek for BufWriter<'a> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// # #![allow(unused_must_use)]
 /// use std::old_io::BufReader;
 ///
@@ -395,7 +398,7 @@ impl<'a> Buffer for BufReader<'a> {
 mod test {
     extern crate "test" as test_crate;
     use old_io::{SeekSet, SeekCur, SeekEnd, Reader, Writer, Seek};
-    use prelude::v1::{Ok, Err, range,  Vec, Buffer,  AsSlice, SliceExt};
+    use prelude::v1::{Ok, Err, range,  Vec, Buffer,  AsSlice};
     use prelude::v1::IteratorExt;
     use old_io;
     use iter::repeat;
diff --git a/src/libstd/old_io/mod.rs b/src/libstd/old_io/mod.rs
index 332b941bcc0..15a80e34451 100644
--- a/src/libstd/old_io/mod.rs
+++ b/src/libstd/old_io/mod.rs
@@ -251,6 +251,7 @@ pub use self::FileMode::*;
 pub use self::FileAccess::*;
 pub use self::IoErrorKind::*;
 
+#[cfg(stage0)]
 use char::CharExt;
 use default::Default;
 use error::Error;
@@ -267,7 +268,9 @@ use boxed::Box;
 use result::Result;
 use result::Result::{Ok, Err};
 use sys;
+#[cfg(stage0)]
 use slice::SliceExt;
+#[cfg(stage0)]
 use str::StrExt;
 use str;
 use string::String;
@@ -932,6 +935,7 @@ impl<'a> Reader for &'a mut (Reader+'a) {
 // API yet. If so, it should be a method on Vec.
 unsafe fn slice_vec_capacity<'a, T>(v: &'a mut Vec<T>, start: uint, end: uint) -> &'a mut [T] {
     use slice;
+    #[cfg(stage0)]
     use ptr::PtrExt;
 
     assert!(start <= end);
@@ -1406,7 +1410,7 @@ pub trait Buffer: Reader {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::old_io::BufReader;
     ///
     /// let mut reader = BufReader::new(b"hello\nworld");
@@ -1849,7 +1853,7 @@ impl fmt::Display for FilePermission {
 mod tests {
     use self::BadReaderBehavior::*;
     use super::{IoResult, Reader, MemReader, NoProgress, InvalidInput, Writer};
-    use prelude::v1::{Ok, Vec, Buffer, SliceExt};
+    use prelude::v1::{Ok, Vec, Buffer};
     use usize;
 
     #[derive(Clone, PartialEq, Debug)]
diff --git a/src/libstd/old_io/net/ip.rs b/src/libstd/old_io/net/ip.rs
index 6e2f491262d..2dda2c1277a 100644
--- a/src/libstd/old_io/net/ip.rs
+++ b/src/libstd/old_io/net/ip.rs
@@ -26,8 +26,12 @@ use ops::{FnOnce, FnMut};
 use option::Option;
 use option::Option::{None, Some};
 use result::Result::{self, Ok, Err};
+#[cfg(stage0)]
 use slice::SliceExt;
+#[cfg(stage0)]
 use str::{FromStr, StrExt};
+#[cfg(not(stage0))]
+use str::FromStr;
 use vec::Vec;
 
 pub type Port = u16;
diff --git a/src/libstd/old_io/net/pipe.rs b/src/libstd/old_io/net/pipe.rs
index 59352532902..ad0e7a7284d 100644
--- a/src/libstd/old_io/net/pipe.rs
+++ b/src/libstd/old_io/net/pipe.rs
@@ -52,7 +52,7 @@ impl UnixStream {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// # #![allow(unused_must_use)]
     /// use std::old_io::net::pipe::UnixStream;
     ///
diff --git a/src/libstd/old_io/process.rs b/src/libstd/old_io/process.rs
index cabba8e358a..e5f23643372 100644
--- a/src/libstd/old_io/process.rs
+++ b/src/libstd/old_io/process.rs
@@ -761,7 +761,7 @@ mod tests {
     use old_io::{Truncate, Write, TimedOut, timer, process, FileNotFound};
     use prelude::v1::{Ok, Err, range, drop, Some, None, Vec};
     use prelude::v1::{Path, String, Reader, Writer, Clone};
-    use prelude::v1::{SliceExt, Str, StrExt, AsSlice, ToString, GenericPath};
+    use prelude::v1::{Str, AsSlice, ToString, GenericPath};
     use old_io::fs::PathExtensions;
     use old_io::timer::*;
     use rt::running_on_valgrind;
diff --git a/src/libstd/old_io/stdio.rs b/src/libstd/old_io/stdio.rs
index dcc34505730..b699b93f2b8 100644
--- a/src/libstd/old_io/stdio.rs
+++ b/src/libstd/old_io/stdio.rs
@@ -43,7 +43,9 @@ use ops::{Deref, DerefMut, FnOnce};
 use ptr;
 use result::Result::{Ok, Err};
 use rt;
+#[cfg(stage0)]
 use slice::SliceExt;
+#[cfg(stage0)]
 use str::StrExt;
 use string::String;
 use sys::{fs, tty};
@@ -140,7 +142,7 @@ impl StdinReader {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::old_io;
     ///
     /// let mut stdin = old_io::stdin();
diff --git a/src/libstd/old_io/tempfile.rs b/src/libstd/old_io/tempfile.rs
index 76753dca52e..b34804fce61 100644
--- a/src/libstd/old_io/tempfile.rs
+++ b/src/libstd/old_io/tempfile.rs
@@ -21,6 +21,7 @@ use option::Option;
 use old_path::{Path, GenericPath};
 use rand::{Rng, thread_rng};
 use result::Result::{Ok, Err};
+#[cfg(stage0)]
 use str::StrExt;
 use string::String;
 
diff --git a/src/libstd/old_io/timer.rs b/src/libstd/old_io/timer.rs
index de7883c715a..65c62a99335 100644
--- a/src/libstd/old_io/timer.rs
+++ b/src/libstd/old_io/timer.rs
@@ -115,7 +115,7 @@ impl Timer {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::old_io::Timer;
     /// use std::time::Duration;
     ///
@@ -128,7 +128,7 @@ impl Timer {
     /// ten_milliseconds.recv().unwrap();
     /// ```
     ///
-    /// ```rust
+    /// ```
     /// use std::old_io::Timer;
     /// use std::time::Duration;
     ///
@@ -167,7 +167,7 @@ impl Timer {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::old_io::Timer;
     /// use std::time::Duration;
     ///
@@ -186,7 +186,7 @@ impl Timer {
     /// ten_milliseconds.recv().unwrap();
     /// ```
     ///
-    /// ```rust
+    /// ```
     /// use std::old_io::Timer;
     /// use std::time::Duration;
     ///
diff --git a/src/libstd/old_path/mod.rs b/src/libstd/old_path/mod.rs
index 01eec230d21..37875658ae0 100644
--- a/src/libstd/old_path/mod.rs
+++ b/src/libstd/old_path/mod.rs
@@ -72,8 +72,10 @@ use iter::IteratorExt;
 use option::Option;
 use option::Option::{None, Some};
 use str;
+#[cfg(stage0)]
 use str::StrExt;
 use string::{String, CowString};
+#[cfg(stage0)]
 use slice::SliceExt;
 use vec::Vec;
 
diff --git a/src/libstd/old_path/posix.rs b/src/libstd/old_path/posix.rs
index 8d5765e1ffe..e35623d7b1a 100644
--- a/src/libstd/old_path/posix.rs
+++ b/src/libstd/old_path/posix.rs
@@ -20,8 +20,14 @@ use iter::{Iterator, IteratorExt, Map};
 use marker::Sized;
 use option::Option::{self, Some, None};
 use result::Result::{self, Ok, Err};
+#[cfg(stage0)]
 use slice::{AsSlice, Split, SliceExt, SliceConcatExt};
+#[cfg(not(stage0))]
+use slice::{AsSlice, Split, SliceConcatExt};
+#[cfg(stage0)]
 use str::{self, FromStr, StrExt};
+#[cfg(not(stage0))]
+use str::{self, FromStr};
 use vec::Vec;
 
 use super::{BytesContainer, GenericPath, GenericPathUnsafe};
@@ -447,8 +453,8 @@ mod tests {
     use iter::IteratorExt;
     use option::Option::{self, Some, None};
     use old_path::GenericPath;
-    use slice::{AsSlice, SliceExt};
-    use str::{self, Str, StrExt};
+    use slice::AsSlice;
+    use str::{self, Str};
     use string::ToString;
     use vec::Vec;
 
diff --git a/src/libstd/old_path/windows.rs b/src/libstd/old_path/windows.rs
index 838710b1aec..ff4f083333b 100644
--- a/src/libstd/old_path/windows.rs
+++ b/src/libstd/old_path/windows.rs
@@ -15,6 +15,7 @@
 use self::PathPrefix::*;
 
 use ascii::AsciiExt;
+#[cfg(stage0)]
 use char::CharExt;
 use clone::Clone;
 use cmp::{Ordering, Eq, Ord, PartialEq, PartialOrd};
@@ -26,8 +27,14 @@ use iter::{Iterator, IteratorExt, Map, repeat};
 use mem;
 use option::Option::{self, Some, None};
 use result::Result::{self, Ok, Err};
+#[cfg(stage0)]
 use slice::{SliceExt, SliceConcatExt};
+#[cfg(not(stage0))]
+use slice::SliceConcatExt;
+#[cfg(stage0)]
 use str::{SplitTerminator, FromStr, StrExt};
+#[cfg(not(stage0))]
+use str::{SplitTerminator, FromStr};
 use string::{String, ToString};
 use vec::Vec;
 
@@ -1126,7 +1133,7 @@ mod tests {
     use iter::IteratorExt;
     use option::Option::{self, Some, None};
     use old_path::GenericPath;
-    use slice::{AsSlice, SliceExt};
+    use slice::AsSlice;
     use str::Str;
     use string::ToString;
     use vec::Vec;
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index 2dea77a3ccd..46233a46ee5 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -52,12 +52,19 @@ use option::Option::{Some, None};
 use option::Option;
 use old_path::{Path, GenericPath, BytesContainer};
 use path::{self, PathBuf};
+#[cfg(stage0)]
 use ptr::PtrExt;
 use ptr;
 use result::Result::{Err, Ok};
 use result::Result;
+#[cfg(stage0)]
 use slice::{AsSlice, SliceExt};
+#[cfg(not(stage0))]
+use slice::AsSlice;
+#[cfg(stage0)]
 use str::{Str, StrExt};
+#[cfg(not(stage0))]
+use str::Str;
 use str;
 use string::{String, ToString};
 use sync::atomic::{AtomicIsize, ATOMIC_ISIZE_INIT, Ordering};
@@ -125,7 +132,7 @@ pub const TMPBUF_SZ : uint = 1000;
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::os;
 ///
 /// // We assume that we are in a valid directory.
@@ -145,7 +152,7 @@ pub fn getcwd() -> IoResult<Path> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::os;
 ///
 /// // We will iterate through the references to the element returned by os::env();
@@ -181,7 +188,7 @@ pub fn env_as_bytes() -> Vec<(Vec<u8>, Vec<u8>)> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::os;
 ///
 /// let key = "HOME";
@@ -223,7 +230,7 @@ fn byteify(s: OsString) -> Vec<u8> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::os;
 ///
 /// let key = "KEY";
@@ -263,7 +270,8 @@ pub fn unsetenv(n: &str) {
 /// environment variable.
 ///
 /// # Examples
-/// ```rust
+///
+/// ```
 /// use std::os;
 ///
 /// let key = "PATH";
@@ -295,7 +303,7 @@ pub fn split_paths<T: BytesContainer>(unparsed: T) -> Vec<Path> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::os;
 /// use std::old_path::Path;
 ///
@@ -356,7 +364,7 @@ pub fn dll_filename(base: &str) -> String {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::os;
 ///
 /// match os::self_exe_name() {
@@ -376,7 +384,7 @@ pub fn self_exe_name() -> Option<Path> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::os;
 ///
 /// match os::self_exe_path() {
@@ -405,7 +413,7 @@ pub fn self_exe_path() -> Option<Path> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::os;
 ///
 /// match os::homedir() {
@@ -494,7 +502,8 @@ pub fn tmpdir() -> Path {
 /// as is.
 ///
 /// # Examples
-/// ```rust
+///
+/// ```
 /// use std::os;
 /// use std::old_path::Path;
 ///
@@ -525,7 +534,8 @@ pub fn make_absolute(p: &Path) -> IoResult<Path> {
 /// whether the change was completed successfully or not.
 ///
 /// # Examples
-/// ```rust
+///
+/// ```
 /// use std::os;
 /// use std::old_path::Path;
 ///
@@ -546,7 +556,8 @@ pub fn errno() -> i32 {
 /// Return the string corresponding to an `errno()` value of `errnum`.
 ///
 /// # Examples
-/// ```rust
+///
+/// ```
 /// use std::os;
 ///
 /// // Same as println!("{}", last_os_error());
@@ -742,7 +753,7 @@ extern "system" {
 /// See `String::from_utf8_lossy` for details.
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::os;
 ///
 /// // Prints each argument on a separate line
diff --git a/src/libstd/path.rs b/src/libstd/path.rs
index 2159e300744..2d97d651366 100644
--- a/src/libstd/path.rs
+++ b/src/libstd/path.rs
@@ -159,6 +159,7 @@ mod platform {
     use core::prelude::*;
     use ascii::*;
 
+    #[cfg(stage0)]
     use char::CharExt as UnicodeCharExt;
     use super::{os_str_as_u8_slice, u8_slice_as_os_str, Prefix};
     use ffi::OsStr;
@@ -855,7 +856,7 @@ impl<'a> cmp::Ord for Components<'a> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::path::PathBuf;
 ///
 /// let mut path = PathBuf::new("c:\\");
@@ -947,7 +948,7 @@ impl PathBuf {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::path::PathBuf;
     ///
     /// let mut buf = PathBuf::new("/");
@@ -1104,7 +1105,7 @@ impl AsOsStr for PathBuf {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::path::Path;
 ///
 /// let path = Path::new("/tmp/foo/bar.txt");
@@ -1209,7 +1210,7 @@ impl Path {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```
     /// use std::path::Path;
     ///
     /// let path = Path::new("/foo/bar");
diff --git a/src/libstd/prelude/v1.rs b/src/libstd/prelude/v1.rs
index 31aac333859..4327b26260a 100644
--- a/src/libstd/prelude/v1.rs
+++ b/src/libstd/prelude/v1.rs
@@ -25,6 +25,7 @@
 // Reexported types and traits
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)] pub use boxed::Box;
+#[cfg(stage0)]
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)] pub use char::CharExt;
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -39,14 +40,23 @@
 #[doc(no_inline)] pub use iter::{Iterator, IteratorExt, Extend};
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)] pub use option::Option::{self, Some, None};
+#[cfg(stage0)]
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)] pub use ptr::{PtrExt, MutPtrExt};
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)] pub use result::Result::{self, Ok, Err};
+#[cfg(stage0)]
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)] pub use slice::{SliceExt, SliceConcatExt, AsSlice};
+#[cfg(not(stage0))]
+#[stable(feature = "rust1", since = "1.0.0")]
+#[doc(no_inline)] pub use slice::{SliceConcatExt, AsSlice};
+#[cfg(stage0)]
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)] pub use str::{Str, StrExt};
+#[cfg(not(stage0))]
+#[stable(feature = "rust1", since = "1.0.0")]
+#[doc(no_inline)] pub use str::Str;
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)] pub use string::{String, ToString};
 #[stable(feature = "rust1", since = "1.0.0")]
diff --git a/src/libstd/process.rs b/src/libstd/process.rs
index 08aa92d5f20..df8a5d27c7f 100644
--- a/src/libstd/process.rs
+++ b/src/libstd/process.rs
@@ -533,7 +533,7 @@ mod tests {
     use io::prelude::*;
     use prelude::v1::{Ok, Err, drop, Some, Vec};
     use prelude::v1::{String, Clone};
-    use prelude::v1::{SliceExt, Str, StrExt, AsSlice, ToString, GenericPath};
+    use prelude::v1::{Str, AsSlice, ToString, GenericPath};
     use old_path;
     use old_io::fs::PathExtensions;
     use rt::running_on_valgrind;
diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs
index e8407ab1115..69053252ed1 100644
--- a/src/libstd/rand/mod.rs
+++ b/src/libstd/rand/mod.rs
@@ -426,7 +426,7 @@ pub fn random<T: Rand>() -> T {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::rand::{thread_rng, sample};
 ///
 /// let mut rng = thread_rng();
diff --git a/src/libstd/rand/os.rs b/src/libstd/rand/os.rs
index 6cb3eb4d16e..46e35e0fa8b 100644
--- a/src/libstd/rand/os.rs
+++ b/src/libstd/rand/os.rs
@@ -24,6 +24,7 @@ mod imp {
     use rand::Rng;
     use rand::reader::ReaderRng;
     use result::Result::Ok;
+    #[cfg(stage0)]
     use slice::SliceExt;
     use mem;
     use os::errno;
@@ -193,6 +194,7 @@ mod imp {
     use rand::Rng;
     use result::Result::{Ok};
     use self::libc::{c_int, size_t};
+    #[cfg(stage0)]
     use slice::SliceExt;
 
     /// A random number generator that retrieves randomness straight from
@@ -263,6 +265,7 @@ mod imp {
     use result::Result::{Ok, Err};
     use self::libc::{DWORD, BYTE, LPCSTR, BOOL};
     use self::libc::types::os::arch::extra::{LONG_PTR};
+    #[cfg(stage0)]
     use slice::SliceExt;
 
     type HCRYPTPROV = LONG_PTR;
diff --git a/src/libstd/rand/reader.rs b/src/libstd/rand/reader.rs
index 08c43198aa1..42c153af036 100644
--- a/src/libstd/rand/reader.rs
+++ b/src/libstd/rand/reader.rs
@@ -13,6 +13,7 @@
 use old_io::Reader;
 use rand::Rng;
 use result::Result::{Ok, Err};
+#[cfg(stage0)]
 use slice::SliceExt;
 
 /// An RNG that reads random bytes straight from a `Reader`. This will
@@ -24,7 +25,7 @@ use slice::SliceExt;
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::rand::{reader, Rng};
 /// use std::old_io::MemReader;
 ///
diff --git a/src/libstd/rt/at_exit_imp.rs b/src/libstd/rt/at_exit_imp.rs
index 08755ba829f..f6bb87f011d 100644
--- a/src/libstd/rt/at_exit_imp.rs
+++ b/src/libstd/rt/at_exit_imp.rs
@@ -12,6 +12,7 @@
 //!
 //! Documentation can be found on the `rt::at_exit` function.
 
+#[cfg(stage0)]
 use core::prelude::*;
 
 use boxed;
diff --git a/src/libstd/sync/barrier.rs b/src/libstd/sync/barrier.rs
index f697d10d5df..ebf4d337749 100644
--- a/src/libstd/sync/barrier.rs
+++ b/src/libstd/sync/barrier.rs
@@ -13,7 +13,7 @@ use sync::{Mutex, Condvar};
 /// A barrier enables multiple tasks to synchronize the beginning
 /// of some computation.
 ///
-/// ```rust
+/// ```
 /// use std::sync::{Arc, Barrier};
 /// use std::thread;
 ///
diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs
index 41378a6b312..1cbfbbf2927 100644
--- a/src/libstd/sync/mutex.rs
+++ b/src/libstd/sync/mutex.rs
@@ -46,7 +46,7 @@ use fmt;
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::sync::{Arc, Mutex};
 /// use std::thread;
 /// use std::sync::mpsc::channel;
@@ -84,7 +84,7 @@ use fmt;
 ///
 /// To recover from a poisoned mutex:
 ///
-/// ```rust
+/// ```
 /// use std::sync::{Arc, Mutex};
 /// use std::thread;
 ///
@@ -135,7 +135,7 @@ unsafe impl<T: Send> Sync for Mutex<T> { }
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::sync::{StaticMutex, MUTEX_INIT};
 ///
 /// static LOCK: StaticMutex = MUTEX_INIT;
diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs
index 5cad2916624..258cf1d38a8 100644
--- a/src/libstd/sync/once.rs
+++ b/src/libstd/sync/once.rs
@@ -26,7 +26,7 @@ use sync::{StaticMutex, MUTEX_INIT};
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::sync::{Once, ONCE_INIT};
 ///
 /// static START: Once = ONCE_INIT;
diff --git a/src/libstd/sync/task_pool.rs b/src/libstd/sync/task_pool.rs
index 3d31790550b..8a1946b86ab 100644
--- a/src/libstd/sync/task_pool.rs
+++ b/src/libstd/sync/task_pool.rs
@@ -60,7 +60,7 @@ impl<'a> Drop for Sentinel<'a> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use std::sync::TaskPool;
 /// use std::iter::AdditiveIterator;
 /// use std::sync::mpsc::channel;
diff --git a/src/libstd/sys/common/net2.rs b/src/libstd/sys/common/net2.rs
index af5b49a4239..25aeab1b4ff 100644
--- a/src/libstd/sys/common/net2.rs
+++ b/src/libstd/sys/common/net2.rs
@@ -14,7 +14,7 @@ use ffi::CString;
 use io::{self, Error, ErrorKind};
 use libc::{self, c_int, c_char, c_void, socklen_t};
 use mem;
-use net::{IpAddr, SocketAddr, Shutdown};
+use net::{SocketAddr, Shutdown};
 use sys::c;
 use sys::net::{cvt, cvt_r, cvt_gai, Socket, init, wrlen_t};
 use sys_common::{AsInner, FromInner, IntoInner};
@@ -63,15 +63,15 @@ fn sockaddr_to_addr(storage: &libc::sockaddr_storage,
     match storage.ss_family as libc::c_int {
         libc::AF_INET => {
             assert!(len as usize >= mem::size_of::<libc::sockaddr_in>());
-            Ok(FromInner::from_inner(unsafe {
+            Ok(SocketAddr::V4(FromInner::from_inner(unsafe {
                 *(storage as *const _ as *const libc::sockaddr_in)
-            }))
+            })))
         }
         libc::AF_INET6 => {
             assert!(len as usize >= mem::size_of::<libc::sockaddr_in6>());
-            Ok(FromInner::from_inner(unsafe {
+            Ok(SocketAddr::V6(FromInner::from_inner(unsafe {
                 *(storage as *const _ as *const libc::sockaddr_in6)
-            }))
+            })))
         }
         _ => {
             Err(Error::new(ErrorKind::InvalidInput, "invalid argument", None))
@@ -334,39 +334,39 @@ impl UdpSocket {
                    libc::IP_MULTICAST_LOOP, on as c_int)
     }
 
-    pub fn join_multicast(&self, multi: &IpAddr) -> io::Result<()> {
+    pub fn join_multicast(&self, multi: &SocketAddr) -> io::Result<()> {
         match *multi {
-            IpAddr::V4(..) => {
+            SocketAddr::V4(..) => {
                 self.set_membership(multi, libc::IP_ADD_MEMBERSHIP)
             }
-            IpAddr::V6(..) => {
+            SocketAddr::V6(..) => {
                 self.set_membership(multi, libc::IPV6_ADD_MEMBERSHIP)
             }
         }
     }
-    pub fn leave_multicast(&self, multi: &IpAddr) -> io::Result<()> {
+    pub fn leave_multicast(&self, multi: &SocketAddr) -> io::Result<()> {
         match *multi {
-            IpAddr::V4(..) => {
+            SocketAddr::V4(..) => {
                 self.set_membership(multi, libc::IP_DROP_MEMBERSHIP)
             }
-            IpAddr::V6(..) => {
+            SocketAddr::V6(..) => {
                 self.set_membership(multi, libc::IPV6_DROP_MEMBERSHIP)
             }
         }
     }
-    fn set_membership(&self, addr: &IpAddr, opt: c_int) -> io::Result<()> {
+    fn set_membership(&self, addr: &SocketAddr, opt: c_int) -> io::Result<()> {
         match *addr {
-            IpAddr::V4(ref addr) => {
+            SocketAddr::V4(ref addr) => {
                 let mreq = libc::ip_mreq {
-                    imr_multiaddr: *addr.as_inner(),
+                    imr_multiaddr: *addr.ip().as_inner(),
                     // interface == INADDR_ANY
                     imr_interface: libc::in_addr { s_addr: 0x0 },
                 };
                 setsockopt(&self.inner, libc::IPPROTO_IP, opt, mreq)
             }
-            IpAddr::V6(ref addr) => {
+            SocketAddr::V6(ref addr) => {
                 let mreq = libc::ip6_mreq {
-                    ipv6mr_multiaddr: *addr.as_inner(),
+                    ipv6mr_multiaddr: *addr.ip().as_inner(),
                     ipv6mr_interface: 0,
                 };
                 setsockopt(&self.inner, libc::IPPROTO_IPV6, opt, mreq)
diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs
index 4c0b26f8649..dfc88571a82 100644
--- a/src/libstd/sys/common/wtf8.rs
+++ b/src/libstd/sys/common/wtf8.rs
@@ -172,6 +172,7 @@ impl Wtf8Buf {
         Wtf8Buf { bytes: string.into_bytes() }
     }
 
+    #[cfg(stage0)]
     /// Create a WTF-8 string from an UTF-8 `&str` slice.
     ///
     /// This copies the content of the slice.
@@ -182,6 +183,17 @@ impl Wtf8Buf {
         Wtf8Buf { bytes: slice::SliceExt::to_vec(str.as_bytes()) }
     }
 
+    #[cfg(not(stage0))]
+    /// Create a WTF-8 string from an UTF-8 `&str` slice.
+    ///
+    /// This copies the content of the slice.
+    ///
+    /// Since WTF-8 is a superset of UTF-8, this always succeeds.
+    #[inline]
+    pub fn from_str(str: &str) -> Wtf8Buf {
+        Wtf8Buf { bytes: <[_]>::to_vec(str.as_bytes()) }
+    }
+
     /// Create a WTF-8 string from a potentially ill-formed UTF-16 slice of 16-bit code units.
     ///
     /// This is lossless: calling `.encode_wide()` on the resulting string
diff --git a/src/libstd/sys/unix/net.rs b/src/libstd/sys/unix/net.rs
index 83b6a14b78d..b22fa33e562 100644
--- a/src/libstd/sys/unix/net.rs
+++ b/src/libstd/sys/unix/net.rs
@@ -15,7 +15,7 @@ use io;
 use libc::{self, c_int, size_t};
 use str;
 use sys::c;
-use net::{SocketAddr, IpAddr};
+use net::SocketAddr;
 use sys::fd::FileDesc;
 use sys_common::AsInner;
 
@@ -40,9 +40,9 @@ pub fn cvt_gai(err: c_int) -> io::Result<()> {
 
 impl Socket {
     pub fn new(addr: &SocketAddr, ty: c_int) -> io::Result<Socket> {
-        let fam = match addr.ip() {
-            IpAddr::V4(..) => libc::AF_INET,
-            IpAddr::V6(..) => libc::AF_INET6,
+        let fam = match *addr {
+            SocketAddr::V4(..) => libc::AF_INET,
+            SocketAddr::V6(..) => libc::AF_INET6,
         };
         unsafe {
             let fd = try!(cvt(libc::socket(fam, ty, 0)));
diff --git a/src/libstd/sys/unix/os_str.rs b/src/libstd/sys/unix/os_str.rs
index 89ab3e1981b..99591480752 100644
--- a/src/libstd/sys/unix/os_str.rs
+++ b/src/libstd/sys/unix/os_str.rs
@@ -16,6 +16,7 @@ use core::prelude::*;
 use borrow::Cow;
 use fmt::{self, Debug};
 use vec::Vec;
+#[cfg(stage0)]
 use slice::SliceExt as StdSliceExt;
 use str;
 use string::String;
diff --git a/src/libstd/sys/windows/net.rs b/src/libstd/sys/windows/net.rs
index 6caa4df5dfe..e092faf4935 100644
--- a/src/libstd/sys/windows/net.rs
+++ b/src/libstd/sys/windows/net.rs
@@ -14,7 +14,7 @@ use io;
 use libc::consts::os::extra::INVALID_SOCKET;
 use libc::{self, c_int, c_void};
 use mem;
-use net::{SocketAddr, IpAddr};
+use net::SocketAddr;
 use num::{SignedInt, Int};
 use rt;
 use sync::{Once, ONCE_INIT};
@@ -73,9 +73,9 @@ pub fn cvt_r<T: SignedInt, F>(mut f: F) -> io::Result<T> where F: FnMut() -> T {
 
 impl Socket {
     pub fn new(addr: &SocketAddr, ty: c_int) -> io::Result<Socket> {
-        let fam = match addr.ip() {
-            IpAddr::V4(..) => libc::AF_INET,
-            IpAddr::V6(..) => libc::AF_INET6,
+        let fam = match *addr {
+            SocketAddr::V4(..) => libc::AF_INET,
+            SocketAddr::V6(..) => libc::AF_INET6,
         };
         match unsafe { libc::socket(fam, ty, 0) } {
             INVALID_SOCKET => Err(last_error()),
diff --git a/src/libstd/sys/windows/process2.rs b/src/libstd/sys/windows/process2.rs
index 4fbaabc9ecc..e3cf5da59f0 100644
--- a/src/libstd/sys/windows/process2.rs
+++ b/src/libstd/sys/windows/process2.rs
@@ -128,6 +128,7 @@ impl Process {
         use env::split_paths;
         use mem;
         use iter::IteratorExt;
+        #[cfg(stage0)]
         use str::StrExt;
 
         // To have the spawning semantics of unix/windows stay the same, we need to
diff --git a/src/libstd/thread.rs b/src/libstd/thread.rs
index adc3b77407a..a40b26c85be 100644
--- a/src/libstd/thread.rs
+++ b/src/libstd/thread.rs
@@ -402,18 +402,18 @@ pub fn park() {
 /// the specified duration has been reached (may wake spuriously).
 ///
 /// The semantics of this function are equivalent to `park()` except that the
-/// thread will be blocked for roughly no longer than dur. This method
+/// thread will be blocked for roughly no longer than *duration*. This method
 /// should not be used for precise timing due to anomalies such as
 /// preemption or platform differences that may not cause the maximum
-/// amount of time waited to be precisely dur
+/// amount of time waited to be precisely *duration* long.
 ///
 /// See the module doc for more detail.
 #[unstable(feature = "std_misc", reason = "recently introduced, depends on Duration")]
-pub fn park_timeout(dur: Duration) {
+pub fn park_timeout(duration: Duration) {
     let thread = current();
     let mut guard = thread.inner.lock.lock().unwrap();
     if !*guard {
-        let (g, _) = thread.inner.cvar.wait_timeout(guard, dur).unwrap();
+        let (g, _) = thread.inner.cvar.wait_timeout(guard, duration).unwrap();
         guard = g;
     }
     *guard = false;
@@ -502,11 +502,11 @@ impl Thread {
     /// Deprecated: use module-level free function.
     #[deprecated(since = "1.0.0", reason = "use module-level free function")]
     #[unstable(feature = "std_misc", reason = "recently introduced")]
-    pub fn park_timeout(dur: Duration) {
+    pub fn park_timeout(duration: Duration) {
         let thread = current();
         let mut guard = thread.inner.lock.lock().unwrap();
         if !*guard {
-            let (g, _) = thread.inner.cvar.wait_timeout(guard, dur).unwrap();
+            let (g, _) = thread.inner.cvar.wait_timeout(guard, duration).unwrap();
             guard = g;
         }
         *guard = false;
diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs
index 48c045ee4f9..c38556b0782 100644
--- a/src/libsyntax/ext/quote.rs
+++ b/src/libsyntax/ext/quote.rs
@@ -361,8 +361,7 @@ pub mod rt {
             parse::parse_stmt_from_source_str("<quote expansion>".to_string(),
                                               s,
                                               self.cfg(),
-                                              Vec::new(),
-                                              self.parse_sess())
+                                              self.parse_sess()).expect("parse error")
         }
 
         fn parse_expr(&self, s: String) -> P<ast::Expr> {
@@ -407,7 +406,7 @@ pub fn expand_quote_expr<'cx>(cx: &'cx mut ExtCtxt,
                               sp: Span,
                               tts: &[ast::TokenTree])
                               -> Box<base::MacResult+'cx> {
-    let expanded = expand_parse_call(cx, sp, "parse_expr", Vec::new(), tts);
+    let expanded = expand_parse_call(cx, sp, "parse_expr", vec!(), tts);
     base::MacEager::expr(expanded)
 }
 
@@ -415,8 +414,7 @@ pub fn expand_quote_item<'cx>(cx: &mut ExtCtxt,
                               sp: Span,
                               tts: &[ast::TokenTree])
                               -> Box<base::MacResult+'cx> {
-    let expanded = expand_parse_call(cx, sp, "parse_item_with_outer_attributes",
-                                    vec!(), tts);
+    let expanded = expand_parse_call(cx, sp, "parse_item", vec!(), tts);
     base::MacEager::expr(expanded)
 }
 
@@ -448,9 +446,7 @@ pub fn expand_quote_stmt(cx: &mut ExtCtxt,
                          sp: Span,
                          tts: &[ast::TokenTree])
                          -> Box<base::MacResult+'static> {
-    let e_attrs = cx.expr_vec_ng(sp);
-    let expanded = expand_parse_call(cx, sp, "parse_stmt",
-                                    vec!(e_attrs), tts);
+    let expanded = expand_parse_call(cx, sp, "parse_stmt", vec!(), tts);
     base::MacEager::expr(expanded)
 }
 
diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs
index eb0daac3ab8..c61aec0069d 100644
--- a/src/libsyntax/ext/source_util.rs
+++ b/src/libsyntax/ext/source_util.rs
@@ -115,7 +115,7 @@ pub fn expand_include<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree
                       -> Option<SmallVector<P<ast::Item>>> {
             let mut ret = SmallVector::zero();
             while self.p.token != token::Eof {
-                match self.p.parse_item_with_outer_attributes() {
+                match self.p.parse_item() {
                     Some(item) => ret.push(item),
                     None => self.p.span_fatal(
                         self.p.span,
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs
index eb15d708232..b7d40a46f3e 100644
--- a/src/libsyntax/ext/tt/macro_parser.rs
+++ b/src/libsyntax/ext/tt/macro_parser.rs
@@ -521,12 +521,15 @@ pub fn parse_nt(p: &mut Parser, sp: Span, name: &str) -> Nonterminal {
     // check at the beginning and the parser checks after each bump
     p.check_unknown_macro_variable();
     match name {
-      "item" => match p.parse_item(Vec::new()) {
+      "item" => match p.parse_item() {
         Some(i) => token::NtItem(i),
         None => p.fatal("expected an item keyword")
       },
       "block" => token::NtBlock(p.parse_block()),
-      "stmt" => token::NtStmt(p.parse_stmt(Vec::new())),
+      "stmt" => match p.parse_stmt() {
+        Some(s) => token::NtStmt(s),
+        None => p.fatal("expected a statement")
+      },
       "pat" => token::NtPat(p.parse_pat()),
       "expr" => token::NtExpr(p.parse_expr()),
       "ty" => token::NtTy(p.parse_ty()),
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index 7575d4b5ecd..7a2ae55e914 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -17,7 +17,6 @@ use ext::tt::macro_parser::{NamedMatch, MatchedSeq, MatchedNonterminal};
 use ext::tt::macro_parser::{parse, parse_or_else};
 use parse::lexer::new_tt_reader;
 use parse::parser::Parser;
-use parse::attr::ParserAttr;
 use parse::token::{self, special_idents, gensym_ident, NtTT, Token};
 use parse::token::Token::*;
 use print;
@@ -68,15 +67,8 @@ impl<'a> MacResult for ParserAnyMacro<'a> {
     }
     fn make_items(self: Box<ParserAnyMacro<'a>>) -> Option<SmallVector<P<ast::Item>>> {
         let mut ret = SmallVector::zero();
-        loop {
-            let mut parser = self.parser.borrow_mut();
-            // so... do outer attributes attached to the macro invocation
-            // just disappear? This question applies to make_impl_items, as
-            // well.
-            match parser.parse_item_with_outer_attributes() {
-                Some(item) => ret.push(item),
-                None => break
-            }
+        while let Some(item) = self.parser.borrow_mut().parse_item() {
+            ret.push(item);
         }
         self.ensure_complete_parse(false);
         Some(ret)
@@ -89,7 +81,7 @@ impl<'a> MacResult for ParserAnyMacro<'a> {
             let mut parser = self.parser.borrow_mut();
             match parser.token {
                 token::Eof => break,
-                _ => ret.push(parser.parse_impl_item_with_outer_attributes())
+                _ => ret.push(parser.parse_impl_item())
             }
         }
         self.ensure_complete_parse(false);
@@ -97,10 +89,9 @@ impl<'a> MacResult for ParserAnyMacro<'a> {
     }
 
     fn make_stmt(self: Box<ParserAnyMacro<'a>>) -> Option<P<ast::Stmt>> {
-        let attrs = self.parser.borrow_mut().parse_outer_attributes();
-        let ret = self.parser.borrow_mut().parse_stmt(attrs);
+        let ret = self.parser.borrow_mut().parse_stmt();
         self.ensure_complete_parse(true);
-        Some(ret)
+        ret
     }
 }
 
diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs
index f60ac8f3f33..b53bb4bc75e 100644
--- a/src/libsyntax/lib.rs
+++ b/src/libsyntax/lib.rs
@@ -37,7 +37,6 @@
 #![feature(staged_api)]
 #![feature(std_misc)]
 #![feature(unicode)]
-#![feature(io)]
 #![feature(path_ext)]
 
 extern crate arena;
diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs
index db5583cf13a..a5dd4f22224 100644
--- a/src/libsyntax/parse/attr.rs
+++ b/src/libsyntax/parse/attr.rs
@@ -19,9 +19,8 @@ use ptr::P;
 /// A parser that can parse attributes.
 pub trait ParserAttr {
     fn parse_outer_attributes(&mut self) -> Vec<ast::Attribute>;
+    fn parse_inner_attributes(&mut self) -> Vec<ast::Attribute>;
     fn parse_attribute(&mut self, permit_inner: bool) -> ast::Attribute;
-    fn parse_inner_attrs_and_next(&mut self)
-                                  -> (Vec<ast::Attribute>, Vec<ast::Attribute>);
     fn parse_meta_item(&mut self) -> P<ast::MetaItem>;
     fn parse_meta_seq(&mut self) -> Vec<P<ast::MetaItem>>;
     fn parse_optional_meta(&mut self) -> Vec<P<ast::MetaItem>>;
@@ -118,45 +117,40 @@ impl<'a> ParserAttr for Parser<'a> {
 
     /// Parse attributes that appear after the opening of an item. These should
     /// be preceded by an exclamation mark, but we accept and warn about one
-    /// terminated by a semicolon. In addition to a vector of inner attributes,
-    /// this function also returns a vector that may contain the first outer
-    /// attribute of the next item (since we can't know whether the attribute
-    /// is an inner attribute of the containing item or an outer attribute of
-    /// the first contained item until we see the semi).
-
-    /// matches inner_attrs* outer_attr?
-    /// you can make the 'next' field an Option, but the result is going to be
-    /// more useful as a vector.
-    fn parse_inner_attrs_and_next(&mut self)
-                                  -> (Vec<ast::Attribute> , Vec<ast::Attribute> ) {
-        let mut inner_attrs: Vec<ast::Attribute> = Vec::new();
-        let mut next_outer_attrs: Vec<ast::Attribute> = Vec::new();
+    /// terminated by a semicolon.
+
+    /// matches inner_attrs*
+    fn parse_inner_attributes(&mut self) -> Vec<ast::Attribute> {
+        let mut attrs: Vec<ast::Attribute> = vec![];
         loop {
-            let attr = match self.token {
+            match self.token {
                 token::Pound => {
-                    self.parse_attribute(true)
+                    // Don't even try to parse if it's not an inner attribute.
+                    if !self.look_ahead(1, |t| t == &token::Not) {
+                        break;
+                    }
+
+                    let attr = self.parse_attribute(true);
+                    assert!(attr.node.style == ast::AttrInner);
+                    attrs.push(attr);
                 }
                 token::DocComment(s) => {
                     // we need to get the position of this token before we bump.
                     let Span { lo, hi, .. } = self.span;
-                    self.bump();
-                    attr::mk_sugared_doc_attr(attr::mk_attr_id(),
-                                              self.id_to_interned_str(s.ident()),
-                                              lo,
-                                              hi)
-                }
-                _ => {
-                    break;
+                    let attr = attr::mk_sugared_doc_attr(attr::mk_attr_id(),
+                                                         self.id_to_interned_str(s.ident()),
+                                                         lo, hi);
+                    if attr.node.style == ast::AttrInner {
+                        attrs.push(attr);
+                        self.bump();
+                    } else {
+                        break;
+                    }
                 }
-            };
-            if attr.node.style == ast::AttrInner {
-                inner_attrs.push(attr);
-            } else {
-                next_outer_attrs.push(attr);
-                break;
+                _ => break
             }
         }
-        (inner_attrs, next_outer_attrs)
+        attrs
     }
 
     /// matches meta_item = IDENT
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index f542246705c..82ba873e54b 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -96,9 +96,7 @@ pub fn parse_crate_attrs_from_file(
     cfg: ast::CrateConfig,
     sess: &ParseSess
 ) -> Vec<ast::Attribute> {
-    let mut parser = new_parser_from_file(sess, cfg, input);
-    let (inner, _) = parser.parse_inner_attrs_and_next();
-    inner
+    new_parser_from_file(sess, cfg, input).parse_inner_attributes()
 }
 
 pub fn parse_crate_from_source_str(name: String,
@@ -122,8 +120,7 @@ pub fn parse_crate_attrs_from_source_str(name: String,
                                            cfg,
                                            name,
                                            source);
-    let (inner, _) = maybe_aborted(p.parse_inner_attrs_and_next(),p);
-    inner
+    maybe_aborted(p.parse_inner_attributes(), p)
 }
 
 pub fn parse_expr_from_source_str(name: String,
@@ -141,7 +138,7 @@ pub fn parse_item_from_source_str(name: String,
                                   sess: &ParseSess)
                                   -> Option<P<ast::Item>> {
     let mut p = new_parser_from_source_str(sess, cfg, name, source);
-    maybe_aborted(p.parse_item_with_outer_attributes(),p)
+    maybe_aborted(p.parse_item(),p)
 }
 
 pub fn parse_meta_from_source_str(name: String,
@@ -156,16 +153,15 @@ pub fn parse_meta_from_source_str(name: String,
 pub fn parse_stmt_from_source_str(name: String,
                                   source: String,
                                   cfg: ast::CrateConfig,
-                                  attrs: Vec<ast::Attribute> ,
                                   sess: &ParseSess)
-                                  -> P<ast::Stmt> {
+                                  -> Option<P<ast::Stmt>> {
     let mut p = new_parser_from_source_str(
         sess,
         cfg,
         name,
         source
     );
-    maybe_aborted(p.parse_stmt(attrs),p)
+    maybe_aborted(p.parse_stmt(), p)
 }
 
 // Note: keep in sync with `with_hygiene::parse_tts_from_source_str`
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index f2ada490fad..bf2b2c0afe6 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -39,7 +39,7 @@ use ast::{LitStr, LitInt, Local, LocalLet};
 use ast::{MacStmtWithBraces, MacStmtWithSemicolon, MacStmtWithoutBraces};
 use ast::{MutImmutable, MutMutable, Mac_, MacInvocTT, MatchSource};
 use ast::{MutTy, BiMul, Mutability};
-use ast::{MethodImplItem, NamedField, UnNeg, NoReturn, NodeId, UnNot};
+use ast::{MethodImplItem, NamedField, UnNeg, NoReturn, UnNot};
 use ast::{Pat, PatEnum, PatIdent, PatLit, PatRange, PatRegion, PatStruct};
 use ast::{PatTup, PatBox, PatWild, PatWildMulti, PatWildSingle};
 use ast::{PolyTraitRef, QSelf};
@@ -78,6 +78,7 @@ use owned_slice::OwnedSlice;
 use std::collections::HashSet;
 use std::io::prelude::*;
 use std::mem;
+#[cfg(stage0)]
 use std::num::Float;
 use std::path::{Path, PathBuf};
 use std::rc::Rc;
@@ -116,11 +117,6 @@ pub enum BoundParsingMode {
     Modified,
 }
 
-/// The `Err` case indicates a failure to parse any kind of item.
-/// The attributes are returned.
-type MaybeItem = Result<P<Item>, Vec<Attribute>>;
-
-
 /// Possibly accept an `token::Interpolated` expression (a pre-parsed expression
 /// dropped into the token stream, which happens while parsing the result of
 /// macro expansion). Placement of these is not as complex as I feared it would
@@ -207,7 +203,7 @@ macro_rules! maybe_whole {
             }
         }
     );
-    (Some $p:expr, $constructor:ident) => (
+    (Some deref $p:expr, $constructor:ident) => (
         {
             let found = match ($p).token {
                 token::Interpolated(token::$constructor(_)) => {
@@ -216,7 +212,7 @@ macro_rules! maybe_whole {
                 _ => None
             };
             if let Some(token::Interpolated(token::$constructor(x))) = found {
-                return Some(x.clone());
+                return Some((*x).clone());
             }
         }
     );
@@ -1239,41 +1235,6 @@ impl<'a> Parser<'a> {
         }
     }
 
-    /// Parses `type Foo;` in a trait declaration only. The `type` keyword has
-    /// already been parsed.
-    fn parse_assoc_ty_in_trait(&mut self, attrs: Vec<Attribute>)
-                               -> P<TraitItem> {
-        let TyParam {id, ident, bounds, default, span} = self.parse_ty_param();
-        self.expect(&token::Semi);
-        P(TraitItem {
-            id: id,
-            ident: ident,
-            attrs: attrs,
-            node: TypeTraitItem(bounds, default),
-            span: span,
-        })
-    }
-
-    /// Parses `type Foo = TYPE;` in an implementation declaration only. The
-    /// `type` keyword has already been parsed.
-    fn parse_assoc_ty_in_impl(&mut self, attrs: Vec<Attribute>, vis: Visibility)
-                              -> P<ImplItem> {
-        let lo = self.span.lo;
-        let ident = self.parse_ident();
-        self.expect(&token::Eq);
-        let typ = self.parse_ty_sum();
-        let hi = self.span.hi;
-        self.expect(&token::Semi);
-        P(ImplItem {
-            id: ast::DUMMY_NODE_ID,
-            span: mk_sp(lo, hi),
-            ident: ident,
-            vis: vis,
-            attrs: attrs,
-            node: TypeImplItem(typ),
-        })
-    }
-
     /// Parse the items in a trait declaration
     pub fn parse_trait_items(&mut self) -> Vec<P<TraitItem>> {
         self.parse_unspanned_seq(
@@ -1281,13 +1242,14 @@ impl<'a> Parser<'a> {
             &token::CloseDelim(token::Brace),
             seq_sep_none(),
             |p| {
+            let lo = p.span.lo;
             let mut attrs = p.parse_outer_attributes();
 
-            if p.eat_keyword(keywords::Type) {
-                p.parse_assoc_ty_in_trait(attrs)
+            let (name, node) = if p.eat_keyword(keywords::Type) {
+                let TyParam {ident, bounds, default, ..} = p.parse_ty_param();
+                p.expect(&token::Semi);
+                (ident, TypeTraitItem(bounds, default))
             } else {
-                let lo = p.span.lo;
-
                 let style = p.parse_unsafety();
                 let abi = if p.eat_keyword(keywords::Extern) {
                     p.parse_opt_abi().unwrap_or(abi::C)
@@ -1315,7 +1277,6 @@ impl<'a> Parser<'a> {
                     explicit_self: explicit_self,
                 };
 
-                let hi = p.last_span.hi;
                 let body = match p.token {
                   token::Semi => {
                     p.bump();
@@ -1336,15 +1297,16 @@ impl<'a> Parser<'a> {
                                        token_str)[..])
                   }
                 };
+                (ident, ast::MethodTraitItem(sig, body))
+            };
 
-                P(TraitItem {
-                    id: ast::DUMMY_NODE_ID,
-                    ident: ident,
-                    attrs: attrs,
-                    node: ast::MethodTraitItem(sig, body),
-                    span: mk_sp(lo, hi),
-                })
-            }
+            P(TraitItem {
+                id: ast::DUMMY_NODE_ID,
+                ident: name,
+                attrs: attrs,
+                node: node,
+                span: mk_sp(lo, p.last_span.hi),
+            })
         })
     }
 
@@ -3646,41 +3608,47 @@ impl<'a> Parser<'a> {
         })
     }
 
-    /// Get an expected item after attributes error message.
-    fn expected_item_err(attrs: &[Attribute]) -> &'static str {
-        match attrs.last() {
+    /// Emit an expected item after attributes error.
+    fn expected_item_err(&self, attrs: &[Attribute]) {
+        let message = match attrs.last() {
             Some(&Attribute { node: ast::Attribute_ { is_sugared_doc: true, .. }, .. }) => {
                 "expected item after doc comment"
             }
             _ => "expected item after attributes",
-        }
+        };
+
+        self.span_err(self.last_span, message);
     }
 
     /// Parse a statement. may include decl.
-    /// Precondition: any attributes are parsed already
-    pub fn parse_stmt(&mut self, item_attrs: Vec<Attribute>) -> P<Stmt> {
-        maybe_whole!(self, NtStmt);
+    pub fn parse_stmt(&mut self) -> Option<P<Stmt>> {
+        self.parse_stmt_().map(P)
+    }
+
+    fn parse_stmt_(&mut self) -> Option<Stmt> {
+        maybe_whole!(Some deref self, NtStmt);
 
         fn check_expected_item(p: &mut Parser, attrs: &[Attribute]) {
             // If we have attributes then we should have an item
             if !attrs.is_empty() {
-                let last_span = p.last_span;
-                p.span_err(last_span, Parser::expected_item_err(attrs));
+                p.expected_item_err(attrs);
             }
         }
 
         let lo = self.span.lo;
-        if self.check_keyword(keywords::Let) {
-            check_expected_item(self, &item_attrs[..]);
+        let attrs = self.parse_outer_attributes();
+
+        Some(if self.check_keyword(keywords::Let) {
+            check_expected_item(self, &attrs);
             self.expect_keyword(keywords::Let);
             let decl = self.parse_let();
-            P(spanned(lo, decl.span.hi, StmtDecl(decl, ast::DUMMY_NODE_ID)))
+            spanned(lo, decl.span.hi, StmtDecl(decl, ast::DUMMY_NODE_ID))
         } else if self.token.is_ident()
             && !self.token.is_any_keyword()
             && self.look_ahead(1, |t| *t == token::Not) {
             // it's a macro invocation:
 
-            check_expected_item(self, &item_attrs[..]);
+            check_expected_item(self, &attrs);
 
             // Potential trouble: if we allow macros with paths instead of
             // idents, we'd need to look ahead past the whole path here...
@@ -3727,12 +3695,11 @@ impl<'a> Parser<'a> {
             };
 
             if id.name == token::special_idents::invalid.name {
-                P(spanned(lo,
-                          hi,
-                          StmtMac(P(spanned(lo,
+                spanned(lo, hi,
+                        StmtMac(P(spanned(lo,
                                           hi,
                                           MacInvocTT(pth, tts, EMPTY_CTXT))),
-                                  style)))
+                                  style))
             } else {
                 // if it has a special ident, it's definitely an item
                 //
@@ -3746,35 +3713,38 @@ impl<'a> Parser<'a> {
                                        followed by a semicolon");
                     }
                 }
-                P(spanned(lo, hi, StmtDecl(
+                spanned(lo, hi, StmtDecl(
                     P(spanned(lo, hi, DeclItem(
                         self.mk_item(
                             lo, hi, id /*id is good here*/,
                             ItemMac(spanned(lo, hi, MacInvocTT(pth, tts, EMPTY_CTXT))),
                             Inherited, Vec::new(/*no attrs*/))))),
-                    ast::DUMMY_NODE_ID)))
+                    ast::DUMMY_NODE_ID))
             }
         } else {
-            let found_attrs = !item_attrs.is_empty();
-            let item_err = Parser::expected_item_err(&item_attrs[..]);
-            match self.parse_item_(item_attrs, false) {
-                Ok(i) => {
+            match self.parse_item_(attrs, false) {
+                Some(i) => {
                     let hi = i.span.hi;
                     let decl = P(spanned(lo, hi, DeclItem(i)));
-                    P(spanned(lo, hi, StmtDecl(decl, ast::DUMMY_NODE_ID)))
+                    spanned(lo, hi, StmtDecl(decl, ast::DUMMY_NODE_ID))
                 }
-                Err(_) => {
-                    if found_attrs {
-                        let last_span = self.last_span;
-                        self.span_err(last_span, item_err);
+                None => {
+                    // Do not attempt to parse an expression if we're done here.
+                    if self.token == token::Semi {
+                        self.bump();
+                        return None;
+                    }
+
+                    if self.token == token::CloseDelim(token::Brace) {
+                        return None;
                     }
 
                     // Remainder are line-expr stmts.
                     let e = self.parse_expr_res(RESTRICTION_STMT_EXPR);
-                    P(spanned(lo, e.span.hi, StmtExpr(e, ast::DUMMY_NODE_ID)))
+                    spanned(lo, e.span.hi, StmtExpr(e, ast::DUMMY_NODE_ID))
                 }
             }
-        }
+        })
     }
 
     /// Is this expression a successfully-parsed statement?
@@ -3797,153 +3767,110 @@ impl<'a> Parser<'a> {
                                  "place this code inside a block");
         }
 
-        return self.parse_block_tail_(lo, DefaultBlock, Vec::new());
+        self.parse_block_tail(lo, DefaultBlock)
     }
 
     /// Parse a block. Inner attrs are allowed.
-    fn parse_inner_attrs_and_block(&mut self)
-        -> (Vec<Attribute> , P<Block>) {
-
+    fn parse_inner_attrs_and_block(&mut self) -> (Vec<Attribute>, P<Block>) {
         maybe_whole!(pair_empty self, NtBlock);
 
         let lo = self.span.lo;
         self.expect(&token::OpenDelim(token::Brace));
-        let (inner, next) = self.parse_inner_attrs_and_next();
-
-        (inner, self.parse_block_tail_(lo, DefaultBlock, next))
+        (self.parse_inner_attributes(),
+         self.parse_block_tail(lo, DefaultBlock))
     }
 
+    /// Parse the rest of a block expression or function body
     /// Precondition: already parsed the '{'.
     fn parse_block_tail(&mut self, lo: BytePos, s: BlockCheckMode) -> P<Block> {
-        self.parse_block_tail_(lo, s, Vec::new())
-    }
-
-    /// Parse the rest of a block expression or function body
-    fn parse_block_tail_(&mut self, lo: BytePos, s: BlockCheckMode,
-                         first_item_attrs: Vec<Attribute>) -> P<Block> {
         let mut stmts = vec![];
         let mut expr = None;
-        let mut attributes_box = first_item_attrs;
 
-        while self.token != token::CloseDelim(token::Brace) {
-            // parsing items even when they're not allowed lets us give
-            // better error messages and recover more gracefully.
-            attributes_box.push_all(&self.parse_outer_attributes());
-            match self.token {
-                token::Semi => {
-                    if !attributes_box.is_empty() {
-                        let last_span = self.last_span;
-                        self.span_err(last_span,
-                                      Parser::expected_item_err(&attributes_box[..]));
-                        attributes_box = Vec::new();
-                    }
-                    self.bump(); // empty
-                }
-                token::CloseDelim(token::Brace) => {
-                    // fall through and out.
+        while !self.eat(&token::CloseDelim(token::Brace)) {
+            let Spanned {node, span} = if let Some(s) = self.parse_stmt_() {
+                s
+            } else {
+                // Found only `;` or `}`.
+                continue;
+            };
+            match node {
+                StmtExpr(e, _) => {
+                    self.handle_expression_like_statement(e, span, &mut stmts, &mut expr);
                 }
-                _ => {
-                    let stmt = self.parse_stmt(attributes_box);
-                    attributes_box = Vec::new();
-                    stmt.and_then(|Spanned {node, span}| match node {
-                        StmtExpr(e, stmt_id) => {
-                            self.handle_expression_like_statement(e,
-                                                                  stmt_id,
-                                                                  span,
-                                                                  &mut stmts,
-                                                                  &mut expr);
+                StmtMac(mac, MacStmtWithoutBraces) => {
+                    // statement macro without braces; might be an
+                    // expr depending on whether a semicolon follows
+                    match self.token {
+                        token::Semi => {
+                            stmts.push(P(Spanned {
+                                node: StmtMac(mac, MacStmtWithSemicolon),
+                                span: span,
+                            }));
+                            self.bump();
                         }
-                        StmtMac(mac, MacStmtWithoutBraces) => {
-                            // statement macro without braces; might be an
-                            // expr depending on whether a semicolon follows
-                            match self.token {
-                                token::Semi => {
-                                    stmts.push(P(Spanned {
-                                        node: StmtMac(mac,
-                                                      MacStmtWithSemicolon),
-                                        span: span,
-                                    }));
-                                    self.bump();
-                                }
-                                _ => {
-                                    let e = self.mk_mac_expr(span.lo,
-                                                             span.hi,
-                                                             mac.and_then(|m| m.node));
-                                    let e = self.parse_dot_or_call_expr_with(e);
-                                    let e = self.parse_more_binops(e, 0);
-                                    let e = self.parse_assign_expr_with(e);
-                                    self.handle_expression_like_statement(
-                                        e,
-                                        ast::DUMMY_NODE_ID,
-                                        span,
-                                        &mut stmts,
-                                        &mut expr);
-                                }
-                            }
+                        _ => {
+                            let e = self.mk_mac_expr(span.lo, span.hi,
+                                                     mac.and_then(|m| m.node));
+                            let e = self.parse_dot_or_call_expr_with(e);
+                            let e = self.parse_more_binops(e, 0);
+                            let e = self.parse_assign_expr_with(e);
+                            self.handle_expression_like_statement(
+                                e,
+                                span,
+                                &mut stmts,
+                                &mut expr);
                         }
-                        StmtMac(m, style) => {
-                            // statement macro; might be an expr
-                            match self.token {
-                                token::Semi => {
-                                    stmts.push(P(Spanned {
-                                        node: StmtMac(m,
-                                                      MacStmtWithSemicolon),
-                                        span: span,
-                                    }));
-                                    self.bump();
-                                }
-                                token::CloseDelim(token::Brace) => {
-                                    // if a block ends in `m!(arg)` without
-                                    // a `;`, it must be an expr
-                                    expr = Some(
-                                        self.mk_mac_expr(span.lo,
-                                                         span.hi,
+                    }
+                }
+                StmtMac(m, style) => {
+                    // statement macro; might be an expr
+                    match self.token {
+                        token::Semi => {
+                            stmts.push(P(Spanned {
+                                node: StmtMac(m, MacStmtWithSemicolon),
+                                span: span,
+                            }));
+                            self.bump();
+                        }
+                        token::CloseDelim(token::Brace) => {
+                            // if a block ends in `m!(arg)` without
+                            // a `;`, it must be an expr
+                            expr = Some(self.mk_mac_expr(span.lo, span.hi,
                                                          m.and_then(|x| x.node)));
-                                }
-                                _ => {
-                                    stmts.push(P(Spanned {
-                                        node: StmtMac(m, style),
-                                        span: span
-                                    }));
-                                }
-                            }
                         }
-                        _ => { // all other kinds of statements:
-                            if classify::stmt_ends_with_semi(&node) {
-                                self.commit_stmt_expecting(token::Semi);
-                            }
-
+                        _ => {
                             stmts.push(P(Spanned {
-                                node: node,
+                                node: StmtMac(m, style),
                                 span: span
                             }));
                         }
-                    })
+                    }
                 }
-            }
-        }
+                _ => { // all other kinds of statements:
+                    if classify::stmt_ends_with_semi(&node) {
+                        self.commit_stmt_expecting(token::Semi);
+                    }
 
-        if !attributes_box.is_empty() {
-            let last_span = self.last_span;
-            self.span_err(last_span,
-                          Parser::expected_item_err(&attributes_box[..]));
+                    stmts.push(P(Spanned {
+                        node: node,
+                        span: span
+                    }));
+                }
+            }
         }
 
-        let hi = self.span.hi;
-        self.bump();
         P(ast::Block {
             stmts: stmts,
             expr: expr,
             id: ast::DUMMY_NODE_ID,
             rules: s,
-            span: mk_sp(lo, hi),
+            span: mk_sp(lo, self.last_span.hi),
         })
     }
 
     fn handle_expression_like_statement(
             &mut self,
             e: P<Expr>,
-            stmt_id: NodeId,
             span: Span,
             stmts: &mut Vec<P<Stmt>>,
             last_block_expr: &mut Option<P<Expr>>) {
@@ -3963,14 +3890,14 @@ impl<'a> Parser<'a> {
                     expn_id: span.expn_id,
                 };
                 stmts.push(P(Spanned {
-                    node: StmtSemi(e, stmt_id),
+                    node: StmtSemi(e, ast::DUMMY_NODE_ID),
                     span: span_with_semi,
                 }));
             }
             token::CloseDelim(token::Brace) => *last_block_expr = Some(e),
             _ => {
                 stmts.push(P(Spanned {
-                    node: StmtExpr(e, stmt_id),
+                    node: StmtExpr(e, ast::DUMMY_NODE_ID),
                     span: span
                 }));
             }
@@ -4625,14 +4552,30 @@ impl<'a> Parser<'a> {
     }
 
     /// Parse an impl item.
-    pub fn parse_impl_item_with_outer_attributes(&mut self) -> P<ImplItem> {
-        let attrs = self.parse_outer_attributes();
+    pub fn parse_impl_item(&mut self) -> P<ImplItem> {
+        let lo = self.span.lo;
+        let mut attrs = self.parse_outer_attributes();
         let vis = self.parse_visibility();
-        if self.eat_keyword(keywords::Type) {
-            self.parse_assoc_ty_in_impl(attrs, vis)
+        let (name, node) = if self.eat_keyword(keywords::Type) {
+            let name = self.parse_ident();
+            self.expect(&token::Eq);
+            let typ = self.parse_ty_sum();
+            self.expect(&token::Semi);
+            (name, TypeImplItem(typ))
         } else {
-            self.parse_method(attrs, vis)
-        }
+            let (name, inner_attrs, node) = self.parse_impl_method(vis);
+            attrs.extend(inner_attrs.into_iter());
+            (name, node)
+        };
+
+        P(ImplItem {
+            id: ast::DUMMY_NODE_ID,
+            span: mk_sp(lo, self.last_span.hi),
+            ident: name,
+            vis: vis,
+            attrs: attrs,
+            node: node
+        })
     }
 
     fn complain_if_pub_macro(&mut self, visa: Visibility, span: Span) {
@@ -4646,76 +4589,58 @@ impl<'a> Parser<'a> {
         }
     }
 
-    /// Parse a method in a trait impl, starting with `attrs` attributes.
-    pub fn parse_method(&mut self,
-                        attrs: Vec<Attribute>,
-                        vis: Visibility)
-                        -> P<ImplItem> {
-        let lo = self.span.lo;
-
+    /// Parse a method or a macro invocation in a trait impl.
+    fn parse_impl_method(&mut self, vis: Visibility)
+                         -> (Ident, Vec<ast::Attribute>, ast::ImplItem_) {
         // code copied from parse_macro_use_or_failure... abstraction!
-        let (method_, hi, new_attrs, ident) = {
-            if !self.token.is_any_keyword()
-                && self.look_ahead(1, |t| *t == token::Not)
-                && (self.look_ahead(2, |t| *t == token::OpenDelim(token::Paren))
-                    || self.look_ahead(2, |t| *t == token::OpenDelim(token::Brace))) {
-                // method macro.
+        if !self.token.is_any_keyword()
+            && self.look_ahead(1, |t| *t == token::Not)
+            && (self.look_ahead(2, |t| *t == token::OpenDelim(token::Paren))
+                || self.look_ahead(2, |t| *t == token::OpenDelim(token::Brace))) {
+            // method macro.
 
-                let last_span = self.last_span;
-                self.complain_if_pub_macro(vis, last_span);
-
-                let pth = self.parse_path(NoTypesAllowed);
-                self.expect(&token::Not);
-
-                // eat a matched-delimiter token tree:
-                let delim = self.expect_open_delim();
-                let tts = self.parse_seq_to_end(&token::CloseDelim(delim),
-                                                seq_sep_none(),
-                                                |p| p.parse_token_tree());
-                let m_ = ast::MacInvocTT(pth, tts, EMPTY_CTXT);
-                let m: ast::Mac = codemap::Spanned { node: m_,
-                                                 span: mk_sp(self.span.lo,
-                                                             self.span.hi) };
-                if delim != token::Brace {
-                    self.expect(&token::Semi)
-                }
-                (ast::MacImplItem(m), self.span.hi, attrs,
-                 token::special_idents::invalid)
-            } else {
-                let unsafety = self.parse_unsafety();
-                let abi = if self.eat_keyword(keywords::Extern) {
-                    self.parse_opt_abi().unwrap_or(abi::C)
-                } else {
-                    abi::Rust
-                };
-                self.expect_keyword(keywords::Fn);
-                let ident = self.parse_ident();
-                let mut generics = self.parse_generics();
-                let (explicit_self, decl) = self.parse_fn_decl_with_self(|p| {
-                        p.parse_arg()
-                    });
-                self.parse_where_clause(&mut generics);
-                let (inner_attrs, body) = self.parse_inner_attrs_and_block();
-                let body_span = body.span;
-                let mut new_attrs = attrs;
-                new_attrs.push_all(&inner_attrs[..]);
-                (MethodImplItem(ast::MethodSig {
-                    generics: generics,
-                    abi: abi,
-                    explicit_self: explicit_self,
-                    unsafety: unsafety,
-                    decl: decl
-                 }, body), body_span.hi, new_attrs, ident)
+            let last_span = self.last_span;
+            self.complain_if_pub_macro(vis, last_span);
+
+            let pth = self.parse_path(NoTypesAllowed);
+            self.expect(&token::Not);
+
+            // eat a matched-delimiter token tree:
+            let delim = self.expect_open_delim();
+            let tts = self.parse_seq_to_end(&token::CloseDelim(delim),
+                                            seq_sep_none(),
+                                            |p| p.parse_token_tree());
+            let m_ = ast::MacInvocTT(pth, tts, EMPTY_CTXT);
+            let m: ast::Mac = codemap::Spanned { node: m_,
+                                                span: mk_sp(self.span.lo,
+                                                            self.span.hi) };
+            if delim != token::Brace {
+                self.expect(&token::Semi)
             }
-        };
-        P(ImplItem {
-            id: ast::DUMMY_NODE_ID,
-            attrs: new_attrs,
-            vis: vis,
-            ident: ident,
-            node: method_,
-            span: mk_sp(lo, hi),
-        })
+            (token::special_idents::invalid, vec![], ast::MacImplItem(m))
+        } else {
+            let unsafety = self.parse_unsafety();
+            let abi = if self.eat_keyword(keywords::Extern) {
+                self.parse_opt_abi().unwrap_or(abi::C)
+            } else {
+                abi::Rust
+            };
+            self.expect_keyword(keywords::Fn);
+            let ident = self.parse_ident();
+            let mut generics = self.parse_generics();
+            let (explicit_self, decl) = self.parse_fn_decl_with_self(|p| {
+                    p.parse_arg()
+                });
+            self.parse_where_clause(&mut generics);
+            let (inner_attrs, body) = self.parse_inner_attrs_and_block();
+            (ident, inner_attrs, MethodImplItem(ast::MethodSig {
+                generics: generics,
+                abi: abi,
+                explicit_self: explicit_self,
+                unsafety: unsafety,
+                decl: decl
+             }, body))
+        }
     }
 
     /// Parse trait Foo { ... }
@@ -4746,28 +4671,6 @@ impl<'a> Parser<'a> {
         (ident, ItemTrait(unsafety, tps, bounds, meths), None)
     }
 
-    fn parse_impl_items(&mut self) -> (Vec<P<ImplItem>>, Vec<Attribute>) {
-        let mut impl_items = Vec::new();
-        self.expect(&token::OpenDelim(token::Brace));
-        let (inner_attrs, mut method_attrs) =
-            self.parse_inner_attrs_and_next();
-        loop {
-            method_attrs.extend(self.parse_outer_attributes().into_iter());
-            if method_attrs.is_empty() && self.eat(&token::CloseDelim(token::Brace)) {
-                break;
-            }
-
-            let vis = self.parse_visibility();
-            impl_items.push(if self.eat_keyword(keywords::Type) {
-                self.parse_assoc_ty_in_impl(method_attrs, vis)
-            } else {
-                self.parse_method(method_attrs, vis)
-            });
-            method_attrs = vec![];
-        }
-        (impl_items, inner_attrs)
-    }
-
     /// Parses items implementations variants
     ///    impl<T> Foo { ... }
     ///    impl<T> ToString for &'static T { ... }
@@ -4834,7 +4737,14 @@ impl<'a> Parser<'a> {
                 ty = self.parse_ty_sum();
             }
             self.parse_where_clause(&mut generics);
-            let (impl_items, attrs) = self.parse_impl_items();
+
+            self.expect(&token::OpenDelim(token::Brace));
+            let attrs = self.parse_inner_attributes();
+
+            let mut impl_items = vec![];
+            while !self.eat(&token::CloseDelim(token::Brace)) {
+                impl_items.push(self.parse_impl_item());
+            }
 
             (ast_util::impl_pretty_name(&opt_trait, Some(&*ty)),
              ItemImpl(unsafety, polarity, generics, opt_trait, ty, impl_items),
@@ -5073,53 +4983,16 @@ impl<'a> Parser<'a> {
         }
     }
 
-    /// Given a termination token and a vector of already-parsed
-    /// attributes (of length 0 or 1), parse all of the items in a module
-    fn parse_mod_items(&mut self,
-                       term: token::Token,
-                       first_item_attrs: Vec<Attribute>,
-                       inner_lo: BytePos)
-                       -> Mod {
-        // Parse all of the items up to closing or an attribute.
-
-        let mut attrs = first_item_attrs;
-        attrs.push_all(&self.parse_outer_attributes());
+    /// Given a termination token, parse all of the items in a module
+    fn parse_mod_items(&mut self, term: &token::Token, inner_lo: BytePos) -> Mod {
         let mut items = vec![];
-
-        loop {
-            match self.parse_item_(attrs, true) {
-                Err(returned_attrs) => {
-                    attrs = returned_attrs;
-                    break
-                }
-                Ok(item) => {
-                    attrs = self.parse_outer_attributes();
-                    items.push(item)
-                }
-            }
-        }
-
-        // don't think this other loop is even necessary....
-
-        while self.token != term {
-            let mut attrs = mem::replace(&mut attrs, vec![]);
-            attrs.push_all(&self.parse_outer_attributes());
-            debug!("parse_mod_items: parse_item_(attrs={:?})", attrs);
-            match self.parse_item_(attrs, true /* macros allowed */) {
-              Ok(item) => items.push(item),
-              Err(_) => {
-                  let token_str = self.this_token_to_string();
-                  self.fatal(&format!("expected item, found `{}`",
-                                     token_str))
-              }
-            }
+        while let Some(item) = self.parse_item() {
+            items.push(item);
         }
 
-        if !attrs.is_empty() {
-            // We parsed attributes for the first item but didn't find it
-            let last_span = self.last_span;
-            self.span_err(last_span,
-                          Parser::expected_item_err(&attrs[..]));
+        if !self.eat(term) {
+            let token_str = self.this_token_to_string();
+            self.fatal(&format!("expected item, found `{}`", token_str))
         }
 
         ast::Mod {
@@ -5157,12 +5030,11 @@ impl<'a> Parser<'a> {
             let mod_inner_lo = self.span.lo;
             let old_owns_directory = self.owns_directory;
             self.owns_directory = true;
-            let (inner, next) = self.parse_inner_attrs_and_next();
-            let m = self.parse_mod_items(token::CloseDelim(token::Brace), next, mod_inner_lo);
-            self.expect(&token::CloseDelim(token::Brace));
+            let attrs = self.parse_inner_attributes();
+            let m = self.parse_mod_items(&token::CloseDelim(token::Brace), mod_inner_lo);
             self.owns_directory = old_owns_directory;
             self.pop_mod_path();
-            (id, ItemMod(m), Some(inner))
+            (id, ItemMod(m), Some(attrs))
         }
     }
 
@@ -5289,11 +5161,10 @@ impl<'a> Parser<'a> {
                                      Some(name),
                                      id_sp);
         let mod_inner_lo = p0.span.lo;
-        let (mod_attrs, next) = p0.parse_inner_attrs_and_next();
-        let first_item_outer_attrs = next;
-        let m0 = p0.parse_mod_items(token::Eof, first_item_outer_attrs, mod_inner_lo);
+        let mod_attrs = p0.parse_inner_attributes();
+        let m0 = p0.parse_mod_items(&token::Eof, mod_inner_lo);
         self.sess.included_mod_stack.borrow_mut().pop();
-        return (ast::ItemMod(m0), mod_attrs);
+        (ast::ItemMod(m0), mod_attrs)
     }
 
     /// Parse a function declaration from a foreign module
@@ -5340,20 +5211,6 @@ impl<'a> Parser<'a> {
         })
     }
 
-    /// At this point, this is essentially a wrapper for
-    /// parse_foreign_items.
-    fn parse_foreign_mod_items(&mut self,
-                               abi: abi::Abi,
-                               first_item_attrs: Vec<Attribute>)
-                               -> ForeignMod {
-        let foreign_items = self.parse_foreign_items(first_item_attrs);
-        assert!(self.token == token::CloseDelim(token::Brace));
-        ast::ForeignMod {
-            abi: abi,
-            items: foreign_items
-        }
-    }
-
     /// Parse extern crate links
     ///
     /// # Examples
@@ -5432,24 +5289,31 @@ impl<'a> Parser<'a> {
                               lo: BytePos,
                               opt_abi: Option<abi::Abi>,
                               visibility: Visibility,
-                              attrs: Vec<Attribute>)
+                              mut attrs: Vec<Attribute>)
                               -> P<Item> {
-
         self.expect(&token::OpenDelim(token::Brace));
 
         let abi = opt_abi.unwrap_or(abi::C);
 
-        let (inner, next) = self.parse_inner_attrs_and_next();
-        let m = self.parse_foreign_mod_items(abi, next);
+        attrs.extend(self.parse_inner_attributes().into_iter());
+
+        let mut foreign_items = vec![];
+        while let Some(item) = self.parse_foreign_item() {
+            foreign_items.push(item);
+        }
         self.expect(&token::CloseDelim(token::Brace));
 
         let last_span = self.last_span;
+        let m = ast::ForeignMod {
+            abi: abi,
+            items: foreign_items
+        };
         self.mk_item(lo,
                      last_span.hi,
                      special_idents::invalid,
                      ItemForeignMod(m),
                      visibility,
-                     maybe_append(attrs, Some(inner)))
+                     attrs)
     }
 
     /// Parse type Foo = Bar;
@@ -5591,12 +5455,11 @@ impl<'a> Parser<'a> {
         }
     }
 
-    /// Parse one of the items allowed by the flags; on failure,
-    /// return `Err(remaining_attrs)`.
+    /// Parse one of the items allowed by the flags.
     /// NB: this function no longer parses the items inside an
     /// extern crate.
     fn parse_item_(&mut self, attrs: Vec<Attribute>,
-                   macros_allowed: bool) -> MaybeItem {
+                   macros_allowed: bool) -> Option<P<Item>> {
         let nt_item = match self.token {
             token::Interpolated(token::NtItem(ref item)) => {
                 Some((**item).clone())
@@ -5609,7 +5472,7 @@ impl<'a> Parser<'a> {
                 let mut attrs = attrs;
                 mem::swap(&mut item.attrs, &mut attrs);
                 item.attrs.extend(attrs.into_iter());
-                return Ok(P(item));
+                return Some(P(item));
             }
             None => {}
         }
@@ -5630,12 +5493,12 @@ impl<'a> Parser<'a> {
                                     item_,
                                     visibility,
                                     attrs);
-            return Ok(item);
+            return Some(item);
         }
 
         if self.eat_keyword(keywords::Extern) {
             if self.eat_keyword(keywords::Crate) {
-                return Ok(self.parse_item_extern_crate(lo, visibility, attrs));
+                return Some(self.parse_item_extern_crate(lo, visibility, attrs));
             }
 
             let opt_abi = self.parse_opt_abi();
@@ -5652,9 +5515,9 @@ impl<'a> Parser<'a> {
                                         item_,
                                         visibility,
                                         maybe_append(attrs, extra_attrs));
-                return Ok(item);
+                return Some(item);
             } else if self.check(&token::OpenDelim(token::Brace)) {
-                return Ok(self.parse_item_foreign_mod(lo, opt_abi, visibility, attrs));
+                return Some(self.parse_item_foreign_mod(lo, opt_abi, visibility, attrs));
             }
 
             let span = self.span;
@@ -5680,7 +5543,7 @@ impl<'a> Parser<'a> {
                                     item_,
                                     visibility,
                                     maybe_append(attrs, extra_attrs));
-            return Ok(item);
+            return Some(item);
         }
         if self.eat_keyword(keywords::Const) {
             // CONST ITEM
@@ -5697,7 +5560,7 @@ impl<'a> Parser<'a> {
                                     item_,
                                     visibility,
                                     maybe_append(attrs, extra_attrs));
-            return Ok(item);
+            return Some(item);
         }
         if self.check_keyword(keywords::Unsafe) &&
             self.look_ahead(1, |t| t.is_keyword(keywords::Trait))
@@ -5714,7 +5577,7 @@ impl<'a> Parser<'a> {
                                     item_,
                                     visibility,
                                     maybe_append(attrs, extra_attrs));
-            return Ok(item);
+            return Some(item);
         }
         if self.check_keyword(keywords::Unsafe) &&
             self.look_ahead(1, |t| t.is_keyword(keywords::Impl))
@@ -5730,7 +5593,7 @@ impl<'a> Parser<'a> {
                                     item_,
                                     visibility,
                                     maybe_append(attrs, extra_attrs));
-            return Ok(item);
+            return Some(item);
         }
         if self.check_keyword(keywords::Fn) {
             // FUNCTION ITEM
@@ -5744,7 +5607,7 @@ impl<'a> Parser<'a> {
                                     item_,
                                     visibility,
                                     maybe_append(attrs, extra_attrs));
-            return Ok(item);
+            return Some(item);
         }
         if self.check_keyword(keywords::Unsafe)
             && self.look_ahead(1, |t| *t != token::OpenDelim(token::Brace)) {
@@ -5765,7 +5628,7 @@ impl<'a> Parser<'a> {
                                     item_,
                                     visibility,
                                     maybe_append(attrs, extra_attrs));
-            return Ok(item);
+            return Some(item);
         }
         if self.eat_keyword(keywords::Mod) {
             // MODULE ITEM
@@ -5778,7 +5641,7 @@ impl<'a> Parser<'a> {
                                     item_,
                                     visibility,
                                     maybe_append(attrs, extra_attrs));
-            return Ok(item);
+            return Some(item);
         }
         if self.eat_keyword(keywords::Type) {
             // TYPE ITEM
@@ -5790,7 +5653,7 @@ impl<'a> Parser<'a> {
                                     item_,
                                     visibility,
                                     maybe_append(attrs, extra_attrs));
-            return Ok(item);
+            return Some(item);
         }
         if self.eat_keyword(keywords::Enum) {
             // ENUM ITEM
@@ -5802,7 +5665,7 @@ impl<'a> Parser<'a> {
                                     item_,
                                     visibility,
                                     maybe_append(attrs, extra_attrs));
-            return Ok(item);
+            return Some(item);
         }
         if self.eat_keyword(keywords::Trait) {
             // TRAIT ITEM
@@ -5815,7 +5678,7 @@ impl<'a> Parser<'a> {
                                     item_,
                                     visibility,
                                     maybe_append(attrs, extra_attrs));
-            return Ok(item);
+            return Some(item);
         }
         if self.eat_keyword(keywords::Impl) {
             // IMPL ITEM
@@ -5827,7 +5690,7 @@ impl<'a> Parser<'a> {
                                     item_,
                                     visibility,
                                     maybe_append(attrs, extra_attrs));
-            return Ok(item);
+            return Some(item);
         }
         if self.eat_keyword(keywords::Struct) {
             // STRUCT ITEM
@@ -5839,30 +5702,34 @@ impl<'a> Parser<'a> {
                                     item_,
                                     visibility,
                                     maybe_append(attrs, extra_attrs));
-            return Ok(item);
+            return Some(item);
         }
         self.parse_macro_use_or_failure(attrs,macros_allowed,lo,visibility)
     }
 
-    /// Parse a foreign item; on failure, return `Err(remaining_attrs)`.
-    fn parse_foreign_item(&mut self, attrs: Vec<Attribute>)
-                          -> Result<P<ForeignItem>, Vec<Attribute>> {
+    /// Parse a foreign item.
+    fn parse_foreign_item(&mut self) -> Option<P<ForeignItem>> {
         let lo = self.span.lo;
 
+        let attrs = self.parse_outer_attributes();
         let visibility = self.parse_visibility();
 
         if self.check_keyword(keywords::Static) {
             // FOREIGN STATIC ITEM
-            return Ok(self.parse_item_foreign_static(visibility, attrs));
+            return Some(self.parse_item_foreign_static(visibility, attrs));
         }
         if self.check_keyword(keywords::Fn) || self.check_keyword(keywords::Unsafe) {
             // FOREIGN FUNCTION ITEM
-            return Ok(self.parse_item_foreign_fn(visibility, attrs));
+            return Some(self.parse_item_foreign_fn(visibility, attrs));
         }
 
         // FIXME #5668: this will occur for a macro invocation:
-        let item = try!(self.parse_macro_use_or_failure(attrs, true, lo, visibility));
-        self.span_fatal(item.span, "macros cannot expand to foreign items");
+        match self.parse_macro_use_or_failure(attrs, true, lo, visibility) {
+            Some(item) => {
+                self.span_fatal(item.span, "macros cannot expand to foreign items");
+            }
+            None => None
+        }
     }
 
     /// This is the fall-through for parsing items.
@@ -5872,7 +5739,7 @@ impl<'a> Parser<'a> {
         macros_allowed: bool,
         lo: BytePos,
         visibility: Visibility
-    ) -> MaybeItem {
+    ) -> Option<P<Item>> {
         if macros_allowed && !self.token.is_any_keyword()
                 && self.look_ahead(1, |t| *t == token::Not)
                 && (self.look_ahead(2, |t| t.is_plain_ident())
@@ -5924,7 +5791,7 @@ impl<'a> Parser<'a> {
                                     item_,
                                     visibility,
                                     attrs);
-            return Ok(item);
+            return Some(item);
         }
 
         // FAILURE TO PARSE ITEM
@@ -5935,16 +5802,22 @@ impl<'a> Parser<'a> {
                 self.span_fatal(last_span, "unmatched visibility `pub`");
             }
         }
-        Err(attrs)
+
+        if !attrs.is_empty() {
+            self.expected_item_err(&attrs);
+        }
+        None
     }
 
+    // HACK(eddyb) staging required for `quote_item!`.
+    #[cfg(stage0)] // SNAP 270a677
     pub fn parse_item_with_outer_attributes(&mut self) -> Option<P<Item>> {
-        let attrs = self.parse_outer_attributes();
-        self.parse_item(attrs)
+        self.parse_item()
     }
 
-    pub fn parse_item(&mut self, attrs: Vec<Attribute>) -> Option<P<Item>> {
-        self.parse_item_(attrs, true).ok()
+    pub fn parse_item(&mut self) -> Option<P<Item>> {
+        let attrs = self.parse_outer_attributes();
+        self.parse_item_(attrs, true)
     }
 
     /// Matches view_path : MOD? non_global_path as IDENT
@@ -6050,52 +5923,13 @@ impl<'a> Parser<'a> {
         P(spanned(lo, self.last_span.hi, ViewPathSimple(rename_to, path)))
     }
 
-    /// Parses a sequence of foreign items. Stops when it finds program
-    /// text that can't be parsed as an item
-    fn parse_foreign_items(&mut self, first_item_attrs: Vec<Attribute>)
-                           -> Vec<P<ForeignItem>> {
-        let mut attrs = first_item_attrs;
-        attrs.push_all(&self.parse_outer_attributes());
-        let mut foreign_items = Vec::new();
-        loop {
-            match self.parse_foreign_item(attrs) {
-                Ok(foreign_item) => {
-                    foreign_items.push(foreign_item);
-                }
-                Err(returned_attrs) => {
-                    if self.check(&token::CloseDelim(token::Brace)) {
-                        attrs = returned_attrs;
-                        break
-                    }
-                    self.unexpected();
-                }
-            }
-            attrs = self.parse_outer_attributes();
-        }
-
-        if !attrs.is_empty() {
-            let last_span = self.last_span;
-            self.span_err(last_span,
-                          Parser::expected_item_err(&attrs[..]));
-        }
-
-        foreign_items
-    }
-
     /// Parses a source module as a crate. This is the main
     /// entry point for the parser.
     pub fn parse_crate_mod(&mut self) -> Crate {
         let lo = self.span.lo;
-        // parse the crate's inner attrs, maybe (oops) one
-        // of the attrs of an item:
-        let (inner, next) = self.parse_inner_attrs_and_next();
-        let first_item_outer_attrs = next;
-        // parse the items inside the crate:
-        let m = self.parse_mod_items(token::Eof, first_item_outer_attrs, lo);
-
         ast::Crate {
-            module: m,
-            attrs: inner,
+            attrs: self.parse_inner_attributes(),
+            module: self.parse_mod_items(&token::Eof, lo),
             config: self.cfg.clone(),
             span: mk_sp(lo, self.span.lo),
             exported_macros: Vec::new(),
diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs
index 5e858d8a79f..2a47a696b1c 100644
--- a/src/libsyntax/test.rs
+++ b/src/libsyntax/test.rs
@@ -121,13 +121,11 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> {
         debug!("current path: {}",
                ast_util::path_name_i(&self.cx.path));
 
-        if is_test_fn(&self.cx, &*i) || is_bench_fn(&self.cx, &*i) {
+        let i = if is_test_fn(&self.cx, &*i) || is_bench_fn(&self.cx, &*i) {
             match i.node {
                 ast::ItemFn(_, ast::Unsafety::Unsafe, _, _, _) => {
                     let diag = self.cx.span_diagnostic;
-                    diag.span_fatal(i.span,
-                                    "unsafe functions cannot be used for \
-                                     tests");
+                    diag.span_fatal(i.span, "unsafe functions cannot be used for tests");
                 }
                 _ => {
                     debug!("this is a test function");
@@ -142,9 +140,19 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> {
                     self.tests.push(i.ident);
                     // debug!("have {} test/bench functions",
                     //        cx.testfns.len());
+
+                    // Make all tests public so we can call them from outside
+                    // the module (note that the tests are re-exported and must
+                    // be made public themselves to avoid privacy errors).
+                    i.map(|mut i| {
+                        i.vis = ast::Public;
+                        i
+                    })
                 }
             }
-        }
+        } else {
+            i
+        };
 
         // We don't want to recurse into anything other than mods, since
         // mods or tests inside of functions will break things
diff --git a/src/libsyntax/util/parser_testing.rs b/src/libsyntax/util/parser_testing.rs
index 89854f5d979..9b570c2b1fe 100644
--- a/src/libsyntax/util/parser_testing.rs
+++ b/src/libsyntax/util/parser_testing.rs
@@ -58,14 +58,14 @@ pub fn string_to_expr (source_str : String) -> P<ast::Expr> {
 /// Parse a string, return an item
 pub fn string_to_item (source_str : String) -> Option<P<ast::Item>> {
     with_error_checking_parse(source_str, |p| {
-        p.parse_item(Vec::new())
+        p.parse_item()
     })
 }
 
 /// Parse a string, return a stmt
 pub fn string_to_stmt(source_str : String) -> P<ast::Stmt> {
     with_error_checking_parse(source_str, |p| {
-        p.parse_stmt(Vec::new())
+        p.parse_stmt().unwrap()
     })
 }
 
diff --git a/src/libterm/lib.rs b/src/libterm/lib.rs
index 36225fad221..89960d5d62f 100644
--- a/src/libterm/lib.rs
+++ b/src/libterm/lib.rs
@@ -57,7 +57,6 @@
 #![feature(box_syntax)]
 #![feature(collections)]
 #![feature(int_uint)]
-#![feature(io)]
 #![feature(rustc_private)]
 #![feature(staged_api)]
 #![feature(std_misc)]
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
index 8fe0cd6ebd4..02ddeea46bf 100644
--- a/src/libtest/lib.rs
+++ b/src/libtest/lib.rs
@@ -42,7 +42,6 @@
 #![feature(rustc_private)]
 #![feature(staged_api)]
 #![feature(std_misc)]
-#![feature(io)]
 #![feature(libc)]
 #![feature(set_stdio)]
 
diff --git a/src/libunicode/char.rs b/src/libunicode/char.rs
index bcc2820e381..56bc0389b74 100644
--- a/src/libunicode/char.rs
+++ b/src/libunicode/char.rs
@@ -41,6 +41,7 @@ pub use normalize::{decompose_canonical, decompose_compatible, compose};
 pub use tables::normalization::canonical_combining_class;
 pub use tables::UNICODE_VERSION;
 
+#[cfg(stage0)]
 /// Functionality for manipulating `char`.
 #[stable(feature = "rust1", since = "1.0.0")]
 pub trait CharExt {
@@ -374,6 +375,7 @@ pub trait CharExt {
     fn width(self, is_cjk: bool) -> Option<usize>;
 }
 
+#[cfg(stage0)]
 #[stable(feature = "rust1", since = "1.0.0")]
 impl CharExt for char {
     fn is_digit(self, radix: u32) -> bool { C::is_digit(self, radix) }
@@ -467,3 +469,373 @@ impl Iterator for ToUppercase {
     type Item = char;
     fn next(&mut self) -> Option<char> { self.0.take() }
 }
+
+#[cfg(not(stage0))]
+#[stable(feature = "rust1", since = "1.0.0")]
+#[lang = "char"]
+impl char {
+    /// Checks if a `char` parses as a numeric digit in the given radix.
+    ///
+    /// Compared to `is_numeric()`, this function only recognizes the characters
+    /// `0-9`, `a-z` and `A-Z`.
+    ///
+    /// # Return value
+    ///
+    /// Returns `true` if `c` is a valid digit under `radix`, and `false`
+    /// otherwise.
+    ///
+    /// # Panics
+    ///
+    /// Panics if given a radix > 36.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let c = '1';
+    ///
+    /// assert!(c.is_digit(10));
+    ///
+    /// assert!('f'.is_digit(16));
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn is_digit(self, radix: u32) -> bool { C::is_digit(self, radix) }
+
+    /// Converts a character to the corresponding digit.
+    ///
+    /// # Return value
+    ///
+    /// If `c` is between '0' and '9', the corresponding value between 0 and
+    /// 9. If `c` is 'a' or 'A', 10. If `c` is 'b' or 'B', 11, etc. Returns
+    /// none if the character does not refer to a digit in the given radix.
+    ///
+    /// # Panics
+    ///
+    /// Panics if given a radix outside the range [0..36].
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let c = '1';
+    ///
+    /// assert_eq!(c.to_digit(10), Some(1));
+    ///
+    /// assert_eq!('f'.to_digit(16), Some(15));
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn to_digit(self, radix: u32) -> Option<u32> { C::to_digit(self, radix) }
+
+    /// Returns an iterator that yields the hexadecimal Unicode escape of a
+    /// character, as `char`s.
+    ///
+    /// All characters are escaped with Rust syntax of the form `\\u{NNNN}`
+    /// where `NNNN` is the shortest hexadecimal representation of the code
+    /// point.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// for i in '❤'.escape_unicode() {
+    ///     println!("{}", i);
+    /// }
+    /// ```
+    ///
+    /// This prints:
+    ///
+    /// ```text
+    /// \
+    /// u
+    /// {
+    /// 2
+    /// 7
+    /// 6
+    /// 4
+    /// }
+    /// ```
+    ///
+    /// Collecting into a `String`:
+    ///
+    /// ```
+    /// let heart: String = '❤'.escape_unicode().collect();
+    ///
+    /// assert_eq!(heart, r"\u{2764}");
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn escape_unicode(self) -> EscapeUnicode { C::escape_unicode(self) }
+
+    /// Returns an iterator that yields the 'default' ASCII and
+    /// C++11-like literal escape of a character, as `char`s.
+    ///
+    /// The default is chosen with a bias toward producing literals that are
+    /// legal in a variety of languages, including C++11 and similar C-family
+    /// languages. The exact rules are:
+    ///
+    /// * Tab, CR and LF are escaped as '\t', '\r' and '\n' respectively.
+    /// * Single-quote, double-quote and backslash chars are backslash-
+    ///   escaped.
+    /// * Any other chars in the range [0x20,0x7e] are not escaped.
+    /// * Any other chars are given hex Unicode escapes; see `escape_unicode`.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// for i in '"'.escape_default() {
+    ///     println!("{}", i);
+    /// }
+    /// ```
+    ///
+    /// This prints:
+    ///
+    /// ```text
+    /// \
+    /// "
+    /// ```
+    ///
+    /// Collecting into a `String`:
+    ///
+    /// ```
+    /// let quote: String = '"'.escape_default().collect();
+    ///
+    /// assert_eq!(quote, "\\\"");
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn escape_default(self) -> EscapeDefault { C::escape_default(self) }
+
+    /// Returns the number of bytes this character would need if encoded in
+    /// UTF-8.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let n = 'ß'.len_utf8();
+    ///
+    /// assert_eq!(n, 2);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn len_utf8(self) -> usize { C::len_utf8(self) }
+
+    /// Returns the number of 16-bit code units this character would need if
+    /// encoded in UTF-16.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let n = 'ß'.len_utf16();
+    ///
+    /// assert_eq!(n, 1);
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn len_utf16(self) -> usize { C::len_utf16(self) }
+
+    /// Encodes this character as UTF-8 into the provided byte buffer, and then
+    /// returns the number of bytes written.
+    ///
+    /// If the buffer is not large enough, nothing will be written into it and a
+    /// `None` will be returned. A buffer of length four is large enough to
+    /// encode any `char`.
+    ///
+    /// # Examples
+    ///
+    /// In both of these examples, 'ß' takes two bytes to encode.
+    ///
+    /// ```
+    /// let mut b = [0; 2];
+    ///
+    /// let result = 'ß'.encode_utf8(&mut b);
+    ///
+    /// assert_eq!(result, Some(2));
+    /// ```
+    ///
+    /// A buffer that's too small:
+    ///
+    /// ```
+    /// let mut b = [0; 1];
+    ///
+    /// let result = 'ß'.encode_utf8(&mut b);
+    ///
+    /// assert_eq!(result, None);
+    /// ```
+    #[unstable(feature = "unicode",
+               reason = "pending decision about Iterator/Writer/Reader")]
+    pub fn encode_utf8(self, dst: &mut [u8]) -> Option<usize> { C::encode_utf8(self, dst) }
+
+    /// Encodes this character as UTF-16 into the provided `u16` buffer, and
+    /// then returns the number of `u16`s written.
+    ///
+    /// If the buffer is not large enough, nothing will be written into it and a
+    /// `None` will be returned. A buffer of length 2 is large enough to encode
+    /// any `char`.
+    ///
+    /// # Examples
+    ///
+    /// In both of these examples, 'ß' takes one `u16` to encode.
+    ///
+    /// ```
+    /// let mut b = [0; 1];
+    ///
+    /// let result = 'ß'.encode_utf16(&mut b);
+    ///
+    /// assert_eq!(result, Some(1));
+    /// ```
+    ///
+    /// A buffer that's too small:
+    ///
+    /// ```
+    /// let mut b = [0; 0];
+    ///
+    /// let result = 'ß'.encode_utf8(&mut b);
+    ///
+    /// assert_eq!(result, None);
+    /// ```
+    #[unstable(feature = "unicode",
+               reason = "pending decision about Iterator/Writer/Reader")]
+    pub fn encode_utf16(self, dst: &mut [u16]) -> Option<usize> { C::encode_utf16(self, dst) }
+
+    /// Returns whether the specified character is considered a Unicode
+    /// alphabetic code point.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn is_alphabetic(self) -> bool {
+        match self {
+            'a' ... 'z' | 'A' ... 'Z' => true,
+            c if c > '\x7f' => derived_property::Alphabetic(c),
+            _ => false
+        }
+    }
+
+    /// Returns whether the specified character satisfies the 'XID_Start'
+    /// Unicode property.
+    ///
+    /// 'XID_Start' is a Unicode Derived Property specified in
+    /// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
+    /// mostly similar to ID_Start but modified for closure under NFKx.
+    #[unstable(feature = "unicode",
+               reason = "mainly needed for compiler internals")]
+    pub fn is_xid_start(self) -> bool { derived_property::XID_Start(self) }
+
+    /// Returns whether the specified `char` satisfies the 'XID_Continue'
+    /// Unicode property.
+    ///
+    /// 'XID_Continue' is a Unicode Derived Property specified in
+    /// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
+    /// mostly similar to 'ID_Continue' but modified for closure under NFKx.
+    #[unstable(feature = "unicode",
+               reason = "mainly needed for compiler internals")]
+    pub fn is_xid_continue(self) -> bool { derived_property::XID_Continue(self) }
+
+    /// Indicates whether a character is in lowercase.
+    ///
+    /// This is defined according to the terms of the Unicode Derived Core
+    /// Property `Lowercase`.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn is_lowercase(self) -> bool {
+        match self {
+            'a' ... 'z' => true,
+            c if c > '\x7f' => derived_property::Lowercase(c),
+            _ => false
+        }
+    }
+
+    /// Indicates whether a character is in uppercase.
+    ///
+    /// This is defined according to the terms of the Unicode Derived Core
+    /// Property `Uppercase`.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn is_uppercase(self) -> bool {
+        match self {
+            'A' ... 'Z' => true,
+            c if c > '\x7f' => derived_property::Uppercase(c),
+            _ => false
+        }
+    }
+
+    /// Indicates whether a character is whitespace.
+    ///
+    /// Whitespace is defined in terms of the Unicode Property `White_Space`.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn is_whitespace(self) -> bool {
+        match self {
+            ' ' | '\x09' ... '\x0d' => true,
+            c if c > '\x7f' => property::White_Space(c),
+            _ => false
+        }
+    }
+
+    /// Indicates whether a character is alphanumeric.
+    ///
+    /// Alphanumericness is defined in terms of the Unicode General Categories
+    /// 'Nd', 'Nl', 'No' and the Derived Core Property 'Alphabetic'.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn is_alphanumeric(self) -> bool {
+        self.is_alphabetic() || self.is_numeric()
+    }
+
+    /// Indicates whether a character is a control code point.
+    ///
+    /// Control code points are defined in terms of the Unicode General
+    /// Category `Cc`.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn is_control(self) -> bool { general_category::Cc(self) }
+
+    /// Indicates whether the character is numeric (Nd, Nl, or No).
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn is_numeric(self) -> bool {
+        match self {
+            '0' ... '9' => true,
+            c if c > '\x7f' => general_category::N(c),
+            _ => false
+        }
+    }
+
+    /// Converts a character to its lowercase equivalent.
+    ///
+    /// The case-folding performed is the common or simple mapping. See
+    /// `to_uppercase()` for references and more information.
+    ///
+    /// # Return value
+    ///
+    /// Returns an iterator which yields the characters corresponding to the
+    /// lowercase equivalent of the character. If no conversion is possible then
+    /// the input character is returned.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn to_lowercase(self) -> ToLowercase {
+        ToLowercase(Some(conversions::to_lower(self)))
+    }
+
+    /// Converts a character to its uppercase equivalent.
+    ///
+    /// The case-folding performed is the common or simple mapping: it maps
+    /// one Unicode codepoint to its uppercase equivalent according to the
+    /// Unicode database [1]. The additional [`SpecialCasing.txt`] is not yet
+    /// considered here, but the iterator returned will soon support this form
+    /// of case folding.
+    ///
+    /// A full reference can be found here [2].
+    ///
+    /// # Return value
+    ///
+    /// Returns an iterator which yields the characters corresponding to the
+    /// uppercase equivalent of the character. If no conversion is possible then
+    /// the input character is returned.
+    ///
+    /// [1]: ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt
+    ///
+    /// [`SpecialCasing`.txt`]: ftp://ftp.unicode.org/Public/UNIDATA/SpecialCasing.txt
+    ///
+    /// [2]: http://www.unicode.org/versions/Unicode4.0.0/ch03.pdf#G33992
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn to_uppercase(self) -> ToUppercase {
+        ToUppercase(Some(conversions::to_upper(self)))
+    }
+
+    /// Returns this character's displayed width in columns, or `None` if it is a
+    /// control character other than `'\x00'`.
+    ///
+    /// `is_cjk` determines behavior for characters in the Ambiguous category:
+    /// if `is_cjk` is `true`, these are 2 columns wide; otherwise, they are 1.
+    /// In CJK contexts, `is_cjk` should be `true`, else it should be `false`.
+    /// [Unicode Standard Annex #11](http://www.unicode.org/reports/tr11/)
+    /// recommends that these characters be treated as 1 column (i.e.,
+    /// `is_cjk` = `false`) if the context cannot be reliably determined.
+    #[unstable(feature = "unicode",
+               reason = "needs expert opinion. is_cjk flag stands out as ugly")]
+    pub fn width(self, is_cjk: bool) -> Option<usize> { charwidth::width(self, is_cjk) }
+}
diff --git a/src/libunicode/lib.rs b/src/libunicode/lib.rs
index fadf91f33bc..a09c0cb3bd6 100644
--- a/src/libunicode/lib.rs
+++ b/src/libunicode/lib.rs
@@ -24,6 +24,7 @@
 #![cfg_attr(stage0, feature(custom_attribute))]
 #![crate_name = "unicode"]
 #![unstable(feature = "unicode")]
+#![feature(lang_items)]
 #![feature(staged_api)]
 #![staged_api]
 #![crate_type = "rlib"]
diff --git a/src/libunicode/u_str.rs b/src/libunicode/u_str.rs
index 050d2adf050..917c2d2dfbe 100644
--- a/src/libunicode/u_str.rs
+++ b/src/libunicode/u_str.rs
@@ -26,6 +26,7 @@ use core::num::Int;
 use core::slice;
 use core::str::Split;
 
+#[cfg(stage0)]
 use char::CharExt as UCharExt; // conflicts with core::prelude::CharExt
 use tables::grapheme::GraphemeCat;
 
@@ -481,7 +482,7 @@ impl<'a> Iterator for Utf16Items<'a> {
 ///
 /// # Examples
 ///
-/// ```rust
+/// ```
 /// use unicode::str::Utf16Item::{ScalarValue, LoneSurrogate};
 ///
 /// // 𝄞mus<invalid>ic<invalid>
diff --git a/src/rt/msvc/typeof.h b/src/rt/msvc/typeof.h
index b83f530b0e9..7de08af314a 100644
--- a/src/rt/msvc/typeof.h
+++ b/src/rt/msvc/typeof.h
@@ -94,4 +94,3 @@ namespace msvc_typeof_impl {
 #endif
 
 #endif
-
diff --git a/src/rt/valgrind/memcheck.h b/src/rt/valgrind/memcheck.h
index 3af0728f017..ee72707d319 100644
--- a/src/rt/valgrind/memcheck.h
+++ b/src/rt/valgrind/memcheck.h
@@ -1,4 +1,3 @@
-
 /*
    ----------------------------------------------------------------
 
@@ -284,4 +283,3 @@ typedef
                                     (zznbytes), 0, 0 )
 
 #endif
-
diff --git a/src/test/auxiliary/changing-crates-a2.rs b/src/test/auxiliary/changing-crates-a2.rs
index a54dcbbbfc2..28eae023d68 100644
--- a/src/test/auxiliary/changing-crates-a2.rs
+++ b/src/test/auxiliary/changing-crates-a2.rs
@@ -11,4 +11,3 @@
 #![crate_name = "a"]
 
 pub fn foo<T>() { println!("hello!"); }
-
diff --git a/src/test/auxiliary/coherence-orphan-lib.rs b/src/test/auxiliary/coherence-orphan-lib.rs
index cc42b288e66..93d8fd3da88 100644
--- a/src/test/auxiliary/coherence-orphan-lib.rs
+++ b/src/test/auxiliary/coherence-orphan-lib.rs
@@ -11,4 +11,3 @@
 pub trait TheTrait<T> : ::std::marker::PhantomFn<T> {
     fn the_fn(&self);
 }
-
diff --git a/src/test/auxiliary/default_type_params_xc.rs b/src/test/auxiliary/default_type_params_xc.rs
index 0a65174911e..fe852e5d8ea 100644
--- a/src/test/auxiliary/default_type_params_xc.rs
+++ b/src/test/auxiliary/default_type_params_xc.rs
@@ -13,4 +13,3 @@ pub struct Heap;
 pub struct FakeHeap;
 
 pub struct FakeVec<T, A = FakeHeap> { pub f: Option<(T,A)> }
-
diff --git a/src/test/auxiliary/iss.rs b/src/test/auxiliary/iss.rs
index 690d5783c4b..b231efa0fec 100644
--- a/src/test/auxiliary/iss.rs
+++ b/src/test/auxiliary/iss.rs
@@ -20,4 +20,3 @@ fn no_op() { }
 pub const D : C<fn()> = C {
     k: no_op as fn()
 };
-
diff --git a/src/test/auxiliary/issue-12133-dylib2.rs b/src/test/auxiliary/issue-12133-dylib2.rs
index ee2b11da8f0..cf1953005ba 100644
--- a/src/test/auxiliary/issue-12133-dylib2.rs
+++ b/src/test/auxiliary/issue-12133-dylib2.rs
@@ -14,4 +14,3 @@
 
 extern crate "issue-12133-rlib" as a;
 extern crate "issue-12133-dylib" as b;
-
diff --git a/src/test/auxiliary/issue-13560-3.rs b/src/test/auxiliary/issue-13560-3.rs
index 5510d3e2e0d..f1f16af6f0e 100644
--- a/src/test/auxiliary/issue-13560-3.rs
+++ b/src/test/auxiliary/issue-13560-3.rs
@@ -14,4 +14,3 @@
 
 #[macro_use] #[no_link] extern crate "issue-13560-1" as t1;
 #[macro_use] extern crate "issue-13560-2" as t2;
-
diff --git a/src/test/auxiliary/issue-16725.rs b/src/test/auxiliary/issue-16725.rs
index 7f388c13e15..b3b04b4a5ac 100644
--- a/src/test/auxiliary/issue-16725.rs
+++ b/src/test/auxiliary/issue-16725.rs
@@ -11,4 +11,3 @@
 extern {
     fn bar();
 }
-
diff --git a/src/test/auxiliary/issue-5521.rs b/src/test/auxiliary/issue-5521.rs
index d9d393cc749..2ffdddcc798 100644
--- a/src/test/auxiliary/issue-5521.rs
+++ b/src/test/auxiliary/issue-5521.rs
@@ -12,4 +12,3 @@
 use std::collections::HashMap;
 
 pub type map = Box<HashMap<uint, uint>>;
-
diff --git a/src/test/auxiliary/issue13213aux.rs b/src/test/auxiliary/issue13213aux.rs
index 227fab73048..c2acc514346 100644
--- a/src/test/auxiliary/issue13213aux.rs
+++ b/src/test/auxiliary/issue13213aux.rs
@@ -27,4 +27,3 @@ mod private {
 }
 
 pub static A: S = S { p: private::THREE };
-
diff --git a/src/test/auxiliary/issue_3907.rs b/src/test/auxiliary/issue_3907.rs
index 545e15fe166..c118f7e4854 100644
--- a/src/test/auxiliary/issue_3907.rs
+++ b/src/test/auxiliary/issue_3907.rs
@@ -13,4 +13,3 @@ use std::marker::MarkerTrait;
 pub trait Foo : MarkerTrait {
     fn bar();
 }
-
diff --git a/src/test/auxiliary/issue_5844_aux.rs b/src/test/auxiliary/issue_5844_aux.rs
index 0f898ae8385..e12af579c57 100644
--- a/src/test/auxiliary/issue_5844_aux.rs
+++ b/src/test/auxiliary/issue_5844_aux.rs
@@ -13,4 +13,3 @@ extern crate libc;
 extern "C" {
     pub fn rand() -> libc::c_int;
 }
-
diff --git a/src/test/auxiliary/issue_8401.rs b/src/test/auxiliary/issue_8401.rs
index 9006a5d1775..04b56442d0b 100644
--- a/src/test/auxiliary/issue_8401.rs
+++ b/src/test/auxiliary/issue_8401.rs
@@ -24,4 +24,3 @@ fn foo<T>(t: &T) {
     let b = B;
     bar(unsafe { mem::transmute(&b as &A) }, t)
 }
-
diff --git a/src/test/auxiliary/issue_9123.rs b/src/test/auxiliary/issue_9123.rs
index 4f2792aebcd..8c2546e76cf 100644
--- a/src/test/auxiliary/issue_9123.rs
+++ b/src/test/auxiliary/issue_9123.rs
@@ -17,4 +17,3 @@ pub trait X {
     }
     fn dummy(&self) { }
 }
-
diff --git a/src/test/auxiliary/issue_9188.rs b/src/test/auxiliary/issue_9188.rs
index 5f5a8f02fd9..d17e4afb5e8 100644
--- a/src/test/auxiliary/issue_9188.rs
+++ b/src/test/auxiliary/issue_9188.rs
@@ -21,4 +21,3 @@ pub fn foo<T>() -> &'static int {
 pub fn bar() -> &'static int {
     foo::<int>()
 }
-
diff --git a/src/test/auxiliary/kinds_in_metadata.rs b/src/test/auxiliary/kinds_in_metadata.rs
index 7e090523984..82f182c04bd 100644
--- a/src/test/auxiliary/kinds_in_metadata.rs
+++ b/src/test/auxiliary/kinds_in_metadata.rs
@@ -16,4 +16,3 @@
 #![crate_type="lib"]
 
 pub fn f<T:Copy>() {}
-
diff --git a/src/test/auxiliary/lang-item-public.rs b/src/test/auxiliary/lang-item-public.rs
index b9cc20b63cc..c5d4182eae6 100644
--- a/src/test/auxiliary/lang-item-public.rs
+++ b/src/test/auxiliary/lang-item-public.rs
@@ -32,5 +32,3 @@ extern fn eh_personality() {}
 pub trait Copy : PhantomFn<Self> {
     // Empty.
 }
-
-
diff --git a/src/test/auxiliary/namespaced_enums.rs b/src/test/auxiliary/namespaced_enums.rs
index 5b21d130d17..3c0138a7077 100644
--- a/src/test/auxiliary/namespaced_enums.rs
+++ b/src/test/auxiliary/namespaced_enums.rs
@@ -18,4 +18,3 @@ impl Foo {
     pub fn foo() {}
     pub fn bar(&self) {}
 }
-
diff --git a/src/test/auxiliary/plugin_crate_outlive_expansion_phase.rs b/src/test/auxiliary/plugin_crate_outlive_expansion_phase.rs
index c460c60b02b..420151c471e 100644
--- a/src/test/auxiliary/plugin_crate_outlive_expansion_phase.rs
+++ b/src/test/auxiliary/plugin_crate_outlive_expansion_phase.rs
@@ -32,4 +32,3 @@ pub fn registrar(_: &mut Registry) {
     thread_local!(static FOO: RefCell<Option<Box<Any+Send>>> = RefCell::new(None));
     FOO.with(|s| *s.borrow_mut() = Some(box Foo { foo: 10 } as Box<Any+Send>));
 }
-
diff --git a/src/test/auxiliary/privacy_reexport.rs b/src/test/auxiliary/privacy_reexport.rs
index 266903169c7..e60dbb290b0 100644
--- a/src/test/auxiliary/privacy_reexport.rs
+++ b/src/test/auxiliary/privacy_reexport.rs
@@ -10,6 +10,6 @@
 
 pub use foo as bar;
 
-mod foo {
+pub mod foo {
     pub fn frob() {}
 }
diff --git a/src/test/auxiliary/pub_static_array.rs b/src/test/auxiliary/pub_static_array.rs
new file mode 100644
index 00000000000..4419a5ae83c
--- /dev/null
+++ b/src/test/auxiliary/pub_static_array.rs
@@ -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.
+
+pub static ARRAY: &'static [u8] = &[1];
diff --git a/src/test/auxiliary/struct_variant_privacy.rs b/src/test/auxiliary/struct_variant_privacy.rs
index 0bdda235080..8d9b304aa51 100644
--- a/src/test/auxiliary/struct_variant_privacy.rs
+++ b/src/test/auxiliary/struct_variant_privacy.rs
@@ -11,4 +11,3 @@
 enum Bar {
     Baz { a: int }
 }
-
diff --git a/src/test/auxiliary/trait_bounds_on_structs_and_enums_xc.rs b/src/test/auxiliary/trait_bounds_on_structs_and_enums_xc.rs
index a7c469fccaa..beee83f9f7c 100644
--- a/src/test/auxiliary/trait_bounds_on_structs_and_enums_xc.rs
+++ b/src/test/auxiliary/trait_bounds_on_structs_and_enums_xc.rs
@@ -21,4 +21,3 @@ pub enum Bar<T:Trait> {
     BBar(T),
     CBar(uint),
 }
-
diff --git a/src/test/auxiliary/weak-lang-items.rs b/src/test/auxiliary/weak-lang-items.rs
index fa254cb91ad..85f49b4bb7f 100644
--- a/src/test/auxiliary/weak-lang-items.rs
+++ b/src/test/auxiliary/weak-lang-items.rs
@@ -34,4 +34,3 @@ pub fn foo() {
 mod std {
     pub use core::{option, fmt};
 }
-
diff --git a/src/test/auxiliary/where_clauses_xc.rs b/src/test/auxiliary/where_clauses_xc.rs
index 002b31f099f..4549bd719c6 100644
--- a/src/test/auxiliary/where_clauses_xc.rs
+++ b/src/test/auxiliary/where_clauses_xc.rs
@@ -27,4 +27,3 @@ impl<T> Equal for T where T: Eq {
 pub fn equal<T>(x: &T, y: &T) -> bool where T: Eq {
     x == y
 }
-
diff --git a/src/test/auxiliary/xcrate_struct_aliases.rs b/src/test/auxiliary/xcrate_struct_aliases.rs
index a0ec7272720..5556ee6971c 100644
--- a/src/test/auxiliary/xcrate_struct_aliases.rs
+++ b/src/test/auxiliary/xcrate_struct_aliases.rs
@@ -14,4 +14,3 @@ pub struct S {
 }
 
 pub type S2 = S;
-
diff --git a/src/test/auxiliary/xcrate_unit_struct.rs b/src/test/auxiliary/xcrate_unit_struct.rs
index 7ae36554079..538abf00a67 100644
--- a/src/test/auxiliary/xcrate_unit_struct.rs
+++ b/src/test/auxiliary/xcrate_unit_struct.rs
@@ -36,4 +36,3 @@ pub enum EnumWithVariants {
     EnumVariant,
     EnumVariantArg(int)
 }
-
diff --git a/src/test/compile-fail/associated-types-coherence-failure.rs b/src/test/compile-fail/associated-types-coherence-failure.rs
index b7a16c68a34..915cb077787 100644
--- a/src/test/compile-fail/associated-types-coherence-failure.rs
+++ b/src/test/compile-fail/associated-types-coherence-failure.rs
@@ -57,4 +57,3 @@ pub trait ToOwned {
 
 
 fn main() {}
-
diff --git a/src/test/compile-fail/associated-types-eq-expr-path.rs b/src/test/compile-fail/associated-types-eq-expr-path.rs
index c48f9972ebc..0d68b960f31 100644
--- a/src/test/compile-fail/associated-types-eq-expr-path.rs
+++ b/src/test/compile-fail/associated-types-eq-expr-path.rs
@@ -22,5 +22,5 @@ impl Foo for isize {
 
 pub fn main() {
     let x: isize = Foo::<A=usize>::bar();
-    //~^ERROR unexpected binding of associated item in expression path
+    //~^ ERROR unexpected binding of associated item in expression path
 }
diff --git a/src/test/compile-fail/associated-types-issue-17359.rs b/src/test/compile-fail/associated-types-issue-17359.rs
index 625f4cdb8ef..5c36e3356a5 100644
--- a/src/test/compile-fail/associated-types-issue-17359.rs
+++ b/src/test/compile-fail/associated-types-issue-17359.rs
@@ -18,4 +18,3 @@ trait Trait : ::std::marker::MarkerTrait {
 impl Trait for isize {}  //~ ERROR missing: `Type`
 
 fn main() {}
-
diff --git a/src/test/compile-fail/bad-crate-id2.rs b/src/test/compile-fail/bad-crate-id2.rs
index 4899252a1a4..6425908672d 100644
--- a/src/test/compile-fail/bad-crate-id2.rs
+++ b/src/test/compile-fail/bad-crate-id2.rs
@@ -11,4 +11,3 @@
 extern crate "#a" as bar; //~ ERROR: invalid character `#` in crate name: `#a`
 
 fn main() {}
-
diff --git a/src/test/compile-fail/borrowck-box-insensitivity.rs b/src/test/compile-fail/borrowck-box-insensitivity.rs
index 59514f75a77..c980e77df6f 100644
--- a/src/test/compile-fail/borrowck-box-insensitivity.rs
+++ b/src/test/compile-fail/borrowck-box-insensitivity.rs
@@ -152,4 +152,3 @@ fn main() {
     borrow_after_mut_borrow_nested();
     mut_borrow_after_borrow_nested();
 }
-
diff --git a/src/test/compile-fail/borrowck-closures-unique-imm.rs b/src/test/compile-fail/borrowck-closures-unique-imm.rs
index dcf43c01e17..247a4fe89a5 100644
--- a/src/test/compile-fail/borrowck-closures-unique-imm.rs
+++ b/src/test/compile-fail/borrowck-closures-unique-imm.rs
@@ -22,4 +22,3 @@ pub fn main() {
     };
     r()
 }
-
diff --git a/src/test/compile-fail/borrowck-field-sensitivity.rs b/src/test/compile-fail/borrowck-field-sensitivity.rs
index fe5142a7734..13fd5fce955 100644
--- a/src/test/compile-fail/borrowck-field-sensitivity.rs
+++ b/src/test/compile-fail/borrowck-field-sensitivity.rs
@@ -124,4 +124,3 @@ fn main() {
     borrow_after_field_assign_after_uninit();
     move_after_field_assign_after_uninit();
 }
-
diff --git a/src/test/compile-fail/borrowck-for-loop-correct-cmt-for-pattern.rs b/src/test/compile-fail/borrowck-for-loop-correct-cmt-for-pattern.rs
index b6b26006555..31ec5aea7f3 100644
--- a/src/test/compile-fail/borrowck-for-loop-correct-cmt-for-pattern.rs
+++ b/src/test/compile-fail/borrowck-for-loop-correct-cmt-for-pattern.rs
@@ -32,4 +32,3 @@ fn main() {
     for &a in x.iter() {    //~ ERROR cannot move out
     }
 }
-
diff --git a/src/test/compile-fail/borrowck-for-loop-head-linkage.rs b/src/test/compile-fail/borrowck-for-loop-head-linkage.rs
index 01a649ae247..b79fc5b2bf6 100644
--- a/src/test/compile-fail/borrowck-for-loop-head-linkage.rs
+++ b/src/test/compile-fail/borrowck-for-loop-head-linkage.rs
@@ -18,4 +18,3 @@ fn main() {
         vector[1] = 5;   //~ ERROR cannot borrow
     }
 }
-
diff --git a/src/test/compile-fail/borrowck-issue-14498.rs b/src/test/compile-fail/borrowck-issue-14498.rs
index deae1fbad20..8278b4fb971 100644
--- a/src/test/compile-fail/borrowck-issue-14498.rs
+++ b/src/test/compile-fail/borrowck-issue-14498.rs
@@ -62,4 +62,3 @@ fn main() {
     borrow_in_field_from_var();
     borrow_in_field_from_field();
 }
-
diff --git a/src/test/compile-fail/borrowck-let-suggestion.rs b/src/test/compile-fail/borrowck-let-suggestion.rs
index 5729f8c5617..d760f3db0c2 100644
--- a/src/test/compile-fail/borrowck-let-suggestion.rs
+++ b/src/test/compile-fail/borrowck-let-suggestion.rs
@@ -17,4 +17,3 @@ fn f() {
 fn main() {
     f();
 }
-
diff --git a/src/test/compile-fail/borrowck-multiple-captures.rs b/src/test/compile-fail/borrowck-multiple-captures.rs
index f417416e7b5..042b914ce41 100644
--- a/src/test/compile-fail/borrowck-multiple-captures.rs
+++ b/src/test/compile-fail/borrowck-multiple-captures.rs
@@ -63,4 +63,3 @@ fn main() {
     same_var_after_borrow();
     same_var_after_move();
 }
-
diff --git a/src/test/compile-fail/borrowck-mutate-in-guard.rs b/src/test/compile-fail/borrowck-mutate-in-guard.rs
index 44353ab5d96..e35edca639e 100644
--- a/src/test/compile-fail/borrowck-mutate-in-guard.rs
+++ b/src/test/compile-fail/borrowck-mutate-in-guard.rs
@@ -30,4 +30,3 @@ fn foo() -> isize {
 fn main() {
     foo();
 }
-
diff --git a/src/test/compile-fail/borrowck-object-lifetime.rs b/src/test/compile-fail/borrowck-object-lifetime.rs
index bbb58e21198..021b3f38e00 100644
--- a/src/test/compile-fail/borrowck-object-lifetime.rs
+++ b/src/test/compile-fail/borrowck-object-lifetime.rs
@@ -37,4 +37,3 @@ fn imm_owned_receiver(mut x: Box<Foo>) {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/borrowck-object-mutability.rs b/src/test/compile-fail/borrowck-object-mutability.rs
index 9b5087bd7e0..1bdc32b0975 100644
--- a/src/test/compile-fail/borrowck-object-mutability.rs
+++ b/src/test/compile-fail/borrowck-object-mutability.rs
@@ -35,4 +35,3 @@ fn mut_owned_receiver(mut x: Box<Foo>) {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/borrowck-overloaded-call.rs b/src/test/compile-fail/borrowck-overloaded-call.rs
index 04d73cc36f0..673c025e863 100644
--- a/src/test/compile-fail/borrowck-overloaded-call.rs
+++ b/src/test/compile-fail/borrowck-overloaded-call.rs
@@ -77,4 +77,3 @@ fn h() {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/borrowck-overloaded-index-and-overloaded-deref.rs b/src/test/compile-fail/borrowck-overloaded-index-and-overloaded-deref.rs
index 4188cf00142..430f2fcc13a 100644
--- a/src/test/compile-fail/borrowck-overloaded-index-and-overloaded-deref.rs
+++ b/src/test/compile-fail/borrowck-overloaded-index-and-overloaded-deref.rs
@@ -44,4 +44,3 @@ fn main() {
 }
 
 fn read(_: usize) { }
-
diff --git a/src/test/compile-fail/borrowck-partial-reinit-2.rs b/src/test/compile-fail/borrowck-partial-reinit-2.rs
index 0926ba6e432..c9cdeff9c7a 100644
--- a/src/test/compile-fail/borrowck-partial-reinit-2.rs
+++ b/src/test/compile-fail/borrowck-partial-reinit-2.rs
@@ -31,4 +31,3 @@ fn main() {
     stuff();
     println!("Hello, world!")
 }
-
diff --git a/src/test/compile-fail/borrowck-unboxed-closures.rs b/src/test/compile-fail/borrowck-unboxed-closures.rs
index 8e7e2e3e777..3eca850e493 100644
--- a/src/test/compile-fail/borrowck-unboxed-closures.rs
+++ b/src/test/compile-fail/borrowck-unboxed-closures.rs
@@ -26,4 +26,3 @@ fn c<F:FnOnce(isize, isize) -> isize>(f: F) {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/borrowck-use-mut-borrow.rs b/src/test/compile-fail/borrowck-use-mut-borrow.rs
index 52f89da10b9..e14df7329ea 100644
--- a/src/test/compile-fail/borrowck-use-mut-borrow.rs
+++ b/src/test/compile-fail/borrowck-use-mut-borrow.rs
@@ -94,4 +94,3 @@ fn main() {
     field_deref_after_var_borrow();
     field_deref_after_field_borrow();
 }
-
diff --git a/src/test/compile-fail/closure-reform-bad.rs b/src/test/compile-fail/closure-reform-bad.rs
index d2295eba6d7..490734d463d 100644
--- a/src/test/compile-fail/closure-reform-bad.rs
+++ b/src/test/compile-fail/closure-reform-bad.rs
@@ -20,4 +20,3 @@ fn main() {
     let f = |s: &str| println!("{}{}", s, string);
     call_bare(f)    //~ ERROR mismatched types
 }
-
diff --git a/src/test/compile-fail/cross-borrow-trait.rs b/src/test/compile-fail/cross-borrow-trait.rs
index 871f52cbebd..d60fb1d5d19 100644
--- a/src/test/compile-fail/cross-borrow-trait.rs
+++ b/src/test/compile-fail/cross-borrow-trait.rs
@@ -24,4 +24,3 @@ pub fn main() {
                         //~| expected &-ptr
                         //~| found box
 }
-
diff --git a/src/test/compile-fail/drop-with-active-borrows-1.rs b/src/test/compile-fail/drop-with-active-borrows-1.rs
index dc8deb04833..903365fb909 100644
--- a/src/test/compile-fail/drop-with-active-borrows-1.rs
+++ b/src/test/compile-fail/drop-with-active-borrows-1.rs
@@ -16,4 +16,3 @@ fn main() {
         println!("{}", *s);
     }
 }
-
diff --git a/src/test/compile-fail/duplicate-parameter.rs b/src/test/compile-fail/duplicate-parameter.rs
index 18ec55e10bb..7586bc61cd6 100644
--- a/src/test/compile-fail/duplicate-parameter.rs
+++ b/src/test/compile-fail/duplicate-parameter.rs
@@ -13,4 +13,3 @@ fn f(a: isize, a: isize) {}
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/duplicate-type-parameter.rs b/src/test/compile-fail/duplicate-type-parameter.rs
index d535ce4a69a..42b67337c64 100644
--- a/src/test/compile-fail/duplicate-type-parameter.rs
+++ b/src/test/compile-fail/duplicate-type-parameter.rs
@@ -36,4 +36,3 @@ impl<T,T> Qux<T,T> for Option<T> {}
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/explicit-self-lifetime-mismatch.rs b/src/test/compile-fail/explicit-self-lifetime-mismatch.rs
index 92542ab3bcb..922e58698dd 100644
--- a/src/test/compile-fail/explicit-self-lifetime-mismatch.rs
+++ b/src/test/compile-fail/explicit-self-lifetime-mismatch.rs
@@ -26,4 +26,3 @@ impl<'a,'b> Foo<'a,'b> {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/extern-with-type-bounds.rs b/src/test/compile-fail/extern-with-type-bounds.rs
index 21334e1d513..2553bdcbb27 100644
--- a/src/test/compile-fail/extern-with-type-bounds.rs
+++ b/src/test/compile-fail/extern-with-type-bounds.rs
@@ -28,4 +28,3 @@ extern "rust-intrinsic" {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/feature-gate-advanced-slice-features.rs b/src/test/compile-fail/feature-gate-advanced-slice-features.rs
index d5841e1e77e..a4524ccd9db 100644
--- a/src/test/compile-fail/feature-gate-advanced-slice-features.rs
+++ b/src/test/compile-fail/feature-gate-advanced-slice-features.rs
@@ -16,4 +16,3 @@ fn main() {
         [ 1, 2, xs.. ] => {}    // OK without feature gate
     }
 }
-
diff --git a/src/test/compile-fail/feature-gate-box-expr.rs b/src/test/compile-fail/feature-gate-box-expr.rs
index 39f54be4561..8f8b035f4a9 100644
--- a/src/test/compile-fail/feature-gate-box-expr.rs
+++ b/src/test/compile-fail/feature-gate-box-expr.rs
@@ -20,4 +20,3 @@ fn main() {
     let x = box (HEAP) 'c'; //~ ERROR box expression syntax is experimental
     println!("x: {}", x);
 }
-
diff --git a/src/test/compile-fail/feature-gate-start.rs b/src/test/compile-fail/feature-gate-start.rs
index 6a9acf04290..7a0924d8adf 100644
--- a/src/test/compile-fail/feature-gate-start.rs
+++ b/src/test/compile-fail/feature-gate-start.rs
@@ -10,4 +10,3 @@
 
 #[start]
 fn foo() {} //~ ERROR: a #[start] function is an experimental feature
-
diff --git a/src/test/compile-fail/generic-no-mangle.rs b/src/test/compile-fail/generic-no-mangle.rs
index f4ead18ee16..4163d531e87 100644
--- a/src/test/compile-fail/generic-no-mangle.rs
+++ b/src/test/compile-fail/generic-no-mangle.rs
@@ -15,4 +15,3 @@ fn foo<T>() {} //~ ERROR generic functions must be mangled
 
 #[no_mangle]
 extern fn foo<T>() {} //~ ERROR generic functions must be mangled
-
diff --git a/src/test/compile-fail/indexing-requires-a-uint.rs b/src/test/compile-fail/indexing-requires-a-uint.rs
index 901d8783d02..3ca00fcb66a 100644
--- a/src/test/compile-fail/indexing-requires-a-uint.rs
+++ b/src/test/compile-fail/indexing-requires-a-uint.rs
@@ -23,4 +23,3 @@ fn main() {
     bar::<isize>(i);  // i should not be re-coerced back to an isize
     //~^ ERROR: mismatched types
 }
-
diff --git a/src/test/compile-fail/infinite-macro-expansion.rs b/src/test/compile-fail/infinite-macro-expansion.rs
index 74835f4bf22..14d22702db7 100644
--- a/src/test/compile-fail/infinite-macro-expansion.rs
+++ b/src/test/compile-fail/infinite-macro-expansion.rs
@@ -15,4 +15,3 @@ macro_rules! recursive {
 fn main() {
     recursive!()
 }
-
diff --git a/src/test/compile-fail/integral-indexing.rs b/src/test/compile-fail/integral-indexing.rs
index e8998dd7a9d..e2fb0fa4f2f 100644
--- a/src/test/compile-fail/integral-indexing.rs
+++ b/src/test/compile-fail/integral-indexing.rs
@@ -24,11 +24,11 @@ pub fn main() {
     s.as_bytes()[3_usize];
     s.as_bytes()[3];
     s.as_bytes()[3u8];  //~ERROR the trait `core::ops::Index<u8>` is not implemented
-    //~^ERROR the trait `core::ops::Index<u8>` is not implemented
+    //~^ ERROR the trait `core::ops::Index<u8>` is not implemented
     s.as_bytes()[3i8];  //~ERROR the trait `core::ops::Index<i8>` is not implemented
-    //~^ERROR the trait `core::ops::Index<i8>` is not implemented
+    //~^ ERROR the trait `core::ops::Index<i8>` is not implemented
     s.as_bytes()[3u32]; //~ERROR the trait `core::ops::Index<u32>` is not implemented
-    //~^ERROR the trait `core::ops::Index<u32>` is not implemented
+    //~^ ERROR the trait `core::ops::Index<u32>` is not implemented
     s.as_bytes()[3i32]; //~ERROR the trait `core::ops::Index<i32>` is not implemented
-    //~^ERROR the trait `core::ops::Index<i32>` is not implemented
+    //~^ ERROR the trait `core::ops::Index<i32>` is not implemented
 }
diff --git a/src/test/compile-fail/intrinsic-return-address.rs b/src/test/compile-fail/intrinsic-return-address.rs
index a80d3931555..b83f0f73436 100644
--- a/src/test/compile-fail/intrinsic-return-address.rs
+++ b/src/test/compile-fail/intrinsic-return-address.rs
@@ -27,5 +27,3 @@ unsafe fn g() -> isize {
 }
 
 fn main() {}
-
-
diff --git a/src/test/compile-fail/issue-10536.rs b/src/test/compile-fail/issue-10536.rs
index 370a6228db6..3b0ea55cfa9 100644
--- a/src/test/compile-fail/issue-10536.rs
+++ b/src/test/compile-fail/issue-10536.rs
@@ -29,4 +29,3 @@ pub fn main() {
     // least throw a conventional error.
     assert!({one! two});
 }
-
diff --git a/src/test/compile-fail/issue-11192.rs b/src/test/compile-fail/issue-11192.rs
index 7313d357ffc..7d8a1528aba 100644
--- a/src/test/compile-fail/issue-11192.rs
+++ b/src/test/compile-fail/issue-11192.rs
@@ -30,4 +30,3 @@ fn main() {
     test(&*ptr);
     //~^ ERROR: cannot borrow `*ptr` as immutable
 }
-
diff --git a/src/test/compile-fail/issue-11593.rs b/src/test/compile-fail/issue-11593.rs
index ecc584d81b0..2749438433d 100644
--- a/src/test/compile-fail/issue-11593.rs
+++ b/src/test/compile-fail/issue-11593.rs
@@ -18,4 +18,3 @@ impl private_trait_xc::Foo for Bar {}
 //~^ ERROR: trait `Foo` is private
 
 fn main() {}
-
diff --git a/src/test/compile-fail/issue-11844.rs b/src/test/compile-fail/issue-11844.rs
index 560cbe1b8a8..a6dbe954ec0 100644
--- a/src/test/compile-fail/issue-11844.rs
+++ b/src/test/compile-fail/issue-11844.rs
@@ -18,4 +18,3 @@ fn main() {
         None => panic!()
     }
 }
-
diff --git a/src/test/compile-fail/issue-12041.rs b/src/test/compile-fail/issue-12041.rs
index 735f529277c..f0f4bf5ca71 100644
--- a/src/test/compile-fail/issue-12041.rs
+++ b/src/test/compile-fail/issue-12041.rs
@@ -21,4 +21,3 @@ fn main() {
         }
     });
 }
-
diff --git a/src/test/compile-fail/issue-12612.rs b/src/test/compile-fail/issue-12612.rs
index 0550472dabb..41cd3863001 100644
--- a/src/test/compile-fail/issue-12612.rs
+++ b/src/test/compile-fail/issue-12612.rs
@@ -20,4 +20,3 @@ mod test {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/issue-13407.rs b/src/test/compile-fail/issue-13407.rs
new file mode 100644
index 00000000000..f845eba4060
--- /dev/null
+++ b/src/test/compile-fail/issue-13407.rs
@@ -0,0 +1,19 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+mod A {
+    struct C;
+}
+
+fn main() {
+    A::C = 1;
+    //~^ ERROR: illegal left-hand side expression
+    //~| ERROR: mismatched types
+}
diff --git a/src/test/compile-fail/issue-13446.rs b/src/test/compile-fail/issue-13446.rs
index a0a7660428d..53d14862889 100644
--- a/src/test/compile-fail/issue-13446.rs
+++ b/src/test/compile-fail/issue-13446.rs
@@ -16,4 +16,3 @@
 static VEC: [u32; 256] = vec!();
 
 fn main() {}
-
diff --git a/src/test/compile-fail/issue-14092.rs b/src/test/compile-fail/issue-14092.rs
index 0ab37a88826..c87dcb8ae79 100644
--- a/src/test/compile-fail/issue-14092.rs
+++ b/src/test/compile-fail/issue-14092.rs
@@ -11,4 +11,3 @@
 fn fn1(0: Box) {} //~ ERROR: wrong number of type arguments: expected 1, found 0
 
 fn main() {}
-
diff --git a/src/test/compile-fail/issue-16149.rs b/src/test/compile-fail/issue-16149.rs
index a924cc9f9bb..4954c95fcd1 100644
--- a/src/test/compile-fail/issue-16149.rs
+++ b/src/test/compile-fail/issue-16149.rs
@@ -19,4 +19,3 @@ fn main() {
         _ => false
     };
 }
-
diff --git a/src/test/compile-fail/issue-16338.rs b/src/test/compile-fail/issue-16338.rs
index ba936561ae5..ba369734daa 100644
--- a/src/test/compile-fail/issue-16338.rs
+++ b/src/test/compile-fail/issue-16338.rs
@@ -18,4 +18,3 @@ fn main() {
     //~| expected &-ptr
     //~| found struct `core::raw::Slice`
 }
-
diff --git a/src/test/compile-fail/issue-16725.rs b/src/test/compile-fail/issue-16725.rs
index 218e9dba065..67fcd820429 100644
--- a/src/test/compile-fail/issue-16725.rs
+++ b/src/test/compile-fail/issue-16725.rs
@@ -16,4 +16,3 @@ fn main() {
     unsafe { foo::bar(); }
     //~^ ERROR: function `bar` is private
 }
-
diff --git a/src/test/compile-fail/issue-16922.rs b/src/test/compile-fail/issue-16922.rs
new file mode 100644
index 00000000000..b525d5f64fc
--- /dev/null
+++ b/src/test/compile-fail/issue-16922.rs
@@ -0,0 +1,20 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::any::Any;
+
+fn foo<T: Any>(value: &T) -> Box<Any> {
+    Box::new(value) as Box<Any>
+    //~^ ERROR: cannot infer an appropriate lifetime
+}
+
+fn main() {
+    let _ = foo(&5);
+}
diff --git a/src/test/compile-fail/issue-17718-const-bad-values.rs b/src/test/compile-fail/issue-17718-const-bad-values.rs
index 2347d3f3d5c..6ee869d65a8 100644
--- a/src/test/compile-fail/issue-17718-const-bad-values.rs
+++ b/src/test/compile-fail/issue-17718-const-bad-values.rs
@@ -17,4 +17,3 @@ const C2: &'static mut usize = &mut S;
 //~^^ ERROR: references in constants may only refer to immutable values
 
 fn main() {}
-
diff --git a/src/test/compile-fail/issue-18919.rs b/src/test/compile-fail/issue-18919.rs
new file mode 100644
index 00000000000..8c2c52e6fad
--- /dev/null
+++ b/src/test/compile-fail/issue-18919.rs
@@ -0,0 +1,17 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+type FuncType<'f> = Fn(&isize) -> isize + 'f;
+
+fn ho_func(f: Option<FuncType>) {
+    //~^ ERROR: the trait `core::marker::Sized` is not implemented for the type
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/issue-19982.rs b/src/test/compile-fail/issue-19982.rs
new file mode 100644
index 00000000000..9dbca997341
--- /dev/null
+++ b/src/test/compile-fail/issue-19982.rs
@@ -0,0 +1,17 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(unboxed_closures)]
+
+struct Foo;
+
+impl Fn<(&(),)> for Foo { } //~ ERROR missing lifetime specifier
+
+fn main() {}
diff --git a/src/test/compile-fail/issue-20225.rs b/src/test/compile-fail/issue-20225.rs
new file mode 100644
index 00000000000..e4bedbbb7e1
--- /dev/null
+++ b/src/test/compile-fail/issue-20225.rs
@@ -0,0 +1,22 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(unboxed_closures)]
+
+struct Foo;
+
+impl<'a, T> Fn<(&'a T,)> for Foo {
+  type Output = ();
+
+  extern "rust-call" fn call(&self, (_,): (T,)) {}
+  //~^ ERROR: has an incompatible type for trait: expected &-ptr
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/issue-20261.rs b/src/test/compile-fail/issue-20261.rs
new file mode 100644
index 00000000000..33e00f9a823
--- /dev/null
+++ b/src/test/compile-fail/issue-20261.rs
@@ -0,0 +1,17 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    for (ref i,) in [].iter() { //~ ERROR: type mismatch resolving
+        i.clone();
+        //~^ ERROR: the type of this value must be known in this context
+        //~| ERROR: reached the recursion limit while auto-dereferencing
+    }
+}
diff --git a/src/test/compile-fail/issue-20714.rs b/src/test/compile-fail/issue-20714.rs
new file mode 100644
index 00000000000..cb322f00723
--- /dev/null
+++ b/src/test/compile-fail/issue-20714.rs
@@ -0,0 +1,15 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+struct G;
+
+fn main() {
+    let g = G(); //~ ERROR: expected function, found `G`
+}
diff --git a/src/test/compile-fail/issue-3008-2.rs b/src/test/compile-fail/issue-3008-2.rs
index 1e8f81a05e7..c744dff0c04 100644
--- a/src/test/compile-fail/issue-3008-2.rs
+++ b/src/test/compile-fail/issue-3008-2.rs
@@ -15,4 +15,3 @@ struct bar { x: bar }
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/issue-3907.rs b/src/test/compile-fail/issue-3907.rs
index 001de796b4a..a3d90a00d03 100644
--- a/src/test/compile-fail/issue-3907.rs
+++ b/src/test/compile-fail/issue-3907.rs
@@ -28,4 +28,3 @@ fn main() {
     };
     s.bar();
 }
-
diff --git a/src/test/compile-fail/issue-5844.rs b/src/test/compile-fail/issue-5844.rs
index 6c85a97f7f5..02e5b9b0921 100644
--- a/src/test/compile-fail/issue-5844.rs
+++ b/src/test/compile-fail/issue-5844.rs
@@ -15,4 +15,3 @@ extern crate issue_5844_aux;
 fn main () {
     issue_5844_aux::rand(); //~ ERROR: requires unsafe
 }
-
diff --git a/src/test/compile-fail/issue-7607-1.rs b/src/test/compile-fail/issue-7607-1.rs
index 4ac90177609..40c3d96bc9a 100644
--- a/src/test/compile-fail/issue-7607-1.rs
+++ b/src/test/compile-fail/issue-7607-1.rs
@@ -17,4 +17,3 @@ impl Fo { //~ ERROR use of undeclared type name `Fo`
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/issue-8767.rs b/src/test/compile-fail/issue-8767.rs
index 2ef0a75f77b..9abd8c9e3fc 100644
--- a/src/test/compile-fail/issue-8767.rs
+++ b/src/test/compile-fail/issue-8767.rs
@@ -15,4 +15,3 @@ impl B { //~ ERROR use of undeclared type name `B`
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/kindck-copy.rs b/src/test/compile-fail/kindck-copy.rs
index 74e372e41eb..d5bfe3d1692 100644
--- a/src/test/compile-fail/kindck-copy.rs
+++ b/src/test/compile-fail/kindck-copy.rs
@@ -80,4 +80,3 @@ fn test<'a,T,U:Copy>(_: &'a isize) {
 
 pub fn main() {
 }
-
diff --git a/src/test/compile-fail/kindck-nonsendable-1.rs b/src/test/compile-fail/kindck-nonsendable-1.rs
index c370aa4b8fb..bf2a209c4c4 100644
--- a/src/test/compile-fail/kindck-nonsendable-1.rs
+++ b/src/test/compile-fail/kindck-nonsendable-1.rs
@@ -20,4 +20,3 @@ fn main() {
     bar(move|| foo(x));
     //~^ ERROR `core::marker::Send` is not implemented
 }
-
diff --git a/src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs b/src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs
index 55cce016335..1fa7284f6b5 100644
--- a/src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs
+++ b/src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs
@@ -37,4 +37,3 @@ fn i(_x: isize) -> &isize { //~ ERROR missing lifetime specifier
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/linkage3.rs b/src/test/compile-fail/linkage3.rs
index c75c7002e5e..8343f718902 100644
--- a/src/test/compile-fail/linkage3.rs
+++ b/src/test/compile-fail/linkage3.rs
@@ -18,4 +18,3 @@ extern {
 fn main() {
     println!("{:?}", foo);
 }
-
diff --git a/src/test/compile-fail/lint-dead-code-3.rs b/src/test/compile-fail/lint-dead-code-3.rs
index f60c39ba020..13ee3f16361 100644
--- a/src/test/compile-fail/lint-dead-code-3.rs
+++ b/src/test/compile-fail/lint-dead-code-3.rs
@@ -19,7 +19,7 @@ extern crate libc;
 
 pub use extern_foo as x;
 extern {
-    fn extern_foo();
+    pub fn extern_foo();
 }
 
 struct Foo; //~ ERROR: struct is never used
diff --git a/src/test/compile-fail/lint-exceeding-bitshifts.rs b/src/test/compile-fail/lint-exceeding-bitshifts.rs
index 345e56e2e58..171dedd5b2e 100644
--- a/src/test/compile-fail/lint-exceeding-bitshifts.rs
+++ b/src/test/compile-fail/lint-exceeding-bitshifts.rs
@@ -60,4 +60,3 @@ fn main() {
       let n = 1_isize << std::isize::BITS; //~ ERROR: bitshift exceeds the type's number of bits
       let n = 1_usize << std::usize::BITS; //~ ERROR: bitshift exceeds the type's number of bits
 }
-
diff --git a/src/test/compile-fail/lint-stability3.rs b/src/test/compile-fail/lint-stability3.rs
index 88a93134b47..44a36f215f3 100644
--- a/src/test/compile-fail/lint-stability3.rs
+++ b/src/test/compile-fail/lint-stability3.rs
@@ -22,4 +22,3 @@ use lint_stability::*;
 fn main() {
     macro_test_arg_nested!(deprecated_text);
 }
-
diff --git a/src/test/compile-fail/lint-uppercase-variables.rs b/src/test/compile-fail/lint-uppercase-variables.rs
index a4f46cbd187..517be0eb8ac 100644
--- a/src/test/compile-fail/lint-uppercase-variables.rs
+++ b/src/test/compile-fail/lint-uppercase-variables.rs
@@ -40,4 +40,3 @@ fn main() {
 
     let _ = Something { X: 0 };
 }
-
diff --git a/src/test/compile-fail/macro-inner-attributes.rs b/src/test/compile-fail/macro-inner-attributes.rs
index e76eaea365e..abf0ed420e7 100644
--- a/src/test/compile-fail/macro-inner-attributes.rs
+++ b/src/test/compile-fail/macro-inner-attributes.rs
@@ -29,4 +29,3 @@ fn main() {
     //~^^ ERROR unresolved name `a::bar`
     b::bar();
 }
-
diff --git a/src/test/compile-fail/macro-outer-attributes.rs b/src/test/compile-fail/macro-outer-attributes.rs
index cff01f36f3a..0469a9d1cc8 100644
--- a/src/test/compile-fail/macro-outer-attributes.rs
+++ b/src/test/compile-fail/macro-outer-attributes.rs
@@ -28,4 +28,3 @@ fn main() {
     a::bar(); //~ ERROR unresolved name `a::bar`
     b::bar();
 }
-
diff --git a/src/test/compile-fail/manual-link-bad-form.rs b/src/test/compile-fail/manual-link-bad-form.rs
index bd2a3eba0b5..c251ce6a3c8 100644
--- a/src/test/compile-fail/manual-link-bad-form.rs
+++ b/src/test/compile-fail/manual-link-bad-form.rs
@@ -13,5 +13,3 @@
 
 fn main() {
 }
-
-
diff --git a/src/test/compile-fail/manual-link-bad-kind.rs b/src/test/compile-fail/manual-link-bad-kind.rs
index 4614440ddaf..5ab073c33bc 100644
--- a/src/test/compile-fail/manual-link-bad-kind.rs
+++ b/src/test/compile-fail/manual-link-bad-kind.rs
@@ -13,4 +13,3 @@
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/method-ambig-two-traits-cross-crate.rs b/src/test/compile-fail/method-ambig-two-traits-cross-crate.rs
index 981c4c6f40d..c1d4551fd9e 100644
--- a/src/test/compile-fail/method-ambig-two-traits-cross-crate.rs
+++ b/src/test/compile-fail/method-ambig-two-traits-cross-crate.rs
@@ -19,4 +19,3 @@ trait me2 {
 }
 impl me2 for usize { fn me(&self) -> usize { *self } }
 fn main() { 1_usize.me(); } //~ ERROR E0034
-
diff --git a/src/test/compile-fail/method-missing-call.rs b/src/test/compile-fail/method-missing-call.rs
index 6616dcc8e1b..b13d4250ee9 100644
--- a/src/test/compile-fail/method-missing-call.rs
+++ b/src/test/compile-fail/method-missing-call.rs
@@ -40,4 +40,3 @@ fn main() {
               .filter_map; //~ ERROR attempted to take value of method `filter_map` on type
               //~^ HELP maybe a `()` to call it is missing
 }
-
diff --git a/src/test/compile-fail/method-suggestion-no-duplication.rs b/src/test/compile-fail/method-suggestion-no-duplication.rs
index e807d2b9448..1d0c4254eda 100644
--- a/src/test/compile-fail/method-suggestion-no-duplication.rs
+++ b/src/test/compile-fail/method-suggestion-no-duplication.rs
@@ -19,6 +19,4 @@ fn main() {
     //~^ ERROR does not implement any method
     //~^^ HELP #1: `core::slice::SliceExt`
     //~^^^ HELP #2: `core::str::StrExt`
-    //~^^^^ HELP #3: `collections::slice::SliceExt`
-    //~^^^^^ HELP #4: `collections::str::StrExt`
 }
diff --git a/src/test/compile-fail/mut-cross-borrowing.rs b/src/test/compile-fail/mut-cross-borrowing.rs
index 6829cd574e1..73982fa2811 100644
--- a/src/test/compile-fail/mut-cross-borrowing.rs
+++ b/src/test/compile-fail/mut-cross-borrowing.rs
@@ -16,4 +16,3 @@ fn main() {
     let mut x: Box<_> = box 3;
     f(x)    //~ ERROR mismatched types
 }
-
diff --git a/src/test/compile-fail/object-safety-by-value-self-use.rs b/src/test/compile-fail/object-safety-by-value-self-use.rs
index 1b20a902c9d..36356cb7d52 100644
--- a/src/test/compile-fail/object-safety-by-value-self-use.rs
+++ b/src/test/compile-fail/object-safety-by-value-self-use.rs
@@ -26,4 +26,3 @@ fn use_bar(t: Box<Bar>) {
 }
 
 fn main() { }
-
diff --git a/src/test/compile-fail/opt-in-copy.rs b/src/test/compile-fail/opt-in-copy.rs
index 56f71c844ac..bc18b52a0c1 100644
--- a/src/test/compile-fail/opt-in-copy.rs
+++ b/src/test/compile-fail/opt-in-copy.rs
@@ -30,4 +30,3 @@ impl Copy for IWantToCopyThisToo {}
 //~^ ERROR the trait `Copy` may not be implemented for this type
 
 fn main() {}
-
diff --git a/src/test/compile-fail/overloaded-calls-nontuple.rs b/src/test/compile-fail/overloaded-calls-nontuple.rs
index 41ecf714613..c4019fa2209 100644
--- a/src/test/compile-fail/overloaded-calls-nontuple.rs
+++ b/src/test/compile-fail/overloaded-calls-nontuple.rs
@@ -31,4 +31,3 @@ fn main() {
     };
     drop(s(3))  //~ ERROR cannot use call notation
 }
-
diff --git a/src/test/compile-fail/pattern-bindings-after-at.rs b/src/test/compile-fail/pattern-bindings-after-at.rs
index 80544099329..da2a97b0ca8 100644
--- a/src/test/compile-fail/pattern-bindings-after-at.rs
+++ b/src/test/compile-fail/pattern-bindings-after-at.rs
@@ -23,4 +23,3 @@ fn main() {
         _ => ()
     }
 }
-
diff --git a/src/test/compile-fail/pattern-ident-path-generics.rs b/src/test/compile-fail/pattern-ident-path-generics.rs
index 58288fa4842..0b7886842b4 100644
--- a/src/test/compile-fail/pattern-ident-path-generics.rs
+++ b/src/test/compile-fail/pattern-ident-path-generics.rs
@@ -14,4 +14,3 @@ fn main() {
         Some(_) => {}
     }
 }
-
diff --git a/src/test/compile-fail/privacy1.rs b/src/test/compile-fail/privacy1.rs
index 1ae79adbad7..67dccb4c93e 100644
--- a/src/test/compile-fail/privacy1.rs
+++ b/src/test/compile-fail/privacy1.rs
@@ -27,10 +27,6 @@ mod bar {
 
     // can't publicly re-export private items
     pub use self::baz::{foo, bar};
-    //~^ ERROR: function `bar` is private
-
-    pub use self::private::ppriv;
-    //~^ ERROR: function `ppriv` is private
 
     pub struct A;
     impl A {
@@ -61,10 +57,8 @@ mod bar {
             fn bar2(&self) {}
         }
 
-        // both of these are re-exported by `bar`, but only one should be
-        // validly re-exported
         pub fn foo() {}
-        fn bar() {}
+        pub fn bar() {}
     }
 
     extern {
@@ -92,10 +86,6 @@ mod bar {
         pub fn gpub() {}
         fn gpriv() {}
     }
-
-    mod private {
-        fn ppriv() {}
-    }
 }
 
 pub fn gpub() {}
@@ -142,13 +132,13 @@ mod foo {
 
         ::bar::baz::foo(); //~ ERROR: function `foo` is inaccessible
                            //~^ NOTE: module `baz` is private
-        ::bar::baz::bar(); //~ ERROR: function `bar` is private
+        ::bar::baz::bar(); //~ ERROR: function `bar` is inaccessible
     }
 
     fn test2() {
         use bar::baz::{foo, bar};
         //~^ ERROR: function `foo` is inaccessible
-        //~^^ ERROR: function `bar` is private
+        //~^^ ERROR: function `bar` is inaccessible
         foo();
         bar();
     }
diff --git a/src/test/compile-fail/region-bound-on-closure-outlives-call.rs b/src/test/compile-fail/region-bound-on-closure-outlives-call.rs
index 9f35c636b45..b73c283fa51 100644
--- a/src/test/compile-fail/region-bound-on-closure-outlives-call.rs
+++ b/src/test/compile-fail/region-bound-on-closure-outlives-call.rs
@@ -13,4 +13,3 @@ fn call_rec<F>(mut f: F) -> usize where F: FnMut(usize) -> usize {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/region-object-lifetime-1.rs b/src/test/compile-fail/region-object-lifetime-1.rs
index 2095fb903b8..1e615be9d6a 100644
--- a/src/test/compile-fail/region-object-lifetime-1.rs
+++ b/src/test/compile-fail/region-object-lifetime-1.rs
@@ -26,4 +26,3 @@ fn borrowed_receiver_same_lifetime<'a>(x: &'a Foo) -> &'a () {
 
 #[rustc_error]
 fn main() {} //~ ERROR compilation successful
-
diff --git a/src/test/compile-fail/region-object-lifetime-2.rs b/src/test/compile-fail/region-object-lifetime-2.rs
index f9bf4e257b3..e011b8f5697 100644
--- a/src/test/compile-fail/region-object-lifetime-2.rs
+++ b/src/test/compile-fail/region-object-lifetime-2.rs
@@ -21,4 +21,3 @@ fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a Foo) -> &'b () {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/region-object-lifetime-3.rs b/src/test/compile-fail/region-object-lifetime-3.rs
index 097053276c7..84dd97643a1 100644
--- a/src/test/compile-fail/region-object-lifetime-3.rs
+++ b/src/test/compile-fail/region-object-lifetime-3.rs
@@ -26,4 +26,3 @@ fn borrowed_receiver_related_lifetimes<'a,'b>(x: &'a (Foo+'b)) -> &'a () {
 
 #[rustc_error]
 fn main() {} //~ ERROR compilation successful
-
diff --git a/src/test/compile-fail/region-object-lifetime-4.rs b/src/test/compile-fail/region-object-lifetime-4.rs
index fe0ff8dc3fe..0a68e7f1076 100644
--- a/src/test/compile-fail/region-object-lifetime-4.rs
+++ b/src/test/compile-fail/region-object-lifetime-4.rs
@@ -23,4 +23,3 @@ fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (Foo+'b)) -> &'b () {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/region-object-lifetime-5.rs b/src/test/compile-fail/region-object-lifetime-5.rs
index f07f753d825..26aad0e33b1 100644
--- a/src/test/compile-fail/region-object-lifetime-5.rs
+++ b/src/test/compile-fail/region-object-lifetime-5.rs
@@ -22,4 +22,3 @@ fn owned_receiver(x: Box<Foo>) -> &'static () {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/regionck-unboxed-closure-lifetimes.rs b/src/test/compile-fail/regionck-unboxed-closure-lifetimes.rs
index 9418156ffcd..5db9a01c012 100644
--- a/src/test/compile-fail/regionck-unboxed-closure-lifetimes.rs
+++ b/src/test/compile-fail/regionck-unboxed-closure-lifetimes.rs
@@ -20,4 +20,3 @@ fn main() {
         f = move |a: isize, b: isize| { a + b + *c_ref };
     }
 }
-
diff --git a/src/test/compile-fail/regions-close-associated-type-into-object.rs b/src/test/compile-fail/regions-close-associated-type-into-object.rs
index 72a024e563c..f80b0ffa5aa 100644
--- a/src/test/compile-fail/regions-close-associated-type-into-object.rs
+++ b/src/test/compile-fail/regions-close-associated-type-into-object.rs
@@ -84,4 +84,3 @@ fn meh1<'a, T: Iter>(v: &'a T) -> Box<X+'a>
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/regions-close-object-into-object-1.rs b/src/test/compile-fail/regions-close-object-into-object-1.rs
index 7bbce7dad53..4c831a2b659 100644
--- a/src/test/compile-fail/regions-close-object-into-object-1.rs
+++ b/src/test/compile-fail/regions-close-object-into-object-1.rs
@@ -25,4 +25,3 @@ fn f<'a, T:'static, U>(v: Box<A<T>+'static>) -> Box<X+'static> {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/regions-close-object-into-object-3.rs b/src/test/compile-fail/regions-close-object-into-object-3.rs
index e22d0c7d0a4..b723efff3c9 100644
--- a/src/test/compile-fail/regions-close-object-into-object-3.rs
+++ b/src/test/compile-fail/regions-close-object-into-object-3.rs
@@ -24,4 +24,3 @@ fn h<'a, T, U>(v: Box<A<U>+'static>) -> Box<X+'static> {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/regions-close-object-into-object-4.rs b/src/test/compile-fail/regions-close-object-into-object-4.rs
index 147a575d38c..9b311588bb1 100644
--- a/src/test/compile-fail/regions-close-object-into-object-4.rs
+++ b/src/test/compile-fail/regions-close-object-into-object-4.rs
@@ -23,4 +23,3 @@ fn i<'a, T, U>(v: Box<A<U>+'a>) -> Box<X+'static> {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/regions-close-object-into-object-5.rs b/src/test/compile-fail/regions-close-object-into-object-5.rs
index bdc52eca2cb..f3b5ccabe79 100644
--- a/src/test/compile-fail/regions-close-object-into-object-5.rs
+++ b/src/test/compile-fail/regions-close-object-into-object-5.rs
@@ -27,4 +27,3 @@ fn f<'a, T, U>(v: Box<A<T>+'static>) -> Box<X+'static> {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/regions-close-param-into-object.rs b/src/test/compile-fail/regions-close-param-into-object.rs
index eebf93bc893..7324d4a4a0e 100644
--- a/src/test/compile-fail/regions-close-param-into-object.rs
+++ b/src/test/compile-fail/regions-close-param-into-object.rs
@@ -37,4 +37,3 @@ fn p4<'a,T>(v: Box<T>) -> Box<X+'a>
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/resolve-conflict-extern-crate-vs-extern-crate.rs b/src/test/compile-fail/resolve-conflict-extern-crate-vs-extern-crate.rs
index 8673d95de1b..af3ee7f3537 100644
--- a/src/test/compile-fail/resolve-conflict-extern-crate-vs-extern-crate.rs
+++ b/src/test/compile-fail/resolve-conflict-extern-crate-vs-extern-crate.rs
@@ -12,4 +12,3 @@ extern crate std;
 //~^ ERROR an external crate named `std` has already been imported
 
 fn main(){}
-
diff --git a/src/test/compile-fail/resolve-conflict-import-vs-extern-crate.rs b/src/test/compile-fail/resolve-conflict-import-vs-extern-crate.rs
index f27b11d5411..0c601a81178 100644
--- a/src/test/compile-fail/resolve-conflict-import-vs-extern-crate.rs
+++ b/src/test/compile-fail/resolve-conflict-import-vs-extern-crate.rs
@@ -12,4 +12,3 @@ use std::slice as std; //~ ERROR import `std` conflicts with imported crate
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/resolve-conflict-import-vs-import.rs b/src/test/compile-fail/resolve-conflict-import-vs-import.rs
index beb4b74f326..10afe82f2ef 100644
--- a/src/test/compile-fail/resolve-conflict-import-vs-import.rs
+++ b/src/test/compile-fail/resolve-conflict-import-vs-import.rs
@@ -14,4 +14,3 @@ use std::mem::transmute;
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/resolve-conflict-item-vs-extern-crate.rs b/src/test/compile-fail/resolve-conflict-item-vs-extern-crate.rs
index 9d40196d4ac..e685353592f 100644
--- a/src/test/compile-fail/resolve-conflict-item-vs-extern-crate.rs
+++ b/src/test/compile-fail/resolve-conflict-item-vs-extern-crate.rs
@@ -12,4 +12,3 @@ fn std() {}    //~ ERROR the name `std` conflicts with an external crate
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/resolve-conflict-item-vs-import.rs b/src/test/compile-fail/resolve-conflict-item-vs-import.rs
index 96800918351..1edf815ecae 100644
--- a/src/test/compile-fail/resolve-conflict-item-vs-import.rs
+++ b/src/test/compile-fail/resolve-conflict-item-vs-import.rs
@@ -15,4 +15,3 @@ fn transmute() {}
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/resolve-unknown-trait.rs b/src/test/compile-fail/resolve-unknown-trait.rs
index 3983a84f6ad..fd4dce51fc8 100644
--- a/src/test/compile-fail/resolve-unknown-trait.rs
+++ b/src/test/compile-fail/resolve-unknown-trait.rs
@@ -17,4 +17,3 @@ impl SomeNonExistentTrait for isize {}
 
 fn f<T:SomeNonExistentTrait>() {}
 //~^ ERROR use of undeclared trait name `SomeNonExistentTrait`
-
diff --git a/src/test/compile-fail/shadowing-in-the-same-pattern.rs b/src/test/compile-fail/shadowing-in-the-same-pattern.rs
index c29534128ae..e847d332416 100644
--- a/src/test/compile-fail/shadowing-in-the-same-pattern.rs
+++ b/src/test/compile-fail/shadowing-in-the-same-pattern.rs
@@ -15,4 +15,3 @@ fn f((a, a): (isize, isize)) {} //~ ERROR identifier `a` is bound more than once
 fn main() {
     let (a, a) = (1, 1);    //~ ERROR identifier `a` is bound more than once
 }
-
diff --git a/src/test/compile-fail/single-primitive-inherent-impl.rs b/src/test/compile-fail/single-primitive-inherent-impl.rs
new file mode 100644
index 00000000000..b2cfcfab78b
--- /dev/null
+++ b/src/test/compile-fail/single-primitive-inherent-impl.rs
@@ -0,0 +1,24 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-tidy-linelength
+
+#![crate_type = "lib"]
+#![feature(lang_items)]
+#![feature(no_std)]
+#![no_std]
+
+// OK
+#[lang = "char"]
+impl char {}
+
+impl char {
+//~^ error: only a single inherent implementation marked with `#[lang = "char"]` is allowed for the `char` primitive
+}
diff --git a/src/test/compile-fail/static-array-across-crate.rs b/src/test/compile-fail/static-array-across-crate.rs
new file mode 100644
index 00000000000..422cf630429
--- /dev/null
+++ b/src/test/compile-fail/static-array-across-crate.rs
@@ -0,0 +1,20 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:pub_static_array.rs
+
+extern crate "pub_static_array" as array;
+
+use array::ARRAY;
+
+static X: &'static u8 = &ARRAY[0];
+//~^ ERROR: cannot refer to the interior of another static, use a constant
+
+pub fn main() {}
diff --git a/src/test/compile-fail/struct-variant-privacy-xc.rs b/src/test/compile-fail/struct-variant-privacy-xc.rs
index c58273361ad..b8be7d0cdc2 100644
--- a/src/test/compile-fail/struct-variant-privacy-xc.rs
+++ b/src/test/compile-fail/struct-variant-privacy-xc.rs
@@ -18,4 +18,3 @@ fn f(b: struct_variant_privacy::Bar) { //~ ERROR enum `Bar` is private
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/structure-constructor-type-mismatch.rs b/src/test/compile-fail/structure-constructor-type-mismatch.rs
index ea6d63ca540..02c4f3d5d52 100644
--- a/src/test/compile-fail/structure-constructor-type-mismatch.rs
+++ b/src/test/compile-fail/structure-constructor-type-mismatch.rs
@@ -62,4 +62,3 @@ fn main() {
         y: 10,
     };
 }
-
diff --git a/src/test/compile-fail/trait-as-struct-constructor.rs b/src/test/compile-fail/trait-as-struct-constructor.rs
index fff14414094..1fd711ca4fb 100644
--- a/src/test/compile-fail/trait-as-struct-constructor.rs
+++ b/src/test/compile-fail/trait-as-struct-constructor.rs
@@ -14,4 +14,3 @@ fn main() {
     TraitNotAStruct{ value: 0 };
     //~^ ERROR: use of trait `TraitNotAStruct` as a struct constructor [E0159]
 }
-
diff --git a/src/test/compile-fail/trait-bounds-impl-comparison-2.rs b/src/test/compile-fail/trait-bounds-impl-comparison-2.rs
index 284c4fac953..217540415a7 100644
--- a/src/test/compile-fail/trait-bounds-impl-comparison-2.rs
+++ b/src/test/compile-fail/trait-bounds-impl-comparison-2.rs
@@ -32,4 +32,3 @@ struct ZipIterator<T, U> {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs b/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs
index 448b186f6a5..e126a3040e9 100644
--- a/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs
+++ b/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs
@@ -15,7 +15,7 @@ trait Foo {
 // This should emit the less confusing error, not the more confusing one.
 
 fn foo(_x: Foo + Send) {
-    //~^ERROR the trait `core::marker::Sized` is not implemented
+    //~^ ERROR the trait `core::marker::Sized` is not implemented
 }
 
 fn main() { }
diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs
index df44e847c50..d39b7e15edc 100644
--- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs
+++ b/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs
@@ -25,4 +25,3 @@ fn main() {
     let baz: Foo<usize> = panic!();
     //~^ ERROR not implemented
 }
-
diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs
index 18871d0d386..d93c9bafaef 100644
--- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs
+++ b/src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs
@@ -23,4 +23,3 @@ static X: Foo<usize> = Foo {
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc.rs
index ded75aa1d85..5f95a7ca6e2 100644
--- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc.rs
+++ b/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc.rs
@@ -22,4 +22,3 @@ fn kaboom(y: Bar<f32>) {}
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc1.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc1.rs
index 8a9732de7fb..840787022e6 100644
--- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc1.rs
+++ b/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc1.rs
@@ -23,4 +23,3 @@ fn main() {
     //~^ ERROR not implemented
     let _ = bar;
 }
-
diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs
index 8dfdb2f205d..ce0a7d3bb36 100644
--- a/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs
+++ b/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs
@@ -66,4 +66,3 @@ impl PolyTrait<Foo<usize>> for Struct {
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/trait-coercion-generic-regions.rs b/src/test/compile-fail/trait-coercion-generic-regions.rs
index bbe256d1c8f..9ba017e150e 100644
--- a/src/test/compile-fail/trait-coercion-generic-regions.rs
+++ b/src/test/compile-fail/trait-coercion-generic-regions.rs
@@ -28,4 +28,3 @@ fn main() {
     // FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
     let s: Box<Trait<&'static str>> = Box::new(Struct { person: person });
 }
-
diff --git a/src/test/compile-fail/transmute-different-sizes.rs b/src/test/compile-fail/transmute-different-sizes.rs
index 5c61212a7f5..918589b8fd3 100644
--- a/src/test/compile-fail/transmute-different-sizes.rs
+++ b/src/test/compile-fail/transmute-different-sizes.rs
@@ -25,5 +25,3 @@ unsafe fn g<T>(x: &T) {
 }
 
 fn main() {}
-
-
diff --git a/src/test/compile-fail/type-params-in-different-spaces-2.rs b/src/test/compile-fail/type-params-in-different-spaces-2.rs
index 3a4cc9e874e..71e9113603a 100644
--- a/src/test/compile-fail/type-params-in-different-spaces-2.rs
+++ b/src/test/compile-fail/type-params-in-different-spaces-2.rs
@@ -29,4 +29,3 @@ trait B<T>: Tr<T> {
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/type-params-in-different-spaces-3.rs b/src/test/compile-fail/type-params-in-different-spaces-3.rs
index c113e1b7815..3ad1e9ab538 100644
--- a/src/test/compile-fail/type-params-in-different-spaces-3.rs
+++ b/src/test/compile-fail/type-params-in-different-spaces-3.rs
@@ -15,4 +15,3 @@ trait Tr : Sized {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/ufcs-explicit-self-bad.rs b/src/test/compile-fail/ufcs-explicit-self-bad.rs
index cbcf31b5b7e..5d2b5fa52db 100644
--- a/src/test/compile-fail/ufcs-explicit-self-bad.rs
+++ b/src/test/compile-fail/ufcs-explicit-self-bad.rs
@@ -63,4 +63,3 @@ fn main() {
     };
     println!("{} {}", bar.foo(2), bar.bar(2));
 }
-
diff --git a/src/test/compile-fail/ufcs-qpath-self-mismatch.rs b/src/test/compile-fail/ufcs-qpath-self-mismatch.rs
index 868c1eae4a9..8e60064beca 100644
--- a/src/test/compile-fail/ufcs-qpath-self-mismatch.rs
+++ b/src/test/compile-fail/ufcs-qpath-self-mismatch.rs
@@ -18,4 +18,3 @@ fn main() {
     <i32 as Add<i32>>::add(1, 2u32);
     //~^ ERROR mismatched types
 }
-
diff --git a/src/test/compile-fail/unboxed-closure-sugar-nonexistent-trait.rs b/src/test/compile-fail/unboxed-closure-sugar-nonexistent-trait.rs
index f28bf7acadd..b195a932aca 100644
--- a/src/test/compile-fail/unboxed-closure-sugar-nonexistent-trait.rs
+++ b/src/test/compile-fail/unboxed-closure-sugar-nonexistent-trait.rs
@@ -17,4 +17,3 @@ type Typedef = isize;
 fn g<F:Typedef(isize) -> isize>(x: F) {} //~ ERROR `Typedef` is not a trait
 
 fn main() {}
-
diff --git a/src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs b/src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs
index 1f0d5aae36d..55156e28cd7 100644
--- a/src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs
+++ b/src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs
@@ -20,4 +20,3 @@ fn bar2<T>(x: &T) where T: Fn<()> {
 }
 
 fn main() { }
-
diff --git a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs
index a3991a87b78..1e36c47c097 100644
--- a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs
+++ b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs
@@ -22,4 +22,3 @@ fn bar() {
 }
 
 fn main() { }
-
diff --git a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs
index ad85cdcaa03..f50d91a4ddd 100644
--- a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs
+++ b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs
@@ -20,4 +20,3 @@ fn foo(b: Box<Bar()>) {
 }
 
 fn main() { }
-
diff --git a/src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs b/src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs
index 5810ffcf21a..e6e18d996b9 100644
--- a/src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs
+++ b/src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs
@@ -17,4 +17,3 @@ fn f<F:Trait(isize) -> isize>(x: F) {}
 //~| ERROR no associated type `Output`
 
 fn main() {}
-
diff --git a/src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs b/src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs
index bbafd5109ed..92e6affa4c2 100644
--- a/src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs
+++ b/src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs
@@ -35,4 +35,3 @@ fn main() {
     //~^ ERROR not implemented
     //~| ERROR not implemented
 }
-
diff --git a/src/test/compile-fail/unboxed-closures-infer-explicit-call-too-early.rs b/src/test/compile-fail/unboxed-closures-infer-explicit-call-too-early.rs
index f993b8fa8c4..226b516e09d 100644
--- a/src/test/compile-fail/unboxed-closures-infer-explicit-call-too-early.rs
+++ b/src/test/compile-fail/unboxed-closures-infer-explicit-call-too-early.rs
@@ -15,4 +15,3 @@ fn main() {
     let () = zero.call_mut(());
     //~^ ERROR we have not yet inferred what kind of closure it is
 }
-
diff --git a/src/test/compile-fail/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs b/src/test/compile-fail/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs
index afbc141b5d2..7c5ea031596 100644
--- a/src/test/compile-fail/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs
+++ b/src/test/compile-fail/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs
@@ -29,4 +29,3 @@ fn main() {
 
     tick2(); //~ ERROR cannot borrow
 }
-
diff --git a/src/test/compile-fail/unboxed-closures-static-call-wrong-trait.rs b/src/test/compile-fail/unboxed-closures-static-call-wrong-trait.rs
index f430e9fc759..1a52e22419e 100644
--- a/src/test/compile-fail/unboxed-closures-static-call-wrong-trait.rs
+++ b/src/test/compile-fail/unboxed-closures-static-call-wrong-trait.rs
@@ -16,4 +16,3 @@ fn main() {
     let mut_ = to_fn_mut(|x| x);
     mut_.call((0, )); //~ ERROR does not implement any method in scope named `call`
 }
-
diff --git a/src/test/compile-fail/unboxed-closures-vtable-mismatch.rs b/src/test/compile-fail/unboxed-closures-vtable-mismatch.rs
index c2a2e5162ac..28e8b8db2a4 100644
--- a/src/test/compile-fail/unboxed-closures-vtable-mismatch.rs
+++ b/src/test/compile-fail/unboxed-closures-vtable-mismatch.rs
@@ -25,4 +25,3 @@ pub fn main() {
     //~| ERROR type mismatch
     println!("{}", z);
 }
-
diff --git a/src/test/compile-fail/unboxed-closures-wrong-abi.rs b/src/test/compile-fail/unboxed-closures-wrong-abi.rs
index 96619bef36f..40655f8a3ce 100644
--- a/src/test/compile-fail/unboxed-closures-wrong-abi.rs
+++ b/src/test/compile-fail/unboxed-closures-wrong-abi.rs
@@ -35,4 +35,3 @@ fn c() {
 }
 
 fn main() { }
-
diff --git a/src/test/compile-fail/variance-issue-20533.rs b/src/test/compile-fail/variance-issue-20533.rs
index e5473f12bf2..60690012485 100644
--- a/src/test/compile-fail/variance-issue-20533.rs
+++ b/src/test/compile-fail/variance-issue-20533.rs
@@ -51,4 +51,3 @@ fn main() {
         drop(x);
     }
 }
-
diff --git a/src/test/compile-fail/variance-trait-matching.rs b/src/test/compile-fail/variance-trait-matching.rs
index d4dab5f0ed0..ec020f18818 100644
--- a/src/test/compile-fail/variance-trait-matching.rs
+++ b/src/test/compile-fail/variance-trait-matching.rs
@@ -27,4 +27,3 @@ fn f() -> &'static mut isize {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/vector-cast-weirdness.rs b/src/test/compile-fail/vector-cast-weirdness.rs
index c5109ce473e..97e67cd2eae 100644
--- a/src/test/compile-fail/vector-cast-weirdness.rs
+++ b/src/test/compile-fail/vector-cast-weirdness.rs
@@ -28,4 +28,3 @@ fn main() {
     let t1: *mut [u8; 2] = &mut x1.y as *mut _;
     let h1: *mut [u8; 2] = &mut x1.y as *mut [u8; 2];
 }
-
diff --git a/src/test/compile-fail/walk-struct-literal-with.rs b/src/test/compile-fail/walk-struct-literal-with.rs
index 0f3754e09e4..10503084b9d 100644
--- a/src/test/compile-fail/walk-struct-literal-with.rs
+++ b/src/test/compile-fail/walk-struct-literal-with.rs
@@ -25,4 +25,3 @@ fn main(){
     let end = Mine{other_val:1, ..start.make_string_bar()};
     println!("{}", start.test); //~ ERROR use of moved value: `start.test`
 }
-
diff --git a/src/test/compile-fail/where-clauses-unsatisfied.rs b/src/test/compile-fail/where-clauses-unsatisfied.rs
index 4a4a5f3193d..269df212489 100644
--- a/src/test/compile-fail/where-clauses-unsatisfied.rs
+++ b/src/test/compile-fail/where-clauses-unsatisfied.rs
@@ -17,4 +17,3 @@ fn main() {
     drop(equal(&Struct, &Struct))
     //~^ ERROR the trait `core::cmp::Eq` is not implemented
 }
-
diff --git a/src/test/debuginfo/function-arg-initialization.rs b/src/test/debuginfo/function-arg-initialization.rs
index 9eadf3cc19b..7cefb6044f6 100644
--- a/src/test/debuginfo/function-arg-initialization.rs
+++ b/src/test/debuginfo/function-arg-initialization.rs
@@ -330,6 +330,3 @@ fn main() {
     while_expr(40, 41, 42);
     loop_expr(43, 44, 45);
 }
-
-
-
diff --git a/src/test/debuginfo/generic-method-on-generic-struct.rs b/src/test/debuginfo/generic-method-on-generic-struct.rs
index 8b698d900af..07b6d745544 100644
--- a/src/test/debuginfo/generic-method-on-generic-struct.rs
+++ b/src/test/debuginfo/generic-method-on-generic-struct.rs
@@ -149,4 +149,3 @@ fn main() {
 }
 
 fn zzz() {()}
-
diff --git a/src/test/debuginfo/lexical-scope-in-parameterless-closure.rs b/src/test/debuginfo/lexical-scope-in-parameterless-closure.rs
index e097ec2adb1..59935e55b33 100644
--- a/src/test/debuginfo/lexical-scope-in-parameterless-closure.rs
+++ b/src/test/debuginfo/lexical-scope-in-parameterless-closure.rs
@@ -20,4 +20,3 @@ fn main() {
     let _ = ||();
     let _ = (1_usize..3).map(|_| 5);
 }
-
diff --git a/src/test/debuginfo/limited-debuginfo.rs b/src/test/debuginfo/limited-debuginfo.rs
index e51842992cc..c140390604b 100644
--- a/src/test/debuginfo/limited-debuginfo.rs
+++ b/src/test/debuginfo/limited-debuginfo.rs
@@ -54,4 +54,3 @@ fn some_function(a: int, b: int) {
 }
 
 fn some_other_function(a: int, b: int) -> bool { true }
-
diff --git a/src/test/debuginfo/method-on-enum.rs b/src/test/debuginfo/method-on-enum.rs
index 638d73f0d4e..7172a880f4c 100644
--- a/src/test/debuginfo/method-on-enum.rs
+++ b/src/test/debuginfo/method-on-enum.rs
@@ -151,4 +151,3 @@ fn main() {
 }
 
 fn zzz() {()}
-
diff --git a/src/test/debuginfo/method-on-generic-struct.rs b/src/test/debuginfo/method-on-generic-struct.rs
index 784d60eec9a..bf6635f833f 100644
--- a/src/test/debuginfo/method-on-generic-struct.rs
+++ b/src/test/debuginfo/method-on-generic-struct.rs
@@ -150,4 +150,3 @@ fn main() {
 }
 
 fn zzz() {()}
-
diff --git a/src/test/debuginfo/method-on-struct.rs b/src/test/debuginfo/method-on-struct.rs
index a91586a6aa6..54779e00708 100644
--- a/src/test/debuginfo/method-on-struct.rs
+++ b/src/test/debuginfo/method-on-struct.rs
@@ -150,4 +150,3 @@ fn main() {
 }
 
 fn zzz() {()}
-
diff --git a/src/test/debuginfo/method-on-trait.rs b/src/test/debuginfo/method-on-trait.rs
index e2c827ee517..7954bcae1b2 100644
--- a/src/test/debuginfo/method-on-trait.rs
+++ b/src/test/debuginfo/method-on-trait.rs
@@ -156,4 +156,3 @@ fn main() {
 }
 
 fn zzz() {()}
-
diff --git a/src/test/debuginfo/method-on-tuple-struct.rs b/src/test/debuginfo/method-on-tuple-struct.rs
index e8bc40f1810..af128706650 100644
--- a/src/test/debuginfo/method-on-tuple-struct.rs
+++ b/src/test/debuginfo/method-on-tuple-struct.rs
@@ -148,4 +148,3 @@ fn main() {
 }
 
 fn zzz() {()}
-
diff --git a/src/test/debuginfo/no-debug-attribute.rs b/src/test/debuginfo/no-debug-attribute.rs
index 5b2045d59dc..f39e8ee2229 100644
--- a/src/test/debuginfo/no-debug-attribute.rs
+++ b/src/test/debuginfo/no-debug-attribute.rs
@@ -40,4 +40,3 @@ fn main() {
     function_without_debuginfo();
     function_with_debuginfo();
 }
-
diff --git a/src/test/debuginfo/recursive-struct.rs b/src/test/debuginfo/recursive-struct.rs
index 25afd3514b0..fe262a7ea8d 100644
--- a/src/test/debuginfo/recursive-struct.rs
+++ b/src/test/debuginfo/recursive-struct.rs
@@ -219,4 +219,3 @@ fn main() {
 }
 
 fn zzz() {()}
-
diff --git a/src/test/debuginfo/self-in-default-method.rs b/src/test/debuginfo/self-in-default-method.rs
index 03a79993342..008eeda92d0 100644
--- a/src/test/debuginfo/self-in-default-method.rs
+++ b/src/test/debuginfo/self-in-default-method.rs
@@ -150,4 +150,3 @@ fn main() {
 }
 
 fn zzz() {()}
-
diff --git a/src/test/debuginfo/self-in-generic-default-method.rs b/src/test/debuginfo/self-in-generic-default-method.rs
index 5869625bafe..94e5f6f6c10 100644
--- a/src/test/debuginfo/self-in-generic-default-method.rs
+++ b/src/test/debuginfo/self-in-generic-default-method.rs
@@ -151,4 +151,3 @@ fn main() {
 }
 
 fn zzz() {()}
-
diff --git a/src/test/parse-fail/ascii-only-character-escape.rs b/src/test/parse-fail/ascii-only-character-escape.rs
index 1ba25a827a5..bcfcc434703 100644
--- a/src/test/parse-fail/ascii-only-character-escape.rs
+++ b/src/test/parse-fail/ascii-only-character-escape.rs
@@ -14,4 +14,3 @@ fn main() {
     let z = "\xe2"; //~ ERROR may only be used
     let a = b"\x00e2";  // ok because byte literal
 }
-
diff --git a/src/test/parse-fail/byte-literals.rs b/src/test/parse-fail/byte-literals.rs
index 436078fa762..08935a24a1b 100644
--- a/src/test/parse-fail/byte-literals.rs
+++ b/src/test/parse-fail/byte-literals.rs
@@ -21,5 +21,3 @@ pub fn main() {
     b'é';  //~ ERROR byte constant must be ASCII
     b'a  //~ ERROR unterminated byte constant
 }
-
-
diff --git a/src/test/parse-fail/byte-string-literals.rs b/src/test/parse-fail/byte-string-literals.rs
index ec67cdd77e1..ee3d86a6638 100644
--- a/src/test/parse-fail/byte-string-literals.rs
+++ b/src/test/parse-fail/byte-string-literals.rs
@@ -19,5 +19,3 @@ pub fn main() {
     b"é";  //~ ERROR byte constant must be ASCII
     b"a  //~ ERROR unterminated double quote byte string
 }
-
-
diff --git a/src/test/parse-fail/column-offset-1-based.rs b/src/test/parse-fail/column-offset-1-based.rs
index 621b480fe77..a00ded61758 100644
--- a/src/test/parse-fail/column-offset-1-based.rs
+++ b/src/test/parse-fail/column-offset-1-based.rs
@@ -8,4 +8,4 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-# //~ ERROR 11:1: 11:2 error: expected one of `!` or `[`, found `<eof>`
+# //~ ERROR 11:1: 11:2 error: expected `[`, found `<eof>`
diff --git a/src/test/parse-fail/issue-10392-2.rs b/src/test/parse-fail/issue-10392-2.rs
index b077081c5b0..2a3dd7fba0c 100644
--- a/src/test/parse-fail/issue-10392-2.rs
+++ b/src/test/parse-fail/issue-10392-2.rs
@@ -15,4 +15,3 @@ fn a() -> A { panic!() }
 fn main() {
     let A { .., } = a(); //~ ERROR: expected `}`
 }
-
diff --git a/src/test/parse-fail/issue-1655.rs b/src/test/parse-fail/issue-1655.rs
index a8704f7545f..6bdcf5c5edc 100644
--- a/src/test/parse-fail/issue-1655.rs
+++ b/src/test/parse-fail/issue-1655.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern:expected one of `!` or `[`, found `vec`
+// error-pattern:expected `[`, found `vec`
 mod blade_runner {
     #vec[doc(
         brief = "Blade Runner is probably the best movie ever",
diff --git a/src/test/parse-fail/issue-17718-const-mut.rs b/src/test/parse-fail/issue-17718-const-mut.rs
index 5177ebbc188..b7feeecbfd9 100644
--- a/src/test/parse-fail/issue-17718-const-mut.rs
+++ b/src/test/parse-fail/issue-17718-const-mut.rs
@@ -15,4 +15,3 @@ FOO: usize = 3;
 
 fn main() {
 }
-
diff --git a/src/test/parse-fail/issue-20711-2.rs b/src/test/parse-fail/issue-20711-2.rs
index a6c4570c60f..a50a757160d 100644
--- a/src/test/parse-fail/issue-20711-2.rs
+++ b/src/test/parse-fail/issue-20711-2.rs
@@ -17,4 +17,3 @@ impl Foo {
 } //~ ERROR expected one of `extern`, `fn`, `pub`, `type`, or `unsafe`, found `}`
 
 fn main() {}
-
diff --git a/src/test/parse-fail/issue-2354-1.rs b/src/test/parse-fail/issue-2354-1.rs
index d37837b9714..48cdeeb0d70 100644
--- a/src/test/parse-fail/issue-2354-1.rs
+++ b/src/test/parse-fail/issue-2354-1.rs
@@ -9,4 +9,3 @@
 // except according to those terms.
 
 static foo: isize = 2; } //~ ERROR incorrect close delimiter:
-
diff --git a/src/test/parse-fail/keywords-followed-by-double-colon.rs b/src/test/parse-fail/keywords-followed-by-double-colon.rs
index f69b041597e..ba04a5ac9af 100644
--- a/src/test/parse-fail/keywords-followed-by-double-colon.rs
+++ b/src/test/parse-fail/keywords-followed-by-double-colon.rs
@@ -12,4 +12,3 @@ fn main() {
     struct::foo();  //~ ERROR expected identifier
     mut::baz(); //~ ERROR expected identifier
 }
-
diff --git a/src/test/parse-fail/macro-attribute.rs b/src/test/parse-fail/macro-attribute.rs
index 77ea0c9c4f3..52f867fe913 100644
--- a/src/test/parse-fail/macro-attribute.rs
+++ b/src/test/parse-fail/macro-attribute.rs
@@ -10,4 +10,3 @@
 
 #[doc = $not_there] //~ error: unexpected token: `$`
 fn main() { }
-
diff --git a/src/test/parse-fail/macros-no-semicolon.rs b/src/test/parse-fail/macros-no-semicolon.rs
index 0e85551e216..23b27b49a86 100644
--- a/src/test/parse-fail/macros-no-semicolon.rs
+++ b/src/test/parse-fail/macros-no-semicolon.rs
@@ -13,4 +13,3 @@ fn main() {
     assert!(3 == 4) //~ ERROR expected one of `.`, `;`, `}`, or an operator, found `assert`
     println!("hello");
 }
-
diff --git a/src/test/parse-fail/obsolete-proc.rs b/src/test/parse-fail/obsolete-proc.rs
index f1ed0be7640..4767c66c2a0 100644
--- a/src/test/parse-fail/obsolete-proc.rs
+++ b/src/test/parse-fail/obsolete-proc.rs
@@ -14,4 +14,4 @@ fn foo(p: proc()) { } //~ ERROR `proc` is a reserved keyword
 
 fn bar() { proc() 1; }
 
-fn main() { }
\ No newline at end of file
+fn main() { }
diff --git a/src/test/parse-fail/raw-byte-string-eof.rs b/src/test/parse-fail/raw-byte-string-eof.rs
index 83ea9db39b7..ccf9e2d8688 100644
--- a/src/test/parse-fail/raw-byte-string-eof.rs
+++ b/src/test/parse-fail/raw-byte-string-eof.rs
@@ -12,5 +12,3 @@
 pub fn main() {
     br##"a"#;  //~ unterminated raw string
 }
-
-
diff --git a/src/test/parse-fail/raw-byte-string-literals.rs b/src/test/parse-fail/raw-byte-string-literals.rs
index 7a3d1b2318a..d6073a10307 100644
--- a/src/test/parse-fail/raw-byte-string-literals.rs
+++ b/src/test/parse-fail/raw-byte-string-literals.rs
@@ -13,5 +13,3 @@ pub fn main() {
     br"é";  //~ raw byte string must be ASCII
     br##~"a"~##;  //~ only `#` is allowed in raw string delimitation
 }
-
-
diff --git a/src/test/parse-fail/struct-literal-in-for.rs b/src/test/parse-fail/struct-literal-in-for.rs
index 4bb5d5e6aa1..a6d4da526fb 100644
--- a/src/test/parse-fail/struct-literal-in-for.rs
+++ b/src/test/parse-fail/struct-literal-in-for.rs
@@ -25,4 +25,3 @@ fn main() {
         println!("yo");
     }
 }
-
diff --git a/src/test/parse-fail/struct-literal-in-if.rs b/src/test/parse-fail/struct-literal-in-if.rs
index b2bc8a4901f..00ece3fcca3 100644
--- a/src/test/parse-fail/struct-literal-in-if.rs
+++ b/src/test/parse-fail/struct-literal-in-if.rs
@@ -25,4 +25,3 @@ fn main() {
         println!("yo");
     }
 }
-
diff --git a/src/test/parse-fail/struct-literal-in-match-discriminant.rs b/src/test/parse-fail/struct-literal-in-match-discriminant.rs
index e6948b7c7c9..cdcf98a42f9 100644
--- a/src/test/parse-fail/struct-literal-in-match-discriminant.rs
+++ b/src/test/parse-fail/struct-literal-in-match-discriminant.rs
@@ -21,4 +21,3 @@ fn main() {
         } => {}
     }
 }
-
diff --git a/src/test/parse-fail/struct-literal-in-while.rs b/src/test/parse-fail/struct-literal-in-while.rs
index 05fa3a8dd5f..c23b5dbb9cc 100644
--- a/src/test/parse-fail/struct-literal-in-while.rs
+++ b/src/test/parse-fail/struct-literal-in-while.rs
@@ -25,4 +25,3 @@ fn main() {
         println!("yo");
     }
 }
-
diff --git a/src/test/parse-fail/type-parameters-in-field-exprs.rs b/src/test/parse-fail/type-parameters-in-field-exprs.rs
index 54ddb3e19fa..191bd782124 100644
--- a/src/test/parse-fail/type-parameters-in-field-exprs.rs
+++ b/src/test/parse-fail/type-parameters-in-field-exprs.rs
@@ -21,4 +21,3 @@ fn main() {
     f.x::<isize>;
     //~^ ERROR field expressions may not have type parameters
 }
-
diff --git a/src/test/parse-fail/unboxed-closure-sugar-used-on-struct-3.rs b/src/test/parse-fail/unboxed-closure-sugar-used-on-struct-3.rs
index d86f55d5368..de6291c7cc3 100644
--- a/src/test/parse-fail/unboxed-closure-sugar-used-on-struct-3.rs
+++ b/src/test/parse-fail/unboxed-closure-sugar-used-on-struct-3.rs
@@ -26,4 +26,3 @@ fn bar() {
 }
 
 fn main() { }
-
diff --git a/src/test/parse-fail/use-mod-4.rs b/src/test/parse-fail/use-mod-4.rs
index a8b551b5376..52d0d1a5fba 100644
--- a/src/test/parse-fail/use-mod-4.rs
+++ b/src/test/parse-fail/use-mod-4.rs
@@ -12,4 +12,3 @@ use foo::self;
 //~^ ERROR expected identifier, found keyword `self`
 
 fn main() {}
-
diff --git a/src/test/parse-fail/where-clauses-no-bounds-or-predicates.rs b/src/test/parse-fail/where-clauses-no-bounds-or-predicates.rs
index b96c7c2de6b..ebdbdc4b2b5 100644
--- a/src/test/parse-fail/where-clauses-no-bounds-or-predicates.rs
+++ b/src/test/parse-fail/where-clauses-no-bounds-or-predicates.rs
@@ -20,4 +20,3 @@ fn equal2<T>(_: &T, _: &T) -> bool where T: {
 
 fn main() {
 }
-
diff --git a/src/test/pretty/asm-clobbers.rs b/src/test/pretty/asm-clobbers.rs
index 20a3ac226bd..c72add8d3d6 100644
--- a/src/test/pretty/asm-clobbers.rs
+++ b/src/test/pretty/asm-clobbers.rs
@@ -11,4 +11,3 @@
 #![feature(asm)]
 
 pub fn main() { unsafe { asm!("" : : : "hello", "world") }; }
-
diff --git a/src/test/pretty/closure-reform-pretty.rs b/src/test/pretty/closure-reform-pretty.rs
index 094e3ce9156..33a80f46946 100644
--- a/src/test/pretty/closure-reform-pretty.rs
+++ b/src/test/pretty/closure-reform-pretty.rs
@@ -24,4 +24,3 @@ fn call_extern(f: fn() -> int) { }
 fn call_abid_extern(f: extern "C" fn() -> int) { }
 
 pub fn main() { }
-
diff --git a/src/test/pretty/path-type-bounds.rs b/src/test/pretty/path-type-bounds.rs
index 9e1f2aa8bfe..0a20300e4f4 100644
--- a/src/test/pretty/path-type-bounds.rs
+++ b/src/test/pretty/path-type-bounds.rs
@@ -23,4 +23,3 @@ fn main() {
 
     Box::new(1) as Box<Tr+ Sync>;
 }
-
diff --git a/src/test/pretty/where-clauses.rs b/src/test/pretty/where-clauses.rs
index 0f3b914334e..ad582ac1b62 100644
--- a/src/test/pretty/where-clauses.rs
+++ b/src/test/pretty/where-clauses.rs
@@ -13,4 +13,3 @@
 fn f<'a, 'b, T>(t: T) -> int where T: 'a, 'a:'b, T: Eq { 0 }
 
 fn main() { }
-
diff --git a/src/test/run-make/allow-non-lint-warnings-cmdline/Makefile b/src/test/run-make/allow-non-lint-warnings-cmdline/Makefile
index 961342591aa..c14006cc2e0 100644
--- a/src/test/run-make/allow-non-lint-warnings-cmdline/Makefile
+++ b/src/test/run-make/allow-non-lint-warnings-cmdline/Makefile
@@ -9,4 +9,3 @@ all: foo
 # This is just to make sure the above command actually succeeds
 foo:
 	$(RUSTC) foo.rs -A warnings
-
diff --git a/src/test/run-make/allow-warnings-cmdline-stability/Makefile b/src/test/run-make/allow-warnings-cmdline-stability/Makefile
index 64b7f58caea..3eecaf93142 100644
--- a/src/test/run-make/allow-warnings-cmdline-stability/Makefile
+++ b/src/test/run-make/allow-warnings-cmdline-stability/Makefile
@@ -13,7 +13,3 @@ bar:
 
 foo: bar
 	$(RUSTC) foo.rs -A warnings
-
-
-
-
diff --git a/src/test/run-make/compiler-lookup-paths/c.rs b/src/test/run-make/compiler-lookup-paths/c.rs
index 8a801d589fb..b5c54558a4f 100644
--- a/src/test/run-make/compiler-lookup-paths/c.rs
+++ b/src/test/run-make/compiler-lookup-paths/c.rs
@@ -10,4 +10,3 @@
 
 #![crate_type = "lib"]
 extern crate b;
-
diff --git a/src/test/run-make/crate-name-priority/foo1.rs b/src/test/run-make/crate-name-priority/foo1.rs
index 0f02f100572..a397d6bc749 100644
--- a/src/test/run-make/crate-name-priority/foo1.rs
+++ b/src/test/run-make/crate-name-priority/foo1.rs
@@ -11,4 +11,3 @@
 #![crate_name = "foo"]
 
 fn main() {}
-
diff --git a/src/test/run-make/extern-flag-disambiguates/Makefile b/src/test/run-make/extern-flag-disambiguates/Makefile
index 049b76c1b64..81930e969a9 100644
--- a/src/test/run-make/extern-flag-disambiguates/Makefile
+++ b/src/test/run-make/extern-flag-disambiguates/Makefile
@@ -23,4 +23,3 @@ all:
 	@echo after
 	$(RUSTC) --cfg after  d.rs --extern a=$(TMPDIR)/liba-1.rlib
 	$(call RUN,d)
-
diff --git a/src/test/run-make/extern-flag-fun/bar.rs b/src/test/run-make/extern-flag-fun/bar.rs
index 2152aa79c33..e6c76025738 100644
--- a/src/test/run-make/extern-flag-fun/bar.rs
+++ b/src/test/run-make/extern-flag-fun/bar.rs
@@ -7,4 +7,3 @@
 // <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.
-
diff --git a/src/test/run-make/extern-overrides-distribution/main.rs b/src/test/run-make/extern-overrides-distribution/main.rs
index 92b353c892a..451841e7368 100644
--- a/src/test/run-make/extern-overrides-distribution/main.rs
+++ b/src/test/run-make/extern-overrides-distribution/main.rs
@@ -13,4 +13,3 @@ extern crate libc;
 fn main() {
     libc::foo();
 }
-
diff --git a/src/test/run-make/interdependent-c-libraries/Makefile b/src/test/run-make/interdependent-c-libraries/Makefile
index 7654917b462..cf7683479f0 100644
--- a/src/test/run-make/interdependent-c-libraries/Makefile
+++ b/src/test/run-make/interdependent-c-libraries/Makefile
@@ -12,4 +12,3 @@ all: $(call STATICLIB,foo) $(call STATICLIB,bar)
 	$(RUSTC) foo.rs
 	$(RUSTC) bar.rs
 	$(RUSTC) main.rs -Z print-link-args
-
diff --git a/src/test/run-make/interdependent-c-libraries/bar.rs b/src/test/run-make/interdependent-c-libraries/bar.rs
index 5311af2959b..88fc98615f0 100644
--- a/src/test/run-make/interdependent-c-libraries/bar.rs
+++ b/src/test/run-make/interdependent-c-libraries/bar.rs
@@ -20,4 +20,3 @@ extern {
 pub fn doit() {
     unsafe { bar(); }
 }
-
diff --git a/src/test/run-make/issue-14500/Makefile b/src/test/run-make/issue-14500/Makefile
index 446c6e5c81b..c19d3d5c30f 100644
--- a/src/test/run-make/issue-14500/Makefile
+++ b/src/test/run-make/issue-14500/Makefile
@@ -11,4 +11,3 @@ all:
 	$(RUSTC) bar.rs --crate-type=staticlib -C lto -L. -o $(TMPDIR)/libbar.a
 	$(CC) foo.c -lbar -o $(call RUN_BINFILE,foo) $(EXTRACFLAGS)
 	$(call RUN,foo)
-
diff --git a/src/test/run-make/libs-and-bins/Makefile b/src/test/run-make/libs-and-bins/Makefile
index 4d975d2f717..cc3b257a5c5 100644
--- a/src/test/run-make/libs-and-bins/Makefile
+++ b/src/test/run-make/libs-and-bins/Makefile
@@ -4,4 +4,3 @@ all:
 	$(RUSTC) foo.rs
 	$(call RUN,foo)
 	rm $(TMPDIR)/$(call DYLIB_GLOB,foo)
-
diff --git a/src/test/run-make/link-path-order/Makefile b/src/test/run-make/link-path-order/Makefile
index b8ebe6db6fd..116c7ae991c 100644
--- a/src/test/run-make/link-path-order/Makefile
+++ b/src/test/run-make/link-path-order/Makefile
@@ -14,4 +14,3 @@ all: $(TMPDIR)/libcorrect.a $(TMPDIR)/libwrong.a
 	$(call RUN,should_succeed)
 	$(RUSTC) main.rs -o $(TMPDIR)/should_fail -L $(WRONG_DIR) -L $(CORRECT_DIR)
 	$(call FAIL,should_fail)
-
diff --git a/src/test/run-make/linkage-attr-on-static/Makefile b/src/test/run-make/linkage-attr-on-static/Makefile
index 6bcde96335c..1871a5bbdc7 100644
--- a/src/test/run-make/linkage-attr-on-static/Makefile
+++ b/src/test/run-make/linkage-attr-on-static/Makefile
@@ -5,4 +5,3 @@ all:
 	$(AR) rcs $(TMPDIR)/libfoo.a $(TMPDIR)/foo.o
 	$(RUSTC) bar.rs -lfoo -L $(TMPDIR)
 	$(call RUN,bar) || exit 1
-
diff --git a/src/test/run-make/manual-link/Makefile b/src/test/run-make/manual-link/Makefile
index d0536956152..dccf0d99b0f 100644
--- a/src/test/run-make/manual-link/Makefile
+++ b/src/test/run-make/manual-link/Makefile
@@ -4,4 +4,3 @@ all: $(TMPDIR)/libbar.a
 	$(RUSTC) foo.rs -lstatic=bar
 	$(RUSTC) main.rs
 	$(call RUN,main)
-
diff --git a/src/test/run-make/many-crates-but-no-match/Makefile b/src/test/run-make/many-crates-but-no-match/Makefile
index da5fc78f328..edf8e9df465 100644
--- a/src/test/run-make/many-crates-but-no-match/Makefile
+++ b/src/test/run-make/many-crates-but-no-match/Makefile
@@ -16,7 +16,7 @@ A3=$(TMPDIR)/a3
 # A hack to match distinct lines of output from a single run.
 LOG=$(TMPDIR)/log.txt
 
-all: 
+all:
 	mkdir -p $(A1) $(A2) $(A3)
 	$(RUSTC) --crate-type=rlib crateA1.rs
 	mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A1)
diff --git a/src/test/run-make/missing-crate-dependency/Makefile b/src/test/run-make/missing-crate-dependency/Makefile
index 3f8b97f2566..275658047d3 100644
--- a/src/test/run-make/missing-crate-dependency/Makefile
+++ b/src/test/run-make/missing-crate-dependency/Makefile
@@ -1,6 +1,6 @@
 -include ../tools.mk
 
-all: 
+all:
 	$(RUSTC) --crate-type=rlib crateA.rs
 	$(RUSTC) --crate-type=rlib crateB.rs
 	$(call REMOVE_RLIBS,crateA)
diff --git a/src/test/run-make/mixing-formats/baz2.rs b/src/test/run-make/mixing-formats/baz2.rs
index 4cfa65330bd..c5066ccd656 100644
--- a/src/test/run-make/mixing-formats/baz2.rs
+++ b/src/test/run-make/mixing-formats/baz2.rs
@@ -12,4 +12,3 @@ extern crate bar1;
 extern crate bar2;
 
 fn main() {}
-
diff --git a/src/test/run-make/obey-crate-type-flag/test.rs b/src/test/run-make/obey-crate-type-flag/test.rs
index 8eb82b48eac..e6c8b8eb179 100644
--- a/src/test/run-make/obey-crate-type-flag/test.rs
+++ b/src/test/run-make/obey-crate-type-flag/test.rs
@@ -10,4 +10,3 @@
 
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
-
diff --git a/src/test/run-make/rustdoc-default-impl/bar.rs b/src/test/run-make/rustdoc-default-impl/bar.rs
index c9fae80d858..60a2f7202f8 100644
--- a/src/test/run-make/rustdoc-default-impl/bar.rs
+++ b/src/test/run-make/rustdoc-default-impl/bar.rs
@@ -14,4 +14,3 @@ pub use foo::bar;
 
 pub fn wut<T: bar::Bar>() {
 }
-
diff --git a/src/test/run-make/rustdoc-extern-method/Makefile b/src/test/run-make/rustdoc-extern-method/Makefile
index c87684f59ea..55cbd2da6ae 100644
--- a/src/test/run-make/rustdoc-extern-method/Makefile
+++ b/src/test/run-make/rustdoc-extern-method/Makefile
@@ -5,4 +5,3 @@ all: foo.rs bar.rs
 	$(HOST_RPATH_ENV) $(RUSTDOC) -w html -o $(TMPDIR)/doc foo.rs
 	$(HOST_RPATH_ENV) $(RUSTDOC) -L $(TMPDIR) -w html -o $(TMPDIR)/doc bar.rs
 	$(HTMLDOCCK) $(TMPDIR)/doc bar.rs
-
diff --git a/src/test/run-make/rustdoc-negative-impl/Makefile b/src/test/run-make/rustdoc-negative-impl/Makefile
index 1316ee256e1..c1b1683efdb 100644
--- a/src/test/run-make/rustdoc-negative-impl/Makefile
+++ b/src/test/run-make/rustdoc-negative-impl/Makefile
@@ -3,4 +3,3 @@
 all: foo.rs
 	$(HOST_RPATH_ENV) $(RUSTDOC) -w html -o $(TMPDIR)/doc foo.rs
 	$(HTMLDOCCK) $(TMPDIR)/doc foo.rs
-
diff --git a/src/test/run-make/rustdoc-recursion/Makefile b/src/test/run-make/rustdoc-recursion/Makefile
index b7fc6d6c0ad..ba971836e5a 100644
--- a/src/test/run-make/rustdoc-recursion/Makefile
+++ b/src/test/run-make/rustdoc-recursion/Makefile
@@ -9,4 +9,3 @@ all:
 else
 all:
 endif
-
diff --git a/src/test/run-make/rustdoc-recursion/foo.rs b/src/test/run-make/rustdoc-recursion/foo.rs
index 29a909f139e..7505d20566d 100644
--- a/src/test/run-make/rustdoc-recursion/foo.rs
+++ b/src/test/run-make/rustdoc-recursion/foo.rs
@@ -22,4 +22,3 @@ mod m {
         pub use super::*;
     }
 }
-
diff --git a/src/test/run-make/rustdoc-viewpath-self/Makefile b/src/test/run-make/rustdoc-viewpath-self/Makefile
index 1316ee256e1..c1b1683efdb 100644
--- a/src/test/run-make/rustdoc-viewpath-self/Makefile
+++ b/src/test/run-make/rustdoc-viewpath-self/Makefile
@@ -3,4 +3,3 @@
 all: foo.rs
 	$(HOST_RPATH_ENV) $(RUSTDOC) -w html -o $(TMPDIR)/doc foo.rs
 	$(HTMLDOCCK) $(TMPDIR)/doc foo.rs
-
diff --git a/src/test/run-make/rustdoc-where/Makefile b/src/test/run-make/rustdoc-where/Makefile
index 1316ee256e1..c1b1683efdb 100644
--- a/src/test/run-make/rustdoc-where/Makefile
+++ b/src/test/run-make/rustdoc-where/Makefile
@@ -3,4 +3,3 @@
 all: foo.rs
 	$(HOST_RPATH_ENV) $(RUSTDOC) -w html -o $(TMPDIR)/doc foo.rs
 	$(HTMLDOCCK) $(TMPDIR)/doc foo.rs
-
diff --git a/src/test/run-make/tools.mk b/src/test/run-make/tools.mk
index 23c422bc7a7..7b604bedfd0 100644
--- a/src/test/run-make/tools.mk
+++ b/src/test/run-make/tools.mk
@@ -83,4 +83,3 @@ REMOVE_RLIBS      = rm $(TMPDIR)/$(call RLIB_GLOB,$(1))
 
 $(TMPDIR)/lib%.o: %.c
 	$(CC) -c -o $@ $<
-
diff --git a/src/test/run-pass-fulldeps/compiler-calls.rs b/src/test/run-pass-fulldeps/compiler-calls.rs
index 75a968c3f81..8492424a145 100644
--- a/src/test/run-pass-fulldeps/compiler-calls.rs
+++ b/src/test/run-pass-fulldeps/compiler-calls.rs
@@ -80,4 +80,3 @@ fn main() {
     rustc_driver::run_compiler(args.as_slice(), &mut tc);
     assert!(tc.count == 30);
 }
-
diff --git a/src/test/run-pass-fulldeps/quote-tokens.rs b/src/test/run-pass-fulldeps/quote-tokens.rs
index 7f7ed586878..020f5f562d2 100644
--- a/src/test/run-pass-fulldeps/quote-tokens.rs
+++ b/src/test/run-pass-fulldeps/quote-tokens.rs
@@ -25,7 +25,7 @@ fn syntax_extension(cx: &ExtCtxt) {
     let a: P<syntax::ast::Expr> = quote_expr!(cx, 1 + 2);
     let _b: Option<P<syntax::ast::Item>> = quote_item!(cx, static foo : int = $e_toks; );
     let _c: P<syntax::ast::Pat> = quote_pat!(cx, (x, 1 .. 4, *) );
-    let _d: P<syntax::ast::Stmt> = quote_stmt!(cx, let x = $a; );
+    let _d: Option<P<syntax::ast::Stmt>> = quote_stmt!(cx, let x = $a; );
     let _d: syntax::ast::Arm = quote_arm!(cx, (ref x, ref y) = (x, y) );
     let _e: P<syntax::ast::Expr> = quote_expr!(cx, match foo { $p_toks => 10 } );
 
diff --git a/src/test/run-pass-valgrind/cleanup-auto-borrow-obj.rs b/src/test/run-pass-valgrind/cleanup-auto-borrow-obj.rs
index aecec44f6fd..0bbb9ed1285 100644
--- a/src/test/run-pass-valgrind/cleanup-auto-borrow-obj.rs
+++ b/src/test/run-pass-valgrind/cleanup-auto-borrow-obj.rs
@@ -36,4 +36,3 @@ pub fn main() {
         assert!(DROP_RAN);
     }
 }
-
diff --git a/src/test/run-pass/as-precedence.rs b/src/test/run-pass/as-precedence.rs
index 0760f13200c..de294f88a4c 100644
--- a/src/test/run-pass/as-precedence.rs
+++ b/src/test/run-pass/as-precedence.rs
@@ -15,4 +15,3 @@ fn main() {
     assert_eq!(3 as uint + 3, 6);
     assert_eq!(3 as (uint) + 3, 6);
 }
-
diff --git a/src/test/run-pass/backtrace-debuginfo-aux.rs b/src/test/run-pass/backtrace-debuginfo-aux.rs
index 074ee97c37a..f0d36ea976e 100644
--- a/src/test/run-pass/backtrace-debuginfo-aux.rs
+++ b/src/test/run-pass/backtrace-debuginfo-aux.rs
@@ -19,4 +19,3 @@ pub fn callback<F>(f: F) where F: FnOnce((&'static str, u32)) {
 pub fn callback_inlined<F>(f: F) where F: FnOnce((&'static str, u32)) {
     f((file!(), line!()))
 }
-
diff --git a/src/test/run-pass/backtrace-debuginfo.rs b/src/test/run-pass/backtrace-debuginfo.rs
index 23aadbc7053..088fa19356c 100644
--- a/src/test/run-pass/backtrace-debuginfo.rs
+++ b/src/test/run-pass/backtrace-debuginfo.rs
@@ -157,4 +157,3 @@ fn main() {
         run_test(&args[0]);
     }
 }
-
diff --git a/src/test/run-pass/bare-fn-implements-fn-mut.rs b/src/test/run-pass/bare-fn-implements-fn-mut.rs
index 758776298e1..e8118e90a9f 100644
--- a/src/test/run-pass/bare-fn-implements-fn-mut.rs
+++ b/src/test/run-pass/bare-fn-implements-fn-mut.rs
@@ -35,4 +35,3 @@ fn main() {
     assert_eq!(call_g(g, "foo".to_string(), "bar".to_string()),
                "foobar");
 }
-
diff --git a/src/test/run-pass/bitv-perf-test.rs b/src/test/run-pass/bitv-perf-test.rs
index 24bfbd9eb44..e6982949501 100644
--- a/src/test/run-pass/bitv-perf-test.rs
+++ b/src/test/run-pass/bitv-perf-test.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/borrowck-field-sensitivity.rs b/src/test/run-pass/borrowck-field-sensitivity.rs
index 89d80190042..533445052ae 100644
--- a/src/test/run-pass/borrowck-field-sensitivity.rs
+++ b/src/test/run-pass/borrowck-field-sensitivity.rs
@@ -270,4 +270,3 @@ fn main() {
     borrow_after_assign_after_uninit();
     move_after_assign_after_uninit();
 }
-
diff --git a/src/test/run-pass/borrowck-move-by-capture-ok.rs b/src/test/run-pass/borrowck-move-by-capture-ok.rs
index 27fbfc96410..269063bbd05 100644
--- a/src/test/run-pass/borrowck-move-by-capture-ok.rs
+++ b/src/test/run-pass/borrowck-move-by-capture-ok.rs
@@ -17,4 +17,3 @@ pub fn main() {
     let h = || -> int *bar;
     assert_eq!(h(), 3);
 }
-
diff --git a/src/test/run-pass/borrowck-use-mut-borrow.rs b/src/test/run-pass/borrowck-use-mut-borrow.rs
index 7be12ff3cc9..4b69e554cda 100644
--- a/src/test/run-pass/borrowck-use-mut-borrow.rs
+++ b/src/test/run-pass/borrowck-use-mut-borrow.rs
@@ -57,4 +57,3 @@ fn main() {
     field_move_after_field_borrow();
     fu_field_move_after_field_borrow();
 }
-
diff --git a/src/test/run-pass/can-copy-pod.rs b/src/test/run-pass/can-copy-pod.rs
index 099374b5937..9c8bc5411ef 100644
--- a/src/test/run-pass/can-copy-pod.rs
+++ b/src/test/run-pass/can-copy-pod.rs
@@ -21,5 +21,3 @@ fn can_copy_copy<T:Copy>(v: T) {
 }
 
 pub fn main() {}
-
-
diff --git a/src/test/run-pass/capture-clauses-boxed-closures.rs b/src/test/run-pass/capture-clauses-boxed-closures.rs
index 1a85797fa6d..6518df11517 100644
--- a/src/test/run-pass/capture-clauses-boxed-closures.rs
+++ b/src/test/run-pass/capture-clauses-boxed-closures.rs
@@ -20,4 +20,3 @@ fn main() {
     each(&elems, |val| sum += *val);
     assert_eq!(sum, 15);
 }
-
diff --git a/src/test/run-pass/class-exports.rs b/src/test/run-pass/class-exports.rs
index 1cf4c35ee96..a3f857ab4b0 100644
--- a/src/test/run-pass/class-exports.rs
+++ b/src/test/run-pass/class-exports.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/cleanup-arm-conditional.rs b/src/test/run-pass/cleanup-arm-conditional.rs
index 0d155ae085c..cb152f1c64e 100644
--- a/src/test/run-pass/cleanup-arm-conditional.rs
+++ b/src/test/run-pass/cleanup-arm-conditional.rs
@@ -52,4 +52,3 @@ pub fn main() {
     let t = Test { x: 1 };
     do_something(&t);
 }
-
diff --git a/src/test/run-pass/cleanup-shortcircuit.rs b/src/test/run-pass/cleanup-shortcircuit.rs
index 59f63a79c3d..4466dda6c69 100644
--- a/src/test/run-pass/cleanup-shortcircuit.rs
+++ b/src/test/run-pass/cleanup-shortcircuit.rs
@@ -36,4 +36,3 @@ pub fn main() {
         unsafe { *(0 as *mut int) = 0; }
     }
 }
-
diff --git a/src/test/run-pass/closure-reform.rs b/src/test/run-pass/closure-reform.rs
index a4495c3c68e..af64553b913 100644
--- a/src/test/run-pass/closure-reform.rs
+++ b/src/test/run-pass/closure-reform.rs
@@ -66,4 +66,3 @@ pub fn main() {
 
     call_bare_again(println);
 }
-
diff --git a/src/test/run-pass/conditional-compile.rs b/src/test/run-pass/conditional-compile.rs
index 178fc3dcd4f..f77be4d9c06 100644
--- a/src/test/run-pass/conditional-compile.rs
+++ b/src/test/run-pass/conditional-compile.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/deriving-meta-multiple.rs b/src/test/run-pass/deriving-meta-multiple.rs
index 62ec2f8e590..3164021a72e 100644
--- a/src/test/run-pass/deriving-meta-multiple.rs
+++ b/src/test/run-pass/deriving-meta-multiple.rs
@@ -1,4 +1,3 @@
-
 // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
diff --git a/src/test/run-pass/deriving-meta.rs b/src/test/run-pass/deriving-meta.rs
index 82cf9db3232..16df6e7004f 100644
--- a/src/test/run-pass/deriving-meta.rs
+++ b/src/test/run-pass/deriving-meta.rs
@@ -1,4 +1,3 @@
-
 // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
diff --git a/src/test/run-pass/deriving-via-extension-hash-enum.rs b/src/test/run-pass/deriving-via-extension-hash-enum.rs
index 10bd1b29444..2d6997341fb 100644
--- a/src/test/run-pass/deriving-via-extension-hash-enum.rs
+++ b/src/test/run-pass/deriving-via-extension-hash-enum.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/deriving-via-extension-hash-struct.rs b/src/test/run-pass/deriving-via-extension-hash-struct.rs
index 19809def9a1..448d5bfd4cb 100644
--- a/src/test/run-pass/deriving-via-extension-hash-struct.rs
+++ b/src/test/run-pass/deriving-via-extension-hash-struct.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/deriving-via-extension-type-params.rs b/src/test/run-pass/deriving-via-extension-type-params.rs
index 890b4e69783..1a31743b4c0 100644
--- a/src/test/run-pass/deriving-via-extension-type-params.rs
+++ b/src/test/run-pass/deriving-via-extension-type-params.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/drop-with-type-ascription-1.rs b/src/test/run-pass/drop-with-type-ascription-1.rs
index f9fcf8ced28..4f1fc91a53c 100644
--- a/src/test/run-pass/drop-with-type-ascription-1.rs
+++ b/src/test/run-pass/drop-with-type-ascription-1.rs
@@ -14,4 +14,3 @@ fn main() {
     let invalid_string = &foo[0];
     assert_eq!(*invalid_string, "hello");
 }
-
diff --git a/src/test/run-pass/drop-with-type-ascription-2.rs b/src/test/run-pass/drop-with-type-ascription-2.rs
index f3d79f0c7d5..ec8de2a709e 100644
--- a/src/test/run-pass/drop-with-type-ascription-2.rs
+++ b/src/test/run-pass/drop-with-type-ascription-2.rs
@@ -14,4 +14,3 @@ fn main() {
     assert_eq!(arr[0], "asdf");
     assert_eq!(arr[0], "asdf");
 }
-
diff --git a/src/test/run-pass/duplicated-external-mods.rs b/src/test/run-pass/duplicated-external-mods.rs
index 65e2b178abf..f7b1cef83ea 100644
--- a/src/test/run-pass/duplicated-external-mods.rs
+++ b/src/test/run-pass/duplicated-external-mods.rs
@@ -13,4 +13,3 @@
 extern crate anonexternmod;
 
 pub fn main() { }
-
diff --git a/src/test/run-pass/export-multi.rs b/src/test/run-pass/export-multi.rs
index 2e44bf5be5b..09e816cff0b 100644
--- a/src/test/run-pass/export-multi.rs
+++ b/src/test/run-pass/export-multi.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/export-non-interference3.rs b/src/test/run-pass/export-non-interference3.rs
index 091c389840a..b7ef4df7ed6 100644
--- a/src/test/run-pass/export-non-interference3.rs
+++ b/src/test/run-pass/export-non-interference3.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/extern-compare-with-return-type.rs b/src/test/run-pass/extern-compare-with-return-type.rs
index 3febff18704..612b6ee14e1 100644
--- a/src/test/run-pass/extern-compare-with-return-type.rs
+++ b/src/test/run-pass/extern-compare-with-return-type.rs
@@ -31,4 +31,3 @@ pub fn main() {
     assert!(uintuintuintuintret as uintuintuintuintret ==
             uintuintuintuintret as uintuintuintuintret);
 }
-
diff --git a/src/test/run-pass/extern-mod-syntax.rs b/src/test/run-pass/extern-mod-syntax.rs
index 3e430b6e728..4d4f5036fc1 100644
--- a/src/test/run-pass/extern-mod-syntax.rs
+++ b/src/test/run-pass/extern-mod-syntax.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/for-loop-goofiness.rs b/src/test/run-pass/for-loop-goofiness.rs
index 7754751120e..84218befcd8 100644
--- a/src/test/run-pass/for-loop-goofiness.rs
+++ b/src/test/run-pass/for-loop-goofiness.rs
@@ -21,4 +21,3 @@ pub fn main() {
         assert_eq!(*i, 3);
     }
 }
-
diff --git a/src/test/run-pass/format-nan.rs b/src/test/run-pass/format-nan.rs
index 1024bc21d2b..9670d2de3ef 100644
--- a/src/test/run-pass/format-nan.rs
+++ b/src/test/run-pass/format-nan.rs
@@ -15,4 +15,3 @@ pub fn main() {
     assert_eq!(format!("{:e}", f64::NAN), x);
     assert_eq!(format!("{:E}", f64::NAN), x);
 }
-
diff --git a/src/test/run-pass/import-from.rs b/src/test/run-pass/import-from.rs
index bbf914411fd..38602bef229 100644
--- a/src/test/run-pass/import-from.rs
+++ b/src/test/run-pass/import-from.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/import-trailing-comma.rs b/src/test/run-pass/import-trailing-comma.rs
index 42a90b3e39a..b46f81479bf 100644
--- a/src/test/run-pass/import-trailing-comma.rs
+++ b/src/test/run-pass/import-trailing-comma.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/import2.rs b/src/test/run-pass/import2.rs
index d684c30aca1..4086acc0a8e 100644
--- a/src/test/run-pass/import2.rs
+++ b/src/test/run-pass/import2.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/import3.rs b/src/test/run-pass/import3.rs
index 4a3358488d8..2c09eff7b12 100644
--- a/src/test/run-pass/import3.rs
+++ b/src/test/run-pass/import3.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/import4.rs b/src/test/run-pass/import4.rs
index 44f6b6140fb..229813ff55c 100644
--- a/src/test/run-pass/import4.rs
+++ b/src/test/run-pass/import4.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/import5.rs b/src/test/run-pass/import5.rs
index 18cc1aa0848..0cad094d55d 100644
--- a/src/test/run-pass/import5.rs
+++ b/src/test/run-pass/import5.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/import6.rs b/src/test/run-pass/import6.rs
index 802dfc1f2ed..545bd7cee5e 100644
--- a/src/test/run-pass/import6.rs
+++ b/src/test/run-pass/import6.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/import7.rs b/src/test/run-pass/import7.rs
index 15e935c8f4f..4b9d1328951 100644
--- a/src/test/run-pass/import7.rs
+++ b/src/test/run-pass/import7.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/import8.rs b/src/test/run-pass/import8.rs
index 119107404d7..532c3843284 100644
--- a/src/test/run-pass/import8.rs
+++ b/src/test/run-pass/import8.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/inherent-trait-method-order.rs b/src/test/run-pass/inherent-trait-method-order.rs
index 6643636c570..9674c86b379 100644
--- a/src/test/run-pass/inherent-trait-method-order.rs
+++ b/src/test/run-pass/inherent-trait-method-order.rs
@@ -31,4 +31,3 @@ fn main() {
     let x = &(&(&Foo));
     x.foo();
 }
-
diff --git a/src/test/run-pass/integer-literal-suffix-inference-2.rs b/src/test/run-pass/integer-literal-suffix-inference-2.rs
index 05973a545a2..77e7ee62643 100644
--- a/src/test/run-pass/integer-literal-suffix-inference-2.rs
+++ b/src/test/run-pass/integer-literal-suffix-inference-2.rs
@@ -14,4 +14,3 @@ fn main() {
     let a = 3;
     foo(&a as *const _ as *const ());
 }
-
diff --git a/src/test/run-pass/integer-literal-suffix-inference-3.rs b/src/test/run-pass/integer-literal-suffix-inference-3.rs
index 05b275a0d8c..31aca964def 100644
--- a/src/test/run-pass/integer-literal-suffix-inference-3.rs
+++ b/src/test/run-pass/integer-literal-suffix-inference-3.rs
@@ -11,4 +11,3 @@
 fn main() {
     println!("{}", std::mem::size_of_val(&1));
 }
-
diff --git a/src/test/run-pass/intrinsic-assume.rs b/src/test/run-pass/intrinsic-assume.rs
index abf9b94c59d..837c2d21513 100644
--- a/src/test/run-pass/intrinsic-assume.rs
+++ b/src/test/run-pass/intrinsic-assume.rs
@@ -22,4 +22,3 @@ fn main() {
     let x = unsafe { f(34) };
     assert_eq!(x, 42);
 }
-
diff --git a/src/test/run-pass/intrinsic-return-address.rs b/src/test/run-pass/intrinsic-return-address.rs
index 91af669340d..99578abed38 100644
--- a/src/test/run-pass/intrinsic-return-address.rs
+++ b/src/test/run-pass/intrinsic-return-address.rs
@@ -40,4 +40,3 @@ fn main() {
     let actual_address = &pt as *const Point as uint;
     assert_eq!(intrinsic_reported_address, actual_address);
 }
-
diff --git a/src/test/run-pass/intrinsics-math.rs b/src/test/run-pass/intrinsics-math.rs
index ab65f35dd34..028b2bfb0ec 100644
--- a/src/test/run-pass/intrinsics-math.rs
+++ b/src/test/run-pass/intrinsics-math.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/issue-11736.rs b/src/test/run-pass/issue-11736.rs
index b09d516dd35..c6e0a5be763 100644
--- a/src/test/run-pass/issue-11736.rs
+++ b/src/test/run-pass/issue-11736.rs
@@ -32,4 +32,3 @@ fn main() {
         }
     }
 }
-
diff --git a/src/test/run-pass/issue-11820.rs b/src/test/run-pass/issue-11820.rs
new file mode 100644
index 00000000000..f7aaf495377
--- /dev/null
+++ b/src/test/run-pass/issue-11820.rs
@@ -0,0 +1,19 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+struct NoClone;
+
+fn main() {
+  let rnc = &NoClone;
+  let rsnc = &Some(NoClone);
+
+  let _: &NoClone = rnc.clone();
+  let _: &Option<NoClone> = rsnc.clone();
+}
diff --git a/src/test/run-pass/issue-12729.rs b/src/test/run-pass/issue-12729.rs
index 09c0c8604ad..9bf4c94d7e3 100644
--- a/src/test/run-pass/issue-12729.rs
+++ b/src/test/run-pass/issue-12729.rs
@@ -18,4 +18,3 @@ mod bar {
     }
 }
 fn main() {}
-
diff --git a/src/test/run-pass/issue-14421.rs b/src/test/run-pass/issue-14421.rs
index c595f98cd0e..4bdf5a31c71 100644
--- a/src/test/run-pass/issue-14421.rs
+++ b/src/test/run-pass/issue-14421.rs
@@ -19,4 +19,3 @@ pub fn main() {
     let mut an_A: B = make();
     an_A.foo();
 }
-
diff --git a/src/test/run-pass/issue-15155.rs b/src/test/run-pass/issue-15155.rs
index 3a63e63355c..e1ecaaab026 100644
--- a/src/test/run-pass/issue-15155.rs
+++ b/src/test/run-pass/issue-15155.rs
@@ -28,5 +28,3 @@ fn main() {
     test_trait::<TraitWithSend>();
     test_trait::<IndirectTraitWithSend>();
 }
-
-
diff --git a/src/test/run-pass/issue-15221.rs b/src/test/run-pass/issue-15221.rs
index 49e5b14aff8..6310ce39d99 100644
--- a/src/test/run-pass/issue-15221.rs
+++ b/src/test/run-pass/issue-15221.rs
@@ -20,4 +20,3 @@ fn main() {
     let outer!(g1) = 13;
     g1;
 }
-
diff --git a/src/test/run-pass/issue-16151.rs b/src/test/run-pass/issue-16151.rs
index 5401d6a6fdc..60d5ea8c84c 100644
--- a/src/test/run-pass/issue-16151.rs
+++ b/src/test/run-pass/issue-16151.rs
@@ -35,4 +35,3 @@ fn main() {
         assert_eq!(DROP_COUNT, 3);
     }
 }
-
diff --git a/src/test/run-pass/issue-16278.rs b/src/test/run-pass/issue-16278.rs
index ade312da21b..41af72db200 100644
--- a/src/test/run-pass/issue-16278.rs
+++ b/src/test/run-pass/issue-16278.rs
@@ -17,4 +17,3 @@ fn main() {assert_eq!(b"", b"\
 assert_eq!(b"\n", b"
 ");
 }
-
diff --git a/src/test/run-pass/issue-16452.rs b/src/test/run-pass/issue-16452.rs
index da480207490..f89dbfd2da9 100644
--- a/src/test/run-pass/issue-16452.rs
+++ b/src/test/run-pass/issue-16452.rs
@@ -14,4 +14,3 @@ fn main() {
         () => { static MAGIC: uint = 0; }
     }
 }
-
diff --git a/src/test/run-pass/issue-16597.rs b/src/test/run-pass/issue-16597.rs
index 72e948e613b..d074095dbde 100644
--- a/src/test/run-pass/issue-16597.rs
+++ b/src/test/run-pass/issue-16597.rs
@@ -15,5 +15,5 @@ mod test {
     use super::*;
 
     #[test]
-    fn test(){}
+    pub fn test(){}
 }
diff --git a/src/test/run-pass/issue-16922.rs b/src/test/run-pass/issue-16922.rs
new file mode 100644
index 00000000000..25909bcbfe9
--- /dev/null
+++ b/src/test/run-pass/issue-16922.rs
@@ -0,0 +1,18 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::any::Any;
+
+fn foo(_: &u8) {
+}
+
+fn main() {
+    let _ = &foo as &Any;
+}
diff --git a/src/test/run-pass/issue-19982.rs b/src/test/run-pass/issue-19982.rs
new file mode 100644
index 00000000000..3082fc27a7d
--- /dev/null
+++ b/src/test/run-pass/issue-19982.rs
@@ -0,0 +1,22 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(core,unboxed_closures)]
+
+#[allow(dead_code)]
+struct Foo;
+
+impl<'a> Fn<(&'a (),)> for Foo {
+    type Output = ();
+
+    extern "rust-call" fn call(&self, (_,): (&(),)) {}
+}
+
+fn main() {}
diff --git a/src/test/run-pass/issue-20396.rs b/src/test/run-pass/issue-20396.rs
new file mode 100644
index 00000000000..63a88988162
--- /dev/null
+++ b/src/test/run-pass/issue-20396.rs
@@ -0,0 +1,23 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![allow(dead_code)]
+
+trait Foo<T> {
+    fn noop(&self, _: T);
+}
+
+enum Bar<T> { Bla(T) }
+
+struct Baz<'a> {
+    inner: for<'b> Foo<Bar<&'b ()>> + 'a,
+}
+
+fn main() {}
diff --git a/src/test/run-pass/issue-20823.rs b/src/test/run-pass/issue-20823.rs
index 561b6195476..c297998b649 100644
--- a/src/test/run-pass/issue-20823.rs
+++ b/src/test/run-pass/issue-20823.rs
@@ -14,4 +14,4 @@
 #![deny(unstable)]
 
 #[test]
-fn foo() {}
+pub fn foo() {}
diff --git a/src/test/run-pass/issue-21520.rs b/src/test/run-pass/issue-21520.rs
index 3a813641a3f..6eed3574152 100644
--- a/src/test/run-pass/issue-21520.rs
+++ b/src/test/run-pass/issue-21520.rs
@@ -26,4 +26,3 @@ struct Bar<T:Foo>
 }
 
 fn main() { }
-
diff --git a/src/test/run-pass/issue-2214.rs b/src/test/run-pass/issue-2214.rs
index a319ee5e600..1dcbfd92fa0 100644
--- a/src/test/run-pass/issue-2214.rs
+++ b/src/test/run-pass/issue-2214.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/issue-22577.rs b/src/test/run-pass/issue-22577.rs
index 1ecdd39ca7a..f668cae66c6 100644
--- a/src/test/run-pass/issue-22577.rs
+++ b/src/test/run-pass/issue-22577.rs
@@ -25,5 +25,8 @@ fn main() {
     assert_both::<net::TcpListener>();
     assert_both::<net::UdpSocket>();
     assert_both::<net::SocketAddr>();
-    assert_both::<net::IpAddr>();
+    assert_both::<net::SocketAddrV4>();
+    assert_both::<net::SocketAddrV6>();
+    assert_both::<net::Ipv4Addr>();
+    assert_both::<net::Ipv6Addr>();
 }
diff --git a/src/test/run-pass/issue-2383.rs b/src/test/run-pass/issue-2383.rs
index a5a05283f80..9599a908950 100644
--- a/src/test/run-pass/issue-2383.rs
+++ b/src/test/run-pass/issue-2383.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs
index ae146d8d353..3a1178c2824 100644
--- a/src/test/run-pass/issue-2718.rs
+++ b/src/test/run-pass/issue-2718.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/issue-2804-2.rs b/src/test/run-pass/issue-2804-2.rs
index 952ea1e9d3d..4f89d28332a 100644
--- a/src/test/run-pass/issue-2804-2.rs
+++ b/src/test/run-pass/issue-2804-2.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/issue-2804.rs b/src/test/run-pass/issue-2804.rs
index 25b933b8f96..b9b5aec62fc 100644
--- a/src/test/run-pass/issue-2804.rs
+++ b/src/test/run-pass/issue-2804.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs
index b55f3691358..3f954c3c918 100644
--- a/src/test/run-pass/issue-2904.rs
+++ b/src/test/run-pass/issue-2904.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/issue-3026.rs b/src/test/run-pass/issue-3026.rs
index 98c9f3d5ec5..8da15496844 100644
--- a/src/test/run-pass/issue-3026.rs
+++ b/src/test/run-pass/issue-3026.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/issue-3979.rs b/src/test/run-pass/issue-3979.rs
index 4f69342830b..36939a2877e 100644
--- a/src/test/run-pass/issue-3979.rs
+++ b/src/test/run-pass/issue-3979.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/issue-4759.rs b/src/test/run-pass/issue-4759.rs
index 2245e80971a..142f088a684 100644
--- a/src/test/run-pass/issue-4759.rs
+++ b/src/test/run-pass/issue-4759.rs
@@ -25,4 +25,3 @@ pub fn main() {
     let T { a: a } = T { a: box 0 };
     a.f();
 }
-
diff --git a/src/test/run-pass/issue-5060.rs b/src/test/run-pass/issue-5060.rs
index 7c3b0a5f1f0..5726f236e2e 100644
--- a/src/test/run-pass/issue-5060.rs
+++ b/src/test/run-pass/issue-5060.rs
@@ -24,4 +24,3 @@ macro_rules! print_hd_tl {
 pub fn main() {
     print_hd_tl!(x, y, z, w)
 }
-
diff --git a/src/test/run-pass/issue-5666.rs b/src/test/run-pass/issue-5666.rs
index 4f304e3b436..e28a929d527 100644
--- a/src/test/run-pass/issue-5666.rs
+++ b/src/test/run-pass/issue-5666.rs
@@ -35,4 +35,3 @@ pub fn main() {
         println!("{}", pup.bark());
     }
 }
-
diff --git a/src/test/run-pass/issue-5950.rs b/src/test/run-pass/issue-5950.rs
index c9413258e0f..88bbba44bbe 100644
--- a/src/test/run-pass/issue-5950.rs
+++ b/src/test/run-pass/issue-5950.rs
@@ -11,6 +11,6 @@
 
 pub use local as local_alias;
 
-mod local { }
+pub mod local { }
 
 pub fn main() {}
diff --git a/src/test/run-pass/issue-6318.rs b/src/test/run-pass/issue-6318.rs
index 6e608d34bd5..61bc70465e0 100644
--- a/src/test/run-pass/issue-6318.rs
+++ b/src/test/run-pass/issue-6318.rs
@@ -28,4 +28,3 @@ pub fn main() {
         Thing::A(_a) => 0,
     };
 }
-
diff --git a/src/test/run-pass/issue-6919.rs b/src/test/run-pass/issue-6919.rs
index c684c4d897b..10dae96d88d 100644
--- a/src/test/run-pass/issue-6919.rs
+++ b/src/test/run-pass/issue-6919.rs
@@ -16,4 +16,3 @@ extern crate issue6919_3;
 pub fn main() {
     let _ = issue6919_3::D.k;
 }
-
diff --git a/src/test/run-pass/issue-7222.rs b/src/test/run-pass/issue-7222.rs
index 65ea895c2c8..0ca4e428bc4 100644
--- a/src/test/run-pass/issue-7222.rs
+++ b/src/test/run-pass/issue-7222.rs
@@ -16,4 +16,3 @@ pub fn main() {
         _ => ()
     }
 }
-
diff --git a/src/test/run-pass/issue-7607-2.rs b/src/test/run-pass/issue-7607-2.rs
index c52051fab96..a0408a03590 100644
--- a/src/test/run-pass/issue-7607-2.rs
+++ b/src/test/run-pass/issue-7607-2.rs
@@ -20,5 +20,3 @@ pub mod b {
 }
 
 pub fn main() { }
-
-
diff --git a/src/test/run-pass/issue-8248.rs b/src/test/run-pass/issue-8248.rs
index 7bc8dbe616f..3800564b867 100644
--- a/src/test/run-pass/issue-8248.rs
+++ b/src/test/run-pass/issue-8248.rs
@@ -20,4 +20,3 @@ pub fn main() {
     let mut b = B;
     foo(&mut b as &mut A);
 }
-
diff --git a/src/test/run-pass/issue-8249.rs b/src/test/run-pass/issue-8249.rs
index 83c9e9bf450..10d3ade648d 100644
--- a/src/test/run-pass/issue-8249.rs
+++ b/src/test/run-pass/issue-8249.rs
@@ -24,4 +24,3 @@ fn foo(a: &mut A) {
 
 pub fn main() {
 }
-
diff --git a/src/test/run-pass/issue-8398.rs b/src/test/run-pass/issue-8398.rs
index e52e3295c6e..f8065d0bcd3 100644
--- a/src/test/run-pass/issue-8398.rs
+++ b/src/test/run-pass/issue-8398.rs
@@ -15,4 +15,3 @@ fn foo(a: &mut old_io::Writer) {
 }
 
 pub fn main(){}
-
diff --git a/src/test/run-pass/issue-9188.rs b/src/test/run-pass/issue-9188.rs
index 31797deccf9..73d3b355935 100644
--- a/src/test/run-pass/issue-9188.rs
+++ b/src/test/run-pass/issue-9188.rs
@@ -17,4 +17,3 @@ pub fn main() {
     let b = issue_9188::foo::<int>();
     assert_eq!(*a, *b);
 }
-
diff --git a/src/test/run-pass/issue-9951.rs b/src/test/run-pass/issue-9951.rs
new file mode 100644
index 00000000000..210f647e5be
--- /dev/null
+++ b/src/test/run-pass/issue-9951.rs
@@ -0,0 +1,28 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![allow(unused_variables)]
+
+trait Bar {
+  fn noop(&self);
+}
+impl Bar for u8 {
+  fn noop(&self) {}
+}
+
+fn main() {
+    let (a, b) = (&5u8 as &Bar, &9u8 as &Bar);
+    let (c, d): (&Bar, &Bar) = (a, b);
+
+    let (a, b) = (Box::new(5u8) as Box<Bar>, Box::new(9u8) as Box<Bar>);
+    let (c, d): (&Bar, &Bar) = (&*a, &*b);
+
+    let (c, d): (&Bar, &Bar) = (&5, &9);
+}
diff --git a/src/test/run-pass/kindck-implicit-close-over-mut-var.rs b/src/test/run-pass/kindck-implicit-close-over-mut-var.rs
index f2d509ee61d..9d6ca1e9cfb 100644
--- a/src/test/run-pass/kindck-implicit-close-over-mut-var.rs
+++ b/src/test/run-pass/kindck-implicit-close-over-mut-var.rs
@@ -50,4 +50,3 @@ fn car() {
 }
 
 pub fn main() {}
-
diff --git a/src/test/run-pass/kinds-in-metadata.rs b/src/test/run-pass/kinds-in-metadata.rs
index 233db83d289..bd75f547507 100644
--- a/src/test/run-pass/kinds-in-metadata.rs
+++ b/src/test/run-pass/kinds-in-metadata.rs
@@ -22,4 +22,3 @@ use kinds_in_metadata::f;
 pub fn main() {
     f::<int>();
 }
-
diff --git a/src/test/run-pass/loop-label-shadowing.rs b/src/test/run-pass/loop-label-shadowing.rs
index d96ff869fa0..090872e69ea 100644
--- a/src/test/run-pass/loop-label-shadowing.rs
+++ b/src/test/run-pass/loop-label-shadowing.rs
@@ -16,4 +16,3 @@ fn main() {
         foo.push(*i);
     }
 }
-
diff --git a/src/test/run-pass/macro-delimiter-significance.rs b/src/test/run-pass/macro-delimiter-significance.rs
index 01362f0f83f..a2ae3fbf83b 100644
--- a/src/test/run-pass/macro-delimiter-significance.rs
+++ b/src/test/run-pass/macro-delimiter-significance.rs
@@ -11,4 +11,3 @@
 fn main() {
     vec![1_usize, 2, 3].len();
 }
-
diff --git a/src/test/run-pass/macro-meta-items.rs b/src/test/run-pass/macro-meta-items.rs
index 47e3a072399..605cade2b3f 100644
--- a/src/test/run-pass/macro-meta-items.rs
+++ b/src/test/run-pass/macro-meta-items.rs
@@ -38,4 +38,3 @@ pub fn main() {
     emit!(baz);
     println!("{}", MISTYPED);
 }
-
diff --git a/src/test/run-pass/macro-method-issue-4621.rs b/src/test/run-pass/macro-method-issue-4621.rs
index fd16958d896..c58a0301424 100644
--- a/src/test/run-pass/macro-method-issue-4621.rs
+++ b/src/test/run-pass/macro-method-issue-4621.rs
@@ -16,6 +16,3 @@ impl A { make_thirteen_method!(); }
 fn main() {
     assert_eq!(A.thirteen(),13);
 }
-
-
-
diff --git a/src/test/run-pass/macro-with-attrs2.rs b/src/test/run-pass/macro-with-attrs2.rs
index d683979462b..b56dff6b01f 100644
--- a/src/test/run-pass/macro-with-attrs2.rs
+++ b/src/test/run-pass/macro-with-attrs2.rs
@@ -17,4 +17,3 @@ macro_rules! foo { () => (2) }
 pub fn main() {
     assert_eq!(foo!(), 2);
 }
-
diff --git a/src/test/run-pass/method-normalize-bounds-issue-20604.rs b/src/test/run-pass/method-normalize-bounds-issue-20604.rs
index 73489948da5..5ba5d7f8d72 100644
--- a/src/test/run-pass/method-normalize-bounds-issue-20604.rs
+++ b/src/test/run-pass/method-normalize-bounds-issue-20604.rs
@@ -62,4 +62,3 @@ fn foo<K: Hash<SipHasher>>(map: &Map<SipState>) {
 }
 
 fn main() {}
-
diff --git a/src/test/run-pass/mid-path-type-params.rs b/src/test/run-pass/mid-path-type-params.rs
index 4a04a71f9a0..85c05d408e8 100644
--- a/src/test/run-pass/mid-path-type-params.rs
+++ b/src/test/run-pass/mid-path-type-params.rs
@@ -40,4 +40,3 @@ pub fn main() {
     let _ = S::<int>::new::<f64>(1, 1.0);
     let _: S2 = Trait::<int>::new::<f64>(1, 1.0);
 }
-
diff --git a/src/test/run-pass/mod-view-items.rs b/src/test/run-pass/mod-view-items.rs
index f03ec7b6f3e..1513eb88835 100644
--- a/src/test/run-pass/mod-view-items.rs
+++ b/src/test/run-pass/mod-view-items.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/namespaced-enum-emulate-flat-xc.rs b/src/test/run-pass/namespaced-enum-emulate-flat-xc.rs
index 680cdf14e8f..ea7e05d24e2 100644
--- a/src/test/run-pass/namespaced-enum-emulate-flat-xc.rs
+++ b/src/test/run-pass/namespaced-enum-emulate-flat-xc.rs
@@ -28,4 +28,3 @@ fn _f2(f: Bar) {
 }
 
 pub fn main() {}
-
diff --git a/src/test/run-pass/namespaced-enums-xcrate.rs b/src/test/run-pass/namespaced-enums-xcrate.rs
index 7545908dcbb..3b56d6c59a1 100644
--- a/src/test/run-pass/namespaced-enums-xcrate.rs
+++ b/src/test/run-pass/namespaced-enums-xcrate.rs
@@ -21,4 +21,3 @@ fn _foo (f: Foo) {
 }
 
 pub fn main() {}
-
diff --git a/src/test/run-pass/new-box.rs b/src/test/run-pass/new-box.rs
index 1f2207ad873..3e4665bb231 100644
--- a/src/test/run-pass/new-box.rs
+++ b/src/test/run-pass/new-box.rs
@@ -39,4 +39,3 @@ fn main() {
     f(box 1234);
     g(box Struct as Box<Trait>);
 }
-
diff --git a/src/test/run-pass/overloaded-calls-simple.rs b/src/test/run-pass/overloaded-calls-simple.rs
index f9e838d9b3d..d18a91c5452 100644
--- a/src/test/run-pass/overloaded-calls-simple.rs
+++ b/src/test/run-pass/overloaded-calls-simple.rs
@@ -70,4 +70,3 @@ fn main() {
     let ans = s(3, 1);
     assert_eq!(ans, 27);
 }
-
diff --git a/src/test/run-pass/overloaded-calls-zero-args.rs b/src/test/run-pass/overloaded-calls-zero-args.rs
index ce7395673b3..78e84b9d55b 100644
--- a/src/test/run-pass/overloaded-calls-zero-args.rs
+++ b/src/test/run-pass/overloaded-calls-zero-args.rs
@@ -32,5 +32,3 @@ fn main() {
     let ans = s();
     assert_eq!(ans, 9);
 }
-
-
diff --git a/src/test/run-pass/placement-new-arena.rs b/src/test/run-pass/placement-new-arena.rs
index 7ad93d271a9..c4cf8357baa 100644
--- a/src/test/run-pass/placement-new-arena.rs
+++ b/src/test/run-pass/placement-new-arena.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/ranges-precedence.rs b/src/test/run-pass/ranges-precedence.rs
index 41ed9a74d13..18afcdd7f3f 100644
--- a/src/test/run-pass/ranges-precedence.rs
+++ b/src/test/run-pass/ranges-precedence.rs
@@ -58,4 +58,3 @@ fn main() {
     let y = ..;
     assert!(y == (..));
 }
-
diff --git a/src/test/run-pass/self-shadowing-import.rs b/src/test/run-pass/self-shadowing-import.rs
index 19fdd04069e..47380287ab6 100644
--- a/src/test/run-pass/self-shadowing-import.rs
+++ b/src/test/run-pass/self-shadowing-import.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/sepcomp-fns-backwards.rs b/src/test/run-pass/sepcomp-fns-backwards.rs
index 61f008ad854..35a8c9330bf 100644
--- a/src/test/run-pass/sepcomp-fns-backwards.rs
+++ b/src/test/run-pass/sepcomp-fns-backwards.rs
@@ -38,4 +38,3 @@ fn main() {
     assert_eq!(a::two(), 2);
     assert_eq!(b::three(), 3);
 }
-
diff --git a/src/test/run-pass/sepcomp-statics.rs b/src/test/run-pass/sepcomp-statics.rs
index 26a5c4d1c50..0e8d33f74f8 100644
--- a/src/test/run-pass/sepcomp-statics.rs
+++ b/src/test/run-pass/sepcomp-statics.rs
@@ -36,4 +36,3 @@ fn main() {
     assert_eq!(a::TWO, 2);
     assert_eq!(b::THREE, 3);
 }
-
diff --git a/src/test/run-pass/struct-aliases-xcrate.rs b/src/test/run-pass/struct-aliases-xcrate.rs
index 9046cafe757..7d99a2d1dcf 100644
--- a/src/test/run-pass/struct-aliases-xcrate.rs
+++ b/src/test/run-pass/struct-aliases-xcrate.rs
@@ -28,4 +28,3 @@ fn main() {
         }
     }
 }
-
diff --git a/src/test/run-pass/struct-aliases.rs b/src/test/run-pass/struct-aliases.rs
index 2cf961a5c0c..2e24bb64bed 100644
--- a/src/test/run-pass/struct-aliases.rs
+++ b/src/test/run-pass/struct-aliases.rs
@@ -30,4 +30,3 @@ fn main() {
         }
     }
 }
-
diff --git a/src/test/run-pass/test-fn-signature-verification-for-explicit-return-type.rs b/src/test/run-pass/test-fn-signature-verification-for-explicit-return-type.rs
index 7c99c968e35..df3c9a0f119 100644
--- a/src/test/run-pass/test-fn-signature-verification-for-explicit-return-type.rs
+++ b/src/test/run-pass/test-fn-signature-verification-for-explicit-return-type.rs
@@ -13,8 +13,7 @@
 extern crate test;
 
 #[bench]
-fn bench_explicit_return_type(_: &mut ::test::Bencher) -> () {}
+pub fn bench_explicit_return_type(_: &mut ::test::Bencher) -> () {}
 
 #[test]
-fn test_explicit_return_type() -> () {}
-
+pub fn test_explicit_return_type() -> () {}
diff --git a/src/test/run-pass/test-should-fail-good-message.rs b/src/test/run-pass/test-should-fail-good-message.rs
index b8e05b4d35a..28698499303 100644
--- a/src/test/run-pass/test-should-fail-good-message.rs
+++ b/src/test/run-pass/test-should-fail-good-message.rs
@@ -13,14 +13,12 @@
 
 #[test]
 #[should_panic(expected = "foo")]
-fn test_foo() {
+pub fn test_foo() {
     panic!("foo bar")
 }
 
 #[test]
 #[should_panic(expected = "foo")]
-fn test_foo_dynamic() {
+pub fn test_foo_dynamic() {
     panic!("{} bar", "foo")
 }
-
-
diff --git a/src/test/run-pass/trait-bounds-impl-comparison-duplicates.rs b/src/test/run-pass/trait-bounds-impl-comparison-duplicates.rs
index 5b744a44132..5c913f7921d 100644
--- a/src/test/run-pass/trait-bounds-impl-comparison-duplicates.rs
+++ b/src/test/run-pass/trait-bounds-impl-comparison-duplicates.rs
@@ -21,5 +21,3 @@ impl A for int {
 }
 
 fn main() {}
-
-
diff --git a/src/test/run-pass/trait-coercion-generic.rs b/src/test/run-pass/trait-coercion-generic.rs
index 1565ccfe459..96203ba4779 100644
--- a/src/test/run-pass/trait-coercion-generic.rs
+++ b/src/test/run-pass/trait-coercion-generic.rs
@@ -32,4 +32,3 @@ pub fn main() {
     let c: &Trait<&'static str> = &a;
     c.f("Joe");
 }
-
diff --git a/src/test/run-pass/trait-coercion.rs b/src/test/run-pass/trait-coercion.rs
index 6db7113b050..b02f8eb0aa9 100644
--- a/src/test/run-pass/trait-coercion.rs
+++ b/src/test/run-pass/trait-coercion.rs
@@ -45,4 +45,3 @@ pub fn main() {
     let out = old_io::stdout();
     foo(Box::new(out));
 }
-
diff --git a/src/test/run-pass/trait-contravariant-self.rs b/src/test/run-pass/trait-contravariant-self.rs
index 19d76b88901..17c68d64948 100644
--- a/src/test/run-pass/trait-contravariant-self.rs
+++ b/src/test/run-pass/trait-contravariant-self.rs
@@ -38,5 +38,3 @@ fn main() {
     let x: Box<Foo+Send> = (box SFoo);
     wants_bar(&x);
 }
-
-
diff --git a/src/test/run-pass/trait-inheritance-num.rs b/src/test/run-pass/trait-inheritance-num.rs
index 9a30d51f4c5..5fb28eb9d8d 100644
--- a/src/test/run-pass/trait-inheritance-num.rs
+++ b/src/test/run-pass/trait-inheritance-num.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/trait-inheritance-num0.rs b/src/test/run-pass/trait-inheritance-num0.rs
index d68b6a54f71..183d6659062 100644
--- a/src/test/run-pass/trait-inheritance-num0.rs
+++ b/src/test/run-pass/trait-inheritance-num0.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/trait-inheritance-num2.rs b/src/test/run-pass/trait-inheritance-num2.rs
index f89eea46090..1fb28c50652 100644
--- a/src/test/run-pass/trait-inheritance-num2.rs
+++ b/src/test/run-pass/trait-inheritance-num2.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/trait-static-method-overwriting.rs b/src/test/run-pass/trait-static-method-overwriting.rs
index 10439d5c86a..31968da6ee3 100644
--- a/src/test/run-pass/trait-static-method-overwriting.rs
+++ b/src/test/run-pass/trait-static-method-overwriting.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/ufcs-explicit-self.rs b/src/test/run-pass/ufcs-explicit-self.rs
index 832c1f8802d..810148b012d 100644
--- a/src/test/run-pass/ufcs-explicit-self.rs
+++ b/src/test/run-pass/ufcs-explicit-self.rs
@@ -57,4 +57,3 @@ fn main() {
     let bar: Box<Bar<int>> = bar;
     println!("{} {} {}", bar.foo(2), bar.bar(2), bar.baz(2));
 }
-
diff --git a/src/test/run-pass/unboxed-closures-all-traits.rs b/src/test/run-pass/unboxed-closures-all-traits.rs
index 7e71e1da462..b4b0d2b0148 100644
--- a/src/test/run-pass/unboxed-closures-all-traits.rs
+++ b/src/test/run-pass/unboxed-closures-all-traits.rs
@@ -28,4 +28,3 @@ fn main() {
     assert_eq!(b(move |x: int, y| x + y + z), 14);
     assert_eq!(c(move |x: int, y| x + y + z), 18);
 }
-
diff --git a/src/test/run-pass/unboxed-closures-boxed.rs b/src/test/run-pass/unboxed-closures-boxed.rs
index d515ccf2ec0..5dea6a7c6db 100644
--- a/src/test/run-pass/unboxed-closures-boxed.rs
+++ b/src/test/run-pass/unboxed-closures-boxed.rs
@@ -25,4 +25,3 @@ pub fn main() {
     println!("{}", z);
     assert_eq!(z, 5);
 }
-
diff --git a/src/test/run-pass/unboxed-closures-call-sugar-object-autoderef.rs b/src/test/run-pass/unboxed-closures-call-sugar-object-autoderef.rs
index 52311544297..271381f520e 100644
--- a/src/test/run-pass/unboxed-closures-call-sugar-object-autoderef.rs
+++ b/src/test/run-pass/unboxed-closures-call-sugar-object-autoderef.rs
@@ -26,4 +26,3 @@ pub fn main() {
     println!("{}", z);
     assert_eq!(z, 5);
 }
-
diff --git a/src/test/run-pass/unboxed-closures-call-sugar-object.rs b/src/test/run-pass/unboxed-closures-call-sugar-object.rs
index a34799fdcc5..e51e35d2c65 100644
--- a/src/test/run-pass/unboxed-closures-call-sugar-object.rs
+++ b/src/test/run-pass/unboxed-closures-call-sugar-object.rs
@@ -24,4 +24,3 @@ pub fn main() {
     println!("{}", z);
     assert_eq!(z, 5);
 }
-
diff --git a/src/test/run-pass/unboxed-closures-direct-sugary-call.rs b/src/test/run-pass/unboxed-closures-direct-sugary-call.rs
index 0c49c815170..6b2dcfa69b4 100644
--- a/src/test/run-pass/unboxed-closures-direct-sugary-call.rs
+++ b/src/test/run-pass/unboxed-closures-direct-sugary-call.rs
@@ -14,4 +14,3 @@ fn main() {
     let mut unboxed = || {};
     unboxed();
 }
-
diff --git a/src/test/run-pass/unboxed-closures-drop.rs b/src/test/run-pass/unboxed-closures-drop.rs
index f4a24c17e6e..e61d454023f 100644
--- a/src/test/run-pass/unboxed-closures-drop.rs
+++ b/src/test/run-pass/unboxed-closures-drop.rs
@@ -124,4 +124,3 @@ fn main() {
     test_fn_mut();
     test_fn_once();
 }
-
diff --git a/src/test/run-pass/unboxed-closures-extern-fn-hr.rs b/src/test/run-pass/unboxed-closures-extern-fn-hr.rs
index df753f0f33e..6a071f6a4c5 100644
--- a/src/test/run-pass/unboxed-closures-extern-fn-hr.rs
+++ b/src/test/run-pass/unboxed-closures-extern-fn-hr.rs
@@ -42,4 +42,3 @@ fn main() {
     assert_eq!(y, square(&22));
     assert_eq!(z, square(&22));
 }
-
diff --git a/src/test/run-pass/unboxed-closures-extern-fn.rs b/src/test/run-pass/unboxed-closures-extern-fn.rs
index a25f5e265e8..ed941ac0fdb 100644
--- a/src/test/run-pass/unboxed-closures-extern-fn.rs
+++ b/src/test/run-pass/unboxed-closures-extern-fn.rs
@@ -37,4 +37,3 @@ fn main() {
     assert_eq!(y, square(22));
     assert_eq!(z, square(22));
 }
-
diff --git a/src/test/run-pass/unboxed-closures-fn-as-fnmut-and-fnonce.rs b/src/test/run-pass/unboxed-closures-fn-as-fnmut-and-fnonce.rs
index 5d6029e703b..0aab5be2877 100644
--- a/src/test/run-pass/unboxed-closures-fn-as-fnmut-and-fnonce.rs
+++ b/src/test/run-pass/unboxed-closures-fn-as-fnmut-and-fnonce.rs
@@ -44,4 +44,3 @@ fn main() {
     assert_eq!(x, y);
     assert_eq!(y, z);
 }
-
diff --git a/src/test/run-pass/unboxed-closures-fnmut-as-fnonce.rs b/src/test/run-pass/unboxed-closures-fnmut-as-fnonce.rs
index 95dae41c684..a8bb0918932 100644
--- a/src/test/run-pass/unboxed-closures-fnmut-as-fnonce.rs
+++ b/src/test/run-pass/unboxed-closures-fnmut-as-fnonce.rs
@@ -39,4 +39,3 @@ fn main() {
     let z = call_it_once(S, 22);
     assert_eq!(y, z);
 }
-
diff --git a/src/test/run-pass/unboxed-closures-generic.rs b/src/test/run-pass/unboxed-closures-generic.rs
index f4af42a866b..47936ba9382 100644
--- a/src/test/run-pass/unboxed-closures-generic.rs
+++ b/src/test/run-pass/unboxed-closures-generic.rs
@@ -22,4 +22,3 @@ pub fn main() {
     println!("{}", z);
     assert_eq!(z, 5);
 }
-
diff --git a/src/test/run-pass/unboxed-closures-infer-fnmut-calling-fnmut.rs b/src/test/run-pass/unboxed-closures-infer-fnmut-calling-fnmut.rs
index 09b8c8f4454..17833033492 100644
--- a/src/test/run-pass/unboxed-closures-infer-fnmut-calling-fnmut.rs
+++ b/src/test/run-pass/unboxed-closures-infer-fnmut-calling-fnmut.rs
@@ -26,4 +26,3 @@ fn main() {
 
     assert_eq!(counter, 2);
 }
-
diff --git a/src/test/run-pass/unboxed-closures-manual-impl.rs b/src/test/run-pass/unboxed-closures-manual-impl.rs
index 37075de0405..f1b79a1829e 100644
--- a/src/test/run-pass/unboxed-closures-manual-impl.rs
+++ b/src/test/run-pass/unboxed-closures-manual-impl.rs
@@ -1,4 +1,3 @@
-
 // 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.
@@ -37,4 +36,3 @@ fn main() {
     assert!(x == 4);
     assert!(y == 4);
 }
-
diff --git a/src/test/run-pass/unboxed-closures-prelude.rs b/src/test/run-pass/unboxed-closures-prelude.rs
index 16a55ab550d..4ed3fa5ca2d 100644
--- a/src/test/run-pass/unboxed-closures-prelude.rs
+++ b/src/test/run-pass/unboxed-closures-prelude.rs
@@ -28,4 +28,3 @@ fn main() {
 fn call<F:FnOnce(int) -> int>(f: F, x: int) -> int {
     f(x)
 }
-
diff --git a/src/test/run-pass/unboxed-closures-single-word-env.rs b/src/test/run-pass/unboxed-closures-single-word-env.rs
index 9e543f925f8..84544d6d24b 100644
--- a/src/test/run-pass/unboxed-closures-single-word-env.rs
+++ b/src/test/run-pass/unboxed-closures-single-word-env.rs
@@ -31,4 +31,3 @@ fn main() {
     assert_eq!(b(move |x: int, y| x + y + z), 17);
     assert_eq!(c(move |x: int, y| x + y + z), 21);
 }
-
diff --git a/src/test/run-pass/unboxed-closures-static-call-fn-once.rs b/src/test/run-pass/unboxed-closures-static-call-fn-once.rs
index 7a6b68a5e09..1f5481ccde9 100644
--- a/src/test/run-pass/unboxed-closures-static-call-fn-once.rs
+++ b/src/test/run-pass/unboxed-closures-static-call-fn-once.rs
@@ -14,4 +14,3 @@ fn main() {
     let onetime = |x| x;
     onetime(0);
 }
-
diff --git a/src/test/run-pass/unboxed-closures-zero-args.rs b/src/test/run-pass/unboxed-closures-zero-args.rs
index 8e3d44df798..c81b0515aec 100644
--- a/src/test/run-pass/unboxed-closures-zero-args.rs
+++ b/src/test/run-pass/unboxed-closures-zero-args.rs
@@ -14,4 +14,3 @@ fn main() {
     let mut zero = || {};
     let () = zero();
 }
-
diff --git a/src/test/run-pass/use.rs b/src/test/run-pass/use.rs
index 65a392e63c5..c25cd15b2cd 100644
--- a/src/test/run-pass/use.rs
+++ b/src/test/run-pass/use.rs
@@ -1,4 +1,3 @@
-
 // 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.
diff --git a/src/test/run-pass/variance-trait-matching.rs b/src/test/run-pass/variance-trait-matching.rs
index 10441bee3cb..d46ffa80183 100644
--- a/src/test/run-pass/variance-trait-matching.rs
+++ b/src/test/run-pass/variance-trait-matching.rs
@@ -45,5 +45,3 @@ fn main() {
     let y = get(&x);
     assert_eq!(y, 23);
 }
-
-
diff --git a/src/test/run-pass/visible-private-types-feature-gate.rs b/src/test/run-pass/visible-private-types-feature-gate.rs
index 46e93b25697..3060c12d39a 100644
--- a/src/test/run-pass/visible-private-types-feature-gate.rs
+++ b/src/test/run-pass/visible-private-types-feature-gate.rs
@@ -19,4 +19,3 @@ struct Baz;
 pub fn f(_: Baz) {}
 
 fn main() {}
-
diff --git a/src/test/run-pass/where-clause-method-substituion.rs b/src/test/run-pass/where-clause-method-substituion.rs
index ecc210ea579..e2280f0b07b 100644
--- a/src/test/run-pass/where-clause-method-substituion.rs
+++ b/src/test/run-pass/where-clause-method-substituion.rs
@@ -27,4 +27,3 @@ impl Bar<X> for i32 {
 fn main() {
     1.method::<S>();
 }
-
diff --git a/src/test/run-pass/where-clauses-cross-crate.rs b/src/test/run-pass/where-clauses-cross-crate.rs
index b822abd6732..6a2fec7260a 100644
--- a/src/test/run-pass/where-clauses-cross-crate.rs
+++ b/src/test/run-pass/where-clauses-cross-crate.rs
@@ -20,4 +20,3 @@ fn main() {
     println!("{}", "hello".equal(&"hello"));
     println!("{}", "hello".equals::<int,&str>(&1, &1, &"foo", &"bar"));
 }
-
diff --git a/src/test/run-pass/where-clauses-unboxed-closures.rs b/src/test/run-pass/where-clauses-unboxed-closures.rs
index 7edcdf64292..dbff4b9599b 100644
--- a/src/test/run-pass/where-clauses-unboxed-closures.rs
+++ b/src/test/run-pass/where-clauses-unboxed-closures.rs
@@ -23,4 +23,3 @@ fn main() {
     // OK
     warm_up(|b| () );
 }
-
diff --git a/src/test/run-pass/where-clauses.rs b/src/test/run-pass/where-clauses.rs
index 92bc7edf285..0f0741dcea7 100644
--- a/src/test/run-pass/where-clauses.rs
+++ b/src/test/run-pass/where-clauses.rs
@@ -34,4 +34,3 @@ fn main() {
     println!("{}", "hello".equal(&"hello"));
     println!("{}", "hello".equals::<int,&str>(&1, &1, &"foo", &"bar"));
 }
-
diff --git a/src/test/run-pass/where-for-self.rs b/src/test/run-pass/where-for-self.rs
index 67757d7efa8..4e841029a6b 100644
--- a/src/test/run-pass/where-for-self.rs
+++ b/src/test/run-pass/where-for-self.rs
@@ -62,4 +62,3 @@ fn main() {
         assert!(COUNT == 12);
     }
 }
-